All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: Juergen Gross <jgross@suse.com>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Subject: [PATCH 15/18] xen/scsifront: use xenbus_setup_ring() and xenbus_teardown_ring()
Date: Wed, 20 Apr 2022 17:09:39 +0200	[thread overview]
Message-ID: <20220420150942.31235-16-jgross@suse.com> (raw)
In-Reply-To: <20220420150942.31235-1-jgross@suse.com>

Simplify scsifront's ring creation and removal via xenbus_setup_ring()
and xenbus_teardown_ring().

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 drivers/scsi/xen-scsifront.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 9db2366fa2d4..f15a35750040 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -798,28 +798,17 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
 {
 	struct xenbus_device *dev = info->dev;
 	struct vscsiif_sring *sring;
-	grant_ref_t gref;
-	int err = -ENOMEM;
+	int err;
 
 	/***** Frontend to Backend ring start *****/
-	sring = (struct vscsiif_sring *)__get_free_page(GFP_KERNEL);
-	if (!sring) {
-		xenbus_dev_fatal(dev, err,
-			"fail to allocate shared ring (Front to Back)");
+	err = xenbus_setup_ring(dev, GFP_KERNEL, (void **)&sring, 1,
+				&info->ring_ref);
+	if (err)
 		return err;
-	}
+
 	SHARED_RING_INIT(sring);
 	FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE);
 
-	err = xenbus_grant_ring(dev, sring, 1, &gref);
-	if (err < 0) {
-		free_page((unsigned long)sring);
-		xenbus_dev_fatal(dev, err,
-			"fail to grant shared ring (Front to Back)");
-		return err;
-	}
-	info->ring_ref = gref;
-
 	err = xenbus_alloc_evtchn(dev, &info->evtchn);
 	if (err) {
 		xenbus_dev_fatal(dev, err, "xenbus_alloc_evtchn");
@@ -847,8 +836,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
 free_irq:
 	unbind_from_irqhandler(info->irq, info);
 free_gnttab:
-	gnttab_end_foreign_access(info->ring_ref,
-				  (unsigned long)info->ring.sring);
+	xenbus_teardown_ring((void **)&sring, 1, &info->ring_ref);
 
 	return err;
 }
@@ -856,8 +844,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *info)
 static void scsifront_free_ring(struct vscsifrnt_info *info)
 {
 	unbind_from_irqhandler(info->irq, info);
-	gnttab_end_foreign_access(info->ring_ref,
-				  (unsigned long)info->ring.sring);
+	xenbus_teardown_ring((void **)&info->ring.sring, 1, &info->ring_ref);
 }
 
 static int scsifront_init_ring(struct vscsifrnt_info *info)
-- 
2.34.1


  parent reply	other threads:[~2022-04-20 15:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:09 [PATCH 00/18] xen: simplify frontend side ring setup Juergen Gross
2022-04-20 15:09 ` Juergen Gross
2022-04-20 15:09 ` Juergen Gross
2022-04-20 15:09 ` [PATCH 01/18] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Juergen Gross
2022-04-20 15:09 ` [PATCH 02/18] xen/netfront: switch netfront " Juergen Gross
2022-04-20 15:09 ` [PATCH 03/18] xen/scsifront: remove unused GRANT_INVALID_REF definition Juergen Gross
2022-04-20 15:09 ` [PATCH 04/18] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Juergen Gross
2022-04-20 15:34   ` Greg Kroah-Hartman
2022-04-20 15:09 ` [PATCH 05/18] xen/drm: switch xen_drm_front " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 06/18] xen/sound: switch xen_snd_front " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 07/18] xen/dmabuf: switch gntdev-dmabuf " Juergen Gross
2022-04-20 15:09 ` [PATCH 08/18] xen/shbuf: switch xen-front-pgdir-shbuf " Juergen Gross
2022-04-20 15:09 ` [PATCH 09/18] xen/xenbus: add xenbus_setup_ring() service function Juergen Gross
2022-04-20 18:44   ` Boris Ostrovsky
2022-04-21  7:57     ` Juergen Gross
2022-04-20 15:09 ` [PATCH 10/18] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Juergen Gross
2022-04-20 15:09 ` [PATCH 11/18] xen/netfront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 12/18] xen/tpmfront: " Juergen Gross
2022-04-20 15:09 ` [PATCH 13/18] xen/drmfront: " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 14/18] xen/pcifront: " Juergen Gross
2022-04-20 15:09 ` Juergen Gross [this message]
2022-04-20 15:09 ` [PATCH 16/18] xen/usbfront: " Juergen Gross
2022-04-20 15:35   ` Greg Kroah-Hartman
2022-04-20 15:09 ` [PATCH 17/18] xen/sndfront: " Juergen Gross
2022-04-20 15:09   ` Juergen Gross
2022-04-20 15:09 ` [PATCH 18/18] xen/xenbus: eliminate xenbus_grant_ring() Juergen Gross
2022-04-20 15:22   ` Andrew Cooper
2022-04-20 15:33     ` Juergen Gross

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420150942.31235-16-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.