* [PATCH AUTOSEL 6.1 07/24] HID: elecom: add support for TrackBall 056E:011C
From: Sasha Levin @ 2023-02-15 20:45 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Takahiro Fujii, Jiri Kosina, Sasha Levin, jikos,
benjamin.tissoires, linux-input
In-Reply-To: <20230215204547.2760761-1-sashal@kernel.org>
From: Takahiro Fujii <fujii@xaxxi.net>
[ Upstream commit 29f316a1d7e0a570be9a47fa283ece53a67cebb7 ]
Make function buttons on ELECOM M-HT1DRBK trackball mouse work. This model
has two devices with different device IDs (010D and 011C). Both of
them misreports the number of buttons as 5 in the report descriptor, even
though they have 8 buttons. hid-elecom overwrites the report to fix them,
but supports only on 010D and does not work on 011C. This patch fixes
011C in the similar way but with specialized position parameters.
In fact, it is sufficient to rewrite only 17th byte (05 -> 08). However I
followed the existing way.
Signed-off-by: Takahiro Fujii <fujii@xaxxi.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/hid-elecom.c | 16 ++++++++++++++--
drivers/hid/hid-ids.h | 3 ++-
drivers/hid/hid-quirks.c | 3 ++-
3 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index e59e9911fc370..4fa45ee77503b 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -12,6 +12,7 @@
* Copyright (c) 2017 Alex Manoussakis <amanou@gnu.org>
* Copyright (c) 2017 Tomasz Kramkowski <tk@the-tk.com>
* Copyright (c) 2020 YOSHIOKA Takuma <lo48576@hard-wi.red>
+ * Copyright (c) 2022 Takahiro Fujii <fujii@xaxxi.net>
*/
/*
@@ -89,7 +90,7 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
case USB_DEVICE_ID_ELECOM_M_DT1URBK:
case USB_DEVICE_ID_ELECOM_M_DT1DRBK:
case USB_DEVICE_ID_ELECOM_M_HT1URBK:
- case USB_DEVICE_ID_ELECOM_M_HT1DRBK:
+ case USB_DEVICE_ID_ELECOM_M_HT1DRBK_010D:
/*
* Report descriptor format:
* 12: button bit count
@@ -99,6 +100,16 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
*/
mouse_button_fixup(hdev, rdesc, *rsize, 12, 30, 14, 20, 8);
break;
+ case USB_DEVICE_ID_ELECOM_M_HT1DRBK_011C:
+ /*
+ * Report descriptor format:
+ * 22: button bit count
+ * 30: padding bit count
+ * 24: button report size
+ * 16: button usage maximum
+ */
+ mouse_button_fixup(hdev, rdesc, *rsize, 22, 30, 24, 16, 8);
+ break;
}
return rdesc;
}
@@ -112,7 +123,8 @@ static const struct hid_device_id elecom_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1URBK) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_010D) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_011C) },
{ }
};
MODULE_DEVICE_TABLE(hid, elecom_devices);
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 0f8c11842a3a5..d01d798ebedca 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -428,7 +428,8 @@
#define USB_DEVICE_ID_ELECOM_M_DT1URBK 0x00fe
#define USB_DEVICE_ID_ELECOM_M_DT1DRBK 0x00ff
#define USB_DEVICE_ID_ELECOM_M_HT1URBK 0x010c
-#define USB_DEVICE_ID_ELECOM_M_HT1DRBK 0x010d
+#define USB_DEVICE_ID_ELECOM_M_HT1DRBK_010D 0x010d
+#define USB_DEVICE_ID_ELECOM_M_HT1DRBK_011C 0x011c
#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34
#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index be3ad02573de8..5bc91f68b3747 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -393,7 +393,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1URBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_DT1DRBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1URBK) },
- { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_010D) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_HT1DRBK_011C) },
#endif
#if IS_ENABLED(CONFIG_HID_ELO)
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
--
2.39.0
^ permalink raw reply related
* Re: [PATCH v4 0/5] HID: use spinlocks to safely schedule led workers
From: Benjamin Tissoires @ 2023-02-15 18:20 UTC (permalink / raw)
To: Pietro Borrello
Cc: Jiri Kosina, Hanno Zulla, Hanno Zulla, Greg Kroah-Hartman,
Cristiano Giuffrida, Bos, H.J., Jakob Koschel, Jiri Kosina,
Roderick Colenbrander, linux-input, linux-kernel
In-Reply-To: <20230125-hid-unregister-leds-v4-0-7860c5763c38@diag.uniroma1.it>
On Feb 12 2023, Pietro Borrello wrote:
> I noticed a recurring pattern is present in multiple hid devices in the
> Linux tree, where the LED controller of a device schedules a work_struct
> to interact with the hardware.
> The work_struct is embedded in the device structure and thus, is freed
> at device removal.
>
> The issue is that a LED worker may be scheduled by a timer concurrently
> with device removal, causing the work_struct to be accessed after having
> been freed.
> I was able to trigger the issue in hid-bigbenff.c and hid-asus.c
> where the work_structs may be scheduled by the LED controller
> while the device is disconnecting, triggering use-after-frees.
> I can attach the reproducer, but it's very simple USB configuration,
> using the /dev/raw-gadget interface with some more USB interactions
> to manage LEDs configuration and pass checks in asus_kbd_init()
> and asus_kbd_get_functions() in case of hid-asus.c.
> I triggered the issue by connecting a device and immediately
> disconnecting it, so that the remove function runs before the LED one
> which remains pending.
>
> I am attaching multiple patches for asus and bigben drivers.
> The proposed patches introduce safe wrappers to schedule the workers
> safely with several spinlocks checks.
>
> I attach the (partial for brevity) ODEBUG dumps:
>
> ```hid-bigbenff.c
> [ 37.803135][ T1170] usb 1-1: USB disconnect, device number 2
> [ 37.827979][ T1170] ODEBUG: free active (active state 0) object
> type: work_struct hint: bigben_worker+0x0/0x860
> [ 37.829634][ T1170] WARNING: CPU: 0 PID: 1170 at
> lib/debugobjects.c:505 debug_check_no_obj_freed+0x43a/0x630
> [ 37.830904][ T1170] Modules linked in:
> [ 37.831413][ T1170] CPU: 0 PID: 1170 Comm: kworker/0:3 Not tainted
> 6.1.0-rc4-dirty #43
> [ 37.832465][ T1170] Hardware name: QEMU Standard PC (i440FX + PIIX,
> 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
> [ 37.833751][ T1170] Workqueue: usb_hub_wq hub_event
> [ 37.834409][ T1170] RIP: 0010:debug_check_no_obj_freed+0x43a/0x630
> [ 37.835218][ T1170] Code: 48 89 ef e8 28 82 58 ff 49 8b 14 24 4c 8b
> 45 00 48 c7 c7 40 5f 09 87 48 c7 c6 60 5b 09 87 89 d9 4d 89 f9 31 c0
> e8 46 25 ef fe <0f> 0b 4c 8b 64 24 20 48 ba 00 00 00 00 00 fc ff df ff
> 05 4f 7c 17
> [ 37.837667][ T1170] RSP: 0018:ffffc900006fee60 EFLAGS: 00010246
> [ 37.838503][ T1170] RAX: 0d2d19ffcded3d00 RBX: 0000000000000000
> RCX: ffff888117fc9b00
> [ 37.839519][ T1170] RDX: 0000000000000000 RSI: 0000000000000000
> RDI: 0000000000000000
> [ 37.840570][ T1170] RBP: ffffffff86e88380 R08: ffffffff8130793b
> R09: fffff520000dfd85
> [ 37.841618][ T1170] R10: fffff520000dfd85 R11: 0000000000000000
> R12: ffffffff87095fb8
> [ 37.842649][ T1170] R13: ffff888117770ad8 R14: ffff888117770acc
> R15: ffffffff852b7420
> [ 37.843728][ T1170] FS: 0000000000000000(0000)
> GS:ffff8881f6600000(0000) knlGS:0000000000000000
> [ 37.844877][ T1170] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 37.845749][ T1170] CR2: 00007f992eaab380 CR3: 000000011834b000
> CR4: 00000000001006f0
> [ 37.846794][ T1170] Call Trace:
> [ 37.847245][ T1170] <TASK>
> [ 37.847643][ T1170] slab_free_freelist_hook+0x89/0x160
> [ 37.848409][ T1170] ? devres_release_all+0x262/0x350
> [ 37.849156][ T1170] __kmem_cache_free+0x71/0x110
> [ 37.849829][ T1170] devres_release_all+0x262/0x350
> [ 37.850478][ T1170] ? devres_release+0x90/0x90
> [ 37.851118][ T1170] device_release_driver_internal+0x5e5/0x8a0
> [ 37.851944][ T1170] bus_remove_device+0x2ea/0x400
> [ 37.852611][ T1170] device_del+0x64f/0xb40
> [ 37.853212][ T1170] ? kill_device+0x150/0x150
> [ 37.853831][ T1170] ? print_irqtrace_events+0x1f0/0x1f0
> [ 37.854564][ T1170] hid_destroy_device+0x66/0x100
> [ 37.855226][ T1170] usbhid_disconnect+0x9a/0xc0
> [ 37.855887][ T1170] usb_unbind_interface+0x1e1/0x890
> ```
>
> ``` hid-asus.c
> [ 77.409878][ T1169] usb 1-1: USB disconnect, device number 2
> [ 77.423606][ T1169] ODEBUG: free active (active state 0) object
> type: work_struct hint: asus_kbd_backlight_work+0x0/0x2c0
> [ 77.425222][ T1169] WARNING: CPU: 0 PID: 1169 at
> lib/debugobjects.c:505 debug_check_no_obj_freed+0x43a/0x630
> [ 77.426599][ T1169] Modules linked in:
> [ 77.427322][ T1169] CPU: 0 PID: 1169 Comm: kworker/0:3 Not tainted
> 6.1.0-rc4-dirty #43
> [ 77.428404][ T1169] Hardware name: QEMU Standard PC (i440FX + PIIX,
> 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
> [ 77.429644][ T1169] Workqueue: usb_hub_wq hub_event
> [ 77.430296][ T1169] RIP: 0010:debug_check_no_obj_freed+0x43a/0x630
> [ 77.431142][ T1169] Code: 48 89 ef e8 28 82 58 ff 49 8b 14 24 4c 8b
> 45 00 48 c7 c7 40 5f 09 87 48 c7 c6 60 5b 09 87 89 d9 4d 89 f9 31 c0
> e8 46 25 ef fe <0f> 0b 4c 8b 64 24 20 48 ba 00 00 00 00 00 fc ff df ff
> 05 4f 7c 17
> [ 77.433691][ T1169] RSP: 0018:ffffc9000069ee60 EFLAGS: 00010246
> [ 77.434470][ T1169] RAX: b85d2b40c12d7600 RBX: 0000000000000000
> RCX: ffff888117a78000
> [ 77.435507][ T1169] RDX: 0000000000000000 RSI: 0000000080000000
> RDI: 0000000000000000
> [ 77.436521][ T1169] RBP: ffffffff86e88380 R08: ffffffff8130793b
> R09: ffffed103ecc4ed6
> [ 77.437582][ T1169] R10: ffffed103ecc4ed6 R11: 0000000000000000
> R12: ffffffff87095fb8
> [ 77.438593][ T1169] R13: ffff88810e348fe0 R14: ffff88810e348fd4
> R15: ffffffff852b5780
> [ 77.439667][ T1169] FS: 0000000000000000(0000)
> GS:ffff8881f6600000(0000) knlGS:0000000000000000
> [ 77.440842][ T1169] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [ 77.441688][ T1169] CR2: 00007ffc05495ff0 CR3: 000000010cdf0000
> CR4: 00000000001006f0
> [ 77.442720][ T1169] Call Trace:
> [ 77.443167][ T1169] <TASK>
> [ 77.443555][ T1169] slab_free_freelist_hook+0x89/0x160
> [ 77.444302][ T1169] ? devres_release_all+0x262/0x350
> [ 77.444990][ T1169] __kmem_cache_free+0x71/0x110
> [ 77.445638][ T1169] devres_release_all+0x262/0x350
> [ 77.446309][ T1169] ? devres_release+0x90/0x90
> [ 77.446978][ T1169] device_release_driver_internal+0x5e5/0x8a0
> [ 77.447748][ T1169] bus_remove_device+0x2ea/0x400
> [ 77.448421][ T1169] device_del+0x64f/0xb40
> [ 77.448976][ T1169] ? kill_device+0x150/0x150
> [ 77.449577][ T1169] ? print_irqtrace_events+0x1f0/0x1f0
> [ 77.450307][ T1169] hid_destroy_device+0x66/0x100
> [ 77.450938][ T1169] usbhid_disconnect+0x9a/0xc0
> ```
>
> Signed-off-by: Pietro Borrello <borrello@diag.uniroma1.it>
> ---
> Changes in v4:
> - Split patches that add spinlock wrt the patches that check scheduling
> - Smaller locked regions
> - Link to v3: https://lore.kernel.org/r/20230125-hid-unregister-leds-v3-0-0a52ac225e00@diag.uniroma1.it
>
> Changes in v3:
> - use spinlocks to prevent workers scheduling
> - drop patches on sony & playstation hid drivers
> - Link to v2: https://lore.kernel.org/r/20230125-hid-unregister-leds-v2-0-689cc62fc878@diag.uniroma1.it
>
> Changes in v2:
> - dualshock4: Clarify UAF
> - dualsense: Clarify UAF
> - dualsense: Unregister multicolor led controller
> - Link to v1: https://lore.kernel.org/r/20230125-hid-unregister-leds-v1-0-9a5192dcef16@diag.uniroma1.it
>
> ---
> Pietro Borrello (5):
> HID: bigben: use spinlock to protect concurrent accesses
> HID: bigben_worker() remove unneeded check on report_field
> HID: bigben: use spinlock to safely schedule workers
> HID: asus: use spinlock to protect concurrent accesses
> HID: asus: use spinlock to safely schedule workers
>
> drivers/hid/hid-asus.c | 37 +++++++++++++++++++++----
> drivers/hid/hid-bigbenff.c | 68 +++++++++++++++++++++++++++++++++++++++++-----
> 2 files changed, 93 insertions(+), 12 deletions(-)
And patches 1-3 applied to hid/hid.git branch for-6.3/bigben
Cheers,
Benjamin
> ---
> base-commit: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
> change-id: 20230125-hid-unregister-leds-4cbf67099e1d
>
> Best regards,
> --
> Pietro Borrello <borrello@diag.uniroma1.it>
>
^ permalink raw reply
* Re: (subset) [PATCH v4 0/5] HID: use spinlocks to safely schedule led workers
From: Benjamin Tissoires @ 2023-02-15 18:18 UTC (permalink / raw)
To: Jiri Kosina, Hanno Zulla, Hanno Zulla, Greg Kroah-Hartman,
Pietro Borrello
Cc: Cristiano Giuffrida, Bos, H.J., Jakob Koschel, Jiri Kosina,
Roderick Colenbrander, linux-input, linux-kernel
In-Reply-To: <20230125-hid-unregister-leds-v4-0-7860c5763c38@diag.uniroma1.it>
On Sun, 12 Feb 2023 18:59:58 +0000, Pietro Borrello wrote:
> I noticed a recurring pattern is present in multiple hid devices in the
> Linux tree, where the LED controller of a device schedules a work_struct
> to interact with the hardware.
> The work_struct is embedded in the device structure and thus, is freed
> at device removal.
>
> The issue is that a LED worker may be scheduled by a timer concurrently
> with device removal, causing the work_struct to be accessed after having
> been freed.
> I was able to trigger the issue in hid-bigbenff.c and hid-asus.c
> where the work_structs may be scheduled by the LED controller
> while the device is disconnecting, triggering use-after-frees.
> I can attach the reproducer, but it's very simple USB configuration,
> using the /dev/raw-gadget interface with some more USB interactions
> to manage LEDs configuration and pass checks in asus_kbd_init()
> and asus_kbd_get_functions() in case of hid-asus.c.
> I triggered the issue by connecting a device and immediately
> disconnecting it, so that the remove function runs before the LED one
> which remains pending.
>
> [...]
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/hid/hid.git (for-6.3/asus), thanks!
[4/5] HID: asus: use spinlock to protect concurrent accesses
https://git.kernel.org/hid/hid/c/315c537068a1
[5/5] HID: asus: use spinlock to safely schedule workers
https://git.kernel.org/hid/hid/c/4ab3a086d10e
Cheers,
--
Benjamin Tissoires <benjamin.tissoires@redhat.com>
^ permalink raw reply
* Re: [PATCH] HID: mcp-2221: prevent UAF in delayed work
From: Benjamin Tissoires @ 2023-02-15 17:15 UTC (permalink / raw)
To: Rishi Gupta, Jiri Kosina, Pietro Borrello, linux-input,
linux-kernel
In-Reply-To: <20230215-wip-mcp2221-v1-1-d7d1da261a5c@redhat.com>
On Feb 15 2023, Benjamin Tissoires via B4 Submission Endpoint wrote:
> From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
> If the device is plugged/unplugged without giving time for mcp_init_work()
> to complete, we might kick in the devm free code path and thus have
> unavailable struct mcp_2221 while in delayed work.
>
> Add a boolean and a spinlock to prevent scheduling the deleyed work if
> we are in the operation of removing the device.
>
> Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
> ---
> Similar to Pietro's series, we can see the pattern in hid-mcp2221,
> except that this time the ledclass is not involved.
>
> Link: https://lore.kernel.org/linux-input/20230125-hid-unregister-leds-v4-5-7860c5763c38@diag.uniroma1.it/
> ---
> drivers/hid/hid-mcp2221.c | 17 ++++++++++++++++-
> 1 file changed, 16 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
> index e61dd039354b..de8b988f4a48 100644
> --- a/drivers/hid/hid-mcp2221.c
> +++ b/drivers/hid/hid-mcp2221.c
> @@ -95,6 +95,8 @@ struct mcp2221 {
> struct mutex lock;
> struct completion wait_in_report;
> struct delayed_work init_work;
> + spinlock_t init_work_lock;
> + bool removing;
> u8 *rxbuf;
> u8 txbuf[64];
> int rxbuf_idx;
> @@ -922,6 +924,14 @@ static void mcp2221_hid_unregister(void *ptr)
> /* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */
> static void mcp2221_remove(struct hid_device *hdev)
> {
> + struct mcp2221 *mcp = hid_get_drvdata(hdev);
> + unsigned long flags;
> +
> + spin_lock_irqsave(&mcp->init_work_lock, flags);
> + mcp->removing = true;
> + spin_unlock_irqrestore(&mcp->init_work_lock, flags);
> +
> + cancel_delayed_work_sync(&mcp->init_work);
Actually, given that the only re-submission of this work is from the
work item itself, I wonder if I really need the boolean and the
spinlock. cancel_delayed_work_sync() might already prevent a
resubmission by itself as it does in cancel_work_sync().
Cheers,
Benjamin
> }
>
> #if IS_REACHABLE(CONFIG_IIO)
> @@ -1040,6 +1050,7 @@ static void mcp_init_work(struct work_struct *work)
> struct mcp2221_iio *data;
> static int retries = 5;
> int ret, num_channels;
> + unsigned long flags;
>
> hid_hw_power(mcp->hdev, PM_HINT_FULLON);
> mutex_lock(&mcp->lock);
> @@ -1090,7 +1101,10 @@ static void mcp_init_work(struct work_struct *work)
> return;
>
> /* Device is not ready to read SRAM or FLASH data, try again */
> - schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100));
> + spin_lock_irqsave(&mcp->init_work_lock, flags);
> + if (!mcp->removing)
> + schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100));
> + spin_unlock_irqrestore(&mcp->init_work_lock, flags);
> }
> #endif
>
> @@ -1131,6 +1145,7 @@ static int mcp2221_probe(struct hid_device *hdev,
> }
>
> mutex_init(&mcp->lock);
> + spin_lock_init(&mcp->init_work_lock);
> init_completion(&mcp->wait_in_report);
> hid_set_drvdata(hdev, mcp);
> mcp->hdev = hdev;
>
> ---
> base-commit: d883fd110dc17308a1506c5bf17e00ce9fe7b2a2
> change-id: 20230215-wip-mcp2221-979d4115efb5
>
> Best regards,
> --
> Benjamin Tissoires <benjamin.tissoires@redhat.com>
>
^ permalink raw reply
* [PATCH] HID: mcp-2221: prevent UAF in delayed work
From: Benjamin Tissoires via B4 Submission Endpoint @ 2023-02-15 16:48 UTC (permalink / raw)
To: Rishi Gupta, Jiri Kosina, Pietro Borrello
Cc: linux-input, linux-kernel, Benjamin Tissoires
From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
If the device is plugged/unplugged without giving time for mcp_init_work()
to complete, we might kick in the devm free code path and thus have
unavailable struct mcp_2221 while in delayed work.
Add a boolean and a spinlock to prevent scheduling the deleyed work if
we are in the operation of removing the device.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
Similar to Pietro's series, we can see the pattern in hid-mcp2221,
except that this time the ledclass is not involved.
Link: https://lore.kernel.org/linux-input/20230125-hid-unregister-leds-v4-5-7860c5763c38@diag.uniroma1.it/
---
drivers/hid/hid-mcp2221.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/drivers/hid/hid-mcp2221.c b/drivers/hid/hid-mcp2221.c
index e61dd039354b..de8b988f4a48 100644
--- a/drivers/hid/hid-mcp2221.c
+++ b/drivers/hid/hid-mcp2221.c
@@ -95,6 +95,8 @@ struct mcp2221 {
struct mutex lock;
struct completion wait_in_report;
struct delayed_work init_work;
+ spinlock_t init_work_lock;
+ bool removing;
u8 *rxbuf;
u8 txbuf[64];
int rxbuf_idx;
@@ -922,6 +924,14 @@ static void mcp2221_hid_unregister(void *ptr)
/* This is needed to be sure hid_hw_stop() isn't called twice by the subsystem */
static void mcp2221_remove(struct hid_device *hdev)
{
+ struct mcp2221 *mcp = hid_get_drvdata(hdev);
+ unsigned long flags;
+
+ spin_lock_irqsave(&mcp->init_work_lock, flags);
+ mcp->removing = true;
+ spin_unlock_irqrestore(&mcp->init_work_lock, flags);
+
+ cancel_delayed_work_sync(&mcp->init_work);
}
#if IS_REACHABLE(CONFIG_IIO)
@@ -1040,6 +1050,7 @@ static void mcp_init_work(struct work_struct *work)
struct mcp2221_iio *data;
static int retries = 5;
int ret, num_channels;
+ unsigned long flags;
hid_hw_power(mcp->hdev, PM_HINT_FULLON);
mutex_lock(&mcp->lock);
@@ -1090,7 +1101,10 @@ static void mcp_init_work(struct work_struct *work)
return;
/* Device is not ready to read SRAM or FLASH data, try again */
- schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100));
+ spin_lock_irqsave(&mcp->init_work_lock, flags);
+ if (!mcp->removing)
+ schedule_delayed_work(&mcp->init_work, msecs_to_jiffies(100));
+ spin_unlock_irqrestore(&mcp->init_work_lock, flags);
}
#endif
@@ -1131,6 +1145,7 @@ static int mcp2221_probe(struct hid_device *hdev,
}
mutex_init(&mcp->lock);
+ spin_lock_init(&mcp->init_work_lock);
init_completion(&mcp->wait_in_report);
hid_set_drvdata(hdev, mcp);
mcp->hdev = hdev;
---
base-commit: d883fd110dc17308a1506c5bf17e00ce9fe7b2a2
change-id: 20230215-wip-mcp2221-979d4115efb5
Best regards,
--
Benjamin Tissoires <benjamin.tissoires@redhat.com>
^ permalink raw reply related
* Re: [PATCH v4 00/18] gpiolib cleanups
From: Andy Shevchenko @ 2023-02-15 15:59 UTC (permalink / raw)
To: Bartosz Golaszewski
Cc: Arnd Bergmann, Linus Walleij, Bartosz Golaszewski, Tony Lindgren,
Thomas Gleixner, Krzysztof Kozlowski, Geert Uytterhoeven,
Michael Ellerman, Christophe Leroy, Vincenzo Palazzo,
Devarsh Thakkar, Michael Walle, Dmitry Torokhov, Dipen Patel,
Thierry Reding, Stefan Schmidt, Miquel Raynal, Lee Jones,
linux-gpio, linux-doc, linux-kernel, linux-doc-tw-discuss,
linux-arm-kernel, linux-omap, linux-samsung-soc, linux-m68k,
linuxppc-dev, linux-sh, linux-acpi, linux-tegra, linux-input,
linux-media, linux-wpan, netdev, linux-wireless,
brcm80211-dev-list.pdl, SHA-cyfmac-dev-list, linux-arch,
devicetree, Jonathan Corbet, Alex Shi, Yanteng Si, Hu Haowen,
Russell King, Aaro Koskinen, Janusz Krzysztofik, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
Keerthy, Mika Westerberg, Thierry Reding, Jonathan Hunter,
Mauro Carvalho Chehab, Alexander Aring, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Arend van Spriel,
Franky Lin, Hante Meuleman, Kalle Valo, Qiang Zhao, Li Yang,
Rob Herring, Frank Rowand
In-Reply-To: <CAMRc=MdsCZKh12QcqdWk+Zht5UDpA_G1+rx6+_3dzwjDYe6L+Q@mail.gmail.com>
On Wed, Feb 15, 2023 at 04:52:29PM +0100, Bartosz Golaszewski wrote:
> On Wed, Feb 8, 2023 at 6:34 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > These are some older patches Arnd did last year, rebased to
> > linux-next-20230208. On top there are Andy's patches regarding
> > similar topic. The series starts with Linus Walleij's patches.
> >
> > The main goal is to remove some of the legacy bits of the gpiolib
> > interfaces, where the corner cases are easily avoided or replaced
> > with gpio descriptor based interfaces.
> >
> > The idea is to get an immutable branch and route the whole series
> > via GPIO tree.
>
> Andy,
>
> looks like this series has all the acks it needs but I decided to not
> send it in the upcoming merge window, I'd prefer it gets some time in
> next so I'll let it sit until the next release cycle.
Ah, I forgot to mention that this is for the next cycle (v6.4).
Hence it's fine. (Moreover it's based on Linux Next, so it will
fail compilation in any certain tree except that one.)
I will create an immutable branch after v6.3-rc1 is out.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v4 00/18] gpiolib cleanups
From: Bartosz Golaszewski @ 2023-02-15 15:52 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Arnd Bergmann, Linus Walleij, Bartosz Golaszewski, Tony Lindgren,
Thomas Gleixner, Krzysztof Kozlowski, Geert Uytterhoeven,
Michael Ellerman, Christophe Leroy, Vincenzo Palazzo,
Devarsh Thakkar, Michael Walle, Dmitry Torokhov, Dipen Patel,
Thierry Reding, Stefan Schmidt, Miquel Raynal, Lee Jones,
linux-gpio, linux-doc, linux-kernel, linux-doc-tw-discuss,
linux-arm-kernel, linux-omap, linux-samsung-soc, linux-m68k,
linuxppc-dev, linux-sh, linux-acpi, linux-tegra, linux-input,
linux-media, linux-wpan, netdev, linux-wireless,
brcm80211-dev-list.pdl, SHA-cyfmac-dev-list, linux-arch,
devicetree, Jonathan Corbet, Alex Shi, Yanteng Si, Hu Haowen,
Russell King, Aaro Koskinen, Janusz Krzysztofik, Andrew Lunn,
Sebastian Hesselbarth, Gregory Clement, Alim Akhtar,
Nicholas Piggin, Yoshinori Sato, Rich Felker, Mun Yew Tham,
Keerthy, Mika Westerberg, Thierry Reding, Jonathan Hunter,
Mauro Carvalho Chehab, Alexander Aring, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Arend van Spriel,
Franky Lin, Hante Meuleman, Kalle Valo, Qiang Zhao, Li Yang,
Rob Herring, Frank Rowand
In-Reply-To: <20230208173343.37582-1-andriy.shevchenko@linux.intel.com>
On Wed, Feb 8, 2023 at 6:34 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> These are some older patches Arnd did last year, rebased to
> linux-next-20230208. On top there are Andy's patches regarding
> similar topic. The series starts with Linus Walleij's patches.
>
> The main goal is to remove some of the legacy bits of the gpiolib
> interfaces, where the corner cases are easily avoided or replaced
> with gpio descriptor based interfaces.
>
> The idea is to get an immutable branch and route the whole series
> via GPIO tree.
>
Andy,
looks like this series has all the acks it needs but I decided to not
send it in the upcoming merge window, I'd prefer it gets some time in
next so I'll let it sit until the next release cycle.
Bart
^ permalink raw reply
* Re: [PATCH v3 1/2] HID: logitech-hidpp: Retry commands when device is busy
From: Benjamin Tissoires @ 2023-02-15 13:50 UTC (permalink / raw)
To: linux-input, Bastien Nocera
Cc: linux-kernel, Jiri Kosina, Peter F . Patel-Schneider,
Filipe Laíns, Nestor Lopez Casado
In-Reply-To: <20230209154916.462158-1-hadess@hadess.net>
On Thu, 09 Feb 2023 16:49:15 +0100, Bastien Nocera wrote:
> Handle the busy error coming from the device or receiver. The
> documentation says a busy error can be returned when:
> "
> Device (or receiver) cannot answer immediately to this request
> for any reason i.e:
> - already processing a request from the same or another SW
> - pipe full
> "
>
> [...]
Applied to hid/hid.git (for-6.3/logitech), thanks!
[1/2] HID: logitech-hidpp: Retry commands when device is busy
https://git.kernel.org/hid/hid/c/586e8fede795
[2/2] HID: logitech-hidpp: Add myself to authors
https://git.kernel.org/hid/hid/c/1b136aeb3c4a
Cheers,
--
Benjamin Tissoires <benjamin.tissoires@redhat.com>
^ permalink raw reply
* [PATCH v5 3/3] arm64: dts: imx93: Add the bbnsm dts node
From: Jacky Bai @ 2023-02-15 2:41 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com>
Add the bbnsm node for RTC & ON/OFF button support
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
---
- v5 changes: no
- v4 changes:
- update the compatible string to align with binding file
- v3 changes:
- remove 'nxp,bbnsm-regmap' property to align with binding doc
- v2 changes:
- update the regmap property to align with binding doc
---
arch/arm64/boot/dts/freescale/imx93.dtsi | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi
index 2076f9c9983a..e772c136e895 100644
--- a/arch/arm64/boot/dts/freescale/imx93.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
@@ -243,6 +243,22 @@ iomuxc: pinctrl@443c0000 {
status = "okay";
};
+ bbnsm: bbnsm@44440000 {
+ compatible = "nxp,imx93-bbnsm", "syscon", "simple-mfd";
+ reg = <0x44440000 0x10000>;
+
+ bbnsm_rtc: rtc {
+ compatible = "nxp,imx93-bbnsm-rtc";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ };
+
+ bbnsm_pwrkey: pwrkey {
+ compatible = "nxp,imx93-bbnsm-pwrkey";
+ interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+ linux,code = <KEY_POWER>;
+ };
+ };
+
clk: clock-controller@44450000 {
compatible = "fsl,imx93-ccm";
reg = <0x44450000 0x10000>;
--
2.34.1
^ permalink raw reply related
* [PATCH v5 2/3] rtc: bbnsm: Add the bbnsm rtc support
From: Jacky Bai @ 2023-02-15 2:41 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com>
The BBNSM module includes a real time counter with alarm.
Add a RTC driver for this function.
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
- v5 changes: no
- v4 changes:
- update the compatible string to align with binding file
- v3 changes:
- get the regmap directly from parent node
- remove unnecessary dev_err log print
- v2 changes:
- sort the header file alphabetically
- rename the file to add 'nxp' prefix
- refine bbnsm_rtc_irq_handler function, remove the unnecessary
event variable
- add rtc enable check in .read_time, remove rtc enable in probe function
- remove unnecessary dev_err log in probe function
---
drivers/rtc/Kconfig | 12 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-nxp-bbnsm.c | 226 ++++++++++++++++++++++++++++++++++++
3 files changed, 239 insertions(+)
create mode 100644 drivers/rtc/rtc-nxp-bbnsm.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 2ba72de0fa47..13c9c57aab73 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1773,6 +1773,18 @@ config RTC_DRV_SNVS
This driver can also be built as a module, if so, the module
will be called "rtc-snvs".
+config RTC_DRV_BBNSM
+ tristate "NXP BBNSM RTC support"
+ select REGMAP_MMIO
+ depends on ARCH_MXC || COMPILE_TEST
+ depends on HAS_IOMEM
+ depends on OF
+ help
+ If you say yes here you get support for the NXP BBNSM RTC module.
+
+ This driver can also be built as a module, if so, the module
+ will be called "rtc-bbnsm".
+
config RTC_DRV_IMX_SC
depends on IMX_SCU
depends on HAVE_ARM_SMCCC
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 59eb30289335..ea445d1ebb17 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -33,6 +33,7 @@ obj-$(CONFIG_RTC_DRV_ASPEED) += rtc-aspeed.o
obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o
obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o
+obj-$(CONFIG_RTC_DRV_BBNSM) += rtc-nxp-bbnsm.o
obj-$(CONFIG_RTC_DRV_BD70528) += rtc-bd70528.o
obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o
obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o
diff --git a/drivers/rtc/rtc-nxp-bbnsm.c b/drivers/rtc/rtc-nxp-bbnsm.c
new file mode 100644
index 000000000000..1009388b635e
--- /dev/null
+++ b/drivers/rtc/rtc-nxp-bbnsm.c
@@ -0,0 +1,226 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2022 NXP.
+
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/regmap.h>
+#include <linux/rtc.h>
+
+#define BBNSM_CTRL 0x8
+#define BBNSM_INT_EN 0x10
+#define BBNSM_EVENTS 0x14
+#define BBNSM_RTC_LS 0x40
+#define BBNSM_RTC_MS 0x44
+#define BBNSM_TA 0x50
+
+#define RTC_EN 0x2
+#define RTC_EN_MSK 0x3
+#define TA_EN (0x2 << 2)
+#define TA_DIS (0x1 << 2)
+#define TA_EN_MSK (0x3 << 2)
+#define RTC_INT_EN 0x2
+#define TA_INT_EN (0x2 << 2)
+
+#define BBNSM_EVENT_TA (0x2 << 2)
+
+#define CNTR_TO_SECS_SH 15
+
+struct bbnsm_rtc {
+ struct rtc_device *rtc;
+ struct regmap *regmap;
+ int irq;
+ struct clk *clk;
+};
+
+static u32 bbnsm_read_counter(struct bbnsm_rtc *bbnsm)
+{
+ u32 rtc_msb, rtc_lsb;
+ unsigned int timeout = 100;
+ u32 time;
+ u32 tmp = 0;
+
+ do {
+ time = tmp;
+ /* read the msb */
+ regmap_read(bbnsm->regmap, BBNSM_RTC_MS, &rtc_msb);
+ /* read the lsb */
+ regmap_read(bbnsm->regmap, BBNSM_RTC_LS, &rtc_lsb);
+ /* convert to seconds */
+ tmp = (rtc_msb << 17) | (rtc_lsb >> 15);
+ } while (tmp != time && --timeout);
+
+ return time;
+}
+
+static int bbnsm_rtc_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+ unsigned long time;
+ u32 val;
+
+ regmap_read(bbnsm->regmap, BBNSM_CTRL, &val);
+ if ((val & RTC_EN_MSK) != RTC_EN)
+ return -EINVAL;
+
+ time = bbnsm_read_counter(bbnsm);
+ rtc_time64_to_tm(time, tm);
+
+ return 0;
+}
+
+static int bbnsm_rtc_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+ unsigned long time = rtc_tm_to_time64(tm);
+
+ /* disable the RTC first */
+ regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, 0);
+
+ /* write the 32bit sec time to 47 bit timer counter, leaving 15 LSBs blank */
+ regmap_write(bbnsm->regmap, BBNSM_RTC_LS, time << CNTR_TO_SECS_SH);
+ regmap_write(bbnsm->regmap, BBNSM_RTC_MS, time >> (32 - CNTR_TO_SECS_SH));
+
+ /* Enable the RTC again */
+ regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, RTC_EN_MSK, RTC_EN);
+
+ return 0;
+}
+
+static int bbnsm_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+ u32 bbnsm_events, bbnsm_ta;
+
+ regmap_read(bbnsm->regmap, BBNSM_TA, &bbnsm_ta);
+ rtc_time64_to_tm(bbnsm_ta, &alrm->time);
+
+ regmap_read(bbnsm->regmap, BBNSM_EVENTS, &bbnsm_events);
+ alrm->pending = (bbnsm_events & BBNSM_EVENT_TA) ? 1 : 0;
+
+ return 0;
+}
+
+static int bbnsm_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
+{
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+
+ /* enable the alarm event */
+ regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN_MSK, enable ? TA_EN : TA_DIS);
+ /* enable the alarm interrupt */
+ regmap_update_bits(bbnsm->regmap, BBNSM_INT_EN, TA_EN_MSK, enable ? TA_EN : TA_DIS);
+
+ return 0;
+}
+
+static int bbnsm_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
+{
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+ unsigned long time = rtc_tm_to_time64(&alrm->time);
+
+ /* disable the alarm */
+ regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, TA_EN, TA_EN);
+
+ /* write the seconds to TA */
+ regmap_write(bbnsm->regmap, BBNSM_TA, time);
+
+ return bbnsm_rtc_alarm_irq_enable(dev, alrm->enabled);
+}
+
+static const struct rtc_class_ops bbnsm_rtc_ops = {
+ .read_time = bbnsm_rtc_read_time,
+ .set_time = bbnsm_rtc_set_time,
+ .read_alarm = bbnsm_rtc_read_alarm,
+ .set_alarm = bbnsm_rtc_set_alarm,
+ .alarm_irq_enable = bbnsm_rtc_alarm_irq_enable,
+};
+
+static irqreturn_t bbnsm_rtc_irq_handler(int irq, void *dev_id)
+{
+ struct device *dev = dev_id;
+ struct bbnsm_rtc *bbnsm = dev_get_drvdata(dev);
+ u32 val;
+
+ regmap_read(bbnsm->regmap, BBNSM_EVENTS, &val);
+ if (val & BBNSM_EVENT_TA) {
+ bbnsm_rtc_alarm_irq_enable(dev, false);
+ /* clear the alarm event */
+ regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, TA_EN_MSK, BBNSM_EVENT_TA);
+ rtc_update_irq(bbnsm->rtc, 1, RTC_AF | RTC_IRQF);
+
+ return IRQ_HANDLED;
+ }
+
+ return IRQ_NONE;
+}
+
+static int bbnsm_rtc_probe(struct platform_device *pdev)
+{
+ struct device_node *np = pdev->dev.of_node;
+ struct bbnsm_rtc *bbnsm;
+ int ret;
+
+ bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL);
+ if (!bbnsm)
+ return -ENOMEM;
+
+ bbnsm->rtc = devm_rtc_allocate_device(&pdev->dev);
+ if (IS_ERR(bbnsm->rtc))
+ return PTR_ERR(bbnsm->rtc);
+
+ bbnsm->regmap = syscon_node_to_regmap(np->parent);
+ if (IS_ERR(bbnsm->regmap)) {
+ dev_dbg(&pdev->dev, "bbnsm get regmap failed\n");
+ return PTR_ERR(bbnsm->regmap);
+ }
+
+ bbnsm->irq = platform_get_irq(pdev, 0);
+ if (bbnsm->irq < 0)
+ return bbnsm->irq;
+
+ platform_set_drvdata(pdev, bbnsm);
+
+ /* clear all the pending events */
+ regmap_write(bbnsm->regmap, BBNSM_EVENTS, 0x7A);
+
+ device_init_wakeup(&pdev->dev, true);
+ dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+
+ ret = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_rtc_irq_handler,
+ IRQF_SHARED, "rtc alarm", &pdev->dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request irq %d: %d\n",
+ bbnsm->irq, ret);
+ return ret;
+ }
+
+ bbnsm->rtc->ops = &bbnsm_rtc_ops;
+ bbnsm->rtc->range_max = U32_MAX;
+
+ return devm_rtc_register_device(bbnsm->rtc);
+}
+
+static const struct of_device_id bbnsm_dt_ids[] = {
+ { .compatible = "nxp,imx93-bbnsm-rtc" },
+ { /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(of, bbnsm_dt_ids);
+
+static struct platform_driver bbnsm_rtc_driver = {
+ .driver = {
+ .name = "bbnsm_rtc",
+ .of_match_table = bbnsm_dt_ids,
+ },
+ .probe = bbnsm_rtc_probe,
+};
+module_platform_driver(bbnsm_rtc_driver);
+
+MODULE_AUTHOR("Jacky Bai <ping.bai@nxp.com>");
+MODULE_DESCRIPTION("NXP BBNSM RTC Driver");
+MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply related
* [PATCH v5 1/3] input: bbnsm_pwrkey: Add bbnsm power key support
From: Jacky Bai @ 2023-02-15 2:41 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
In-Reply-To: <20230215024117.3357341-1-ping.bai@nxp.com>
The ON/OFF logic inside the BBNSM allows for connecting directly
into a PMIC or other voltage regulator device. The module has an
button input signal and a wakeup request input signal. It also
has two interrupts (set_pwr_off_irq and set_pwr_on_irq) and an
active-low PMIC enable (pmic_en_b) output.
Add the power key support for the ON/OFF button function found in
BBNSM module.
Signed-off-by: Jacky Bai <ping.bai@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
---
- v5 changes:
- move the bbnsm pwr key driver to input/misc as Dmitry suggested
- replace del_timer_sync with timer_shutdown_sync()
- minor refine for error log string
- v4 changes:
- update the compatible string to align with binding file
- fix the device_property_read_u32 as stated in v2.
- add back the 'dev_warn' for 'dev_pm_set_wake_irq' return fail.
- v3 changes:
- get the regmap directly from the parent node
- v2 changes:
- use device_property_read_u32() to read the property
- clean up the goto return, return directly
- sort the header file alphabetically
- rename the file to add 'nxp' prefix
---
drivers/input/misc/Kconfig | 11 ++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/nxp-bbnsm-pwrkey.c | 192 ++++++++++++++++++++++++++
3 files changed, 204 insertions(+)
create mode 100644 drivers/input/misc/nxp-bbnsm-pwrkey.c
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 5c2d0c06d2a5..81a54a59e13c 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -119,6 +119,17 @@ config INPUT_ATMEL_CAPTOUCH
To compile this driver as a module, choose M here: the
module will be called atmel_captouch.
+config INPUT_BBNSM_PWRKEY
+ tristate "NXP BBNSM Power Key Driver"
+ depends on ARCH_MXC || COMPILE_TEST
+ depends on OF
+ help
+ This is the bbnsm powerkey driver for the NXP i.MX application
+ processors.
+
+ To compile this driver as a module, choose M here; the
+ module will be called bbnsm_pwrkey.
+
config INPUT_BMA150
tristate "BMA150/SMB380 acceleration sensor support"
depends on I2C
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index 61949263300d..04296a4abe8e 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -21,6 +21,7 @@ obj-$(CONFIG_INPUT_ATC260X_ONKEY) += atc260x-onkey.o
obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o
obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o
obj-$(CONFIG_INPUT_ATMEL_CAPTOUCH) += atmel_captouch.o
+obj-$(CONFIG_INPUT_BBNSM_PWRKEY) += nxp-bbnsm-pwrkey.o
obj-$(CONFIG_INPUT_BMA150) += bma150.o
obj-$(CONFIG_INPUT_CM109) += cm109.o
obj-$(CONFIG_INPUT_CMA3000) += cma3000_d0x.o
diff --git a/drivers/input/misc/nxp-bbnsm-pwrkey.c b/drivers/input/misc/nxp-bbnsm-pwrkey.c
new file mode 100644
index 000000000000..737e202ec513
--- /dev/null
+++ b/drivers/input/misc/nxp-bbnsm-pwrkey.c
@@ -0,0 +1,192 @@
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2022 NXP.
+
+#include <linux/device.h>
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/io.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/regmap.h>
+
+#define BBNSM_CTRL 0x8
+#define BBNSM_INT_EN 0x10
+#define BBNSM_EVENTS 0x14
+#define BBNSM_PAD_CTRL 0x24
+
+#define BBNSM_BTN_PRESSED BIT(7)
+#define BBNSM_PWR_ON BIT(6)
+#define BBNSM_BTN_OFF BIT(5)
+#define BBNSM_EMG_OFF BIT(4)
+#define BBNSM_PWRKEY_EVENTS (BBNSM_PWR_ON | BBNSM_BTN_OFF | BBNSM_EMG_OFF)
+#define BBNSM_DP_EN BIT(24)
+
+#define DEBOUNCE_TIME 30
+#define REPEAT_INTERVAL 60
+
+struct bbnsm_pwrkey {
+ struct regmap *regmap;
+ int irq;
+ int keycode;
+ int keystate; /* 1:pressed */
+ struct timer_list check_timer;
+ struct input_dev *input;
+};
+
+static void bbnsm_pwrkey_check_for_events(struct timer_list *t)
+{
+ struct bbnsm_pwrkey *bbnsm = from_timer(bbnsm, t, check_timer);
+ struct input_dev *input = bbnsm->input;
+ u32 state;
+
+ regmap_read(bbnsm->regmap, BBNSM_EVENTS, &state);
+
+ state = state & BBNSM_BTN_PRESSED ? 1 : 0;
+
+ /* only report new event if status changed */
+ if (state ^ bbnsm->keystate) {
+ bbnsm->keystate = state;
+ input_event(input, EV_KEY, bbnsm->keycode, state);
+ input_sync(input);
+ pm_relax(bbnsm->input->dev.parent);
+ }
+
+ /* repeat check if pressed long */
+ if (state) {
+ mod_timer(&bbnsm->check_timer,
+ jiffies + msecs_to_jiffies(REPEAT_INTERVAL));
+ }
+}
+
+static irqreturn_t bbnsm_pwrkey_interrupt(int irq, void *dev_id)
+{
+ struct platform_device *pdev = dev_id;
+ struct bbnsm_pwrkey *bbnsm = platform_get_drvdata(pdev);
+ struct input_dev *input = bbnsm->input;
+ u32 event;
+
+ regmap_read(bbnsm->regmap, BBNSM_EVENTS, &event);
+ if (event & BBNSM_BTN_OFF)
+ mod_timer(&bbnsm->check_timer, jiffies + msecs_to_jiffies(DEBOUNCE_TIME));
+ else
+ return IRQ_NONE;
+
+ pm_wakeup_event(input->dev.parent, 0);
+
+ /* clear PWR OFF */
+ regmap_write(bbnsm->regmap, BBNSM_EVENTS, BBNSM_BTN_OFF);
+
+ return IRQ_HANDLED;
+}
+
+static void bbnsm_pwrkey_act(void *pdata)
+{
+ struct bbnsm_pwrkey *bbnsm = pdata;
+
+ timer_shutdown_sync(&bbnsm->check_timer);
+}
+
+static int bbnsm_pwrkey_probe(struct platform_device *pdev)
+{
+ struct bbnsm_pwrkey *bbnsm;
+ struct input_dev *input;
+ struct device_node *np = pdev->dev.of_node;
+ int error;
+
+ bbnsm = devm_kzalloc(&pdev->dev, sizeof(*bbnsm), GFP_KERNEL);
+ if (!bbnsm)
+ return -ENOMEM;
+
+ bbnsm->regmap = syscon_node_to_regmap(np->parent);
+ if (IS_ERR(bbnsm->regmap)) {
+ dev_err(&pdev->dev, "bbnsm pwerkey get regmap failed\n");
+ return PTR_ERR(bbnsm->regmap);
+ }
+
+ if (device_property_read_u32(&pdev->dev, "linux,code", &bbnsm->keycode)) {
+ bbnsm->keycode = KEY_POWER;
+ dev_warn(&pdev->dev, "key code is not specified, using default KEY_POWER\n");
+ }
+
+ bbnsm->irq = platform_get_irq(pdev, 0);
+ if (bbnsm->irq < 0)
+ return -EINVAL;
+
+ /* config the BBNSM power related register */
+ regmap_update_bits(bbnsm->regmap, BBNSM_CTRL, BBNSM_DP_EN, BBNSM_DP_EN);
+
+ /* clear the unexpected interrupt before driver ready */
+ regmap_write_bits(bbnsm->regmap, BBNSM_EVENTS, BBNSM_PWRKEY_EVENTS, BBNSM_PWRKEY_EVENTS);
+
+ timer_setup(&bbnsm->check_timer, bbnsm_pwrkey_check_for_events, 0);
+
+ input = devm_input_allocate_device(&pdev->dev);
+ if (!input) {
+ dev_err(&pdev->dev, "failed to allocate the input device\n");
+ return -ENOMEM;
+ }
+
+ input->name = pdev->name;
+ input->phys = "bbnsm-pwrkey/input0";
+ input->id.bustype = BUS_HOST;
+
+ input_set_capability(input, EV_KEY, bbnsm->keycode);
+
+ /* input customer action to cancel release timer */
+ error = devm_add_action(&pdev->dev, bbnsm_pwrkey_act, bbnsm);
+ if (error) {
+ dev_err(&pdev->dev, "failed to register remove action\n");
+ return error;
+ }
+
+ bbnsm->input = input;
+ platform_set_drvdata(pdev, bbnsm);
+
+ error = devm_request_irq(&pdev->dev, bbnsm->irq, bbnsm_pwrkey_interrupt,
+ IRQF_SHARED, pdev->name, pdev);
+ if (error) {
+ dev_err(&pdev->dev, "interrupt not available.\n");
+ return error;
+ }
+
+ error = input_register_device(input);
+ if (error < 0) {
+ dev_err(&pdev->dev, "failed to register input device\n");
+ return error;
+ }
+
+ device_init_wakeup(&pdev->dev, true);
+ error = dev_pm_set_wake_irq(&pdev->dev, bbnsm->irq);
+ if (error)
+ dev_warn(&pdev->dev, "irq wake enable failed.\n");
+
+ return 0;
+}
+
+static const struct of_device_id bbnsm_pwrkey_ids[] = {
+ { .compatible = "nxp,imx93-bbnsm-pwrkey" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, bbnsm_pwrkey_ids);
+
+static struct platform_driver bbnsm_pwrkey_driver = {
+ .driver = {
+ .name = "bbnsm_pwrkey",
+ .of_match_table = bbnsm_pwrkey_ids,
+ },
+ .probe = bbnsm_pwrkey_probe,
+};
+module_platform_driver(bbnsm_pwrkey_driver);
+
+MODULE_AUTHOR("Jacky Bai <ping.bai@nxp.com>");
+MODULE_DESCRIPTION("NXP bbnsm power key Driver");
+MODULE_LICENSE("GPL");
--
2.34.1
^ permalink raw reply related
* [PATCH v5 0/3] Add nxp bbnsm module support
From: Jacky Bai @ 2023-02-15 2:41 UTC (permalink / raw)
To: lee, robh+dt, krzysztof.kozlowski+dt, shawnguo, s.hauer,
dmitry.torokhov, a.zummo, alexandre.belloni
Cc: devicetree, linux-arm-kernel, linux-input, linux-rtc, kernel,
linux-imx, festevam
NXP BBNSM (Battery-Backed Non-Secure Module) serves as non-volatile
logic and storage for the system. it provides some similar functions
like RTC and ON/OFF support as previous SNVS module found on legacy
i.MX SoCs. The BBNSM is replacement of previous SNVS module, and more
likely it will be used on all the future i.MX SoC or other SoCs from
NXP.
This patchset add the basic support for BBNSM that found on i.MX93.
Jacky Bai (3):
input: bbnsm_pwrkey: Add bbnsm power key support
rtc: bbnsm: Add the bbnsm rtc support
arm64: dts: imx93: Add the bbnsm dts node
arch/arm64/boot/dts/freescale/imx93.dtsi | 16 ++
drivers/input/misc/Kconfig | 11 ++
drivers/input/misc/Makefile | 1 +
drivers/input/misc/nxp-bbnsm-pwrkey.c | 192 +++++++++++++++++++
drivers/rtc/Kconfig | 12 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-nxp-bbnsm.c | 226 +++++++++++++++++++++++
7 files changed, 459 insertions(+)
create mode 100644 drivers/input/misc/nxp-bbnsm-pwrkey.c
create mode 100644 drivers/rtc/rtc-nxp-bbnsm.c
--
2.34.1
^ permalink raw reply
* [PATCH 1/4] HID: steelseries: explicitly include linux/leds.h
From: Thomas Weißschuh @ 2023-02-15 1:03 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hans de Goede
Cc: linux-input, linux-kernel, Thomas Weißschuh
In-Reply-To: <20230215-power_supply-leds-hid-v1-0-35b6f1dcee8a@weissschuh.net>
Instead of relying on an accidental, transitive inclusion of linux/leds.h
use it directly.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/hid/hid-steelseries.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-steelseries.c b/drivers/hid/hid-steelseries.c
index 37353c41cba7..aae3afc4107a 100644
--- a/drivers/hid/hid-steelseries.c
+++ b/drivers/hid/hid-steelseries.c
@@ -11,6 +11,7 @@
#include <linux/device.h>
#include <linux/hid.h>
#include <linux/module.h>
+#include <linux/leds.h>
#include "hid-ids.h"
--
2.39.2
^ permalink raw reply related
* [PATCH 4/4] HID: apple: explicitly include linux/leds.h
From: Thomas Weißschuh @ 2023-02-15 1:03 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hans de Goede
Cc: linux-input, linux-kernel, Thomas Weißschuh
In-Reply-To: <20230215-power_supply-leds-hid-v1-0-35b6f1dcee8a@weissschuh.net>
Instead of relying on an accidental, transitive inclusion of linux/leds.h
use it directly.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/hid/hid-apple.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 1ccab8aa326c..c5b45cd1e44d 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -22,6 +22,7 @@
#include <linux/slab.h>
#include <linux/timer.h>
#include <linux/string.h>
+#include <linux/leds.h>
#include "hid-ids.h"
--
2.39.2
^ permalink raw reply related
* [PATCH 0/4] HID: explicitly include linux/leds.h
From: Thomas Weißschuh @ 2023-02-15 1:03 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hans de Goede
Cc: linux-input, linux-kernel, Thomas Weißschuh
Instead of relying on an accidental, transitive inclusion of linux/leds.h
use it directly.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
Thomas Weißschuh (4):
HID: steelseries: explicitly include linux/leds.h
HID: lg-g15: explicitly include linux/leds.h
HID: asus: explicitly include linux/leds.h
HID: apple: explicitly include linux/leds.h
drivers/hid/hid-apple.c | 1 +
drivers/hid/hid-asus.c | 1 +
drivers/hid/hid-lg-g15.c | 1 +
drivers/hid/hid-steelseries.c | 1 +
4 files changed, 4 insertions(+)
---
base-commit: e1c04510f521e853019afeca2a5991a5ef8d6a5b
change-id: 20230215-power_supply-leds-hid-f99a0a3fd2bf
Best regards,
--
Thomas Weißschuh <linux@weissschuh.net>
^ permalink raw reply
* [PATCH 2/4] HID: lg-g15: explicitly include linux/leds.h
From: Thomas Weißschuh @ 2023-02-15 1:03 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hans de Goede
Cc: linux-input, linux-kernel, Thomas Weißschuh
In-Reply-To: <20230215-power_supply-leds-hid-v1-0-35b6f1dcee8a@weissschuh.net>
Instead of relying on an accidental, transitive inclusion of linux/leds.h
use it directly.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/hid/hid-lg-g15.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-lg-g15.c b/drivers/hid/hid-lg-g15.c
index c8f82bcbf1ab..acbec1dcf196 100644
--- a/drivers/hid/hid-lg-g15.c
+++ b/drivers/hid/hid-lg-g15.c
@@ -7,6 +7,7 @@
#include <linux/device.h>
#include <linux/hid.h>
+#include <linux/leds.h>
#include <linux/module.h>
#include <linux/random.h>
#include <linux/sched.h>
--
2.39.2
^ permalink raw reply related
* [PATCH 3/4] HID: asus: explicitly include linux/leds.h
From: Thomas Weißschuh @ 2023-02-15 1:03 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Hans de Goede
Cc: linux-input, linux-kernel, Thomas Weißschuh
In-Reply-To: <20230215-power_supply-leds-hid-v1-0-35b6f1dcee8a@weissschuh.net>
Instead of relying on an accidental, transitive inclusion of linux/leds.h
use it directly.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
drivers/hid/hid-asus.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/hid/hid-asus.c b/drivers/hid/hid-asus.c
index f99752b998f3..44074c9efa00 100644
--- a/drivers/hid/hid-asus.c
+++ b/drivers/hid/hid-asus.c
@@ -30,6 +30,7 @@
#include <linux/input/mt.h>
#include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
#include <linux/power_supply.h>
+#include <linux/leds.h>
#include "hid-ids.h"
--
2.39.2
^ permalink raw reply related
* Re: [PATCH v5 1/3] dt-bindings: i2c: Add CP2112 HID USB to SMBus Bridge
From: Rob Herring @ 2023-02-14 23:53 UTC (permalink / raw)
To: Danny Kaehn
Cc: krzysztof.kozlowski+dt, jikos, benjamin.tissoires,
bartosz.golaszewski, andriy.shevchenko, dmitry.torokhov,
devicetree, linux-input, ethan.twardy
In-Reply-To: <20230210223638.12796-2-kaehndan@gmail.com>
On Fri, Feb 10, 2023 at 04:36:36PM -0600, Danny Kaehn wrote:
> This is a USB HID device which includes an I2C controller and 8 GPIO pins.
>
> The binding allows describing the chip's gpio and i2c controller in DT
> using the subnodes named "gpio" and "i2c", respectively. This is
> intended to be used in configurations where the CP2112 is permanently
> connected in hardware.
>
> Signed-off-by: Danny Kaehn <kaehndan@gmail.com>
> ---
> .../bindings/i2c/silabs,cp2112.yaml | 113 ++++++++++++++++++
> 1 file changed, 113 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml
>
> diff --git a/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml b/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml
> new file mode 100644
> index 000000000000..81eda01ebda5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/i2c/silabs,cp2112.yaml
> @@ -0,0 +1,113 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/i2c/silabs,cp2112.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: CP2112 HID USB to SMBus/I2C Bridge
> +
> +maintainers:
> + - Danny Kaehn <kaehndan@gmail.com>
> +
> +description:
> + The CP2112 is a USB HID device which includes an integrated I2C controller
> + and 8 GPIO pins. Its GPIO pins can each be configured as inputs, open-drain
> + outputs, or push-pull outputs.
> +
> +properties:
> + compatible:
> + const: usb10c4,ea90
> +
> + reg:
> + maxItems: 1
> + description: The USB port number on the host controller
> +
> + i2c:
> + description: The SMBus/I2C controller node for the CP2112
> + $ref: /schemas/i2c/i2c-controller.yaml#
> + unevaluatedProperties: false
> +
> + properties:
> + sda-gpios:
> + maxItems: 1
> +
> + scl-gpios:
> + maxItems: 1
> +
> + clock-frequency:
> + minimum: 10000
> + default: 100000
> + maximum: 400000
> +
> + gpio:
> + description: The GPIO controller node for the CP2112
> + type: object
> + unevaluatedProperties: false
> +
> + properties:
> + interrupt-controller: true
> + "#interrupt-cells":
> + const: 2
> +
> + gpio-controller: true
> + "#gpio-cells":
> + const: 2
> +
> + gpio-line-names:
> + minItems: 1
> + maxItems: 8
> +
> + patternProperties:
> + "^(.+-hog(-[0-9]+)?)$":
This can be simplified to: '-hog(-[0-9]+)?$'
Otherwise,
Reviewed-by: Rob Herring <robh@kernel.org>
^ permalink raw reply
* Re: [PATCH v3 2/2] HID: asus: use spinlock to safely schedule workers
From: Pietro Borrello @ 2023-02-14 17:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: oe-kbuild, Jiri Kosina, Benjamin Tissoires, Hanno Zulla,
Carlo Caione, lkp, oe-kbuild-all, Cristiano Giuffrida, Bos, H.J.,
Jakob Koschel, Roderick Colenbrander, linux-input, linux-kernel
In-Reply-To: <202302141039.anZLT940-lkp@intel.com>
On Tue, 14 Feb 2023 at 08:58, Dan Carpenter <error27@gmail.com> wrote:
>
> Hi Pietro,
>
> url: https://github.com/intel-lab-lkp/linux/commits/Pietro-Borrello/HID-bigben-use-spinlock-to-safely-schedule-workers/20230210-080058
> base: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
> patch link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v3-2-0a52ac225e00%40diag.uniroma1.it
> patch subject: [PATCH v3 2/2] HID: asus: use spinlock to safely schedule workers
> config: riscv-randconfig-m031-20230212 (https://download.01.org/0day-ci/archive/20230214/202302141039.anZLT940-lkp@intel.com/config)
> compiler: riscv32-linux-gcc (GCC) 12.1.0
>
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> | Reported-by: Dan Carpenter <error27@gmail.com>
> | Link: https://lore.kernel.org/r/202302141039.anZLT940-lkp@intel.com/
>
> smatch warnings:
> drivers/hid/hid-asus.c:532 asus_kbd_backlight_work() warn: sleeping in atomic context
>
> vim +532 drivers/hid/hid-asus.c
>
> af22a610bc3850 Carlo Caione 2017-04-06 521 static void asus_kbd_backlight_work(struct work_struct *work)
> af22a610bc3850 Carlo Caione 2017-04-06 522 {
> af22a610bc3850 Carlo Caione 2017-04-06 523 struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
> af22a610bc3850 Carlo Caione 2017-04-06 524 u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
> af22a610bc3850 Carlo Caione 2017-04-06 525 int ret;
> 31e578b641b3b3 Pietro Borrello 2023-02-09 526 unsigned long flags;
> af22a610bc3850 Carlo Caione 2017-04-06 527
> 31e578b641b3b3 Pietro Borrello 2023-02-09 528 spin_lock_irqsave(&led->lock, flags);
> ^^^^^^^^^^^^^^^^^
> Holding a spinlock.
>
> af22a610bc3850 Carlo Caione 2017-04-06 529
> af22a610bc3850 Carlo Caione 2017-04-06 530 buf[4] = led->brightness;
> af22a610bc3850 Carlo Caione 2017-04-06 531
> af22a610bc3850 Carlo Caione 2017-04-06 @532 ret = asus_kbd_set_report(led->hdev, buf, sizeof(buf));
> ^^^^^^^^^^^^^^^^^^^
> asus_kbd_set_report() does a GFP_KERNEL allocation.
>
>
> af22a610bc3850 Carlo Caione 2017-04-06 533 if (ret < 0)
> af22a610bc3850 Carlo Caione 2017-04-06 534 hid_err(led->hdev, "Asus failed to set keyboard backlight: %d\n", ret);
> 31e578b641b3b3 Pietro Borrello 2023-02-09 535
> 31e578b641b3b3 Pietro Borrello 2023-02-09 536 spin_unlock_irqrestore(&led->lock, flags);
> af22a610bc3850 Carlo Caione 2017-04-06 537 }
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests
>
Hello,
Thank you, but the issue has already been fixed in v4.
Link: https://lore.kernel.org/lkml/20230125-hid-unregister-leds-v4-3-7860c5763c38@diag.uniroma1.it/T/#m8983ca3d0fbf656a40011a77c8988e3d16cac671
Best regards,
Pietro
^ permalink raw reply
* Re: (subset) [PATCH 00/35] Documentation: correct lots of spelling errors (series 1)
From: Martin K. Petersen @ 2023-02-14 16:57 UTC (permalink / raw)
To: linux-kernel, Randy Dunlap
Cc: Martin K . Petersen, Jonathan Corbet, Catalin Marinas,
Will Deacon, Russell King, Jens Axboe, Andrii Nakryiko,
Alexei Starovoitov, Daniel Borkmann, Vladimir Oltean,
Steffen Klassert, Daniel Jordan, Akinobu Mita, Helge Deller,
Rafael J. Wysocki, Jiri Kosina, Benjamin Tissoires,
Srinivas Pandruvada, Wolfram Sang, Dmitry Torokhov,
Henrik Rydberg, Karsten Keil, Pavel Machek, Lee Jones,
Josh Poimboeuf, Miroslav Benes, Petr Mladek, Peter Zijlstra,
Ingo Molnar, Jérôme Glisse, Naoya Horiguchi, Miaohe Lin,
Jonas Bonn, Stefan Kristiansson, Stafford Horne, Bjorn Helgaas,
Lorenzo Pieralisi, Marc Zyngier, Michael Ellerman, Len Brown,
Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Juri Lelli,
Vincent Guittot, David Howells, Jarkko Sakkinen, Paul Moore,
James Morris, Serge E. Hallyn, Jaroslav Kysela, Takashi Iwai,
Mark Brown, Daniel Bristot de Oliveira, Steven Rostedt,
Greg Kroah-Hartman, Masami Hiramatsu, Mathieu Poirier,
Suzuki K Poulose, Evgeniy Polyakov, Fenghua Yu, Reinette Chatre,
Thomas Gleixner, Borislav Petkov, Chris Zankel, Max Filippov,
alsa-devel, coresight, bpf, dri-devel, isdn4linux, keyrings,
linux-acpi, linux-block, linux-crypto, linux-doc, linux-fbdev,
linux-i2c, linux-input, linux-leds, linux-pci, linux-s390,
linux-scsi, linux-sgx, linux-spi, linux-trace-devel,
linux-trace-kernel, live-patching, linux-pm,
linux-security-module, linux-usb, netdev, target-devel, linux-mm,
openrisc, linux-arm-kernel, linux-xtensa, linuxppc-dev, x86
In-Reply-To: <20230127064005.1558-1-rdunlap@infradead.org>
On Thu, 26 Jan 2023 22:39:30 -0800, Randy Dunlap wrote:
> Correct many spelling errors in Documentation/ as reported by codespell.
>
> Maintainers of specific kernel subsystems are only Cc-ed on their
> respective patches, not the entire series. [if all goes well]
>
> These patches are based on linux-next-20230125.
>
> [...]
Applied to 6.3/scsi-queue, thanks!
[28/35] Documentation: target: correct spelling
https://git.kernel.org/mkp/scsi/c/c57ac5748be5
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply
* Panele fotowaltaiczne
From: Piotr Werner @ 2023-02-10 8:35 UTC (permalink / raw)
To: linux-input
Dzień dobry,
Jesteśmy firmą z wieloletnim doświadczeniem, która sprawnie przygotuje dla Państwa ofertę i wszelkie formalności. Sam montaż zaplanujemy na wiosnę.
O samych plusach fotowoltaiki czy pompach ciepła na pewno już Państwo słyszeli, dlatego teraz prosimy o zostawienie kontaktu, aby nasz specjalista mógł przedstawić ofertę zgodną z Waszymi potrzebami.
Kiedy moglibyśmy z Państwem umówić się na rozmowę w celu zbadania potrzeb?
Pozdrawiam,
Piotr Werner
^ permalink raw reply
* [PATCH] Input: mainstone: fix pxa2xx_ac97 dependency
From: Arnd Bergmann @ 2023-02-14 9:07 UTC (permalink / raw)
To: Dmitry Torokhov, Robert Jarzmik, Arnd Bergmann
Cc: Mark Brown, alsa-devel, linux-input, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
The exported PXA AC97 symbols are provided by the snd-pxa2xx-lib module
if SND_PXA2XX_SOC_AC97 is set, so both symbols have to be enabled for
the mainstone driver to actually work, and if snd-pxa2xx-lib is a loadable
module, the touchscreen driver cannot be built-in:
arm-linux-gnueabi-ld: drivers/input/touchscreen/mainstone-wm97xx.o: in function `wm97xx_acc_pen_up':
mainstone-wm97xx.c:(.text+0x8c): undefined reference to `pxa2xx_ac97_read_modr'
arm-linux-gnueabi-ld: drivers/input/touchscreen/mainstone-wm97xx.o: in function `wm97xx_acc_pen_down':
mainstone-wm97xx.c:(.text+0x2e0): undefined reference to `pxa2xx_ac97_read_modr'
The misconfiguration has always been possible but I never hit this after
my previous incomplete fix in 2019: since there were many options that
each 'select SND_PXA2XX_SOC_AC97', randconfig builds for PXA would almost
always have this built-in, not in a loadable module.
Fixes: e217b085a1ac ("Input: touchscreen: use wrapper for pxa2xx ac97 registers")
Fixes: b401d1fd8053 ("ASoC: pxa: remove unused board support")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/input/touchscreen/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 61bb8e632413..1601f5bae005 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -903,7 +903,7 @@ config TOUCHSCREEN_WM9713
config TOUCHSCREEN_WM97XX_MAINSTONE
tristate "WM97xx Mainstone/Palm accelerated touch"
depends on TOUCHSCREEN_WM97XX && ARCH_PXA
- depends on SND_PXA2XX_LIB_AC97
+ depends on SND_PXA2XX_LIB && SND_PXA2XX_LIB_AC97
help
Say Y here for support for streaming mode with WM97xx touchscreens
on Mainstone, Palm Tungsten T5, TX and LifeDrive systems.
--
2.39.1
^ permalink raw reply related
* Re: [PATCH v3 2/2] HID: asus: use spinlock to safely schedule workers
From: Dan Carpenter @ 2023-02-14 7:58 UTC (permalink / raw)
To: oe-kbuild, Pietro Borrello, Jiri Kosina, Benjamin Tissoires,
Hanno Zulla, Carlo Caione
Cc: lkp, oe-kbuild-all, Cristiano Giuffrida, Bos, H.J., Jakob Koschel,
Roderick Colenbrander, linux-input, linux-kernel, Pietro Borrello
In-Reply-To: <20230125-hid-unregister-leds-v3-2-0a52ac225e00@diag.uniroma1.it>
Hi Pietro,
url: https://github.com/intel-lab-lkp/linux/commits/Pietro-Borrello/HID-bigben-use-spinlock-to-safely-schedule-workers/20230210-080058
base: 2241ab53cbb5cdb08a6b2d4688feb13971058f65
patch link: https://lore.kernel.org/r/20230125-hid-unregister-leds-v3-2-0a52ac225e00%40diag.uniroma1.it
patch subject: [PATCH v3 2/2] HID: asus: use spinlock to safely schedule workers
config: riscv-randconfig-m031-20230212 (https://download.01.org/0day-ci/archive/20230214/202302141039.anZLT940-lkp@intel.com/config)
compiler: riscv32-linux-gcc (GCC) 12.1.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202302141039.anZLT940-lkp@intel.com/
smatch warnings:
drivers/hid/hid-asus.c:532 asus_kbd_backlight_work() warn: sleeping in atomic context
vim +532 drivers/hid/hid-asus.c
af22a610bc3850 Carlo Caione 2017-04-06 521 static void asus_kbd_backlight_work(struct work_struct *work)
af22a610bc3850 Carlo Caione 2017-04-06 522 {
af22a610bc3850 Carlo Caione 2017-04-06 523 struct asus_kbd_leds *led = container_of(work, struct asus_kbd_leds, work);
af22a610bc3850 Carlo Caione 2017-04-06 524 u8 buf[] = { FEATURE_KBD_REPORT_ID, 0xba, 0xc5, 0xc4, 0x00 };
af22a610bc3850 Carlo Caione 2017-04-06 525 int ret;
31e578b641b3b3 Pietro Borrello 2023-02-09 526 unsigned long flags;
af22a610bc3850 Carlo Caione 2017-04-06 527
31e578b641b3b3 Pietro Borrello 2023-02-09 528 spin_lock_irqsave(&led->lock, flags);
^^^^^^^^^^^^^^^^^
Holding a spinlock.
af22a610bc3850 Carlo Caione 2017-04-06 529
af22a610bc3850 Carlo Caione 2017-04-06 530 buf[4] = led->brightness;
af22a610bc3850 Carlo Caione 2017-04-06 531
af22a610bc3850 Carlo Caione 2017-04-06 @532 ret = asus_kbd_set_report(led->hdev, buf, sizeof(buf));
^^^^^^^^^^^^^^^^^^^
asus_kbd_set_report() does a GFP_KERNEL allocation.
af22a610bc3850 Carlo Caione 2017-04-06 533 if (ret < 0)
af22a610bc3850 Carlo Caione 2017-04-06 534 hid_err(led->hdev, "Asus failed to set keyboard backlight: %d\n", ret);
31e578b641b3b3 Pietro Borrello 2023-02-09 535
31e578b641b3b3 Pietro Borrello 2023-02-09 536 spin_unlock_irqrestore(&led->lock, flags);
af22a610bc3850 Carlo Caione 2017-04-06 537 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
^ permalink raw reply
* Re: remove arch/sh
From: John Paul Adrian Glaubitz @ 2023-02-13 16:30 UTC (permalink / raw)
To: Stephen Rothwell
Cc: Christoph Hellwig, Yoshinori Sato, Rich Felker, Arnd Bergmann,
Greg Kroah-Hartman, Laurent Pinchart, Kieran Bingham,
Geert Uytterhoeven, linux-kernel, linux-watchdog, devicetree,
linux-arch, dmaengine, dri-devel, linux-renesas-soc, linux-i2c,
linux-input, linux-media, linux-mmc, linux-mtd, netdev,
linux-gpio, linux-rtc, linux-spi, linux-serial, linux-usb,
linux-fbdev, alsa-devel, linux-sh
In-Reply-To: <20230206100856.603a0f8f@canb.auug.org.au>
Hi Steve!
On Mon, 2023-02-06 at 10:08 +1100, Stephen Rothwell wrote:
> Hi,
>
> On Fri, 3 Feb 2023 09:30:37 +0100 Christoph Hellwig <hch@lst.de> wrote:
> >
> > On Fri, Feb 03, 2023 at 09:24:46AM +0100, John Paul Adrian Glaubitz wrote:
> > > Since this is my very first time stepping up as a kernel maintainer, I was hoping
> > > to get some pointers on what to do to make this happen.
> > >
> > > So far, we have set up a new kernel tree and I have set up a local development and
> > > test environment for SH kernels using my SH7785LCR board as the target platform.
> > >
> > > Do I just need to send a patch asking to change the corresponding entry in the
> > > MAINTAINERS file?
> >
> > I'm not sure a there is a document, but:
> >
> > - add the MAINTAINERS change to your tree
> > - ask Stephen to get your tree included in linux-next
>
> And by "Stephen", Christoph means me. When you are ready, please send
> me a request to include your tree/branch in linux-next (usually the
> branch is called something like "for-next" or just "next") telling me
> the git URL, and the contacts I should send email to if there are
> conflicts/build issues with the branch. I will then fetch the branch
> every time I create a new linux-next release (most work days), so all
> you need to do is update that branch each time you are ready to publish
> more commits.
I'm in the MAINTAINERS now in Linus' tree. I have requested a kernel.org
account now and will hopefully have my trees set up later this week.
I'll let you know about the URLs as soon as possible.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
^ permalink raw reply
* Re: [PATCH v3 1/2] HID: bigben: use spinlock to safely schedule workers
From: Benjamin Tissoires @ 2023-02-13 10:47 UTC (permalink / raw)
To: Hillf Danton
Cc: Pietro Borrello, Jiri Kosina, Hanno Zulla, linux-input,
linux-kernel
In-Reply-To: <20230213103658.3091-1-hdanton@sina.com>
On Mon, Feb 13, 2023 at 11:37 AM Hillf Danton <hdanton@sina.com> wrote:
>
> On Mon, 13 Feb 2023 09:25:37 +0100 Benjamin Tissoires <benjamin.tissoires@redhat.com>
> >
> > The remove flag is just a way to prevent any other workqueue from
> > starting. It doesn't mean that the struct bigben has been freed, so
> > acquiring a lock at that point is fine.
> > We then rely on 2 things:
> > - devm_class_led to be released before struct bigben, because it was
> > devm-allocated *after* the struct bigben was devm-allocated
>
> This is the current behavior and it is intact after this patch.
>
> > - we prevent any new workqueue to start and we guarantee that any
> > running workqueue is terminated before leaving the .remove function.
>
> If spinlock is added for not scheduling new workqueue then it is not
> needed, because the removed flag is set before running workqueue is
> terminated. Checking the flag is enough upon queuing new work.
>
I tend to disagree (based on Pietro's v4:
- no worker is running
- a led sysfs call is made
- the line "if (!bigben->removed)" is true
- this gets interrupted/or another CPU kicks in for the next one
-> .remove gets called
- bigben->removed is set to false
- cancel_work_sync() called
the led call continues, and schedules the work
.removes terminates, and devm kicks in, killing led_class and struct
bigben while the workqueue is running.
So having a simple spinlocks ensures the atomicity between checking
for bigben->removed and scheduling a workqueue.
Cheers,
Benjamin
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox