From nobody Fri May 10 09:39:34 2024 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=1651134495; cv=none; d=zohomail.com; s=zohoarc; b=BO4lfov8GfaBP+8AV6x6LYFtjATkJTnmSWWXkZBm7GP6GXOrN0v/zdB8e4+xXF/6lgrp98qZ7a580EQD9JJY6/Ev4KEcFWwPtJHgOyE4GA46mXnq0jxqte4WhVU1c9f+NQqkbS/gTrxUpd5XVs94pwapESf3KAFrAEMYNhPdIfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134495; 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=8T6Z7jV+2E1LG0Lx6kFTGECOTx+ZZjBB+fMJq4VZyPo=; b=VKpySAx+3Cf3uzTlYX3hQ9Iylmv0XXgvOzWTZ2t2BPpGpsM0u85ao4yZ/DKRw8V0d/ahE4qMCqsOfx3ypZpfx4wZGel2Jd66Zm3y4vxVz7bJJC6K8T9v1lvnvMUA4LlYaAbr8MQaYz58IYl9qIPdc/9ErWMJdU3y0D9oV5oqPF4= 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 1651134495696379.3102921798994; Thu, 28 Apr 2022 01:28:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316170.534948 (Exim 4.92) (envelope-from ) id 1njzV9-0005Vo-2M; Thu, 28 Apr 2022 08:27:51 +0000 Received: by outflank-mailman (output) from mailman id 316170.534948; Thu, 28 Apr 2022 08:27:51 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzV8-0005Uw-UV; Thu, 28 Apr 2022 08:27:50 +0000 Received: by outflank-mailman (input) for mailman id 316170; Thu, 28 Apr 2022 08:27:49 +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 1njzV7-0005SM-LA for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:49 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16110460-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:48 +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 130A721870; Thu, 28 Apr 2022 08:27:48 +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 C8D3313AF9; Thu, 28 Apr 2022 08:27:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sECFLwNQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:47 +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: 16110460-c6cd-11ec-8fc3-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134468; 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=8T6Z7jV+2E1LG0Lx6kFTGECOTx+ZZjBB+fMJq4VZyPo=; b=XZftGB6VP1qLXSlx4vJcQgEjy/RezPi5BrmURePrVfY6UngIHaNNnPVV044Jx1K2+Oqe3O Wh+Mc+ZK5OY1s62YkenGBJ01tTqaxK8XfJ9xRaxGeX13/aXHyh6u2s6U0EhwawiTbqYlUx rBrskyscjbFRnyRxb7/LrYMicon72ec= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Jens Axboe Subject: [PATCH v2 01/19] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:25 +0200 Message-Id: <20220428082743.16593-2-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: 1651134497305100001 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- drivers/block/xen-blkfront.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 003056d4f7f5..7f35e30e626a 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -229,8 +229,6 @@ static unsigned int nr_minors; static unsigned long *minors; static DEFINE_SPINLOCK(minor_lock); =20 -#define GRANT_INVALID_REF 0 - #define PARTS_PER_DISK 16 #define PARTS_PER_EXT_DISK 256 =20 @@ -321,7 +319,7 @@ static int fill_grant_buffer(struct blkfront_ring_info = *rinfo, int num) gnt_list_entry->page =3D granted_page; } =20 - gnt_list_entry->gref =3D GRANT_INVALID_REF; + gnt_list_entry->gref =3D INVALID_GRANT_REF; list_add(&gnt_list_entry->node, &rinfo->grants); i++; } @@ -350,7 +348,7 @@ static struct grant *get_free_grant(struct blkfront_rin= g_info *rinfo) node); list_del(&gnt_list_entry->node); =20 - if (gnt_list_entry->gref !=3D GRANT_INVALID_REF) + if (gnt_list_entry->gref !=3D INVALID_GRANT_REF) rinfo->persistent_gnts_c--; =20 return gnt_list_entry; @@ -372,7 +370,7 @@ static struct grant *get_grant(grant_ref_t *gref_head, struct grant *gnt_list_entry =3D get_free_grant(rinfo); struct blkfront_info *info =3D rinfo->dev_info; =20 - if (gnt_list_entry->gref !=3D GRANT_INVALID_REF) + if (gnt_list_entry->gref !=3D INVALID_GRANT_REF) return gnt_list_entry; =20 /* Assign a gref to this page */ @@ -396,7 +394,7 @@ static struct grant *get_indirect_grant(grant_ref_t *gr= ef_head, struct grant *gnt_list_entry =3D get_free_grant(rinfo); struct blkfront_info *info =3D rinfo->dev_info; =20 - if (gnt_list_entry->gref !=3D GRANT_INVALID_REF) + if (gnt_list_entry->gref !=3D INVALID_GRANT_REF) return gnt_list_entry; =20 /* Assign a gref to this page */ @@ -1221,7 +1219,7 @@ static void blkif_free_ring(struct blkfront_ring_info= *rinfo) list_for_each_entry_safe(persistent_gnt, n, &rinfo->grants, node) { list_del(&persistent_gnt->node); - if (persistent_gnt->gref !=3D GRANT_INVALID_REF) { + if (persistent_gnt->gref !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(persistent_gnt->gref, 0UL); rinfo->persistent_gnts_c--; @@ -1283,9 +1281,9 @@ static void blkif_free_ring(struct blkfront_ring_info= *rinfo) =20 /* Free resources associated with old device channel. */ for (i =3D 0; i < info->nr_ring_pages; i++) { - if (rinfo->ring_ref[i] !=3D GRANT_INVALID_REF) { + if (rinfo->ring_ref[i] !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(rinfo->ring_ref[i], 0); - rinfo->ring_ref[i] =3D GRANT_INVALID_REF; + rinfo->ring_ref[i] =3D INVALID_GRANT_REF; } } free_pages_exact(rinfo->ring.sring, @@ -1475,7 +1473,7 @@ static int blkif_completion(unsigned long *id, * to the tail of the list, so it will not be picked * again unless we run out of persistent grants. */ - s->grants_used[i]->gref =3D GRANT_INVALID_REF; + s->grants_used[i]->gref =3D INVALID_GRANT_REF; list_add_tail(&s->grants_used[i]->node, &rinfo->grants); } } @@ -1500,7 +1498,7 @@ static int blkif_completion(unsigned long *id, indirect_page =3D s->indirect_grants[i]->page; list_add(&indirect_page->lru, &rinfo->indirect_pages); } - s->indirect_grants[i]->gref =3D GRANT_INVALID_REF; + s->indirect_grants[i]->gref =3D INVALID_GRANT_REF; list_add_tail(&s->indirect_grants[i]->node, &rinfo->grants); } } @@ -1687,7 +1685,7 @@ static int setup_blkring(struct xenbus_device *dev, grant_ref_t gref[XENBUS_MAX_RING_GRANTS]; =20 for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D GRANT_INVALID_REF; + rinfo->ring_ref[i] =3D INVALID_GRANT_REF; =20 sring =3D alloc_pages_exact(ring_size, GFP_NOIO); if (!sring) { @@ -2544,13 +2542,13 @@ static void purge_persistent_grants(struct blkfront= _info *info) =20 list_for_each_entry_safe(gnt_list_entry, tmp, &rinfo->grants, node) { - if (gnt_list_entry->gref =3D=3D GRANT_INVALID_REF || + if (gnt_list_entry->gref =3D=3D INVALID_GRANT_REF || !gnttab_try_end_foreign_access(gnt_list_entry->gref)) continue; =20 list_del(&gnt_list_entry->node); rinfo->persistent_gnts_c--; - gnt_list_entry->gref =3D GRANT_INVALID_REF; + gnt_list_entry->gref =3D INVALID_GRANT_REF; list_add_tail(&gnt_list_entry->node, &grants); } =20 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134499; cv=none; d=zohomail.com; s=zohoarc; b=gC46B6OHOIYF11UVeEqoMmUPpV7IdyOn9Wr3q7cpC7QTgFOl5gFVyH+X1oK/k2EF0YO7OFb/w9mFe5hWHaHihRWQKg5t4/wblwYSLoGH+5GuE+ceRfocgBOZg+eEDt7hXNyarJgrdzTxzsn0yMnTBcOozMKhUjgVd5eSQqfN3ck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134499; 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=1+sLUcbyL72u2uT21oB5tsWX/EFozEKqCEXKzXzCiFA=; b=QQGxvYmH+C7OHFFE/b3nzdFOPQiQV+iFXQ+91hOLE4HrAgBzDrYnyVy+lmFS7TNbwCBffNv+Pes5cyN7Rh7qF1ncKPgJF2uESVlydEYvSEo99frqFe5KxXZoGPkX8JvtDP0eGNI1LW63uxffr/irI6ZHhzJxRAiFjwBdecwWOJM= 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 1651134499165902.7295702699607; Thu, 28 Apr 2022 01:28:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316172.534970 (Exim 4.92) (envelope-from ) id 1njzVA-00061L-Q3; Thu, 28 Apr 2022 08:27:52 +0000 Received: by outflank-mailman (output) from mailman id 316172.534970; Thu, 28 Apr 2022 08:27:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVA-0005zo-HL; Thu, 28 Apr 2022 08:27:52 +0000 Received: by outflank-mailman (input) for mailman id 316172; Thu, 28 Apr 2022 08:27:50 +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 1njzV8-0005SM-Dv for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:50 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1632c798-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:48 +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 6132A21871; Thu, 28 Apr 2022 08:27:48 +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 1BC7913491; Thu, 28 Apr 2022 08:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0KaDBQRQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:48 +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: 1632c798-c6cd-11ec-8fc3-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134468; 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=1+sLUcbyL72u2uT21oB5tsWX/EFozEKqCEXKzXzCiFA=; b=UnsC/U6cRAnvBqbXD65jZsvqsn6XqCQFhpOxRtYjKbTiLSNREIe8/ihMdRY93qVR4qiTmB rCJNq/A/60c+PxQpAn3nr/EmT1y0umP0H3kUFtXu8lzWdFOifhRD45y1sS0Z6sfcuDpnyr bbK/7Lz+zzWkM7Ld2KfJdNfwt4J5+eo= From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , "David S. Miller" , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2 02/19] xen/netfront: switch netfront to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:26 +0200 Message-Id: <20220428082743.16593-3-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: 1651134501080100002 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- drivers/net/xen-netfront.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index e2b4a1893a13..af3d3de7d9fa 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -78,8 +78,6 @@ struct netfront_cb { =20 #define RX_COPY_THRESHOLD 256 =20 -#define GRANT_INVALID_REF 0 - #define NET_TX_RING_SIZE __CONST_RING_SIZE(xen_netif_tx, XEN_PAGE_SIZE) #define NET_RX_RING_SIZE __CONST_RING_SIZE(xen_netif_rx, XEN_PAGE_SIZE) =20 @@ -224,7 +222,7 @@ static grant_ref_t xennet_get_rx_ref(struct netfront_qu= eue *queue, { int i =3D xennet_rxidx(ri); grant_ref_t ref =3D queue->grant_rx_ref[i]; - queue->grant_rx_ref[i] =3D GRANT_INVALID_REF; + queue->grant_rx_ref[i] =3D INVALID_GRANT_REF; return ref; } =20 @@ -432,7 +430,7 @@ static bool xennet_tx_buf_gc(struct netfront_queue *que= ue) } gnttab_release_grant_reference( &queue->gref_tx_head, queue->grant_tx_ref[id]); - queue->grant_tx_ref[id] =3D GRANT_INVALID_REF; + queue->grant_tx_ref[id] =3D INVALID_GRANT_REF; queue->grant_tx_page[id] =3D NULL; add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, id); dev_kfree_skb_irq(skb); @@ -1021,7 +1019,7 @@ static int xennet_get_responses(struct netfront_queue= *queue, * the backend driver. In future this should flag the bad * situation to the system controller to reboot the backend. */ - if (ref =3D=3D GRANT_INVALID_REF) { + if (ref =3D=3D INVALID_GRANT_REF) { if (net_ratelimit()) dev_warn(dev, "Bad rx response id %d.\n", rx->id); @@ -1390,7 +1388,7 @@ static void xennet_release_tx_bufs(struct netfront_qu= eue *queue) gnttab_end_foreign_access(queue->grant_tx_ref[i], (unsigned long)page_address(queue->grant_tx_page[i])); queue->grant_tx_page[i] =3D NULL; - queue->grant_tx_ref[i] =3D GRANT_INVALID_REF; + queue->grant_tx_ref[i] =3D INVALID_GRANT_REF; add_id_to_list(&queue->tx_skb_freelist, queue->tx_link, i); dev_kfree_skb_irq(skb); } @@ -1411,7 +1409,7 @@ static void xennet_release_rx_bufs(struct netfront_qu= eue *queue) continue; =20 ref =3D queue->grant_rx_ref[id]; - if (ref =3D=3D GRANT_INVALID_REF) + if (ref =3D=3D INVALID_GRANT_REF) continue; =20 page =3D skb_frag_page(&skb_shinfo(skb)->frags[0]); @@ -1422,7 +1420,7 @@ static void xennet_release_rx_bufs(struct netfront_qu= eue *queue) get_page(page); gnttab_end_foreign_access(ref, (unsigned long)page_address(page)); - queue->grant_rx_ref[id] =3D GRANT_INVALID_REF; + queue->grant_rx_ref[id] =3D INVALID_GRANT_REF; =20 kfree_skb(skb); } @@ -1761,7 +1759,7 @@ static int netfront_probe(struct xenbus_device *dev, static void xennet_end_access(int ref, void *page) { /* This frees the page as a side-effect */ - if (ref !=3D GRANT_INVALID_REF) + if (ref !=3D INVALID_GRANT_REF) gnttab_end_foreign_access(ref, (unsigned long)page); } =20 @@ -1798,8 +1796,8 @@ static void xennet_disconnect_backend(struct netfront= _info *info) xennet_end_access(queue->tx_ring_ref, queue->tx.sring); xennet_end_access(queue->rx_ring_ref, queue->rx.sring); =20 - queue->tx_ring_ref =3D GRANT_INVALID_REF; - queue->rx_ring_ref =3D GRANT_INVALID_REF; + queue->tx_ring_ref =3D INVALID_GRANT_REF; + queue->rx_ring_ref =3D INVALID_GRANT_REF; queue->tx.sring =3D NULL; queue->rx.sring =3D NULL; =20 @@ -1927,8 +1925,8 @@ static int setup_netfront(struct xenbus_device *dev, grant_ref_t gref; int err; =20 - queue->tx_ring_ref =3D GRANT_INVALID_REF; - queue->rx_ring_ref =3D GRANT_INVALID_REF; + queue->tx_ring_ref =3D INVALID_GRANT_REF; + queue->rx_ring_ref =3D INVALID_GRANT_REF; queue->rx.sring =3D NULL; queue->tx.sring =3D NULL; =20 @@ -1978,17 +1976,17 @@ static int setup_netfront(struct xenbus_device *dev, * granted pages because backend is not accessing it at this point. */ fail: - if (queue->rx_ring_ref !=3D GRANT_INVALID_REF) { + if (queue->rx_ring_ref !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(queue->rx_ring_ref, (unsigned long)rxs); - queue->rx_ring_ref =3D GRANT_INVALID_REF; + queue->rx_ring_ref =3D INVALID_GRANT_REF; } else { free_page((unsigned long)rxs); } - if (queue->tx_ring_ref !=3D GRANT_INVALID_REF) { + if (queue->tx_ring_ref !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(queue->tx_ring_ref, (unsigned long)txs); - queue->tx_ring_ref =3D GRANT_INVALID_REF; + queue->tx_ring_ref =3D INVALID_GRANT_REF; } else { free_page((unsigned long)txs); } @@ -2020,7 +2018,7 @@ static int xennet_init_queue(struct netfront_queue *q= ueue) queue->tx_pend_queue =3D TX_LINK_NONE; for (i =3D 0; i < NET_TX_RING_SIZE; i++) { queue->tx_link[i] =3D i + 1; - queue->grant_tx_ref[i] =3D GRANT_INVALID_REF; + queue->grant_tx_ref[i] =3D INVALID_GRANT_REF; queue->grant_tx_page[i] =3D NULL; } queue->tx_link[NET_TX_RING_SIZE - 1] =3D TX_LINK_NONE; @@ -2028,7 +2026,7 @@ static int xennet_init_queue(struct netfront_queue *q= ueue) /* Clear out rx_skbs */ for (i =3D 0; i < NET_RX_RING_SIZE; i++) { queue->rx_skbs[i] =3D NULL; - queue->grant_rx_ref[i] =3D GRANT_INVALID_REF; + queue->grant_rx_ref[i] =3D INVALID_GRANT_REF; } =20 /* A grant for every tx ring slot */ --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134499; cv=none; d=zohomail.com; s=zohoarc; b=brIrEZv2ikM4ozESiMJGQ5SMlIpq/CyGtV5mpHF/kg1MzC5jTA7s3s8UWnNzZAgC7WaXRxLT05lQ0/0bkIP5YezQhTXvd1YLx0wVcmYIsQQpblHRK4UeKPm3gryWlUiCga9oZksPPAhHAanBc0vMoyH8eCNdNVewoXWPa40qdaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134499; 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=JgTSDzyFH4odL3+op3mwwaz3GF9HZ1rzMHlaax9H0jQ=; b=embBQCX2/dpn94BLChObXtFRYncI58ZaJWVjS3kER4QVvxch5dOSnHAuybdE6nFygOGDHhczg+Lcnz6sSWfZQ/ijLtSex8nl9I5VmT1j5yGetT3Qg58lb8e2CDQ3+UE0C911EsweupbVd/td7VwEcwteL73PfpnCZvjm0oPxXJQ= 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 1651134499260806.5720250396005; Thu, 28 Apr 2022 01:28:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316171.534966 (Exim 4.92) (envelope-from ) id 1njzVA-0005x9-By; Thu, 28 Apr 2022 08:27:52 +0000 Received: by outflank-mailman (output) from mailman id 316171.534966; Thu, 28 Apr 2022 08:27:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVA-0005wk-7r; Thu, 28 Apr 2022 08:27:52 +0000 Received: by outflank-mailman (input) for mailman id 316171; Thu, 28 Apr 2022 08:27:50 +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 1njzV8-0005SL-9t for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:50 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1664d82d-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:49 +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 B68971F88B; Thu, 28 Apr 2022 08:27:48 +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 6A6DD13491; Thu, 28 Apr 2022 08:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mPaeGARQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:48 +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: 1664d82d-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134468; 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=JgTSDzyFH4odL3+op3mwwaz3GF9HZ1rzMHlaax9H0jQ=; b=XJSEFs+iNetHUnKTGEZp1HsPSzQlTRyaGB3P+gTZL34FW8MH4Kl98mOgVnhzQzPxlxbka0 5HWsPhR50wFcq9np7hRBIg2ejBAmi8i+QnKhcg4+gI+dWtaHjXhpi2cubxv4IcSVVPJlx2 B/2ksRkjk3lAWibFGeQNovVIqq/4Ixc= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH v2 03/19] xen/scsifront: remove unused GRANT_INVALID_REF definition Date: Thu, 28 Apr 2022 10:27:27 +0200 Message-Id: <20220428082743.16593-4-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: 1651134501077100001 Content-Type: text/plain; charset="utf-8" GRANT_INVALID_REF isn't used in scsifront, so remove it. Signed-off-by: Juergen Gross --- drivers/scsi/xen-scsifront.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 56173beecbc6..4c55e479fc36 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -58,9 +58,6 @@ =20 #include =20 - -#define GRANT_INVALID_REF 0 - #define VSCSIFRONT_OP_ADD_LUN 1 #define VSCSIFRONT_OP_DEL_LUN 2 #define VSCSIFRONT_OP_READD_LUN 3 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134498; cv=none; d=zohomail.com; s=zohoarc; b=h9RaEDE0H7OYHmL/ogEruvulTQroAjhfRkqS2vghpOZjrq8ghQ9uLYr78Ppitct39exWNWFed5qz3PpZl1iwcfgEF0jTCUo88WOvdnO7jJ9MH1FxOyTX9TSL6YN77/PrUTq7ldnHobBj3mtBz33TZsjnHdyxlT11My6igqdhxc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134498; 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=7TSQqudTcVLuLhQNOY3wWT3BirutbrjVm/F1DYUL/Jc=; b=jM3tmuH+lT3qrEqYJLz9Hc+JT9CnP3+HPyHv5CvbShEVLwpz1HooizJn8AjGv73hsMspASND7jNWDdyIZD0fLNNJcV6uvcP8efQnGVLQ42sHp1xLDETHE6qqV5CLFGm/ZQTFh3KbrMVxoRuD7zmRecVCHKybtcPl+CI7pRAAzM0= 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 1651134498354246.10341289402925; Thu, 28 Apr 2022 01:28:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316173.534978 (Exim 4.92) (envelope-from ) id 1njzVB-0006Ed-IX; Thu, 28 Apr 2022 08:27:53 +0000 Received: by outflank-mailman (output) from mailman id 316173.534978; Thu, 28 Apr 2022 08:27:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVB-0006AS-97; Thu, 28 Apr 2022 08:27:53 +0000 Received: by outflank-mailman (input) for mailman id 316173; Thu, 28 Apr 2022 08:27:51 +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 1njzV9-0005SL-AA for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:51 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 169b9424-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:49 +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 ECFC21F899; Thu, 28 Apr 2022 08:27:48 +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 BDE1313491; Thu, 28 Apr 2022 08:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OFX/LARQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:48 +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: 169b9424-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134468; 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=7TSQqudTcVLuLhQNOY3wWT3BirutbrjVm/F1DYUL/Jc=; b=bXQFN0N+BgI1kmZyCngmvHVCA1I+1WiKiyl4AoNXMJlXEBLY1bscsQfLjv+ocbOnCYApPF Bj/5Cq72navU9MxLn+AfqK7WV3/FX3gM1bLJgJ28Gl0hLTxsS7SNqZ8qKkurAL6KoXX2bH 6ofYmp6Du47LiNOIHekEpuVElAnDZSs= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Greg Kroah-Hartman Subject: [PATCH v2 04/19] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:28 +0200 Message-Id: <20220428082743.16593-5-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: 1651134499014100006 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross Acked-by: Greg Kroah-Hartman --- drivers/usb/host/xen-hcd.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c index 3e487baf8422..9cbc7c2dab02 100644 --- a/drivers/usb/host/xen-hcd.c +++ b/drivers/usb/host/xen-hcd.c @@ -87,8 +87,6 @@ struct xenhcd_info { bool error; }; =20 -#define GRANT_INVALID_REF 0 - #define XENHCD_RING_JIFFIES (HZ/200) #define XENHCD_SCAN_JIFFIES 1 =20 @@ -1100,17 +1098,17 @@ static void xenhcd_destroy_rings(struct xenhcd_info= *info) unbind_from_irqhandler(info->irq, info); info->irq =3D 0; =20 - if (info->urb_ring_ref !=3D GRANT_INVALID_REF) { + if (info->urb_ring_ref !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(info->urb_ring_ref, (unsigned long)info->urb_ring.sring); - info->urb_ring_ref =3D GRANT_INVALID_REF; + info->urb_ring_ref =3D INVALID_GRANT_REF; } info->urb_ring.sring =3D NULL; =20 - if (info->conn_ring_ref !=3D GRANT_INVALID_REF) { + if (info->conn_ring_ref !=3D INVALID_GRANT_REF) { gnttab_end_foreign_access(info->conn_ring_ref, (unsigned long)info->conn_ring.sring); - info->conn_ring_ref =3D GRANT_INVALID_REF; + info->conn_ring_ref =3D INVALID_GRANT_REF; } info->conn_ring.sring =3D NULL; } @@ -1123,8 +1121,8 @@ static int xenhcd_setup_rings(struct xenbus_device *d= ev, grant_ref_t gref; int err; =20 - info->urb_ring_ref =3D GRANT_INVALID_REF; - info->conn_ring_ref =3D GRANT_INVALID_REF; + info->urb_ring_ref =3D INVALID_GRANT_REF; + info->conn_ring_ref =3D INVALID_GRANT_REF; =20 urb_sring =3D (struct xenusb_urb_sring *)get_zeroed_page( GFP_NOIO | __GFP_HIGH); --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134497; cv=none; d=zohomail.com; s=zohoarc; b=jpcjSVEB5rYs5jGR3V+Ke17NMUogHMS7psYRvd0WJ/w/l1VuVZR9KvfPMuxYvt51LaZEQvzkhY1pcNzv9vbdgKqoVdGv/GJOEFap7PzfpKxkBQEf6x8ef9aooT7HhGj5gyIVVfIJnujzuD5pv6/7Qe2P4mqYX4rBZm2Yc6Bins8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134497; 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=tOhV6YQDouFKSF4kDrscgmAnoCYSHdFmpTsct9Kqzek=; b=dEQ5tlgI1K+A0xZjOn5ELKSDn24JtTPAu4EQ1+run8u65eHi+gEMcMB/gXnPO65n7NSAWFZmODvxq35jnzc3eEqFjV8NPi5VCUHRgiTQjH01+jQvaIWD2wHmclxwknXhUWYv2b8eCsZvjsVi668IqlUdPzVpLmKr3PaQg0Kwst4= 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 1651134497137572.8851422674727; Thu, 28 Apr 2022 01:28:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316174.534986 (Exim 4.92) (envelope-from ) id 1njzVC-0006Lb-6Q; Thu, 28 Apr 2022 08:27:54 +0000 Received: by outflank-mailman (output) from mailman id 316174.534986; Thu, 28 Apr 2022 08:27:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVB-0006HV-Pu; Thu, 28 Apr 2022 08:27:53 +0000 Received: by outflank-mailman (input) for mailman id 316174; Thu, 28 Apr 2022 08:27:51 +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 1njzV9-0005SM-Dw for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:51 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 16b2dfeb-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:49 +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 3AA1321873; Thu, 28 Apr 2022 08:27:49 +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 0188D13491; Thu, 28 Apr 2022 08:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EMGoOgRQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:48 +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: 16b2dfeb-c6cd-11ec-8fc3-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134469; 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=tOhV6YQDouFKSF4kDrscgmAnoCYSHdFmpTsct9Kqzek=; b=h6hwiM9FHRpDwvATx8ZJwxdJgF4aQmHGQmkHLtLJrYUY3ATb3CYZi1lh3cJIcZpfglwM82 FnnkX9Ux6gOptve9MuodDmBZFvSvzzfaQd9rtWom4I0jgM9qfoQTzXUk9eOHuFfhhQ3J0o Hsizgzz4vnGMgdDhowBzhKzpG3NUYfc= From: Juergen Gross To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Oleksandr Andrushchenko , David Airlie , Daniel Vetter Subject: [PATCH v2 05/19] xen/drm: switch xen_drm_front to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:29 +0200 Message-Id: <20220428082743.16593-6-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: 1651134498912100003 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- drivers/gpu/drm/xen/xen_drm_front.h | 9 --------- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 4 ++-- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front.h b/drivers/gpu/drm/xen/xen_= drm_front.h index cefafe859aba..a987c78abe41 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.h +++ b/drivers/gpu/drm/xen/xen_drm_front.h @@ -80,15 +80,6 @@ struct drm_pending_vblank_event; /* timeout in ms to wait for backend to respond */ #define XEN_DRM_FRONT_WAIT_BACK_MS 3000 =20 -#ifndef GRANT_INVALID_REF -/* - * Note on usage of grant reference 0 as invalid grant reference: - * grant reference 0 is valid, but never exposed to a PV driver, - * because of the fact it is already in use/reserved by the PV console. - */ -#define GRANT_INVALID_REF 0 -#endif - struct xen_drm_front_info { struct xenbus_device *xb_dev; struct xen_drm_front_drm_info *drm_info; diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/= xen/xen_drm_front_evtchnl.c index 08b526eeec16..4006568b9e32 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -147,7 +147,7 @@ static void evtchnl_free(struct xen_drm_front_info *fro= nt_info, xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); =20 /* end access and free the page */ - if (evtchnl->gref !=3D GRANT_INVALID_REF) + if (evtchnl->gref !=3D INVALID_GRANT_REF) gnttab_end_foreign_access(evtchnl->gref, page); =20 memset(evtchnl, 0, sizeof(*evtchnl)); @@ -168,7 +168,7 @@ static int evtchnl_alloc(struct xen_drm_front_info *fro= nt_info, int index, evtchnl->index =3D index; evtchnl->front_info =3D front_info; evtchnl->state =3D EVTCHNL_STATE_DISCONNECTED; - evtchnl->gref =3D GRANT_INVALID_REF; + evtchnl->gref =3D INVALID_GRANT_REF; =20 page =3D get_zeroed_page(GFP_NOIO | __GFP_HIGH); if (!page) { --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134499; cv=none; d=zohomail.com; s=zohoarc; b=Sv1Lm6bj0KJBCGYiobT4dWbMATluc7oWn2iko3Sp1juO60bTRaBDmumKGreS9udHdDkumiaZuoOups/3w8UggKOh/W1AvkvlGYlE8o7/qXSYW8f7D+r2Y7HQX1jxu9gl93OlNltX144S/mndwBhBbV1tpbb0T5ZxONAZTFuSIsE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134499; 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=nqfEAJYikez5yuRaJWQFVEnr7bTvqklH6kJ7XEyZeH4=; b=R5jOqrL7WCmHW4CdhzXq/kUHCWzMrR/1p1a2B/6p4RXexIiWag4krlXabd6C7Oflax66q15eeGKsfUZ11K549hGgVS5jHFoVkdZq+OPODTVal6rwhc1Kja9NONZeNZRjXsFMAsGwnuL8EyO6YN+/rrII+TTdnO/pT7MZ3i2s8To= 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 1651134499008805.135122118954; Thu, 28 Apr 2022 01:28:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316175.534995 (Exim 4.92) (envelope-from ) id 1njzVD-0006XV-20; Thu, 28 Apr 2022 08:27:55 +0000 Received: by outflank-mailman (output) from mailman id 316175.534995; Thu, 28 Apr 2022 08:27:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVC-0006TJ-FI; Thu, 28 Apr 2022 08:27:54 +0000 Received: by outflank-mailman (input) for mailman id 316175; Thu, 28 Apr 2022 08:27:52 +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 1njzVA-0005SL-AB for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:52 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 16dea835-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:49 +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 804C41F8A8; Thu, 28 Apr 2022 08:27:49 +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 4287913491; Thu, 28 Apr 2022 08:27:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sDPlDgVQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:49 +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: 16dea835-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134469; 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=nqfEAJYikez5yuRaJWQFVEnr7bTvqklH6kJ7XEyZeH4=; b=TYPIqdG6C2kNSXwfoxobkb0T7Qrlkecz89DW0NUUSRJk8G1Cl1McWKfb63f8rCvjK2Z1w9 hltCqgILrPkBWZf7D6lZQrTVsQ9bYGNjEQQXo2D58+bj+Zbr/uJommfLuFr/ZVITaGpYKs 3TdHSODcKkMVn6eBxvw3c05nJoauKJs= 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 v2 06/19] xen/sound: switch xen_snd_front to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:30 +0200 Message-Id: <20220428082743.16593-7-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: 1651134501083100003 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- sound/xen/xen_snd_front_evtchnl.c | 4 ++-- sound/xen/xen_snd_front_evtchnl.h | 9 --------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_ev= tchnl.c index ecbc294fc59a..3e21369c8216 100644 --- a/sound/xen/xen_snd_front_evtchnl.c +++ b/sound/xen/xen_snd_front_evtchnl.c @@ -167,7 +167,7 @@ static void evtchnl_free(struct xen_snd_front_info *fro= nt_info, xenbus_free_evtchn(front_info->xb_dev, channel->port); =20 /* End access and free the page. */ - if (channel->gref !=3D GRANT_INVALID_REF) + if (channel->gref !=3D INVALID_GRANT_REF) gnttab_end_foreign_access(channel->gref, page); else free_page(page); @@ -207,7 +207,7 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, channel->index =3D index; channel->front_info =3D front_info; channel->state =3D EVTCHNL_STATE_DISCONNECTED; - channel->gref =3D GRANT_INVALID_REF; + channel->gref =3D INVALID_GRANT_REF; page =3D get_zeroed_page(GFP_KERNEL); if (!page) { ret =3D -ENOMEM; diff --git a/sound/xen/xen_snd_front_evtchnl.h b/sound/xen/xen_snd_front_ev= tchnl.h index cbe51fd1ec15..3675fba70564 100644 --- a/sound/xen/xen_snd_front_evtchnl.h +++ b/sound/xen/xen_snd_front_evtchnl.h @@ -15,15 +15,6 @@ =20 struct xen_snd_front_info; =20 -#ifndef GRANT_INVALID_REF -/* - * FIXME: usage of grant reference 0 as invalid grant reference: - * grant reference 0 is valid, but never exposed to a PV driver, - * because of the fact it is already in use/reserved by the PV console. - */ -#define GRANT_INVALID_REF 0 -#endif - /* Timeout in ms to wait for backend to respond. */ #define VSND_WAIT_BACK_MS 3000 =20 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134498; cv=none; d=zohomail.com; s=zohoarc; b=Ru7sR0cw/8wFaC+IC8VO7xhBUsI7iLlGo8Yxhg9CfPgY3gGlumgsSTnM7d7h2aXc57x3XhJwnG88gDpE45sfjLxSYXPQwAzsVuWWh97tYBa1G5xWW1sU7k9OvnX9x3pHqMSxtteaA+mYISv03qQwmB4L/B5Veboy7u4c91SxFss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134498; 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=SPIngja7rfH6/X0ahWtYB7L7nX8NRl4zj/+cjR7xZr0=; b=U62iRfhx6uQsP/ZuMBSwAVkxgpOPNUuT2Bzg3/CVZ4bHEBBaVK6sVSN+Q+8yr8W5wzd7t3j1GtRWMw5e5GLRWGkUcc8X7ssUJMSCRKY9jqCeFoJ97NgKCY0aDpB8nIf+hrK+M10gjyZEz36e4vTCWAiJYczchsRPSiK+x/sg1wY= 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 1651134498586619.4587175008214; Thu, 28 Apr 2022 01:28:18 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316177.535011 (Exim 4.92) (envelope-from ) id 1njzVE-0006wj-V2; Thu, 28 Apr 2022 08:27:56 +0000 Received: by outflank-mailman (output) from mailman id 316177.535011; Thu, 28 Apr 2022 08:27:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVE-0006q5-7F; Thu, 28 Apr 2022 08:27:56 +0000 Received: by outflank-mailman (input) for mailman id 316177; Thu, 28 Apr 2022 08:27:53 +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 1njzVB-0005SL-AT for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:53 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1708cee3-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:50 +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 B78F51F88A; Thu, 28 Apr 2022 08:27:49 +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 8A17913491; Thu, 28 Apr 2022 08:27:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CFi8HwVQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:49 +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: 1708cee3-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134469; 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=SPIngja7rfH6/X0ahWtYB7L7nX8NRl4zj/+cjR7xZr0=; b=b7TnDrRcZ8z68LrDQfaX1DqYfORj8ovWaBSLWfmePTyAcTrj7ib5gCErS/v1IQdBeh1X3M Qu5cD8Fe5euQgJsZU3TUwzQz/XM70bZA++EtW65/fPX/tHI910GU8H0Dh8g3F4RlQWAky9 CV2BiAzCmMq6L8R2HrQyYiQ9FoU5Y7A= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v2 07/19] xen/dmabuf: switch gntdev-dmabuf to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:31 +0200 Message-Id: <20220428082743.16593-8-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: 1651134499014100005 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- drivers/xen/gntdev-dmabuf.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c index d5bfd7b867fc..91073b4e4a20 100644 --- a/drivers/xen/gntdev-dmabuf.c +++ b/drivers/xen/gntdev-dmabuf.c @@ -24,15 +24,6 @@ =20 MODULE_IMPORT_NS(DMA_BUF); =20 -#ifndef GRANT_INVALID_REF -/* - * Note on usage of grant reference 0 as invalid grant reference: - * grant reference 0 is valid, but never exposed to a driver, - * because of the fact it is already in use/reserved by the PV console. - */ -#define GRANT_INVALID_REF 0 -#endif - struct gntdev_dmabuf { struct gntdev_dmabuf_priv *priv; struct dma_buf *dmabuf; @@ -532,7 +523,7 @@ static void dmabuf_imp_end_foreign_access(u32 *refs, in= t count) int i; =20 for (i =3D 0; i < count; i++) - if (refs[i] !=3D GRANT_INVALID_REF) + if (refs[i] !=3D INVALID_GRANT_REF) gnttab_end_foreign_access(refs[i], 0UL); } =20 @@ -567,7 +558,7 @@ static struct gntdev_dmabuf *dmabuf_imp_alloc_storage(i= nt count) gntdev_dmabuf->nr_pages =3D count; =20 for (i =3D 0; i < count; i++) - gntdev_dmabuf->u.imp.refs[i] =3D GRANT_INVALID_REF; + gntdev_dmabuf->u.imp.refs[i] =3D INVALID_GRANT_REF; =20 return gntdev_dmabuf; =20 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134499; cv=none; d=zohomail.com; s=zohoarc; b=Gf+7ktvQC+fCoaMwQmEwDl9pJqu9uyVtDG22Q0cMYVvC8ES4iFFDcKoWO7xRogvf1ZruhcNSt43CGs/tW3nLkc5BzIKzQPbkNxx+n5KusNHqTv1/h/YGrGiRsZqUH9DD2kvvCpXsOLZynpWaGrfEI4A084sQl+v9EcnLuqT+boU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134499; 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=27ryrQ9/V3A+L0L1cMkzg+znNHks8+NEi42Ak1eCxTQ=; b=IgJsgObgkukZR8rD81lWck/C73uYOPdD7dOvKd1x29yFyQXnI7zY02XMiheJ5pir+Uuv5L4R8KsId2V6/0LCm6nja1cy+wiiJjYas0fcu8rI6Xk4/GVZr7Ctf4G0yDJ/PZ9MgxR31QhDbbVcOo6fH81RYJhfZJytt//dWfFTGaU= 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 1651134499499706.810213951869; Thu, 28 Apr 2022 01:28:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316176.535002 (Exim 4.92) (envelope-from ) id 1njzVD-0006fp-T9; Thu, 28 Apr 2022 08:27:55 +0000 Received: by outflank-mailman (output) from mailman id 316176.535002; Thu, 28 Apr 2022 08:27:55 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVD-0006eF-8r; Thu, 28 Apr 2022 08:27:55 +0000 Received: by outflank-mailman (input) for mailman id 316176; Thu, 28 Apr 2022 08:27:52 +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 1njzVA-0005SM-EB for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:52 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 172293ae-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:50 +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 EE17421874; Thu, 28 Apr 2022 08:27:49 +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 BFF4713491; Thu, 28 Apr 2022 08:27:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mGl2LQVQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:49 +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: 172293ae-c6cd-11ec-8fc3-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134469; 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=27ryrQ9/V3A+L0L1cMkzg+znNHks8+NEi42Ak1eCxTQ=; b=OuTXoWvhfYYiK6CpG+Xj3URKFgDVAutPiSkezySiwcZy5fZN/9LUWyECUUdJYzu/QyFtIK IlWEbdsvMavVm0S7cE2dMet6r3Ofm33wYWqZxXMaKMQ+q2ofTy2NzLxMYjglo8jdcdMQIn Gfl9iKNb3w0tnJ62vhff94o8tpqp+WM= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v2 08/19] xen/shbuf: switch xen-front-pgdir-shbuf to use INVALID_GRANT_REF Date: Thu, 28 Apr 2022 10:27:32 +0200 Message-Id: <20220428082743.16593-9-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: 1651134501086100004 Content-Type: text/plain; charset="utf-8" Instead of using a private macro for an invalid grant reference use the common one. Signed-off-by: Juergen Gross --- drivers/xen/xen-front-pgdir-shbuf.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/xen/xen-front-pgdir-shbuf.c b/drivers/xen/xen-front-pg= dir-shbuf.c index a959dee21134..fa2921d4fbfc 100644 --- a/drivers/xen/xen-front-pgdir-shbuf.c +++ b/drivers/xen/xen-front-pgdir-shbuf.c @@ -21,15 +21,6 @@ =20 #include =20 -#ifndef GRANT_INVALID_REF -/* - * FIXME: usage of grant reference 0 as invalid grant reference: - * grant reference 0 is valid, but never exposed to a PV driver, - * because of the fact it is already in use/reserved by the PV console. - */ -#define GRANT_INVALID_REF 0 -#endif - /** * This structure represents the structure of a shared page * that contains grant references to the pages of the shared @@ -83,7 +74,7 @@ grant_ref_t xen_front_pgdir_shbuf_get_dir_start(struct xen_front_pgdir_shbuf *buf) { if (!buf->grefs) - return GRANT_INVALID_REF; + return INVALID_GRANT_REF; =20 return buf->grefs[0]; } @@ -142,7 +133,7 @@ void xen_front_pgdir_shbuf_free(struct xen_front_pgdir_= shbuf *buf) int i; =20 for (i =3D 0; i < buf->num_grefs; i++) - if (buf->grefs[i] !=3D GRANT_INVALID_REF) + if (buf->grefs[i] !=3D INVALID_GRANT_REF) gnttab_end_foreign_access(buf->grefs[i], 0UL); } kfree(buf->grefs); @@ -355,7 +346,7 @@ static void backend_fill_page_dir(struct xen_front_pgdi= r_shbuf *buf) } /* Last page must say there is no more pages. */ page_dir =3D (struct xen_page_directory *)ptr; - page_dir->gref_dir_next_page =3D GRANT_INVALID_REF; + page_dir->gref_dir_next_page =3D INVALID_GRANT_REF; } =20 /** @@ -384,7 +375,7 @@ static void guest_fill_page_dir(struct xen_front_pgdir_= shbuf *buf) =20 if (grefs_left <=3D XEN_NUM_GREFS_PER_PAGE) { to_copy =3D grefs_left; - page_dir->gref_dir_next_page =3D GRANT_INVALID_REF; + page_dir->gref_dir_next_page =3D INVALID_GRANT_REF; } else { to_copy =3D XEN_NUM_GREFS_PER_PAGE; page_dir->gref_dir_next_page =3D buf->grefs[i + 1]; --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134505; cv=none; d=zohomail.com; s=zohoarc; b=ShkpQ+X6eaqIcnGcbVUkj7g7etaAUQW0EQdB6BuFfgf858Nvo9FGTpfciCsQC9XE+CvL2E0shAHvdJHu5YOTo8A9c/smb8VpL47CwX6l8SkzY7n0HQ+YodNPay8EvfhVG5wJyHHaqomZBf5It5KBRoQuBi9K9KevuYTQo9yHq3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134505; 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=8veqePX7rdlWDFOqgS78jUbLrgjtOmHQWA4ds9ys4IE=; b=lwyrBYjQ9yti1gtU/KlO3l3Qf0GfaK47BOs8F1JIkQ16ZpQmxRmk0UnC7CECN4m+tLdjZMHBKl3aUJT6xV1RgFRWEkohFYc0/IBGzhbCfGKCQnmD2VR7p9z9xvYIUmkxvokEKRcYdiLKfiUeHFfF7D93SPyEb/e+U9GOo3hjEFM= 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 1651134505150938.0553111239091; Thu, 28 Apr 2022 01:28:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316179.535044 (Exim 4.92) (envelope-from ) id 1njzVJ-0007u6-3Y; Thu, 28 Apr 2022 08:28:01 +0000 Received: by outflank-mailman (output) from mailman id 316179.535044; Thu, 28 Apr 2022 08:28:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVI-0007qQ-FX; Thu, 28 Apr 2022 08:28:00 +0000 Received: by outflank-mailman (input) for mailman id 316179; Thu, 28 Apr 2022 08:27:54 +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 1njzVC-0005SL-Aj for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:54 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17541ed6-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:50 +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 464531F8AC; Thu, 28 Apr 2022 08:27:50 +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 038BE13491; Thu, 28 Apr 2022 08:27:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kIMQOwVQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:49 +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: 17541ed6-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134470; 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=8veqePX7rdlWDFOqgS78jUbLrgjtOmHQWA4ds9ys4IE=; b=rlIU5c4XpDDC7FrePn4vUJzKDyXHqwBA/KrdUbuegUL/GMk4CbeRxuLFKYzRcV4h6uEH0R L0jIaXxjVS2Dr3TW9oriwnhhCWoUjTrAD4Ua6LmdjKnMAEecMlj3qMU8neAALFcwsCaTww qTn2D9U/CoxHhFQs9ltdPwvn5qwcNqw= From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , "David S. Miller" , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2 09/19] xen: update ring.h Date: Thu, 28 Apr 2022 10:27:33 +0200 Message-Id: <20220428082743.16593-10-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: 1651134507056100020 Content-Type: text/plain; charset="utf-8" Update include/xen/interface/io/ring.h to its newest version. Switch the two improper use cases of RING_HAS_UNCONSUMED_RESPONSES() to XEN_RING_NR_UNCONSUMED_RESPONSES() in order to avoid the nasty XEN_RING_HAS_UNCONSUMED_IS_BOOL #define. Signed-off-by: Juergen Gross --- V2: - new patch --- drivers/net/xen-netfront.c | 4 ++-- include/xen/interface/io/ring.h | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index af3d3de7d9fa..966bee2a6902 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -866,7 +866,7 @@ static void xennet_set_rx_rsp_cons(struct netfront_queu= e *queue, RING_IDX val) =20 spin_lock_irqsave(&queue->rx_cons_lock, flags); queue->rx.rsp_cons =3D val; - queue->rx_rsp_unconsumed =3D RING_HAS_UNCONSUMED_RESPONSES(&queue->rx); + queue->rx_rsp_unconsumed =3D XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); spin_unlock_irqrestore(&queue->rx_cons_lock, flags); } =20 @@ -1498,7 +1498,7 @@ static bool xennet_handle_rx(struct netfront_queue *q= ueue, unsigned int *eoi) return false; =20 spin_lock_irqsave(&queue->rx_cons_lock, flags); - work_queued =3D RING_HAS_UNCONSUMED_RESPONSES(&queue->rx); + work_queued =3D XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); if (work_queued > queue->rx_rsp_unconsumed) { queue->rx_rsp_unconsumed =3D work_queued; *eoi =3D 0; diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/rin= g.h index 2470ec45ebb2..ba4c4274b714 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h @@ -72,9 +72,8 @@ typedef unsigned int RING_IDX; * of the shared memory area (PAGE_SIZE, for instance). To initialise * the front half: * - * mytag_front_ring_t front_ring; - * SHARED_RING_INIT((mytag_sring_t *)shared_page); - * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZ= E); + * mytag_front_ring_t ring; + * XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE); * * Initializing the back follows similarly (note that only the front * initializes the shared ring): @@ -146,6 +145,11 @@ struct __name##_back_ring { = \ =20 #define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __siz= e) =20 +#define XEN_FRONT_RING_INIT(r, s, size) do { \ + SHARED_RING_INIT(s); \ + FRONT_RING_INIT(r, s, size); \ +} while (0) + #define BACK_RING_ATTACH(_r, _s, _i, __size) do { \ (_r)->rsp_prod_pvt =3D (_i); \ (_r)->req_cons =3D (_i); \ @@ -170,16 +174,21 @@ struct __name##_back_ring { = \ (RING_FREE_REQUESTS(_r) =3D=3D 0) =20 /* Test if there are outstanding messages to be processed on a ring. */ -#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ +#define XEN_RING_NR_UNCONSUMED_RESPONSES(_r) \ ((_r)->sring->rsp_prod - (_r)->rsp_cons) =20 -#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ +#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r) ({ \ unsigned int req =3D (_r)->sring->req_prod - (_r)->req_cons; \ unsigned int rsp =3D RING_SIZE(_r) - \ ((_r)->req_cons - (_r)->rsp_prod_pvt); \ req < rsp ? req : rsp; \ }) =20 +#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ + (!!XEN_RING_NR_UNCONSUMED_RESPONSES(_r)) +#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ + (!!XEN_RING_NR_UNCONSUMED_REQUESTS(_r)) + /* Direct access to individual ring elements, by index. */ #define RING_GET_REQUEST(_r, _idx) \ (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134500; cv=none; d=zohomail.com; s=zohoarc; b=WfY0Ro7FQhChunpCMdP5Iy0tfa/3TgkaALBX685TbzI/KPtuFyYXZ9xFpiF3yTNHxw43Dzb8NKKaRhJF8cDC/yKUUrLmJEp+jtwV65qVUFZu59A+YuVjkFU2rO6R/pzZ9U6MnazkfMLLhOfbL06MbYlBOCPRpjR+JbbrGIi7P/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134500; 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=YDGIDWKPRWQB7unVe+D0Q46rvuLr6BdasgzAbPg2LQ4=; b=kSevFIciF2Cnp2DU2ETuELaikR5ZC+ZfdOSPfTX8Sow10OQiGxjtCZkD7sbvAju+wd2HYBPT43hDtxFD2H7BK8as4zJhUhVkwOzrwcimDNb0W0T32WKpZU0jmlIJxA8dNMD1192+45zJay5vU3n9zAogBF0+oKZ0dMjRsgWu6RA= 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 1651134500545425.9946646169142; Thu, 28 Apr 2022 01:28:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316178.535021 (Exim 4.92) (envelope-from ) id 1njzVF-0007BX-SU; Thu, 28 Apr 2022 08:27:57 +0000 Received: by outflank-mailman (output) from mailman id 316178.535021; Thu, 28 Apr 2022 08:27:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVF-00078K-CQ; Thu, 28 Apr 2022 08:27:57 +0000 Received: by outflank-mailman (input) for mailman id 316178; Thu, 28 Apr 2022 08:27:53 +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 1njzVB-0005SM-EE for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:53 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 17755833-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:50 +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 7D74021876; Thu, 28 Apr 2022 08:27:50 +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 5049213491; Thu, 28 Apr 2022 08:27:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CKAEEgZQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:50 +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: 17755833-c6cd-11ec-8fc3-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134470; 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=YDGIDWKPRWQB7unVe+D0Q46rvuLr6BdasgzAbPg2LQ4=; b=T5xs3W2ptqXsPfAvqIrcBVCVmeIIst8eIXsa6BQstyNsdU/WQh1htmsRml82tfTV2fGZ3M 7cGIdDix3zSa2IetRSiHt7IZIEFkNcvniiOV1J8BaTLWaoZ1RioIq/s150J0i7xKAcImqK uRJEG3SHaqX4FP/qg/DOiCvut/Qn7YI= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v2 10/19] xen/xenbus: add xenbus_setup_ring() service function Date: Thu, 28 Apr 2022 10:27:34 +0200 Message-Id: <20220428082743.16593-11-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: 1651134501094100005 Content-Type: text/plain; charset="utf-8" Most PV device frontends share very similar code for setting up shared ring buffers: - allocate page(s) - init the ring admin data - give the backend access to the ring via grants Tearing down the ring requires similar actions in all frontends again: - remove grants - free the page(s) Provide service functions xenbus_setup_ring() and xenbus_teardown_ring() for that purpose. Signed-off-by: Juergen Gross --- drivers/xen/xenbus/xenbus_client.c | 69 ++++++++++++++++++++++++++++++ include/xen/xenbus.h | 4 ++ 2 files changed, 73 insertions(+) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus= _client.c index df6890681231..1a2e0d94ccd1 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -407,6 +407,75 @@ int xenbus_grant_ring(struct xenbus_device *dev, void = *vaddr, } EXPORT_SYMBOL_GPL(xenbus_grant_ring); =20 +/* + * xenbus_setup_ring + * @dev: xenbus device + * @vaddr: pointer to starting virtual address of the ring + * @nr_pages: number of pages to be granted + * @grefs: grant reference array to be filled in + * + * Allocate physically contiguous pages for a shared ring buffer and grant= it + * to the peer of the given device. The ring buffer is initially filled wi= th + * zeroes. The virtual address of the ring is stored at @vaddr and the + * grant references are stored in the @grefs array. In case of error @vaddr + * will be set to NULL and @grefs will be filled with INVALID_GRANT_REF. + */ +int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr, + unsigned int nr_pages, grant_ref_t *grefs) +{ + unsigned long ring_size =3D nr_pages * XEN_PAGE_SIZE; + unsigned int i; + int ret; + + *vaddr =3D alloc_pages_exact(ring_size, gfp | __GFP_ZERO); + if (!*vaddr) { + ret =3D -ENOMEM; + goto err; + } + + ret =3D xenbus_grant_ring(dev, *vaddr, nr_pages, grefs); + if (ret) + goto err; + + return 0; + + err: + if (*vaddr) + free_pages_exact(*vaddr, ring_size); + for (i =3D 0; i < nr_pages; i++) + grefs[i] =3D INVALID_GRANT_REF; + *vaddr =3D NULL; + + return ret; +} +EXPORT_SYMBOL_GPL(xenbus_setup_ring); + +/* + * xenbus_teardown_ring + * @vaddr: starting virtual address of the ring + * @nr_pages: number of pages + * @grefs: grant reference array + * + * Remove grants for the shared ring buffer and free the associated memory. + * On return the grant reference array is filled with INVALID_GRANT_REF. + */ +void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages, + grant_ref_t *grefs) +{ + unsigned int i; + + for (i =3D 0; i < nr_pages; i++) { + if (grefs[i] !=3D INVALID_GRANT_REF) { + gnttab_end_foreign_access(grefs[i], 0); + grefs[i] =3D INVALID_GRANT_REF; + } + } + + if (*vaddr) + free_pages_exact(*vaddr, nr_pages * XEN_PAGE_SIZE); + *vaddr =3D NULL; +} +EXPORT_SYMBOL_GPL(xenbus_teardown_ring); =20 /** * Allocate an event channel for the given xenbus_device, assigning the ne= wly diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b13eb86395e0..b533b4adc835 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -226,6 +226,10 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, st= ruct xenbus_watch *watch, int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_s= tate); int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, unsigned int nr_pages, grant_ref_t *grefs); +int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr, + unsigned int nr_pages, grant_ref_t *grefs); +void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages, + grant_ref_t *grefs); int xenbus_map_ring_valloc(struct xenbus_device *dev, grant_ref_t *gnt_ref= s, unsigned int nr_grefs, void **vaddr); =20 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8290DC433F5 for ; Thu, 28 Apr 2022 08:29:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344406AbiD1IcY (ORCPT ); Thu, 28 Apr 2022 04:32:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344181AbiD1IbH (ORCPT ); Thu, 28 Apr 2022 04:31:07 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 846F0972D6; Thu, 28 Apr 2022 01:27:52 -0700 (PDT) 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 C72351F88F; Thu, 28 Apr 2022 08:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134470; 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=VDUTirs/68J75dLhVfxQ8SwGZggDnAgUBf0vqNCyldA=; b=uYPkEtI1D+dBDttNAMWwXe5ps2vwOgVNOH3jvmBtgFhBUy/z0IPKe2AMkUYo9qfXjXomlv eDi8P8+olYpzbp6RDG+C2VAYvNC2s/qwj3kH+fQ1mRdC6zeuKb69a8lZJCAUDt5w17TMiZ crrx8z21AJh4HirtTLTotjXWv2WOsT4= 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 86DCA13491; Thu, 28 Apr 2022 08:27:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qJVhHwZQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:50 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Boris Ostrovsky , Stefano Stabellini , Jens Axboe Subject: [PATCH v2 11/19] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:35 +0200 Message-Id: <20220428082743.16593-12-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Simplify blkfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/block/xen-blkfront.c | 37 ++++++++---------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 7f35e30e626a..bd7b34f29193 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1280,15 +1280,8 @@ static void blkif_free_ring(struct blkfront_ring_inf= o *rinfo) flush_work(&rinfo->work); =20 /* Free resources associated with old device channel. */ - for (i =3D 0; i < info->nr_ring_pages; i++) { - if (rinfo->ring_ref[i] !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(rinfo->ring_ref[i], 0); - rinfo->ring_ref[i] =3D INVALID_GRANT_REF; - } - } - free_pages_exact(rinfo->ring.sring, - info->nr_ring_pages * XEN_PAGE_SIZE); - rinfo->ring.sring =3D NULL; + xenbus_teardown_ring((void **)&rinfo->ring.sring, info->nr_ring_pages, + rinfo->ring_ref); =20 if (rinfo->irq) unbind_from_irqhandler(rinfo->irq, rinfo); @@ -1679,30 +1672,16 @@ static int setup_blkring(struct xenbus_device *dev, struct blkfront_ring_info *rinfo) { struct blkif_sring *sring; - int err, i; + int err; struct blkfront_info *info =3D rinfo->dev_info; unsigned long ring_size =3D info->nr_ring_pages * XEN_PAGE_SIZE; - grant_ref_t gref[XENBUS_MAX_RING_GRANTS]; - - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D INVALID_GRANT_REF; =20 - sring =3D alloc_pages_exact(ring_size, GFP_NOIO); - if (!sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring"); - return -ENOMEM; - } - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&rinfo->ring, sring, ring_size); - - err =3D xenbus_grant_ring(dev, rinfo->ring.sring, info->nr_ring_pages, gr= ef); - if (err < 0) { - free_pages_exact(sring, ring_size); - rinfo->ring.sring =3D NULL; + err =3D xenbus_setup_ring(dev, GFP_NOIO, (void **)&sring, + info->nr_ring_pages, rinfo->ring_ref); + if (err) goto fail; - } - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D gref[i]; + + XEN_FRONT_RING_INIT(&rinfo->ring, sring, ring_size); =20 err =3D xenbus_alloc_evtchn(dev, &rinfo->evtchn); if (err) --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134503; cv=none; d=zohomail.com; s=zohoarc; b=IaetDnZMzbEI154bdR/Q+IvIUtpXvYtmhDLUu4YSW01Yiq5HXLMmwkcdk1JTm2drwVdYleNLi+PmMrt88uuKt3bch3dnFP52WIYLb+PqMORv+oVR35PCYuwkv5NVUymIgpyHBit87yehV8Ng9Qda+3T4/kUNyCDqXrzM1Y+HnM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134503; 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=bVl00wdBYeWK59DNgpTl+klU3KYXSfeQcCWUD7CZHgs=; b=NyFvMXhgTK+k4sf5wnTKbZeAU5HkqG5UnR9Kd/4VCxkdgKr10qv3ghm2tbh+dcfBFhzR763Dij02qzFjeRe718GPdnuLTKtodVz5Xvl0aGp2oBdCWY6q264YbNml2pJ8TmrnqduYMviISpWgtD15BnKt2EPjUW51WaoS+0aEaXo= 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 1651134503291441.1636729427886; Thu, 28 Apr 2022 01:28:23 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316182.535061 (Exim 4.92) (envelope-from ) id 1njzVL-0008Iz-UE; Thu, 28 Apr 2022 08:28:03 +0000 Received: by outflank-mailman (output) from mailman id 316182.535061; Thu, 28 Apr 2022 08:28:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVK-0008FY-HF; Thu, 28 Apr 2022 08:28:02 +0000 Received: by outflank-mailman (input) for mailman id 316182; Thu, 28 Apr 2022 08:27:55 +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 1njzVD-0005SL-B3 for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:55 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 17d24682-c6cd-11ec-a405-831a346695d4; Thu, 28 Apr 2022 10:27:51 +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 213BC1F890; 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 CE03013491; Thu, 28 Apr 2022 08:27:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qCMIMQZQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:50 +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: 17d24682-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=bVl00wdBYeWK59DNgpTl+klU3KYXSfeQcCWUD7CZHgs=; b=k881eTR02k8w1RYRfM94bVRQVC+/P1KxAKK9Vr1oaKX1zwBgry4GKvMMbwXVTKe5Vz9u53 NzzI2WgN10PupMpUlvxc/YqIEqnJiuFBZzXUZpOWrtSvAndR0+LlKR61OsCyf7F7A5Xfen LBx/pgfQle9bOdS54vpk7CkRnFKHe3g= From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , "David S. Miller" , Jakub Kicinski , Paolo Abeni Subject: [PATCH v2 12/19] xen/netfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:36 +0200 Message-Id: <20220428082743.16593-13-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: 1651134505076100014 Content-Type: text/plain; charset="utf-8" Simplify netfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/net/xen-netfront.c | 53 +++++++++----------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 966bee2a6902..65ab907aca5a 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1921,8 +1921,7 @@ static int setup_netfront(struct xenbus_device *dev, struct netfront_queue *queue, unsigned int feature_split_evtchn) { struct xen_netif_tx_sring *txs; - struct xen_netif_rx_sring *rxs =3D NULL; - grant_ref_t gref; + struct xen_netif_rx_sring *rxs; int err; =20 queue->tx_ring_ref =3D INVALID_GRANT_REF; @@ -1930,33 +1929,19 @@ static int setup_netfront(struct xenbus_device *dev, queue->rx.sring =3D NULL; queue->tx.sring =3D NULL; =20 - txs =3D (struct xen_netif_tx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIG= H); - if (!txs) { - err =3D -ENOMEM; - xenbus_dev_fatal(dev, err, "allocating tx ring page"); + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&txs, + 1, &queue->tx_ring_ref); + if (err) goto fail; - } - SHARED_RING_INIT(txs); - FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, txs, 1, &gref); - if (err < 0) - goto fail; - queue->tx_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); =20 - rxs =3D (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIG= H); - if (!rxs) { - err =3D -ENOMEM; - xenbus_dev_fatal(dev, err, "allocating rx ring page"); + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs, + 1, &queue->rx_ring_ref); + if (err) goto fail; - } - SHARED_RING_INIT(rxs); - FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, rxs, 1, &gref); - if (err < 0) - goto fail; - queue->rx_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); =20 if (feature_split_evtchn) err =3D setup_netfront_split(queue); @@ -1972,24 +1957,10 @@ static int setup_netfront(struct xenbus_device *dev, =20 return 0; =20 - /* If we fail to setup netfront, it is safe to just revoke access to - * granted pages because backend is not accessing it at this point. - */ fail: - if (queue->rx_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(queue->rx_ring_ref, - (unsigned long)rxs); - queue->rx_ring_ref =3D INVALID_GRANT_REF; - } else { - free_page((unsigned long)rxs); - } - if (queue->tx_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(queue->tx_ring_ref, - (unsigned long)txs); - queue->tx_ring_ref =3D INVALID_GRANT_REF; - } else { - free_page((unsigned long)txs); - } + xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref); + xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref); + return err; } =20 --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134504; cv=none; d=zohomail.com; s=zohoarc; b=ANp+eJwBWQltcAvhxLIjxixrb4szsghCn/S+mqajD6YJ7a3sS5hr/mhoCpJPLVbwumZg7wgb1fOlJnnUCm6vMa7JAccczUON48T1B6l7hgAzF78kHshVWulYoXZalb2wjO9+rydTORE7340j/DoXyKp5eyVmfBxfn9jY9GKqjRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134504; 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=CI5eCbbUh0HTvUxNvVm6rOMW68v7G6W10HjxAtg/ngA=; b=iqKAXy2Dpz7qVPWrxf1b7bWPy683r0YPqTH7ikAjxU1oinsVnEGX5Gj40NZSQlPcWYJMLncRezLEtA1xzZTz8XbePgjT/+HjRfu9qvcyZ7v6GuJzpYi3b1juEnGseQDFraoW64qpGfKm8a/7/7aQgR8kdJ7e/W8EROG+bNEc3Ks= 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 1651134504372692.5026399279652; Thu, 28 Apr 2022 01:28:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316181.535051 (Exim 4.92) (envelope-from ) id 1njzVK-00082k-1t; Thu, 28 Apr 2022 08:28:02 +0000 Received: by outflank-mailman (output) from mailman id 316181.535051; Thu, 28 Apr 2022 08:28:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVJ-000808-4k; Thu, 28 Apr 2022 08:28:01 +0000 Received: by outflank-mailman (input) for mailman id 316181; Thu, 28 Apr 2022 08:27:55 +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 1njzVD-0005SM-Ey for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:55 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 17fa7363-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:51 +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 5F85421870; 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 27BFC13491; 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 2Fd3CAdQamIBLgAAMHmgww (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: 17fa7363-c6cd-11ec-8fc3-03012f2f19d4 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=CI5eCbbUh0HTvUxNvVm6rOMW68v7G6W10HjxAtg/ngA=; b=plhuxsR5eHWXzBK0P+35/4qRW5X11ur7K+VFwBQHFjrUXz367eeCDl5N4tO+2yDtlkMhzg YYPWBfxbelagkQWT0RoqKtMDb6YfVYgzvvOjcOzLMU+1dV3acvtrEjUNtANR3KBuDqcv2V NXaoQzG58L0ZWkmi9psNZD7qJZerN9M= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe Subject: [PATCH v2 13/19] xen/tpmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:37 +0200 Message-Id: <20220428082743.16593-14-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: 1651134505146100015 Content-Type: text/plain; charset="utf-8" Simplify tpmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/char/tpm/xen-tpmfront.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfron= t.c index 69df04ae2401..379291826261 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c @@ -253,20 +253,12 @@ static int setup_ring(struct xenbus_device *dev, stru= ct tpm_private *priv) struct xenbus_transaction xbt; const char *message =3D NULL; int rv; - grant_ref_t gref; =20 - priv->shr =3D (void *)__get_free_page(GFP_KERNEL|__GFP_ZERO); - if (!priv->shr) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring"); - return -ENOMEM; - } - - rv =3D xenbus_grant_ring(dev, priv->shr, 1, &gref); + rv =3D xenbus_setup_ring(dev, GFP_KERNEL, (void **)&priv->shr, 1, + &priv->ring_ref); if (rv < 0) return rv; =20 - priv->ring_ref =3D gref; - rv =3D xenbus_alloc_evtchn(dev, &priv->evtchn); if (rv) return rv; @@ -331,11 +323,7 @@ static void ring_free(struct tpm_private *priv) if (!priv) return; =20 - if (priv->ring_ref) - gnttab_end_foreign_access(priv->ring_ref, - (unsigned long)priv->shr); - else - free_page((unsigned long)priv->shr); + xenbus_teardown_ring((void **)&priv->shr, 1, &priv->ring_ref); =20 if (priv->irq) unbind_from_irqhandler(priv->irq, priv); --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134508; cv=none; d=zohomail.com; s=zohoarc; b=ByrheaR/Yee3VbCK6+2BJJNmi6Ejr5btNmNW+EYhVltw9VCGZRcWMl2968tzYDLtiJKk0hkTNg40dJudJFyNifUjiU89Dg3MAfS2hSRce/3EYP2hRak80xxSyeTLApyKzOd3zvEoLqeHSAcmHRSoUBLQo7jhqwfVMOecPnMpIZ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134508; 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=pzS6PLrR2PHAizt1+i4tl6giJjA8snqDfs2l2Q2VBs0=; b=SmTDEvw5v4ctXzNcpoI5XKN7Kqo31baeOfix+4vEjVdmRVlVLMaFYm3gUBAGzCcsIVtXM9lKa/Hx0ej1df1m/UJ/e9wjUQwuuKvBlMFlmmXO5owL3dCKLuULOOsqa4GBkYQ6OhODXR7dJhYJVVqqIt7RwrufVvwTvfFUhEXvhno= 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 1651134508860714.6954278293413; Thu, 28 Apr 2022 01:28:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316184.535076 (Exim 4.92) (envelope-from ) id 1njzVP-0000c7-L0; Thu, 28 Apr 2022 08:28:07 +0000 Received: by outflank-mailman (output) from mailman id 316184.535076; Thu, 28 Apr 2022 08:28:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVO-0000U1-5y; Thu, 28 Apr 2022 08:28:06 +0000 Received: by outflank-mailman (input) for mailman id 316184; Thu, 28 Apr 2022 08:27:56 +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 1njzVE-0005SM-F9 for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:56 +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 1827338a-c6cd-11ec-8fc3-03012f2f19d4; Thu, 28 Apr 2022 10:27:51 +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 A49C61F88C; 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 695A913491; 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 eDY0GAdQamIBLgAAMHmgww (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: 1827338a-c6cd-11ec-8fc3-03012f2f19d4 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=pzS6PLrR2PHAizt1+i4tl6giJjA8snqDfs2l2Q2VBs0=; b=nFFFyryTPJUwSGLm0DOiWi5pBKFreuwVT6dtG6vv7wwwjuQBZiXQURV9kZVktg8KWsLx1t ilLRU/ya4Wl0h4xf0vilOs5Q1STs8uNfcYkc77DBM7WYb0v8XRhp6kV9DQJWf22LPv4YH4 YeMQaNn8uOAEoouaJA49F3Fl0qU4Z08= From: Juergen Gross To: xen-devel@lists.xenproject.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Oleksandr Andrushchenko , David Airlie , Daniel Vetter Subject: [PATCH v2 14/19] xen/drmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:38 +0200 Message-Id: <20220428082743.16593-15-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: 1651134509091100023 Content-Type: text/plain; charset="utf-8" Simplify drmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 43 ++++++--------------- 1 file changed, 11 insertions(+), 32 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..e52afd792346 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, voi= d *dev_id) static void evtchnl_free(struct xen_drm_front_info *front_info, struct xen_drm_front_evtchnl *evtchnl) { - unsigned long page =3D 0; + void *page =3D NULL; =20 if (evtchnl->type =3D=3D EVTCHNL_TYPE_REQ) - page =3D (unsigned long)evtchnl->u.req.ring.sring; + page =3D evtchnl->u.req.ring.sring; else if (evtchnl->type =3D=3D EVTCHNL_TYPE_EVT) - page =3D (unsigned long)evtchnl->u.evt.page; + page =3D evtchnl->u.evt.page; if (!page) return; =20 @@ -147,8 +147,7 @@ static void evtchnl_free(struct xen_drm_front_info *fro= nt_info, xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); =20 /* end access and free the page */ - if (evtchnl->gref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(evtchnl->gref, page); + xenbus_teardown_ring(&page, 1, &evtchnl->gref); =20 memset(evtchnl, 0, sizeof(*evtchnl)); } @@ -158,8 +157,7 @@ static int evtchnl_alloc(struct xen_drm_front_info *fro= nt_info, int index, enum xen_drm_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; int ret; =20 @@ -168,44 +166,25 @@ static int evtchnl_alloc(struct xen_drm_front_info *f= ront_info, int index, evtchnl->index =3D index; evtchnl->front_info =3D front_info; evtchnl->state =3D EVTCHNL_STATE_DISCONNECTED; - evtchnl->gref =3D INVALID_GRANT_REF; =20 - page =3D get_zeroed_page(GFP_NOIO | __GFP_HIGH); - if (!page) { - ret =3D -ENOMEM; + ret =3D xenbus_setup_ring(xb_dev, GFP_NOIO | __GFP_HIGH, &page, + 1, &evtchnl->gref); + if (ret) goto fail; - } =20 if (type =3D=3D EVTCHNL_TYPE_REQ) { struct xen_displif_sring *sring; =20 init_completion(&evtchnl->u.req.completion); mutex_init(&evtchnl->u.req.req_io_lock); - sring =3D (struct xen_displif_sring *)page; - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); - - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - evtchnl->u.req.ring.sring =3D NULL; - free_page(page); - goto fail; - } + sring =3D page; + XEN_FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); =20 handler =3D evtchnl_interrupt_ctrl; } else { - ret =3D 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 =3D (struct xendispl_event_page *)page; - gref =3D ret; + evtchnl->u.evt.page =3D page; handler =3D evtchnl_interrupt_evt; } - evtchnl->gref =3D gref; =20 ret =3D xenbus_alloc_evtchn(xb_dev, &evtchnl->port); if (ret < 0) --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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 From nobody Fri May 10 09:39:34 2024 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=1651134512; cv=none; d=zohomail.com; s=zohoarc; b=eoDUXIl4XLfQDFVmZcHA+LSItlObtr0PLJ4a6ocOR7Oto11nhvV+MtbtX2dDVOg3G6bpT0HMebi+QQ7RYW7dHnBFfU7CJET0DM3ugBz3mjRBVGlfY3cbgL3otkXqfj35dzWya6ZmRG+xJJHU2iDctawtxekwfH8mbzXK/2DZVWk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134512; 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=1OIhlvhpDf96xGkhA26yZf7pns1SEZ9vLk/EobSBf7U=; b=AbDdW9snLLWTTk2m0W/xMXfiRQ7pfnGKqjEnnOW2mDse8G8QC941QuxX0g3fFkkO5gT/dLVpMCoPx6zDHNNrJ6VHuQS3Eanp49B7iQW/Hvj2bzABcEObUQQ4EaqnHKTVOb53BTO2z8cw8vEL1BtDb6h1NsJqMWmdw588M+QHy9w= 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 1651134512951293.20812066174324; Thu, 28 Apr 2022 01:28:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316185.535091 (Exim 4.92) (envelope-from ) id 1njzVS-00017g-Mz; Thu, 28 Apr 2022 08:28:10 +0000 Received: by outflank-mailman (output) from mailman id 316185.535091; Thu, 28 Apr 2022 08:28:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVQ-0000xd-MF; Thu, 28 Apr 2022 08:28:08 +0000 Received: by outflank-mailman (input) for mailman id 316185; Thu, 28 Apr 2022 08:27:58 +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 1njzVF-0005SL-Bj for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:57 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 187ae0aa-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-out2.suse.de (Postfix) with ESMTPS id 3C6951F88B; Thu, 28 Apr 2022 08:27:52 +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 EEBE613491; 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 GGn6OAdQamIBLgAAMHmgww (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: 187ae0aa-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134472; 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=1OIhlvhpDf96xGkhA26yZf7pns1SEZ9vLk/EobSBf7U=; b=e4ZiNoI9Kk/vxF6WBGPMvTgtaqzePnrbSEgd3HhKF9fP7PEcYc6C3tzqPjkZsraNDBQpgQ Xh5BmiCZb69+V49nJ6MhqGTMRLvrWvGZekAggS1g0NOR11UvMZk2/S6Lwh9yw+93369n8K zuoWN8JagVvATERzOOkykaCGvpybBDs= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , "James E.J. Bottomley" , "Martin K. Petersen" Subject: [PATCH v2 16/19] xen/scsifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:40 +0200 Message-Id: <20220428082743.16593-17-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: 1651134515155100001 Content-Type: text/plain; charset="utf-8" Simplify scsifront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- drivers/scsi/xen-scsifront.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 4c55e479fc36..51afc66e839d 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -798,27 +798,15 @@ static int scsifront_alloc_ring(struct vscsifrnt_info= *info) { struct xenbus_device *dev =3D info->dev; struct vscsiif_sring *sring; - grant_ref_t gref; - int err =3D -ENOMEM; + int err; =20 /***** Frontend to Backend ring start *****/ - sring =3D (struct vscsiif_sring *)__get_free_page(GFP_KERNEL); - if (!sring) { - xenbus_dev_fatal(dev, err, - "fail to allocate shared ring (Front to Back)"); + err =3D 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); =20 - err =3D 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 =3D gref; + XEN_FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); =20 err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { @@ -847,8 +835,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); =20 return err; } @@ -856,8 +843,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); } =20 static int scsifront_init_ring(struct vscsifrnt_info *info) --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 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=1651134514; cv=none; d=zohomail.com; s=zohoarc; b=Rxefc7tLcKXbEAvQuM7YOkjeRfsk1u29S/kDEwLnueTfYrldnzW50R8wxVpdJAmipy15RQpTyDiIU+Gp5nlKZh7P/u+MtQrQJFI8IienR6HNUazyyvjTcgyMAaG1ICq869+p0RcNtmmovrb8Upg2dnUwnHnkzxw9Hu5lFgia8ZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651134514; 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=7cqwaPLtFzhyk9LMWncXmAETsj1bDnyp+ydH1my5u10=; b=WaNadpTsr2wya1n77DN44u8OgYVTruTjkVpTF7SC/H+ABu2+aETVkGUdcf9Jtc6SU05JPd9XBBtua7egfvOfionww2VRRnP67x0PPQ0eBIcoT5Buk9HduDPwKcF/A72abXpXtlYQP7O923QfisyFZscpkhWMUiaiDMWmHGVViMQ= 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 1651134514239119.27811503351518; Thu, 28 Apr 2022 01:28:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.316186.535101 (Exim 4.92) (envelope-from ) id 1njzVU-0001jE-P1; Thu, 28 Apr 2022 08:28:12 +0000 Received: by outflank-mailman (output) from mailman id 316186.535101; Thu, 28 Apr 2022 08:28:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1njzVT-0001as-4i; Thu, 28 Apr 2022 08:28:11 +0000 Received: by outflank-mailman (input) for mailman id 316186; Thu, 28 Apr 2022 08:27:59 +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 1njzVG-0005SL-C6 for xen-devel@lists.xenproject.org; Thu, 28 Apr 2022 08:27:58 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 189c7fbc-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-out2.suse.de (Postfix) with ESMTPS id 7237D1F88A; Thu, 28 Apr 2022 08:27:52 +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 43ED413491; Thu, 28 Apr 2022 08:27:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QF5XDwhQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:52 +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: 189c7fbc-c6cd-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134472; 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=7cqwaPLtFzhyk9LMWncXmAETsj1bDnyp+ydH1my5u10=; b=XTUSjtzPzruE8bhqvv73TtSTB50qK9+aNrXbuRtAJ9c6hvz9KnGSHEC+p8iV6zrfVFvbr7 Me2MbBlNtrfCJ/FKyPE9+PGYOV6x5DQhu0AqYudjZTvyTvrfxBYt3eMH0Ldo8Fj7KYWYxl hQkceNSNaNLcPkHDy8rh2e1023pRJhY= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Greg Kroah-Hartman Subject: [PATCH v2 17/19] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:41 +0200 Message-Id: <20220428082743.16593-18-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: 1651134515164100002 Content-Type: text/plain; charset="utf-8" Simplify xen-hcd's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross Acked-by: Greg Kroah-Hartman --- drivers/usb/host/xen-hcd.c | 61 ++++++++++---------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c index 9cbc7c2dab02..de1b09158318 100644 --- a/drivers/usb/host/xen-hcd.c +++ b/drivers/usb/host/xen-hcd.c @@ -1098,19 +1098,10 @@ static void xenhcd_destroy_rings(struct xenhcd_info= *info) unbind_from_irqhandler(info->irq, info); info->irq =3D 0; =20 - if (info->urb_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(info->urb_ring_ref, - (unsigned long)info->urb_ring.sring); - info->urb_ring_ref =3D INVALID_GRANT_REF; - } - info->urb_ring.sring =3D NULL; - - if (info->conn_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(info->conn_ring_ref, - (unsigned long)info->conn_ring.sring); - info->conn_ring_ref =3D INVALID_GRANT_REF; - } - info->conn_ring.sring =3D NULL; + xenbus_teardown_ring((void **)&info->urb_ring.sring, 1, + &info->urb_ring_ref); + xenbus_teardown_ring((void **)&info->conn_ring.sring, 1, + &info->conn_ring_ref); } =20 static int xenhcd_setup_rings(struct xenbus_device *dev, @@ -1118,46 +1109,24 @@ static int xenhcd_setup_rings(struct xenbus_device = *dev, { struct xenusb_urb_sring *urb_sring; struct xenusb_conn_sring *conn_sring; - grant_ref_t gref; int err; =20 - info->urb_ring_ref =3D INVALID_GRANT_REF; info->conn_ring_ref =3D INVALID_GRANT_REF; - - urb_sring =3D (struct xenusb_urb_sring *)get_zeroed_page( - GFP_NOIO | __GFP_HIGH); - if (!urb_sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating urb ring"); - return -ENOMEM; - } - SHARED_RING_INIT(urb_sring); - FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); - - err =3D xenbus_grant_ring(dev, urb_sring, 1, &gref); - if (err < 0) { - free_page((unsigned long)urb_sring); - info->urb_ring.sring =3D NULL; - goto fail; - } - info->urb_ring_ref =3D gref; - - conn_sring =3D (struct xenusb_conn_sring *)get_zeroed_page( - GFP_NOIO | __GFP_HIGH); - if (!conn_sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating conn ring"); - err =3D -ENOMEM; - goto fail; + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, + (void **)&urb_sring, 1, &info->urb_ring_ref); + if (err) { + xenbus_dev_fatal(dev, err, "allocating urb ring"); + return err; } - SHARED_RING_INIT(conn_sring); - FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); + XEN_FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, conn_sring, 1, &gref); - if (err < 0) { - free_page((unsigned long)conn_sring); - info->conn_ring.sring =3D NULL; + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, + (void **)&conn_sring, 1, &info->conn_ring_ref); + if (err) { + xenbus_dev_fatal(dev, err, "allocating conn ring"); goto fail; } - info->conn_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); =20 err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { --=20 2.34.1 From nobody Fri May 10 09:39:34 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2744FC433F5 for ; Thu, 28 Apr 2022 08:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344292AbiD1Idg (ORCPT ); Thu, 28 Apr 2022 04:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344219AbiD1IbJ (ORCPT ); Thu, 28 Apr 2022 04:31:09 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F37BA0BD2 for ; Thu, 28 Apr 2022 01:27:54 -0700 (PDT) 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 B7E8F1F88D; Thu, 28 Apr 2022 08:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134472; 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=bFzOYs3GvoZ1bc2idQf8TBLq/Nc4sN1RlI7sPOTyE0I=; b=HNTQdnlj0qCLAqxzw388+FkheIAWG3gwHYAtRFSV9cIoUXwBDo2Iv94Cjlkxh2sI+LNuPe eLFVkOqNjIzUnhB/3qk/P9dSppkkTBWNGhorExasJlN0/U3whVT0HWJbZPavxKrAuaoTbs 4daprI//vTA4Gg5FL9df8FOk1WsMij0= 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 7BA3013491; Thu, 28 Apr 2022 08:27:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OLTnHAhQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:52 +0000 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 v2 18/19] xen/sndfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 28 Apr 2022 10:27:42 +0200 Message-Id: <20220428082743.16593-19-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 44 +++++++------------------------ 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_ev= tchnl.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 =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,18 @@ 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); - - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - channel->u.req.ring.sring =3D NULL; - goto fail; - } + XEN_FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE); =20 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 +257,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 From nobody Fri May 10 09:39:34 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 493B1C433F5 for ; Thu, 28 Apr 2022 08:30:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344443AbiD1IdV (ORCPT ); Thu, 28 Apr 2022 04:33:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344216AbiD1IbJ (ORCPT ); Thu, 28 Apr 2022 04:31:09 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53084A0BD6 for ; Thu, 28 Apr 2022 01:27:54 -0700 (PDT) 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 EF2F21F88E; Thu, 28 Apr 2022 08:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651134472; 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=DySE+lWBPx7VwNEF3X1lwYDq+4S10O0jUUqyaBArCE0=; b=nbgsI2l8XvMPHhwykxKcjmjFm5ic18dsQ4iNKTc8cOED/bFxCbEf3NTRN8JBCmnMBKGyQ2 qXLhAX68u5bD4eceSKKH1djjOsiFninHCccZsIkSwMsZEy1jxCtv8Ps2onc8BrAtqKGNng Yy+egfDuGQZXpsqZG2QPjJvI84+Pz7Q= 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 C01E513491; Thu, 28 Apr 2022 08:27:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mIuaLQhQamIBLgAAMHmgww (envelope-from ); Thu, 28 Apr 2022 08:27:52 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v2 19/19] xen/xenbus: eliminate xenbus_grant_ring() Date: Thu, 28 Apr 2022 10:27:43 +0200 Message-Id: <20220428082743.16593-20-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no external user of xenbus_grant_ring() left, so merge it into the only caller xenbus_setup_ring(). Signed-off-by: Juergen Gross Reviewed-by: Oleksandr Tyshchenko --- V2: - make error message more precise (Andrew Cooper) --- drivers/xen/xenbus/xenbus_client.c | 65 +++++++++--------------------- include/xen/xenbus.h | 2 - 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus= _client.c index 1a2e0d94ccd1..d6fdd2d209d3 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -363,50 +363,6 @@ static void xenbus_switch_fatal(struct xenbus_device *= dev, int depth, int err, __xenbus_switch_state(dev, XenbusStateClosing, 1); } =20 -/** - * xenbus_grant_ring - * @dev: xenbus device - * @vaddr: starting virtual address of the ring - * @nr_pages: number of pages to be granted - * @grefs: grant reference array to be filled in - * - * Grant access to the given @vaddr to the peer of the given device. - * Then fill in @grefs with grant references. Return 0 on success, or - * -errno on error. On error, the device will switch to - * XenbusStateClosing, and the error will be saved in the store. - */ -int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, - unsigned int nr_pages, grant_ref_t *grefs) -{ - int err; - unsigned int i; - grant_ref_t gref_head; - - err =3D gnttab_alloc_grant_references(nr_pages, &gref_head); - if (err) { - xenbus_dev_fatal(dev, err, "granting access to ring page"); - return err; - } - - for (i =3D 0; i < nr_pages; i++) { - unsigned long gfn; - - if (is_vmalloc_addr(vaddr)) - gfn =3D pfn_to_gfn(vmalloc_to_pfn(vaddr)); - else - gfn =3D virt_to_gfn(vaddr); - - grefs[i] =3D gnttab_claim_grant_reference(&gref_head); - gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id, - gfn, 0); - - vaddr =3D vaddr + XEN_PAGE_SIZE; - } - - return 0; -} -EXPORT_SYMBOL_GPL(xenbus_grant_ring); - /* * xenbus_setup_ring * @dev: xenbus device @@ -424,6 +380,7 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t = gfp, void **vaddr, unsigned int nr_pages, grant_ref_t *grefs) { unsigned long ring_size =3D nr_pages * XEN_PAGE_SIZE; + grant_ref_t gref_head; unsigned int i; int ret; =20 @@ -433,9 +390,25 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t= gfp, void **vaddr, goto err; } =20 - ret =3D xenbus_grant_ring(dev, *vaddr, nr_pages, grefs); - if (ret) + ret =3D gnttab_alloc_grant_references(nr_pages, &gref_head); + if (ret) { + xenbus_dev_fatal(dev, ret, "granting access to %u ring pages", + nr_pages); goto err; + } + + for (i =3D 0; i < nr_pages; i++) { + unsigned long gfn; + + if (is_vmalloc_addr(*vaddr)) + gfn =3D pfn_to_gfn(vmalloc_to_pfn(vaddr[i])); + else + gfn =3D virt_to_gfn(vaddr[i]); + + grefs[i] =3D gnttab_claim_grant_reference(&gref_head); + gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id, + gfn, 0); + } =20 return 0; =20 diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b533b4adc835..eaa932b99d8a 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -224,8 +224,6 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, str= uct xenbus_watch *watch, const char *pathfmt, ...); =20 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_s= tate); -int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, - unsigned int nr_pages, grant_ref_t *grefs); int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr, unsigned int nr_pages, grant_ref_t *grefs); void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages, --=20 2.34.1