From edad432cc47a06ca5c098d3087e2ab95611a3617 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 4 Jul 2026 22:04:37 -0700 Subject: [PATCH 01/10] sh: mach-x3proto: Add software node for GPIO controller We want to convert the legacy gpio-keys platform device on the SH-X3 Prototype board to use software nodes. To do this properly and allow referencing the GPIO controller by address rather than relying on name-based matching (which is being removed from the gpiolib core), we need to associate the GPIO controller with a software node. Introduce x3proto_gpiochip_node, register it, and associate it with x3proto_gpio_chip. Signed-off-by: Dmitry Torokhov Assisted-by: Antigravity:gemini-3.5-flash Reviewed-by: Bartosz Golaszewski Reviewed-by: John Paul Adrian Glaubitz Reviewed-by: Linus Walleij Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/boards/mach-x3proto/gpio.c | 15 ++++++++++++++- arch/sh/include/mach-x3proto/mach/hardware.h | 2 ++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/sh/boards/mach-x3proto/gpio.c b/arch/sh/boards/mach-x3proto/gpio.c index c13d51b29702..a09cafc782b4 100644 --- a/arch/sh/boards/mach-x3proto/gpio.c +++ b/arch/sh/boards/mach-x3proto/gpio.c @@ -18,6 +18,7 @@ #include #include #include +#include #define KEYCTLR 0xb81c0000 #define KEYOUTR 0xb81c0002 @@ -73,6 +74,10 @@ static void x3proto_gpio_irq_handler(struct irq_desc *desc) chip->irq_unmask(data); } +const struct software_node x3proto_gpiochip_node = { + .name = "x3proto-gpio", +}; + struct gpio_chip x3proto_gpio_chip = { .label = "x3proto-gpio", .direction_input = x3proto_gpio_direction_input, @@ -104,9 +109,15 @@ int __init x3proto_gpio_setup(void) if (unlikely(ilsel < 0)) return ilsel; + ret = software_node_register(&x3proto_gpiochip_node); + if (ret) + goto err_gpio; + + x3proto_gpio_chip.fwnode = software_node_fwnode(&x3proto_gpiochip_node); + ret = gpiochip_add_data(&x3proto_gpio_chip, NULL); if (unlikely(ret)) - goto err_gpio; + goto err_swnode; x3proto_irq_domain = irq_domain_create_linear(NULL, NR_BASEBOARD_GPIOS, &x3proto_gpio_irq_ops, NULL); @@ -127,6 +138,8 @@ int __init x3proto_gpio_setup(void) err_irq: gpiochip_remove(&x3proto_gpio_chip); ret = 0; +err_swnode: + software_node_unregister(&x3proto_gpiochip_node); err_gpio: synchronize_irq(ilsel); diff --git a/arch/sh/include/mach-x3proto/mach/hardware.h b/arch/sh/include/mach-x3proto/mach/hardware.h index 57ea4a5cca35..1ee5a404973c 100644 --- a/arch/sh/include/mach-x3proto/mach/hardware.h +++ b/arch/sh/include/mach-x3proto/mach/hardware.h @@ -3,10 +3,12 @@ #define __MACH_X3PROTO_HARDWARE_H struct gpio_chip; +struct software_node; /* arch/sh/boards/mach-x3proto/gpio.c */ int x3proto_gpio_setup(void); extern struct gpio_chip x3proto_gpio_chip; +extern const struct software_node x3proto_gpiochip_node; #define NR_BASEBOARD_GPIOS 16 From f5af65b2f33a23b474656e2c79719b12cf1c69b0 Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Sat, 4 Jul 2026 22:04:38 -0700 Subject: [PATCH 02/10] sh: mach-x3proto: Convert gpio-keys to software nodes Convert the legacy gpio-keys platform device on the SH-X3 Prototype board to use software nodes/properties. This allows us to describe the GPIO keys and their GPIO bindings using software nodes, so that support for platform data can eventually be removed from the gpio-keys driver. Signed-off-by: Dmitry Torokhov Assisted-by: Antigravity:gemini-3.5-flash Reviewed-by: Bartosz Golaszewski Reviewed-by: John Paul Adrian Glaubitz Reviewed-by: Linus Walleij Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/boards/mach-x3proto/setup.c | 165 +++++++++++++--------------- 1 file changed, 78 insertions(+), 87 deletions(-) diff --git a/arch/sh/boards/mach-x3proto/setup.c b/arch/sh/boards/mach-x3proto/setup.c index ca2802d30565..0d9d5982cf0c 100644 --- a/arch/sh/boards/mach-x3proto/setup.c +++ b/arch/sh/boards/mach-x3proto/setup.c @@ -16,8 +16,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -123,87 +123,74 @@ static struct platform_device m66592_usb_peripheral_device = { .resource = m66592_usb_peripheral_resources, }; -static struct gpio_keys_button baseboard_buttons[NR_BASEBOARD_GPIOS] = { - { - .desc = "key44", - .code = KEY_POWER, - .active_low = 1, - .wakeup = 1, - }, { - .desc = "key43", - .code = KEY_SUSPEND, - .active_low = 1, - .wakeup = 1, - }, { - .desc = "key42", - .code = KEY_KATAKANAHIRAGANA, - .active_low = 1, - }, { - .desc = "key41", - .code = KEY_SWITCHVIDEOMODE, - .active_low = 1, - }, { - .desc = "key34", - .code = KEY_F12, - .active_low = 1, - }, { - .desc = "key33", - .code = KEY_F11, - .active_low = 1, - }, { - .desc = "key32", - .code = KEY_F10, - .active_low = 1, - }, { - .desc = "key31", - .code = KEY_F9, - .active_low = 1, - }, { - .desc = "key24", - .code = KEY_F8, - .active_low = 1, - }, { - .desc = "key23", - .code = KEY_F7, - .active_low = 1, - }, { - .desc = "key22", - .code = KEY_F6, - .active_low = 1, - }, { - .desc = "key21", - .code = KEY_F5, - .active_low = 1, - }, { - .desc = "key14", - .code = KEY_F4, - .active_low = 1, - }, { - .desc = "key13", - .code = KEY_F3, - .active_low = 1, - }, { - .desc = "key12", - .code = KEY_F2, - .active_low = 1, - }, { - .desc = "key11", - .code = KEY_F1, - .active_low = 1, - }, +static const struct software_node x3proto_gpio_keys_node = { + .name = "x3proto-gpio-keys", }; -static struct gpio_keys_platform_data baseboard_buttons_data = { - .buttons = baseboard_buttons, - .nbuttons = ARRAY_SIZE(baseboard_buttons), +#define __X3PROTO_KEY(_id, _code, _gpio, ...) \ +static const struct property_entry x3proto_key##_id##_props[] = { \ + PROPERTY_ENTRY_STRING("label", "key" #_id), \ + PROPERTY_ENTRY_U32("linux,code", _code), \ + PROPERTY_ENTRY_GPIO("gpios", &x3proto_gpiochip_node, \ + _gpio, GPIO_ACTIVE_LOW), \ + __VA_ARGS__ \ + { } \ +}; \ +static const struct software_node x3proto_key##_id##_node = { \ + .parent = &x3proto_gpio_keys_node, \ + .properties = x3proto_key##_id##_props, \ +} + +#define X3PROTO_KEY(_id, _code, _gpio) \ + __X3PROTO_KEY(_id, _code, _gpio) + +#define X3PROTO_KEY_WAKEUP(_id, _code, _gpio) \ + __X3PROTO_KEY(_id, _code, _gpio, \ + PROPERTY_ENTRY_BOOL("wakeup-source"), \ + ) + +X3PROTO_KEY_WAKEUP(44, KEY_POWER, 0); +X3PROTO_KEY_WAKEUP(43, KEY_SUSPEND, 1); +X3PROTO_KEY(42, KEY_KATAKANAHIRAGANA, 2); +X3PROTO_KEY(41, KEY_SWITCHVIDEOMODE, 3); +X3PROTO_KEY(34, KEY_F12, 4); +X3PROTO_KEY(33, KEY_F11, 5); +X3PROTO_KEY(32, KEY_F10, 6); +X3PROTO_KEY(31, KEY_F9, 7); +X3PROTO_KEY(24, KEY_F8, 8); +X3PROTO_KEY(23, KEY_F7, 9); +X3PROTO_KEY(22, KEY_F6, 10); +X3PROTO_KEY(21, KEY_F5, 11); +X3PROTO_KEY(14, KEY_F4, 12); +X3PROTO_KEY(13, KEY_F3, 13); +X3PROTO_KEY(12, KEY_F2, 14); +X3PROTO_KEY(11, KEY_F1, 15); + +static const struct software_node *const x3proto_swnodes[] __initconst = { + &x3proto_gpio_keys_node, + &x3proto_key44_node, + &x3proto_key43_node, + &x3proto_key42_node, + &x3proto_key41_node, + &x3proto_key34_node, + &x3proto_key33_node, + &x3proto_key32_node, + &x3proto_key31_node, + &x3proto_key24_node, + &x3proto_key23_node, + &x3proto_key22_node, + &x3proto_key21_node, + &x3proto_key14_node, + &x3proto_key13_node, + &x3proto_key12_node, + &x3proto_key11_node, + NULL }; -static struct platform_device baseboard_buttons_device = { +static const struct platform_device_info x3proto_gpio_keys_device_info __initconst = { .name = "gpio-keys", - .id = -1, - .dev = { - .platform_data = &baseboard_buttons_data, - }, + .id = PLATFORM_DEVID_NONE, + .swnode = &x3proto_gpio_keys_node, }; static struct platform_device *x3proto_devices[] __initdata = { @@ -211,7 +198,6 @@ static struct platform_device *x3proto_devices[] __initdata = { &smc91x_device, &r8a66597_usb_host_device, &m66592_usb_peripheral_device, - &baseboard_buttons_device, }; static void __init x3proto_init_irq(void) @@ -224,7 +210,8 @@ static void __init x3proto_init_irq(void) static int __init x3proto_devices_setup(void) { - int ret, i; + struct platform_device *pd; + int ret; /* * IRLs are only needed for ILSEL mappings, so flip over the INTC @@ -239,11 +226,11 @@ static int __init x3proto_devices_setup(void) if (unlikely(ret)) return ret; - /* - * Propagate dynamic GPIOs for the baseboard button device. - */ - for (i = 0; i < ARRAY_SIZE(baseboard_buttons); i++) - baseboard_buttons[i].gpio = x3proto_gpio_chip.base + i; + ret = software_node_register_node_group(x3proto_swnodes); + if (ret) { + pr_err("Failed to register software nodes: %d\n", ret); + return ret; + } r8a66597_usb_host_resources[1].start = r8a66597_usb_host_resources[1].end = ilsel_enable(ILSEL_USBH_I); @@ -254,8 +241,12 @@ static int __init x3proto_devices_setup(void) smc91x_resources[1].start = smc91x_resources[1].end = ilsel_enable(ILSEL_LAN); - return platform_add_devices(x3proto_devices, - ARRAY_SIZE(x3proto_devices)); + ret = platform_add_devices(x3proto_devices, ARRAY_SIZE(x3proto_devices)); + if (ret) + return ret; + + pd = platform_device_register_full(&x3proto_gpio_keys_device_info); + return PTR_ERR_OR_ZERO(pd); } device_initcall(x3proto_devices_setup); From 980421d4486e4ab8a0be6cbc20573ec28b18846b Mon Sep 17 00:00:00 2001 From: Dmitry Torokhov Date: Mon, 13 Jul 2026 14:41:31 -0700 Subject: [PATCH 03/10] sh: ecovec24: Use static device properties to describe the touchscreen Convert the board to use static device properties instead of platform data to describe the touchscreen, so that support for platform data can be removed from tsc2007 driver (ecovec24 is the last board using this mechanism of describing tsc2007). Device properties do not allow custom board methods, so the method for getting "pen down" state was removed (the driver is capable of working without it). If this functionality is needed proper pin control/gpio support needs to be implemented so that the same pin can serve as an input GPIO and an interrupt. Signed-off-by: Dmitry Torokhov Reviewed-by: Bartosz Golaszewski Reviewed-by: John Paul Adrian Glaubitz Reviewed-by: Linus Walleij Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/boards/mach-ecovec24/setup.c | 38 ++++++++-------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index ca4b4dd1ddef..f662a296a54c 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -589,39 +590,21 @@ static struct platform_device keysc_device = { /* TouchScreen */ #define IRQ0 evt2irq(0x600) -static int ts_get_pendown_state(struct device *dev) -{ - int val = 0; - gpio_free(GPIO_FN_INTC_IRQ0); - gpio_request(GPIO_PTZ0, NULL); - gpio_direction_input(GPIO_PTZ0); +static const struct property_entry tsc2007_properties[] = { + PROPERTY_ENTRY_U32("ti,x-plate-ohms", 180), + { } +}; - val = gpio_get_value(GPIO_PTZ0); - - gpio_free(GPIO_PTZ0); - gpio_request(GPIO_FN_INTC_IRQ0, NULL); - - return val ? 0 : 1; -} - -static int ts_init(void) -{ - gpio_request(GPIO_FN_INTC_IRQ0, NULL); - return 0; -} - -static struct tsc2007_platform_data tsc2007_info = { - .model = 2007, - .x_plate_ohms = 180, - .get_pendown_state = ts_get_pendown_state, - .init_platform_hw = ts_init, +static const struct software_node tsc2007_swnode = { + .name = "tsc2007", + .properties = tsc2007_properties, }; static struct i2c_board_info ts_i2c_clients = { I2C_BOARD_INFO("tsc2007", 0x48), .type = "tsc2007", - .platform_data = &tsc2007_info, .irq = IRQ0, + .swnode = &tsc2007_swnode, }; static struct regulator_consumer_supply cn12_power_consumers[] = @@ -1242,8 +1225,9 @@ static int __init arch_setup(void) gpio_direction_output(GPIO_PTF4, 1); /* enable TouchScreen */ - i2c_register_board_info(0, &ts_i2c_clients, 1); + gpio_request(GPIO_FN_INTC_IRQ0, NULL); irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW); + i2c_register_board_info(0, &ts_i2c_clients, 1); } /* enable CEU0 */ From 642c9b8ee61dd492eb75b347f9e5f0ce6bf24281 Mon Sep 17 00:00:00 2001 From: Florian Fuchs Date: Sat, 11 Jul 2026 02:01:46 +0200 Subject: [PATCH 04/10] sh: Fix built-in DTB build with generic rule Commit 21bcc49974c2 ("sh: Migrate to the generic rule for built-in DTB") selected GENERIC_BUILTIN_DTB and renamed the Kconfig symbols, but left arch/sh/boot/dts/Makefile using the old obj-y form. So convert them as well, to fix the build error when using CONFIG_BUILTIN_DTB. Fixes: 21bcc49974c2 ("sh: Migrate to the generic rule for built-in DTB") Signed-off-by: Florian Fuchs Reviewed-by: John Paul Adrian Glaubitz Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/boot/dts/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/boot/dts/Makefile b/arch/sh/boot/dts/Makefile index d109978a5eb9..16e281b859ae 100644 --- a/arch/sh/boot/dts/Makefile +++ b/arch/sh/boot/dts/Makefile @@ -1,2 +1,2 @@ # SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .dtb.o, $(CONFIG_BUILTIN_DTB_NAME)) +dtb-y += $(addsuffix .dtb, $(CONFIG_BUILTIN_DTB_NAME)) From 8b5dba9ea4a3f5ed994f03d6ca7686c49491b426 Mon Sep 17 00:00:00 2001 From: Florian Fuchs Date: Thu, 16 Jul 2026 18:53:29 +0200 Subject: [PATCH 05/10] sh: uaccess: Require offsettable operands for 64-bit user access The 64-bit __get_user_u64()/__put_user_u64() paths address the memory operand as %T2 (base+4). This base+4 requires an offsettable address, but "m" also allows the indexed mode @(R0,Rn) (e.g. for a variable- indexed array element), which has no displacement field for the +4. Depending on optimization this build fails with "invalid 'asm'" or an ICE in GCC's change_address_1. Require an offsettable memory operand, allowing GCC to reload an unsuitable indexed address into an appropriate form. Fixes: 2d2b308a8b7d ("sh: Implement __get_user_u64() required for 64-bit get_user()") Signed-off-by: Florian Fuchs Reviewed-by: John Paul Adrian Glaubitz Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/include/asm/uaccess_32.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/sh/include/asm/uaccess_32.h b/arch/sh/include/asm/uaccess_32.h index 5d7ddc092afd..cef40414bfb1 100644 --- a/arch/sh/include/asm/uaccess_32.h +++ b/arch/sh/include/asm/uaccess_32.h @@ -92,7 +92,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); }) #else #define __get_user_u64(x, addr, err) \ ({ \ @@ -116,7 +116,7 @@ __asm__ __volatile__( \ ".long 1b + 2, 3b\n\t" \ ".previous" \ :"=&r" (err), "=&r" (x) \ - :"m" (__m(addr)), "i" (-EFAULT), "0" (err)); }) + :"o" (__m(addr)), "i" (-EFAULT), "0" (err)); }) #endif #define __put_user_size(x,ptr,size,retval) \ @@ -196,7 +196,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #else #define __put_user_u64(val,addr,retval) \ @@ -218,7 +218,7 @@ __asm__ __volatile__( \ ".long 1b, 3b\n\t" \ ".previous" \ : "=r" (retval) \ - : "r" (val), "m" (__m(addr)), "i" (-EFAULT), "0" (retval) \ + : "r" (val), "o" (__m(addr)), "i" (-EFAULT), "0" (retval) \ : "memory"); }) #endif From 9b65dcd94222c37febf98127b1ac5452c94a16d0 Mon Sep 17 00:00:00 2001 From: Pengpeng Hou Date: Fri, 14 Aug 2026 15:55:31 +0800 Subject: [PATCH 06/10] sh: defconfig: Enable the current M66592 UDC symbol The M66592 UDC provider is built under CONFIG_USB_M66592. Several SuperH defconfigs still enable the removed CONFIG_USB_GADGET_M66592 symbol. Replace the stale entries with the current provider symbol. Fixes: 193ab2a6070039e7 ("usb: gadget: allow multiple gadgets to be built") Signed-off-by: Pengpeng Hou Assisted-by: Codex:gpt-5 Tested-by: Geert Uytterhoeven # build-tested Reviewed-by: Geert Uytterhoeven Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/configs/migor_defconfig | 2 +- arch/sh/configs/sdk7786_defconfig | 2 +- arch/sh/configs/shx3_defconfig | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/sh/configs/migor_defconfig b/arch/sh/configs/migor_defconfig index 1d9d543eef4c..bde70f3bf857 100644 --- a/arch/sh/configs/migor_defconfig +++ b/arch/sh/configs/migor_defconfig @@ -72,7 +72,7 @@ CONFIG_LOGO=y # CONFIG_LOGO_LINUX_VGA16 is not set # CONFIG_LOGO_LINUX_CLUT224 is not set CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_USB_G_SERIAL=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_RS5C372=y diff --git a/arch/sh/configs/sdk7786_defconfig b/arch/sh/configs/sdk7786_defconfig index d6fa3a422e24..d40be415dcb9 100644 --- a/arch/sh/configs/sdk7786_defconfig +++ b/arch/sh/configs/sdk7786_defconfig @@ -147,7 +147,7 @@ CONFIG_USB_MON=y CONFIG_USB_OHCI_HCD=y CONFIG_USB_STORAGE=y CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_MAX6900=y CONFIG_RTC_DRV_SH=y diff --git a/arch/sh/configs/shx3_defconfig b/arch/sh/configs/shx3_defconfig index 0cb69a0b92cb..d7496ea9a9fc 100644 --- a/arch/sh/configs/shx3_defconfig +++ b/arch/sh/configs/shx3_defconfig @@ -79,7 +79,7 @@ CONFIG_USB=y CONFIG_USB_MON=y CONFIG_USB_R8A66597_HCD=m CONFIG_USB_GADGET=y -CONFIG_USB_GADGET_M66592=y +CONFIG_USB_M66592=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_SH=y CONFIG_UIO=m From 94a219eda3b5fb1d1753a5ecf28b171c8f308a27 Mon Sep 17 00:00:00 2001 From: Karl Mehltretter Date: Sun, 27 Sep 2026 21:13:59 +0200 Subject: [PATCH 07/10] sh: intc: Sort the prio and sense lists after filling them register_intc_controller() sorts d->prio and d->sense right after allocating them, with hw->nr_prio_regs and hw->nr_sense_regs as the element count. The lists hold hw->nr_vectors entries and are only filled later, by intc_register_irq(). On SH7785, sh7785-irq0123 and sh7785-irq4567 have four vectors but the SoC's eleven priority registers, so sort() swaps 88 bytes in a 32 byte kmalloc object at boot. slub_debug=FZPU reports "Right Redzone overwritten" in kmalloc-32, and v6.5 and v6.6 panic in __kmem_cache_alloc_node() while registering sh7785-irq0123. Found with a custom QEMU model of the SH7785LCR. On it, v6.4 sh7785lcr_defconfig boots with SLAB, the defconfig default before v6.5, and hangs before the console is up when built with SLUB. Sort the lists once all vectors are registered, with the number of entries that were added. Fixes: b59f9f9775e6 ("sh: intc: optimize intc IRQ lookup") Signed-off-by: Karl Mehltretter Assisted-by: LLM Cc: stable@vger.kernel.org Tested-by: John Paul Adrian Glaubitz Reviewed-by: John Paul Adrian Glaubitz Reviewed-by: Geert Uytterhoeven Signed-off-by: John Paul Adrian Glaubitz --- drivers/sh/intc/core.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c index aa68fe190865..ffbe60234eef 100644 --- a/drivers/sh/intc/core.c +++ b/drivers/sh/intc/core.c @@ -275,9 +275,6 @@ int __init register_intc_controller(struct intc_desc *desc) k += save_reg(d, k, hw->prio_regs[i].set_reg, smp); k += save_reg(d, k, hw->prio_regs[i].clr_reg, smp); } - - sort(d->prio, hw->nr_prio_regs, sizeof(*d->prio), - intc_handle_int_cmp, NULL); } if (hw->sense_regs) { @@ -287,9 +284,6 @@ int __init register_intc_controller(struct intc_desc *desc) for (i = 0; i < hw->nr_sense_regs; i++) k += save_reg(d, k, hw->sense_regs[i].reg, 0); - - sort(d->sense, hw->nr_sense_regs, sizeof(*d->sense), - intc_handle_int_cmp, NULL); } if (hw->subgroups) @@ -357,6 +351,11 @@ int __init register_intc_controller(struct intc_desc *desc) } } + sort(d->prio, d->nr_prio, sizeof(*d->prio), + intc_handle_int_cmp, NULL); + sort(d->sense, d->nr_sense, sizeof(*d->sense), + intc_handle_int_cmp, NULL); + intc_subgroup_init(desc, d); /* enable bits matching force_enable after registering irqs */ From 3b8386ffc0c33b6b5a6a8e64e1487c1adec57dc9 Mon Sep 17 00:00:00 2001 From: Karl Mehltretter Date: Sun, 4 Oct 2026 20:46:44 +0200 Subject: [PATCH 08/10] sh: sh7785lcr: Register the PCA9564 controller as I2C bus 0 Before commit 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified"), a negative ID was replaced by zero, and I2C bus zero was instantiated. Since that commit, a negative ID is passed verbatim, instantiating an I2C bus with a dynamic number. As SH boards still use i2c_register_board_info(0, ...) to register I2C devices, they rely on the I2C bus being bus zero. The SH7785LCR is the only SH board whose I2C adapter has a negative ID and its PCA9564 controller becomes i2c-1, causing registration of the R2025S/D RTC to fail and hwclock not detecting /dev/rtc0. Set the platform device ID to 0 so that the adapter is registered as bus zero again. Fixes: 44454baa7ca7 ("i2c: Dynamically assign adapter id if it wasn't explictly specified") Signed-off-by: Karl Mehltretter Assisted-by: LLM Tested-by: John Paul Adrian Glaubitz Reviewed-by: John Paul Adrian Glaubitz Reviewed-by: Geert Uytterhoeven Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/boards/board-sh7785lcr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c index 25c4968f0d8b..b93423df582f 100644 --- a/arch/sh/boards/board-sh7785lcr.c +++ b/arch/sh/boards/board-sh7785lcr.c @@ -256,7 +256,7 @@ static struct i2c_pca9564_pf_platform_data i2c_platform_data = { static struct platform_device i2c_device = { .name = "i2c-pca-platform", - .id = -1, + .id = 0, .dev = { .platform_data = &i2c_platform_data, }, From e3ef44e77b40e3cecfb34757ff3c15ecceea0309 Mon Sep 17 00:00:00 2001 From: Runyu Xiao Date: Fri, 9 Oct 2026 12:02:48 +0800 Subject: [PATCH 09/10] sh: maple: Use the matching IRQ cookie when invoking free_irq() The Maple DMA and VBLANK handlers are registered with &maple_unsupported_device as their dev_id. Passing NULL to free_irq() cannot find either action, so the handlers remain registered and the IRQ core warns. Use the same cookie when freeing both handlers on the error paths. Fixes: b3c69e248176 ("maple: more robust device detection.") Signed-off-by: Runyu Xiao Assisted-by: LLM Cc: stable@vger.kernel.org Tested-by: Florian Fuchs Reviewed-By: Florian Fuchs Reviewed-by: John Paul Adrian Glaubitz Signed-off-by: John Paul Adrian Glaubitz --- drivers/sh/maple/maple.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 5585f220e495..7df88e00c20f 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c @@ -863,10 +863,10 @@ static int __init maple_bus_init(void) kmem_cache_destroy(maple_queue_cache); cleanup_bothirqs: - free_irq(HW_EVENT_VSYNC, 0); + free_irq(HW_EVENT_VSYNC, &maple_unsupported_device); cleanup_irq: - free_irq(HW_EVENT_MAPLE_DMA, 0); + free_irq(HW_EVENT_MAPLE_DMA, &maple_unsupported_device); cleanup_dma: free_pages((unsigned long) maple_sendbuf, MAPLE_DMA_PAGES); From f45711b39e03ff5e80b60dcc1fd34b3fc7d3d36c Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Wed, 21 Oct 2026 02:02:50 +0200 Subject: [PATCH 10/10] sh: Select BINFMT_FLAT_NO_DATA_START_OFFSET for !MMU binfmt_flat offsets the in-memory start of the data segment by MAX_SHARED_LIBS words and then aligns it to FLAT_DATA_ALIGN, so FLAT_FLAG_RAM binaries end up with a gap between text and data (commit 2217b9826246 ("binfmt_flat: revert "binfmt_flat: don't offset the data start"")). SH position-independent code finds the GOT with a PC-relative mova of _GLOBAL_OFFSET_TABLE_, which assumes data follows text directly, as elf2flt lays out the image. With the gap, the GOT register points below the real GOT, so every GOT load reads the neighbouring slot and gets a wrong pointer. On a J2 (sh2eb, no MMU) this made userland crash or hang right after start-up. In my case the data was moved up by 0x20 bytes. Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") added CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET for architectures that cannot tolerate such a gap; currently only riscv !MMU selects it. Select it on SH as well when building without an MMU. Tested on a J2 board (Numato Mimas V2, sh2eb, no MMU) with Linux 7.3 and FLAT binaries built with elf2flt: with this change the data segment starts exactly at the end of text and init runs. Without the patch bootup fails with: [ 12.080472] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.123609] Fixing up unaligned userspace access in "init" pid=1 pc=0x(ptrval) ins=0x6583 [ 12.175153] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00007f00 Fixes: 2217b9826246 ("binfmt_flat: revert "binfmt_flat: don't offset the data start"") Signed-off-by: Waldemar Brodkorb Assisted-by: LLM Reviewed-by: John Paul Adrian Glaubitz Signed-off-by: John Paul Adrian Glaubitz --- arch/sh/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig index d60f1d5a94c0..b501153551c0 100644 --- a/arch/sh/Kconfig +++ b/arch/sh/Kconfig @@ -15,6 +15,7 @@ config SUPERH select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_WANT_IPC_PARSE_VERSION select ARCH_NEED_CMPXCHG_1_EMU + select BINFMT_FLAT_NO_DATA_START_OFFSET if !MMU select CPU_NO_EFFICIENT_FFS select DMA_DECLARE_COHERENT select GENERIC_ATOMIC64