From nobody Mon May 13 17:16:45 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=1651738636; cv=none; d=zohomail.com; s=zohoarc; b=A35mOZ28svuXYb8gdqLJsaf4SSzdXuQSN5Ci0e0BACDzBwfibkFN/r2Vpcv6AXZOu1brLogusQmWMZm7ghl+EydVtRN5SfB19aEkn85iMJf/qMp4w5t489Cxw72BAOJx2t6O7ZvPjNk0oxF37Yn+ga5CUA99Trd9QalD78VBUIk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738636; 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=FLxbtpzBQ9VbjqIE6K+qmcx5CrSY4iyn10JST4u0ffI=; b=Wlmq3OO7NYt97aXkUufvUo1CNjFyerGFwaDF7HxySS7C2r7oFyOsbG4aB+LzQcjYPeXOrSraW9sCX7w4F7n71RzbH3bJ+ERtzbMRW5lpRq05dE3Qc81sjnmUKbSXsMB1Xp7F0sT9LYSfMvwZ7VhzfAYkCM91cLdbn2vcXxflAcw= 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 165173863599926.931895771051813; Thu, 5 May 2022 01:17:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321663.542714 (Exim 4.92) (envelope-from ) id 1nmWfI-00024T-I3; Thu, 05 May 2022 08:16:48 +0000 Received: by outflank-mailman (output) from mailman id 321663.542714; Thu, 05 May 2022 08:16:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfI-00024J-F5; Thu, 05 May 2022 08:16:48 +0000 Received: by outflank-mailman (input) for mailman id 321663; Thu, 05 May 2022 08:16:46 +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 1nmWfG-0001o5-A0 for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:46 +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 b324c607-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:44 +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 162DA1F45F; Thu, 5 May 2022 08:16:44 +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 D700013B12; Thu, 5 May 2022 08:16:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wL4gM+uHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:43 +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: b324c607-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738604; 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=FLxbtpzBQ9VbjqIE6K+qmcx5CrSY4iyn10JST4u0ffI=; b=ay1jpywDJoybUwQoo2dUHqa0To7OTJNg/ZM1r+YNMOd3surTH0G/97x0mDb7bzCvSiLOI7 f/RB5om3S2Zi8OUxDTeYZWcLhK99ITR1to9+YrZTjmC80uSFFispkwJWb2V16Rh7jJZTJq zLC6uOkeYylneNsL4LOKmBK0ZhYQJF8= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v3 01/21] xen: update grant_table.h Date: Thu, 5 May 2022 10:16:20 +0200 Message-Id: <20220505081640.17425-2-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738636646100004 Content-Type: text/plain; charset="utf-8" Update include/xen/interface/grant_table.h to its newest version. This allows to drop some private definitions in grant-table.c and include/xen/grant_table.h. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- V3: - new patch --- drivers/xen/grant-table.c | 8 +- include/xen/grant_table.h | 2 - include/xen/interface/grant_table.h | 161 +++++++++++++++++----------- 3 files changed, 103 insertions(+), 68 deletions(-) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 8ccccace2a4f..6ea31ea26008 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -66,8 +66,6 @@ =20 #include =20 -/* External tools reserve first few grant table entries. */ -#define NR_RESERVED_ENTRIES 8 #define GNTTAB_LIST_END 0xffffffff =20 static grant_ref_t **gnttab_list; @@ -1465,12 +1463,12 @@ int gnttab_init(void) nr_init_grefs =3D nr_grant_frames * gnttab_interface->grefs_per_grant_frame; =20 - for (i =3D NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++) + for (i =3D GNTTAB_NR_RESERVED_ENTRIES; i < nr_init_grefs - 1; i++) gnttab_entry(i) =3D i + 1; =20 gnttab_entry(nr_init_grefs - 1) =3D GNTTAB_LIST_END; - gnttab_free_count =3D nr_init_grefs - NR_RESERVED_ENTRIES; - gnttab_free_head =3D NR_RESERVED_ENTRIES; + gnttab_free_count =3D nr_init_grefs - GNTTAB_NR_RESERVED_ENTRIES; + gnttab_free_head =3D GNTTAB_NR_RESERVED_ENTRIES; =20 printk("Grant table initialized\n"); return 0; diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index dfd5bf31cfb9..7d0f2f0037b8 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h @@ -57,8 +57,6 @@ #define INVALID_GRANT_REF ((grant_ref_t)-1) #define INVALID_GRANT_HANDLE ((grant_handle_t)-1) =20 -#define GNTTAB_RESERVED_XENSTORE 1 - /* NR_GRANT_FRAMES must be less than or equal to that configured in Xen */ #define NR_GRANT_FRAMES 4 =20 diff --git a/include/xen/interface/grant_table.h b/include/xen/interface/gr= ant_table.h index 3eeabbc7ee09..cebbd99f1f84 100644 --- a/include/xen/interface/grant_table.h +++ b/include/xen/interface/grant_table.h @@ -19,7 +19,8 @@ =20 /* Some rough guidelines on accessing and updating grant-table entries * in a concurrency-safe manner. For more information, Linux contains a - * reference implementation for guest OSes (arch/xen/kernel/grant_table.c). + * reference implementation for guest OSes (drivers/xen/grant_table.c, see + * http://git.kernel.org/?p=3Dlinux/kernel/git/torvalds/linux.git;a=3Dblob= ;f=3Ddrivers/xen/grant-table.c;hb=3DHEAD * * NB. WMB is a no-op on current-generation x86 processors. However, a * compiler barrier will still be required. @@ -80,8 +81,9 @@ typedef uint32_t grant_ref_t; */ =20 /* - * Version 1 of the grant table entry structure is maintained purely - * for backwards compatibility. New guests should use version 2. + * Version 1 of the grant table entry structure is maintained largely for + * backwards compatibility. New guests are recommended to support using + * version 2 to overcome version 1 limitations, but to default to version = 1. */ struct grant_entry_v1 { /* GTF_xxx: various type and flag information. [XEN,GST] */ @@ -89,12 +91,21 @@ struct grant_entry_v1 { /* The domain being granted foreign privileges. [GST] */ domid_t domid; /* - * GTF_permit_access: Frame that @domid is allowed to map and access. = [GST] - * GTF_accept_transfer: Frame whose ownership transferred by @domid. [= XEN] + * GTF_permit_access: GFN that @domid is allowed to map and access. [G= ST] + * GTF_accept_transfer: GFN that @domid is allowed to transfer into. [= GST] + * GTF_transfer_completed: MFN whose ownership transferred by @domid + * (non-translated guests only). [XEN] */ uint32_t frame; }; =20 +/* The first few grant table entries will be preserved across grant table + * version changes and may be pre-populated at domain creation by tools. + */ +#define GNTTAB_NR_RESERVED_ENTRIES 8 +#define GNTTAB_RESERVED_CONSOLE 0 +#define GNTTAB_RESERVED_XENSTORE 1 + /* * Type of grant entry. * GTF_invalid: This grant entry grants no privileges. @@ -111,10 +122,13 @@ struct grant_entry_v1 { #define GTF_type_mask (3U<<0) =20 /* - * Subflags for GTF_permit_access. + * Subflags for GTF_permit_access and GTF_transitive. * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] * GTF_reading: Grant entry is currently mapped for reading by @domid. [X= EN] * GTF_writing: Grant entry is currently mapped for writing by @domid. [X= EN] + * Further subflags for GTF_permit_access only. + * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags to be used for + * mappings of the grant [GST] * GTF_sub_page: Grant access to only a subrange of the page. @domid * will only be allowed to copy from the grant, and not * map it. [GST] @@ -125,6 +139,12 @@ struct grant_entry_v1 { #define GTF_reading (1U<<_GTF_reading) #define _GTF_writing (4) #define GTF_writing (1U<<_GTF_writing) +#define _GTF_PWT (5) +#define GTF_PWT (1U<<_GTF_PWT) +#define _GTF_PCD (6) +#define GTF_PCD (1U<<_GTF_PCD) +#define _GTF_PAT (7) +#define GTF_PAT (1U<<_GTF_PAT) #define _GTF_sub_page (8) #define GTF_sub_page (1U<<_GTF_sub_page) =20 @@ -164,8 +184,7 @@ struct grant_entry_header { }; =20 /* - * Version 2 of the grant entry structure, here is a union because three - * different types are suppotted: full_page, sub_page and transitive. + * Version 2 of the grant entry structure. */ union grant_entry_v2 { struct grant_entry_header hdr; @@ -180,9 +199,9 @@ union grant_entry_v2 { * field of the same name in the V1 entry structure. */ struct { - struct grant_entry_header hdr; - uint32_t pad0; - uint64_t frame; + struct grant_entry_header hdr; + uint32_t pad0; + uint64_t frame; } full_page; =20 /* @@ -191,10 +210,10 @@ union grant_entry_v2 { * in frame @frame. */ struct { - struct grant_entry_header hdr; - uint16_t page_off; - uint16_t length; - uint64_t frame; + struct grant_entry_header hdr; + uint16_t page_off; + uint16_t length; + uint64_t frame; } sub_page; =20 /* @@ -202,12 +221,15 @@ union grant_entry_v2 { * grant @gref in domain @trans_domid, as if it was the local * domain. Obviously, the transitive access must be compatible * with the original grant. + * + * The current version of Xen does not allow transitive grants + * to be mapped. */ struct { - struct grant_entry_header hdr; - domid_t trans_domid; - uint16_t pad0; - grant_ref_t gref; + struct grant_entry_header hdr; + domid_t trans_domid; + uint16_t pad0; + grant_ref_t gref; } transitive; =20 uint32_t __spacer[4]; /* Pad to a power of two */ @@ -219,6 +241,21 @@ typedef uint16_t grant_status_t; * GRANT TABLE QUERIES AND USES */ =20 +#define GNTTABOP_map_grant_ref 0 +#define GNTTABOP_unmap_grant_ref 1 +#define GNTTABOP_setup_table 2 +#define GNTTABOP_dump_table 3 +#define GNTTABOP_transfer 4 +#define GNTTABOP_copy 5 +#define GNTTABOP_query_size 6 +#define GNTTABOP_unmap_and_replace 7 +#define GNTTABOP_set_version 8 +#define GNTTABOP_get_status_frames 9 +#define GNTTABOP_get_version 10 +#define GNTTABOP_swap_grant_ref 11 +#define GNTTABOP_cache_flush 12 +/* ` } */ + /* * Handle to track a mapping created via a grant reference. */ @@ -227,7 +264,7 @@ typedef uint32_t grant_handle_t; /* * GNTTABOP_map_grant_ref: Map the grant entry (,) for access * by devices and/or host CPUs. If successful, is a tracking numb= er - * that must be presented later to destroy the mapping(s). On error, + * that must be presented later to destroy the mapping(s). On error, * is a negative status code. * NOTES: * 1. If GNTMAP_device_map is specified then is the address @@ -241,7 +278,6 @@ typedef uint32_t grant_handle_t; * host mapping is destroyed by other means then it is *NOT* guaranteed * to be accounted to the correct grant reference! */ -#define GNTTABOP_map_grant_ref 0 struct gnttab_map_grant_ref { /* IN parameters. */ uint64_t host_addr; @@ -266,7 +302,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_map_grant_ref); * 3. After executing a batch of unmaps, it is guaranteed that no stale * mappings will remain in the device or host TLBs. */ -#define GNTTABOP_unmap_grant_ref 1 struct gnttab_unmap_grant_ref { /* IN parameters. */ uint64_t host_addr; @@ -286,7 +321,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_grant_ref); * 2. Only a sufficiently-privileged domain may specify !=3D DOMID_= SELF. * 3. Xen may not support more than a single grant-table page per domain. */ -#define GNTTABOP_setup_table 2 struct gnttab_setup_table { /* IN parameters. */ domid_t dom; @@ -301,7 +335,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_setup_table); * GNTTABOP_dump_table: Dump the contents of the grant table to the * xen console. Debugging use only. */ -#define GNTTABOP_dump_table 3 struct gnttab_dump_table { /* IN parameters. */ domid_t dom; @@ -311,17 +344,17 @@ struct gnttab_dump_table { DEFINE_GUEST_HANDLE_STRUCT(gnttab_dump_table); =20 /* - * GNTTABOP_transfer_grant_ref: Transfer to a foreign domain. The - * foreign domain has previously registered its interest in the transfer v= ia - * . + * GNTTABOP_transfer: Transfer to a foreign domain. The foreign do= main + * has previously registered its interest in the transfer via . * * Note that, even if the transfer fails, the specified page no longer bel= ongs * to the calling domain *unless* the error is GNTST_bad_page. + * + * Note further that only PV guests can use this operation. */ -#define GNTTABOP_transfer 4 struct gnttab_transfer { /* IN parameters. */ - xen_pfn_t mfn; + xen_pfn_t mfn; domid_t domid; grant_ref_t ref; /* OUT parameters. */ @@ -352,21 +385,20 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_transfer); #define _GNTCOPY_dest_gref (1) #define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) =20 -#define GNTTABOP_copy 5 struct gnttab_copy { - /* IN parameters. */ - struct { - union { - grant_ref_t ref; - xen_pfn_t gmfn; - } u; - domid_t domid; - uint16_t offset; - } source, dest; - uint16_t len; - uint16_t flags; /* GNTCOPY_* */ - /* OUT parameters. */ - int16_t status; + /* IN parameters. */ + struct gnttab_copy_ptr { + union { + grant_ref_t ref; + xen_pfn_t gmfn; + } u; + domid_t domid; + uint16_t offset; + } source, dest; + uint16_t len; + uint16_t flags; /* GNTCOPY_* */ + /* OUT parameters. */ + int16_t status; }; DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy); =20 @@ -377,7 +409,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_copy); * 1. may be specified as DOMID_SELF. * 2. Only a sufficiently-privileged domain may specify !=3D DOMID_= SELF. */ -#define GNTTABOP_query_size 6 struct gnttab_query_size { /* IN parameters. */ domid_t dom; @@ -399,7 +430,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_query_size); * 2. After executing a batch of unmaps, it is guaranteed that no stale * mappings will remain in the device or host TLBs. */ -#define GNTTABOP_unmap_and_replace 7 struct gnttab_unmap_and_replace { /* IN parameters. */ uint64_t host_addr; @@ -412,14 +442,12 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_unmap_and_replace); =20 /* * GNTTABOP_set_version: Request a particular version of the grant - * table shared table structure. This operation can only be performed - * once in any given domain. It must be performed before any grants - * are activated; otherwise, the domain will be stuck with version 1. - * The only defined versions are 1 and 2. + * table shared table structure. This operation may be used to toggle + * between different versions, but must be performed while no grants + * are active. The only defined versions are 1 and 2. */ -#define GNTTABOP_set_version 8 struct gnttab_set_version { - /* IN parameters */ + /* IN/OUT parameters */ uint32_t version; }; DEFINE_GUEST_HANDLE_STRUCT(gnttab_set_version); @@ -436,7 +464,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_set_version); * 1. may be specified as DOMID_SELF. * 2. Only a sufficiently-privileged domain may specify !=3D DOMID_= SELF. */ -#define GNTTABOP_get_status_frames 9 struct gnttab_get_status_frames { /* IN parameters. */ uint32_t nr_frames; @@ -451,7 +478,6 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_status_frames); * GNTTABOP_get_version: Get the grant table version which is in * effect for domain . */ -#define GNTTABOP_get_version 10 struct gnttab_get_version { /* IN parameters */ domid_t dom; @@ -461,27 +487,38 @@ struct gnttab_get_version { }; DEFINE_GUEST_HANDLE_STRUCT(gnttab_get_version); =20 +/* + * GNTTABOP_swap_grant_ref: Swap the contents of two grant entries. + */ +struct gnttab_swap_grant_ref { + /* IN parameters */ + grant_ref_t ref_a; + grant_ref_t ref_b; + /* OUT parameters */ + int16_t status; /* GNTST_* */ +}; +DEFINE_GUEST_HANDLE_STRUCT(gnttab_swap_grant_ref); + /* * Issue one or more cache maintenance operations on a portion of a * page granted to the calling domain by a foreign domain. */ -#define GNTTABOP_cache_flush 12 struct gnttab_cache_flush { union { uint64_t dev_bus_addr; grant_ref_t ref; } a; - uint16_t offset; /* offset from start of grant */ - uint16_t length; /* size within the grant */ -#define GNTTAB_CACHE_CLEAN (1<<0) -#define GNTTAB_CACHE_INVAL (1<<1) -#define GNTTAB_CACHE_SOURCE_GREF (1<<31) + uint16_t offset; /* offset from start of grant */ + uint16_t length; /* size within the grant */ +#define GNTTAB_CACHE_CLEAN (1u<<0) +#define GNTTAB_CACHE_INVAL (1u<<1) +#define GNTTAB_CACHE_SOURCE_GREF (1u<<31) uint32_t op; }; DEFINE_GUEST_HANDLE_STRUCT(gnttab_cache_flush); =20 /* - * Bitfield values for update_pin_status.flags. + * Bitfield values for gnttab_map_grant_ref.flags. */ /* Map the grant entry for access by I/O devices. */ #define _GNTMAP_device_map (0) @@ -531,6 +568,7 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_cache_flush); #define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary.= */ #define GNTST_address_too_big (-11) /* transfer page address too large. = */ #define GNTST_eagain (-12) /* Operation not done; try again. = */ +#define GNTST_no_space (-13) /* Out of space (handles etc). = */ =20 #define GNTTABOP_error_msgs { \ "okay", \ @@ -545,7 +583,8 @@ DEFINE_GUEST_HANDLE_STRUCT(gnttab_cache_flush); "bad page", \ "copy arguments cross page boundary", \ "page address size too large", \ - "operation not done; try again" \ + "operation not done; try again", \ + "out of space", \ } =20 #endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738639; cv=none; d=zohomail.com; s=zohoarc; b=BEbC7g56WveMpQMrsjYrIzIooNWdwvG2IeBik3mtbFY5DSAG/RVO0g6raozYOe/RpZ7G0oS5xd72s0+z8Un8HBBrF44oQ1a13tOBiyfCfZv2eudxdIW9CRQmFGNgZUQ0BR4oIGrJ1KBDWlLFOnXZg6M4yY9SvEovNmuKhpbFIXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738639; 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=97UDNK1f7czhnU/2ak2EMjgJM9WmcipgW6hepwuQnLg=; b=TB65txr+J/Tj4dNSLFQmzFdwznklP90S4CQ9awdbrlwZFlqOKKHiBw8l9CZwccv1QTXVBin/iYXhnCq0bQw+LhGeK43rcJGjVVonACmlx6DAHjlSbX0EOUIWigGU2G/FChGO5sYqk6k/nSR20ycbt1KXpkI+4uubxO0+MKOYLxU= 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 1651738639781350.4181147496673; Thu, 5 May 2022 01:17:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321662.542703 (Exim 4.92) (envelope-from ) id 1nmWfH-0001oO-DL; Thu, 05 May 2022 08:16:47 +0000 Received: by outflank-mailman (output) from mailman id 321662.542703; Thu, 05 May 2022 08:16:47 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfH-0001oG-7b; Thu, 05 May 2022 08:16:47 +0000 Received: by outflank-mailman (input) for mailman id 321662; Thu, 05 May 2022 08:16:45 +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 1nmWfF-0001o5-IK for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:45 +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 b3401556-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:44 +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 4AF8C210DF; Thu, 5 May 2022 08:16:44 +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 1CCDA13B11; Thu, 5 May 2022 08:16:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8JqSBeyHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:44 +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: b3401556-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738604; 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=97UDNK1f7czhnU/2ak2EMjgJM9WmcipgW6hepwuQnLg=; b=TIGROP5NtrO/PMKocRwXDq4uW8i352wOc1Z8dfJPBykWG1KVaUs1y2V2ugsyPQNmx7HW7A 7YEaBEYBaDKYEspokFV4o5IqKEomEss+SP90j3p4SJQhRp2HPvh7OngYWLnofHdSf1J4/b gKvNZ3TxKDt4H8fjI3G6ZJ0tlhzkvPg= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v3 02/21] xen/grant-table: never put a reserved grant on the free list Date: Thu, 5 May 2022 10:16:21 +0200 Message-Id: <20220505081640.17425-3-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640702100001 Content-Type: text/plain; charset="utf-8" Make sure a reserved grant is never put on the free list, as this could cause hard to debug errors. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- V3: - new patch --- drivers/xen/grant-table.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 6ea31ea26008..1a1aec0a88a1 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c @@ -207,6 +207,10 @@ static inline void check_free_callbacks(void) static void put_free_entry(grant_ref_t ref) { unsigned long flags; + + if (unlikely(ref < GNTTAB_NR_RESERVED_ENTRIES)) + return; + spin_lock_irqsave(&gnttab_list_lock, flags); gnttab_entry(ref) =3D gnttab_free_head; gnttab_free_head =3D ref; --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738639; cv=none; d=zohomail.com; s=zohoarc; b=mHDxZzLnGuwKnBOy1dz9dvY2XgoT3T5AjBl0MrmNqE3j+AUN5ZkARl+7nQv93XeS9118XBmM5wzXBNIyt9HaoruD20cqXdOHNzzTVR6jwmqvY9FtK5L+oMMOsaj4bgPlqH59v8AlsTqQCPwNGR8JMFM9uqEPeOTJw72iLk7MiO4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738639; 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=LiPPxVvJ/tZwu8jvS4fDntozP5hW+zLbGIbL5f3d6ug=; b=C4pX233qgtyLVTUXqbABUJW+P+dmjsaonqdwcyRn0bH6QJ+TT2RDCT5wRqiv2mmJp4RH+hlZ2VWLDNoCz/sGywvtpvwkNpyA2URbIROyq+XOjTCOlhg48NFHcAaZh70dwVv/n50C4+od9w9dwDT/VdICsksrHuEaRXZHWPlvJl8= 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 1651738639525923.0970637208503; Thu, 5 May 2022 01:17:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321664.542720 (Exim 4.92) (envelope-from ) id 1nmWfJ-000299-0Q; Thu, 05 May 2022 08:16:49 +0000 Received: by outflank-mailman (output) from mailman id 321664.542720; Thu, 05 May 2022 08:16:48 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfI-00027Y-Qp; Thu, 05 May 2022 08:16:48 +0000 Received: by outflank-mailman (input) for mailman id 321664; Thu, 05 May 2022 08:16:47 +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 1nmWfH-0001o5-Aa for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:47 +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 b391d4b2-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:45 +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 9A2411F460; Thu, 5 May 2022 08:16:44 +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 515F513B11; Thu, 5 May 2022 08:16:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 4NWHEuyHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:44 +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: b391d4b2-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738604; 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=LiPPxVvJ/tZwu8jvS4fDntozP5hW+zLbGIbL5f3d6ug=; b=lKDEZaYIrZbZV4QoHmZ/ztck+zaRHuUrhf9XzAXw8TYoOaMZLBy/6PqTsy2u9tZ3RGh5rN br1KiRGwE6tZ0a4Rhq9/oaOZGsqLWY5ghXvy+6NeNQSGW9uQhU2pPwQn2YBxSmcfKgQ4so PQf8BYf5MYZ5Uj2P/okjcZrWgtE92jo= 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 v3 03/21] xen/blkfront: switch blkfront to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:22 +0200 Message-Id: <20220505081640.17425-4-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640741100005 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: Roger Pau Monn=C3=A9 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738635; cv=none; d=zohomail.com; s=zohoarc; b=VmEzyO0knqEbmyqdl1XRCMgLk3Qy6QNMsIZclcZHfqUhc1rLXoR1dj7le7U0u73KJOd10PGR91quffZM78VFtAL2GakycUiIpjZhGpuS74ktOhtmRTmZIF6rX23AvuraVBZuzJ2sUVUOlHIhbvG+G/Ponrq0vXF/PDBA1MwvsQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738635; 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=Wb0uPnKVxH6X1fgBon9Xmych7JExQqCQIYQDdDvAVlQ=; b=LfDY6mkrQ6BpjAowxfLJMdslDxC/BBWoCw2Ww5xx4TN0+CdQBqo3ouGSHQoFfbrTlzL8e3zy6BvGpfG4Lfks1NSwZAtzhXiPbyd9C9zxJdWtmbCX5jiBXI5K3fiihuk2BDPhDQMuBzjrxr+8v0RKqj1YrWnjNrzuHfyP5Rr/J0U= 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 1651738635869290.97804279827415; Thu, 5 May 2022 01:17:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321665.542727 (Exim 4.92) (envelope-from ) id 1nmWfJ-0002FW-D3; Thu, 05 May 2022 08:16:49 +0000 Received: by outflank-mailman (output) from mailman id 321665.542727; Thu, 05 May 2022 08:16:49 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfJ-0002DJ-4R; Thu, 05 May 2022 08:16:49 +0000 Received: by outflank-mailman (input) for mailman id 321665; Thu, 05 May 2022 08:16:47 +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 1nmWfH-0001qT-U3 for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:47 +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 b3a9e985-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:45 +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 DDDEC1F855; Thu, 5 May 2022 08:16:44 +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 945B313B12; Thu, 5 May 2022 08:16:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id cF3JIuyHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:44 +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: b3a9e985-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738604; 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=Wb0uPnKVxH6X1fgBon9Xmych7JExQqCQIYQDdDvAVlQ=; b=k1MwMA6LVKHn4L9RbGeodLm/ou5drbiC+/MbupQdZY0wZom9Er4mw5atok2+PHFm4+7p5o pe7ibN48YJRZ4BpfaAyM4qGPRz6VZ3mDCKlIU2/4/HGucH1zu9hjHWvMmeidZ0WHufVZCh LzZlGjtJFZCHchL/8oPj8rkEjUasN8Y= 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" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v3 04/21] xen/netfront: switch netfront to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:23 +0200 Message-Id: <20220505081640.17425-5-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738636627100003 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738639; cv=none; d=zohomail.com; s=zohoarc; b=iK8F78/32ZrRlpzr7PLUnnE6wDnoBY1/NxNDKoKTL7agEnVR/KY2EHvDHWBM4AJIy3GEVBCMJ6osbGYMxuXvfjwLLBc13HSVzODaSBqIyHuEWMdPQCeeJgIAbw+Y1c5stA8WCCf9xBN3tCBP2CJe2UUX5iwaoCCQbhIpdrB2yqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738639; 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=+7CMtprq6730KQODSTXPIsn2CRUJgb2Tt/M0T6KuL48=; b=guJe51aujZeUGefot4tsmoSsxeQ60UqUa6ieo9Au0KZpqWoO8jeJrHS6TJndT5iDfg8MH9fwsy5C0M6yAQR31kSkQAX3RJRyC1sPRDn5tqRW6/hyxUDamoI5pDSw3AZxFq2vj2t8zltk+BryvHbQBiuhCH6lynchF3FE4nC1BBg= 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 1651738639520847.5083433428424; Thu, 5 May 2022 01:17:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321669.542763 (Exim 4.92) (envelope-from ) id 1nmWfM-0003BD-Ug; Thu, 05 May 2022 08:16:52 +0000 Received: by outflank-mailman (output) from mailman id 321669.542763; Thu, 05 May 2022 08:16:52 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfM-00036l-G3; Thu, 05 May 2022 08:16:52 +0000 Received: by outflank-mailman (input) for mailman id 321669; Thu, 05 May 2022 08:16:50 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfJ-0001qT-NB for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:49 +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 b3d7f15a-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:45 +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 3969B1F88B; Thu, 5 May 2022 08:16:45 +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 E496F13B11; Thu, 5 May 2022 08:16:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iMNpNuyHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:44 +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: b3d7f15a-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738605; 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=+7CMtprq6730KQODSTXPIsn2CRUJgb2Tt/M0T6KuL48=; b=Q2+/LfYrDGupnXadg7i13kivgfkB4z78xXa2vTrESCx1cXyAPfEcMcie1z+7R0euXijjcM vw4QUlQh0InKyhg1f3MxDpMjPVc1uSit3MGRMu5iswkPMFFQOxRbo897oUllJDl9kUPf0r bFhchb8fTC55lJqtirWiVOUmJD46sT4= 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 v3 05/21] xen/scsifront: remove unused GRANT_INVALID_REF definition Date: Thu, 5 May 2022 10:16:24 +0200 Message-Id: <20220505081640.17425-6-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640723100002 Content-Type: text/plain; charset="utf-8" GRANT_INVALID_REF isn't used in scsifront, so remove it. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/scsi/xen-scsifront.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 56173beecbc6..4c55e479fc36 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -58,9 +58,6 @@ =20 #include =20 - -#define GRANT_INVALID_REF 0 - #define VSCSIFRONT_OP_ADD_LUN 1 #define VSCSIFRONT_OP_DEL_LUN 2 #define VSCSIFRONT_OP_READD_LUN 3 --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738639; cv=none; d=zohomail.com; s=zohoarc; b=ckhZDEPf750/mep0KJ2kC+irlxdo70sLDZyFAUeam4LvwAPOF/JjTkyEieXRikatcRRxGIyuX5NLHLyN05w1a9aR0S6sMN94vzKjktQOcD2+jDVz/0/IQtR6s3mGEL/J3D0/+UkbFWH3m0v7pIiCx1SO1zSbFplBG83m5F4Ii58= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738639; 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=40GR81qLBAKpQ1pdFfw5ZbcFKNAIeNjaSwOGqddCksA=; b=XdaWZsYRW0a571i5wUPsWI3dg2TL1ArIET/VUavbDwx2iN5F41EXfydhxcR1pKuvYMC+JQmpTuKVCtFOGFzbwKK8UimGkwfpAAJ9twt+ay6+HMRFYPDXsq0yZ68Fqt/HJUtVDq15e+NCpb6gm4adZQnERFUsWQI2kzrpTXyvilM= 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 1651738639614157.81139908847183; Thu, 5 May 2022 01:17:19 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321671.542782 (Exim 4.92) (envelope-from ) id 1nmWfO-0003Zw-Ve; Thu, 05 May 2022 08:16:54 +0000 Received: by outflank-mailman (output) from mailman id 321671.542782; Thu, 05 May 2022 08:16:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfO-0003Vg-C6; Thu, 05 May 2022 08:16:54 +0000 Received: by outflank-mailman (input) for mailman id 321671; Thu, 05 May 2022 08:16:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfK-0001qT-NH for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:50 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b3f1c427-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:45 +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 6F7012129A; Thu, 5 May 2022 08:16:45 +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 3FEC413B11; Thu, 5 May 2022 08:16:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id WPtXDu2Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:45 +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: b3f1c427-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738605; 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=40GR81qLBAKpQ1pdFfw5ZbcFKNAIeNjaSwOGqddCksA=; b=EYWTHAdH5RBPO4czJu3WhK/zfuAs3DPsQSFX7ShogW2nC4Y+RSVboPlZrXxv7vWz6rPt4r hH6yrF93UKdeG02In73kBwMr+ScCL3WB97iWJbmhTeE3jQIFTITqOW8UWBzubf6sOu4oSJ NLeFPsnT2hA+8Ihi6gyc0hhiGm3PHGg= 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 v3 06/21] xen/usb: switch xen-hcd to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:25 +0200 Message-Id: <20220505081640.17425-7-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640934100011 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738640; cv=none; d=zohomail.com; s=zohoarc; b=hQLoup3ZavokiIcsrGIWoE84zmWEjR3pDHuxjv+/sJvl1FvPPDOfV5/12WK5aqQbwZEEpk6OrLMvwT/qCpWDTC5ef4yHW/9c8m9sWZe7rBfjpSwNi26xzpbq45bK0zW36jAeJcQIaHah6BJkm/IjnXNcB2+GU8nImNfazP1E2ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738640; 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=i6ggN2balHjG5CI3jRk1VrmRzP8B/Nm2ztrH3YOWGCk=; b=XkdPlXk75hEwSTtPal+NEp+Vyb/3PD7YmMTAxOewuVC3ntDzZzuNmB+SuxWBk6nhdYU7DxHR1c9AfyzuOqCRP0rP6IRxB2/qCW2hphWpR68fpifbN/cGhcOpyn4dEcM6vwPO+IhYNXr7snEbZZA6KE07YTOLzZ5XhcmhdDcmkQE= 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 1651738640554757.4427732367864; Thu, 5 May 2022 01:17:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321675.542811 (Exim 4.92) (envelope-from ) id 1nmWfS-0004Qe-Rd; Thu, 05 May 2022 08:16:58 +0000 Received: by outflank-mailman (output) from mailman id 321675.542811; Thu, 05 May 2022 08:16:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfR-0004Mz-QJ; Thu, 05 May 2022 08:16:57 +0000 Received: by outflank-mailman (input) for mailman id 321675; Thu, 05 May 2022 08:16:53 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfM-0001qT-NY for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:52 +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 b4194cc7-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:46 +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 AD77B1F891; Thu, 5 May 2022 08:16:45 +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 75BD113B11; Thu, 5 May 2022 08:16:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id GKd6G+2Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:45 +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: b4194cc7-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738605; 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=i6ggN2balHjG5CI3jRk1VrmRzP8B/Nm2ztrH3YOWGCk=; b=helWnP73V72ZSHcX1/aibZU8SheuDic0cwyuSMwpOutceVsMy58aFEH/CDLZXrGoidt9BX 7t+UwBsoDdE6odBOC2KMcJdtaJihm/5I7y8lbWp4Q7bOuuFSRsLN6jJbVGWTBEd9nduCyW hil4J+m7kbB57nwtL9W34PEnDiV3IrU= 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 v3 07/21] xen/drm: switch xen_drm_front to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:26 +0200 Message-Id: <20220505081640.17425-8-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738642727100013 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738635; cv=none; d=zohomail.com; s=zohoarc; b=fccfv4ilfEx6ccowf1Jh7E8GCNGKVPODMFVhRStyUdsoZUuCtr7PQXpEcQ6RCR/FqfECpfMSZI0xUMjov5mMgrn7u2AaVcMiKIf7Gg2UFYsrW5lxNV5OzF4DOGc0rW/0fiGhO/nRkeoj8DeamXwtXQLbS8gvElajveFE+OfE84g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738635; 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=+hTaiTIyePP0FUFQBbLbCUhke4bQBarxkCj3G5VB5K4=; b=QF7+n9ui6ND948lcx140oNzGvdq8cBcUKKa4hy/ZpNLVDfzBTFpj54XVInf/ahhr9QQDZcIg9j6kr51gzNJjzrNT4TzE/MOnXiOFO4UBzdpEfrbUZH5fLf5lO9Os8Fe4WvMxkxhGbcLf3Kem14GWYuhB/hmD9iQJ3gYbO/r4RvE= 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 165173863507483.53342598749703; Thu, 5 May 2022 01:17:15 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321668.542746 (Exim 4.92) (envelope-from ) id 1nmWfL-0002bc-3n; Thu, 05 May 2022 08:16:51 +0000 Received: by outflank-mailman (output) from mailman id 321668.542746; Thu, 05 May 2022 08:16:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfK-0002YX-Go; Thu, 05 May 2022 08:16:50 +0000 Received: by outflank-mailman (input) for mailman id 321668; Thu, 05 May 2022 08:16:49 +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 1nmWfJ-0001o5-Ay for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:49 +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 b44835c0-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:46 +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 F05971F898; Thu, 5 May 2022 08:16:45 +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 B495913B11; Thu, 5 May 2022 08:16:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id OOBiKu2Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:45 +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: b44835c0-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738605; 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=+hTaiTIyePP0FUFQBbLbCUhke4bQBarxkCj3G5VB5K4=; b=aeJosLBGzoVaAdiBDdxPfy+Uo/uCh2Mz1gdkHFZtuDdt1P0s9kB1QomOQe8wM6fslfYUBC RlMnuBh33GsFIs0C9YK7GDs7Z+Gm8tpGQ1DQOA+gHhvbmMKL7LFdvX9OlSdw93QKPlZLUp 8H2PS6IrRiOqk7Kx3GL5Kyojzya3M3w= 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 v3 08/21] xen/sound: switch xen_snd_front to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:27 +0200 Message-Id: <20220505081640.17425-9-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738636609100001 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738640; cv=none; d=zohomail.com; s=zohoarc; b=RW+uKIpJGwCdoVA9wFNB8udcaWrPj9nSqriXGoVTxbRhH5BILbCKL77QBTJsCAsTMpdvb0myk+UufO3j6ZXlg30uJiPmb0R/mToAEbKVHRmCY09l312RjBImIVkCbmw1YAuzELD8Pm/FxOh9RWubYouT9Q1qqWmCV66ALWSDINM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738640; 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=HbhUc4kkAgjpJllqUuyWzZXVZYGf9QqSKvPktQD9iyQ=; b=dPR5IRY6eErZAMER+OXyaF9VthRjfCpoFVcN1xBoyymWBdSN/v4nSk3S6FcFCTxtnlerfXwQaooektj5nns1/CU6UVfr23qXsGONzw88StFPEOPxDR3ZBTmNB4rIrDLZE4lTuLWGFjf8XgBTHVB7X/CnixYfbqBwSsnLv7iHBic= 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 1651738640385241.5830712545021; Thu, 5 May 2022 01:17:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321673.542792 (Exim 4.92) (envelope-from ) id 1nmWfQ-0003uC-9W; Thu, 05 May 2022 08:16:56 +0000 Received: by outflank-mailman (output) from mailman id 321673.542792; Thu, 05 May 2022 08:16:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfP-0003rY-Iv; Thu, 05 May 2022 08:16:55 +0000 Received: by outflank-mailman (input) for mailman id 321673; Thu, 05 May 2022 08:16:51 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfL-0001qT-Nh for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:51 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b462e9cb-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:46 +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 30DBD210E7; Thu, 5 May 2022 08:16:46 +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 029DD13B11; Thu, 5 May 2022 08:16:45 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id oL34Ou2Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:45 +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: b462e9cb-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738606; 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=HbhUc4kkAgjpJllqUuyWzZXVZYGf9QqSKvPktQD9iyQ=; b=rHPzp9Pc6VbGCmz1ZS7ybs1DGkH3gmX3BoOpGkieYlTPAbhcH+NHvsmWQu1WFVL2naVmuD eKYWr1PLWsZCQ3Omym3VkvbUaP3GMXNXjdA0XGexieKFIIVo1g52oQFiGzHlDuSPuhIYNg IhZV2NcAdYXhYHVPq+TJP5OWPIz6AE8= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v3 09/21] xen/dmabuf: switch gntdev-dmabuf to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:28 +0200 Message-Id: <20220505081640.17425-10-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640723100003 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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 CDAB2C433F5 for ; Thu, 5 May 2022 08:18:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347321AbiEEIWX (ORCPT ); Thu, 5 May 2022 04:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347207AbiEEIU2 (ORCPT ); Thu, 5 May 2022 04:20:28 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C31B496A0 for ; Thu, 5 May 2022 01:16:48 -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 604741F899; Thu, 5 May 2022 08:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738606; 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=cTsWa69X2OUjBOqWnT/IIW2kgbsTrmAnTYOsVwnlfpA=; b=YmPDgx7mOyOodnOmuOxz9DYtEeuCQsuHYFfhPXOPmAD/4WumcdcywENs+Yo9BSVgTJyyLI xNPJyleTNI3ziOaWL6Q6gJzGPis7dM16r5SsfSHyrTqMVL0f/dvhQQk4vCjoIiJhLfEPcV jmS3s2tqWLpMXMAEMPFPYhWj9Bn+B+c= 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 35D7D13B11; Thu, 5 May 2022 08:16:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id QCrLC+6Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:46 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v3 10/21] xen/shbuf: switch xen-front-pgdir-shbuf to use INVALID_GRANT_REF Date: Thu, 5 May 2022 10:16:29 +0200 Message-Id: <20220505081640.17425-11-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- V3: - terminate grant ref list with 0 (Oleksandr Tyshchenko) --- drivers/xen/xen-front-pgdir-shbuf.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/xen/xen-front-pgdir-shbuf.c b/drivers/xen/xen-front-pg= dir-shbuf.c index a959dee21134..b6433761d42c 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 @@ -38,6 +29,7 @@ */ struct xen_page_directory { grant_ref_t gref_dir_next_page; +#define XEN_GREF_LIST_END 0 grant_ref_t gref[1]; /* Variable length */ }; =20 @@ -83,7 +75,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 +134,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 +347,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 XEN_GREF_LIST_END; } =20 /** @@ -384,7 +376,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 XEN_GREF_LIST_END; } else { to_copy =3D XEN_NUM_GREFS_PER_PAGE; page_dir->gref_dir_next_page =3D buf->grefs[i + 1]; --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738636; cv=none; d=zohomail.com; s=zohoarc; b=ayUB5F4fnfQCIWoz54kwGj4luaw4d5igdK8z21/+mMGZUh0SKdnGUlnvZjVdHE7FtjbWJCXzYRgPTbpcT/XCrGCv8XaQxSLQvTqlndKbkGqa6jRLY5CDZQGiUWO9/QNePN/YuYwg+hXADkI2FSEn9SM96dENH8o2ICsFThSMJJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738636; 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=NOtG87ytP6Jh5NCmFkub01f6OJcOR1V96rvCSE+C7vA=; b=eTYD6SWGfVbqEHQNo8Ud9YGZ4knFUaAgKBeKxgqc7rDZULJ71aHh/62EPFE06T7NjMGmxHHDaks1wRuGd7drTYIRikYB/MOiKeoFM8y/zLXJioJNrJidK21rGK9T2JL7ys13AOqpb9QBE+VwbKFHURi1O08o2heS9xqhnpz3idE= 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 1651738636874113.84950736861185; Thu, 5 May 2022 01:17:16 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321670.542774 (Exim 4.92) (envelope-from ) id 1nmWfN-0003MF-UG; Thu, 05 May 2022 08:16:53 +0000 Received: by outflank-mailman (output) from mailman id 321670.542774; Thu, 05 May 2022 08:16:53 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfN-0003Hz-9Z; Thu, 05 May 2022 08:16:53 +0000 Received: by outflank-mailman (input) for mailman id 321670; Thu, 05 May 2022 08:16:50 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfK-0001o5-Ap for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:50 +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 b4b17495-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:46 +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 AF08821871; Thu, 5 May 2022 08:16:46 +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 696DF13B11; Thu, 5 May 2022 08:16:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EKRqGO6Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:46 +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: b4b17495-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738606; 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=NOtG87ytP6Jh5NCmFkub01f6OJcOR1V96rvCSE+C7vA=; b=rgjzT37HswzabuodndnNoAIBhcaV9Yg3557K0ICQL/jluev/EsR89xbFX9PZQizcwOrRYi PnFyHFkLNAbjfh3DXofOl4AODH8F7yCKDyv5ztM0DC+tE08tp28mCbuOhVYzzZFRUHiS39 DfP4Pmh6ZCTaySti8VzrjWisi+VBWA8= 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" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v3 11/21] xen: update ring.h Date: Thu, 5 May 2022 10:16:30 +0200 Message-Id: <20220505081640.17425-12-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738638570100010 Content-Type: text/plain; charset="utf-8" Update include/xen/interface/io/ring.h to its newest version. Switch the two improper use cases of RING_HAS_UNCONSUMED_RESPONSES() to XEN_RING_NR_UNCONSUMED_RESPONSES() in order to avoid the nasty XEN_RING_HAS_UNCONSUMED_IS_BOOL #define. Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- V2: - new patch --- drivers/net/xen-netfront.c | 4 ++-- include/xen/interface/io/ring.h | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index af3d3de7d9fa..966bee2a6902 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -866,7 +866,7 @@ static void xennet_set_rx_rsp_cons(struct netfront_queu= e *queue, RING_IDX val) =20 spin_lock_irqsave(&queue->rx_cons_lock, flags); queue->rx.rsp_cons =3D val; - queue->rx_rsp_unconsumed =3D RING_HAS_UNCONSUMED_RESPONSES(&queue->rx); + queue->rx_rsp_unconsumed =3D XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); spin_unlock_irqrestore(&queue->rx_cons_lock, flags); } =20 @@ -1498,7 +1498,7 @@ static bool xennet_handle_rx(struct netfront_queue *q= ueue, unsigned int *eoi) return false; =20 spin_lock_irqsave(&queue->rx_cons_lock, flags); - work_queued =3D RING_HAS_UNCONSUMED_RESPONSES(&queue->rx); + work_queued =3D XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx); if (work_queued > queue->rx_rsp_unconsumed) { queue->rx_rsp_unconsumed =3D work_queued; *eoi =3D 0; diff --git a/include/xen/interface/io/ring.h b/include/xen/interface/io/rin= g.h index 2470ec45ebb2..ba4c4274b714 100644 --- a/include/xen/interface/io/ring.h +++ b/include/xen/interface/io/ring.h @@ -72,9 +72,8 @@ typedef unsigned int RING_IDX; * of the shared memory area (PAGE_SIZE, for instance). To initialise * the front half: * - * mytag_front_ring_t front_ring; - * SHARED_RING_INIT((mytag_sring_t *)shared_page); - * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZ= E); + * mytag_front_ring_t ring; + * XEN_FRONT_RING_INIT(&ring, (mytag_sring_t *)shared_page, PAGE_SIZE); * * Initializing the back follows similarly (note that only the front * initializes the shared ring): @@ -146,6 +145,11 @@ struct __name##_back_ring { = \ =20 #define FRONT_RING_INIT(_r, _s, __size) FRONT_RING_ATTACH(_r, _s, 0, __siz= e) =20 +#define XEN_FRONT_RING_INIT(r, s, size) do { \ + SHARED_RING_INIT(s); \ + FRONT_RING_INIT(r, s, size); \ +} while (0) + #define BACK_RING_ATTACH(_r, _s, _i, __size) do { \ (_r)->rsp_prod_pvt =3D (_i); \ (_r)->req_cons =3D (_i); \ @@ -170,16 +174,21 @@ struct __name##_back_ring { = \ (RING_FREE_REQUESTS(_r) =3D=3D 0) =20 /* Test if there are outstanding messages to be processed on a ring. */ -#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ +#define XEN_RING_NR_UNCONSUMED_RESPONSES(_r) \ ((_r)->sring->rsp_prod - (_r)->rsp_cons) =20 -#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ +#define XEN_RING_NR_UNCONSUMED_REQUESTS(_r) ({ \ unsigned int req =3D (_r)->sring->req_prod - (_r)->req_cons; \ unsigned int rsp =3D RING_SIZE(_r) - \ ((_r)->req_cons - (_r)->rsp_prod_pvt); \ req < rsp ? req : rsp; \ }) =20 +#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ + (!!XEN_RING_NR_UNCONSUMED_RESPONSES(_r)) +#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ + (!!XEN_RING_NR_UNCONSUMED_REQUESTS(_r)) + /* Direct access to individual ring elements, by index. */ #define RING_GET_REQUEST(_r, _idx) \ (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738647; cv=none; d=zohomail.com; s=zohoarc; b=CYgFZJdKMzKFU5SIZxmfx+PAfzSD6gZR/J2Itsghvt8Klc4N/Hpaoc55qbAk/RKLUFSvZ4XRWH56ISp8U81tufcNVe0mU5KYFRw0b//y2+s1K5enMY/MQTzK0StKW1UcLS2Ju2aBwBpA20ohMpl57McZknbwCvwemqTPnpCjNHE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738647; 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=7yFjXHXMXwZa6Ccja7xlX/k6b/j03dysFoZbs8/tSS0=; b=Noo16ojjGtteoCZdn4eBUcOrL2H8I0Op0mmYPY2BplF5esLJ2+wlkdlK7qyqDBsAQ78OvFJhLHun2ZzKHov9ayYfVFxky6eN8an6nYKCm+O+4n/hT0TZThr5wecYm7vnYpSuRycp3lSPO3VKLhcUjw+8Z5cdQmKxVhXYwfhelmQ= 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 165173864781952.486784484901136; Thu, 5 May 2022 01:17:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321674.542819 (Exim 4.92) (envelope-from ) id 1nmWfU-0004i7-IB; Thu, 05 May 2022 08:17:00 +0000 Received: by outflank-mailman (output) from mailman id 321674.542819; Thu, 05 May 2022 08:17:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfT-0004db-4E; Thu, 05 May 2022 08:16:59 +0000 Received: by outflank-mailman (input) for mailman id 321674; Thu, 05 May 2022 08:16:52 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfM-0001o5-B1 for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:52 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b4d2a2ac-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:47 +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 E5F9F1F895; Thu, 5 May 2022 08:16:46 +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 B70D213B11; Thu, 5 May 2022 08:16:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id CFNgK+6Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:46 +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: b4d2a2ac-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738606; 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=7yFjXHXMXwZa6Ccja7xlX/k6b/j03dysFoZbs8/tSS0=; b=tZpw7w2YZs7zI4Wv0ZhcBunFcpmESyHgadFim0wkQdlTZDZz7ZNdx1QNcQvdlPsvcwlSM2 QWD8TVciM+/T64Fk45IKVJjeUCiDTZIQ8t9ZdDRgywz13/SQqfAoPJSygm1LjbV/XUYDrk 5x1A1Gezd16QvlIB5qynYPOvcggWS7A= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini Subject: [PATCH v3 12/21] xen/xenbus: add xenbus_setup_ring() service function Date: Thu, 5 May 2022 10:16:31 +0200 Message-Id: <20220505081640.17425-13-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738648784100007 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738645; cv=none; d=zohomail.com; s=zohoarc; b=CfVyz/BMDdR/WRE767it3EmVQtXhVgQM4y3qXJ52wXtugwlOlKGz/CCiCtAj7XV0+N0EdMnBLGoiEmBxubN2RyQ4Au3j+I4ou9WsrqdVhVTlDxVvIfpZfafTsn6J0kMRO6eImvnYdFg5rhygQMmOG517MRKzVcW/MBYE+lAafHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738645; 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=DUFvPpZ+oh+I9lruBO51qkEJU8XZSf+Prfa9vNAfD4o=; b=XEQtv5sA2qK3APwKPuSmkFF25iW9UOtpP3NnkTMSmfQ9EDC034p8U8Pj8182G94vP612feG+jJ9dMNoUB4iU7O/L0EDS7iWC1mUFy0P7JWETuET0Xz13rXvu1/A7vfu9knHR4d2D/WmomrU4wsx9jNjCbe+MKV7EbbMCaamsKQM= 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 1651738645921828.5864486038998; Thu, 5 May 2022 01:17:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321677.542836 (Exim 4.92) (envelope-from ) id 1nmWfX-0005Et-6N; Thu, 05 May 2022 08:17:03 +0000 Received: by outflank-mailman (output) from mailman id 321677.542836; Thu, 05 May 2022 08:17: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 1nmWfV-000580-OZ; Thu, 05 May 2022 08:17:01 +0000 Received: by outflank-mailman (input) for mailman id 321677; Thu, 05 May 2022 08:16:54 +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 1nmWfN-0001qT-Nu for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:53 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b4ff8518-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:47 +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 37EDF2186F; Thu, 5 May 2022 08:16:47 +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 ED19B13B11; Thu, 5 May 2022 08:16:46 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mEeNOO6Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:46 +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: b4ff8518-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738607; 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=DUFvPpZ+oh+I9lruBO51qkEJU8XZSf+Prfa9vNAfD4o=; b=RYSQ8JFtt7g+QL1lPmO44RO9WuQtxDFHNcWhV9LQmmzP+qFc/I5gcomwpavuHenseioV94 /ToMKaMYHhmxtL6brZ94XA4T42D3tUBUIQYIaj/77wHBPTJxtAZoJ6Phi6kIFSXMdQx40T R9TSSP1SL5v99dQ6Wa6XXsWqGcEUCvA= 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 v3 13/21] xen/blkfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:32 +0200 Message-Id: <20220505081640.17425-14-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738646767100002 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 Acked-by: Roger Pau Monn=C3=A9 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/block/xen-blkfront.c | 37 ++++++++---------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 7f35e30e626a..bd7b34f29193 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1280,15 +1280,8 @@ static void blkif_free_ring(struct blkfront_ring_inf= o *rinfo) flush_work(&rinfo->work); =20 /* Free resources associated with old device channel. */ - for (i =3D 0; i < info->nr_ring_pages; i++) { - if (rinfo->ring_ref[i] !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(rinfo->ring_ref[i], 0); - rinfo->ring_ref[i] =3D INVALID_GRANT_REF; - } - } - free_pages_exact(rinfo->ring.sring, - info->nr_ring_pages * XEN_PAGE_SIZE); - rinfo->ring.sring =3D NULL; + xenbus_teardown_ring((void **)&rinfo->ring.sring, info->nr_ring_pages, + rinfo->ring_ref); =20 if (rinfo->irq) unbind_from_irqhandler(rinfo->irq, rinfo); @@ -1679,30 +1672,16 @@ static int setup_blkring(struct xenbus_device *dev, struct blkfront_ring_info *rinfo) { struct blkif_sring *sring; - int err, i; + int err; struct blkfront_info *info =3D rinfo->dev_info; unsigned long ring_size =3D info->nr_ring_pages * XEN_PAGE_SIZE; - grant_ref_t gref[XENBUS_MAX_RING_GRANTS]; - - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D INVALID_GRANT_REF; =20 - sring =3D alloc_pages_exact(ring_size, GFP_NOIO); - if (!sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating shared ring"); - return -ENOMEM; - } - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&rinfo->ring, sring, ring_size); - - err =3D xenbus_grant_ring(dev, rinfo->ring.sring, info->nr_ring_pages, gr= ef); - if (err < 0) { - free_pages_exact(sring, ring_size); - rinfo->ring.sring =3D NULL; + err =3D xenbus_setup_ring(dev, GFP_NOIO, (void **)&sring, + info->nr_ring_pages, rinfo->ring_ref); + if (err) goto fail; - } - for (i =3D 0; i < info->nr_ring_pages; i++) - rinfo->ring_ref[i] =3D gref[i]; + + XEN_FRONT_RING_INIT(&rinfo->ring, sring, ring_size); =20 err =3D xenbus_alloc_evtchn(dev, &rinfo->evtchn); if (err) --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738640; cv=none; d=zohomail.com; s=zohoarc; b=ZdJE6M/CcClye/TPrOBfc6cYSSGQhKcnscDSeFhWmmhJgREuMJK9CG7BPTzmeclVfhcYUB/5n23L48bzJ/V+H1afrpeKLCeJGPz9Fg5787h3FiLYRgdCyOVONJwCI1wnysiloEJ1J14bErqAPyHW+3XWvwkBl8XudVQ+MTvATYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738640; 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=M6eg+rFc1MumAtFExaebcTMQjlP8JRCZ6MaTwnyhXTA=; b=dBMxQbnupT1V8mGBqMlyRKokEhu/h/RzldPCJaordaSL+gp3MGvVI4DHeZh3dTxCdBYuGra4dwvyAIxcO76vckV7Xg++Yhvx8xUSlbJRmABYIH0Zv9McPmGTKlZkjUJVUF/qXslyRvwUCGOpGOn2IQ63lLhpIcrxUWirw6kOnrs= 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 1651738640126603.832839146606; Thu, 5 May 2022 01:17:20 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321672.542803 (Exim 4.92) (envelope-from ) id 1nmWfR-0004CL-Lj; Thu, 05 May 2022 08:16:57 +0000 Received: by outflank-mailman (output) from mailman id 321672.542803; Thu, 05 May 2022 08:16:57 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfQ-00045C-NB; Thu, 05 May 2022 08:16:56 +0000 Received: by outflank-mailman (input) for mailman id 321672; Thu, 05 May 2022 08:16:51 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfL-0001o5-Ax for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:51 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b53264fd-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:47 +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 887BE1F8A4; Thu, 5 May 2022 08:16:47 +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 404C813B11; Thu, 5 May 2022 08:16:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wBleDu+Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b53264fd-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738607; 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=M6eg+rFc1MumAtFExaebcTMQjlP8JRCZ6MaTwnyhXTA=; b=PRWXK75Iy6glOCFP+BRMxBlVtN2eHikrFDyCXtCZLSYh/NlKtBEhjsX7rYe7cPq6dpCFly qvF85uuWPEVq+aRqbBWAp2SNiiVWB76NOqlqkde8eV21BTItvL14AtMhA40lzTs2DmU8P+ I7XPM8jeaQbxgQQTxLE8bS2JFHwffU0= 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" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH v3 14/21] xen/netfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:33 +0200 Message-Id: <20220505081640.17425-15-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738640728100004 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/net/xen-netfront.c | 53 +++++++++----------------------------- 1 file changed, 12 insertions(+), 41 deletions(-) diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 966bee2a6902..65ab907aca5a 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c @@ -1921,8 +1921,7 @@ static int setup_netfront(struct xenbus_device *dev, struct netfront_queue *queue, unsigned int feature_split_evtchn) { struct xen_netif_tx_sring *txs; - struct xen_netif_rx_sring *rxs =3D NULL; - grant_ref_t gref; + struct xen_netif_rx_sring *rxs; int err; =20 queue->tx_ring_ref =3D INVALID_GRANT_REF; @@ -1930,33 +1929,19 @@ static int setup_netfront(struct xenbus_device *dev, queue->rx.sring =3D NULL; queue->tx.sring =3D NULL; =20 - txs =3D (struct xen_netif_tx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIG= H); - if (!txs) { - err =3D -ENOMEM; - xenbus_dev_fatal(dev, err, "allocating tx ring page"); + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&txs, + 1, &queue->tx_ring_ref); + if (err) goto fail; - } - SHARED_RING_INIT(txs); - FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, txs, 1, &gref); - if (err < 0) - goto fail; - queue->tx_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&queue->tx, txs, XEN_PAGE_SIZE); =20 - rxs =3D (struct xen_netif_rx_sring *)get_zeroed_page(GFP_NOIO | __GFP_HIG= H); - if (!rxs) { - err =3D -ENOMEM; - xenbus_dev_fatal(dev, err, "allocating rx ring page"); + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, (void **)&rxs, + 1, &queue->rx_ring_ref); + if (err) goto fail; - } - SHARED_RING_INIT(rxs); - FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, rxs, 1, &gref); - if (err < 0) - goto fail; - queue->rx_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&queue->rx, rxs, XEN_PAGE_SIZE); =20 if (feature_split_evtchn) err =3D setup_netfront_split(queue); @@ -1972,24 +1957,10 @@ static int setup_netfront(struct xenbus_device *dev, =20 return 0; =20 - /* If we fail to setup netfront, it is safe to just revoke access to - * granted pages because backend is not accessing it at this point. - */ fail: - if (queue->rx_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(queue->rx_ring_ref, - (unsigned long)rxs); - queue->rx_ring_ref =3D INVALID_GRANT_REF; - } else { - free_page((unsigned long)rxs); - } - if (queue->tx_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(queue->tx_ring_ref, - (unsigned long)txs); - queue->tx_ring_ref =3D INVALID_GRANT_REF; - } else { - free_page((unsigned long)txs); - } + xenbus_teardown_ring((void **)&queue->rx.sring, 1, &queue->rx_ring_ref); + xenbus_teardown_ring((void **)&queue->tx.sring, 1, &queue->tx_ring_ref); + return err; } =20 --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738647; cv=none; d=zohomail.com; s=zohoarc; b=Lj3p9HQOeVUrpiUjyAIJwGGkwbrC2c/3dijQ/NSMTZf5awjZ0IhOdwNcYNuR69ejV0O8MB8FxqCI5oT9PaUZklbVee18LtJkOVmfETWMMqkGbwYEepiYkzl2i8CKtChHcUA08+xL6YUkWLe10tJW/qXBfWAiwtYAIESCmfFHPfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738647; 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=CBDkywWrMTWS4hJ++nC6A/5fx/cpBVFJCY9cboe51eI=; b=Y/vdrjr8n0ECJXv1XvuNx85qcF5RbJuZSGtFbR+st0vwi5uuYYhGwCbES+x9qU3DRCSYiXUeM0Xpd+JqQA45q/eWnLhQWzKeby1yckkmU8a7/ASt06YiElylsjn5WLHg7W1QmL9kP4IVcJdKEoflb9OystI+TqkRPAhOEcdeQ1A= 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 1651738647214688.1741701341474; Thu, 5 May 2022 01:17:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321678.542852 (Exim 4.92) (envelope-from ) id 1nmWfa-0005xD-55; Thu, 05 May 2022 08:17:06 +0000 Received: by outflank-mailman (output) from mailman id 321678.542852; Thu, 05 May 2022 08:17: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 1nmWfY-0005oe-Vf; Thu, 05 May 2022 08:17:04 +0000 Received: by outflank-mailman (input) for mailman id 321678; Thu, 05 May 2022 08:16:54 +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 1nmWfO-0001qT-OA for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:54 +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 b5599068-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:48 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C5D41210DF; Thu, 5 May 2022 08:16:47 +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 8E7AD13B12; Thu, 5 May 2022 08:16:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iP9gIe+Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:47 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b5599068-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738607; 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=CBDkywWrMTWS4hJ++nC6A/5fx/cpBVFJCY9cboe51eI=; b=OEjJij1fp5lh4IRX8e9PkSZvFNrlGEYuIQSutmEO+TvPqFZXcgCap5W1giZv0lvoVKgGni BS2MmSOX7SimDLZiVLSOxL7uf/YU1PzAeNCyDghPW9RcDxXya8DHpSwXv98HH1ATacpLgT d9CEKt/6bV7Wm3zIeR43ugE9p4xvL1M= 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 v3 15/21] xen/tpmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:34 +0200 Message-Id: <20220505081640.17425-16-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738648847100008 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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 142CEC433F5 for ; Thu, 5 May 2022 08:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346932AbiEEIV5 (ORCPT ); Thu, 5 May 2022 04:21:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347325AbiEEIU2 (ORCPT ); Thu, 5 May 2022 04:20:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 756A449917 for ; Thu, 5 May 2022 01:16:49 -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 12A012129A; Thu, 5 May 2022 08:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738608; 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=IedMI7VTW3rOengTxIhbDIljAXRKt8bJ55HpQHeXTKE=; b=icajDoZbBIwzJ6XcUYvjT5rdUpqaOLHVx+KJgSdfR6jIBErNSkSt0o44KvdViEe6Gl4dxM y8ety7dLU+QVWAR9qvUOSPuT4K7BvqCgmQSR10XuH36FLkxabJLU+fZ6mW8c6f0yU+WgIg CVjSUZA1EqxHMUE0Gi/sxDg4kyBRsoM= 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 CCA8B13B11; Thu, 5 May 2022 08:16:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kD2xMO+Hc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:47 +0000 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 v3 16/21] xen/drmfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:35 +0200 Message-Id: <20220505081640.17425-17-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-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 drmfront's ring creation and removal via xenbus_setup_ring() and xenbus_teardown_ring(). Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/gpu/drm/xen/xen_drm_front_evtchnl.c | 43 ++++++--------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c b/drivers/gpu/drm/= xen/xen_drm_front_evtchnl.c index 4006568b9e32..e52afd792346 100644 --- a/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c +++ b/drivers/gpu/drm/xen/xen_drm_front_evtchnl.c @@ -123,12 +123,12 @@ static irqreturn_t evtchnl_interrupt_evt(int irq, voi= d *dev_id) static void evtchnl_free(struct xen_drm_front_info *front_info, struct xen_drm_front_evtchnl *evtchnl) { - unsigned long page =3D 0; + void *page =3D NULL; =20 if (evtchnl->type =3D=3D EVTCHNL_TYPE_REQ) - page =3D (unsigned long)evtchnl->u.req.ring.sring; + page =3D evtchnl->u.req.ring.sring; else if (evtchnl->type =3D=3D EVTCHNL_TYPE_EVT) - page =3D (unsigned long)evtchnl->u.evt.page; + page =3D evtchnl->u.evt.page; if (!page) return; =20 @@ -147,8 +147,7 @@ static void evtchnl_free(struct xen_drm_front_info *fro= nt_info, xenbus_free_evtchn(front_info->xb_dev, evtchnl->port); =20 /* end access and free the page */ - if (evtchnl->gref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(evtchnl->gref, page); + xenbus_teardown_ring(&page, 1, &evtchnl->gref); =20 memset(evtchnl, 0, sizeof(*evtchnl)); } @@ -158,8 +157,7 @@ static int evtchnl_alloc(struct xen_drm_front_info *fro= nt_info, int index, enum xen_drm_front_evtchnl_type type) { struct xenbus_device *xb_dev =3D front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; int ret; =20 @@ -168,44 +166,25 @@ static int evtchnl_alloc(struct xen_drm_front_info *f= ront_info, int index, evtchnl->index =3D index; evtchnl->front_info =3D front_info; evtchnl->state =3D EVTCHNL_STATE_DISCONNECTED; - evtchnl->gref =3D INVALID_GRANT_REF; =20 - page =3D get_zeroed_page(GFP_NOIO | __GFP_HIGH); - if (!page) { - ret =3D -ENOMEM; + ret =3D xenbus_setup_ring(xb_dev, GFP_NOIO | __GFP_HIGH, &page, + 1, &evtchnl->gref); + if (ret) goto fail; - } =20 if (type =3D=3D EVTCHNL_TYPE_REQ) { struct xen_displif_sring *sring; =20 init_completion(&evtchnl->u.req.completion); mutex_init(&evtchnl->u.req.req_io_lock); - sring =3D (struct xen_displif_sring *)page; - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); - - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - evtchnl->u.req.ring.sring =3D NULL; - free_page(page); - goto fail; - } + sring =3D page; + XEN_FRONT_RING_INIT(&evtchnl->u.req.ring, sring, XEN_PAGE_SIZE); =20 handler =3D evtchnl_interrupt_ctrl; } else { - ret =3D gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) { - free_page(page); - goto fail; - } - - evtchnl->u.evt.page =3D (struct xendispl_event_page *)page; - gref =3D ret; + evtchnl->u.evt.page =3D page; handler =3D evtchnl_interrupt_evt; } - evtchnl->gref =3D gref; =20 ret =3D xenbus_alloc_evtchn(xb_dev, &evtchnl->port); if (ret < 0) --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738645; cv=none; d=zohomail.com; s=zohoarc; b=R8qC3He2ophqTVhxnDWqaBG1uzNfJiUW/WTt8WiDN0HSIUFecEBgcgih9iUBUwKzYyTT3GTHjNxI7mSsKEkODM3TtjoQZ03PCvN4UETwwX7b3oRfhVpZFP+V6N21jHedXYsq6Q/WAZt+yWg30/Meq4ZbrufVeI1RVd8YRWpKqFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738645; 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=KZPJLwAsgzNCCroRjeE9JafH9BIwjuth4vqOa5N14pw=; b=kkjVoK1dHL5H0WF1yPnxuyQCfk34FeCVK56VM8Wtqy/TSxYtlxHsNEn/k4UMzQWqsGXOaQfNOPr9jJ3TJmy3e4mw7+UkbWpq2zF5BpeM8U7vGlX4Onrt0tkOijiL4IdbVkH8RhbalAei2iZYCjbACXl23OJvvFjVzyBg0Ld2GKU= 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 1651738645240497.64735156575284; Thu, 5 May 2022 01:17:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321676.542830 (Exim 4.92) (envelope-from ) id 1nmWfW-00050h-7J; Thu, 05 May 2022 08:17:02 +0000 Received: by outflank-mailman (output) from mailman id 321676.542830; Thu, 05 May 2022 08:17: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 1nmWfU-0004xu-OE; Thu, 05 May 2022 08:17:00 +0000 Received: by outflank-mailman (input) for mailman id 321676; Thu, 05 May 2022 08:16:53 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfN-0001o5-BB for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:53 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b5a69cf7-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:48 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 527911F896; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 1BA3413B11; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SE5QBfCHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b5a69cf7-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738608; 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=KZPJLwAsgzNCCroRjeE9JafH9BIwjuth4vqOa5N14pw=; b=L9AkWL0xVkfyaETjQQnwkqUS5khHtDMf+yhkFrQWWVGL/FhZgqSqJiD6oFcqjNRK/K9rtz 6R8uVePLGLABT2Xwd4pNjgXpVO+mNjheueg8SMDJ1wu3KzgWpc+QQ1S9WmzuZ1sM5HFo3U g/h5qKh9aDov7yLDD/Pzd+iMPkafJ5k= 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 v3 17/21] xen/pcifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:36 +0200 Message-Id: <20220505081640.17425-18-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738646767100001 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- 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.35.3 From nobody Mon May 13 17:16:45 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=1651738648; cv=none; d=zohomail.com; s=zohoarc; b=gZdSQaUY7GxiihJFZzozsZ4fPIUtidgmRTaTOvvZeLoPgBnq+wFy6GKFc7eo81mvw9A/nzS/U3KQ4Rt5SqHARJeAgDXLaUezTEWJTpUSZKLiDAgDh/ZK5pccBIw++/pHMjDsrFnCI65bN9dBjrx9Scv/Tfu9UhX626qXCFnwjy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738648; 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=0MG5If+wT1PFlFjSpPM4l/2JLJ70ISQLhBhO24AmiRY=; b=CToIzYCgCgDmf8eYXPDxonUfnxH6VrCXduKKIX0y1uatxnOYlbN9eY/1W9NgOe68hFwm+TLHcew/u4FKDSq2lCZkSn9okF8pgQGqMtxXXgqGIqJEDudnke/2PEW9LZ8n8zVqt7Abw6Luq9763SYyppnsMRHpqCGUld40oWBYw6I= 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 1651738648721416.83845084914117; Thu, 5 May 2022 01:17:28 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321679.542860 (Exim 4.92) (envelope-from ) id 1nmWfb-0006Mw-Ow; Thu, 05 May 2022 08:17:07 +0000 Received: by outflank-mailman (output) from mailman id 321679.542860; Thu, 05 May 2022 08:17: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 1nmWfa-0006CY-Q2; Thu, 05 May 2022 08:17:06 +0000 Received: by outflank-mailman (input) for mailman id 321679; Thu, 05 May 2022 08:16:55 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfO-0001o5-BW for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:54 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b5d1a77d-cc4b-11ec-a406-831a346695d4; Thu, 05 May 2022 10:16:48 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 946131F8A3; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5A8A413B11; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id IM5DFPCHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b5d1a77d-cc4b-11ec-a406-831a346695d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738608; 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=0MG5If+wT1PFlFjSpPM4l/2JLJ70ISQLhBhO24AmiRY=; b=jySglPOM/qmId9veILCMfWbXmbLP+gNn4u7XEfWwcN1T4/oJO4hATS7eTV+0YsaVudLyFb aYaRxPRl6knBSXtSBo/g/lmKCyGWWV5cbs786fWksp1RjeOLzvSNCVsHa/oH4L1QHJObdw 88zVG8kaKeockHaPdWQ38AjKWsWoiqY= 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 v3 18/21] xen/scsifront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:37 +0200 Message-Id: <20220505081640.17425-19-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738650770100011 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/scsi/xen-scsifront.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c index 4c55e479fc36..51afc66e839d 100644 --- a/drivers/scsi/xen-scsifront.c +++ b/drivers/scsi/xen-scsifront.c @@ -798,27 +798,15 @@ static int scsifront_alloc_ring(struct vscsifrnt_info= *info) { struct xenbus_device *dev =3D info->dev; struct vscsiif_sring *sring; - grant_ref_t gref; - int err =3D -ENOMEM; + int err; =20 /***** Frontend to Backend ring start *****/ - sring =3D (struct vscsiif_sring *)__get_free_page(GFP_KERNEL); - if (!sring) { - xenbus_dev_fatal(dev, err, - "fail to allocate shared ring (Front to Back)"); + err =3D xenbus_setup_ring(dev, GFP_KERNEL, (void **)&sring, 1, + &info->ring_ref); + if (err) return err; - } - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, sring, 1, &gref); - if (err < 0) { - free_page((unsigned long)sring); - xenbus_dev_fatal(dev, err, - "fail to grant shared ring (Front to Back)"); - return err; - } - info->ring_ref =3D gref; + XEN_FRONT_RING_INIT(&info->ring, sring, PAGE_SIZE); =20 err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { @@ -847,8 +835,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *= info) free_irq: unbind_from_irqhandler(info->irq, info); free_gnttab: - gnttab_end_foreign_access(info->ring_ref, - (unsigned long)info->ring.sring); + xenbus_teardown_ring((void **)&sring, 1, &info->ring_ref); =20 return err; } @@ -856,8 +843,7 @@ static int scsifront_alloc_ring(struct vscsifrnt_info *= info) static void scsifront_free_ring(struct vscsifrnt_info *info) { unbind_from_irqhandler(info->irq, info); - gnttab_end_foreign_access(info->ring_ref, - (unsigned long)info->ring.sring); + xenbus_teardown_ring((void **)&info->ring.sring, 1, &info->ring_ref); } =20 static int scsifront_init_ring(struct vscsifrnt_info *info) --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738651; cv=none; d=zohomail.com; s=zohoarc; b=SCZf8L41W6Xhw+sshBhE7RWXhWbx1lDzQk+rpryJpUqGFFG5sil0xQ8MWHy9+y7B4l5rB2YIn19H78UfOvdwCg2yN0qgrBjvRqJClIBG5LuzQkdxgNaV3vHTnUNvPdTxaXkJEtReZPOIH9w9IBXVo6H3sHM+s3lo4uaqMExwQDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738651; 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=s4Z1RjFpyVDty3WoTn8qjFQASCN+ZRnPh5FcuU0Fko0=; b=NKCDuxO1PgSoB7s582xxmdj8oUY29C0HAc/VDLNrzhFyP7XPhWk8bseAHraKXtL6PCrOcNYIDJ5jfTqBEBdjDUVs6MOfeJzD17eMODvmAkczyEvZ5syn0Muo6Wv3g4hewAeLC/ckAHB/Yly0NkxZl7CCPtIidlO3DViiuMrouqQ= 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 165173865144882.5669604960384; Thu, 5 May 2022 01:17:31 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321680.542871 (Exim 4.92) (envelope-from ) id 1nmWfe-00071r-FC; Thu, 05 May 2022 08:17:10 +0000 Received: by outflank-mailman (output) from mailman id 321680.542871; Thu, 05 May 2022 08:17:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfd-0006tu-4h; Thu, 05 May 2022 08:17:09 +0000 Received: by outflank-mailman (input) for mailman id 321680; Thu, 05 May 2022 08:16:56 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nmWfP-0001qT-Oa for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:55 +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 b5f27b5e-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:49 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C77D11F8A6; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9BF4413B11; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 2GSyJPCHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b5f27b5e-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738608; 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=s4Z1RjFpyVDty3WoTn8qjFQASCN+ZRnPh5FcuU0Fko0=; b=BhtFVaZFvCxw2q4uOqiGV6IV3CyJrE9Dw4JGcI3BpRoPiNqDCjWjoHDih934WXw7iqEQyg YEMJJBedzXNNfme/6kZ/1j44R+ppHMB90m/u+85yIn4E5iYAKPb8s5fbntyx4w2hypvn8M loMr0Bhpw9KIeQDLTwcA1mOnCSAVuQ0= 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 v3 19/21] xen/usbfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:38 +0200 Message-Id: <20220505081640.17425-20-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738652787100013 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- drivers/usb/host/xen-hcd.c | 61 ++++++++++---------------------------- 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/drivers/usb/host/xen-hcd.c b/drivers/usb/host/xen-hcd.c index 9cbc7c2dab02..de1b09158318 100644 --- a/drivers/usb/host/xen-hcd.c +++ b/drivers/usb/host/xen-hcd.c @@ -1098,19 +1098,10 @@ static void xenhcd_destroy_rings(struct xenhcd_info= *info) unbind_from_irqhandler(info->irq, info); info->irq =3D 0; =20 - if (info->urb_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(info->urb_ring_ref, - (unsigned long)info->urb_ring.sring); - info->urb_ring_ref =3D INVALID_GRANT_REF; - } - info->urb_ring.sring =3D NULL; - - if (info->conn_ring_ref !=3D INVALID_GRANT_REF) { - gnttab_end_foreign_access(info->conn_ring_ref, - (unsigned long)info->conn_ring.sring); - info->conn_ring_ref =3D INVALID_GRANT_REF; - } - info->conn_ring.sring =3D NULL; + xenbus_teardown_ring((void **)&info->urb_ring.sring, 1, + &info->urb_ring_ref); + xenbus_teardown_ring((void **)&info->conn_ring.sring, 1, + &info->conn_ring_ref); } =20 static int xenhcd_setup_rings(struct xenbus_device *dev, @@ -1118,46 +1109,24 @@ static int xenhcd_setup_rings(struct xenbus_device = *dev, { struct xenusb_urb_sring *urb_sring; struct xenusb_conn_sring *conn_sring; - grant_ref_t gref; int err; =20 - info->urb_ring_ref =3D INVALID_GRANT_REF; info->conn_ring_ref =3D INVALID_GRANT_REF; - - urb_sring =3D (struct xenusb_urb_sring *)get_zeroed_page( - GFP_NOIO | __GFP_HIGH); - if (!urb_sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating urb ring"); - return -ENOMEM; - } - SHARED_RING_INIT(urb_sring); - FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); - - err =3D xenbus_grant_ring(dev, urb_sring, 1, &gref); - if (err < 0) { - free_page((unsigned long)urb_sring); - info->urb_ring.sring =3D NULL; - goto fail; - } - info->urb_ring_ref =3D gref; - - conn_sring =3D (struct xenusb_conn_sring *)get_zeroed_page( - GFP_NOIO | __GFP_HIGH); - if (!conn_sring) { - xenbus_dev_fatal(dev, -ENOMEM, "allocating conn ring"); - err =3D -ENOMEM; - goto fail; + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, + (void **)&urb_sring, 1, &info->urb_ring_ref); + if (err) { + xenbus_dev_fatal(dev, err, "allocating urb ring"); + return err; } - SHARED_RING_INIT(conn_sring); - FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); + XEN_FRONT_RING_INIT(&info->urb_ring, urb_sring, PAGE_SIZE); =20 - err =3D xenbus_grant_ring(dev, conn_sring, 1, &gref); - if (err < 0) { - free_page((unsigned long)conn_sring); - info->conn_ring.sring =3D NULL; + err =3D xenbus_setup_ring(dev, GFP_NOIO | __GFP_HIGH, + (void **)&conn_sring, 1, &info->conn_ring_ref); + if (err) { + xenbus_dev_fatal(dev, err, "allocating conn ring"); goto fail; } - info->conn_ring_ref =3D gref; + XEN_FRONT_RING_INIT(&info->conn_ring, conn_sring, PAGE_SIZE); =20 err =3D xenbus_alloc_evtchn(dev, &info->evtchn); if (err) { --=20 2.35.3 From nobody Mon May 13 17:16:45 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=1651738656; cv=none; d=zohomail.com; s=zohoarc; b=D7HR+3r7X4UjOKs/4s6vyZBY+Q0i2v5E54toA42urpBbA8GjZZp29F881L+t2WCKMN5gOv9TAla/GcuF19D63psms5dHJpXFvdmqNgc/7TlrV6qMRoOZ6QfQlf6Z1XDDEa660YF2sGKHABJUGljr1LvQUlNPaBspk5kB+oGVwzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1651738656; 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=YieP6g6GD+6KZq0OezPbFilh5pPFUmXvxSeu0Xk0Zbk=; b=jUxHvS8FGO02OhlMZ6r9xUsHbsmUYIL5qPUcceBaiQNIvUzzFrR89apNC+w1TVyJFPJi8fLfFu6BRow142CizwG7a0b9dkv2Qm6B+0KfUr4K5tJ0yYk1yE7Sk+G/wJ7HWO/v7/DNAr5zD5d9c84GtQvnrQQqYaI0QV9uFPBirKQ= 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 1651738656003640.5857089997842; Thu, 5 May 2022 01:17:36 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.321681.542884 (Exim 4.92) (envelope-from ) id 1nmWfg-0007Z9-UO; Thu, 05 May 2022 08:17:12 +0000 Received: by outflank-mailman (output) from mailman id 321681.542884; Thu, 05 May 2022 08:17: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 1nmWff-0007N6-G6; Thu, 05 May 2022 08:17:11 +0000 Received: by outflank-mailman (input) for mailman id 321681; Thu, 05 May 2022 08:16:57 +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 1nmWfQ-0001qT-Ow for xen-devel@lists.xenproject.org; Thu, 05 May 2022 08:16:56 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b61a15f6-cc4b-11ec-8fc4-03012f2f19d4; Thu, 05 May 2022 10:16:49 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 120B11F8A8; Thu, 5 May 2022 08:16:49 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CD80F13B11; Thu, 5 May 2022 08:16:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 8OnlMPCHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:48 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b61a15f6-cc4b-11ec-8fc4-03012f2f19d4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738609; 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=YieP6g6GD+6KZq0OezPbFilh5pPFUmXvxSeu0Xk0Zbk=; b=a47wg7hs+Ar9ubMMFW2QBPgc/9OvtFAxtGENzHnQvWq+IimOl5w725xLTv49E1Lysuln+l EWdRp77qNP7Ww6z0rS78kI+ZFPVH8Y9J42HfkArvJavBRQdnE3UQxjVoQ5CYzVGeYAGP7p 3Gk9ApfmiHo+Z13DYIfwZirMV54dG0w= 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 v3 20/21] xen/sndfront: use xenbus_setup_ring() and xenbus_teardown_ring() Date: Thu, 5 May 2022 10:16:39 +0200 Message-Id: <20220505081640.17425-21-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1651738656815100001 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 Reviewed-by: Boris Ostrovsky Reviewed-by: Oleksandr Tyshchenko Tested-by: Oleksandr Tyshchenko --- sound/xen/xen_snd_front_evtchnl.c | 44 +++++++------------------------ 1 file changed, 10 insertions(+), 34 deletions(-) diff --git a/sound/xen/xen_snd_front_evtchnl.c b/sound/xen/xen_snd_front_ev= tchnl.c index 3e21369c8216..26d1b3987887 100644 --- a/sound/xen/xen_snd_front_evtchnl.c +++ b/sound/xen/xen_snd_front_evtchnl.c @@ -143,12 +143,12 @@ void xen_snd_front_evtchnl_flush(struct xen_snd_front= _evtchnl *channel) static void evtchnl_free(struct xen_snd_front_info *front_info, struct xen_snd_front_evtchnl *channel) { - unsigned long page =3D 0; + void *page =3D NULL; =20 if (channel->type =3D=3D EVTCHNL_TYPE_REQ) - page =3D (unsigned long)channel->u.req.ring.sring; + page =3D channel->u.req.ring.sring; else if (channel->type =3D=3D EVTCHNL_TYPE_EVT) - page =3D (unsigned long)channel->u.evt.page; + page =3D channel->u.evt.page; =20 if (!page) return; @@ -167,10 +167,7 @@ static void evtchnl_free(struct xen_snd_front_info *fr= ont_info, xenbus_free_evtchn(front_info->xb_dev, channel->port); =20 /* End access and free the page. */ - if (channel->gref !=3D INVALID_GRANT_REF) - gnttab_end_foreign_access(channel->gref, page); - else - free_page(page); + xenbus_teardown_ring(&page, 1, &channel->gref); =20 memset(channel, 0, sizeof(*channel)); } @@ -196,8 +193,7 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, enum xen_snd_front_evtchnl_type type) { struct xenbus_device *xb_dev =3D front_info->xb_dev; - unsigned long page; - grant_ref_t gref; + void *page; irq_handler_t handler; char *handler_name =3D NULL; int ret; @@ -207,12 +203,9 @@ static int evtchnl_alloc(struct xen_snd_front_info *fr= ont_info, int index, channel->index =3D index; channel->front_info =3D front_info; channel->state =3D EVTCHNL_STATE_DISCONNECTED; - channel->gref =3D INVALID_GRANT_REF; - page =3D get_zeroed_page(GFP_KERNEL); - if (!page) { - ret =3D -ENOMEM; + ret =3D xenbus_setup_ring(xb_dev, GFP_KERNEL, &page, 1, &channel->gref); + if (ret) goto fail; - } =20 handler_name =3D kasprintf(GFP_KERNEL, "%s-%s", XENSND_DRIVER_NAME, type =3D=3D EVTCHNL_TYPE_REQ ? @@ -226,33 +219,18 @@ static int evtchnl_alloc(struct xen_snd_front_info *f= ront_info, int index, mutex_init(&channel->ring_io_lock); =20 if (type =3D=3D EVTCHNL_TYPE_REQ) { - struct xen_sndif_sring *sring =3D (struct xen_sndif_sring *)page; + struct xen_sndif_sring *sring =3D page; =20 init_completion(&channel->u.req.completion); mutex_init(&channel->u.req.req_io_lock); - SHARED_RING_INIT(sring); - FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE); - - ret =3D xenbus_grant_ring(xb_dev, sring, 1, &gref); - if (ret < 0) { - channel->u.req.ring.sring =3D NULL; - goto fail; - } + XEN_FRONT_RING_INIT(&channel->u.req.ring, sring, XEN_PAGE_SIZE); =20 handler =3D evtchnl_interrupt_req; } else { - ret =3D gnttab_grant_foreign_access(xb_dev->otherend_id, - virt_to_gfn((void *)page), 0); - if (ret < 0) - goto fail; - - channel->u.evt.page =3D (struct xensnd_event_page *)page; - gref =3D ret; + channel->u.evt.page =3D page; handler =3D evtchnl_interrupt_evt; } =20 - channel->gref =3D gref; - ret =3D xenbus_alloc_evtchn(xb_dev, &channel->port); if (ret < 0) goto fail; @@ -279,8 +257,6 @@ static int evtchnl_alloc(struct xen_snd_front_info *fro= nt_info, int index, return 0; =20 fail: - if (page) - free_page(page); kfree(handler_name); dev_err(&xb_dev->dev, "Failed to allocate ring: %d\n", ret); return ret; --=20 2.35.3 From nobody Mon May 13 17:16:45 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 BB42AC433F5 for ; Thu, 5 May 2022 08:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347993AbiEEIXH (ORCPT ); Thu, 5 May 2022 04:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244879AbiEEIUa (ORCPT ); Thu, 5 May 2022 04:20:30 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ED1749933 for ; Thu, 5 May 2022 01:16:50 -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 4ABF921871; Thu, 5 May 2022 08:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1651738609; 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=Hj6JgClEpjn6TGh0jHUJx9zkFBBp/YGxKjjz8AW9Jwc=; b=eY1x7w8cnLUr3BuPmzWU96Csqt2i/OipoBessbn74oEwg3ab+rmGZw1odPnIDFmotJ228A /1dxHTptERgmJGhz1nf4m63A8AAXb/45etB0cEKFtDLH5dit6Hh0FKkDHrpay1UhjHuHSg sEPUMV6nZWaJFy2qqBkz6PIq5nWPZ7s= 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 1888F13B11; Thu, 5 May 2022 08:16:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id SCawBPGHc2K1BwAAMHmgww (envelope-from ); Thu, 05 May 2022 08:16:49 +0000 From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , Oleksandr Tyshchenko Subject: [PATCH v3 21/21] xen/xenbus: eliminate xenbus_grant_ring() Date: Thu, 5 May 2022 10:16:40 +0200 Message-Id: <20220505081640.17425-22-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220505081640.17425-1-jgross@suse.com> References: <20220505081640.17425-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is no external user of xenbus_grant_ring() left, so merge it into the only caller xenbus_setup_ring(). Signed-off-by: Juergen Gross Reviewed-by: Oleksandr Tyshchenko Reviewed-by: Boris Ostrovsky Tested-by: Oleksandr Tyshchenko --- V2: - make error message more precise (Andrew Cooper) --- drivers/xen/xenbus/xenbus_client.c | 65 +++++++++--------------------- include/xen/xenbus.h | 2 - 2 files changed, 19 insertions(+), 48 deletions(-) diff --git a/drivers/xen/xenbus/xenbus_client.c b/drivers/xen/xenbus/xenbus= _client.c index 1a2e0d94ccd1..d6fdd2d209d3 100644 --- a/drivers/xen/xenbus/xenbus_client.c +++ b/drivers/xen/xenbus/xenbus_client.c @@ -363,50 +363,6 @@ static void xenbus_switch_fatal(struct xenbus_device *= dev, int depth, int err, __xenbus_switch_state(dev, XenbusStateClosing, 1); } =20 -/** - * xenbus_grant_ring - * @dev: xenbus device - * @vaddr: starting virtual address of the ring - * @nr_pages: number of pages to be granted - * @grefs: grant reference array to be filled in - * - * Grant access to the given @vaddr to the peer of the given device. - * Then fill in @grefs with grant references. Return 0 on success, or - * -errno on error. On error, the device will switch to - * XenbusStateClosing, and the error will be saved in the store. - */ -int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, - unsigned int nr_pages, grant_ref_t *grefs) -{ - int err; - unsigned int i; - grant_ref_t gref_head; - - err =3D gnttab_alloc_grant_references(nr_pages, &gref_head); - if (err) { - xenbus_dev_fatal(dev, err, "granting access to ring page"); - return err; - } - - for (i =3D 0; i < nr_pages; i++) { - unsigned long gfn; - - if (is_vmalloc_addr(vaddr)) - gfn =3D pfn_to_gfn(vmalloc_to_pfn(vaddr)); - else - gfn =3D virt_to_gfn(vaddr); - - grefs[i] =3D gnttab_claim_grant_reference(&gref_head); - gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id, - gfn, 0); - - vaddr =3D vaddr + XEN_PAGE_SIZE; - } - - return 0; -} -EXPORT_SYMBOL_GPL(xenbus_grant_ring); - /* * xenbus_setup_ring * @dev: xenbus device @@ -424,6 +380,7 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t = gfp, void **vaddr, unsigned int nr_pages, grant_ref_t *grefs) { unsigned long ring_size =3D nr_pages * XEN_PAGE_SIZE; + grant_ref_t gref_head; unsigned int i; int ret; =20 @@ -433,9 +390,25 @@ int xenbus_setup_ring(struct xenbus_device *dev, gfp_t= gfp, void **vaddr, goto err; } =20 - ret =3D xenbus_grant_ring(dev, *vaddr, nr_pages, grefs); - if (ret) + ret =3D gnttab_alloc_grant_references(nr_pages, &gref_head); + if (ret) { + xenbus_dev_fatal(dev, ret, "granting access to %u ring pages", + nr_pages); goto err; + } + + for (i =3D 0; i < nr_pages; i++) { + unsigned long gfn; + + if (is_vmalloc_addr(*vaddr)) + gfn =3D pfn_to_gfn(vmalloc_to_pfn(vaddr[i])); + else + gfn =3D virt_to_gfn(vaddr[i]); + + grefs[i] =3D gnttab_claim_grant_reference(&gref_head); + gnttab_grant_foreign_access_ref(grefs[i], dev->otherend_id, + gfn, 0); + } =20 return 0; =20 diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h index b533b4adc835..eaa932b99d8a 100644 --- a/include/xen/xenbus.h +++ b/include/xen/xenbus.h @@ -224,8 +224,6 @@ int xenbus_watch_pathfmt(struct xenbus_device *dev, str= uct xenbus_watch *watch, const char *pathfmt, ...); =20 int xenbus_switch_state(struct xenbus_device *dev, enum xenbus_state new_s= tate); -int xenbus_grant_ring(struct xenbus_device *dev, void *vaddr, - unsigned int nr_pages, grant_ref_t *grefs); int xenbus_setup_ring(struct xenbus_device *dev, gfp_t gfp, void **vaddr, unsigned int nr_pages, grant_ref_t *grefs); void xenbus_teardown_ring(void **vaddr, unsigned int nr_pages, --=20 2.35.3