From nobody Fri May 17 05:54:41 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=1650467430; cv=none; d=zohomail.com; s=zohoarc; b=R4/fpGZM2rivalklmKaKGAbyi0NuRXb38jua0OeA/7wEPu+aaNsjUDg7qdkILU+rDkv3JNLqNo3JVg/fWPr/dmBYTM6btQCZVAV90wJ0O7ttBmDlHDx7olSHiGGRzg7ByobmPP+aFMs0PIuFU9avOvuorFkTLpdA1W/gt6sfjOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467430; 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=lSLIgeEsoT5MdQHgQy3InmfR+Jk5fSDoxGBtsBUO5Yprx45/2yAnNVkPFuX+tyEpU3dE08Akm/JkB1q2GcqGdb6TwGILHCLGEJbuwoO7TdvbuZ+Tv/t0cq3gQTUNJbG+1efZG65s0AlU4bSiIGqlE8mzE/MnfHLDRu9tnvWJ26s= 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 1650467430252220.14777290838367; Wed, 20 Apr 2022 08:10:30 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309349.525504 (Exim 4.92) (envelope-from ) id 1nhBxy-00046g-5v; Wed, 20 Apr 2022 15:10:02 +0000 Received: by outflank-mailman (output) from mailman id 309349.525504; Wed, 20 Apr 2022 15:10:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhBxy-00046K-0W; Wed, 20 Apr 2022 15:10:02 +0000 Received: by outflank-mailman (input) for mailman id 309349; Wed, 20 Apr 2022 15:10:00 +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 1nhBxw-0003l4-Ly for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:00 +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 f1ad0c12-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:09:58 +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 9C16421115; Wed, 20 Apr 2022 15:09:58 +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 6227213AE0; Wed, 20 Apr 2022 15:09:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id aMK0FkYiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:58 +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: f1ad0c12-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467398; 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=WF4b9n87A3M7HYOr+N4ZjOY+Cgid8wI0c6irsUK8+pQROZTqJnInO/MAVODMUxLWX9V4V0 Z+LcPet04JF89QS0wEomkfON2JmmAd36vHuHA/rqkTO0zUey1+1KZplpI+cvYdc6r6WSe9 cji3xX1G6SjGEefquTF4b8p4MGSO6uo= 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 01/18] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:25 +0200 Message-Id: <20220420150942.31235-2-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467430956100003 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 17 05:54:41 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=1650467432; cv=none; d=zohomail.com; s=zohoarc; b=jXfUXkW0Z8XwLsKGdm0ft8QYsCvrH6u/zjEIo/0uTBiPgb3uBLyPv9NbCo/XgjK/72wzECQUvEkkFuxRZT3XcN21qmtei6kzaKw4ovjuhiKHXWVTkLWBB7Qci9jNHZily8w78+z+FrVw9q2gCK0aHHwK+dO0+ki3i4G5cHIpSHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467432; 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=IUttQ1H+XcfFLC3kD1l+LebctsArIZR57Igsdzd17IlliOHEgovmmXyxCJ/VSpFbs0leEwY1JHa/Gys9wwQEsHle6LqDOf7RCmc/9qVCDRDCyhZJpeaxz5psVbAGlt9TvvhSzoGKbzMnTBHb3UG+kA+QpQmZkjMZqIF7g5exMfs= 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 16504674326581007.5235028181936; Wed, 20 Apr 2022 08:10:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309348.525498 (Exim 4.92) (envelope-from ) id 1nhBxx-00043c-Rq; Wed, 20 Apr 2022 15:10:01 +0000 Received: by outflank-mailman (output) from mailman id 309348.525498; Wed, 20 Apr 2022 15:10: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 1nhBxx-000434-O6; Wed, 20 Apr 2022 15:10:01 +0000 Received: by outflank-mailman (input) for mailman id 309348; Wed, 20 Apr 2022 15:10:00 +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 1nhBxw-0003l9-EK for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:00 +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 f1d218da-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:09:59 +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 E2C341F380; Wed, 20 Apr 2022 15:09:58 +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 A1E0513AD5; Wed, 20 Apr 2022 15:09:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id uItUJkYiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:58 +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: f1d218da-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467398; 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=RLridzMgQycyuagIizn5XaAT4I+nxk2qHqd10tZfXxzpJqLqtrA1gDkHD182fZNaso9mSe M9IT/uHa81ObORL8HehqC09E8nBntt7MTyqLHZ9M417SVAZWN+02SKS/YxV7x5VfpqEzCX 9ftMZq85+XPw0YvTrEoKDbTzpI9EF3E= 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 02/18] xen/netfront: switch netfront to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:26 +0200 Message-Id: <20220420150942.31235-3-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467434827100011 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 17 05:54:41 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=1650467425; cv=none; d=zohomail.com; s=zohoarc; b=lYdQjWEZW7HaXbkcmV/CYriElyIy5VdqmklasIbj9h6bwBPRSEOV3W3RPhixao5TxqYqeqtC+1Q6MBNKSR0xaEWc8AiNKBNhPf9kZ+xgPr5loEeFVAhYmrw9yTkEJjAvrcz8hlBw2knvS4afYC6cdpoHKRPPWci0ccCtn4ks+Gs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467425; 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=8WOMLJJL+8fDd8BjyKVyzFwvZFKiwjT3Bwvxi9ywj7Y=; b=clpQ0YlbNQ8Gza3F+KTapw/1ntxjtY5OI4vITJelF8Kq0hd6hRrPTqbk+fS3l+sYo44Djk8wD4HBS92hI4s7X37tllWcUGKrqM4huASY7PR3D8v4RkxEMrXFIIqll3htU5X75b50dqAQGh3D1PdEKTx+avmBNJ1leivNnAs+w2g= 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 1650467425698829.570574711845; Wed, 20 Apr 2022 08:10:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309350.525520 (Exim 4.92) (envelope-from ) id 1nhBxz-0004Z9-FR; Wed, 20 Apr 2022 15:10:03 +0000 Received: by outflank-mailman (output) from mailman id 309350.525520; Wed, 20 Apr 2022 15:10: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 1nhBxz-0004YL-8W; Wed, 20 Apr 2022 15:10:03 +0000 Received: by outflank-mailman (input) for mailman id 309350; Wed, 20 Apr 2022 15:10:01 +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 1nhBxx-0003l9-6T for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:01 +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 f1fea23b-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:09:59 +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 379941F747; Wed, 20 Apr 2022 15:09:59 +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 E8D5313AE0; Wed, 20 Apr 2022 15:09:58 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kBmNN0YiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:58 +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: f1fea23b-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467399; 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=8WOMLJJL+8fDd8BjyKVyzFwvZFKiwjT3Bwvxi9ywj7Y=; b=CE/mkh1GUmE0SEPgpv7h3QUa2wELR2bW/esRvHI7txzKQA9wQsVKrOu+eAzgp/hLcYnX7E r6J7pCdMHUpedleoOia07CHwEuQG5UDphvqpVAQRRMVaPddqdZziFxg9iRwriLzvdhz9uZ SvY5Pd4iersIGuwjkFHkZ97a9UYSgi4= 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 03/18] xen/scsifront: remove unused GRANT_INVALID_REF definition Date: Wed, 20 Apr 2022 17:09:27 +0200 Message-Id: <20220420150942.31235-4-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467427295100001 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 761c9c463ecd..9db2366fa2d4 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 17 05:54:41 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 34F9DC433F5 for ; Wed, 20 Apr 2022 15:11:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380119AbiDTPOa (ORCPT ); Wed, 20 Apr 2022 11:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380085AbiDTPMq (ORCPT ); Wed, 20 Apr 2022 11:12:46 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9B1B1BEB8; Wed, 20 Apr 2022 08:10:00 -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-out1.suse.de (Postfix) with ESMTPS id 6714C2112B; Wed, 20 Apr 2022 15:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467399; 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=P9m9SWnGsWjRx9ANR0XSy+QMtPG0e3QupiRUzE89rSY=; b=FqRfpSvFwPYNTbSEb+BczfXaG/PTZ/jawRTYZIcGfRVWCFx/hIuhAVbgCyF6TW7nx10JYF FhE/gNjXdum/2VeRLcck0wNBZhBe41TwRXa/Uxr/OaE4aGv16cRpLtTDb3XaaCaQsxUm2+ ubqyrMN6DY0Ttw/z5+7IZWwzUAbuaTo= 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 3E37713AD5; Wed, 20 Apr 2022 15:09:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SGcBDkciYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:59 +0000 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 04/18] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:28 +0200 Message-Id: <20220420150942.31235-5-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 17 05:54:41 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=1650467433; cv=none; d=zohomail.com; s=zohoarc; b=XMANoiux7Y8KJKWvEjv9H072Z0fvnmFUvcOBjmi+1c7QIW84A3SSqPkzfe4SKBAMBE02953N50qEyjsnO4/ms/hBvwhD0CwyiQXbr4KahM2H40FwS4xl2Oh2v3MeONwb7R1vxQcCxfppw6ZMTewM62wJRphY5oTe99qjJu+QZig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467433; 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=S4QdCOjhYFqloYyOHIkOJDPfQ8wbDyoOogSSeqZRRlmV+gn5ODaKTRQPHdg7EHiCNs53Qo69HUtGYeet6nJ4nvKKjxxn5YI50epHF4C8l3iSC+fBhwieNSfD/aQT29Rs27YWGgF7yaI1upUN0nuKUex92XIZwQqQNPLC9C7U3A0= 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 1650467433924475.3687582823393; Wed, 20 Apr 2022 08:10:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309351.525525 (Exim 4.92) (envelope-from ) id 1nhBxz-0004cF-T2; Wed, 20 Apr 2022 15:10:03 +0000 Received: by outflank-mailman (output) from mailman id 309351.525525; Wed, 20 Apr 2022 15:10: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 1nhBxz-0004bN-KN; Wed, 20 Apr 2022 15:10:03 +0000 Received: by outflank-mailman (input) for mailman id 309351; Wed, 20 Apr 2022 15:10:01 +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 1nhBxx-0003l4-MO for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:01 +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 f247eda1-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:09:59 +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 A9A2B2129B; Wed, 20 Apr 2022 15:09:59 +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 6D87713AD5; Wed, 20 Apr 2022 15:09:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id MJhzGUciYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:59 +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: f247eda1-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467399; 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=M2CSLl0VqnHJJC0YsOCEQojyDKPkmBs5veLj38AgGdJxabAIf7h7XElPNlT4+0mo0+eBOj zKrOb0vmHAlVaH4Nbwvy1oILNfIjzCnCLFr0PRRGVQhPpjPeLu24cZScK/vIUcyE6IHG/O MNv+w8hsIg/uI1+QirFTAqLXtACWMas= 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 05/18] xen/drm: switch xen_drm_front to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:29 +0200 Message-Id: <20220420150942.31235-6-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467434839100012 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 17 05:54:41 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=1650467432; cv=none; d=zohomail.com; s=zohoarc; b=RBZqS7tfMGWGiZxWelb9Y7gkMNbaUQTSsodxP/CBVVHhL5UsOnsziAdQdlrRoDYklDUAJIFnqi+24egVXbf7Pi40UP7TeabFBRbQJXIv5LRJ8J8u2rGh9yOYkpk8P/sFD0D9R7HFW3PxG5e5dyCJy/lnyzsdUwzDLFXw3pN746M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467432; 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=eIVA7qzGldpKS0sl8HGUW5pc+YxoNPyEtKCG2DtwXrEDVMYXlEQId4/o1NgqTzBRaHOgP1c7gxMPeUAm2AYYxTc5PZYip3HGvZJf1tv7p7MxXsf7gL5d6CYzxrVLcRjTnhmM7QQ4BKXPw9hBRFVyZV9q2VkCc5rCbxGYE2rH0Bk= 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 1650467432419525.8482137516779; Wed, 20 Apr 2022 08:10:32 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309353.525540 (Exim 4.92) (envelope-from ) id 1nhBy1-00050A-AW; Wed, 20 Apr 2022 15:10:05 +0000 Received: by outflank-mailman (output) from mailman id 309353.525540; Wed, 20 Apr 2022 15:10: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 1nhBy0-0004ww-S0; Wed, 20 Apr 2022 15:10:04 +0000 Received: by outflank-mailman (input) for mailman id 309353; Wed, 20 Apr 2022 15:10:02 +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 1nhBxy-0003l4-Mv for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:02 +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 f2633f23-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:10:00 +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 D9190212CA; Wed, 20 Apr 2022 15:09:59 +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 A555313AE0; Wed, 20 Apr 2022 15:09:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iIX9JkciYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:59 +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: f2633f23-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467399; 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=uZzO2cwIu/sM9Hdm1fFLMi4NNhXH9dzuMEXeAORI9mIENpJgMi0mH8YBRcV8SfzpXm4aCJ mgsKBrn4Aeo/6RKAQb2zKRH4zXldm3hlBxeNEOtRX2j1vJT8fz76y2iMt2w21WFF5SD4De UvfkRO//eO3i1T3ieg9KOtmlKggUaBw= 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 06/18] xen/sound: switch xen_snd_front to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:30 +0200 Message-Id: <20220420150942.31235-7-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467432809100007 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 17 05:54:41 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=1650467429; cv=none; d=zohomail.com; s=zohoarc; b=UQT8Bz3g9K8xOOER9IlPs9fb1+Zv8CPSBeSfK1Y/d3n8Sz6KxXqHBLTa/9YM/EfC3mxSa/KnTfhGuRWa3jMg1KqVdWP0ISxtGk0rd/h45ccy5XRizuAUfuUwxId1jxOVQ2uwIeBa6PtcX/DKDItQcaBNUfYbuE0hUAh7JcuFM1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467429; 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=kSbE6iL+6st/6U4SJTGFMZhOcJs5+w3p9qBmf4nKIKvqTdS2crgOEZeHg3jmz7Ivme7DQ1Jty1BJfWobLb6y0q7oOArXkSf0qm+eBV99M+rsTIWiZVnNExpTS/UX4kshBz9jq3l8NboxNbhyILHsFd0xNeglnl9f6GJn3lHiYko= 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 1650467429756386.4195867351991; Wed, 20 Apr 2022 08:10:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309354.525543 (Exim 4.92) (envelope-from ) id 1nhBy1-00058X-Rn; Wed, 20 Apr 2022 15:10:05 +0000 Received: by outflank-mailman (output) from mailman id 309354.525543; Wed, 20 Apr 2022 15:10: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 1nhBy1-000545-D2; Wed, 20 Apr 2022 15:10:05 +0000 Received: by outflank-mailman (input) for mailman id 309354; Wed, 20 Apr 2022 15:10:03 +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 1nhBxz-0003l9-70 for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:03 +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 f280d0b4-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:00 +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 1094E215FC; Wed, 20 Apr 2022 15:10:00 +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 DDE5413AD5; Wed, 20 Apr 2022 15:09:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iEbyNEciYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:09:59 +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: f280d0b4-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467400; 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=izW36Q/K4I+x9+ssoIZTIP6kcaOBnqGIAchacXhFrguclN9mlcwDy5Y3j6XIl58RxItKh2 yFKJRHgSaBRlN10cFBSOt7Ea7MtSQEgQQW0NFvI/a+0rlT0kNILSRJWUf2qg0/waqA7ALN NEaH3ZeHIDVzSTHBGCrCGbqlRrM0AMs= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH 07/18] xen/dmabuf: switch gntdev-dmabuf to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:31 +0200 Message-Id: <20220420150942.31235-8-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467430915100002 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 17 05:54:41 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=1650467429; cv=none; d=zohomail.com; s=zohoarc; b=MhmxSRFh36djE1w07RLQn5UfvR7nwclVoqGcLxzYgLJG5d/eYhWP+iyQZSyhiwuzaVeDNzu3yT45FLtovrrsrs1qxj0luHExT8ajfo/UmliO4uNCWGm5PcFCUaIwrAmn5u7qw5xDXu8JkkqMtjl9maq5sZ3btpO2YZ7Yj4TzKFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467429; 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=IoE8HYoeRM7hkEEXNUsAB5eCGyLGqFU6E8ZljgWDPPS4Zu8csWnjbsnJEJpg/jIHqyo7v0SqlPkwVfHWPM0BS/D8TwHEAjEETSnaS4hlKzFsaO/qLuEYHG8FKYgIZXjHH0ZVYtl/k0AVgduAP1dEQpwr4rNsbjmDU9YVgK4Bghk= 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 1650467429791721.9995871940755; Wed, 20 Apr 2022 08:10:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309356.525561 (Exim 4.92) (envelope-from ) id 1nhBy3-0005YH-MF; Wed, 20 Apr 2022 15:10:07 +0000 Received: by outflank-mailman (output) from mailman id 309356.525561; Wed, 20 Apr 2022 15:10: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 1nhBy3-0005UD-3O; Wed, 20 Apr 2022 15:10:07 +0000 Received: by outflank-mailman (input) for mailman id 309356; Wed, 20 Apr 2022 15:10:04 +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 1nhBy0-0003l9-78 for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:04 +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 f29a7f35-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:00 +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 3F52C1F74E; Wed, 20 Apr 2022 15:10:00 +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 1721D13AD5; Wed, 20 Apr 2022 15:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qJqaBEgiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:00 +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: f29a7f35-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467400; 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=tZ70zY2Z8ae+EH5HDjSsCrE0+Obr0+3PLdmMlwpcYTQS6O/gxKd5Wt0smGPntpM64zeZns oDNx8gIE1hM6kQMNo7Cc4s/LzaDVNqHIV/dBcgmK7lqMVFb+cnuA2Tt5XNHncoqPC6Byia RGfEx698LwhJYEYLJteROadnU2YJOEo= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH 08/18] xen/shbuf: switch xen-front-pgdir-shbuf to use INVALID_GRANT_REF Date: Wed, 20 Apr 2022 17:09:32 +0200 Message-Id: <20220420150942.31235-9-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467430914100001 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 17 05:54:41 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=1650467438; cv=none; d=zohomail.com; s=zohoarc; b=PZQsSEkqFm9/hsSSWy3f1ODNoR2V8rfpJwwN293Cw64tNRfgE+XSgeaSwdJxAxgIe6xsAE7/nPePq3VX3nOihFqYo5vPqBj/RhBkPsw/IMrSEDYhZf09XagYdmIWK02wAh5zuYP58qZT5ZIopn6WI50GUcVVvO4c5D2EiEws+a0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467438; 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=GmTPe+yXMfMZHVZ+Fj4h3W5vSvZ0UXBf2f8R5LHUrqGArulZCJzVUXUDVSnJ7v3wE0yS2EpCXP4QnZPjCVWSdCvCEwfhN2L5nCr2hbPmf6dC42V6eVsAjU83202H0EIr9++uo4bqT/WZjP3Eun4m6f+rjRtun+d/FQ8XHByj+4c= 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 1650467437995563.9317364639079; Wed, 20 Apr 2022 08:10:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309355.525556 (Exim 4.92) (envelope-from ) id 1nhBy2-0005L4-VS; Wed, 20 Apr 2022 15:10:06 +0000 Received: by outflank-mailman (output) from mailman id 309355.525556; Wed, 20 Apr 2022 15:10:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhBy2-0005Hn-7b; Wed, 20 Apr 2022 15:10:06 +0000 Received: by outflank-mailman (input) for mailman id 309355; Wed, 20 Apr 2022 15:10:04 +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 1nhBxz-0003l4-Me for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:03 +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 f2b5a086-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:10:00 +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 6E98B215FD; Wed, 20 Apr 2022 15:10:00 +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 45D1113AD5; Wed, 20 Apr 2022 15:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kDnRD0giYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:00 +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: f2b5a086-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467400; 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=ldrF4kjq+B1ALbw+0FXFa11PZ6m6yv1eHafGyMjuw6sVEYhgTHTCPqG4eHHk3RNDnjFvFR uDngELLfvTSL23P1jfO6z9oZtu/Q96ANRFBwBt10W+2B3ZxB7zzO52ScagQgii6L1DZlt7 yUr1q+kDuVo+nLFzfmzqcDwMKjr82z4= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH 09/18] xen/xenbus: add xenbus_setup_ring() service function Date: Wed, 20 Apr 2022 17:09:33 +0200 Message-Id: <20220420150942.31235-10-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467438848100026 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 17 05:54:41 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=1650467433; cv=none; d=zohomail.com; s=zohoarc; b=Y5v6GvUgSZX3iDJlj38rib6mAbrvuNJbaleNXw7ORtm0RLX8LInLSA/hQtUcDRUSPvruHc/L3siDVoEnOTWl+6smjvzQ2oDtuPdZ09NC5F3h2lu4MCdG1AcQnfg9NAaqot8zGuzpA4PPNH5iSua6NLfnaRyvUaKuxN2LmS72EpY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467433; 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=jX7srMhp6ubGUE560TW855B1p8XgeYqviaHs7bo1HEQ=; b=Khm4oZLyxUkg8oMj9b/lsO/rw/cIpVaL9pSgNfxLdhSJpEjcaeVBHYPDf1efX6ocU9fOthUuieEWRs8rSRCO2wZ2AO7s2mZ9H9vdLbPTlo48I923hDSdSUq9lSDNHveDnDme31FwV1FZk7NjTILjCkkXVSqAJhNugfaJ3kQXX9U= 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 1650467433003411.4442965172708; Wed, 20 Apr 2022 08:10:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309357.525572 (Exim 4.92) (envelope-from ) id 1nhBy4-0005oT-NP; Wed, 20 Apr 2022 15:10:08 +0000 Received: by outflank-mailman (output) from mailman id 309357.525572; Wed, 20 Apr 2022 15:10:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhBy4-0005lU-4P; Wed, 20 Apr 2022 15:10:08 +0000 Received: by outflank-mailman (input) for mailman id 309357; Wed, 20 Apr 2022 15:10:05 +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 1nhBy0-0003l4-Mu for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:04 +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 f2ddd54d-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:10:01 +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 AEDA81F74F; Wed, 20 Apr 2022 15:10:00 +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 75BB713AD5; Wed, 20 Apr 2022 15:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sHx2G0giYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:00 +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: f2ddd54d-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467400; 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=jX7srMhp6ubGUE560TW855B1p8XgeYqviaHs7bo1HEQ=; b=kK+HoGASU9zFbNjXEDo2LjceMqvAQGce4bPew3hcIKRD6+xa3dfSQNUY3SkQUPf+rnjJIq Y0nCIHUplnWY8chzVzP3MDTZFhGpeqmjYivp4zntVFFokHKSMNmI5bZgJjfrtepBO97rOd DI4vcrcbfvyYU+fGRcUV/5+gt5T/RHo= 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 10/18] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:34 +0200 Message-Id: <20220420150942.31235-11-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467434845100013 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 | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 7f35e30e626a..367df4d9cd59 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,31 +1672,18 @@ 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]; =20 - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D INVALID_GRANT_REF; + err =3D xenbus_setup_ring(dev, GFP_NOIO, (void **)&sring, + info->nr_ring_pages, rinfo->ring_ref); + if (err) + goto fail; =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); =20 - 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; - goto fail; - } - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D gref[i]; - err =3D xenbus_alloc_evtchn(dev, &rinfo->evtchn); if (err) goto fail; --=20 2.34.1 From nobody Fri May 17 05:54:41 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=1650467436; cv=none; d=zohomail.com; s=zohoarc; b=TCNC3nZjyLcylFvxj/8Lv4Igoil1FFQ/pSpjGQJpoN2RLP7+UO83fJWipwpF150rdskcZYhGdmP3jk6oPPASS579+Jmh1iOvUJ3+LQhRiAc3qjEqSQBhQ7jBOXIk2uvCWijPKMYuhISDdrYdV4cENcQ5XBKe4V4zxfbwGuqpe9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467436; 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=aZCkP4ZTIz8L3n5icXJW44l5GxuZEDRnsAjAP0WhQbc=; b=CAWPbsVd3Loh08HgC0AnBU/38yAsqVzNzLgrwAGCBGrxxceO/RHmnBCT8gfHZf3mTH6l1kf0PjFVix5DJRhM9neypDr9sWn7x8Gj/lhmmLEmnAQu/zZQ7XVSGsmc3BkDePjXswM8IH8Oqap40czFayydevai0Iki+aPswdWD4+U= 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 165046743659319.52698035000583; Wed, 20 Apr 2022 08:10:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309359.525598 (Exim 4.92) (envelope-from ) id 1nhBy8-0006by-DP; Wed, 20 Apr 2022 15:10:12 +0000 Received: by outflank-mailman (output) from mailman id 309359.525598; Wed, 20 Apr 2022 15:10: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 1nhBy7-0006U7-5P; Wed, 20 Apr 2022 15:10:11 +0000 Received: by outflank-mailman (input) for mailman id 309359; Wed, 20 Apr 2022 15:10:06 +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 1nhBy1-0003l4-Mw for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:05 +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 f307f1cf-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:10:01 +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 F1572215FE; Wed, 20 Apr 2022 15:10:00 +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 B560113AD5; Wed, 20 Apr 2022 15:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kMInK0giYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:00 +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: f307f1cf-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467400; 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=aZCkP4ZTIz8L3n5icXJW44l5GxuZEDRnsAjAP0WhQbc=; b=ltchNwiSpdyVnlwL94VdMGg3q9XkNrTd8PU8GecHmmKA2xueh8TSnLik9ju2nQgFdU7jAI fouQD9Ufzdt2SX7rghRnRK21cspyfWJSePo4SMHeff6MNuZopRUi8C1YLrbQaWkDstD8fp lKCwbxP0tpg7NCPGqZst22fehTkYZ20= 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 11/18] xen/netfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:35 +0200 Message-Id: <20220420150942.31235-12-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467436815100019 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 | 49 +++++++++----------------------------- 1 file changed, 11 insertions(+), 38 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index af3d3de7d9fa..880b10d435d9 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,34 +1929,22 @@ 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) + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs, + 1, &queue->rx_ring_ref); + if (err) goto fail; - queue->tx_ring_ref =3D gref; =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"); - 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; - if (feature_split_evtchn) err =3D setup_netfront_split(queue); /* setup single event channel if @@ -1972,24 +1959,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 17 05:54:41 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=1650467443; cv=none; d=zohomail.com; s=zohoarc; b=O76bAJV185tolZhlug4jJIzyaY0Cw8D/4Y5b8iQgRNzPQ2kLsFJnfmWv/aS48t8G9COYRX55Nb6VElWbRnoe3tCkT4DGvetQYPficfQ8ja4xUlGe5H9SNwEJC3Mt8r0v/o3G5QfzlO8lwxdHCka8StgUhP5l8hkVl8zHKkAQBDQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467443; 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=BOqUhMJJAF98X3lAZFlcuGZh0Kfht6xfrA6cCO9+5+jQsQbCZDjRgYvKR/LcEKaTde2JfwL4f9H+aLXKk2ARD7/lJOOse2JNQ2DGh16wk1xRoeunCrOhtukVLvX92Ubf4UAu+6/Gh718joiNJmjSTjdSliRFsa1SEb3JC8Yq0I4= 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 1650467443174885.5620174395028; Wed, 20 Apr 2022 08:10:43 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309361.525619 (Exim 4.92) (envelope-from ) id 1nhByB-0007H9-FG; Wed, 20 Apr 2022 15:10:15 +0000 Received: by outflank-mailman (output) from mailman id 309361.525619; Wed, 20 Apr 2022 15:10:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhByA-00079l-3z; Wed, 20 Apr 2022 15:10:14 +0000 Received: by outflank-mailman (input) for mailman id 309361; Wed, 20 Apr 2022 15:10:07 +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 1nhBy2-0003l4-N6 for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:06 +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 f3288839-c0bb-11ec-a405-831a346695d4; Wed, 20 Apr 2022 17:10:01 +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 326F31F752; Wed, 20 Apr 2022 15:10:01 +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 0350D13AD5; Wed, 20 Apr 2022 15:10:00 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wJc1O0giYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:00 +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: f3288839-c0bb-11ec-a405-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467401; 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=gjZEMURyKhH+ffoe/cJZIs+1qR6NiuC5LbjUsc6HQbUiY2YzhMqa9gcWbW4J8W52XRcuUB bxVKmzgppOt2rXgXD9zG+IZ7iT7xfDjw0J35R694tg4TxR9zrp0FyFGkwbXBgSna0vfc7P /KVWK5ggl/fmh28DGQ7IZcMIgPfHAnU= 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 12/18] xen/tpmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:36 +0200 Message-Id: <20220420150942.31235-13-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467444945100003 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 17 05:54:41 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=1650467431; cv=none; d=zohomail.com; s=zohoarc; b=gUFVCzp9xUDgAf4VPyy7HHnyu5pC8DvqBL8TgHxvr98vaDu+Wdhy/96jnIUVbPld0ivR8q1D7HAIhc/Acjeqd47PTKZFCUp44xr8FYmyZ3eKm1Ok4WXumvCceGup6EvWqhR3+/vjljCOL62ml3ztUe2fQMq9bPr+0Zi8A66Cw94= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467431; 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=tmwmbbtZJudUbAIbysps04tc1Vmd3FQIvvzlUXPcKxg=; b=T/SXzrJzaRPhkYzC6d6LP4WUhqXHlt/uBW0IBmpI2E9RHW7lGcn8KRoPS35WCAu3yPl0R1uVQDvHSBD6ZMQPSlcWlKk5fCttZJnwhCMDLykYZcmlJdoL+d57YIyav7aAW7IwpqPgDOmi7BY/dwnNocvAURPfvxNZBr8PATYGZsA= 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 1650467431334164.4760608081342; Wed, 20 Apr 2022 08:10:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309358.525580 (Exim 4.92) (envelope-from ) id 1nhBy5-00063w-RF; Wed, 20 Apr 2022 15:10:09 +0000 Received: by outflank-mailman (output) from mailman id 309358.525580; Wed, 20 Apr 2022 15:10: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 1nhBy5-0005zb-3L; Wed, 20 Apr 2022 15:10:09 +0000 Received: by outflank-mailman (input) for mailman id 309358; Wed, 20 Apr 2022 15:10:05 +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 1nhBy1-0003l9-7M for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:05 +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 f3556ef4-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:01 +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 74293215FF; Wed, 20 Apr 2022 15:10:01 +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 3DC6113AD5; Wed, 20 Apr 2022 15:10:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sI81DUkiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:01 +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: f3556ef4-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467401; 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=tmwmbbtZJudUbAIbysps04tc1Vmd3FQIvvzlUXPcKxg=; b=pAfvqqiAD4OraYwqo6cZohlEfrN0mMKqAKpKdNaD5lUWEA3R1ABBgaA1jdc8J3HR2zf6Wv CbtxRrC6+LnfHL8iyNIz6lOK5roLsOdBsexS444hgxmjwnb4JHGj8GWdkog+m6mn/sWicy SxSln3cit6a9OYDk0m+vcJYUQ1e4DUo= 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 13/18] xen/drmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:37 +0200 Message-Id: <20220420150942.31235-14-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467432843100008 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 | 40 ++++++--------------- 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/= xen/xen_drm_front_evtchnl.c index 4006568b9e32..9b16ea9f523b 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -123,12 +123,12 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, 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,26 @@ 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; + sring =3D page; SHARED_RING_INIT(sring); FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); =20 - 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; - } - 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 17 05:54:41 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 2B363C433F5 for ; Wed, 20 Apr 2022 15:11:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380152AbiDTPOG (ORCPT ); Wed, 20 Apr 2022 11:14:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380098AbiDTPMt (ORCPT ); Wed, 20 Apr 2022 11:12:49 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CC963E5F7; Wed, 20 Apr 2022 08:10:03 -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-out1.suse.de (Postfix) with ESMTPS id B143321600; Wed, 20 Apr 2022 15:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467401; 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=fz0rlO1XMdB4BddZo8c4Teth0+zAy8QaParWZU14wrqXGD6EySljVo6Vq6kBi9HXKi0Rga xuTZhtvj50WWZimNnLTKwBftHtnnForaUNyo7J+NGQQPcb/KSOCH4nn4iVfeQ4OCTkaQVZ j32mZDbE44Ahb1h++ngv8o4nT0tLPzw= 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 7A52A13AD5; Wed, 20 Apr 2022 15:10:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mMS4HEkiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:01 +0000 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 14/18] xen/pcifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:38 +0200 Message-Id: <20220420150942.31235-15-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 17 05:54:41 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=1650467437; cv=none; d=zohomail.com; s=zohoarc; b=ISfOVape8UomoYJd8JK6o7oEEd2OTP37o16jPm7JaSCjCRuEDB3vOzaAK+89+1HgRkAScVVHfkTdnNhxh2fBEA9xMA9hRnrXKpHsLBAUulvMJ+NU+nOJrM2Fvr0G/KNasdbLEykZHM8y0WskRywTtY4G8DL8A6Z/gX+9jouC10E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467437; 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=zIVRYJfuKT5Cc8Eh8lkT4S5YymR5yO4CxthS7o0vErk=; b=OqOH5xVJb+eDzEp5g76aUayr+biXWTbCOwh2VvKZ1Ta9Lai0KdViTR+WHVdHR1AmWIvevrD+lCY8prP+Mt53KpLzGSCOou7nOBWjU94dg2JfEC/2m0S69jgjorM3XO5D0LE+yJszT+oWg2bELAfqVFkmGU3m45lBT4LAKvBMWXE= 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 1650467437443510.7857410181889; Wed, 20 Apr 2022 08:10:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309362.525631 (Exim 4.92) (envelope-from ) id 1nhByD-0007fM-9x; Wed, 20 Apr 2022 15:10:17 +0000 Received: by outflank-mailman (output) from mailman id 309362.525631; Wed, 20 Apr 2022 15:10:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhByB-0007X3-TO; Wed, 20 Apr 2022 15:10:15 +0000 Received: by outflank-mailman (input) for mailman id 309362; Wed, 20 Apr 2022 15:10:07 +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 1nhBy3-0003l9-7V for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:07 +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 f3a0aa29-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:02 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id EC45B2112B; Wed, 20 Apr 2022 15:10:01 +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 B940913AD5; Wed, 20 Apr 2022 15:10:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GL8QLEkiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:01 +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: f3a0aa29-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467401; 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=zIVRYJfuKT5Cc8Eh8lkT4S5YymR5yO4CxthS7o0vErk=; b=dqosmBbYFka6Cq4Fx3XDgQHYlD1l+kwlMIm2CKI8qmUk88Qls9O2u9OhjZfgqQVVyXEHAl F5AYRXlkgASQKbFoZaaEmJYPy7bQ0yV3XDjBRjOVGpr8R+cUhgWmk84/IMZM/K9yZKlQHC oSvKC/4crEhSlduV6M0b2pJQU17VPOU= 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 15/18] xen/scsifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:39 +0200 Message-Id: <20220420150942.31235-16-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467438825100025 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 | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 9db2366fa2d4..f15a35750040 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -798,28 +798,17 @@ 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; - err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { xenbus_dev_fatal(dev, err, "xenbus_alloc_evtchn"); @@ -847,8 +836,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 +844,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 17 05:54:41 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=1650467446; cv=none; d=zohomail.com; s=zohoarc; b=CtLqjWzEl8Mj8QV0bcpnbFbJrJbStCXyvvzM8aEDflv7wZ3OzgzhJRPLqU6jU1NbvjHsPERR6vGzu7itVa+p/lHcXZ2tOmQKHJBI+w2EnkA0MuqPsGO/sonVWRvpIlSmOqZHDlu/BdiSrY+HWY1CgqEEmewJ/vwfpoYKGFFW32Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467446; 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=4XO8mycpJSRe2vI+Vj0O3qJ4olWbFoCtMGHkp23ojsk=; b=bGUv1IXcimjW/0iyB8r3uJD7ZOi+8I42hZH/tVAtfHsoDwpa9BMWSB6nYwjvcRy05lSmspwNktM/oag6mzSqiKnY2mNIVPf1bOkJycDqmcLC9nGs4RFOYlgp58vFMP/PwyR9/f+MmiT8EVN4RlIN89tmYBDK3DuICV5fdFANIu4= 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 1650467446857917.042284142622; Wed, 20 Apr 2022 08:10:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309363.525639 (Exim 4.92) (envelope-from ) id 1nhByF-0007yl-3h; Wed, 20 Apr 2022 15:10:19 +0000 Received: by outflank-mailman (output) from mailman id 309363.525639; Wed, 20 Apr 2022 15:10:18 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhByD-0007t3-IQ; Wed, 20 Apr 2022 15:10:17 +0000 Received: by outflank-mailman (input) for mailman id 309363; Wed, 20 Apr 2022 15:10:08 +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 1nhBy4-0003l9-7c for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:08 +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 f3bbec23-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:02 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 249321F755; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id F294D13AD5; Wed, 20 Apr 2022 15:10:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wD8gOkkiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:01 +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: f3bbec23-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4XO8mycpJSRe2vI+Vj0O3qJ4olWbFoCtMGHkp23ojsk=; b=Y/wHvCn79hpZ3MR5MUZgiZYUWb54QUxJMgP20Sni9+zhVg83Ad+Ow6g1GClmrtdxakPE9M cm1US8RDJtQ9jv+2INVLRiTBj/VTsmp/DbYnUzbcWFWq60WgTjevWgSCFhJG/LFhRTGMGS NcQBgF6wnnuAovRz8oLfTVPntt124Ag= 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 16/18] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:40 +0200 Message-Id: <20220420150942.31235-17-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467448974100001 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 | 55 +++++++++----------------------------- 1 file changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c index 9cbc7c2dab02..0acb68eb37ee 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,47 +1109,27 @@ 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; + 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(urb_sring); FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); =20 - 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; + 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; } SHARED_RING_INIT(conn_sring); FRONT_RING_INIT(&info->conn_ring, conn_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; - goto fail; - } - info->conn_ring_ref =3D gref; - err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { xenbus_dev_fatal(dev, err, "xenbus_alloc_evtchn"); --=20 2.34.1 From nobody Fri May 17 05:54:41 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=1650467442; cv=none; d=zohomail.com; s=zohoarc; b=C+Fu1FiDT9tvMHD/oEh7OOK4/oUbt+9BDJ2Up2I42Na0DhD79Sd8MlThb6u2T8wsIhy23+YRwUndDpcNws7//s1wgHiMQKeACmVTvBltAhxn/mb/9xWTjxF/d0p06bOpKeCgdwJZVhxiDGctmExcjqRRbe7ad/VsafyLaZhtV4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1650467442; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ij8UfjCLrmWlzw8p3dv1NeerjjrG+tJoiHZZthvTeTI=; b=ljyK3UsKKyrgl/xeMABvhK6dBnTO3AJt3JdiZhqBIlqXQGeM6XuhS3fUuJJZH+99P9dOstiQ7MhScC1b0M2RLWmCGAP1bCucLE8chaL5tc+fQa8F0jjIhhiNnwfMAlhl+FNQM4E6m/08ue0XmnM2xT1qC6ciEdXUh6WHDK+m4tc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1650467442429300.40691673956724; Wed, 20 Apr 2022 08:10:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.309364.525651 (Exim 4.92) (envelope-from ) id 1nhByH-0008LP-0X; Wed, 20 Apr 2022 15:10:21 +0000 Received: by outflank-mailman (output) from mailman id 309364.525651; Wed, 20 Apr 2022 15:10:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhByF-0008Ea-9G; Wed, 20 Apr 2022 15:10:19 +0000 Received: by outflank-mailman (input) for mailman id 309364; Wed, 20 Apr 2022 15:10:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nhBy5-0003l9-7l for xen-devel@lists.xenproject.org; Wed, 20 Apr 2022 15:10:09 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f3ddcb98-c0bb-11ec-8fbf-03012f2f19d4; Wed, 20 Apr 2022 17:10:02 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5A2221F756; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2B21313AD5; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8E1yCUoiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:02 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: f3ddcb98-c0bb-11ec-8fbf-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ij8UfjCLrmWlzw8p3dv1NeerjjrG+tJoiHZZthvTeTI=; b=JFTWSh6PJxJNJV7oRKcYWQSPPmYpfiNbr7bGGF1C4FLcMUoeH5mugdJwUSjRTpmafzW3Z6 3/rnOYNY53Prw7TUqwIAO/wr+1hE9sHaZ8juMfZMr2ylg+TetOlsdH5uDLkAimH+CRHSO4 /xH4WD232P0oiT57WD4l/KlJ4lYa0c0= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Oleksandr Andrushchenko , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org Subject: [PATCH 17/18] xen/sndfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Wed, 20 Apr 2022 17:09:41 +0200 Message-Id: <20220420150942.31235-18-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1650467442848100001 Content-Type: text/plain; charset="utf-8" Simplify sndfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross --- sound/xen/xen_snd_front_evtchnl.c | 41 +++++++------------------------ 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_ev= tchnl.c index 3e21369c8216..32d42fd3f7ac 100644 --- a/sound/xen/xen_snd_front_evtchnl.c +++ b/sound/xen/xen_snd_front_evtchnl.c @@ -143,12 +143,12 @@ void xen_snd_front_evtchnl_flush(struct xen_snd_front= _evtchnl *channel) static void evtchnl_free(struct xen_snd_front_info *front_info, struct xen_snd_front_evtchnl *channel) { - unsigned long page =3D 0; + void *page =3D NULL; =20 if (channel->type =3D=3D EVTCHNL_TYPE_REQ) - page =3D (unsigned long)channel->u.req.ring.sring; + page =3D channel->u.req.ring.sring; else if (channel->type =3D=3D EVTCHNL_TYPE_EVT) - page =3D (unsigned long)channel->u.evt.page; + page =3D channel->u.evt.page; =20 if (!page) return; @@ -167,10 +167,7 @@ static void evtchnl_free(struct xen_snd_front_info *fr= ont_info, xenbus_free_evtchn(front_info->xb_dev, channel->port); =20 /* End access and free the page. */ - if (channel->gref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(channel->gref, page); - else - free_page(page); + xenbus_teardown_ring(&page, 1, &channel->gref); =20 memset(channel, 0, sizeof(*channel)); } @@ -196,8 +193,7 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, enum xen_snd_front_evtchnl_type type) { struct xenbus_device *xb_dev =3D front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; char *handler_name =3D NULL; int ret; @@ -207,12 +203,9 @@ static int evtchnl_alloc(struct xen_snd_front_info *fr= ont_info, int index, channel->index =3D index; channel->front_info =3D front_info; channel->state =3D EVTCHNL_STATE_DISCONNECTED; - channel->gref =3D INVALID_GRANT_REF; - page =3D get_zeroed_page(GFP_KERNEL); - if (!page) { - ret =3D -ENOMEM; + ret =3D xenbus_setup_ring(xb_dev, GFP_KERNEL, &page, 1, &channel->gref); + if (ret) goto fail; - } =20 handler_name =3D kasprintf(GFP_KERNEL, "%s-%s", XENSND_DRIVER_NAME, type =3D=3D EVTCHNL_TYPE_REQ ? @@ -226,33 +219,19 @@ static int evtchnl_alloc(struct xen_snd_front_info *f= ront_info, int index, mutex_init(&channel->ring_io_lock); =20 if (type =3D=3D EVTCHNL_TYPE_REQ) { - struct xen_sndif_sring *sring =3D (struct xen_sndif_sring *)page; + struct xen_sndif_sring *sring =3D page; =20 init_completion(&channel->u.req.completion); mutex_init(&channel->u.req.req_io_lock); SHARED_RING_INIT(sring); FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE); =20 - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - channel->u.req.ring.sring =3D NULL; - goto fail; - } - handler =3D evtchnl_interrupt_req; } else { - ret =3D gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) - goto fail; - - channel->u.evt.page =3D (struct xensnd_event_page *)page; - gref =3D ret; + channel->u.evt.page =3D page; handler =3D evtchnl_interrupt_evt; } =20 - channel->gref =3D gref; - ret =3D xenbus_alloc_evtchn(xb_dev, &channel->port); if (ret < 0) goto fail; @@ -279,8 +258,6 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, return 0; =20 fail: - if (page) - free_page(page); kfree(handler_name); dev_err(&xb_dev->dev, "Failed to allocate ring: %d\n", ret); return ret; --=20 2.34.1 From nobody Fri May 17 05:54:41 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 456FDC433F5 for ; Wed, 20 Apr 2022 15:11:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380200AbiDTPOY (ORCPT ); Wed, 20 Apr 2022 11:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380102AbiDTPMt (ORCPT ); Wed, 20 Apr 2022 11:12:49 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAC403EABE for ; Wed, 20 Apr 2022 08:10:03 -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 870F51F75C; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1650467402; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QLFILJSyTHZFwq9omiEC/cxiL5bUIoRxF/dV9SsWN+s=; b=fU0EP2NLCoJe8acGsjUQq+tmbjd9EV5kJ837Yvpjtv3R+E+3rdGLFrVs3chlN8uv83+s3P V2mWF1R7X54tVlLdCKJydZmarq3eFTC+1QOhIfPS3iXNwVxAbQaf+CszPw4cSbP+RQi0bK PRYJay9LyAUNVTxOluvKtHQACb11R0A= 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 602B213AD5; Wed, 20 Apr 2022 15:10:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2PBIFkoiYGJILQAAMHmgww (envelope-from ); Wed, 20 Apr 2022 15:10:02 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH 18/18] xen/xenbus: eliminate xenbus_grant_ring() Date: Wed, 20 Apr 2022 17:09:42 +0200 Message-Id: <20220420150942.31235-19-jgross@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220420150942.31235-1-jgross@suse.com> References: <20220420150942.31235-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 --- drivers/xen/xenbus/xenbus_client.c | 64 +++++++++--------------------- include/xen/xenbus.h | 2 - 2 files changed, 18 insertions(+), 48 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus= _client.c index 1a2e0d94ccd1..7b1f7f86b6e5 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,24 @@ 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 ring page"); 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