From: Juergen Gross <jgross@suse.com> To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Juergen Gross <jgross@suse.com>, David Airlie <airlied@linux.ie>, Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Subject: [PATCH 13/18] xen/drmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:37 +0200 [thread overview] Message-ID: <20220420150942.31235-14-jgross@suse.com> (raw) In-Reply-To: <20220420150942.31235-1-jgross@suse.com> Simplify drmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross <jgross@suse.com> --- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 40 ++++++--------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c index 4006568b9e32..9b16ea9f523b 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -123,12 +123,12 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id) static void evtchnl_free(struct xen_drm_front_info *front_info, struct xen_drm_front_evtchnl *evtchnl) { - unsigned long page = 0; + void *page = NULL; if (evtchnl->type == EVTCHNL_TYPE_REQ) - page = (unsigned long)evtchnl->u.req.ring.sring; + page = evtchnl->u.req.ring.sring; else if (evtchnl->type == EVTCHNL_TYPE_EVT) - page = (unsigned long)evtchnl->u.evt.page; + page = evtchnl->u.evt.page; if (!page) return; @@ -147,8 +147,7 @@ static void evtchnl_free(struct xen_drm_front_info *front_info, xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); /* end access and free the page */ - if (evtchnl->gref != INVALID_GRANT_REF) - gnttab_end_foreign_access(evtchnl->gref, page); + xenbus_teardown_ring(&page, 1, &evtchnl->gref); memset(evtchnl, 0, sizeof(*evtchnl)); } @@ -158,8 +157,7 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index, enum xen_drm_front_evtchnl_type type) { struct xenbus_device *xb_dev = front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; int ret; @@ -168,44 +166,26 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index, evtchnl->index = index; evtchnl->front_info = front_info; evtchnl->state = EVTCHNL_STATE_DISCONNECTED; - evtchnl->gref = INVALID_GRANT_REF; - page = get_zeroed_page(GFP_NOIO | __GFP_HIGH); - if (!page) { - ret = -ENOMEM; + ret = xenbus_setup_ring(xb_dev, GFP_NOIO | __GFP_HIGH, &page, + 1, &evtchnl->gref); + if (ret) goto fail; - } if (type == EVTCHNL_TYPE_REQ) { struct xen_displif_sring *sring; init_completion(&evtchnl->u.req.completion); mutex_init(&evtchnl->u.req.req_io_lock); - sring = (struct xen_displif_sring *)page; + sring = page; SHARED_RING_INIT(sring); FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); - ret = xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - evtchnl->u.req.ring.sring = NULL; - free_page(page); - goto fail; - } - handler = evtchnl_interrupt_ctrl; } else { - ret = gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) { - free_page(page); - goto fail; - } - - evtchnl->u.evt.page = (struct xendispl_event_page *)page; - gref = ret; + evtchnl->u.evt.page = page; handler = evtchnl_interrupt_evt; } - evtchnl->gref = gref; ret = xenbus_alloc_evtchn(xb_dev, &evtchnl->port); if (ret < 0) -- 2.34.1
WARNING: multiple messages have this Message-ID (diff)
From: Juergen Gross <jgross@suse.com> To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Juergen Gross <jgross@suse.com>, Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch> Subject: [PATCH 13/18] xen/drmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:37 +0200 [thread overview] Message-ID: <20220420150942.31235-14-jgross@suse.com> (raw) In-Reply-To: <20220420150942.31235-1-jgross@suse.com> Simplify drmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross <jgross@suse.com> --- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 40 ++++++--------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c index 4006568b9e32..9b16ea9f523b 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -123,12 +123,12 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, void *dev_id) static void evtchnl_free(struct xen_drm_front_info *front_info, struct xen_drm_front_evtchnl *evtchnl) { - unsigned long page = 0; + void *page = NULL; if (evtchnl->type == EVTCHNL_TYPE_REQ) - page = (unsigned long)evtchnl->u.req.ring.sring; + page = evtchnl->u.req.ring.sring; else if (evtchnl->type == EVTCHNL_TYPE_EVT) - page = (unsigned long)evtchnl->u.evt.page; + page = evtchnl->u.evt.page; if (!page) return; @@ -147,8 +147,7 @@ static void evtchnl_free(struct xen_drm_front_info *front_info, xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); /* end access and free the page */ - if (evtchnl->gref != INVALID_GRANT_REF) - gnttab_end_foreign_access(evtchnl->gref, page); + xenbus_teardown_ring(&page, 1, &evtchnl->gref); memset(evtchnl, 0, sizeof(*evtchnl)); } @@ -158,8 +157,7 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index, enum xen_drm_front_evtchnl_type type) { struct xenbus_device *xb_dev = front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; int ret; @@ -168,44 +166,26 @@ static int evtchnl_alloc(struct xen_drm_front_info *front_info, int index, evtchnl->index = index; evtchnl->front_info = front_info; evtchnl->state = EVTCHNL_STATE_DISCONNECTED; - evtchnl->gref = INVALID_GRANT_REF; - page = get_zeroed_page(GFP_NOIO | __GFP_HIGH); - if (!page) { - ret = -ENOMEM; + ret = xenbus_setup_ring(xb_dev, GFP_NOIO | __GFP_HIGH, &page, + 1, &evtchnl->gref); + if (ret) goto fail; - } if (type == EVTCHNL_TYPE_REQ) { struct xen_displif_sring *sring; init_completion(&evtchnl->u.req.completion); mutex_init(&evtchnl->u.req.req_io_lock); - sring = (struct xen_displif_sring *)page; + sring = page; SHARED_RING_INIT(sring); FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); - ret = xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - evtchnl->u.req.ring.sring = NULL; - free_page(page); - goto fail; - } - handler = evtchnl_interrupt_ctrl; } else { - ret = gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) { - free_page(page); - goto fail; - } - - evtchnl->u.evt.page = (struct xendispl_event_page *)page; - gref = ret; + evtchnl->u.evt.page = page; handler = evtchnl_interrupt_evt; } - evtchnl->gref = gref; ret = xenbus_alloc_evtchn(xb_dev, &evtchnl->port); if (ret < 0) -- 2.34.1
next prev parent reply other threads:[~2022-04-20 15:10 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 ` Juergen Gross [this message] 2022-04-20 15:09 ` [PATCH 13/18] xen/drmfront: " Juergen Gross 2022-04-20 15:09 ` [PATCH 14/18] xen/pcifront: " Juergen Gross 2022-04-20 15:09 ` [PATCH 15/18] xen/scsifront: " Juergen Gross 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-14-jgross@suse.com \ --to=jgross@suse.com \ --cc=airlied@linux.ie \ --cc=dri-devel@lists.freedesktop.org \ --cc=linux-kernel@vger.kernel.org \ --cc=oleksandr_andrushchenko@epam.com \ --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: linkBe 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.