Introduce generic headers
v8 cover Introduce generic headers
Some headers are common between several architectures, so the current patch series provide them.
Another one reason to have them as generic is a simplification of adding support necessary to make a complete Xen build as it was/is being done in the patch series [1] and [2].
Also, instead of providing generic/stub headers, it was used "#ifdef CONFIG_* #include <asm/*.h> #endif" instead of providing empty headers.
This patch series is a pre-requisite for "Enable build of full Xen for RISC-V" [3].
[1] https://lore.kernel.org/xen-devel/[email protected]/
[2] https://lore.kernel.org/xen-devel/[email protected]/
[3] https://lore.kernel.org/xen-devel/[email protected]/
---
Changes in V8:
- Add Acked-by Acked-by: Tamas K Lengyel <[email protected]> for patches:
[PATCH v7 4/7] xen/asm-generic: ifdef inclusion of <asm/mem_access.h> [PATCH v7 3/7] xen/asm-generic: introduce stub header monitor.h
- Update the commit messages for patches:
[PATCH v7 5/7] xen/asm-generic: introduce generic device.h
[PATCH v7 6/7] xen/arm: switch Arm to use asm-generic/device.h
- Drop #ifdef HAS_PCI in asm-generic/device.h to be consistent with other pci-related things in the header.
- Code styles fixes.
---
Changes in V7:
- The following patches were dropped because of rebasing as they were merged to staging:
- [PATCH v6 3/9] xen/asm-generic: introduce generic div64.h header
- [PATCH v6 6/9] xen/asm-generic: introduce stub header softirq.h
- [PATCH v6 7/9] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
- [PATCH v6 8/9] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
- [PATCH v6 5/9] xen/asm-generic: introduce stub header numa.h was dropped becaus of the patch: "[PATCH v2] NUMA: no need for asm/numa.h when !NUMA"
- Drop definition of arch_monitor_domctl_event for PPC.
- define arch_monitor_domctl_event in asm-generic/monitor.h.
- Add "define HAS_ARCH_MONITOR_DOMCTL_EVENT" in arm/.../monitor.h as it has arch specific implementation.
- keeping DEVICE_PCI_HOSTBRIDGE available for every build based on the reply:
https://lore.kernel.org/xen-devel/[email protected]/
- add comment above enum device_type.h with explanation about DEV_TYPE_MAX.
- drop #ifdef HAS_PCI around "(device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE))" in ARM code.
- separate patch "[PATCH v6 9/9] xen/asm-generic: introduce generic device.h" into 3 patches.
---
Changes in V6:
- Fix the build script to work properly with EXTRA_FIXED_RANDCONFIG.
- Introduce separate randconfig yaml with fixed configs for RISC-V.
- Disable CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS for PPC and RISC-V.
- Remove change in Kconfig/common for CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS.
- Rebase on top of the latest staging.
---
Changes in V5:
- Update the patch series message as patch related to delay.h was merged.
- Rebase on top of staging because half of the patches of the patch series were
merged to staging branch.
- Add A-by for some of the patches.
- Add "depends on X86 || Arm" for CONFIG_GRANT_TABLE and CONFIG_MEM_ACCESS to be
sure it won't be turned on by randconfig in CI.
- Partly switch Arm and PPC to asm-generic/monitor.h.
- Some other minor changes
---
Changes in V4:
- Update the cover letter message
- Add Reviewed-by/Acked-by for patches:
[PATCH v3 01/14] xen/asm-generic: introduce stub header paging.h
[PATCH v3 03/14] xen/asm-generic: introduce generic hypercall.h
[PATCH v3 04/14] xen/asm-generic: introduce generic header iocap.h
[PATCH v3 05/14] xen/asm-generic: introduce stub header <asm/random.h>
[PATCH v3 06/14] xen/asm-generic: introduce generic header percpu.h
[PATCH v3 07/14] xen/asm-generic: introduce generalized hardirq.h
[PATCH v3 08/14] xen/asm-generic: introduce generic div64.h header
[PATCH v3 09/14] xen/asm-generic: introduce generic header altp2m.h
[PATCH v3 10/14] xen/asm-generic: introduce stub header monitor.h
[PATCH v3 11/14] xen/asm-generic: introduce stub header numa.h
[PATCH v3 12/14] xen/asm-generic: introduce stub header softirq.h
- Fix some code style and minor issues.
- Use asm-generic version of device.h for Arm and PPC.
---
Changes in V3:
- Update the commit message of the cover letter.
- Drop the following patch as it can be arch-specific enough:
* [PATCH v2 09/15] xen/asm-generic: introduce generic header smp.h
- Drop correspondent arch specific headers and use asm-generic version of
a header.
- Back to the patch series patches:
* xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
* xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
---
Changes in V2:
- Update the commit message of the cover letter.
- Drop the following patches because they are arch-specific or was sent as a separate patch:
- xen/asm-generic: introduce stub header event.h
- xen/asm-generic: introduce stub header spinlock.h
- [PATCH v1 03/29] xen/asm-generic: introduce stub header cpufeature.h
- [PATCH v1 07/29] xen/asm-generic: introduce stub header guest_atomics.h
- [PATCH v1 10/29] xen/asm-generic: introduce stub header iommu.h
- [PATCH v1 12/29] xen/asm-generic: introduce stub header pci.h because separate patch was sent [5]
- [PATCH v1 14/29] xen/asm-generic: introduce stub header setup.h
- [PATCH v1 15/29] xen/asm-generic: introduce stub header xenoprof.h because of [3].
- [PATCH v1 16/29] xen/asm-generic: introduce stub header flushtlb.h
- [PATCH v1 22/29] xen/asm-generic: introduce stub header delay.h because of [3]
- [PATCH v1 23/29] xen/asm-generic: introduce stub header domain.h
- [PATCH v1 24/29] xen/asm-generic: introduce stub header guest_access.h
- [PATCH v1 25/29] xen/asm-generic: introduce stub header irq.h ( probably not so generic as I expected, I'll back to it if it will be necessary in the future )
- [PATCH v1 28/29] xen/asm-generic: introduce stub header p2m.h ( probably not so generic as I expected, I'll back to it if it will be necessary in the future )
- For the rest of the patches please look at changes for each patch separately.
---
Oleksii Kurochko (7):
automation: ensure values in EXTRA_FIXED_RANDCONFIG are separated by
new line
automation: introduce fixed randconfig for RISC-V xen/asm-generic: introduce stub header monitor.h xen/asm-generic: ifdef inclusion of <asm/mem_access.h> xen/asm-generic: introduce generic device.h
xen/arm: switch Arm to use asm-generic/device.h
xen/ppc: switch PPC to use asm-generic/device.h
automation/gitlab-ci/build.yaml | 8 +-
.../gitlab-ci/riscv-fixed-randconfig.yaml | 7 ++
automation/scripts/build | 6 +-
xen/arch/arm/device.c | 5 +
xen/arch/arm/domain_build.c | 2 +-
xen/arch/arm/gic-v2.c | 4 +-
xen/arch/arm/gic-v3.c | 6 +-
xen/arch/arm/gic.c | 4 +-
xen/arch/arm/include/asm/Makefile | 1 +
xen/arch/arm/include/asm/monitor.h | 25 +---
xen/arch/arm/p2m.c | 1 +
xen/arch/arm/traps.c | 1 +
xen/arch/ppc/configs/ppc64_defconfig | 1 +
xen/arch/ppc/include/asm/Makefile | 1 +
xen/arch/ppc/include/asm/device.h | 53 --------
xen/arch/ppc/include/asm/mem_access.h | 5 -
xen/arch/ppc/include/asm/monitor.h | 28 +----
xen/arch/ppc/stubs.c | 8 --
xen/arch/riscv/configs/tiny64_defconfig | 1 +
.../asm => include/asm-generic}/device.h | 117 +++++++++++-------
xen/include/asm-generic/monitor.h | 64 ++++++++++
xen/include/xen/mem_access.h | 2 +
22 files changed, 174 insertions(+), 176 deletions(-)
create mode 100644 automation/gitlab-ci/riscv-fixed-randconfig.yaml
delete mode 100644 xen/arch/ppc/include/asm/device.h
delete mode 100644 xen/arch/ppc/include/asm/mem_access.h
rename xen/{arch/arm/include/asm => include/asm-generic}/device.h (66%)
create mode 100644 xen/include/asm-generic/monitor.hSignature · 1 line
2.43.0
PATCH v8 2/7 automation: introduce fixed randconfig for RISC-V
This patch introduces the file riscv-fixed-randconfig.yaml, which includes all configurations that should be disabled for randconfig builds.
---
The patch were introduced after discussion in a topic:
https://lore.kernel.org/xen-devel/[email protected]/
---
Changes in V8:
- Nothing changed. Only rebase
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- The patch was introduced in this version of patch series.
--- automation/gitlab-ci/build.yaml | 8 ++++---- automation/gitlab-ci/riscv-fixed-randconfig.yaml | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 automation/gitlab-ci/riscv-fixed-randconfig.yaml
automation/gitlab-ci/build.yaml +4 -4
@@ -512,6 +512,8 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools: CONFIG_BOOT_TIME_CPUPOOLS=y # RISC-V 64 cross-build +include: 'automation/gitlab-ci/riscv-fixed-randconfig.yaml' + archlinux-current-gcc-riscv64: extends: .gcc-riscv64-cross-build variables:
@@ -532,8 +534,7 @@ archlinux-current-gcc-riscv64-randconfig: CONTAINER: archlinux:current-riscv64 KBUILD_DEFCONFIG: tiny64_defconfig RANDCONFIG: y - EXTRA_FIXED_RANDCONFIG: - CONFIG_COVERAGE=n + EXTRA_FIXED_RANDCONFIG: !reference [.riscv-fixed-randconfig, variables, EXTRA_FIXED_RANDCONFIG] archlinux-current-gcc-riscv64-debug-randconfig: extends: .gcc-riscv64-cross-build-debug
@@ -541,8 +542,7 @@ archlinux-current-gcc-riscv64-debug-randconfig: CONTAINER: archlinux:current-riscv64 KBUILD_DEFCONFIG: tiny64_defconfig RANDCONFIG: y - EXTRA_FIXED_RANDCONFIG: - CONFIG_COVERAGE=n + EXTRA_FIXED_RANDCONFIG: !reference [.riscv-fixed-randconfig, variables, EXTRA_FIXED_RANDCONFIG] # Power cross-build debian-bullseye-gcc-ppc64le:
automation/gitlab-ci/riscv-fixed-randconfig.yaml new file +7 -0
@@ -0,0 +1,7 @@ +.riscv-fixed-randconfig: + variables: + EXTRA_FIXED_RANDCONFIG: + CONFIG_COVERAGE=n + CONFIG_EXPERT=y + CONFIG_GRANT_TABLE=n + CONFIG_MEM_ACCESS=n
Signature · 1 line
2.43.0
PATCH v8 3/7 xen/asm-generic: introduce stub header monitor.h
In reply to Oleksii KurochkoThe header is shared between several archs so it is moved to asm-generic.
Switch partly Arm and PPC to asm-generic/monitor.h and only arch_monitor_get_capabilities() left in arch-specific/monitor.h.
---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Drop definition of arch_monitor_domctl_event for PPC.
- define arch_monitor_domctl_event in asm-generic/monitor.h.
- add "define HAS_ARCH_MONITOR_DOMCTL_EVENT" in arm/.../monitor.h as it has arch specific implementation.
---
Changes in V6:
- Rebase only.
---
Changes in V5:
- Switched partly Arm and PPC to asm-generic monitor.h only arch_monitor_get_capabilities() left in arch-specific/monitor.h.
- Updated the commit message.
---
Changes in V4:
- Removed the double blank line.
- Added Acked-by: Jan Beulich <[email protected]>.
- Update the commit message
---
Changes in V3:
- Use forward-declaration of struct domain instead of " #include <xen/sched.h> ".
- Add ' include <xen/errno.h> '
- Drop PPC's monitor.h.
---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "struct xen_domctl_monitor_op;"
- remove one of SPDX tags.
--- xen/arch/arm/include/asm/monitor.h | 25 +----------- xen/arch/ppc/include/asm/monitor.h | 28 +------------ xen/arch/ppc/stubs.c | 8 ---- xen/include/asm-generic/monitor.h | 64 ++++++++++++++++++++++++++++++ 4 files changed, 67 insertions(+), 58 deletions(-) create mode 100644 xen/include/asm-generic/monitor.h
xen/arch/arm/include/asm/monitor.h +2 -23
@@ -25,34 +25,13 @@#include <xen/sched.h> #include <public/domctl.h> -static inline -void arch_monitor_allow_userspace (struct domain *d,bool allow_userspace) -{ -} +#define HAS_ARCH_MONITOR_DOMCTL_EVENT -static inline -int arch_monitor_domctl_op (struct domain *d,struct xen_domctl_monitor_op *mop) -{ -/* No arch-specific monitor ops on ARM. */ -return -EOPNOTSUPP ; -} +#include <asm-generic/monitor.h> int arch_monitor_domctl_event (struct domain *d,struct xen_domctl_monitor_op *mop); -static inline -int arch_monitor_init_domain (struct domain *d) -{ -/* No arch-specific domain initialization on ARM. */ -return 0 ; -} - -static inline -void arch_monitor_cleanup_domain (struct domain *d) -{ -/* No arch-specific domain cleanup on ARM. */ -} -static inline uint32_t arch_monitor_get_capabilities (struct domain *d) {uint32_t capabilities =0 ;
xen/arch/ppc/include/asm/monitor.h +1 -27
@@ -6,33 +6,7 @@#include <public/domctl.h> #include <xen/errno.h> -static inline -void arch_monitor_allow_userspace (struct domain *d,bool allow_userspace) -{ -} - -static inline -int arch_monitor_domctl_op (struct domain *d,struct xen_domctl_monitor_op *mop) -{ -/* No arch-specific monitor ops on PPC. */ -return -EOPNOTSUPP ; -} - -int arch_monitor_domctl_event (struct domain *d, -struct xen_domctl_monitor_op *mop); - -static inline -int arch_monitor_init_domain (struct domain *d) -{ -/* No arch-specific domain initialization on PPC. */ -return 0 ; -} - -static inline -void arch_monitor_cleanup_domain (struct domain *d) -{ -/* No arch-specific domain cleanup on PPC. */ -} +#include <asm-generic/monitor.h> static inline uint32_t arch_monitor_get_capabilities (struct domain *d) {
xen/arch/ppc/stubs.c +0 -8
@@ -95,14 +95,6 @@ void arch_get_domain_info(const struct domain *d,BUG_ON ("unimplemented" ); } -/* monitor.c */ - -int arch_monitor_domctl_event (struct domain *d, -struct xen_domctl_monitor_op *mop) -{ -BUG_ON ("unimplemented" ); -} -/* smp.c */ void arch_flush_tlb_mask (const cpumask_t *mask)
xen/include/asm-generic/monitor.h new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v8 4/7 xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
In reply to Oleksii Kurochkoifdefing inclusion of <asm/mem_access.h> in <xen/mem_access.h> allows to avoid generation of empty <asm/mem_access.h> header for the case when !CONFIG_MEM_ACCESS.
For Arm it was explicitly added inclusion of <asm/mem_access.h> for p2m.c and traps.c because they require some functions from <asm/mem_access.h> which aren't available in case of !CONFIG_MEM_ACCESS.
---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- Remove the way how CONFIG_MEM_ACCESS is disabled for PPC and RISC-V.
- Disable the config in ppc64_defconfig and tiny64_defconfig (RISC-V).
---
Changes in V5:
- Added dependencies for "Config MEM_ACCESS" to be sure that randconfig will not turn on the config.
---
Changes in V4:
- Nothing changed. Only rebase.
---
Changes in V3:
- Remove unnecessary comment.
--- xen/arch/arm/p2m.c | 1 + xen/arch/arm/traps.c | 1 + xen/arch/ppc/configs/ppc64_defconfig | 1 + xen/arch/ppc/include/asm/mem_access.h | 5 ----- xen/arch/riscv/configs/tiny64_defconfig | 1 + xen/include/xen/mem_access.h | 2 ++ 6 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 xen/arch/ppc/include/asm/mem_access.h
xen/arch/arm/p2m.c +1 -0
@@ -7,6 +7,7 @@#include <asm/event.h> #include <asm/flushtlb.h> #include <asm/guest_walk.h> +#include <asm/mem_access.h> #include <asm/page.h> #include <asm/traps.h>
xen/arch/arm/traps.c +1 -0
@@ -35,6 +35,7 @@#include <asm/cpufeature.h> #include <asm/event.h> #include <asm/hsr.h> +#include <asm/mem_access.h> #include <asm/mmio.h> #include <asm/regs.h> #include <asm/smccc.h>
xen/arch/ppc/configs/ppc64_defconfig +1 -0
@@ -6,6 +6,7 @@ # CONFIG_HYPFS is not set # CONFIG_GRANT_TABLE is not set # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set +# CONFIG_MEM_ACCESS is not set CONFIG_PPC64=y CONFIG_DEBUG=y
xen/arch/ppc/include/asm/mem_access.h deleted +0 -5
@@ -1,5 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef __ASM_PPC_MEM_ACCESS_H__ -#define __ASM_PPC_MEM_ACCESS_H__ - -#endif /* __ASM_PPC_MEM_ACCESS_H__ */
xen/arch/riscv/configs/tiny64_defconfig +1 -0
@@ -6,6 +6,7 @@ # CONFIG_HYPFS is not set # CONFIG_GRANT_TABLE is not set # CONFIG_SPECULATIVE_HARDEN_ARRAY is not set +# CONFIG_MEM_ACCESS is not set CONFIG_RISCV_64=y CONFIG_DEBUG=y
xen/include/xen/mem_access.h +2 -0
@@ -33,7 +33,9 @@*/ struct vm_event_st ; +#ifdef CONFIG_MEM_ACCESS #include <asm/mem_access.h> +#endif /* * Additional access types, which are used to further restrict
Signature · 1 line
2.43.0
PATCH v8 1/7 automation: ensure values in EXTRA_FIXED_RANDCONFIG are separated by new line
In reply to Oleksii KurochkoKconfig tool expects each configuration to be on a new line.
The current version of the build script puts all of ${EXTRA_FIXED_RANDCONFIG} in a single line and configs are seperated by spaces.
As a result, only the first configuration in ${EXTRA_FIXED_RANDCONFIG} will be used.
---
Changes in V8:
- Nothing changed. Only rebase
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- The patch was introduced in this version of patch series.
--- automation/scripts/build | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
automation/scripts/build +4 -2
@@ -14,7 +14,7 @@ if [[ "${RANDCONFIG}" == "y" ]]; then # Append job-specific fixed configuration if [[ -n "${EXTRA_FIXED_RANDCONFIG}" ]]; then - echo "${EXTRA_FIXED_RANDCONFIG}" >> xen/tools/kconfig/allrandom.config + sed "s/ /\n/g" <<< "${EXTRA_FIXED_RANDCONFIG}" > xen/tools/kconfig/allrandom.config fi make -j$(nproc) -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
@@ -28,9 +28,11 @@ else echo "CONFIG_DEBUG=${debug}" >> xen/.config if [[ -n "${EXTRA_XEN_CONFIG}" ]]; then - echo "${EXTRA_XEN_CONFIG}" >> xen/.config + sed "s/ /\n/g" <<< "${EXTRA_XEN_CONFIG}" >> xen/.config fi + cat xen/.config + make -j$(nproc) -C xen olddefconfig fi
Signature · 1 line
2.43.0
PATCH v8 5/7 xen/asm-generic: introduce generic device.h
In reply to Oleksii KurochkoArm, PPC and RISC-V introduce the same things in asm/device.h, so generic device.h was introduced.
Arm's device.h was taken as a base with the following changes:
- #ifdef ACPI related things.
- Rename #ifdef guards.
- Add SPDX tag.
- #ifdef CONFIG_HAS_DEVICE_TREE related things.
- #ifdef-ing iommu related things with CONFIG_HAS_PASSTHROUGH.
---
Changes in V8:
- drop #ifdef HAS_PCI around DEV_PCI in enum device_type to be consistent with DEVICE_PCI_HOSTBRIDGE
- drop the comment above enum device_type, after DEV_PCI is alaways present in enum device_type, so there is no need anymore in comment and DEV_TYPE_MAX.
- drop #ifdef HAS_PCI around dev_is_pci() as DEV_PCI is alwayds define now.
- rename args _name, _namestr, _class to name, namestr, class.
- drop unnessary backslash after .class = class in defines ACPI_DEVICE_START() and DT_DEVICE_START()
- update the commit message
---
Changes in V7:
- keeping DEVICE_PCI_HOSTBRIDGE available for every build based on the reply:
https://lore.kernel.org/xen-devel/[email protected]/
- add comment above enum device_type.h with explanation about DEV_TYPE_MAX.
- separate patch "[PATCH v6 9/9] xen/asm-generic: introduce generic device.h" into 3 patches.
---
Changes in V6:
- Rebase only.
---
Changes in V5:
- Removed generated file: xen/include/headers++.chk.new
- Removed pointless #ifdef CONFIG_HAS_DEVICE_TREE ... #endif for PPC as CONFIG_HAS_DEVICE_TREE will be always used for PPC.
---
Changes in V4:
- Updated the commit message
- Switched Arm and PPC to asm-generic version of device.h
- Replaced HAS_PCI with CONFIG_HAS_PCI
- ifdef-ing iommu filed of dev_archdata struct with CONFIG_HAS_PASSTHROUGH
- ifdef-ing iommu_fwspec of device struct with CONFIG_HAS_PASSTHROUGH
- ifdef-ing DT related things with CONFIG_HAS_DEVICE_TREE
- Updated the commit message ( remove a note with question about
if device.h should be in asm-generic or not )
- Replaced DEVICE_IC with DEVICE_INTERRUPT_CONTROLLER
- Rationalized usage of CONFIG_HAS_* in device.h
- Fixed indents for ACPI_DEVICE_START and ACPI_DEVICE_END
---
Changes in V3:
- ifdef device tree related things.
- update the commit message
---
Changes in V2:
- take ( as common ) device.h from Arm as PPC and RISC-V use it as a base.
- #ifdef PCI related things.
- #ifdef ACPI related things.
- rename DEVICE_GIC to DEVIC_IC.
- rename #ifdef guards.
- switch Arm and PPC to generic device.h
- add SPDX tag
- update the commit message
--- xen/include/asm-generic/device.h | 149 +++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 xen/include/asm-generic/device.h
xen/include/asm-generic/device.h new file +149 -0
@@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DEVICE_H__ +#define __ASM_GENERIC_DEVICE_H__ + +#include <xen/stdbool.h> + +enum device_type +{ +#ifdef CONFIG_HAS_DEVICE_TREE +DEV_DT , +#endif +DEV_PCI +}; + +enum device_class +{ +DEVICE_SERIAL , +DEVICE_IOMMU , +DEVICE_INTERRUPT_CONTROLLER , +DEVICE_PCI_HOSTBRIDGE , +/* Use for error */ +DEVICE_UNKNOWN , +}; + +struct dev_archdata { +#ifdef CONFIG_HAS_PASSTHROUGH +void *iommu;/* IOMMU private data */ +#endif +}; + +/* struct device - The basic device structure */ +struct device +{ +enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE +struct dt_device_node *of_node;/* Used by drivers imported from Linux */ +#endif +struct dev_archdata archdata; +#ifdef CONFIG_HAS_PASSTHROUGH +struct iommu_fwspec *iommu_fwspec;/* per-device IOMMU instance data */ +#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init (struct dt_device_node *dev,enum device_class class, +const void *data); + +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class (const struct dt_device_node *dev); + +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + +/* List of devices supported by this driver */ +const struct dt_device_match *dt_match; +/* +* Device initialization. +* +* -EAGAIN is used to indicate that device probing is deferred. +*/ +int (*init)(struct dt_device_node *dev,const void *data); + +#endif +}; + +#ifdef CONFIG_ACPI + +struct acpi_device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; +/* type of device supported by the driver */ +const int class_type; +/* Device initialization */ +int (*init)(const void *data); +}; + +/** +* acpi_device_init - Initialize a device +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int acpi_device_init (enum device_class class, +const void *data,int class_type); + +#define ACPI_DEVICE_START (name_, namestr_, class_) \ +static const struct acpi_device_desc __dev_desc_##name_ __used \ +__section(".adev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define ACPI_DEVICE_END \ +}; + +#endif /* CONFIG_ACPI */ + +#endif /* __ASM_GENERIC_DEVICE_H__ */ + +/* +* Local variables: +* mode: C +* c-file-style: "BSD" +* c-basic-offset: 4 +* indent-tabs-mode: nil +* End: +*/
Signature · 1 line
2.43.0
PATCH v8 6/7 xen/arm: switch Arm to use asm-generic/device.h
In reply to Oleksii KurochkoThe following changes were done as a result of switching to asm-generic/device.h:
* DEVICE_GIC was renamed to DEVICE_INTERRUPT_CONTROLLER according to definition of enum device_class in asm-generic/device.h.
* acpi-related things in Arm code were guarded by #ifdef CONFIG_ACPI as struct acpi_device_desc was guarded in asm-generic, also functions acpi_device_init() was guarded too as they are using structure acpi_device_desc inside.
* drop arm/include/asm/device.h and update arm/include/asm/Makefile to use asm-generic/device.h instead.
---
Changes in V8:
- update the commit message
---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce generic device.h
--- xen/arch/arm/device.c | 5 ++ xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic-v2.c | 4 +- xen/arch/arm/gic-v3.c | 6 +- xen/arch/arm/gic.c | 4 +- xen/arch/arm/include/asm/Makefile | 1 + xen/arch/arm/include/asm/device.h | 124 ------------------------------ 7 files changed, 14 insertions(+), 132 deletions(-) delete mode 100644 xen/arch/arm/include/asm/device.h
xen/arch/arm/device.c +5 -0
@@ -16,7 +16,10 @@#include <xen/lib.h> extern const struct device_desc _sdevice[], _edevice[]; + +#ifdef CONFIG_ACPI extern const struct acpi_device_desc _asdevice[], _aedevice[]; +#endif int __init device_init (struct dt_device_node *dev,enum device_class class,const void *data)
@@ -45,6 +48,7 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,return -EBADF ; } +#ifdef CONFIG_ACPI int __init acpi_device_init (enum device_class class,const void *data,int class_type) {const struct acpi_device_desc *desc;
@@ -61,6 +65,7 @@ int __init acpi_device_init(enum device_class class, const void *data, int class return -EBADF; } +#endif enum device_class device_get_class (const struct dt_device_node *dev) {
xen/arch/arm/domain_build.c +1 -1
@@ -1651,7 +1651,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,* Replace these nodes with our own. Note that the original may be * used_by DOMID_XEN so this check comes first. */ -if (device_get_class (node) ==DEVICE_GIC ) +if (device_get_class (node) ==DEVICE_INTERRUPT_CONTROLLER )return make_gic_node (d, kinfo->fdt, node);if (dt_match_node (timer_matches, node) )return make_timer_node (kinfo);
xen/arch/arm/gic-v2.c +2 -2
@@ -1366,7 +1366,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst = { /* sentinel */ }, }; -DT_DEVICE_START (gicv2,"GICv2" ,DEVICE_GIC ) +DT_DEVICE_START (gicv2,"GICv2" ,DEVICE_INTERRUPT_CONTROLLER ) .dt_match = gicv2_dt_match, .init = gicv2_dt_preinit,DT_DEVICE_END
@@ -1381,7 +1381,7 @@ static int __init gicv2_acpi_preinit(const void *data)return 0 ; } -ACPI_DEVICE_START (agicv2,"GICv2" ,DEVICE_GIC ) +ACPI_DEVICE_START (agicv2,"GICv2" ,DEVICE_INTERRUPT_CONTROLLER ) .class_type = ACPI_MADT_GIC_VERSION_V2, .init = gicv2_acpi_preinit,ACPI_DEVICE_END
xen/arch/arm/gic-v3.c +3 -3
@@ -1909,7 +1909,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst = { /* sentinel */ }, }; -DT_DEVICE_START (gicv3,"GICv3" ,DEVICE_GIC ) +DT_DEVICE_START (gicv3,"GICv3" ,DEVICE_INTERRUPT_CONTROLLER ) .dt_match = gicv3_dt_match, .init = gicv3_dt_preinit,DT_DEVICE_END
@@ -1924,12 +1924,12 @@ static int __init gicv3_acpi_preinit(const void *data)return 0 ; } -ACPI_DEVICE_START (agicv3,"GICv3" ,DEVICE_GIC ) +ACPI_DEVICE_START (agicv3,"GICv3" ,DEVICE_INTERRUPT_CONTROLLER ) .class_type =ACPI_MADT_GIC_VERSION_V3 , .init = gicv3_acpi_preinit, ACPI_DEVICE_END -ACPI_DEVICE_START (agicv4,"GICv4" ,DEVICE_GIC ) +ACPI_DEVICE_START (agicv4,"GICv4" ,DEVICE_INTERRUPT_CONTROLLER ) .class_type =ACPI_MADT_GIC_VERSION_V4 , .init = gicv3_acpi_preinit,ACPI_DEVICE_END
xen/arch/arm/gic.c +2 -2
@@ -234,7 +234,7 @@ static void __init gic_dt_preinit(void)if ( !dt_get_parent (node) )continue ; - rc =device_init (node,DEVICE_GIC ,NULL ); + rc =device_init (node,DEVICE_INTERRUPT_CONTROLLER ,NULL );if ( !rc ) {/* NOTE: Only one GIC is supported */
@@ -262,7 +262,7 @@ static void __init gic_acpi_preinit(void) dist = container_of(header, struct acpi_madt_generic_distributor, header); -if (acpi_device_init (DEVICE_GIC ,NULL , dist->version) ) +if (acpi_device_init (DEVICE_INTERRUPT_CONTROLLER ,NULL , dist->version) ) panic("Unable to find compatible GIC in the ACPI table\n"); }#else
xen/arch/arm/include/asm/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only generic-y += altp2m.h +generic-y += device.h generic-y += hardirq.h generic-y += iocap.h generic-y += paging.h
xen/arch/arm/include/asm/device.h deleted +0 -124
124 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH v8 7/7 xen/ppc: switch PPC to use asm-generic/device.h
In reply to Oleksii Kurochko---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce generic device.h
---
xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/ppc/include/asm/device.h | 53 ------------------------------- 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 xen/arch/ppc/include/asm/device.h
xen/arch/ppc/include/asm/Makefile +1 -0
@@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only generic-y += altp2m.h +generic-y += device.h generic-y += div64.h generic-y += hardirq.h generic-y += hypercall.h
xen/arch/ppc/include/asm/device.h deleted +0 -53
53 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v8 1/7] automation: ensure values in EXTRA_FIXED_RANDCONFIG are separated by new line
In reply to Oleksii KurochkoHi Oleksii,
Quoted 9 lines · Oleksii Kurochko
Kconfigtool expects each configuration to be on a new line.The current version of the build script puts all of ${EXTRA_FIXED_RANDCONFIG} in a single line and configs are seperated by spaces.
As a result, only the first configuration in ${EXTRA_FIXED_RANDCONFIG} will be used.
There is no need for this patch. If you want the variables to be separated by new lines, just use a '|' symbol after EXTRA_FIXED_RANDCONFIG (see all definitions of EXTRA_XEN_CONFIG).
~Michal
Re: [PATCH v8 2/7] automation: introduce fixed randconfig for RISC-V
In reply to Oleksii KurochkoHi Oleksii,
Quoted 31 lines · Oleksii Kurochko
This patch introduces the file
riscv-fixed-randconfig.yaml, which includes all configurations that should be disabled for randconfig builds.Suggested-by Stefano Stabellini <[email protected]>Signed-off-by Oleksii Kurochko <[email protected]>---
The patch were introduced after discussion in a topic:
https://lore.kernel.org/xen-devel/[email protected]/
---
Changes in V8:
- Nothing changed. Only rebase
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- The patch was introduced in this version of patch series.--- automation/gitlab-ci/build.yaml | 8 ++++---- automation/gitlab-ci/riscv-fixed-randconfig.yaml | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 automation/gitlab-ci/riscv-fixed-randconfig.yamlautomation/gitlab-ci/build.yaml +0
-0
automation/gitlab-ci/build.yaml alpine-3.18-gcc-debug-arm64-boot-cpupools: · line 515
Quoted 4 lines
automation/gitlab-ci/build.yaml +1
-0@@ -512,6 +512,8 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools: CONFIG_BOOT_TIME_CPUPOOLS=y # RISC-V 64 cross-build +include: 'automation/gitlab-ci/riscv-fixed-randconfig.yaml'
I don't think there is a need to create a new file for that. You could define an anchor in build.yaml:
# RISC-V 64 cross-build
.riscv-fixed-randconfig:
variables: &riscv-fixed-randconfig
EXTRA_FIXED_RANDCONFIG: |
CONFIG_COVERAGE=n
CONFIG_EXPERT=y
CONFIG_GRANT_TABLE=n
CONFIG_MEM_ACCESS=n
and reference it in the job:
archlinux-current-gcc-riscv64-randconfig:
extends: .gcc-riscv64-cross-build
variables:
CONTAINER: archlinux:current-riscv64
KBUILD_DEFCONFIG: tiny64_defconfig
RANDCONFIG: y
<<: *riscv-fixed-randconfig
~Michal
Re: [PATCH v8 1/7] automation: ensure values in EXTRA_FIXED_RANDCONFIG are separated by new line
In reply to Michal OrzelQuoted 1 line · Michal Orzel
Hi Oleksii,
Hi Michal,
Quoted 10 lines · Oleksii Kurochko
Quoted 8 lines
Kconfigtool expects each configuration to be on a new line.The current version of the build script puts all of ${EXTRA_FIXED_RANDCONFIG}
in a single line and configs are seperated by spaces.
Quoted 7 lines
Quoted 3 lines
As a result, only the first configuration in
${EXTRA_FIXED_RANDCONFIG} will
be used.There is no need for this patch. If you want the variables to be separated by new lines,
just use a '|' symbol afterEXTRA_FIXED_RANDCONFIG(see all definitions ofEXTRA_XEN_CONFIG).
Thanks a lot. I'll drop this path then.
~ Oleksii
Re: [PATCH v8 2/7] automation: introduce fixed randconfig for RISC-V
In reply to Michal OrzelQuoted 1 line · Michal Orzel
Hi Oleksii,
Hi Michal,
Quoted 55 lines · Oleksii Kurochko
Quoted 37 lines
This patch introduces the file
riscv-fixed-randconfig.yaml, which includes all configurations that should be disabled for randconfig builds.Suggested-by Stefano Stabellini <[email protected]>Signed-off-by Oleksii Kurochko <[email protected]>---
The patch were introduced after discussion in a topic:
https://lore.kernel.org/xen-devel/[email protected]
/
---
Changes in V8:
- Nothing changed. Only rebase
---
Changes in V7:
- Nothing changed. Only rebase
---
Changes in V6:
- The patch was introduced in this version of patch series.
---
automation/gitlab-ci/build.yaml | 8 ++++----automation/gitlab-ci/riscv-fixed-randconfig.yaml| 7 +++++++2 files changed, 11 insertions(+), 4 deletions(-)create mode 100644 automation/gitlab-ci/riscv-fixed-
randconfig.yamlautomation/gitlab- renamed from automation/gitlab-ci/build.yaml +0
-0
ci/build.yaml
index6d2cb18b88..376eb17f9c100644automation/gitlab-ci/build.yaml +0
-0@@ -512,6 +512,8 @@ alpine-3.18-gcc-debug-arm64-boot-cpupools:
CONFIG_BOOT_TIME_CPUPOOLS=yQuoted 2 lines
# RISC-V 64 cross-build
+include: 'automation/gitlab-ci/riscv-fixed-randconfig.yaml'I don't think there is a need to create a new file for that. You could define an anchor in
build.yaml:# RISC-V 64 cross-build
.riscv-fixed-randconfig:
variables: &riscv-fixed-randconfig
EXTRA_FIXED_RANDCONFIG: |
CONFIG_COVERAGE=n
CONFIG_EXPERT=y
CONFIG_GRANT_TABLE=n
CONFIG_MEM_ACCESS=nand reference it in the job:
Quoted 7 lines
archlinux-current-gcc-riscv64-randconfig:
extends: .gcc-riscv64-cross-build
variables:
CONTAINER: archlinux:current-riscv64
KBUILD_DEFCONFIG:tiny64_defconfig
RANDCONFIG: y
<<: *riscv-fixed-randconfig
I've created a new file just for convenience, build.yaml. It is pretty large, and it's not always easy to navigate, especially when you don't remember a specific name.
This is not directly related to this patch, but it seems to me that it would be better to create arch-specific files and include them in build.yaml.
If it would be better not to create a new file, I am okay to drop it and add everything to build.yaml.
Thanks.
~ Oleksii
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
In reply to Oleksii KurochkoQuoted 64 lines · Oleksii Kurochko
xen/include/asm-generic/device.h new file +61
-0@@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DEVICE_H__ +#define __ASM_GENERIC_DEVICE_H__ + +#include <xen/stdbool.h> + +enum device_type +{ +#ifdef CONFIG_HAS_DEVICE_TREE +DEV_DT , +#endif +DEV_PCI +}; + +enum device_class +{ +DEVICE_SERIAL , +DEVICE_IOMMU , +DEVICE_INTERRUPT_CONTROLLER , +DEVICE_PCI_HOSTBRIDGE , +/* Use for error */ +DEVICE_UNKNOWN , +}; + +struct dev_archdata { +#ifdef CONFIG_HAS_PASSTHROUGH +void *iommu;/* IOMMU private data */ +#endif +}; + +/* struct device - The basic device structure */ +struct device +{ +enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE +struct dt_device_node *of_node;/* Used by drivers imported from Linux */ +#endif +struct dev_archdata archdata; +#ifdef CONFIG_HAS_PASSTHROUGH +struct iommu_fwspec *iommu_fwspec;/* per-device IOMMU instance data */ +#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init (struct dt_device_node *dev,enum device_class class, +const void *data);
xen/include/asm-generic/device.h line 71
Quoted 10 lines
xen/include/asm-generic/device.h new file +10
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class (const struct dt_device_node *dev); + +#define DT_DEVICE_START (name_, namestr_, class_) \
I don't think the trailing underscores are needed or helpful here (or in the ACPI counterpart), ...
xen/include/asm-generic/device.h line 75
Quoted 4 lines
xen/include/asm-generic/device.h new file +4
-0+static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_,
... seeing this all it would have taken was to avoid the two words "name" and "class" (by e.g. using "ident" and "cls").
Nevertheless:
Jan
Re: [PATCH v8 3/7] xen/asm-generic: introduce stub header monitor.h
In reply to Oleksii KurochkoHi Oleksii,
Quoted 40 lines · Oleksii Kurochko
The header is shared between several archs so it is moved to asm-generic.
Switch partly Arm and PPC to
asm-generic/monitor.hand onlyarch_monitor_get_capabilities()left inarch-specific/monitor.h.Signed-off-by Oleksii Kurochko <[email protected]>Acked-by Jan Beulich <[email protected]>Acked-by Tamas K Lengyel <[email protected]>---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Drop definition ofarch_monitor_domctl_eventfor PPC.
- definearch_monitor_domctl_eventinasm-generic/monitor.h.
- add "defineHAS_ARCH_MONITOR_DOMCTL_EVENT" inarm/.../monitor.has it has arch specific implementation.
---
Changes in V6:
- Rebase only.
---
Changes in V5:
- Switched partly Arm and PPC to asm-genericmonitor.honlyarch_monitor_get_capabilities()left inarch-specific/monitor.h.
- Updated the commit message.
---
Changes in V4:
- Removed the double blank line.
- Added Acked-by: Jan Beulich <[email protected]>.
- Update the commit message
---
Changes in V3:
- Use forward-declaration of struct domain instead of " #include <xen/sched.h> ".
- Add ' include <xen/errno.h> '
- Drop PPC'smonitor.h.
---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "structxen_domctl_monitor_op;"
- remove one of SPDX tags.
Quoted 3 lines
--- xen/arch/arm/include/asm/monitor.h | 25 +----------- xen/arch/ppc/include/asm/monitor.h | 28 +------------
Looking at MAINTAINERS, monitor.h was covered by "VM EVENT, MEM ACCESS and MONITOR". As you move to ...
Quoted 2 lines
xen/arch/ppc/stubs.c | 8 ---- xen/include/asm-generic/monitor.h | 64 ++++++++++++++++++++++++++++++
... asm-generic/, I believe it will now fall under "THE REST". So I think MAINTAINERS needs to be updated to also cover asm-generic/monitor.h.
Looking at what was already committed, I think asm-generic/vm_event.h should also be added in MAINTAINERS. Can you send a separate patch for that?
Cheers,
Signature · 1 line
Julien Grall
Julien Grall
Acked-byRe: [PATCH v8 3/7] xen/asm-generic: introduce stub header monitor.h
Hi,
Quoted 47 lines · Julien Grall
Hi Oleksii,
Quoted 35 lines · Oleksii Kurochko
The header is shared between several archs so it is moved to asm-generic.
Switch partly Arm and PPC to
asm-generic/monitor.hand onlyarch_monitor_get_capabilities()left inarch-specific/monitor.h.Signed-off-by Oleksii Kurochko <[email protected]>Acked-by Jan Beulich <[email protected]>Acked-by Tamas K Lengyel <[email protected]>---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Drop definition ofarch_monitor_domctl_eventfor PPC.
- definearch_monitor_domctl_eventinasm-generic/monitor.h.
- add "defineHAS_ARCH_MONITOR_DOMCTL_EVENT" inarm/.../monitor.has it has arch specific implementation.
---
Changes in V6:
- Rebase only.
---
Changes in V5:
- Switched partly Arm and PPC to asm-genericmonitor.honlyarch_monitor_get_capabilities()left inarch-specific/monitor.h.
- Updated the commit message.
---
Changes in V4:
- Removed the double blank line.
- Added Acked-by: Jan Beulich <[email protected]>.
- Update the commit message
---
Changes in V3:
- Use forward-declaration of struct domain instead of " #include <xen/sched.h> ".
- Add ' include <xen/errno.h> '
- Drop PPC'smonitor.h.Quoted 8 lines
---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "structxen_domctl_monitor_op;"
- remove one of SPDX tags.
---
xen/arch/arm/include/asm/monitor.h| 25 +-----------xen/arch/ppc/include/asm/monitor.h| 28 +------------
Quoted 8 lines
Looking at
MAINTAINERS,monitor.hwas covered by "VM EVENT, MEM ACCESS and MONITOR". As you move to ...Quoted 2 lines
xen/arch/ppc/stubs.c | 8 ---- xen/include/asm-generic/monitor.h | 64 ++++++++++++++++++++++++++++++
... asm-generic/, I believe it will now fall under "THE REST". So I think
MAINTAINERSneeds to be updated to also coverasm-generic/monitor.h.Looking at what was already committed, I think
asm-generic/vm_event.hshould also be added inMAINTAINERS. Can you send a separate patch for that?
Oh, I just noticed that we have the following entry:
xen/include/*/monitor.h
So the header is already covered. Sorry for the noise.
As the code is falling under the "VM EVENT..." subsystem, then Tamas's acked is technically sufficient for this patch (even for the PPC change).
But just in case you need one for Arm:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v8 4/7] xen/asm-generic: ifdef inclusion of <asm/mem_access.h>
In reply to Oleksii KurochkoHi Oleksii,
Quoted 7 lines · Oleksii Kurochko
ifdefing inclusion of <
asm/mem_access.h> in <xen/mem_access.h> allows to avoid generation of empty <asm/mem_access.h> header for the case when !CONFIG_MEM_ACCESS.For Arm it was explicitly added inclusion of <
asm/mem_access.h> forp2m.candtraps.cbecause they require some functions from <asm/mem_access.h> which aren't available in case of !CONFIG_MEM_ACCESS.
Ideally we should protect the code relying on <asm/mem_access.h>. But that's a separate improvement for the Arm folks to deal with. So:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
In reply to Oleksii KurochkoHi Oleksii,
Quoted 24 lines · Oleksii Kurochko
xen/include/asm-generic/device.h new file +18
-0@@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DEVICE_H__ +#define __ASM_GENERIC_DEVICE_H__ + +#include <xen/stdbool.h> + +enum device_type +{ +#ifdef CONFIG_HAS_DEVICE_TREE +DEV_DT , +#endif +DEV_PCI +}; + +enum device_class +{ +DEVICE_SERIAL , + DEVICE_IOMMU,
xen/include/asm-generic/device.h line 28
Quoted 10 lines
xen/include/asm-generic/device.h new file +10
-0+DEVICE_INTERRUPT_CONTROLLER , +DEVICE_PCI_HOSTBRIDGE , +/* Use for error */ + DEVICE_UNKNOWN, +}; + +struct dev_archdata { +#ifdef CONFIG_HAS_PASSTHROUGH +void *iommu;/* IOMMU private data */ +#endif > +};
It is a bit too late to change, but I thought I would point it if someone wants to send a follow-up. It is a bit odd to have a structure dev_archdata that, if I am not mistaken, is only used ...
xen/include/asm-generic/device.h line 38
Quoted 9 lines
xen/include/asm-generic/device.h new file +9
-0+ +/* struct device - The basic device structure */ +struct device +{ +enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE +struct dt_device_node *of_node;/* Used by drivers imported from Linux */ +#endif +struct dev_archdata archdata;
... in struct device. Looking at the use, I believe this was only introduced to try to keep that SMMU code close to Linux. I would consider to fold the other structure and update dev_archdata() in drivers/passthrough/arm/smmu.c.
Quoted 56 lines
xen/include/asm-generic/device.h new file +56
-0+#ifdef CONFIG_HAS_PASSTHROUGH +struct iommu_fwspec *iommu_fwspec;/* per-device IOMMU instance data */ +#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init (struct dt_device_node *dev,enum device_class class, +const void *data); + +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class (const struct dt_device_node *dev); + +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { +/* Device name */ +const char *name; +/* Device class */ +enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + +/* List of devices supported by this driver */
xen/include/asm-generic/device.h line 104
Quoted 10 lines
xen/include/asm-generic/device.h new file +10
-0+const struct dt_device_match *dt_match; +/* +* Device initialization. +* +* -EAGAIN is used to indicate that device probing is deferred. +*/ +int (*init)(struct dt_device_node *dev,const void *data); + +#endif +};
I am not sure I fully understand why "device_desc" is not protected by CONFIG_HAS_DEVICE_TREE. The structure doesn't mean much when the config is disabled. Can you clarify?
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v8 6/7] xen/arm: switch Arm to use asm-generic/device.h
In reply to Oleksii KurochkoHi Oleksii,
Quoted 35 lines · Oleksii Kurochko
The following changes were done as a result of switching to
asm-generic/device.h:
*DEVICE_GICwas renamed toDEVICE_INTERRUPT_CONTROLLERaccording to definition of enumdevice_classinasm-generic/device.h.
* acpi-related things in Arm code were guarded by #ifdefCONFIG_ACPIas structacpi_device_descwas guarded in asm-generic, also functionsacpi_device_init()was guarded too as they are using structureacpi_device_descinside.
* droparm/include/asm/device.hand update arm/include/asm/Makefile to useasm-generic/device.hinstead.Signed-off-by Oleksii Kurochko <[email protected]>---
Changes in V8:
- update the commit message
---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce genericdevice.h--- xen/arch/arm/device.c | 5 ++ xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic-v2.c | 4 +- xen/arch/arm/gic-v3.c | 6 +- xen/arch/arm/gic.c | 4 +- xen/arch/arm/include/asm/Makefile | 1 + xen/arch/arm/include/asm/device.h | 124 ------------------------------ 7 files changed, 14 insertions(+), 132 deletions(-)delete mode 100644
xen/arch/arm/include/asm/device.hxen/arch/arm/device.c +0
-0
xen/arch/arm/device.c line 22
Quoted 7 lines
xen/arch/arm/device.c +3
-0@@ -16,7 +16,10 @@#include <xen/lib.h> extern const struct device_desc _sdevice[], _edevice[]; + +#ifdef CONFIG_ACPI extern const struct acpi_device_desc _asdevice[], _aedevice[]; +#endif
Can you also update the linker script to protect the following code? I.e
#ifdef CONFIG_ACPI
. = ALIGN(8);
.adev.info : {
_asdevice = .;
*(.adev.info)
_aedevice = .; } :text
#endif
With this change:
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v8 3/7] xen/asm-generic: introduce stub header monitor.h
In reply to Julien GrallHi Julien,
Quoted 77 lines · Julien Grall
Quoted 64 lines
Hi Oleksii,
Quoted 40 lines · Oleksii Kurochko
The header is shared between several archs so it is moved to asm-generic.
Switch partly Arm and PPC to
asm-generic/monitor.hand onlyarch_monitor_get_capabilities()left inarch-specific/monitor.h.Signed-off-by Oleksii Kurochko <[email protected]>Acked-by Jan Beulich <[email protected]>Acked-by Tamas K Lengyel <[email protected]>---
Changes in V8:
- Add Acked-by: Tamas K Lengyel <[email protected]>
---
Changes in V7:
- Drop definition ofarch_monitor_domctl_eventfor PPC.
- definearch_monitor_domctl_eventinasm-generic/monitor.h.
- add "defineHAS_ARCH_MONITOR_DOMCTL_EVENT" inarm/.../monitor.has
it has arch specific implementation.
---
Changes in V6:
- Rebase only.
---
Changes in V5:
- Switched partly Arm and PPC to asm-genericmonitor.honlyarch_monitor_get_capabilities()left in arch-specific/monitor.h.
- Updated the commit message.
---
Changes in V4:
- Removed the double blank line.
- Added Acked-by: Jan Beulich <[email protected]>.
- Update the commit message
---
Changes in V3:
- Use forward-declaration of struct domain instead of " #include
<xen/sched.h> ".
- Add ' include <xen/errno.h> '
- Drop PPC'smonitor.h.Quoted 8 lines
---
Changes in V2:
- remove inclusion of "+#include <public/domctl.h>"
- add "structxen_domctl_monitor_op;"
- remove one of SPDX tags.
---
xen/arch/arm/include/asm/monitor.h| 25 +-----------xen/arch/ppc/include/asm/monitor.h| 28 +------------Looking at
MAINTAINERS,monitor.hwas covered by "VM EVENT, MEM ACCESS
and MONITOR". As you move to ...Quoted 3 lines
xen/arch/ppc/stubs.c | 8 ----
xen/include/asm-generic/monitor.h | 64
++++++++++++++++++++++++++++++... asm-generic/, I believe it will now fall under "THE REST". So I think
MAINTAINERSneeds to be updated to also cover asm-generic/monitor.h.Quoted 5 lines
Looking at what was already committed, I think asm-
generic/vm_event.h
should also be added inMAINTAINERS. Can you send a separate patch for
that?Oh, I just noticed that we have the following entry:
xen/include/*/monitor.hSo the header is already covered. Sorry for the noise.
Quoted 8 lines
As the code is falling under the "VM EVENT..." subsystem, then Tamas's
acked is technically sufficient for this patch (even for the PPC change).But just in case you need one for Arm:
Acked-by Julien Grall <[email protected]>
Thanks.
~ Oleksii
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
In reply to Jan BeulichQuoted 91 lines · Jan Beulich
Quoted 76 lines · Oleksii Kurochko
xen/include/asm-generic/device.h new file +36
-0@@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DEVICE_H__ +#define __ASM_GENERIC_DEVICE_H__ + +#include <xen/stdbool.h> + +enum device_type +{ +#ifdef CONFIG_HAS_DEVICE_TREE + DEV_DT, +#endif + DEV_PCI +}; + +enum device_class +{ + DEVICE_SERIAL, + DEVICE_IOMMU, + DEVICE_INTERRUPT_CONTROLLER, + DEVICE_PCI_HOSTBRIDGE, + /* Use for error */ + DEVICE_UNKNOWN, +}; + +struct dev_archdata { +#ifdef CONFIG_HAS_PASSTHROUGH + void *iommu; /* IOMMU private data */ +#endif +}; + +/* struct device - The basic device structure */ +struct device +{ + enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE + struct dt_device_node *of_node; /* Used by drivers importedfrom Linux */
xen/include/asm-generic/device.h new file +4
-0+#endif + struct dev_archdata archdata; +#ifdef CONFIG_HAS_PASSTHROUGH + struct iommu_fwspec *iommu_fwspec; /* per-device IOMMUinstance data */
xen/include/asm-generic/device.h new file +20
-0+#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init(struct dt_device_node *dev, enum device_classclass,
+ const void *data);xen/include/asm-generic/device.h new file +8
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class(const struct dt_device_node*dev);
xen/include/asm-generic/device.h
Quoted 2 lines
xen/include/asm-generic/device.h new file +2
-0+ +#define DT_DEVICE_START (name_, namestr_, class_) \I don't think the trailing underscores are needed or helpful here (or in the ACPI counterpart), ...
xen/include/asm-generic/device.h line 75
Quoted 4 lines
xen/include/asm-generic/device.h new file +4
-0+static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_,... seeing this all it would have taken was to avoid the two words "name" and "class" (by e.g. using "ident" and "cls").
Quoted 2 lines
Nevertheless:
Acked-by Jan Beulich <[email protected]>
Thanks.
I'll apply your comments in the next patch version.
~ Oleksii
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
In reply to Julien GrallQuoted 44 lines · Julien Grall
Hi Oleksii,
Quoted 25 lines · Oleksii Kurochko
xen/include/asm- renamed from xen/include/asm-generic/device.h +0
-0
generic/device.h
new file mode 100644
index 0000000000..6e56658271xen/include/asm-generic/device.h new file +18
-0@@ -0,0 +1,149 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DEVICE_H__ +#define __ASM_GENERIC_DEVICE_H__ + +#include <xen/stdbool.h> + +enum device_type +{ +#ifdef CONFIG_HAS_DEVICE_TREE + DEV_DT, +#endif + DEV_PCI +}; + +enum device_class +{ + DEVICE_SERIAL, + DEVICE_IOMMU,xen/include/asm-generic/device.h line 28
Quoted 10 lines
xen/include/asm-generic/device.h new file +10
-0+ DEVICE_INTERRUPT_CONTROLLER, + DEVICE_PCI_HOSTBRIDGE, + /* Use for error */ + DEVICE_UNKNOWN, +}; + +struct dev_archdata { +#ifdef CONFIG_HAS_PASSTHROUGH + void *iommu; /* IOMMU private data */ +#endif > +};It is a bit too late to change, but I thought I would point it if someone wants to send a follow-up. It is a bit odd to have a structure
dev_archdatathat, if I am not mistaken, is only used ...
Quoted 15 lines
Quoted 10 lines
xen/include/asm-generic/device.h new file +7
-0+ +/* struct device - The basic device structure */ +struct device +{ + enum device_type type; +#ifdef CONFIG_HAS_DEVICE_TREE + struct dt_device_node *of_node; /* Used by drivers importedfrom Linux */
+#endif
+ structdev_archdataarchdata;... in struct device. Looking at the use, I believe this was only introduced to try to keep that SMMU code close to Linux. I would consider to fold the other structure and update
dev_archdata()indrivers/passthrough/arm/smmu.c.
I can do that in separate patch. struct dev_archdata was left because of drivers/passthrough/arm/smmu.c.
Quoted 68 lines
Quoted 68 lines
+#ifdef
CONFIG_HAS_PASSTHROUGH
+ structiommu_fwspec*iommu_fwspec; /* per-device IOMMU instance data */xen/include/asm-generic/device.h new file +20
-0+#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init(struct dt_device_node *dev, enum device_classclass,
+ const void *data);xen/include/asm-generic/device.h new file +8
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class(const struct dt_device_node*dev);
xen/include/asm-generic/device.h new file +30
-0+ +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { + /* Device name */ + const char *name; + /* Device class */ + enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + + /* List of devices supported by this driver */ + const struct dt_device_match *dt_match; + /* + * Device initialization. + * + * -EAGAIN is used to indicate that device probing isdeferred.
+ */
+ int (*init)(structdt_device_node*dev, const void *data);
Quoted 8 lines
xen/include/asm-generic/device.h line 13
Quoted 3 lines
xen/include/asm-generic/device.h new file +3
-0+ +#endif +};I am not sure I fully understand why "
device_desc" is not protected byCONFIG_HAS_DEVICE_TREE. The structure doesn't mean much when the config
is disabled. Can you clarify?
I thought that one day struct device_desc and acpi_device_desc will be "merged", and so decided just to #ifdef only DEVICE_TREE specific fields.
Another one reason it is if to protect fully struct device_desc then it would be needed more #ifdef in arm/device.c ( for example, device_init() should be all protected then ) what will require to ifdef all calls of device_init(). As an option device_init can can be defined in case when !CONFIG_HAS_DEVICE_TREE as:
int __init device_init(struct dt_device_node *dev, enum device_class class,
const void *data)
{
return -EBADF;}
The similar thing will be needed for device_get_class() in Arm's device.c.
Would it be better to ifdef full struct device_desc ?
~ Oleksii
Re: [PATCH v8 6/7] xen/arm: switch Arm to use asm-generic/device.h
In reply to Julien GrallHi Julien,
Quoted 38 lines · Julien Grall
Hi Oleksii,
Quoted 35 lines · Oleksii Kurochko
The following changes were done as a result of switching to
asm-generic/device.h:
*DEVICE_GICwas renamed toDEVICE_INTERRUPT_CONTROLLERaccording to definition of enumdevice_classinasm-generic/device.h.
* acpi-related things in Arm code were guarded by #ifdefCONFIG_ACPI
as structacpi_device_descwas guarded in asm-generic, also functions
acpi_device_init()was guarded too as they are using structureacpi_device_descinside.
* droparm/include/asm/device.hand update arm/include/asm/Makefile
to useasm-generic/device.hinstead.Signed-off-by Oleksii Kurochko <[email protected]>---
Changes in V8:
- update the commit message
---
Changes in V7:
- newly introduced patch which is based on the previous version of the patch:
[PATCH v6 9/9] xen/asm-generic: introduce genericdevice.h
---
xen/arch/arm/device.c | 5 ++ xen/arch/arm/domain_build.c | 2 +- xen/arch/arm/gic-v2.c | 4 +- xen/arch/arm/gic-v3.c | 6 +- xen/arch/arm/gic.c | 4 +- xen/arch/arm/include/asm/Makefile | 1 +xen/arch/arm/include/asm/device.h| 124 -------------------------
-----7 files changed, 14 insertions(+), 132 deletions(-)delete mode 100644
xen/arch/arm/include/asm/device.h
Quoted 14 lines
Quoted 10 lines
xen/arch/arm/device.c +0
-0@@ -16,7 +16,10 @@ #include <xen/lib.h>
extern const structdevice_desc_sdevice[], _edevice[];xen/arch/arm/device.c +2
-0+ +#ifdef CONFIG_ACPI Quoted 2 lines
extern const struct
acpi_device_desc_asdevice[], _aedevice[]; +#endifCan you also update the linker script to protect the following code?
Sure, I'll update that. Also please look at my comment to the previous patch. Perhaps, it will be needed to update this patch to ifdef device_init() and device_get_class(), and provide stubs for them in case of !CONFIG_HAS_DEVICE_TREE.
Quoted 11 lines
I.e
#ifdef
CONFIG_ACPI
. = ALIGN(8);
.adev.info : {
_asdevice= .;
*(.adev.info)
_aedevice= .;
} :text
#endif
Quoted 3 lines
With this change:
Reviewed-by Julien Grall <[email protected]>
Thanks.
~ Oleksii
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
In reply to OleksiiHi Oleksii,
Quoted 76 lines · Oleksii
Quoted 67 lines · Julien Grall
Quoted 67 lines
+#ifdef
CONFIG_HAS_PASSTHROUGH
+ structiommu_fwspec*iommu_fwspec; /* per-device IOMMU instance data */xen/include/asm-generic/device.h new file +20
-0+#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init(struct dt_device_node *dev, enum device_classclass,
+ const void *data);xen/include/asm-generic/device.h new file +8
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class(const struct dt_device_node*dev);
xen/include/asm-generic/device.h new file +30
-0+ +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { + /* Device name */ + const char *name; + /* Device class */ + enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + + /* List of devices supported by this driver */ + const struct dt_device_match *dt_match; + /* + * Device initialization. + * + * -EAGAIN is used to indicate that device probing isdeferred.
+ */
+ int (*init)(structdt_device_node*dev, const void *data);Quoted 8 lines
xen/include/asm-generic/device.h line 13
Quoted 3 lines
xen/include/asm-generic/device.h new file +3
-0+ +#endif +};I am not sure I fully understand why "
device_desc" is not protected byCONFIG_HAS_DEVICE_TREE. The structure doesn't mean much when the config
is disabled. Can you clarify?
Quoted 3 lines
I thought that one day struct
device_descandacpi_device_descwill be "merged", and so decided just to #ifdef onlyDEVICE_TREEspecific fields.
It might be possible to merge the two if we were using an union for the ACPI/DT specific part. However the majority of the parsing code needs to differ. So I am not convinced there would be any value to merge the two structures.
Quoted 5 lines
Another one reason it is if to protect fully struct
device_descthen it would be needed more #ifdef inarm/device.c( for example,device_init()should be all protected then ) what will require to ifdef all calls ofdevice_init(). As an optiondevice_initcan can be defined in case when !CONFIG_HAS_DEVICE_TREE as:
Quoted 8 lines
int __init device_init(struct dt_device_node *dev, enum device_class class, const void *data) { return -EBADF; }The similar thing will be needed for
device_get_class()in Arm'sdevice.c.
I agree that in theory device_init() & co should be protected with CONFIG_HAS_DEVICE_TREE. However, it is not possible to compile Xen on Arm without the Device-Tree part today. So I don't view adding the #ifdef or any extra stub as necessary today.
This may be useful in the future though. Note this is not a request to modify the patch more than...
Quoted 2 lines
Would it be better to ifdef full struct
device_desc?
.. moving structure within the #ifdef.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
Quoted 84 lines · Oleksii
Quoted 77 lines · Julien Grall
Quoted 68 lines
Quoted 68 lines
+#ifdef
CONFIG_HAS_PASSTHROUGH
+ structiommu_fwspec*iommu_fwspec; /* per-device IOMMU instance data */xen/include/asm-generic/device.h new file +20
-0+#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init(struct dt_device_node *dev, enum device_classclass,
+ const void *data);xen/include/asm-generic/device.h new file +8
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class(const struct dt_device_node*dev);
xen/include/asm-generic/device.h new file +30
-0+ +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { + /* Device name */ + const char *name; + /* Device class */ + enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + + /* List of devices supported by this driver */ + const struct dt_device_match *dt_match; + /* + * Device initialization. + * + * -EAGAIN is used to indicate that device probing isdeferred.
+ */
+ int (*init)(structdt_device_node*dev, const void *data); +Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+#endif +};I am not sure I fully understand why "
device_desc" is not protected
byCONFIG_HAS_DEVICE_TREE. The structure doesn't mean much when the config
is disabled. Can you clarify?Quoted 4 lines
I thought that one day struct
device_descandacpi_device_descwill be
"merged", and so decided just to #ifdef onlyDEVICE_TREEspecific fields.
Quoted 7 lines
It might be possible to merge the two if we were using an union for the
ACPI/DT specific part. However the majority of the parsing code needs to
differ. So I am not convinced there would be any value to merge the two
structures.
In this case, let's have two separate structures.
This is not the current situation, and I don't have a specific example. It appears that all architectures will use Device Tree or ACPI. However, does it make sense to keep 'struct device_desc' more generic to accommodate non-DT or non-ACPI cases?
I am okay with making the following change, but I am just curious if what I mentioned above makes sense at all:
#ifdef CONFIG_HAS_DEVICE_TREE
struct device_desc {
/* Device name */
const char *name;
/* Device class */
enum device_class class;
/* List of devices supported by this driver */
const struct dt_device_match *dt_match;
/*
* Device initialization.
*
* -EAGAIN is used to indicate that device probing is deferred.
*/
int (*init)(struct dt_device_node *dev, const void *data);
};#endif /* CONFIG_HAS_DEVICE_TREE */
Quoted 25 lines
Quoted 11 lines
Another one reason it is if to protect fully struct
device_descthen it
would be needed more #ifdef inarm/device.c( for example,device_init()should be all protected then ) what will require to ifdef
all calls ofdevice_init(). As an optiondevice_initcan can be defined
in case when !CONFIG_HAS_DEVICE_TREE as:
int__initdevice_init(structdt_device_node*dev, enumdevice_classQuoted 8 lines
class,
const void *data)
{
return-EBADF;
}
The similar thing will be needed fordevice_get_class()in Arm'sdevice.c.I agree that in theory
device_init()& co should be protected withCONFIG_HAS_DEVICE_TREE. However, it is not possible to compile Xen on Arm without the Device-Tree part today. So I don't view adding the #ifdef or any extra stub as necessary today.
Quoted 7 lines
This may be useful in the future though. Note this is not a request to
modify the patch more than...Quoted 2 lines
Would it be better to ifdef full struct
device_desc?.. moving structure within the #ifdef.
Well, I'll update the commit message of the next patch that it is not possible to compile Xen without CONFIG_HAS_DEVICE_TREE, so device_init() and Co won't be protected by CONFIG_HAS_DEVICE_TREE.
~ Oleksii
Re: [PATCH v8 5/7] xen/asm-generic: introduce generic device.h
Hi Oleksii,
Quoted 91 lines · Oleksii
Quoted 84 lines · Oleksii
Quoted 77 lines · Julien Grall
Quoted 68 lines
Quoted 68 lines
+#ifdef
CONFIG_HAS_PASSTHROUGH
+ structiommu_fwspec*iommu_fwspec; /* per-device IOMMU instance data */xen/include/asm-generic/device.h new file +20
-0+#endif +}; + +typedef struct device device_t ; + +#ifdef CONFIG_HAS_DEVICE_TREE + +#include <xen/device_tree.h> + +#define dev_is_dt (dev) ((dev)->type == DEV_DT) + +/** +* device_init - Initialize a device +* @dev: device to initialize +* @class: class of the device (serial, network...) +* @data: specific data for initializing the device +* +* Return 0 on success. +*/ +int device_init(struct dt_device_node *dev, enum device_classclass,
+ const void *data);xen/include/asm-generic/device.h new file +8
-0+ +/** +* device_get_type - Get the type of the device +* @dev: device to match +* +* Return the device type on success or DEVICE_ANY on failure +*/ +enum device_class device_get_class(const struct dt_device_node*dev);
xen/include/asm-generic/device.h new file +30
-0+ +#define DT_DEVICE_START (name_, namestr_, class_) \ +static const struct device_desc __dev_desc_##name_ __used \ +__section(".dev.info") = { \ + .name = namestr_, \ + .class = class_, + +#define DT_DEVICE_END \ +}; + +#else /* !CONFIG_HAS_DEVICE_TREE */ +#define dev_is_dt (dev) ((void)(dev), false) +#endif /* CONFIG_HAS_DEVICE_TREE */ + +#define dev_is_pci (dev) ((dev)->type == DEV_PCI) + +struct device_desc { + /* Device name */ + const char *name; + /* Device class */ + enum device_class class; + +#ifdef CONFIG_HAS_DEVICE_TREE + + /* List of devices supported by this driver */ + const struct dt_device_match *dt_match; + /* + * Device initialization. + * + * -EAGAIN is used to indicate that device probing isdeferred.
+ */
+ int (*init)(structdt_device_node*dev, const void *data); +Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+#endif +};I am not sure I fully understand why "
device_desc" is not protected
byCONFIG_HAS_DEVICE_TREE. The structure doesn't mean much when the config
is disabled. Can you clarify?Quoted 4 lines
I thought that one day struct
device_descandacpi_device_descwill be
"merged", and so decided just to #ifdef onlyDEVICE_TREEspecific fields.Quoted 7 lines
It might be possible to merge the two if we were using an union for the
ACPI/DT specific part. However the majority of the parsing code needs to
differ. So I am not convinced there would be any value to merge the two
structures.
Quoted 6 lines
In this case, let's have two separate structures.
This is not the current situation, and I don't have a specific example. It appears that all architectures will use Device Tree or ACPI. However, does it make sense to keep 'struct
device_desc' more generic to accommodate non-DT or non-ACPI cases?
I am not entirely sure what else to say. As I wrote before yes it could be made generic. But right now I don't see any values.
If you have any idea how to share the structure. Then feel free to make a proposal and I will review it.
Cheers,
Signature · 1 line
Julien Grall