From nobody Mon Feb 9 18:19:08 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1650467442; cv=none; d=zohomail.com; s=zohoarc; b=C+Fu1FiDT9tvMHD/oEh7OOK4/oUbt+9BDJ2Up2I42Na0DhD79Sd8MlThb6u2T8wsIhy23+YRwUndDpcNws7//s1wgHiMQKeACmVTvBltAhxn/mb/9xWTjxF/d0p06bOpKeCgdwJZVhxiDGctmExcjqRRbe7ad/VsafyLaZhtV4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467442; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ij8UfjCLrmWlzw8p3dv1NeerjjrG+tJoiHZZthvTeTI=; b=ljyK3UsKKyrgl/xeMABvhK6dBnTO3AJt3JdiZhqBIlqXQGeM6XuhS3fUuJJZH+99P9dOstiQ7MhScC1b0M2RLWmCGAP1bCucLE8chaL5tc+fQa8F0jjIhhiNnwfMAlhl+FNQM4E6m/08ue0XmnM2xT1qC6ciEdXUh6WHDK+m4tc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650467442429300.40691673956724; Wed, 20 Apr 2022 08:10:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309364.525651 (Exim 4.92) (envelope-from ) id 1nhByH-0008LP-0X; Wed, 20 Apr 2022 15:10:21 +0000 Received: by outflank-mailman (output) from mailman id 309364.525651; Wed, 20 Apr 2022 15:10:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhByF-0008Ea-9G; Wed, 20 Apr 2022 15:10:19 +0000 Received: by outflank-mailman (input) for mailman id 309364; Wed, 20 Apr 2022 15:10:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhBy5-0003l9-7l for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:09 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f3ddcb98-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:02 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5A2221F756; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2B21313AD5; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8E1yCUoiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f3ddcb98-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ij8UfjCLrmWlzw8p3dv1NeerjjrG+tJoiHZZthvTeTI=; b=JFTWSh6PJxJNJV7oRKcYWQSPPmYpfiNbr7bGGF1C4FLcMUoeH5mugdJwUSjRTpmafzW3Z6 3/rnOYNY53Prw7TUqwIAO/wr+1hE9sHaZ8juMfZMr2ylg+TetOlsdH5uDLkAimH+CRHSO4 /xH4WD232P0oiT57WD4l/KlJ4lYa0c0= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Oleksandr Andrushchenko , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org Subject: [PATCH 17/18] xen/sndfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:41 +0200 Message-Id: <20220420150942.31235-18-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467442848100001 Content-Type: text/plain; charset="utf-8" Simplify sndfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- sound/xen/xen_snd_front_evtchnl.c | 41 +++++++------------------------ 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_ev= tchnl.c index 3e21369c8216..32d42fd3f7ac 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 =3D 0; + void *page =3D NULL; =20 if (channel->type =3D=3D EVTCHNL_TYPE_REQ) - page =3D (unsigned long)channel->u.req.ring.sring; + page =3D channel->u.req.ring.sring; else if (channel->type =3D=3D EVTCHNL_TYPE_EVT) - page =3D (unsigned long)channel->u.evt.page; + page =3D channel->u.evt.page; =20 if (!page) return; @@ -167,10 +167,7 @@ static void evtchnl_free(struct xen_snd_front_info *fr= ont_info, xenbus_free_evtchn(front_info->xb_dev, channel->port); =20 /* End access and free the page. */ - if (channel->gref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(channel->gref, page); - else - free_page(page); + xenbus_teardown_ring(&page, 1, &channel->gref); =20 memset(channel, 0, sizeof(*channel)); } @@ -196,8 +193,7 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, enum xen_snd_front_evtchnl_type type) { struct xenbus_device *xb_dev =3D front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; char *handler_name =3D NULL; int ret; @@ -207,12 +203,9 @@ static int evtchnl_alloc(struct xen_snd_front_info *fr= ont_info, int index, channel->index =3D index; channel->front_info =3D front_info; channel->state =3D EVTCHNL_STATE_DISCONNECTED; - channel->gref =3D INVALID_GRANT_REF; - page =3D get_zeroed_page(GFP_KERNEL); - if (!page) { - ret =3D -ENOMEM; + ret =3D xenbus_setup_ring(xb_dev, GFP_KERNEL, &page, 1, &channel->gref); + if (ret) goto fail; - } =20 handler_name =3D kasprintf(GFP_KERNEL, "%s-%s", XENSND_DRIVER_NAME, type =3D=3D EVTCHNL_TYPE_REQ ? @@ -226,33 +219,19 @@ static int evtchnl_alloc(struct xen_snd_front_info *f= ront_info, int index, mutex_init(&channel->ring_io_lock); =20 if (type =3D=3D EVTCHNL_TYPE_REQ) { - struct xen_sndif_sring *sring =3D (struct xen_sndif_sring *)page; + struct xen_sndif_sring *sring =3D page; =20 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); =20 - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - channel->u.req.ring.sring =3D NULL; - goto fail; - } - handler =3D evtchnl_interrupt_req; } else { - ret =3D gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) - goto fail; - - channel->u.evt.page =3D (struct xensnd_event_page *)page; - gref =3D ret; + channel->u.evt.page =3D page; handler =3D evtchnl_interrupt_evt; } =20 - channel->gref =3D gref; - ret =3D xenbus_alloc_evtchn(xb_dev, &channel->port); if (ret < 0) goto fail; @@ -279,8 +258,6 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, return 0; =20 fail: - if (page) - free_page(page); kfree(handler_name); dev_err(&xb_dev->dev, "Failed to allocate ring: %d\n", ret); return ret; --=20 2.34.1