@@ -573,22 +573,18 @@ int vnic_dev_raise_intr(struct vnic_dev *vdev, u16 intr)
573573 return err ;
574574}
575575
576- int vnic_dev_notify_set (struct vnic_dev * vdev , u16 intr )
576+ int vnic_dev_notify_setcmd (struct vnic_dev * vdev ,
577+ void * notify_addr , dma_addr_t notify_pa , u16 intr )
577578{
578579 u64 a0 , a1 ;
579580 int wait = 1000 ;
580581 int r ;
581582
582- if (!vdev -> notify ) {
583- vdev -> notify = pci_alloc_consistent (vdev -> pdev ,
584- sizeof (struct vnic_devcmd_notify ),
585- & vdev -> notify_pa );
586- if (!vdev -> notify )
587- return - ENOMEM ;
588- memset (vdev -> notify , 0 , sizeof (struct vnic_devcmd_notify ));
589- }
583+ memset (notify_addr , 0 , sizeof (struct vnic_devcmd_notify ));
584+ vdev -> notify = notify_addr ;
585+ vdev -> notify_pa = notify_pa ;
590586
591- a0 = vdev -> notify_pa ;
587+ a0 = ( u64 ) notify_pa ;
592588 a1 = ((u64 )intr << 32 ) & 0x0000ffff00000000ULL ;
593589 a1 += sizeof (struct vnic_devcmd_notify );
594590
@@ -597,7 +593,27 @@ int vnic_dev_notify_set(struct vnic_dev *vdev, u16 intr)
597593 return r ;
598594}
599595
600- void vnic_dev_notify_unset (struct vnic_dev * vdev )
596+ int vnic_dev_notify_set (struct vnic_dev * vdev , u16 intr )
597+ {
598+ void * notify_addr ;
599+ dma_addr_t notify_pa ;
600+
601+ if (vdev -> notify || vdev -> notify_pa ) {
602+ printk (KERN_ERR "notify block %p still allocated" ,
603+ vdev -> notify );
604+ return - EINVAL ;
605+ }
606+
607+ notify_addr = pci_alloc_consistent (vdev -> pdev ,
608+ sizeof (struct vnic_devcmd_notify ),
609+ & notify_pa );
610+ if (!notify_addr )
611+ return - ENOMEM ;
612+
613+ return vnic_dev_notify_setcmd (vdev , notify_addr , notify_pa , intr );
614+ }
615+
616+ void vnic_dev_notify_unsetcmd (struct vnic_dev * vdev )
601617{
602618 u64 a0 , a1 ;
603619 int wait = 1000 ;
@@ -607,9 +623,23 @@ void vnic_dev_notify_unset(struct vnic_dev *vdev)
607623 a1 += sizeof (struct vnic_devcmd_notify );
608624
609625 vnic_dev_cmd (vdev , CMD_NOTIFY , & a0 , & a1 , wait );
626+ vdev -> notify = NULL ;
627+ vdev -> notify_pa = 0 ;
610628 vdev -> notify_sz = 0 ;
611629}
612630
631+ void vnic_dev_notify_unset (struct vnic_dev * vdev )
632+ {
633+ if (vdev -> notify ) {
634+ pci_free_consistent (vdev -> pdev ,
635+ sizeof (struct vnic_devcmd_notify ),
636+ vdev -> notify ,
637+ vdev -> notify_pa );
638+ }
639+
640+ vnic_dev_notify_unsetcmd (vdev );
641+ }
642+
613643static int vnic_dev_notify_ready (struct vnic_dev * vdev )
614644{
615645 u32 * words ;
0 commit comments