From nobody Mon Feb 9 01:48:55 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=1651134506; cv=none; d=zohomail.com; s=zohoarc; b=KXbSXBlncaS/jQtWfXTVmNqVAbrtN9AsgxBZ6LwQDPbA0cKTLDfkS0Avu2UDZ8Z+yxycrU3926EbRcQGxrOTdkV4ZxYuqsSI4tMlo0s4TTYIr3myqyyfnVJ3hHNEavMJ+nJ44uBzv2hWwZMQpiOrdi/gS+wTIP90Dd4FLcU74oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134506; 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=4w7uCrVXVTwZfPuB483vIPp5pLFfFRyBD4Y2IYXR2Yk=; b=dMaS+EIMUL7aqcXEqXz3sd9XAU8DFcHyLeJvdvU3680UiAdN8chhPTEPvN4IP9Z1u6QfgL6/c6PTk1OHfiWEExasW6NHph/j+R/MfdqtFmin1iPu8BL96w1+iecmO7m6qQB7C/ILy99uVmwKGilDN/j3XL6I17dB17lV3kfJFN0= 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 1651134506705336.7403087302217; Thu, 28 Apr 2022 01:28:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316183.535071 (Exim 4.92) (envelope-from ) id 1njzVO-0000Jp-0O; Thu, 28 Apr 2022 08:28:06 +0000 Received: by outflank-mailman (output) from mailman id 316183.535071; Thu, 28 Apr 2022 08:28:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVM-0000Ee-Md; Thu, 28 Apr 2022 08:28:04 +0000 Received: by outflank-mailman (input) for mailman id 316183; Thu, 28 Apr 2022 08:27:56 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVE-0005SL-BP for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:56 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 184ea9a1-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:52 +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-out1.suse.de (Postfix) with ESMTPS id E750D21871; Thu, 28 Apr 2022 08:27:51 +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 ADCC013491; Thu, 28 Apr 2022 08:27:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2D3fKAdQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:51 +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: 184ea9a1-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134471; 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=4w7uCrVXVTwZfPuB483vIPp5pLFfFRyBD4Y2IYXR2Yk=; b=evJ5rg5sEto2aWIIjrjOQPgkeyr3Gle8wcN4/Jb29iscyKgXZmT4ie3JH0XrGFhJrMf8Lo Niu40LYPTvOu9bDwFznYsNaBdusaLXqoJQPPx7jd7ZSbB7j+czJkZkmZVN05Zs+VwpwZmz 17Hj+h0lQQ7whUEHoJmdDH9U/WePsPM= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Bjorn Helgaas Subject: [PATCH v2 15/19] xen/pcifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:39 +0200 Message-Id: <20220428082743.16593-16-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220428082743.16593-1-jgross@suse.com> References: <20220428082743.16593-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651134507043100019 Content-Type: text/plain; charset="utf-8" Simplify pcifront's shared page creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/pci/xen-pcifront.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/drivers/pci/xen-pcifront.c b/drivers/pci/xen-pcifront.c index 3edc1565a27c..689271c4245c 100644 --- a/drivers/pci/xen-pcifront.c +++ b/drivers/pci/xen-pcifront.c @@ -709,9 +709,8 @@ static struct pcifront_device *alloc_pdev(struct xenbus= _device *xdev) if (pdev =3D=3D NULL) goto out; =20 - pdev->sh_info =3D - (struct xen_pci_sharedinfo *)__get_free_page(GFP_KERNEL); - if (pdev->sh_info =3D=3D NULL) { + if (xenbus_setup_ring(xdev, GFP_KERNEL, (void **)&pdev->sh_info, 1, + &pdev->gnt_ref)) { kfree(pdev); pdev =3D NULL; goto out; @@ -729,7 +728,6 @@ static struct pcifront_device *alloc_pdev(struct xenbus= _device *xdev) spin_lock_init(&pdev->sh_info_lock); =20 pdev->evtchn =3D INVALID_EVTCHN; - pdev->gnt_ref =3D INVALID_GRANT_REF; pdev->irq =3D -1; =20 INIT_WORK(&pdev->op_work, pcifront_do_aer); @@ -754,11 +752,7 @@ static void free_pdev(struct pcifront_device *pdev) if (pdev->evtchn !=3D INVALID_EVTCHN) xenbus_free_evtchn(pdev->xdev, pdev->evtchn); =20 - if (pdev->gnt_ref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(pdev->gnt_ref, - (unsigned long)pdev->sh_info); - else - free_page((unsigned long)pdev->sh_info); + xenbus_teardown_ring((void **)&pdev->sh_info, 1, &pdev->gnt_ref); =20 dev_set_drvdata(&pdev->xdev->dev, NULL); =20 @@ -769,13 +763,6 @@ static int pcifront_publish_info(struct pcifront_devic= e *pdev) { int err =3D 0; struct xenbus_transaction trans; - grant_ref_t gref; - - err =3D xenbus_grant_ring(pdev->xdev, pdev->sh_info, 1, &gref); - if (err < 0) - goto out; - - pdev->gnt_ref =3D gref; =20 err =3D xenbus_alloc_evtchn(pdev->xdev, &pdev->evtchn); if (err) --=20 2.34.1