Message ID | 20230117165804.18036-1-msuchanek@suse.de (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | of: Make of framebuffer devices unique | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/github-powerpc_kernel_qemu | fail | kernel (mpc885_ads_defconfig, korg-5.5.0) failed at step Build. |
snowpatch_ozlabs/github-powerpc_sparse | fail | sparse (mpc885_ads_defconfig, ubuntu-22.04, ppc64) failed at step Build. |
snowpatch_ozlabs/github-powerpc_clang | fail | 6 of 6 jobs failed. |
On Tue, 17 Jan 2023 17:58:04 +0100, Michal Suchanek wrote: > Since Linux 5.19 this error is observed: > > sysfs: cannot create duplicate filename '/devices/platform/of-display' > > This is because multiple devices with the same name 'of-display' are > created on the same bus. > > Update the code to create numbered device names for the non-boot > disaplay. > > cc: linuxppc-dev@lists.ozlabs.org > References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 > Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") > Reported-by: Erhard F. <erhard_f@mailbox.org> > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > drivers/of/platform.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > Applied, thanks!
On Tue, 17 Jan 2023 17:58:04 +0100 Michal Suchanek <msuchanek@suse.de> wrote: > Since Linux 5.19 this error is observed: > > sysfs: cannot create duplicate filename '/devices/platform/of-display' > > This is because multiple devices with the same name 'of-display' are > created on the same bus. > > Update the code to create numbered device names for the non-boot > disaplay. > > cc: linuxppc-dev@lists.ozlabs.org > References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 > Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") > Reported-by: Erhard F. <erhard_f@mailbox.org> > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > --- > drivers/of/platform.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > index 81c8c227ab6b..f2a5d679a324 100644 > --- a/drivers/of/platform.c > +++ b/drivers/of/platform.c > @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) > if (IS_ENABLED(CONFIG_PPC)) { > struct device_node *boot_display = NULL; > struct platform_device *dev; > + int display_number = 1; > int ret; > > /* Check if we have a MacOS display without a node spec */ > @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) > boot_display = node; > break; > } > + > for_each_node_by_type(node, "display") { > + char *buf[14]; > if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) > continue; > - of_platform_device_create(node, "of-display", NULL); > + ret = snprintf(buf, "of-display-%d", display_number++); > + if (ret >= sizeof(buf)) > + continue; > + of_platform_device_create(node, buf, NULL); > } > > } else { > -- > 2.35.3 > Thank you for the patch Michal! It applies on 6.2-rc4 but I get this build error with my config: # make CALL scripts/checksyscalls.sh CC drivers/of/platform.o drivers/of/platform.c: In function 'of_platform_default_populate_init': drivers/of/platform.c:570:40: error: passing argument 1 of 'snprintf' from incompatible pointer type [-Werror=incompatible-pointer-types] 570 | ret = snprintf(buf, "of-display-%d", display_number++); | ^~~ | | | char ** In file included from ./arch/powerpc/include/asm/page.h:11, from ./arch/powerpc/include/asm/thread_info.h:13, from ./include/linux/thread_info.h:60, from ./arch/powerpc/include/asm/ptrace.h:342, from ./arch/powerpc/include/asm/hw_irq.h:12, from ./arch/powerpc/include/asm/irqflags.h:12, from ./include/linux/irqflags.h:16, from ./include/asm-generic/cmpxchg-local.h:6, from ./arch/powerpc/include/asm/cmpxchg.h:755, from ./arch/powerpc/include/asm/atomic.h:11, from ./include/linux/atomic.h:7, from ./include/linux/mm_types_task.h:13, from ./include/linux/mm_types.h:5, from ./include/linux/buildid.h:5, from ./include/linux/module.h:14, from drivers/of/platform.c:13: ./include/linux/kernel.h:213:20: note: expected 'char *' but argument is of type 'char **' 213 | int snprintf(char *buf, size_t size, const char *fmt, ...); | ~~~~~~^~~ drivers/of/platform.c:570:45: warning: passing argument 2 of 'snprintf' makes integer from pointer without a cast [-Wint-conversion] 570 | ret = snprintf(buf, "of-display-%d", display_number++); | ^~~~~~~~~~~~~~~ | | | char * ./include/linux/kernel.h:213:32: note: expected 'size_t' {aka 'unsigned int'} but argument is of type 'char *' 213 | int snprintf(char *buf, size_t size, const char *fmt, ...); | ~~~~~~~^~~~ drivers/of/platform.c:570:76: warning: passing argument 3 of 'snprintf' makes pointer from integer without a cast [-Wint-conversion] 570 | ret = snprintf(buf, "of-display-%d", display_number++); | ~~~~~~~~~~~~~~^~ | | | int ./include/linux/kernel.h:213:50: note: expected 'const char *' but argument is of type 'int' 213 | int snprintf(char *buf, size_t size, const char *fmt, ...); | ~~~~~~~~~~~~^~~ drivers/of/platform.c:573:57: error: passing argument 2 of 'of_platform_device_create' from incompatible pointer type [-Werror=incompatible-pointer-types] 573 | of_platform_device_create(node, buf, NULL); | ^~~ | | | char ** drivers/of/platform.c:211:57: note: expected 'const char *' but argument is of type 'char **' 211 | const char *bus_id, | ~~~~~~~~~~~~^~~~~~ cc1: some warnings being treated as errors make[3]: *** [scripts/Makefile.build:252: drivers/of/platform.o] Fehler 1 make[2]: *** [scripts/Makefile.build:504: drivers/of] Fehler 2 make[1]: *** [scripts/Makefile.build:504: drivers] Fehler 2 make: *** [Makefile:2008: .] Error 2 Regards, Erhard
On Wed, Jan 18, 2023 at 09:13:05PM +0100, Erhard F. wrote: > On Tue, 17 Jan 2023 17:58:04 +0100 > Michal Suchanek <msuchanek@suse.de> wrote: > > > Since Linux 5.19 this error is observed: > > > > sysfs: cannot create duplicate filename '/devices/platform/of-display' > > > > This is because multiple devices with the same name 'of-display' are > > created on the same bus. > > > > Update the code to create numbered device names for the non-boot > > disaplay. > > > > cc: linuxppc-dev@lists.ozlabs.org > > References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 > > Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") > > Reported-by: Erhard F. <erhard_f@mailbox.org> > > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > --- > > drivers/of/platform.c | 8 +++++++- > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > > index 81c8c227ab6b..f2a5d679a324 100644 > > --- a/drivers/of/platform.c > > +++ b/drivers/of/platform.c > > @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) > > if (IS_ENABLED(CONFIG_PPC)) { > > struct device_node *boot_display = NULL; > > struct platform_device *dev; > > + int display_number = 1; > > int ret; > > > > /* Check if we have a MacOS display without a node spec */ > > @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) > > boot_display = node; > > break; > > } > > + > > for_each_node_by_type(node, "display") { > > + char *buf[14]; > > if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) > > continue; > > - of_platform_device_create(node, "of-display", NULL); > > + ret = snprintf(buf, "of-display-%d", display_number++); > > + if (ret >= sizeof(buf)) > > + continue; > > + of_platform_device_create(node, buf, NULL); > > } > > > > } else { > > -- > > 2.35.3 > > > > Thank you for the patch Michal! > > It applies on 6.2-rc4 but I get this build error with my config: Indeed, it's doubly bad. Where is the kernel test robot when you need it? It should not be that easy to miss this file but clearly it can happen. I will send a fixup. Sorry about the mess. Thanks Michal
Hi Michal, thanks for fixing this issue. But the review time was way too short. Please see my comments below. Am 18.01.23 um 22:46 schrieb Michal Suchánek: > On Wed, Jan 18, 2023 at 09:13:05PM +0100, Erhard F. wrote: >> On Tue, 17 Jan 2023 17:58:04 +0100 >> Michal Suchanek <msuchanek@suse.de> wrote: >> >>> Since Linux 5.19 this error is observed: >>> >>> sysfs: cannot create duplicate filename '/devices/platform/of-display' >>> >>> This is because multiple devices with the same name 'of-display' are >>> created on the same bus. >>> >>> Update the code to create numbered device names for the non-boot >>> disaplay. >>> >>> cc: linuxppc-dev@lists.ozlabs.org >>> References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 >>> Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") >>> Reported-by: Erhard F. <erhard_f@mailbox.org> >>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> >>> Signed-off-by: Michal Suchanek <msuchanek@suse.de> >>> --- >>> drivers/of/platform.c | 8 +++++++- >>> 1 file changed, 7 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c >>> index 81c8c227ab6b..f2a5d679a324 100644 >>> --- a/drivers/of/platform.c >>> +++ b/drivers/of/platform.c >>> @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) >>> if (IS_ENABLED(CONFIG_PPC)) { >>> struct device_node *boot_display = NULL; >>> struct platform_device *dev; >>> + int display_number = 1; >>> int ret; >>> >>> /* Check if we have a MacOS display without a node spec */ >>> @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) >>> boot_display = node; >>> break; >>> } >>> + >>> for_each_node_by_type(node, "display") { >>> + char *buf[14]; >>> if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) >>> continue; >>> - of_platform_device_create(node, "of-display", NULL); >>> + ret = snprintf(buf, "of-display-%d", display_number++); Platform devices use a single dot (.) as separator before the index. Counting starts at zero. See /sys/bus/platform/ for examples. Can we please stick with that scheme? Generated names would then be of-display.0, of-display.1, etc. Best regards Thomas >>> + if (ret >= sizeof(buf)) >>> + continue; >>> + of_platform_device_create(node, buf, NULL); >>> } >>> >>> } else { >>> -- >>> 2.35.3 >>> >> >> Thank you for the patch Michal! >> >> It applies on 6.2-rc4 but I get this build error with my config: > > Indeed, it's doubly bad. > > Where is the kernel test robot when you need it? > > It should not be that easy to miss this file but clearly it can happen. > > I will send a fixup. > > Sorry about the mess. > > Thanks > > Michal
On Thu, Jan 19, 2023 at 09:00:44AM +0100, Thomas Zimmermann wrote: > Hi Michal, > > thanks for fixing this issue. But the review time was way too short. Please > see my comments below. > > Am 18.01.23 um 22:46 schrieb Michal Suchánek: > > On Wed, Jan 18, 2023 at 09:13:05PM +0100, Erhard F. wrote: > > > On Tue, 17 Jan 2023 17:58:04 +0100 > > > Michal Suchanek <msuchanek@suse.de> wrote: > > > > > > > Since Linux 5.19 this error is observed: > > > > > > > > sysfs: cannot create duplicate filename '/devices/platform/of-display' > > > > > > > > This is because multiple devices with the same name 'of-display' are > > > > created on the same bus. > > > > > > > > Update the code to create numbered device names for the non-boot > > > > disaplay. > > > > > > > > cc: linuxppc-dev@lists.ozlabs.org > > > > References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 > > > > Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") > > > > Reported-by: Erhard F. <erhard_f@mailbox.org> > > > > Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> > > > > Signed-off-by: Michal Suchanek <msuchanek@suse.de> > > > > --- > > > > drivers/of/platform.c | 8 +++++++- > > > > 1 file changed, 7 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/drivers/of/platform.c b/drivers/of/platform.c > > > > index 81c8c227ab6b..f2a5d679a324 100644 > > > > --- a/drivers/of/platform.c > > > > +++ b/drivers/of/platform.c > > > > @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) > > > > if (IS_ENABLED(CONFIG_PPC)) { > > > > struct device_node *boot_display = NULL; > > > > struct platform_device *dev; > > > > + int display_number = 1; > > > > int ret; > > > > /* Check if we have a MacOS display without a node spec */ > > > > @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) > > > > boot_display = node; > > > > break; > > > > } > > > > + > > > > for_each_node_by_type(node, "display") { > > > > + char *buf[14]; > > > > if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) > > > > continue; > > > > - of_platform_device_create(node, "of-display", NULL); > > > > + ret = snprintf(buf, "of-display-%d", display_number++); > > Platform devices use a single dot (.) as separator before the index. > Counting starts at zero. See /sys/bus/platform/ for examples. Can we please > stick with that scheme? Generated names would then be of-display.0, > of-display.1, etc. Yes, there was surprisingly no bikeshedding. Do we also want to change the name of the device that did manage to instantiate before? This scheme changes the name only for those that did not in the past, hence "of-display" and "of-display-%d", starting from 1. Sure, replacing '-' with '.' is easy enough, and using the same format for both as well. Thanks Michal > > Best regards > Thomas > > > > > > > + if (ret >= sizeof(buf)) > > > > + continue; > > > > + of_platform_device_create(node, buf, NULL); > > > > } > > > > } else { > > > > -- > > > > 2.35.3 > > > > > > > > > > Thank you for the patch Michal! > > > > > > It applies on 6.2-rc4 but I get this build error with my config: > > > > Indeed, it's doubly bad. > > > > Where is the kernel test robot when you need it? > > > > It should not be that easy to miss this file but clearly it can happen. > > > > I will send a fixup. > > > > Sorry about the mess. > > > > Thanks > > > > Michal > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 Nürnberg, Germany > (HRB 36809, AG Nürnberg) > Geschäftsführer: Ivo Totev
Hi Am 19.01.23 um 10:01 schrieb Michal Suchánek: > On Thu, Jan 19, 2023 at 09:00:44AM +0100, Thomas Zimmermann wrote: >> Hi Michal, >> >> thanks for fixing this issue. But the review time was way too short. Please >> see my comments below. >> >> Am 18.01.23 um 22:46 schrieb Michal Suchánek: >>> On Wed, Jan 18, 2023 at 09:13:05PM +0100, Erhard F. wrote: >>>> On Tue, 17 Jan 2023 17:58:04 +0100 >>>> Michal Suchanek <msuchanek@suse.de> wrote: >>>> >>>>> Since Linux 5.19 this error is observed: >>>>> >>>>> sysfs: cannot create duplicate filename '/devices/platform/of-display' >>>>> >>>>> This is because multiple devices with the same name 'of-display' are >>>>> created on the same bus. >>>>> >>>>> Update the code to create numbered device names for the non-boot >>>>> disaplay. >>>>> >>>>> cc: linuxppc-dev@lists.ozlabs.org >>>>> References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 >>>>> Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") >>>>> Reported-by: Erhard F. <erhard_f@mailbox.org> >>>>> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> >>>>> Signed-off-by: Michal Suchanek <msuchanek@suse.de> >>>>> --- >>>>> drivers/of/platform.c | 8 +++++++- >>>>> 1 file changed, 7 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/drivers/of/platform.c b/drivers/of/platform.c >>>>> index 81c8c227ab6b..f2a5d679a324 100644 >>>>> --- a/drivers/of/platform.c >>>>> +++ b/drivers/of/platform.c >>>>> @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) >>>>> if (IS_ENABLED(CONFIG_PPC)) { >>>>> struct device_node *boot_display = NULL; >>>>> struct platform_device *dev; >>>>> + int display_number = 1; >>>>> int ret; >>>>> /* Check if we have a MacOS display without a node spec */ >>>>> @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) >>>>> boot_display = node; >>>>> break; >>>>> } >>>>> + >>>>> for_each_node_by_type(node, "display") { >>>>> + char *buf[14]; Another issue here: This should simply be buf[14]; not a pointer. Is 14 chars enough for the string plus a full number? >>>>> if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) >>>>> continue; >>>>> - of_platform_device_create(node, "of-display", NULL); >>>>> + ret = snprintf(buf, "of-display-%d", display_number++); The second argument to snprintf() is sizeof(buf); the number of characters in buf. >> >> Platform devices use a single dot (.) as separator before the index. >> Counting starts at zero. See /sys/bus/platform/ for examples. Can we please >> stick with that scheme? Generated names would then be of-display.0, >> of-display.1, etc. > > Yes, there was surprisingly no bikeshedding. > > Do we also want to change the name of the device that did manage to > instantiate before? > > This scheme changes the name only for those that did not in the past, > hence "of-display" and "of-display-%d", starting from 1. I find that very confusing. It is is better to count all devices from 0. I don't expect this to be an issue for userspace. But if necessary, devfs can create softlinks to of-display.0. Best regards Thomas > > Sure, replacing '-' with '.' is easy enough, and using the same format > for both as well. > > Thanks > > Michal > >> >> Best regards >> Thomas >> >> >> >>>>> + if (ret >= sizeof(buf)) >>>>> + continue; >>>>> + of_platform_device_create(node, buf, NULL); >>>>> } >>>>> } else { >>>>> -- >>>>> 2.35.3 >>>>> >>>> >>>> Thank you for the patch Michal! >>>> >>>> It applies on 6.2-rc4 but I get this build error with my config: >>> >>> Indeed, it's doubly bad. >>> >>> Where is the kernel test robot when you need it? >>> >>> It should not be that easy to miss this file but clearly it can happen. >>> >>> I will send a fixup. >>> >>> Sorry about the mess. >>> >>> Thanks >>> >>> Michal >> >> -- >> Thomas Zimmermann >> Graphics Driver Developer >> SUSE Software Solutions Germany GmbH >> Maxfeldstr. 5, 90409 Nürnberg, Germany >> (HRB 36809, AG Nürnberg) >> Geschäftsführer: Ivo Totev > > >
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 81c8c227ab6b..f2a5d679a324 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -525,6 +525,7 @@ static int __init of_platform_default_populate_init(void) if (IS_ENABLED(CONFIG_PPC)) { struct device_node *boot_display = NULL; struct platform_device *dev; + int display_number = 1; int ret; /* Check if we have a MacOS display without a node spec */ @@ -561,10 +562,15 @@ static int __init of_platform_default_populate_init(void) boot_display = node; break; } + for_each_node_by_type(node, "display") { + char *buf[14]; if (!of_get_property(node, "linux,opened", NULL) || node == boot_display) continue; - of_platform_device_create(node, "of-display", NULL); + ret = snprintf(buf, "of-display-%d", display_number++); + if (ret >= sizeof(buf)) + continue; + of_platform_device_create(node, buf, NULL); } } else {
Since Linux 5.19 this error is observed: sysfs: cannot create duplicate filename '/devices/platform/of-display' This is because multiple devices with the same name 'of-display' are created on the same bus. Update the code to create numbered device names for the non-boot disaplay. cc: linuxppc-dev@lists.ozlabs.org References: https://bugzilla.kernel.org/show_bug.cgi?id=216095 Fixes: 52b1b46c39ae ("of: Create platform devices for OF framebuffers") Reported-by: Erhard F. <erhard_f@mailbox.org> Suggested-by: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Michal Suchanek <msuchanek@suse.de> --- drivers/of/platform.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)