* [PATCH 1/4] powerpc: vio: move device attributes into a new ifdef
2024-02-10 0:07 [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
@ 2024-02-10 0:07 ` Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 2/4] powerpc: vio: make vio_bus_type const Ricardo B. Marliere
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ricardo B. Marliere @ 2024-02-10 0:07 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Aneesh Kumar K.V, Naveen N. Rao
Cc: linuxppc-dev, linux-kernel, Greg Kroah-Hartman,
Ricardo B. Marliere
In order to make the distinction of the vio_bus_type variable based on
CONFIG_PPC_SMLPAR more explicit, move the required structs into a new
ifdef block. This is needed in order to make vio_bus_type const and
because the distinction is made explicit, there is no need to set the
fields within the vio_cmo_sysfs_init function.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
arch/powerpc/platforms/pseries/vio.c | 59 +++++++++++++++++++++---------------
1 file changed, 34 insertions(+), 25 deletions(-)
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index 2dc9cbc4bcd8..6c58824190a2 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -991,18 +991,6 @@ static DEVICE_ATTR_RO(cmo_allocated);
static DEVICE_ATTR_RW(cmo_desired);
static DEVICE_ATTR_RW(cmo_allocs_failed);
-static struct attribute *vio_cmo_dev_attrs[] = {
- &dev_attr_name.attr,
- &dev_attr_devspec.attr,
- &dev_attr_modalias.attr,
- &dev_attr_cmo_entitled.attr,
- &dev_attr_cmo_allocated.attr,
- &dev_attr_cmo_desired.attr,
- &dev_attr_cmo_allocs_failed.attr,
- NULL,
-};
-ATTRIBUTE_GROUPS(vio_cmo_dev);
-
/* sysfs bus functions and data structures for CMO */
#define viobus_cmo_rd_attr(name) \
@@ -1062,11 +1050,7 @@ static struct attribute *vio_bus_attrs[] = {
};
ATTRIBUTE_GROUPS(vio_bus);
-static void __init vio_cmo_sysfs_init(void)
-{
- vio_bus_type.dev_groups = vio_cmo_dev_groups;
- vio_bus_type.bus_groups = vio_bus_groups;
-}
+static void __init vio_cmo_sysfs_init(void) { }
#else /* CONFIG_PPC_SMLPAR */
int vio_cmo_entitlement_update(size_t new_entitlement) { return 0; }
void vio_cmo_set_dev_desired(struct vio_dev *viodev, size_t desired) {}
@@ -1584,14 +1568,6 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
}
static DEVICE_ATTR_RO(modalias);
-static struct attribute *vio_dev_attrs[] = {
- &dev_attr_name.attr,
- &dev_attr_devspec.attr,
- &dev_attr_modalias.attr,
- NULL,
-};
-ATTRIBUTE_GROUPS(vio_dev);
-
void vio_unregister_device(struct vio_dev *viodev)
{
device_unregister(&viodev->dev);
@@ -1626,6 +1602,38 @@ static int vio_hotplug(const struct device *dev, struct kobj_uevent_env *env)
return 0;
}
+#ifdef CONFIG_PPC_SMLPAR
+static struct attribute *vio_cmo_dev_attrs[] = {
+ &dev_attr_name.attr,
+ &dev_attr_devspec.attr,
+ &dev_attr_modalias.attr,
+ &dev_attr_cmo_entitled.attr,
+ &dev_attr_cmo_allocated.attr,
+ &dev_attr_cmo_desired.attr,
+ &dev_attr_cmo_allocs_failed.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(vio_cmo_dev);
+
+struct bus_type vio_bus_type = {
+ .name = "vio",
+ .dev_groups = vio_cmo_dev_groups,
+ .bus_groups = vio_bus_groups,
+ .uevent = vio_hotplug,
+ .match = vio_bus_match,
+ .probe = vio_bus_probe,
+ .remove = vio_bus_remove,
+ .shutdown = vio_bus_shutdown,
+};
+#else /* CONFIG_PPC_SMLPAR */
+static struct attribute *vio_dev_attrs[] = {
+ &dev_attr_name.attr,
+ &dev_attr_devspec.attr,
+ &dev_attr_modalias.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(vio_dev);
+
struct bus_type vio_bus_type = {
.name = "vio",
.dev_groups = vio_dev_groups,
@@ -1635,6 +1643,7 @@ struct bus_type vio_bus_type = {
.remove = vio_bus_remove,
.shutdown = vio_bus_shutdown,
};
+#endif /* CONFIG_PPC_SMLPAR */
/**
* vio_get_attribute: - get attribute for virtual device
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 2/4] powerpc: vio: make vio_bus_type const
2024-02-10 0:07 [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 1/4] powerpc: vio: move device attributes into a new ifdef Ricardo B. Marliere
@ 2024-02-10 0:07 ` Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 3/4] powerpc: mpic: make mpic_subsys const Ricardo B. Marliere
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Ricardo B. Marliere @ 2024-02-10 0:07 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Aneesh Kumar K.V, Naveen N. Rao
Cc: linuxppc-dev, linux-kernel, Greg Kroah-Hartman,
Ricardo B. Marliere
Now that the driver core can properly handle constant struct bus_type,
move the vio_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
arch/powerpc/include/asm/vio.h | 2 +-
arch/powerpc/platforms/pseries/vio.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/include/asm/vio.h b/arch/powerpc/include/asm/vio.h
index cc9b787627ad..6faf2a931755 100644
--- a/arch/powerpc/include/asm/vio.h
+++ b/arch/powerpc/include/asm/vio.h
@@ -39,7 +39,7 @@
*/
#define VIO_CMO_MIN_ENT 1562624
-extern struct bus_type vio_bus_type;
+extern const struct bus_type vio_bus_type;
struct iommu_table;
diff --git a/arch/powerpc/platforms/pseries/vio.c b/arch/powerpc/platforms/pseries/vio.c
index 6c58824190a2..90ff85c879bf 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1615,7 +1615,7 @@ static struct attribute *vio_cmo_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(vio_cmo_dev);
-struct bus_type vio_bus_type = {
+const struct bus_type vio_bus_type = {
.name = "vio",
.dev_groups = vio_cmo_dev_groups,
.bus_groups = vio_bus_groups,
@@ -1634,7 +1634,7 @@ static struct attribute *vio_dev_attrs[] = {
};
ATTRIBUTE_GROUPS(vio_dev);
-struct bus_type vio_bus_type = {
+const struct bus_type vio_bus_type = {
.name = "vio",
.dev_groups = vio_dev_groups,
.uevent = vio_hotplug,
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 3/4] powerpc: mpic: make mpic_subsys const
2024-02-10 0:07 [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 1/4] powerpc: vio: move device attributes into a new ifdef Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 2/4] powerpc: vio: make vio_bus_type const Ricardo B. Marliere
@ 2024-02-10 0:07 ` Ricardo B. Marliere
2024-02-10 0:07 ` [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const Ricardo B. Marliere
2024-02-12 19:45 ` [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
4 siblings, 0 replies; 8+ messages in thread
From: Ricardo B. Marliere @ 2024-02-10 0:07 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Aneesh Kumar K.V, Naveen N. Rao
Cc: linuxppc-dev, linux-kernel, Greg Kroah-Hartman,
Ricardo B. Marliere
Now that the driver core can properly handle constant struct bus_type,
move the mpic_subsys variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
arch/powerpc/include/asm/mpic.h | 2 +-
arch/powerpc/sysdev/mpic.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/mpic.h b/arch/powerpc/include/asm/mpic.h
index 58353c5bd3fb..0c03a98986cd 100644
--- a/arch/powerpc/include/asm/mpic.h
+++ b/arch/powerpc/include/asm/mpic.h
@@ -336,7 +336,7 @@ struct mpic
#endif
};
-extern struct bus_type mpic_subsys;
+extern const struct bus_type mpic_subsys;
/*
* MPIC flags (passed to mpic_alloc)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index dabbdd356664..d94cf36b0f65 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -49,7 +49,7 @@
#define DBG(fmt...)
#endif
-struct bus_type mpic_subsys = {
+const struct bus_type mpic_subsys = {
.name = "mpic",
.dev_name = "mpic",
};
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const
2024-02-10 0:07 [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
` (2 preceding siblings ...)
2024-02-10 0:07 ` [PATCH 3/4] powerpc: mpic: make mpic_subsys const Ricardo B. Marliere
@ 2024-02-10 0:07 ` Ricardo B. Marliere
2024-02-10 14:16 ` kernel test robot
2024-02-10 22:56 ` kernel test robot
2024-02-12 19:45 ` [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
4 siblings, 2 replies; 8+ messages in thread
From: Ricardo B. Marliere @ 2024-02-10 0:07 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Aneesh Kumar K.V, Naveen N. Rao
Cc: linuxppc-dev, linux-kernel, Greg Kroah-Hartman,
Ricardo B. Marliere
Now that the driver core can properly handle constant struct bus_type,
move the ibmebus_bus_type variable to be a constant structure as well,
placing it into read-only memory which can not be modified at runtime.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ricardo B. Marliere <ricardo@marliere.net>
---
arch/powerpc/include/asm/ibmebus.h | 2 +-
arch/powerpc/platforms/pseries/ibmebus.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/include/asm/ibmebus.h b/arch/powerpc/include/asm/ibmebus.h
index 6f33253a364a..46fe406f461c 100644
--- a/arch/powerpc/include/asm/ibmebus.h
+++ b/arch/powerpc/include/asm/ibmebus.h
@@ -48,7 +48,7 @@
struct platform_driver;
-extern struct bus_type ibmebus_bus_type;
+extern const struct bus_type ibmebus_bus_type;
int ibmebus_register_driver(struct platform_driver *drv);
void ibmebus_unregister_driver(struct platform_driver *drv);
diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c
index 998e3aff2457..4bb611afaba4 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -432,7 +432,7 @@ static int ibmebus_bus_modalias(const struct device *dev, struct kobj_uevent_env
return of_device_uevent_modalias(dev, env);
}
-struct bus_type ibmebus_bus_type = {
+const struct bus_type ibmebus_bus_type = {
.name = "ibmebus",
.uevent = ibmebus_bus_modalias,
.bus_groups = ibmbus_bus_groups,
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const
2024-02-10 0:07 ` [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const Ricardo B. Marliere
@ 2024-02-10 14:16 ` kernel test robot
2024-02-10 22:56 ` kernel test robot
1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-02-10 14:16 UTC (permalink / raw)
To: Ricardo B. Marliere, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Aneesh Kumar K.V, Naveen N. Rao
Cc: oe-kbuild-all, linuxppc-dev, linux-kernel, Greg Kroah-Hartman,
Ricardo B. Marliere
Hi Ricardo,
kernel test robot noticed the following build errors:
[auto build test ERROR on 41bccc98fb7931d63d03f326a746ac4d429c1dd3]
url: https://github.com/intel-lab-lkp/linux/commits/Ricardo-B-Marliere/powerpc-vio-move-device-attributes-into-a-new-ifdef/20240210-080925
base: 41bccc98fb7931d63d03f326a746ac4d429c1dd3
patch link: https://lore.kernel.org/r/20240209-bus_cleanup-powerpc2-v1-4-79a56dcaebb1%40marliere.net
patch subject: [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20240210/202402102142.uphiKeqw-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240210/202402102142.uphiKeqw-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402102142.uphiKeqw-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/powerpc/platforms/pseries/ibmebus.c:58:17: error: conflicting type qualifiers for 'ibmebus_bus_type'
58 | struct bus_type ibmebus_bus_type;
| ^~~~~~~~~~~~~~~~
In file included from arch/powerpc/platforms/pseries/ibmebus.c:51:
arch/powerpc/include/asm/ibmebus.h:51:30: note: previous declaration of 'ibmebus_bus_type' with type 'const struct bus_type'
51 | extern const struct bus_type ibmebus_bus_type;
| ^~~~~~~~~~~~~~~~
In file included from arch/powerpc/platforms/pseries/ibmebus.c:40:
arch/powerpc/platforms/pseries/ibmebus.c:445:15: error: conflicting type qualifiers for 'ibmebus_bus_type'
445 | EXPORT_SYMBOL(ibmebus_bus_type);
| ^~~~~~~~~~~~~~~~
include/linux/export.h:56:28: note: in definition of macro '__EXPORT_SYMBOL'
56 | extern typeof(sym) sym; \
| ^~~
include/linux/export.h:68:41: note: in expansion of macro '_EXPORT_SYMBOL'
68 | #define EXPORT_SYMBOL(sym) _EXPORT_SYMBOL(sym, "")
| ^~~~~~~~~~~~~~
arch/powerpc/platforms/pseries/ibmebus.c:445:1: note: in expansion of macro 'EXPORT_SYMBOL'
445 | EXPORT_SYMBOL(ibmebus_bus_type);
| ^~~~~~~~~~~~~
arch/powerpc/platforms/pseries/ibmebus.c:435:23: note: previous definition of 'ibmebus_bus_type' with type 'const struct bus_type'
435 | const struct bus_type ibmebus_bus_type = {
| ^~~~~~~~~~~~~~~~
vim +/ibmebus_bus_type +58 arch/powerpc/platforms/pseries/ibmebus.c
d7a301033f1990 arch/powerpc/kernel/ibmebus.c Heiko J Schick 2005-11-16 57
6bccf755ff5324 arch/powerpc/kernel/ibmebus.c Joachim Fenkes 2007-03-09 @58 struct bus_type ibmebus_bus_type;
6bccf755ff5324 arch/powerpc/kernel/ibmebus.c Joachim Fenkes 2007-03-09 59
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const
2024-02-10 0:07 ` [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const Ricardo B. Marliere
2024-02-10 14:16 ` kernel test robot
@ 2024-02-10 22:56 ` kernel test robot
1 sibling, 0 replies; 8+ messages in thread
From: kernel test robot @ 2024-02-10 22:56 UTC (permalink / raw)
To: Ricardo B. Marliere, Michael Ellerman, Nicholas Piggin,
Christophe Leroy, Aneesh Kumar K.V, Naveen N. Rao
Cc: llvm, oe-kbuild-all, linuxppc-dev, linux-kernel,
Greg Kroah-Hartman, Ricardo B. Marliere
Hi Ricardo,
kernel test robot noticed the following build errors:
[auto build test ERROR on 41bccc98fb7931d63d03f326a746ac4d429c1dd3]
url: https://github.com/intel-lab-lkp/linux/commits/Ricardo-B-Marliere/powerpc-vio-move-device-attributes-into-a-new-ifdef/20240210-080925
base: 41bccc98fb7931d63d03f326a746ac4d429c1dd3
patch link: https://lore.kernel.org/r/20240209-bus_cleanup-powerpc2-v1-4-79a56dcaebb1%40marliere.net
patch subject: [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const
config: powerpc-allyesconfig (https://download.01.org/0day-ci/archive/20240211/202402110615.H1X3DSiC-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project ac0577177f053ba7e7016e1b7e44cf5932d00b03)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240211/202402110615.H1X3DSiC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402110615.H1X3DSiC-lkp@intel.com/
All errors (new ones prefixed by >>):
>> arch/powerpc/platforms/pseries/ibmebus.c:58:17: error: redefinition of 'ibmebus_bus_type' with a different type: 'struct bus_type' vs 'const struct bus_type'
58 | struct bus_type ibmebus_bus_type;
| ^
arch/powerpc/include/asm/ibmebus.h:51:30: note: previous declaration is here
51 | extern const struct bus_type ibmebus_bus_type;
| ^
arch/powerpc/platforms/pseries/ibmebus.c:134:17: warning: shift count >= width of type [-Wshift-count-overflow]
134 | return mask == DMA_BIT_MASK(64);
| ^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:77:54: note: expanded from macro 'DMA_BIT_MASK'
77 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
| ^ ~~~
arch/powerpc/platforms/pseries/ibmebus.c:139:9: warning: shift count >= width of type [-Wshift-count-overflow]
139 | return DMA_BIT_MASK(64);
| ^~~~~~~~~~~~~~~~
include/linux/dma-mapping.h:77:54: note: expanded from macro 'DMA_BIT_MASK'
77 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
| ^ ~~~
2 warnings and 1 error generated.
vim +58 arch/powerpc/platforms/pseries/ibmebus.c
d7a301033f1990 arch/powerpc/kernel/ibmebus.c Heiko J Schick 2005-11-16 57
6bccf755ff5324 arch/powerpc/kernel/ibmebus.c Joachim Fenkes 2007-03-09 @58 struct bus_type ibmebus_bus_type;
6bccf755ff5324 arch/powerpc/kernel/ibmebus.c Joachim Fenkes 2007-03-09 59
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] powerpc: struct bus_type cleanup
2024-02-10 0:07 [PATCH 0/4] powerpc: struct bus_type cleanup Ricardo B. Marliere
` (3 preceding siblings ...)
2024-02-10 0:07 ` [PATCH 4/4] powerpc: ibmebus: make ibmebus_bus_type const Ricardo B. Marliere
@ 2024-02-12 19:45 ` Ricardo B. Marliere
4 siblings, 0 replies; 8+ messages in thread
From: Ricardo B. Marliere @ 2024-02-12 19:45 UTC (permalink / raw)
To: Michael Ellerman, Nicholas Piggin, Christophe Leroy,
Aneesh Kumar K.V, Naveen N. Rao
Cc: linuxppc-dev, linux-kernel, Greg Kroah-Hartman
Please disregard this series, I will send a v2.
Thank you,
- Ricardo.
^ permalink raw reply [flat|nested] 8+ messages in thread