Skip to content

Commit 0e6b139

Browse files
committed
xen/pcifront: use xenbus_setup_ring() and xenbus_teardown_ring()
Simplify pcifront's shared page creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross <[email protected]> Reviewed-by: Boris Ostrovsky <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent ae19265 commit 0e6b139

File tree

1 file changed

+3
-16
lines changed

1 file changed

+3
-16
lines changed

drivers/pci/xen-pcifront.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -709,9 +709,8 @@ static struct pcifront_device *alloc_pdev(struct xenbus_device *xdev)
709709
if (pdev == NULL)
710710
goto out;
711711

712-
pdev->sh_info =
713-
(struct xen_pci_sharedinfo *)__get_free_page(GFP_KERNEL);
714-
if (pdev->sh_info == NULL) {
712+
if (xenbus_setup_ring(xdev, GFP_KERNEL, (void **)&pdev->sh_info, 1,
713+
&pdev->gnt_ref)) {
715714
kfree(pdev);
716715
pdev = NULL;
717716
goto out;
@@ -729,7 +728,6 @@ static struct pcifront_device *alloc_pdev(struct xenbus_device *xdev)
729728
spin_lock_init(&pdev->sh_info_lock);
730729

731730
pdev->evtchn = INVALID_EVTCHN;
732-
pdev->gnt_ref = INVALID_GRANT_REF;
733731
pdev->irq = -1;
734732

735733
INIT_WORK(&pdev->op_work, pcifront_do_aer);
@@ -754,11 +752,7 @@ static void free_pdev(struct pcifront_device *pdev)
754752
if (pdev->evtchn != INVALID_EVTCHN)
755753
xenbus_free_evtchn(pdev->xdev, pdev->evtchn);
756754

757-
if (pdev->gnt_ref != INVALID_GRANT_REF)
758-
gnttab_end_foreign_access(pdev->gnt_ref,
759-
(unsigned long)pdev->sh_info);
760-
else
761-
free_page((unsigned long)pdev->sh_info);
755+
xenbus_teardown_ring((void **)&pdev->sh_info, 1, &pdev->gnt_ref);
762756

763757
dev_set_drvdata(&pdev->xdev->dev, NULL);
764758

@@ -769,13 +763,6 @@ static int pcifront_publish_info(struct pcifront_device *pdev)
769763
{
770764
int err = 0;
771765
struct xenbus_transaction trans;
772-
grant_ref_t gref;
773-
774-
err = xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref);
775-
if (err < 0)
776-
goto out;
777-
778-
pdev->gnt_ref = gref;
779766

780767
err = xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn);
781768
if (err)

0 commit comments

Comments
 (0)