@@ -64,6 +64,13 @@ struct vmci_guest_device {
6464 dma_addr_t notification_base ;
6565};
6666
67+ static bool use_ppn64 ;
68+
69+ bool vmci_use_ppn64 (void )
70+ {
71+ return use_ppn64 ;
72+ }
73+
6774/* vmci_dev singleton device and supporting data*/
6875struct pci_dev * vmci_pdev ;
6976static struct vmci_guest_device * vmci_dev_g ;
@@ -432,6 +439,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
432439 struct vmci_guest_device * vmci_dev ;
433440 void __iomem * iobase ;
434441 unsigned int capabilities ;
442+ unsigned int caps_in_use ;
435443 unsigned long cmd ;
436444 int vmci_err ;
437445 int error ;
@@ -496,6 +504,23 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
496504 error = - ENXIO ;
497505 goto err_free_data_buffer ;
498506 }
507+ caps_in_use = VMCI_CAPS_DATAGRAM ;
508+
509+ /*
510+ * Use 64-bit PPNs if the device supports.
511+ *
512+ * There is no check for the return value of dma_set_mask_and_coherent
513+ * since this driver can handle the default mask values if
514+ * dma_set_mask_and_coherent fails.
515+ */
516+ if (capabilities & VMCI_CAPS_PPN64 ) {
517+ dma_set_mask_and_coherent (& pdev -> dev , DMA_BIT_MASK (64 ));
518+ use_ppn64 = true;
519+ caps_in_use |= VMCI_CAPS_PPN64 ;
520+ } else {
521+ dma_set_mask_and_coherent (& pdev -> dev , DMA_BIT_MASK (44 ));
522+ use_ppn64 = false;
523+ }
499524
500525 /*
501526 * If the hardware supports notifications, we will use that as
@@ -510,14 +535,14 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
510535 "Unable to allocate notification bitmap\n" );
511536 } else {
512537 memset (vmci_dev -> notification_bitmap , 0 , PAGE_SIZE );
513- capabilities |= VMCI_CAPS_NOTIFICATIONS ;
538+ caps_in_use |= VMCI_CAPS_NOTIFICATIONS ;
514539 }
515540 }
516541
517- dev_info (& pdev -> dev , "Using capabilities 0x%x\n" , capabilities );
542+ dev_info (& pdev -> dev , "Using capabilities 0x%x\n" , caps_in_use );
518543
519544 /* Let the host know which capabilities we intend to use. */
520- iowrite32 (capabilities , vmci_dev -> iobase + VMCI_CAPS_ADDR );
545+ iowrite32 (caps_in_use , vmci_dev -> iobase + VMCI_CAPS_ADDR );
521546
522547 /* Set up global device so that we can start sending datagrams */
523548 spin_lock_irq (& vmci_dev_spinlock );
@@ -529,13 +554,13 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
529554 * Register notification bitmap with device if that capability is
530555 * used.
531556 */
532- if (capabilities & VMCI_CAPS_NOTIFICATIONS ) {
557+ if (caps_in_use & VMCI_CAPS_NOTIFICATIONS ) {
533558 unsigned long bitmap_ppn =
534559 vmci_dev -> notification_base >> PAGE_SHIFT ;
535560 if (!vmci_dbell_register_notification_bitmap (bitmap_ppn )) {
536561 dev_warn (& pdev -> dev ,
537- "VMCI device unable to register notification bitmap with PPN 0x%x \n" ,
538- ( u32 ) bitmap_ppn );
562+ "VMCI device unable to register notification bitmap with PPN 0x%lx \n" ,
563+ bitmap_ppn );
539564 error = - ENXIO ;
540565 goto err_remove_vmci_dev_g ;
541566 }
@@ -611,7 +636,7 @@ static int vmci_guest_probe_device(struct pci_dev *pdev,
611636
612637 /* Enable specific interrupt bits. */
613638 cmd = VMCI_IMR_DATAGRAM ;
614- if (capabilities & VMCI_CAPS_NOTIFICATIONS )
639+ if (caps_in_use & VMCI_CAPS_NOTIFICATIONS )
615640 cmd |= VMCI_IMR_NOTIFICATION ;
616641 iowrite32 (cmd , vmci_dev -> iobase + VMCI_IMR_ADDR );
617642
0 commit comments