public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleksandr <olekstysh@gmail.com>
To: Juergen Gross <jgross@suse.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>,
	Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
	alsa-devel@alsa-project.org
Subject: Re: [PATCH v2 18/19] xen/sndfront: use xenbus_setup_ring() and xenbus_teardown_ring()
Date: Fri, 29 Apr 2022 21:07:08 +0300	[thread overview]
Message-ID: <91b8b63c-46f0-326e-4092-5bb6c8f681db@gmail.com> (raw)
In-Reply-To: <20220428082743.16593-19-jgross@suse.com>


On 28.04.22 11:27, Juergen Gross wrote:

Hello Juergen, all

> Simplify sndfront's ring creation and removal via xenbus_setup_ring()
> and xenbus_teardown_ring().
>
> Signed-off-by: Juergen Gross <jgross@suse.com>

I am not familiar with SOUND bits of this driver, but a little bit
familiar with Xen bits this patch only touches and I have environment to
test.

Xen specific changes looks good to me. Also I didn't see any issues when 
testing virtulized sound driver with current series except one I have 
already pointed out in PATCH v2 08/19.


root@salvator-x-h3-4x2g-xt-domu:~# dmesg | grep vsnd
[    0.432181] Initialising Xen vsnd frontend driver


root@salvator-x-h3-4x2g-xt-domu:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: vsnd [], device 0: dev1 [Virtual card PCM]
   Subdevices: 1/1
   Subdevice #0: subdevice #0

root@generic-armv8-xt-dom0:~# xenstore-ls -f | grep vsnd
/local/domain/1/backend/vsnd = ""
/local/domain/1/backend/vsnd/6 = ""
/local/domain/1/backend/vsnd/6/0 = ""
/local/domain/1/backend/vsnd/6/0/frontend = "/local/domain/6/device/vsnd/0"
/local/domain/1/backend/vsnd/6/0/frontend-id = "6"
/local/domain/1/backend/vsnd/6/0/online = "1"
/local/domain/1/backend/vsnd/6/0/state = "4"
/local/domain/6/device/vsnd = ""
/local/domain/6/device/vsnd/0 = ""
/local/domain/6/device/vsnd/0/backend = "/local/domain/1/backend/vsnd/6/0"
/local/domain/6/device/vsnd/0/backend-id = "1"
/local/domain/6/device/vsnd/0/state = "4"
/local/domain/6/device/vsnd/0/long-name = "Virtual sound card"
/local/domain/6/device/vsnd/0/short-name = "VCard"
/local/domain/6/device/vsnd/0/sample-rates = 
"8000,11025,16000,22050,32000,44100,48000"
/local/domain/6/device/vsnd/0/sample-formats = "s16_le"
/local/domain/6/device/vsnd/0/buffer-size = "65536"
/local/domain/6/device/vsnd/0/0 = ""
/local/domain/6/device/vsnd/0/0/name = "dev1"
/local/domain/6/device/vsnd/0/0/0 = ""
/local/domain/6/device/vsnd/0/0/0/unique-id = "pulse"
/local/domain/6/device/vsnd/0/0/0/type = "p"
/local/domain/6/device/vsnd/0/0/0/ring-ref = "2070"
/local/domain/6/device/vsnd/0/0/0/event-channel = "18"
/local/domain/6/device/vsnd/0/0/0/evt-ring-ref = "2071"
/local/domain/6/device/vsnd/0/0/0/evt-event-channel = "19"
/libxl/6/device/vsnd = ""
/libxl/6/device/vsnd/0 = ""
/libxl/6/device/vsnd/0/frontend = "/local/domain/6/device/vsnd/0"
/libxl/6/device/vsnd/0/backend = "/local/domain/1/backend/vsnd/6/0"
/libxl/6/device/vsnd/0/frontend-id = "6"
/libxl/6/device/vsnd/0/online = "1"
/libxl/6/device/vsnd/0/state = "1"


> ---
>   sound/xen/xen_snd_front_evtchnl.c | 44 +++++++------------------------
>   1 file changed, 10 insertions(+), 34 deletions(-)
>
> diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_evtchnl.c
> index 3e21369c8216..26d1b3987887 100644
> --- a/sound/xen/xen_snd_front_evtchnl.c
> +++ b/sound/xen/xen_snd_front_evtchnl.c
> @@ -143,12 +143,12 @@ void xen_snd_front_evtchnl_flush(struct xen_snd_front_evtchnl *channel)
>   static void evtchnl_free(struct xen_snd_front_info *front_info,
>   			 struct xen_snd_front_evtchnl *channel)
>   {
> -	unsigned long page = 0;
> +	void *page = NULL;
>   
>   	if (channel->type == EVTCHNL_TYPE_REQ)
> -		page = (unsigned long)channel->u.req.ring.sring;
> +		page = channel->u.req.ring.sring;
>   	else if (channel->type == EVTCHNL_TYPE_EVT)
> -		page = (unsigned long)channel->u.evt.page;
> +		page = channel->u.evt.page;
>   
>   	if (!page)
>   		return;
> @@ -167,10 +167,7 @@ static void evtchnl_free(struct xen_snd_front_info *front_info,
>   		xenbus_free_evtchn(front_info->xb_dev, channel->port);
>   
>   	/* End access and free the page. */
> -	if (channel->gref != INVALID_GRANT_REF)
> -		gnttab_end_foreign_access(channel->gref, page);
> -	else
> -		free_page(page);
> +	xenbus_teardown_ring(&page, 1, &channel->gref);
>   
>   	memset(channel, 0, sizeof(*channel));
>   }
> @@ -196,8 +193,7 @@ static int evtchnl_alloc(struct xen_snd_front_info *front_info, int index,
>   			 enum xen_snd_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;
>   	char *handler_name = NULL;
>   	int ret;
> @@ -207,12 +203,9 @@ static int evtchnl_alloc(struct xen_snd_front_info *front_info, int index,
>   	channel->index = index;
>   	channel->front_info = front_info;
>   	channel->state = EVTCHNL_STATE_DISCONNECTED;
> -	channel->gref = INVALID_GRANT_REF;
> -	page = get_zeroed_page(GFP_KERNEL);
> -	if (!page) {
> -		ret = -ENOMEM;
> +	ret = xenbus_setup_ring(xb_dev, GFP_KERNEL, &page, 1, &channel->gref);
> +	if (ret)
>   		goto fail;
> -	}
>   
>   	handler_name = kasprintf(GFP_KERNEL, "%s-%s", XENSND_DRIVER_NAME,
>   				 type == EVTCHNL_TYPE_REQ ?
> @@ -226,33 +219,18 @@ static int evtchnl_alloc(struct xen_snd_front_info *front_info, int index,
>   	mutex_init(&channel->ring_io_lock);
>   
>   	if (type == EVTCHNL_TYPE_REQ) {
> -		struct xen_sndif_sring *sring = (struct xen_sndif_sring *)page;
> +		struct xen_sndif_sring *sring = page;
>   
>   		init_completion(&channel->u.req.completion);
>   		mutex_init(&channel->u.req.req_io_lock);
> -		SHARED_RING_INIT(sring);
> -		FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE);
> -
> -		ret = xenbus_grant_ring(xb_dev, sring, 1, &gref);
> -		if (ret < 0) {
> -			channel->u.req.ring.sring = NULL;
> -			goto fail;
> -		}
> +		XEN_FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE);
>   
>   		handler = evtchnl_interrupt_req;
>   	} else {
> -		ret = gnttab_grant_foreign_access(xb_dev->otherend_id,
> -						  virt_to_gfn((void *)page), 0);
> -		if (ret < 0)
> -			goto fail;
> -
> -		channel->u.evt.page = (struct xensnd_event_page *)page;
> -		gref = ret;
> +		channel->u.evt.page = page;
>   		handler = evtchnl_interrupt_evt;
>   	}
>   
> -	channel->gref = gref;
> -
>   	ret = xenbus_alloc_evtchn(xb_dev, &channel->port);
>   	if (ret < 0)
>   		goto fail;
> @@ -279,8 +257,6 @@ static int evtchnl_alloc(struct xen_snd_front_info *front_info, int index,
>   	return 0;
>   
>   fail:
> -	if (page)
> -		free_page(page);
>   	kfree(handler_name);
>   	dev_err(&xb_dev->dev, "Failed to allocate ring: %d\n", ret);
>   	return ret;

-- 
Regards,

Oleksandr Tyshchenko


  reply	other threads:[~2022-04-29 18:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  8:27 [PATCH v2 00/19] xen: simplify frontend side ring setup Juergen Gross
2022-04-28  8:27 ` [PATCH v2 01/19] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Juergen Gross
2022-04-28  8:27 ` [PATCH v2 02/19] xen/netfront: switch netfront " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 03/19] xen/scsifront: remove unused GRANT_INVALID_REF definition Juergen Gross
2022-04-28  8:27 ` [PATCH v2 04/19] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Juergen Gross
2022-04-28  8:27 ` [PATCH v2 05/19] xen/drm: switch xen_drm_front " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 06/19] xen/sound: switch xen_snd_front " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 07/19] xen/dmabuf: switch gntdev-dmabuf " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 08/19] xen/shbuf: switch xen-front-pgdir-shbuf " Juergen Gross
     [not found]   ` <CAPD2p-nisRgMOzy+w2jx5ULfZTyv4MqtG0wkV9jNn3wNg415sQ@mail.gmail.com>
2022-04-29 15:28     ` Oleksandr
2022-05-02 13:31       ` Juergen Gross
2022-05-02 13:52         ` Oleksandr
2022-05-02 13:28     ` Juergen Gross
2022-04-28  8:27 ` [PATCH v2 09/19] xen: update ring.h Juergen Gross
2022-04-28  8:27 ` [PATCH v2 10/19] xen/xenbus: add xenbus_setup_ring() service function Juergen Gross
2022-04-28  8:27 ` [PATCH v2 11/19] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Juergen Gross
2022-04-28  8:27 ` [PATCH v2 12/19] xen/netfront: " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 13/19] xen/tpmfront: " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 14/19] xen/drmfront: " Juergen Gross
2022-04-29 16:10   ` Oleksandr
2022-04-28  8:27 ` [PATCH v2 15/19] xen/pcifront: " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 16/19] xen/scsifront: " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 17/19] xen/usbfront: " Juergen Gross
2022-04-28  8:27 ` [PATCH v2 18/19] xen/sndfront: " Juergen Gross
2022-04-29 18:07   ` Oleksandr [this message]
2022-04-28  8:27 ` [PATCH v2 19/19] xen/xenbus: eliminate xenbus_grant_ring() Juergen Gross
2022-04-29 15:10   ` Oleksandr
2022-05-02 13:30     ` Juergen Gross
2022-05-02 14:12       ` Oleksandr

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=91b8b63c-46f0-326e-4092-5bb6c8f681db@gmail.com \
    --to=olekstysh@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleksandr_andrushchenko@epam.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox