From patchwork Tue Feb 11 15:55:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Mukhin X-Patchwork-Id: 13969590 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E92C0C0219B for ; Tue, 11 Feb 2025 15:56:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.885717.1295523 (Exim 4.92) (envelope-from ) id 1thscH-00081X-RY; Tue, 11 Feb 2025 15:56:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 885717.1295523; Tue, 11 Feb 2025 15:56: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 1thscH-00081Q-Nd; Tue, 11 Feb 2025 15:56:05 +0000 Received: by outflank-mailman (input) for mailman id 885717; Tue, 11 Feb 2025 15:56:03 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1thscF-00081K-2t for xen-devel@lists.xenproject.org; Tue, 11 Feb 2025 15:56:03 +0000 Received: from mail-4316.protonmail.ch (mail-4316.protonmail.ch [185.70.43.16]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id aae23117-e890-11ef-b3ef-695165c68f79; Tue, 11 Feb 2025 16:55:51 +0100 (CET) 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: aae23117-e890-11ef-b3ef-695165c68f79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail; t=1739289350; x=1739548550; bh=6EYLHfw0uAD+vYLrvZAkRlwspulsAEhaXqaELNELbIA=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector: List-Unsubscribe:List-Unsubscribe-Post; b=AC7HXfC1NxOFACPUGHvKKgIlzP6A4GRdEqif/daccGhgCMkViYb1Ww+izsDXfhg70 24kBjPOaadqgdnlvqZn+Z59LWaTaN6z4nntZNHjLHE6h9leK2bFp7P9xMuNwuQt+/6 1zHVzoEA2WtM88TmLxGJ733eiTytK8I+sLNgBxCsmTKTbaGD3cEtZBBdC0BFLZY2Wj 0qLTHnDjAsJGSsW9aODxe5nlrkf+PWuAGlniPojAhK7RWTXD7Rdn2jZmulrXIO1vwz QDEecURKLba490z6Wl5eb0KDINy9TEgiUrvoZHrSXyqMI/RV468hpZP3KT1DJ0U+DM ssTwZYewq7ySg== Date: Tue, 11 Feb 2025 15:55:44 +0000 To: xen-devel@lists.xenproject.org From: dmkhn@proton.me Cc: andrew.cooper3@citrix.com, anthony.perard@vates.tech, jbeulich@suse.com, julien@xen.org, michal.orzel@amd.com, roger.pau@citrix.com, sstabellini@kernel.org, dmukhin@ford.com Subject: [PATCH v2] xen/include: introduce resource.h Message-ID: <20250211155517.237048-1-dmkhn@proton.me> Feedback-ID: 123220910:user:proton X-Pm-Message-ID: 60ad220f477b006e42399a4abac5d22d5e0064c2 MIME-Version: 1.0 From: Denis Mukhin Move resource definitions to a new architecture-agnostic shared header file. Signed-off-by: Denis Mukhin Reviewed-by: Stefano Stabellini --- Changes in v2: - Formatting fixes - Link to v1: https://lore.kernel.org/xen-devel/20250207231814.3863449-1-dmukhin@ford.com/ --- xen/common/device-tree/device-tree.c | 21 +---------------- xen/drivers/passthrough/arm/smmu.c | 18 +++------------ xen/include/xen/resource.h | 34 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 35 deletions(-) create mode 100644 xen/include/xen/resource.h diff --git a/xen/common/device-tree/device-tree.c b/xen/common/device-tree/device-tree.c index d0528c5825..e8f810b2fe 100644 --- a/xen/common/device-tree/device-tree.c +++ b/xen/common/device-tree/device-tree.c @@ -24,6 +24,7 @@ #include #include #include +#include const void *device_tree_flattened; dt_irq_xlate_func dt_irq_xlate; @@ -535,26 +536,6 @@ int dt_child_n_size_cells(const struct dt_device_node *parent) return __dt_n_size_cells(parent, true); } -/* - * These are defined in Linux where much of this code comes from, but - * are currently unused outside this file in the context of Xen. - */ -#define IORESOURCE_BITS 0x000000ff /* Bus-specific bits */ - -#define IORESOURCE_TYPE_BITS 0x00001f00 /* Resource type */ -#define IORESOURCE_IO 0x00000100 /* PCI/ISA I/O ports */ -#define IORESOURCE_MEM 0x00000200 -#define IORESOURCE_REG 0x00000300 /* Register offsets */ -#define IORESOURCE_IRQ 0x00000400 -#define IORESOURCE_DMA 0x00000800 -#define IORESOURCE_BUS 0x00001000 - -#define IORESOURCE_PREFETCH 0x00002000 /* No side effects */ -#define IORESOURCE_READONLY 0x00004000 -#define IORESOURCE_CACHEABLE 0x00008000 -#define IORESOURCE_RANGELENGTH 0x00010000 -#define IORESOURCE_SHADOWABLE 0x00020000 - /* * Default translator (generic bus) */ diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c index 03d22bce1e..0f8d47dc98 100644 --- a/xen/drivers/passthrough/arm/smmu.c +++ b/xen/drivers/passthrough/arm/smmu.c @@ -50,6 +50,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,8 @@ /* Alias to Xen device tree helpers */ #define device_node dt_device_node +#define platform_device dt_device_node + #define of_phandle_args dt_phandle_args #define of_device_id dt_device_match #define of_match_node dt_match_node @@ -71,21 +74,6 @@ #define of_property_read_bool dt_property_read_bool #define of_parse_phandle_with_args dt_parse_phandle_with_args -/* Xen: Helpers to get device MMIO and IRQs */ -struct resource -{ - paddr_t addr; - paddr_t size; - unsigned int type; -}; - -#define resource_size(res) (res)->size; - -#define platform_device dt_device_node - -#define IORESOURCE_MEM 0 -#define IORESOURCE_IRQ 1 - static struct resource *platform_get_resource(struct platform_device *pdev, unsigned int type, unsigned int num) diff --git a/xen/include/xen/resource.h b/xen/include/xen/resource.h new file mode 100644 index 0000000000..5d10363128 --- /dev/null +++ b/xen/include/xen/resource.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * System resource description. + */ +#ifndef XEN__RESOURCE_H +#define XEN__RESOURCE_H + +#define IORESOURCE_BITS 0x000000FFU /* Bus-specific bits */ + +#define IORESOURCE_TYPE_BITS 0x00001F00U /* Resource type */ +#define IORESOURCE_IO 0x00000100U /* PCI/ISA I/O ports */ +#define IORESOURCE_MEM 0x00000200U +#define IORESOURCE_REG 0x00000300U /* Register offsets */ +#define IORESOURCE_IRQ 0x00000400U +#define IORESOURCE_DMA 0x00000800U +#define IORESOURCE_BUS 0x00001000U + +#define IORESOURCE_PREFETCH 0x00002000U /* No side effects */ +#define IORESOURCE_READONLY 0x00004000U +#define IORESOURCE_CACHEABLE 0x00008000U +#define IORESOURCE_RANGELENGTH 0x00010000U +#define IORESOURCE_SHADOWABLE 0x00020000U + +#define IORESOURCE_UNKNOWN (~0U) + +struct resource { + paddr_t addr; + paddr_t size; + unsigned int type; +}; + +#define resource_size(res) ((res)->size) + +#endif /* XEN__RESOURCE_H */