* [PATCH 15/18] HID: picoLCD: Constify lcd_ops
From: Krzysztof Kozlowski @ 2024-04-14 16:36 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap, Krzysztof Kozlowski
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-0-9b37fcbf546a@kernel.org>
'struct lcd_ops' is not modified by core backlight code, so it can be
made const for increased code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Depends on the first patch in the series.
---
drivers/hid/hid-picolcd_lcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hid/hid-picolcd_lcd.c b/drivers/hid/hid-picolcd_lcd.c
index 0c4b76de8ae5..061a33ba7b1d 100644
--- a/drivers/hid/hid-picolcd_lcd.c
+++ b/drivers/hid/hid-picolcd_lcd.c
@@ -46,7 +46,7 @@ static int picolcd_check_lcd_fb(struct lcd_device *ldev, struct fb_info *fb)
return fb && fb == picolcd_fbinfo((struct picolcd_data *)lcd_get_data(ldev));
}
-static struct lcd_ops picolcd_lcdops = {
+static const struct lcd_ops picolcd_lcdops = {
.get_contrast = picolcd_get_contrast,
.set_contrast = picolcd_set_contrast,
.check_fb = picolcd_check_lcd_fb,
--
2.34.1
^ permalink raw reply related
* [PATCH 16/18] fbdev: clps711x: Constify lcd_ops
From: Krzysztof Kozlowski @ 2024-04-14 16:36 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap, Krzysztof Kozlowski
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-0-9b37fcbf546a@kernel.org>
'struct lcd_ops' is not modified by core backlight code, so it can be
made const for increased code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Depends on the first patch in the series.
---
drivers/video/fbdev/clps711x-fb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/clps711x-fb.c b/drivers/video/fbdev/clps711x-fb.c
index dcfd1fbbc7e1..6171a98a48fd 100644
--- a/drivers/video/fbdev/clps711x-fb.c
+++ b/drivers/video/fbdev/clps711x-fb.c
@@ -197,7 +197,7 @@ static int clps711x_lcd_set_power(struct lcd_device *lcddev, int blank)
return 0;
}
-static struct lcd_ops clps711x_lcd_ops = {
+static const struct lcd_ops clps711x_lcd_ops = {
.check_fb = clps711x_lcd_check_fb,
.get_power = clps711x_lcd_get_power,
.set_power = clps711x_lcd_set_power,
--
2.34.1
^ permalink raw reply related
* [PATCH 17/18] fbdev: imx: Constify lcd_ops
From: Krzysztof Kozlowski @ 2024-04-14 16:36 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap, Krzysztof Kozlowski
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-0-9b37fcbf546a@kernel.org>
'struct lcd_ops' is not modified by core backlight code, so it can be
made const for increased code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Depends on the first patch in the series.
---
drivers/video/fbdev/imxfb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c
index a4dbc72f93c3..4ebfe9b9df60 100644
--- a/drivers/video/fbdev/imxfb.c
+++ b/drivers/video/fbdev/imxfb.c
@@ -857,7 +857,7 @@ static int imxfb_lcd_set_power(struct lcd_device *lcddev, int power)
return 0;
}
-static struct lcd_ops imxfb_lcd_ops = {
+static const struct lcd_ops imxfb_lcd_ops = {
.check_fb = imxfb_lcd_check_fb,
.get_contrast = imxfb_lcd_get_contrast,
.set_contrast = imxfb_lcd_set_contrast,
--
2.34.1
^ permalink raw reply related
* [PATCH 18/18] fbdev: omap: lcd_ams_delta: Constify lcd_ops
From: Krzysztof Kozlowski @ 2024-04-14 16:36 UTC (permalink / raw)
To: Lee Jones, Daniel Thompson, Jingoo Han, Helge Deller,
Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap, Krzysztof Kozlowski
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-0-9b37fcbf546a@kernel.org>
'struct lcd_ops' is not modified by core backlight code, so it can be
made const for increased code safety.
Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
Depends on the first patch in the series.
---
drivers/video/fbdev/omap/lcd_ams_delta.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/fbdev/omap/lcd_ams_delta.c b/drivers/video/fbdev/omap/lcd_ams_delta.c
index 6f860c814d2c..97e2b71b64d7 100644
--- a/drivers/video/fbdev/omap/lcd_ams_delta.c
+++ b/drivers/video/fbdev/omap/lcd_ams_delta.c
@@ -76,7 +76,7 @@ static int ams_delta_lcd_get_contrast(struct lcd_device *dev)
return ams_delta_lcd & AMS_DELTA_MAX_CONTRAST;
}
-static struct lcd_ops ams_delta_lcd_ops = {
+static const struct lcd_ops ams_delta_lcd_ops = {
.get_power = ams_delta_lcd_get_power,
.set_power = ams_delta_lcd_set_power,
.get_contrast = ams_delta_lcd_get_contrast,
--
2.34.1
^ permalink raw reply related
* [syzbot] [input?] WARNING in bcm5974_start_traffic/usb_submit_urb (2)
From: syzbot @ 2024-04-15 1:54 UTC (permalink / raw)
To: dmitry.torokhov, linux-input, linux-kernel, rydberg,
syzkaller-bugs
Hello,
syzbot found the following issue on:
HEAD commit: fec50db7033e Linux 6.9-rc3
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
console output: https://syzkaller.appspot.com/x/log.txt?x=14439bd3180000
kernel config: https://syzkaller.appspot.com/x/.config?x=560f5db1d0b3f6d0
dashboard link: https://syzkaller.appspot.com/bug?extid=b064b5599f18f7ebb1e1
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: arm64
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11c2c5bd180000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13cbbf5b180000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ab4d6cae2eca/disk-fec50db7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/b67542cc5860/vmlinux-fec50db7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/3eeebb470b79/Image-fec50db7.gz.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+b064b5599f18f7ebb1e1@syzkaller.appspotmail.com
------------[ cut here ]------------
usb 1-1: BOGUS urb xfer, pipe 1 != type 3
WARNING: CPU: 0 PID: 6237 at drivers/usb/core/urb.c:504 usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
Modules linked in:
CPU: 0 PID: 6237 Comm: udevd Not tainted 6.9.0-rc3-syzkaller-gfec50db7033e #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
lr : usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
sp : ffff80009f8b73b0
x29: ffff80009f8b73f0 x28: ffff0000d4fee000 x27: 0000000000000001
x26: ffff80008c6919e8 x25: ffff0000c8bd1fe0 x24: ffff0000c1d45a50
x23: ffff80008c698500 x22: dfff800000000000 x21: 0000000000000002
x20: 0000000000000cc0 x19: ffff0000c1d45a00 x18: 0000000000000008
x17: 0000000000000000 x16: ffff80008ae6d1bc x15: 0000000000000001
x14: 1fffe000367b9a02 x13: 0000000000000000 x12: 0000000000000000
x11: 0000000000000002 x10: 0000000000ff0100 x9 : b1573c5f9bab7600
x8 : b1573c5f9bab7600 x7 : 0000000000000001 x6 : 0000000000000001
x5 : ffff80009f8b6b18 x4 : ffff80008ef65000 x3 : ffff8000805e9200
x2 : 0000000000000001 x1 : 0000000100000000 x0 : 0000000000000000
Call trace:
usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
bcm5974_start_traffic+0xe0/0x154 drivers/input/mouse/bcm5974.c:799
bcm5974_open+0x98/0x134 drivers/input/mouse/bcm5974.c:839
input_open_device+0x170/0x29c drivers/input/input.c:654
evdev_open_device drivers/input/evdev.c:400 [inline]
evdev_open+0x308/0x4b4 drivers/input/evdev.c:487
chrdev_open+0x3c8/0x4dc fs/char_dev.c:414
do_dentry_open+0x778/0x12b4 fs/open.c:955
vfs_open+0x7c/0x90 fs/open.c:1089
do_open fs/namei.c:3642 [inline]
path_openat+0x1f6c/0x2830 fs/namei.c:3799
do_filp_open+0x1bc/0x3cc fs/namei.c:3826
do_sys_openat2+0x124/0x1b8 fs/open.c:1406
do_sys_open fs/open.c:1421 [inline]
__do_sys_openat fs/open.c:1437 [inline]
__se_sys_openat fs/open.c:1432 [inline]
__arm64_sys_openat+0x1f0/0x240 fs/open.c:1432
__invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:133
do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152
el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598
irq event stamp: 5626
hardirqs last enabled at (5625): [<ffff8000803749b0>] __up_console_sem kernel/printk/printk.c:341 [inline]
hardirqs last enabled at (5625): [<ffff8000803749b0>] __console_unlock kernel/printk/printk.c:2731 [inline]
hardirqs last enabled at (5625): [<ffff8000803749b0>] console_unlock+0x17c/0x3d4 kernel/printk/printk.c:3050
hardirqs last disabled at (5626): [<ffff80008ae68608>] el1_dbg+0x24/0x80 arch/arm64/kernel/entry-common.c:470
softirqs last enabled at (2362): [<ffff800080031848>] local_bh_enable+0x10/0x34 include/linux/bottom_half.h:32
softirqs last disabled at (2360): [<ffff800080031814>] local_bh_disable+0x10/0x34 include/linux/bottom_half.h:19
---[ end trace 0000000000000000 ]---
---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
^ permalink raw reply
* [PATCH v2 1/1] mm: change inlined allocation helpers to account at the call site
From: Suren Baghdasaryan @ 2024-04-15 2:07 UTC (permalink / raw)
To: akpm
Cc: willy, jack, joro, will, trond.myklebust, anna, arnd, herbert,
davem, jikos, benjamin.tissoires, tytso, jack, dennis, tj, cl,
jakub, penberg, rientjes, iamjoonsoo.kim, vbabka, edumazet, kuba,
pabeni, iommu, linux-kernel, linux-nfs, linux-acpi, acpica-devel,
linux-arch, linux-crypto, bpf, linux-input, linux-ext4, linux-mm,
netdev, linux-security-module, kent.overstreet, surenb
Main goal of memory allocation profiling patchset is to provide accounting
that is cheap enough to run in production. To achieve that we inject
counters using codetags at the allocation call sites to account every time
allocation is made. This injection allows us to perform accounting
efficiently because injected counters are immediately available as opposed
to the alternative methods, such as using _RET_IP_, which would require
counter lookup and appropriate locking that makes accounting much more
expensive. This method requires all allocation functions to inject
separate counters at their call sites so that their callers can be
individually accounted. Counter injection is implemented by allocation
hooks which should wrap all allocation functions.
Inlined functions which perform allocations but do not use allocation
hooks are directly charged for the allocations they perform. In most
cases these functions are just specialized allocation wrappers used
from multiple places to allocate objects of a specific type. It would
be more useful to do the accounting at their call sites instead.
Instrument these helpers to do accounting at the call site. Simple
inlined allocation wrappers are converted directly into macros. More
complex allocators or allocators with documentation are converted into
_noprof versions and allocation hooks are added. This allows memory
allocation profiling mechanism to charge allocations to the callers
of these functions.
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
---
Changes since v1 [1]:
- Added explicit type casts in macro replacements to force type checks,
per Matthew Wilcox
- Expanded the changelog to explain the reasons codetags are used and
this change is neeed, per Jan Kara
[1] https://lore.kernel.org/all/20240404165404.3805498-1-surenb@google.com/
drivers/iommu/amd/amd_iommu.h | 5 ++--
fs/nfs/iostat.h | 5 +---
include/acpi/platform/aclinuxex.h | 19 +++++---------
include/asm-generic/pgalloc.h | 35 +++++++++++++++----------
include/crypto/hash.h | 7 ++---
include/crypto/internal/acompress.h | 5 ++--
include/crypto/skcipher.h | 7 ++---
include/linux/bpf.h | 33 ++++++-----------------
include/linux/bpfptr.h | 5 ++--
include/linux/dma-fence-chain.h | 6 ++---
include/linux/hid_bpf.h | 6 ++---
include/linux/jbd2.h | 12 +++------
include/linux/mm.h | 5 ++--
include/linux/mm_types.h | 5 ++--
include/linux/percpu.h | 3 +++
include/linux/ptr_ring.h | 28 +++++++++++---------
include/linux/skb_array.h | 19 ++++++++------
include/linux/skbuff.h | 20 ++++++--------
include/linux/skmsg.h | 8 +++---
include/linux/slab.h | 5 ++++
include/linux/sockptr.h | 10 ++++---
include/net/netlabel.h | 16 ++++++-----
include/net/netlink.h | 5 ++--
include/net/request_sock.h | 5 ++--
include/net/tcx.h | 5 ++--
net/sunrpc/auth_gss/auth_gss_internal.h | 6 +++--
26 files changed, 142 insertions(+), 143 deletions(-)
diff --git a/drivers/iommu/amd/amd_iommu.h b/drivers/iommu/amd/amd_iommu.h
index f482aab420f7..52575ba9a141 100644
--- a/drivers/iommu/amd/amd_iommu.h
+++ b/drivers/iommu/amd/amd_iommu.h
@@ -134,13 +134,14 @@ static inline int get_pci_sbdf_id(struct pci_dev *pdev)
return PCI_SEG_DEVID_TO_SBDF(seg, devid);
}
-static inline void *alloc_pgtable_page(int nid, gfp_t gfp)
+static inline void *alloc_pgtable_page_noprof(int nid, gfp_t gfp)
{
struct page *page;
- page = alloc_pages_node(nid, gfp | __GFP_ZERO, 0);
+ page = alloc_pages_node_noprof(nid, gfp | __GFP_ZERO, 0);
return page ? page_address(page) : NULL;
}
+#define alloc_pgtable_page(...) alloc_hooks(alloc_pgtable_page_noprof(__VA_ARGS__))
/*
* This must be called after device probe completes. During probe
diff --git a/fs/nfs/iostat.h b/fs/nfs/iostat.h
index 5aa776b5a3e7..b17a9eb9b148 100644
--- a/fs/nfs/iostat.h
+++ b/fs/nfs/iostat.h
@@ -46,10 +46,7 @@ static inline void nfs_add_stats(const struct inode *inode,
nfs_add_server_stats(NFS_SERVER(inode), stat, addend);
}
-static inline struct nfs_iostats __percpu *nfs_alloc_iostats(void)
-{
- return alloc_percpu(struct nfs_iostats);
-}
+#define nfs_alloc_iostats() alloc_percpu(struct nfs_iostats)
static inline void nfs_free_iostats(struct nfs_iostats __percpu *stats)
{
diff --git a/include/acpi/platform/aclinuxex.h b/include/acpi/platform/aclinuxex.h
index 600d4e2641da..62cac266a1c8 100644
--- a/include/acpi/platform/aclinuxex.h
+++ b/include/acpi/platform/aclinuxex.h
@@ -47,26 +47,19 @@ acpi_status acpi_os_terminate(void);
* However, boot has (system_state != SYSTEM_RUNNING)
* to quiet __might_sleep() in kmalloc() and resume does not.
*/
-static inline void *acpi_os_allocate(acpi_size size)
-{
- return kmalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
+#define acpi_os_allocate(_size) \
+ kmalloc(_size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL)
-static inline void *acpi_os_allocate_zeroed(acpi_size size)
-{
- return kzalloc(size, irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
+#define acpi_os_allocate_zeroed(_size) \
+ kzalloc(_size, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL)
static inline void acpi_os_free(void *memory)
{
kfree(memory);
}
-static inline void *acpi_os_acquire_object(acpi_cache_t * cache)
-{
- return kmem_cache_zalloc(cache,
- irqs_disabled()? GFP_ATOMIC : GFP_KERNEL);
-}
+#define acpi_os_acquire_object(_cache) \
+ kmem_cache_zalloc(_cache, irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL)
static inline acpi_thread_id acpi_os_get_thread_id(void)
{
diff --git a/include/asm-generic/pgalloc.h b/include/asm-generic/pgalloc.h
index 879e5f8aa5e9..7c48f5fbf8aa 100644
--- a/include/asm-generic/pgalloc.h
+++ b/include/asm-generic/pgalloc.h
@@ -16,15 +16,16 @@
*
* Return: pointer to the allocated memory or %NULL on error
*/
-static inline pte_t *__pte_alloc_one_kernel(struct mm_struct *mm)
+static inline pte_t *__pte_alloc_one_kernel_noprof(struct mm_struct *mm)
{
- struct ptdesc *ptdesc = pagetable_alloc(GFP_PGTABLE_KERNEL &
+ struct ptdesc *ptdesc = pagetable_alloc_noprof(GFP_PGTABLE_KERNEL &
~__GFP_HIGHMEM, 0);
if (!ptdesc)
return NULL;
return ptdesc_address(ptdesc);
}
+#define __pte_alloc_one_kernel(...) alloc_hooks(__pte_alloc_one_kernel_noprof(__VA_ARGS__))
#ifndef __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL
/**
@@ -33,10 +34,11 @@ static inline pte_t *__pte_alloc_one_kernel(struct mm_struct *mm)
*
* Return: pointer to the allocated memory or %NULL on error
*/
-static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm)
+static inline pte_t *pte_alloc_one_kernel_noprof(struct mm_struct *mm)
{
- return __pte_alloc_one_kernel(mm);
+ return __pte_alloc_one_kernel_noprof(mm);
}
+#define pte_alloc_one_kernel(...) alloc_hooks(pte_alloc_one_kernel_noprof(__VA_ARGS__))
#endif
/**
@@ -61,11 +63,11 @@ static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte)
*
* Return: `struct page` referencing the ptdesc or %NULL on error
*/
-static inline pgtable_t __pte_alloc_one(struct mm_struct *mm, gfp_t gfp)
+static inline pgtable_t __pte_alloc_one_noprof(struct mm_struct *mm, gfp_t gfp)
{
struct ptdesc *ptdesc;
- ptdesc = pagetable_alloc(gfp, 0);
+ ptdesc = pagetable_alloc_noprof(gfp, 0);
if (!ptdesc)
return NULL;
if (!pagetable_pte_ctor(ptdesc)) {
@@ -75,6 +77,7 @@ static inline pgtable_t __pte_alloc_one(struct mm_struct *mm, gfp_t gfp)
return ptdesc_page(ptdesc);
}
+#define __pte_alloc_one(...) alloc_hooks(__pte_alloc_one_noprof(__VA_ARGS__))
#ifndef __HAVE_ARCH_PTE_ALLOC_ONE
/**
@@ -85,10 +88,11 @@ static inline pgtable_t __pte_alloc_one(struct mm_struct *mm, gfp_t gfp)
*
* Return: `struct page` referencing the ptdesc or %NULL on error
*/
-static inline pgtable_t pte_alloc_one(struct mm_struct *mm)
+static inline pgtable_t pte_alloc_one_noprof(struct mm_struct *mm)
{
- return __pte_alloc_one(mm, GFP_PGTABLE_USER);
+ return __pte_alloc_one_noprof(mm, GFP_PGTABLE_USER);
}
+#define pte_alloc_one(...) alloc_hooks(pte_alloc_one_noprof(__VA_ARGS__))
#endif
/*
@@ -124,14 +128,14 @@ static inline void pte_free(struct mm_struct *mm, struct page *pte_page)
*
* Return: pointer to the allocated memory or %NULL on error
*/
-static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
+static inline pmd_t *pmd_alloc_one_noprof(struct mm_struct *mm, unsigned long addr)
{
struct ptdesc *ptdesc;
gfp_t gfp = GFP_PGTABLE_USER;
if (mm == &init_mm)
gfp = GFP_PGTABLE_KERNEL;
- ptdesc = pagetable_alloc(gfp, 0);
+ ptdesc = pagetable_alloc_noprof(gfp, 0);
if (!ptdesc)
return NULL;
if (!pagetable_pmd_ctor(ptdesc)) {
@@ -140,6 +144,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
}
return ptdesc_address(ptdesc);
}
+#define pmd_alloc_one(...) alloc_hooks(pmd_alloc_one_noprof(__VA_ARGS__))
#endif
#ifndef __HAVE_ARCH_PMD_FREE
@@ -157,7 +162,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
#if CONFIG_PGTABLE_LEVELS > 3
-static inline pud_t *__pud_alloc_one(struct mm_struct *mm, unsigned long addr)
+static inline pud_t *__pud_alloc_one_noprof(struct mm_struct *mm, unsigned long addr)
{
gfp_t gfp = GFP_PGTABLE_USER;
struct ptdesc *ptdesc;
@@ -166,13 +171,14 @@ static inline pud_t *__pud_alloc_one(struct mm_struct *mm, unsigned long addr)
gfp = GFP_PGTABLE_KERNEL;
gfp &= ~__GFP_HIGHMEM;
- ptdesc = pagetable_alloc(gfp, 0);
+ ptdesc = pagetable_alloc_noprof(gfp, 0);
if (!ptdesc)
return NULL;
pagetable_pud_ctor(ptdesc);
return ptdesc_address(ptdesc);
}
+#define __pud_alloc_one(...) alloc_hooks(__pud_alloc_one_noprof(__VA_ARGS__))
#ifndef __HAVE_ARCH_PUD_ALLOC_ONE
/**
@@ -184,10 +190,11 @@ static inline pud_t *__pud_alloc_one(struct mm_struct *mm, unsigned long addr)
*
* Return: pointer to the allocated memory or %NULL on error
*/
-static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
+static inline pud_t *pud_alloc_one_noprof(struct mm_struct *mm, unsigned long addr)
{
- return __pud_alloc_one(mm, addr);
+ return __pud_alloc_one_noprof(mm, addr);
}
+#define pud_alloc_one(...) alloc_hooks(pud_alloc_one_noprof(__VA_ARGS__))
#endif
static inline void __pud_free(struct mm_struct *mm, pud_t *pud)
diff --git a/include/crypto/hash.h b/include/crypto/hash.h
index 5d61f576cfc8..e5181cc9b7c5 100644
--- a/include/crypto/hash.h
+++ b/include/crypto/hash.h
@@ -578,19 +578,20 @@ static inline void ahash_request_set_tfm(struct ahash_request *req,
*
* Return: allocated request handle in case of success, or NULL if out of memory
*/
-static inline struct ahash_request *ahash_request_alloc(
+static inline struct ahash_request *ahash_request_alloc_noprof(
struct crypto_ahash *tfm, gfp_t gfp)
{
struct ahash_request *req;
- req = kmalloc(sizeof(struct ahash_request) +
- crypto_ahash_reqsize(tfm), gfp);
+ req = kmalloc_noprof(sizeof(struct ahash_request) +
+ crypto_ahash_reqsize(tfm), gfp);
if (likely(req))
ahash_request_set_tfm(req, tfm);
return req;
}
+#define ahash_request_alloc(...) alloc_hooks(ahash_request_alloc_noprof(__VA_ARGS__))
/**
* ahash_request_free() - zeroize and free the request data structure
diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h
index 4ac46bafba9d..2a67793f52ad 100644
--- a/include/crypto/internal/acompress.h
+++ b/include/crypto/internal/acompress.h
@@ -69,15 +69,16 @@ static inline void acomp_request_complete(struct acomp_req *req,
crypto_request_complete(&req->base, err);
}
-static inline struct acomp_req *__acomp_request_alloc(struct crypto_acomp *tfm)
+static inline struct acomp_req *__acomp_request_alloc_noprof(struct crypto_acomp *tfm)
{
struct acomp_req *req;
- req = kzalloc(sizeof(*req) + crypto_acomp_reqsize(tfm), GFP_KERNEL);
+ req = kzalloc_noprof(sizeof(*req) + crypto_acomp_reqsize(tfm), GFP_KERNEL);
if (likely(req))
acomp_request_set_tfm(req, tfm);
return req;
}
+#define __acomp_request_alloc(...) alloc_hooks(__acomp_request_alloc_noprof(__VA_ARGS__))
static inline void __acomp_request_free(struct acomp_req *req)
{
diff --git a/include/crypto/skcipher.h b/include/crypto/skcipher.h
index c8857d7bdb37..6c5330e316b0 100644
--- a/include/crypto/skcipher.h
+++ b/include/crypto/skcipher.h
@@ -861,19 +861,20 @@ static inline struct skcipher_request *skcipher_request_cast(
*
* Return: allocated request handle in case of success, or NULL if out of memory
*/
-static inline struct skcipher_request *skcipher_request_alloc(
+static inline struct skcipher_request *skcipher_request_alloc_noprof(
struct crypto_skcipher *tfm, gfp_t gfp)
{
struct skcipher_request *req;
- req = kmalloc(sizeof(struct skcipher_request) +
- crypto_skcipher_reqsize(tfm), gfp);
+ req = kmalloc_noprof(sizeof(struct skcipher_request) +
+ crypto_skcipher_reqsize(tfm), gfp);
if (likely(req))
skcipher_request_set_tfm(req, tfm);
return req;
}
+#define skcipher_request_alloc(...) alloc_hooks(skcipher_request_alloc_noprof(__VA_ARGS__))
/**
* skcipher_request_free() - zeroize and free request data structure
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 4f20f62f9d63..a63fa48ab80d 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -2230,31 +2230,14 @@ void *bpf_map_kvcalloc(struct bpf_map *map, size_t n, size_t size,
void __percpu *bpf_map_alloc_percpu(const struct bpf_map *map, size_t size,
size_t align, gfp_t flags);
#else
-static inline void *
-bpf_map_kmalloc_node(const struct bpf_map *map, size_t size, gfp_t flags,
- int node)
-{
- return kmalloc_node(size, flags, node);
-}
-
-static inline void *
-bpf_map_kzalloc(const struct bpf_map *map, size_t size, gfp_t flags)
-{
- return kzalloc(size, flags);
-}
-
-static inline void *
-bpf_map_kvcalloc(struct bpf_map *map, size_t n, size_t size, gfp_t flags)
-{
- return kvcalloc(n, size, flags);
-}
-
-static inline void __percpu *
-bpf_map_alloc_percpu(const struct bpf_map *map, size_t size, size_t align,
- gfp_t flags)
-{
- return __alloc_percpu_gfp(size, align, flags);
-}
+#define bpf_map_kmalloc_node(_map, _size, _flags, _node) \
+ kmalloc_node(_size, _flags, _node)
+#define bpf_map_kzalloc(_map, _size, _flags) \
+ kzalloc(_size, _flags)
+#define bpf_map_kvcalloc(_map, _n, _size, _flags) \
+ kvcalloc(_n, _size, _flags)
+#define bpf_map_alloc_percpu(_map, _size, _align, _flags) \
+ __alloc_percpu_gfp(_size, _align, _flags)
#endif
static inline int
diff --git a/include/linux/bpfptr.h b/include/linux/bpfptr.h
index 79b2f78eec1a..1af241525a17 100644
--- a/include/linux/bpfptr.h
+++ b/include/linux/bpfptr.h
@@ -65,9 +65,9 @@ static inline int copy_to_bpfptr_offset(bpfptr_t dst, size_t offset,
return copy_to_sockptr_offset((sockptr_t) dst, offset, src, size);
}
-static inline void *kvmemdup_bpfptr(bpfptr_t src, size_t len)
+static inline void *kvmemdup_bpfptr_noprof(bpfptr_t src, size_t len)
{
- void *p = kvmalloc(len, GFP_USER | __GFP_NOWARN);
+ void *p = kvmalloc_noprof(len, GFP_USER | __GFP_NOWARN);
if (!p)
return ERR_PTR(-ENOMEM);
@@ -77,6 +77,7 @@ static inline void *kvmemdup_bpfptr(bpfptr_t src, size_t len)
}
return p;
}
+#define kvmemdup_bpfptr(...) alloc_hooks(kvmemdup_bpfptr_noprof(__VA_ARGS__))
static inline long strncpy_from_bpfptr(char *dst, bpfptr_t src, size_t count)
{
diff --git a/include/linux/dma-fence-chain.h b/include/linux/dma-fence-chain.h
index 4bdf0b96da28..ad9e2506c2f4 100644
--- a/include/linux/dma-fence-chain.h
+++ b/include/linux/dma-fence-chain.h
@@ -86,10 +86,8 @@ dma_fence_chain_contained(struct dma_fence *fence)
*
* Returns a new struct dma_fence_chain object or NULL on failure.
*/
-static inline struct dma_fence_chain *dma_fence_chain_alloc(void)
-{
- return kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL);
-};
+#define dma_fence_chain_alloc() \
+ ((struct dma_fence_chain *)kmalloc(sizeof(struct dma_fence_chain), GFP_KERNEL))
/**
* dma_fence_chain_free
diff --git a/include/linux/hid_bpf.h b/include/linux/hid_bpf.h
index 7118ac28d468..ca70eeb6393e 100644
--- a/include/linux/hid_bpf.h
+++ b/include/linux/hid_bpf.h
@@ -149,10 +149,8 @@ static inline int hid_bpf_connect_device(struct hid_device *hdev) { return 0; }
static inline void hid_bpf_disconnect_device(struct hid_device *hdev) {}
static inline void hid_bpf_destroy_device(struct hid_device *hid) {}
static inline void hid_bpf_device_init(struct hid_device *hid) {}
-static inline u8 *call_hid_bpf_rdesc_fixup(struct hid_device *hdev, u8 *rdesc, unsigned int *size)
-{
- return kmemdup(rdesc, *size, GFP_KERNEL);
-}
+#define call_hid_bpf_rdesc_fixup(_hdev, _rdesc, _size) \
+ ((u8 *)kmemdup(_rdesc, *(_size), GFP_KERNEL))
#endif /* CONFIG_HID_BPF */
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 971f3e826e15..9512fe332668 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -1586,10 +1586,8 @@ void jbd2_journal_put_journal_head(struct journal_head *jh);
*/
extern struct kmem_cache *jbd2_handle_cache;
-static inline handle_t *jbd2_alloc_handle(gfp_t gfp_flags)
-{
- return kmem_cache_zalloc(jbd2_handle_cache, gfp_flags);
-}
+#define jbd2_alloc_handle(_gfp_flags) \
+ ((handle_t *)kmem_cache_zalloc(jbd2_handle_cache, _gfp_flags))
static inline void jbd2_free_handle(handle_t *handle)
{
@@ -1602,10 +1600,8 @@ static inline void jbd2_free_handle(handle_t *handle)
*/
extern struct kmem_cache *jbd2_inode_cache;
-static inline struct jbd2_inode *jbd2_alloc_inode(gfp_t gfp_flags)
-{
- return kmem_cache_alloc(jbd2_inode_cache, gfp_flags);
-}
+#define jbd2_alloc_inode(_gfp_flags) \
+ ((struct jbd2_inode *)kmem_cache_alloc(jbd2_inode_cache, _gfp_flags))
static inline void jbd2_free_inode(struct jbd2_inode *jinode)
{
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 07c73451d42f..d261e45bb29b 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2899,12 +2899,13 @@ static inline bool pagetable_is_reserved(struct ptdesc *pt)
*
* Return: The ptdesc describing the allocated page tables.
*/
-static inline struct ptdesc *pagetable_alloc(gfp_t gfp, unsigned int order)
+static inline struct ptdesc *pagetable_alloc_noprof(gfp_t gfp, unsigned int order)
{
- struct page *page = alloc_pages(gfp | __GFP_COMP, order);
+ struct page *page = alloc_pages_noprof(gfp | __GFP_COMP, order);
return page_ptdesc(page);
}
+#define pagetable_alloc(...) alloc_hooks(pagetable_alloc_noprof(__VA_ARGS__))
/**
* pagetable_free - Free pagetables
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index c432add95913..db0adf5721cc 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -1167,14 +1167,15 @@ static inline void mm_init_cid(struct mm_struct *mm)
cpumask_clear(mm_cidmask(mm));
}
-static inline int mm_alloc_cid(struct mm_struct *mm)
+static inline int mm_alloc_cid_noprof(struct mm_struct *mm)
{
- mm->pcpu_cid = alloc_percpu(struct mm_cid);
+ mm->pcpu_cid = alloc_percpu_noprof(struct mm_cid);
if (!mm->pcpu_cid)
return -ENOMEM;
mm_init_cid(mm);
return 0;
}
+#define mm_alloc_cid(...) alloc_hooks(mm_alloc_cid_noprof(__VA_ARGS__))
static inline void mm_destroy_cid(struct mm_struct *mm)
{
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index 13a82f11e4fd..03053de557cf 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -151,6 +151,9 @@ extern size_t pcpu_alloc_size(void __percpu *__pdata);
#define alloc_percpu(type) \
(typeof(type) __percpu *)__alloc_percpu(sizeof(type), \
__alignof__(type))
+#define alloc_percpu_noprof(type) \
+ ((typeof(type) __percpu *)pcpu_alloc_noprof(sizeof(type), \
+ __alignof__(type), false, GFP_KERNEL))
extern void free_percpu(void __percpu *__pdata);
diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h
index 808f9d3ee546..fd037c127bb0 100644
--- a/include/linux/ptr_ring.h
+++ b/include/linux/ptr_ring.h
@@ -464,11 +464,11 @@ static inline int ptr_ring_consume_batched_bh(struct ptr_ring *r,
/* Not all gfp_t flags (besides GFP_KERNEL) are allowed. See
* documentation for vmalloc for which of them are legal.
*/
-static inline void **__ptr_ring_init_queue_alloc(unsigned int size, gfp_t gfp)
+static inline void **__ptr_ring_init_queue_alloc_noprof(unsigned int size, gfp_t gfp)
{
if (size > KMALLOC_MAX_SIZE / sizeof(void *))
return NULL;
- return kvmalloc_array(size, sizeof(void *), gfp | __GFP_ZERO);
+ return kvmalloc_array_noprof(size, sizeof(void *), gfp | __GFP_ZERO);
}
static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
@@ -484,9 +484,9 @@ static inline void __ptr_ring_set_size(struct ptr_ring *r, int size)
r->batch = 1;
}
-static inline int ptr_ring_init(struct ptr_ring *r, int size, gfp_t gfp)
+static inline int ptr_ring_init_noprof(struct ptr_ring *r, int size, gfp_t gfp)
{
- r->queue = __ptr_ring_init_queue_alloc(size, gfp);
+ r->queue = __ptr_ring_init_queue_alloc_noprof(size, gfp);
if (!r->queue)
return -ENOMEM;
@@ -497,6 +497,7 @@ static inline int ptr_ring_init(struct ptr_ring *r, int size, gfp_t gfp)
return 0;
}
+#define ptr_ring_init(...) alloc_hooks(ptr_ring_init_noprof(__VA_ARGS__))
/*
* Return entries into ring. Destroy entries that don't fit.
@@ -587,11 +588,11 @@ static inline void **__ptr_ring_swap_queue(struct ptr_ring *r, void **queue,
* In particular if you consume ring in interrupt or BH context, you must
* disable interrupts/BH when doing so.
*/
-static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp,
+static inline int ptr_ring_resize_noprof(struct ptr_ring *r, int size, gfp_t gfp,
void (*destroy)(void *))
{
unsigned long flags;
- void **queue = __ptr_ring_init_queue_alloc(size, gfp);
+ void **queue = __ptr_ring_init_queue_alloc_noprof(size, gfp);
void **old;
if (!queue)
@@ -609,6 +610,7 @@ static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp,
return 0;
}
+#define ptr_ring_resize(...) alloc_hooks(ptr_ring_resize_noprof(__VA_ARGS__))
/*
* Note: producer lock is nested within consumer lock, so if you
@@ -616,21 +618,21 @@ static inline int ptr_ring_resize(struct ptr_ring *r, int size, gfp_t gfp,
* In particular if you consume ring in interrupt or BH context, you must
* disable interrupts/BH when doing so.
*/
-static inline int ptr_ring_resize_multiple(struct ptr_ring **rings,
- unsigned int nrings,
- int size,
- gfp_t gfp, void (*destroy)(void *))
+static inline int ptr_ring_resize_multiple_noprof(struct ptr_ring **rings,
+ unsigned int nrings,
+ int size,
+ gfp_t gfp, void (*destroy)(void *))
{
unsigned long flags;
void ***queues;
int i;
- queues = kmalloc_array(nrings, sizeof(*queues), gfp);
+ queues = kmalloc_array_noprof(nrings, sizeof(*queues), gfp);
if (!queues)
goto noqueues;
for (i = 0; i < nrings; ++i) {
- queues[i] = __ptr_ring_init_queue_alloc(size, gfp);
+ queues[i] = __ptr_ring_init_queue_alloc_noprof(size, gfp);
if (!queues[i])
goto nomem;
}
@@ -660,6 +662,8 @@ static inline int ptr_ring_resize_multiple(struct ptr_ring **rings,
noqueues:
return -ENOMEM;
}
+#define ptr_ring_resize_multiple(...) \
+ alloc_hooks(ptr_ring_resize_multiple_noprof(__VA_ARGS__))
static inline void ptr_ring_cleanup(struct ptr_ring *r, void (*destroy)(void *))
{
diff --git a/include/linux/skb_array.h b/include/linux/skb_array.h
index e2d45b7cb619..926496c9cc9c 100644
--- a/include/linux/skb_array.h
+++ b/include/linux/skb_array.h
@@ -177,10 +177,11 @@ static inline int skb_array_peek_len_any(struct skb_array *a)
return PTR_RING_PEEK_CALL_ANY(&a->ring, __skb_array_len_with_tag);
}
-static inline int skb_array_init(struct skb_array *a, int size, gfp_t gfp)
+static inline int skb_array_init_noprof(struct skb_array *a, int size, gfp_t gfp)
{
- return ptr_ring_init(&a->ring, size, gfp);
+ return ptr_ring_init_noprof(&a->ring, size, gfp);
}
+#define skb_array_init(...) alloc_hooks(skb_array_init_noprof(__VA_ARGS__))
static void __skb_array_destroy_skb(void *ptr)
{
@@ -198,15 +199,17 @@ static inline int skb_array_resize(struct skb_array *a, int size, gfp_t gfp)
return ptr_ring_resize(&a->ring, size, gfp, __skb_array_destroy_skb);
}
-static inline int skb_array_resize_multiple(struct skb_array **rings,
- int nrings, unsigned int size,
- gfp_t gfp)
+static inline int skb_array_resize_multiple_noprof(struct skb_array **rings,
+ int nrings, unsigned int size,
+ gfp_t gfp)
{
BUILD_BUG_ON(offsetof(struct skb_array, ring));
- return ptr_ring_resize_multiple((struct ptr_ring **)rings,
- nrings, size, gfp,
- __skb_array_destroy_skb);
+ return ptr_ring_resize_multiple_noprof((struct ptr_ring **)rings,
+ nrings, size, gfp,
+ __skb_array_destroy_skb);
}
+#define skb_array_resize_multiple(...) \
+ alloc_hooks(skb_array_resize_multiple_noprof(__VA_ARGS__))
static inline void skb_array_cleanup(struct skb_array *a)
{
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 9d24aec064e8..b72920c9887b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3371,7 +3371,7 @@ void __napi_kfree_skb(struct sk_buff *skb, enum skb_drop_reason reason);
*
* %NULL is returned if there is no free memory.
*/
-static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
+static inline struct page *__dev_alloc_pages_noprof(gfp_t gfp_mask,
unsigned int order)
{
/* This piece of code contains several assumptions.
@@ -3384,13 +3384,11 @@ static inline struct page *__dev_alloc_pages(gfp_t gfp_mask,
*/
gfp_mask |= __GFP_COMP | __GFP_MEMALLOC;
- return alloc_pages_node(NUMA_NO_NODE, gfp_mask, order);
+ return alloc_pages_node_noprof(NUMA_NO_NODE, gfp_mask, order);
}
+#define __dev_alloc_pages(...) alloc_hooks(__dev_alloc_pages_noprof(__VA_ARGS__))
-static inline struct page *dev_alloc_pages(unsigned int order)
-{
- return __dev_alloc_pages(GFP_ATOMIC | __GFP_NOWARN, order);
-}
+#define dev_alloc_pages(_order) __dev_alloc_pages(GFP_ATOMIC | __GFP_NOWARN, _order)
/**
* __dev_alloc_page - allocate a page for network Rx
@@ -3400,15 +3398,13 @@ static inline struct page *dev_alloc_pages(unsigned int order)
*
* %NULL is returned if there is no free memory.
*/
-static inline struct page *__dev_alloc_page(gfp_t gfp_mask)
+static inline struct page *__dev_alloc_page_noprof(gfp_t gfp_mask)
{
- return __dev_alloc_pages(gfp_mask, 0);
+ return __dev_alloc_pages_noprof(gfp_mask, 0);
}
+#define __dev_alloc_page(...) alloc_hooks(__dev_alloc_page_noprof(__VA_ARGS__))
-static inline struct page *dev_alloc_page(void)
-{
- return dev_alloc_pages(0);
-}
+#define dev_alloc_page() dev_alloc_pages(0)
/**
* dev_page_is_reusable - check whether a page can be reused for network Rx
diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h
index e65ec3fd2799..78efc5b20284 100644
--- a/include/linux/skmsg.h
+++ b/include/linux/skmsg.h
@@ -410,11 +410,9 @@ void sk_psock_stop_verdict(struct sock *sk, struct sk_psock *psock);
int sk_psock_msg_verdict(struct sock *sk, struct sk_psock *psock,
struct sk_msg *msg);
-static inline struct sk_psock_link *sk_psock_init_link(void)
-{
- return kzalloc(sizeof(struct sk_psock_link),
- GFP_ATOMIC | __GFP_NOWARN);
-}
+#define sk_psock_init_link() \
+ ((struct sk_psock_link *)kzalloc(sizeof(struct sk_psock_link), \
+ GFP_ATOMIC | __GFP_NOWARN))
static inline void sk_psock_free_link(struct sk_psock_link *link)
{
diff --git a/include/linux/slab.h b/include/linux/slab.h
index c0be1cd03cf6..4cc37ef22aae 100644
--- a/include/linux/slab.h
+++ b/include/linux/slab.h
@@ -744,6 +744,9 @@ void *kmalloc_node_track_caller_noprof(size_t size, gfp_t flags, int node,
*/
#define kmalloc_track_caller(...) kmalloc_node_track_caller(__VA_ARGS__, NUMA_NO_NODE)
+#define kmalloc_track_caller_noprof(...) \
+ kmalloc_node_track_caller_noprof(__VA_ARGS__, NUMA_NO_NODE, _RET_IP_)
+
static inline __alloc_size(1, 2) void *kmalloc_array_node_noprof(size_t n, size_t size, gfp_t flags,
int node)
{
@@ -781,6 +784,7 @@ extern void *kvmalloc_node_noprof(size_t size, gfp_t flags, int node) __alloc_si
#define kvmalloc_node(...) alloc_hooks(kvmalloc_node_noprof(__VA_ARGS__))
#define kvmalloc(_size, _flags) kvmalloc_node(_size, _flags, NUMA_NO_NODE)
+#define kvmalloc_noprof(_size, _flags) kvmalloc_node_noprof(_size, _flags, NUMA_NO_NODE)
#define kvzalloc(_size, _flags) kvmalloc(_size, _flags|__GFP_ZERO)
#define kvzalloc_node(_size, _flags, _node) kvmalloc_node(_size, _flags|__GFP_ZERO, _node)
@@ -797,6 +801,7 @@ static inline __alloc_size(1, 2) void *kvmalloc_array_noprof(size_t n, size_t si
#define kvmalloc_array(...) alloc_hooks(kvmalloc_array_noprof(__VA_ARGS__))
#define kvcalloc(_n, _size, _flags) kvmalloc_array(_n, _size, _flags|__GFP_ZERO)
+#define kvcalloc_noprof(_n, _size, _flags) kvmalloc_array_noprof(_n, _size, _flags|__GFP_ZERO)
extern void *kvrealloc_noprof(const void *p, size_t oldsize, size_t newsize, gfp_t flags)
__realloc_size(3);
diff --git a/include/linux/sockptr.h b/include/linux/sockptr.h
index 307961b41541..ba703b22e7d8 100644
--- a/include/linux/sockptr.h
+++ b/include/linux/sockptr.h
@@ -92,9 +92,9 @@ static inline int copy_to_sockptr(sockptr_t dst, const void *src, size_t size)
return copy_to_sockptr_offset(dst, 0, src, size);
}
-static inline void *memdup_sockptr(sockptr_t src, size_t len)
+static inline void *memdup_sockptr_noprof(sockptr_t src, size_t len)
{
- void *p = kmalloc_track_caller(len, GFP_USER | __GFP_NOWARN);
+ void *p = kmalloc_track_caller_noprof(len, GFP_USER | __GFP_NOWARN);
if (!p)
return ERR_PTR(-ENOMEM);
@@ -104,10 +104,11 @@ static inline void *memdup_sockptr(sockptr_t src, size_t len)
}
return p;
}
+#define memdup_sockptr(...) alloc_hooks(memdup_sockptr_noprof(__VA_ARGS__))
-static inline void *memdup_sockptr_nul(sockptr_t src, size_t len)
+static inline void *memdup_sockptr_nul_noprof(sockptr_t src, size_t len)
{
- char *p = kmalloc_track_caller(len + 1, GFP_KERNEL);
+ char *p = kmalloc_track_caller_noprof(len + 1, GFP_KERNEL);
if (!p)
return ERR_PTR(-ENOMEM);
@@ -118,6 +119,7 @@ static inline void *memdup_sockptr_nul(sockptr_t src, size_t len)
p[len] = '\0';
return p;
}
+#define memdup_sockptr_nul(...) alloc_hooks(memdup_sockptr_nul_noprof(__VA_ARGS__))
static inline long strncpy_from_sockptr(char *dst, sockptr_t src, size_t count)
{
diff --git a/include/net/netlabel.h b/include/net/netlabel.h
index f3ab0b8a4b18..c31bd96dafdb 100644
--- a/include/net/netlabel.h
+++ b/include/net/netlabel.h
@@ -274,15 +274,17 @@ struct netlbl_calipso_ops {
* on success, NULL on failure.
*
*/
-static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc(gfp_t flags)
+static inline struct netlbl_lsm_cache *netlbl_secattr_cache_alloc_noprof(gfp_t flags)
{
struct netlbl_lsm_cache *cache;
- cache = kzalloc(sizeof(*cache), flags);
+ cache = kzalloc_noprof(sizeof(*cache), flags);
if (cache)
refcount_set(&cache->refcount, 1);
return cache;
}
+#define netlbl_secattr_cache_alloc(...) \
+ alloc_hooks(netlbl_secattr_cache_alloc_noprof(__VA_ARGS__))
/**
* netlbl_secattr_cache_free - Frees a netlbl_lsm_cache struct
@@ -311,10 +313,11 @@ static inline void netlbl_secattr_cache_free(struct netlbl_lsm_cache *cache)
* on failure.
*
*/
-static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc(gfp_t flags)
+static inline struct netlbl_lsm_catmap *netlbl_catmap_alloc_noprof(gfp_t flags)
{
- return kzalloc(sizeof(struct netlbl_lsm_catmap), flags);
+ return kzalloc_noprof(sizeof(struct netlbl_lsm_catmap), flags);
}
+#define netlbl_catmap_alloc(...) alloc_hooks(netlbl_catmap_alloc_noprof(__VA_ARGS__))
/**
* netlbl_catmap_free - Free a LSM secattr catmap
@@ -376,10 +379,11 @@ static inline void netlbl_secattr_destroy(struct netlbl_lsm_secattr *secattr)
* pointer on success, or NULL on failure.
*
*/
-static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc(gfp_t flags)
+static inline struct netlbl_lsm_secattr *netlbl_secattr_alloc_noprof(gfp_t flags)
{
- return kzalloc(sizeof(struct netlbl_lsm_secattr), flags);
+ return kzalloc_noprof(sizeof(struct netlbl_lsm_secattr), flags);
}
+#define netlbl_secattr_alloc(...) alloc_hooks(netlbl_secattr_alloc_noprof(__VA_ARGS__))
/**
* netlbl_secattr_free - Frees a netlbl_lsm_secattr struct
diff --git a/include/net/netlink.h b/include/net/netlink.h
index c19ff921b661..972b5484fa6f 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -1891,10 +1891,11 @@ static inline struct nla_bitfield32 nla_get_bitfield32(const struct nlattr *nla)
* @src: netlink attribute to duplicate from
* @gfp: GFP mask
*/
-static inline void *nla_memdup(const struct nlattr *src, gfp_t gfp)
+static inline void *nla_memdup_noprof(const struct nlattr *src, gfp_t gfp)
{
- return kmemdup(nla_data(src), nla_len(src), gfp);
+ return kmemdup_noprof(nla_data(src), nla_len(src), gfp);
}
+#define nla_memdup(...) alloc_hooks(nla_memdup_noprof(__VA_ARGS__))
/**
* nla_nest_start_noflag - Start a new level of nested attributes
diff --git a/include/net/request_sock.h b/include/net/request_sock.h
index 004e651e6067..29495c331d20 100644
--- a/include/net/request_sock.h
+++ b/include/net/request_sock.h
@@ -127,12 +127,12 @@ static inline struct sock *skb_steal_sock(struct sk_buff *skb,
}
static inline struct request_sock *
-reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener,
+reqsk_alloc_noprof(const struct request_sock_ops *ops, struct sock *sk_listener,
bool attach_listener)
{
struct request_sock *req;
- req = kmem_cache_alloc(ops->slab, GFP_ATOMIC | __GFP_NOWARN);
+ req = kmem_cache_alloc_noprof(ops->slab, GFP_ATOMIC | __GFP_NOWARN);
if (!req)
return NULL;
req->rsk_listener = NULL;
@@ -157,6 +157,7 @@ reqsk_alloc(const struct request_sock_ops *ops, struct sock *sk_listener,
return req;
}
+#define reqsk_alloc(...) alloc_hooks(reqsk_alloc_noprof(__VA_ARGS__))
static inline void __reqsk_free(struct request_sock *req)
{
diff --git a/include/net/tcx.h b/include/net/tcx.h
index 04be9377785d..72a3e75e539f 100644
--- a/include/net/tcx.h
+++ b/include/net/tcx.h
@@ -75,9 +75,9 @@ tcx_entry_fetch(struct net_device *dev, bool ingress)
return rcu_dereference_rtnl(dev->tcx_egress);
}
-static inline struct bpf_mprog_entry *tcx_entry_create(void)
+static inline struct bpf_mprog_entry *tcx_entry_create_noprof(void)
{
- struct tcx_entry *tcx = kzalloc(sizeof(*tcx), GFP_KERNEL);
+ struct tcx_entry *tcx = kzalloc_noprof(sizeof(*tcx), GFP_KERNEL);
if (tcx) {
bpf_mprog_bundle_init(&tcx->bundle);
@@ -85,6 +85,7 @@ static inline struct bpf_mprog_entry *tcx_entry_create(void)
}
return NULL;
}
+#define tcx_entry_create(...) alloc_hooks(tcx_entry_create_noprof(__VA_ARGS__))
static inline void tcx_entry_free(struct bpf_mprog_entry *entry)
{
diff --git a/net/sunrpc/auth_gss/auth_gss_internal.h b/net/sunrpc/auth_gss/auth_gss_internal.h
index c53b329092d4..4ebc1b7043d9 100644
--- a/net/sunrpc/auth_gss/auth_gss_internal.h
+++ b/net/sunrpc/auth_gss/auth_gss_internal.h
@@ -23,7 +23,7 @@ simple_get_bytes(const void *p, const void *end, void *res, size_t len)
}
static inline const void *
-simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
+simple_get_netobj_noprof(const void *p, const void *end, struct xdr_netobj *dest)
{
const void *q;
unsigned int len;
@@ -35,7 +35,7 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
if (unlikely(q > end || q < p))
return ERR_PTR(-EFAULT);
if (len) {
- dest->data = kmemdup(p, len, GFP_KERNEL);
+ dest->data = kmemdup_noprof(p, len, GFP_KERNEL);
if (unlikely(dest->data == NULL))
return ERR_PTR(-ENOMEM);
} else
@@ -43,3 +43,5 @@ simple_get_netobj(const void *p, const void *end, struct xdr_netobj *dest)
dest->len = len;
return q;
}
+
+#define simple_get_netobj(...) alloc_hooks(simple_get_netobj_noprof(__VA_ARGS__))
base-commit: 3aec6b2b34e219898883d1e9ea7e911b4d3762a9
--
2.44.0.683.g7961c838ac-goog
^ permalink raw reply related
* Re: [syzbot] [input?] WARNING in bcm5974_start_traffic/usb_submit_urb (2)
From: Javier Carrasco @ 2024-04-15 6:32 UTC (permalink / raw)
To: syzbot, dmitry.torokhov, linux-input, linux-kernel, rydberg,
syzkaller-bugs
In-Reply-To: <0000000000008acb1e061618e68e@google.com>
On 4/15/24 03:54, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: fec50db7033e Linux 6.9-rc3
> git tree: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
> console output: https://syzkaller.appspot.com/x/log.txt?x=14439bd3180000
> kernel config: https://syzkaller.appspot.com/x/.config?x=560f5db1d0b3f6d0
> dashboard link: https://syzkaller.appspot.com/bug?extid=b064b5599f18f7ebb1e1
> compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
> userspace arch: arm64
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11c2c5bd180000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13cbbf5b180000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/ab4d6cae2eca/disk-fec50db7.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/b67542cc5860/vmlinux-fec50db7.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/3eeebb470b79/Image-fec50db7.gz.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+b064b5599f18f7ebb1e1@syzkaller.appspotmail.com
>
> ------------[ cut here ]------------
> usb 1-1: BOGUS urb xfer, pipe 1 != type 3
> WARNING: CPU: 0 PID: 6237 at drivers/usb/core/urb.c:504 usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
> Modules linked in:
> CPU: 0 PID: 6237 Comm: udevd Not tainted 6.9.0-rc3-syzkaller-gfec50db7033e #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
> pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> pc : usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
> lr : usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
> sp : ffff80009f8b73b0
> x29: ffff80009f8b73f0 x28: ffff0000d4fee000 x27: 0000000000000001
> x26: ffff80008c6919e8 x25: ffff0000c8bd1fe0 x24: ffff0000c1d45a50
> x23: ffff80008c698500 x22: dfff800000000000 x21: 0000000000000002
> x20: 0000000000000cc0 x19: ffff0000c1d45a00 x18: 0000000000000008
> x17: 0000000000000000 x16: ffff80008ae6d1bc x15: 0000000000000001
> x14: 1fffe000367b9a02 x13: 0000000000000000 x12: 0000000000000000
> x11: 0000000000000002 x10: 0000000000ff0100 x9 : b1573c5f9bab7600
> x8 : b1573c5f9bab7600 x7 : 0000000000000001 x6 : 0000000000000001
> x5 : ffff80009f8b6b18 x4 : ffff80008ef65000 x3 : ffff8000805e9200
> x2 : 0000000000000001 x1 : 0000000100000000 x0 : 0000000000000000
> Call trace:
> usb_submit_urb+0xa00/0x1434 drivers/usb/core/urb.c:503
> bcm5974_start_traffic+0xe0/0x154 drivers/input/mouse/bcm5974.c:799
> bcm5974_open+0x98/0x134 drivers/input/mouse/bcm5974.c:839
> input_open_device+0x170/0x29c drivers/input/input.c:654
> evdev_open_device drivers/input/evdev.c:400 [inline]
> evdev_open+0x308/0x4b4 drivers/input/evdev.c:487
> chrdev_open+0x3c8/0x4dc fs/char_dev.c:414
> do_dentry_open+0x778/0x12b4 fs/open.c:955
> vfs_open+0x7c/0x90 fs/open.c:1089
> do_open fs/namei.c:3642 [inline]
> path_openat+0x1f6c/0x2830 fs/namei.c:3799
> do_filp_open+0x1bc/0x3cc fs/namei.c:3826
> do_sys_openat2+0x124/0x1b8 fs/open.c:1406
> do_sys_open fs/open.c:1421 [inline]
> __do_sys_openat fs/open.c:1437 [inline]
> __se_sys_openat fs/open.c:1432 [inline]
> __arm64_sys_openat+0x1f0/0x240 fs/open.c:1432
> __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
> invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
> el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:133
> do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:152
> el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
> el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
> el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598
> irq event stamp: 5626
> hardirqs last enabled at (5625): [<ffff8000803749b0>] __up_console_sem kernel/printk/printk.c:341 [inline]
> hardirqs last enabled at (5625): [<ffff8000803749b0>] __console_unlock kernel/printk/printk.c:2731 [inline]
> hardirqs last enabled at (5625): [<ffff8000803749b0>] console_unlock+0x17c/0x3d4 kernel/printk/printk.c:3050
> hardirqs last disabled at (5626): [<ffff80008ae68608>] el1_dbg+0x24/0x80 arch/arm64/kernel/entry-common.c:470
> softirqs last enabled at (2362): [<ffff800080031848>] local_bh_enable+0x10/0x34 include/linux/bottom_half.h:32
> softirqs last disabled at (2360): [<ffff800080031814>] local_bh_disable+0x10/0x34 include/linux/bottom_half.h:19
> ---[ end trace 0000000000000000 ]---
>
>
> ---
> This report is generated by a bot. It may contain errors.
> See https://goo.gl/tpsmEJ for more information about syzbot.
> syzbot engineers can be reached at syzkaller@googlegroups.com.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
>
> If the report is already addressed, let syzbot know by replying with:
> #syz fix: exact-commit-title
>
> If you want syzbot to run the reproducer, reply with:
> #syz test: git://repo/address.git branch-or-commit-hash
> If you attach or paste a git patch, syzbot will apply it before testing.
>
> If you want to overwrite report's subsystems, reply with:
> #syz set subsystems: new-subsystem
> (See the list of subsystem names on the web dashboard)
>
> If the report is a duplicate of another one, reply with:
> #syz dup: exact-subject-of-another-report
>
> If you want to undo deduplication, reply with:
> #syz undup
>
This is a known bug in the bcm5974 driver that was fixed with commit
2b9c3eb32a69 ("Input: bcm5974 - check endpoint type before starting
traffic").
The fix had to be reverted due to a more severe bug that was hidden by
this one and caused a regression: the driver makes use of endpoints that
belong to interfaces it did not bind to (see discussion here [1]). In a
nutshell, any check to make sure that the endpoint belongs to a bound
interface will fail.
In order to apply the fix for the bug syzbot found again, the
inteface/endpoint issue must be solved first, making sure that the
driver binds to the right interfaces.
Link: https://lore.kernel.org/87sf161jjc.wl-tiwai@suse.de/ [1]
Best regards,
Javier Carrasco
^ permalink raw reply
* Re: [PATCH 00/18] backlight: Constify lcd_ops
From: Thomas Zimmermann @ 2024-04-15 6:56 UTC (permalink / raw)
To: Krzysztof Kozlowski, Lee Jones, Daniel Thompson, Jingoo Han,
Helge Deller, Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-0-9b37fcbf546a@kernel.org>
Hi
for patches 16, 17 and 18:
Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Best regards
Thomas
Am 14.04.24 um 18:35 schrieb Krzysztof Kozlowski:
> Hi,
>
> Dependencies
> ============
> All further patches depend on the first patch. Therefore everything
> could go via backlight tree (please ack) or via cross-tree pulls. Or
> whatever maintainer choose, just coordinate this with backlight.
>
> Best regards,
> Krzysztof
>
> ---
> Krzysztof Kozlowski (18):
> backlight: Constify lcd_ops
> backlight: ams369fg06: Constify lcd_ops
> backlight: corgi_lcd: Constify lcd_ops
> backlight: hx8357: Constify lcd_ops
> backlight: ili922x: Constify lcd_ops
> backlight: ili9320: Constify lcd_ops
> backlight: jornada720_lcd: Constify lcd_ops
> backlight: l4f00242t03: Constify lcd_ops
> backlight: lms283gf05: Constify lcd_ops
> backlight: lms501kf03: Constify lcd_ops
> backlight: ltv350qv: Constify lcd_ops
> backlight: otm3225a: Constify lcd_ops
> backlight: platform_lcd: Constify lcd_ops
> backlight: tdo24m: Constify lcd_ops
> HID: picoLCD: Constify lcd_ops
> fbdev: clps711x: Constify lcd_ops
> fbdev: imx: Constify lcd_ops
> fbdev: omap: lcd_ams_delta: Constify lcd_ops
>
> drivers/hid/hid-picolcd_lcd.c | 2 +-
> drivers/video/backlight/ams369fg06.c | 2 +-
> drivers/video/backlight/corgi_lcd.c | 2 +-
> drivers/video/backlight/hx8357.c | 2 +-
> drivers/video/backlight/ili922x.c | 2 +-
> drivers/video/backlight/ili9320.c | 2 +-
> drivers/video/backlight/jornada720_lcd.c | 2 +-
> drivers/video/backlight/l4f00242t03.c | 2 +-
> drivers/video/backlight/lcd.c | 4 ++--
> drivers/video/backlight/lms283gf05.c | 2 +-
> drivers/video/backlight/lms501kf03.c | 2 +-
> drivers/video/backlight/ltv350qv.c | 2 +-
> drivers/video/backlight/otm3225a.c | 2 +-
> drivers/video/backlight/platform_lcd.c | 2 +-
> drivers/video/backlight/tdo24m.c | 2 +-
> drivers/video/fbdev/clps711x-fb.c | 2 +-
> drivers/video/fbdev/imxfb.c | 2 +-
> drivers/video/fbdev/omap/lcd_ams_delta.c | 2 +-
> include/linux/lcd.h | 6 +++---
> 19 files changed, 22 insertions(+), 22 deletions(-)
> ---
> base-commit: 9ed46da14b9b9b2ad4edb3b0c545b6dbe5c00d39
> change-id: 20240414-video-backlight-lcd-ops-276d8439ffb8
>
> Best regards,
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply
* Re: [PATCH 00/18] backlight: Constify lcd_ops
From: Krzysztof Kozlowski @ 2024-04-15 7:48 UTC (permalink / raw)
To: Thomas Zimmermann, Lee Jones, Daniel Thompson, Jingoo Han,
Helge Deller, Bruno Prémont, Jiri Kosina, Benjamin Tissoires,
Alexander Shiyan, Sascha Hauer, Pengutronix Kernel Team,
Shawn Guo, Fabio Estevam
Cc: dri-devel, linux-fbdev, linux-kernel, linux-input,
linux-arm-kernel, imx, linux-omap
In-Reply-To: <b4cafdd1-c1b0-4abd-a849-8132c19d1525@suse.de>
On 15/04/2024 08:56, Thomas Zimmermann wrote:
> Hi
>
> for patches 16, 17 and 18:
>
> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
This does not work like this. Toolset will apply your review tag for
EVERYTHING. You must provide tag under each individual patch.
Best regards,
Krzysztof
^ permalink raw reply
* Re: [PATCH v2] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
From: Johan Hovold @ 2024-04-15 9:08 UTC (permalink / raw)
To: Łukasz Majczak
Cc: Jiri Kosina, Dmitry Torokhov, Benjamin Tissoires,
Douglas Anderson, Hans de Goede, Maxime Ripard, Kai-Heng Feng,
Johan Hovold, linux-input, linux-kernel, Radoslaw Biernacki
In-Reply-To: <CAE5UKNp3uS9cqDbQjcP3SbfxVi3wPFG4LtP6z=WU_V+M9x6LtQ@mail.gmail.com>
On Thu, Apr 11, 2024 at 04:23:27PM +0200, Łukasz Majczak wrote:
> > Sure, but what about other transactions that are initiated by the host
> > (e.g. SET_POWER)?
> >
> Somehow it is problematic only on reboot and works just fine on
> suspend/resume and
> set_power.
> I will dig more and try to find out what the difference is.
Sounds like it may be related to the i2c_hid_set_power() on shutdown()
then as Kai-Heng pointed out.
That function already handles a similar retry for I2C_HID_PWR_ON during
resume.
> > Perhaps this hack at probe is enough for your use case, but is an
> > incomplete hack and at a minimum you'd need to add a comment explaining
> > why it is there.
> >
> You mean a comment in the code ?
Yes, if this turns out to be needed then there should be a comment
explaining why it is there (and currently also as the delays you used
seem specific for your particular platform).
But hopefully you can find a generic solution to this.
Johan
^ permalink raw reply
* Re: [PATCH 1/6] media: usb: siano: Fix allocation of urbs
From: Hans Verkuil @ 2024-04-15 10:08 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Yasunari Takiguchi,
Jean-Christophe Trotin, Lars-Peter Clausen, Dmitry Torokhov
Cc: linux-media, linux-kernel, linux-input
In-Reply-To: <20240410-smatch-v1-1-785d009a852b@chromium.org>
On 10/04/2024 23:54, Ricardo Ribalda wrote:
> USB urbs must be allocated with usb_alloc_urb. Quoting the manual
>
> Only use this function (usb_init_urb) if you _really_ understand what you
> are doing.
>
> Fix the following smatch error:
>
> drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> drivers/media/usb/siano/smsusb.c | 28 ++++++++++++++++++++--------
> 1 file changed, 20 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
> index 723510520d092..d85308e0785db 100644
> --- a/drivers/media/usb/siano/smsusb.c
> +++ b/drivers/media/usb/siano/smsusb.c
> @@ -40,7 +40,7 @@ struct smsusb_urb_t {
> struct smscore_buffer_t *cb;
> struct smsusb_device_t *dev;
>
> - struct urb urb;
> + struct urb *urb;
>
> /* For the bottom half */
> struct work_struct wq;
> @@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> }
>
> usb_fill_bulk_urb(
> - &surb->urb,
> + surb->urb,
> dev->udev,
> usb_rcvbulkpipe(dev->udev, dev->in_ep),
> surb->cb->p,
> @@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> smsusb_onresponse,
> surb
> );
> - surb->urb.transfer_flags |= URB_FREE_BUFFER;
> + surb->urb->transfer_flags |= URB_FREE_BUFFER;
>
> - return usb_submit_urb(&surb->urb, GFP_ATOMIC);
> + return usb_submit_urb(surb->urb, GFP_ATOMIC);
> }
>
> static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> @@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> int i;
>
> for (i = 0; i < MAX_URBS; i++) {
> - usb_kill_urb(&dev->surbs[i].urb);
> + usb_kill_urb(dev->surbs[i].urb);
> if (dev->surbs[i].wq.func)
> cancel_work_sync(&dev->surbs[i].wq);
>
> @@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
> struct smsusb_device_t *dev = usb_get_intfdata(intf);
>
> if (dev) {
> + int i;
> +
> dev->state = SMSUSB_DISCONNECTED;
>
> smsusb_stop_streaming(dev);
> @@ -346,6 +348,9 @@ static void smsusb_term_device(struct usb_interface *intf)
> if (dev->coredev)
> smscore_unregister_device(dev->coredev);
>
> + for (i = 0; i < MAX_URBS; i++)
> + usb_free_urb(dev->surbs[i].urb);
> +
> pr_debug("device 0x%p destroyed\n", dev);
> kfree(dev);
> }
> @@ -390,6 +395,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> void *mdev;
> int i, rc;
> int align = 0;
> + int n_urb = 0;
>
> /* create device object */
> dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
> @@ -461,9 +467,11 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> dev->coredev->is_usb_device = true;
>
> /* initialize urbs */
> - for (i = 0; i < MAX_URBS; i++) {
> - dev->surbs[i].dev = dev;
> - usb_init_urb(&dev->surbs[i].urb);
> + for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
> + dev->surbs[n_urb].dev = dev;
> + dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
> + if (!dev->surbs[n_urb].urb)
> + goto free_urbs;
> }
After allocating the URBs there are a few more error paths that do
'goto err_unregister_device;' instead of 'goto free_urbs;'. From what
I can see, those need to go through 'free_urbs' as well.
>
> pr_debug("smsusb_start_streaming(...).\n");
> @@ -485,6 +493,10 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
>
> return rc;
>
> +free_urbs:
> + for (i = 0; i < n_urb; i++)
> + usb_free_urb(dev->surbs[n_urb].urb);
Would it be better to also assign NULL to dev->surbs[n_urb].urb?
That way there are no invalid pointers that can mess up things.
Regards,
Hans
> +
> err_unregister_device:
> smsusb_term_device(intf);
> #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>
^ permalink raw reply
* Re: [PATCH v2] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
From: Kenny Levinsen @ 2024-04-15 10:28 UTC (permalink / raw)
To: lma
Cc: benjamin.tissoires, dianders, dtor, hdegoede, jikos, johan+linaro,
johan, kai.heng.feng, linux-input, linux-kernel, mripard, rad
In-Reply-To: <CAE5UKNqufWZfKLAXLcpBYKQpJEVt6jPD4Xtr=Nesh34VkNOETg@mail.gmail.com>
> The problem is that the probe function calling i2c_smbus_read_byte()
> is not aware that
> uC on the other end is in a deep sleep state so the first read will
> fail and so the whole probe.
Well, the probe was just added to "avoid scary messages", so we could
just do away with it and fix the "scary messages" instead.
I think it would be better to handle the wake-up near the command being
sent that requires the device to be awake, just like is done for
i2c_hid_set_power(). This would mean removing the smbus probe
altogether, extending the HID descriptor fetch code to retry on
EREMOTEIO, and to avoid the "scary messages", print something nice if
the second attempt also fails with EREMOTEIO.
If the device can enter deep-sleep arbitrarily, then we presumably also
have problems in i2c_hid_output_raw_report() and
i2c_hid_get_raw_report() which could happen after the device has gone to
sleep from inactivity. These places would also need EREMOTEIO retry logic.
All these places should have the same sleeping behavior as they are
working around the same device glitch. I imagine the client ACK timeout
is longer than your required 400µs, in which case you don't need any
sleep on retry at all, as is the case in the current i2c_hid_set_power()
implementation.
However, as we litter retry-code all over the place, Johan's suggestion
about doing this in the I2C driver does become a bit more relevant...
Best regards,
Kenny Levinsen
^ permalink raw reply
* Re: [PATCH 1/6] media: usb: siano: Fix allocation of urbs
From: Hans Verkuil @ 2024-04-15 11:47 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Yasunari Takiguchi,
Jean-Christophe Trotin, Lars-Peter Clausen, Dmitry Torokhov
Cc: linux-media, linux-kernel, linux-input
In-Reply-To: <38bc9cc4-107b-4915-a5ab-2f305264363a@xs4all.nl>
On 15/04/2024 12:08, Hans Verkuil wrote:
> On 10/04/2024 23:54, Ricardo Ribalda wrote:
>> USB urbs must be allocated with usb_alloc_urb. Quoting the manual
>>
>> Only use this function (usb_init_urb) if you _really_ understand what you
>> are doing.
>>
>> Fix the following smatch error:
>>
>> drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
>>
>> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
>> ---
>> drivers/media/usb/siano/smsusb.c | 28 ++++++++++++++++++++--------
>> 1 file changed, 20 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
>> index 723510520d092..d85308e0785db 100644
>> --- a/drivers/media/usb/siano/smsusb.c
>> +++ b/drivers/media/usb/siano/smsusb.c
>> @@ -40,7 +40,7 @@ struct smsusb_urb_t {
>> struct smscore_buffer_t *cb;
>> struct smsusb_device_t *dev;
>>
>> - struct urb urb;
>> + struct urb *urb;
>>
>> /* For the bottom half */
>> struct work_struct wq;
>> @@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
>> }
>>
>> usb_fill_bulk_urb(
>> - &surb->urb,
>> + surb->urb,
>> dev->udev,
>> usb_rcvbulkpipe(dev->udev, dev->in_ep),
>> surb->cb->p,
>> @@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
>> smsusb_onresponse,
>> surb
>> );
>> - surb->urb.transfer_flags |= URB_FREE_BUFFER;
>> + surb->urb->transfer_flags |= URB_FREE_BUFFER;
>>
>> - return usb_submit_urb(&surb->urb, GFP_ATOMIC);
>> + return usb_submit_urb(surb->urb, GFP_ATOMIC);
>> }
>>
>> static void smsusb_stop_streaming(struct smsusb_device_t *dev)
>> @@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
>> int i;
>>
>> for (i = 0; i < MAX_URBS; i++) {
>> - usb_kill_urb(&dev->surbs[i].urb);
>> + usb_kill_urb(dev->surbs[i].urb);
>> if (dev->surbs[i].wq.func)
>> cancel_work_sync(&dev->surbs[i].wq);
>>
>> @@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
>> struct smsusb_device_t *dev = usb_get_intfdata(intf);
>>
>> if (dev) {
>> + int i;
>> +
>> dev->state = SMSUSB_DISCONNECTED;
>>
>> smsusb_stop_streaming(dev);
>> @@ -346,6 +348,9 @@ static void smsusb_term_device(struct usb_interface *intf)
>> if (dev->coredev)
>> smscore_unregister_device(dev->coredev);
>>
>> + for (i = 0; i < MAX_URBS; i++)
>> + usb_free_urb(dev->surbs[i].urb);
>> +
>> pr_debug("device 0x%p destroyed\n", dev);
>> kfree(dev);
>> }
>> @@ -390,6 +395,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
>> void *mdev;
>> int i, rc;
>> int align = 0;
>> + int n_urb = 0;
>>
>> /* create device object */
>> dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
>> @@ -461,9 +467,11 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
>> dev->coredev->is_usb_device = true;
>>
>> /* initialize urbs */
>> - for (i = 0; i < MAX_URBS; i++) {
>> - dev->surbs[i].dev = dev;
>> - usb_init_urb(&dev->surbs[i].urb);
>> + for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
>> + dev->surbs[n_urb].dev = dev;
>> + dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
>> + if (!dev->surbs[n_urb].urb)
>> + goto free_urbs;
>> }
>
> After allocating the URBs there are a few more error paths that do
> 'goto err_unregister_device;' instead of 'goto free_urbs;'. From what
> I can see, those need to go through 'free_urbs' as well.
>
>>
>> pr_debug("smsusb_start_streaming(...).\n");
>> @@ -485,6 +493,10 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
>>
>> return rc;
>>
>> +free_urbs:
>> + for (i = 0; i < n_urb; i++)
>> + usb_free_urb(dev->surbs[n_urb].urb);
>
> Would it be better to also assign NULL to dev->surbs[n_urb].urb?
> That way there are no invalid pointers that can mess up things.
Ricardo, just post a v2 of this patch. I posted a PR for the other
patches. Nice work, BTW!
Regards,
Hans
>
> Regards,
>
> Hans
>
>> +
>> err_unregister_device:
>> smsusb_term_device(intf);
>> #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>>
>
>
^ permalink raw reply
* Re: [PATCH v2] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
From: Radoslaw Biernacki @ 2024-04-15 12:10 UTC (permalink / raw)
To: Kenny Levinsen
Cc: lma, benjamin.tissoires, dianders, dtor, hdegoede, jikos,
johan+linaro, johan, kai.heng.feng, linux-input, linux-kernel,
mripard, rad
In-Reply-To: <81e1b870-37f9-4ef2-9a3d-87015f32546b@kl.wtf>
Hi Kenny,
> If the device can enter deep-sleep arbitrarily, then we presumably also
> have problems in i2c_hid_output_raw_report() and
> i2c_hid_get_raw_report() which could happen after the device has gone to
> sleep from inactivity. These places would also need EREMOTEIO retry logic.
It does not enter deep-sleep arbitrarily and therefore it is not a problem with
other communication patterns.
The design which was chosen back in the day, to save the battery power
is event based
instead of level based (some HW line). Therefore to avoid power leak
we need to request
low power state (to prevent power leak in case the kernel will not
boot up soon).
Basically we need to take out the device from deep state logic by message,
without knowing if the device is on the bus or it is on the bus but
not responding.
>
> All these places should have the same sleeping behavior as they are
> working around the same device glitch. I imagine the client ACK timeout
> is longer than your required 400µs, in which case you don't need any
> sleep on retry at all, as is the case in the current i2c_hid_set_power()
> implementation.
>
> However, as we litter retry-code all over the place, Johan's suggestion
> about doing this in the I2C driver does become a bit more relevant...
>
> Best regards,
> Kenny Levinsen
>
^ permalink raw reply
* [PATCH v2] media: usb: siano: Fix allocation of urbs
From: Ricardo Ribalda @ 2024-04-15 12:12 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Yasunari Takiguchi, Jean-Christophe Trotin,
Lars-Peter Clausen, Dmitry Torokhov
Cc: Hans Verkuil, linux-media, linux-kernel, linux-input,
Ricardo Ribalda
USB urbs must be allocated with usb_alloc_urb. Quoting the manual
Only use this function (usb_init_urb) if you _really_ understand what you
are doing.
Fix the following smatch error:
drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v2: Thanks Hans
- Only leave 1/6, the other ones are in another PR
- Fix the return tag and NULLify the urbs on return
- Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
---
drivers/media/usb/siano/smsusb.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 723510520d09..2e25b970946a 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -40,7 +40,7 @@ struct smsusb_urb_t {
struct smscore_buffer_t *cb;
struct smsusb_device_t *dev;
- struct urb urb;
+ struct urb *urb;
/* For the bottom half */
struct work_struct wq;
@@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
}
usb_fill_bulk_urb(
- &surb->urb,
+ surb->urb,
dev->udev,
usb_rcvbulkpipe(dev->udev, dev->in_ep),
surb->cb->p,
@@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
smsusb_onresponse,
surb
);
- surb->urb.transfer_flags |= URB_FREE_BUFFER;
+ surb->urb->transfer_flags |= URB_FREE_BUFFER;
- return usb_submit_urb(&surb->urb, GFP_ATOMIC);
+ return usb_submit_urb(surb->urb, GFP_ATOMIC);
}
static void smsusb_stop_streaming(struct smsusb_device_t *dev)
@@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
int i;
for (i = 0; i < MAX_URBS; i++) {
- usb_kill_urb(&dev->surbs[i].urb);
+ usb_kill_urb(dev->surbs[i].urb);
if (dev->surbs[i].wq.func)
cancel_work_sync(&dev->surbs[i].wq);
@@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
struct smsusb_device_t *dev = usb_get_intfdata(intf);
if (dev) {
+ int i;
+
dev->state = SMSUSB_DISCONNECTED;
smsusb_stop_streaming(dev);
@@ -346,6 +348,11 @@ static void smsusb_term_device(struct usb_interface *intf)
if (dev->coredev)
smscore_unregister_device(dev->coredev);
+ for (i = 0; i < MAX_URBS; i++) {
+ usb_free_urb(dev->surbs[i].urb);
+ dev->surbs[i].urb = NULL;
+ }
+
pr_debug("device 0x%p destroyed\n", dev);
kfree(dev);
}
@@ -390,6 +397,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
void *mdev;
int i, rc;
int align = 0;
+ int n_urb = 0;
/* create device object */
dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
@@ -461,16 +469,18 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
dev->coredev->is_usb_device = true;
/* initialize urbs */
- for (i = 0; i < MAX_URBS; i++) {
- dev->surbs[i].dev = dev;
- usb_init_urb(&dev->surbs[i].urb);
+ for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
+ dev->surbs[n_urb].dev = dev;
+ dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->surbs[n_urb].urb)
+ goto free_urbs;
}
pr_debug("smsusb_start_streaming(...).\n");
rc = smsusb_start_streaming(dev);
if (rc < 0) {
pr_err("smsusb_start_streaming(...) failed\n");
- goto err_unregister_device;
+ goto free_urbs;
}
dev->state = SMSUSB_ACTIVE;
@@ -478,13 +488,19 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
rc = smscore_start_device(dev->coredev);
if (rc < 0) {
pr_err("smscore_start_device(...) failed\n");
- goto err_unregister_device;
+ goto free_urbs;
}
pr_debug("device 0x%p created\n", dev);
return rc;
+free_urbs:
+ for (i = 0; i < n_urb; i++) {
+ usb_free_urb(dev->surbs[n_urb].urb);
+ dev->surbs[n_urb].urb = NULL;
+ }
+
err_unregister_device:
smsusb_term_device(intf);
#ifdef CONFIG_MEDIA_CONTROLLER_DVB
---
base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
change-id: 20240410-smatch-8f235d50753d
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply related
* Re: [PATCH v2] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
From: Radoslaw Biernacki @ 2024-04-15 12:13 UTC (permalink / raw)
To: Kenny Levinsen
Cc: lma, benjamin.tissoires, dianders, dtor, hdegoede, jikos,
johan+linaro, johan, kai.heng.feng, linux-input, linux-kernel,
mripard, rad
In-Reply-To: <CAM4=RnJAe1wzi_+Nif0wiSeqC5GR6Aavz97mY7tm=hFu3mijhg@mail.gmail.com>
ps: "without knowing if the device is, or is not on the bus ..."
On Mon, Apr 15, 2024 at 2:10 PM Radoslaw Biernacki <biernacki@google.com> wrote:
>
> Hi Kenny,
>
> > If the device can enter deep-sleep arbitrarily, then we presumably also
> > have problems in i2c_hid_output_raw_report() and
> > i2c_hid_get_raw_report() which could happen after the device has gone to
> > sleep from inactivity. These places would also need EREMOTEIO retry logic.
>
> It does not enter deep-sleep arbitrarily and therefore it is not a problem with
> other communication patterns.
> The design which was chosen back in the day, to save the battery power
> is event based
> instead of level based (some HW line). Therefore to avoid power leak
> we need to request
> low power state (to prevent power leak in case the kernel will not
> boot up soon).
>
> Basically we need to take out the device from deep state logic by message,
> without knowing if the device is on the bus or it is on the bus but
> not responding.
>
> >
> > All these places should have the same sleeping behavior as they are
> > working around the same device glitch. I imagine the client ACK timeout
> > is longer than your required 400µs, in which case you don't need any
> > sleep on retry at all, as is the case in the current i2c_hid_set_power()
> > implementation.
> >
> > However, as we litter retry-code all over the place, Johan's suggestion
> > about doing this in the I2C driver does become a bit more relevant...
> >
> > Best regards,
> > Kenny Levinsen
> >
^ permalink raw reply
* Re: [PATCH v2] media: usb: siano: Fix allocation of urbs
From: Hans Verkuil @ 2024-04-15 12:23 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Yasunari Takiguchi,
Jean-Christophe Trotin, Lars-Peter Clausen, Dmitry Torokhov
Cc: linux-media, linux-kernel, linux-input
In-Reply-To: <20240415-smatch-v2-1-65215936d398@chromium.org>
On 15/04/2024 14:12, Ricardo Ribalda wrote:
> USB urbs must be allocated with usb_alloc_urb. Quoting the manual
>
> Only use this function (usb_init_urb) if you _really_ understand what you
> are doing.
>
> Fix the following smatch error:
>
> drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> Changes in v2: Thanks Hans
> - Only leave 1/6, the other ones are in another PR
> - Fix the return tag and NULLify the urbs on return
> - Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
> ---
> drivers/media/usb/siano/smsusb.c | 36 ++++++++++++++++++++++++++----------
> 1 file changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
> index 723510520d09..2e25b970946a 100644
> --- a/drivers/media/usb/siano/smsusb.c
> +++ b/drivers/media/usb/siano/smsusb.c
> @@ -40,7 +40,7 @@ struct smsusb_urb_t {
> struct smscore_buffer_t *cb;
> struct smsusb_device_t *dev;
>
> - struct urb urb;
> + struct urb *urb;
>
> /* For the bottom half */
> struct work_struct wq;
> @@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> }
>
> usb_fill_bulk_urb(
> - &surb->urb,
> + surb->urb,
> dev->udev,
> usb_rcvbulkpipe(dev->udev, dev->in_ep),
> surb->cb->p,
> @@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> smsusb_onresponse,
> surb
> );
> - surb->urb.transfer_flags |= URB_FREE_BUFFER;
> + surb->urb->transfer_flags |= URB_FREE_BUFFER;
>
> - return usb_submit_urb(&surb->urb, GFP_ATOMIC);
> + return usb_submit_urb(surb->urb, GFP_ATOMIC);
> }
>
> static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> @@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> int i;
>
> for (i = 0; i < MAX_URBS; i++) {
> - usb_kill_urb(&dev->surbs[i].urb);
> + usb_kill_urb(dev->surbs[i].urb);
> if (dev->surbs[i].wq.func)
> cancel_work_sync(&dev->surbs[i].wq);
>
> @@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
> struct smsusb_device_t *dev = usb_get_intfdata(intf);
>
> if (dev) {
> + int i;
> +
> dev->state = SMSUSB_DISCONNECTED;
>
> smsusb_stop_streaming(dev);
> @@ -346,6 +348,11 @@ static void smsusb_term_device(struct usb_interface *intf)
> if (dev->coredev)
> smscore_unregister_device(dev->coredev);
>
> + for (i = 0; i < MAX_URBS; i++) {
> + usb_free_urb(dev->surbs[i].urb);
> + dev->surbs[i].urb = NULL;
You don't need to assign to NULL here...
> + }
> +
> pr_debug("device 0x%p destroyed\n", dev);
> kfree(dev);
...since here the whole dev struct is freed.
> }
> @@ -390,6 +397,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> void *mdev;
> int i, rc;
> int align = 0;
> + int n_urb = 0;
>
> /* create device object */
> dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
> @@ -461,16 +469,18 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> dev->coredev->is_usb_device = true;
>
> /* initialize urbs */
> - for (i = 0; i < MAX_URBS; i++) {
> - dev->surbs[i].dev = dev;
> - usb_init_urb(&dev->surbs[i].urb);
> + for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
> + dev->surbs[n_urb].dev = dev;
> + dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
> + if (!dev->surbs[n_urb].urb)
> + goto free_urbs;
> }
>
> pr_debug("smsusb_start_streaming(...).\n");
> rc = smsusb_start_streaming(dev);
> if (rc < 0) {
> pr_err("smsusb_start_streaming(...) failed\n");
> - goto err_unregister_device;
> + goto free_urbs;
> }
>
> dev->state = SMSUSB_ACTIVE;
> @@ -478,13 +488,19 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> rc = smscore_start_device(dev->coredev);
> if (rc < 0) {
> pr_err("smscore_start_device(...) failed\n");
> - goto err_unregister_device;
> + goto free_urbs;
> }
>
> pr_debug("device 0x%p created\n", dev);
>
> return rc;
>
> +free_urbs:
> + for (i = 0; i < n_urb; i++) {
> + usb_free_urb(dev->surbs[n_urb].urb);
> + dev->surbs[n_urb].urb = NULL;
This should use index 'i', right? Not 'n_urb'.
I'll wait for v3 :-)
Regards,
Hans
> + }
> +
> err_unregister_device:
> smsusb_term_device(intf);
> #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>
> ---
> base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
> change-id: 20240410-smatch-8f235d50753d
>
> Best regards,
^ permalink raw reply
* Re: [PATCH v2] HID: i2c-hid: wait for i2c touchpad deep-sleep to power-up transition
From: Radoslaw Biernacki @ 2024-04-15 12:26 UTC (permalink / raw)
To: Johan Hovold
Cc: Łukasz Majczak, Jiri Kosina, Dmitry Torokhov,
Benjamin Tissoires, Douglas Anderson, Hans de Goede,
Maxime Ripard, Kai-Heng Feng, Johan Hovold, linux-input,
linux-kernel, Radoslaw Biernacki
In-Reply-To: <ZhzuoWgA88CeenMC@hovoldconsulting.com>
Hi Johan,
On Mon, Apr 15, 2024 at 11:08 AM Johan Hovold <johan@kernel.org> wrote:
>
> On Thu, Apr 11, 2024 at 04:23:27PM +0200, Łukasz Majczak wrote:
> > > Sure, but what about other transactions that are initiated by the host
> > > (e.g. SET_POWER)?
> > >
> > Somehow it is problematic only on reboot and works just fine on
> > suspend/resume and
> > set_power.
> > I will dig more and try to find out what the difference is.
>
> Sounds like it may be related to the i2c_hid_set_power() on shutdown()
> then as Kai-Heng pointed out.
>
> That function already handles a similar retry for I2C_HID_PWR_ON during
> resume.
>
> > > Perhaps this hack at probe is enough for your use case, but is an
> > > incomplete hack and at a minimum you'd need to add a comment explaining
> > > why it is there.
> > >
> > You mean a comment in the code ?
>
> Yes, if this turns out to be needed then there should be a comment
> explaining why it is there (and currently also as the delays you used
> seem specific for your particular platform).
>
> But hopefully you can find a generic solution to this.
Yes, we might need a more generic solution though it is not yet clear
for us which would be the cleanest one.
As I wrote in the reply to Kenny, the design back in the day was made
to use events rather than
level driven IO line, to drive the power state of the device.
Consequence is we need to request
a low power state before the kernel goes down as there is no guarantee
the kernel will wake up soon
(prevent battery power leak). This event/level logic problem (event
design for level type problem).
Let us get back to you with more info as we look deeper into some
newly found power sequence limitations
of the second I2C node on this device.
>
> Johan
^ permalink raw reply
* [PATCH v3] media: usb: siano: Fix allocation of urbs
From: Ricardo Ribalda @ 2024-04-15 12:29 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Yasunari Takiguchi, Jean-Christophe Trotin,
Lars-Peter Clausen, Dmitry Torokhov
Cc: Hans Verkuil, linux-media, linux-kernel, linux-input,
Ricardo Ribalda
USB urbs must be allocated with usb_alloc_urb. Quoting the manual
Only use this function (usb_init_urb) if you _really_ understand what you
are doing.
Fix the following smatch error:
drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v3: Thanks Hans
- Remove unneeded NULL assignment
- Use the proper variable :)
- Link to v2: https://lore.kernel.org/r/20240415-smatch-v2-1-65215936d398@chromium.org
Changes in v2: Thanks Hans
- Only leave 1/6, the other ones are in another PR
- Fix the return tag and NULLify the urbs on return
- Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
---
drivers/media/usb/siano/smsusb.c | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 723510520d09..ba2c02e1070e 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -40,7 +40,7 @@ struct smsusb_urb_t {
struct smscore_buffer_t *cb;
struct smsusb_device_t *dev;
- struct urb urb;
+ struct urb *urb;
/* For the bottom half */
struct work_struct wq;
@@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
}
usb_fill_bulk_urb(
- &surb->urb,
+ surb->urb,
dev->udev,
usb_rcvbulkpipe(dev->udev, dev->in_ep),
surb->cb->p,
@@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
smsusb_onresponse,
surb
);
- surb->urb.transfer_flags |= URB_FREE_BUFFER;
+ surb->urb->transfer_flags |= URB_FREE_BUFFER;
- return usb_submit_urb(&surb->urb, GFP_ATOMIC);
+ return usb_submit_urb(surb->urb, GFP_ATOMIC);
}
static void smsusb_stop_streaming(struct smsusb_device_t *dev)
@@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
int i;
for (i = 0; i < MAX_URBS; i++) {
- usb_kill_urb(&dev->surbs[i].urb);
+ usb_kill_urb(dev->surbs[i].urb);
if (dev->surbs[i].wq.func)
cancel_work_sync(&dev->surbs[i].wq);
@@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
struct smsusb_device_t *dev = usb_get_intfdata(intf);
if (dev) {
+ int i;
+
dev->state = SMSUSB_DISCONNECTED;
smsusb_stop_streaming(dev);
@@ -346,6 +348,9 @@ static void smsusb_term_device(struct usb_interface *intf)
if (dev->coredev)
smscore_unregister_device(dev->coredev);
+ for (i = 0; i < MAX_URBS; i++)
+ usb_free_urb(dev->surbs[i].urb);
+
pr_debug("device 0x%p destroyed\n", dev);
kfree(dev);
}
@@ -390,6 +395,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
void *mdev;
int i, rc;
int align = 0;
+ int n_urb = 0;
/* create device object */
dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
@@ -461,16 +467,18 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
dev->coredev->is_usb_device = true;
/* initialize urbs */
- for (i = 0; i < MAX_URBS; i++) {
- dev->surbs[i].dev = dev;
- usb_init_urb(&dev->surbs[i].urb);
+ for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
+ dev->surbs[n_urb].dev = dev;
+ dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->surbs[n_urb].urb)
+ goto free_urbs;
}
pr_debug("smsusb_start_streaming(...).\n");
rc = smsusb_start_streaming(dev);
if (rc < 0) {
pr_err("smsusb_start_streaming(...) failed\n");
- goto err_unregister_device;
+ goto free_urbs;
}
dev->state = SMSUSB_ACTIVE;
@@ -478,13 +486,19 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
rc = smscore_start_device(dev->coredev);
if (rc < 0) {
pr_err("smscore_start_device(...) failed\n");
- goto err_unregister_device;
+ goto free_urbs;
}
pr_debug("device 0x%p created\n", dev);
return rc;
+free_urbs:
+ for (i = 0; i < n_urb; i++) {
+ usb_free_urb(dev->surbs[i].urb);
+ dev->surbs[i].urb = NULL;
+ }
+
err_unregister_device:
smsusb_term_device(intf);
#ifdef CONFIG_MEDIA_CONTROLLER_DVB
---
base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
change-id: 20240410-smatch-8f235d50753d
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply related
* Re: [PATCH v2] media: usb: siano: Fix allocation of urbs
From: Ricardo Ribalda @ 2024-04-15 12:30 UTC (permalink / raw)
To: Hans Verkuil
Cc: Mauro Carvalho Chehab, Yasunari Takiguchi, Jean-Christophe Trotin,
Lars-Peter Clausen, Dmitry Torokhov, linux-media, linux-kernel,
linux-input
In-Reply-To: <a0c8faf3-0043-4eed-9e5d-b1a50d7405f1@xs4all.nl>
Hi Hans
On Mon, 15 Apr 2024 at 14:24, Hans Verkuil <hverkuil-cisco@xs4all.nl> wrote:
>
> On 15/04/2024 14:12, Ricardo Ribalda wrote:
> > USB urbs must be allocated with usb_alloc_urb. Quoting the manual
> >
> > Only use this function (usb_init_urb) if you _really_ understand what you
> > are doing.
> >
> > Fix the following smatch error:
> >
> > drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
> >
> > Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> > ---
> > Changes in v2: Thanks Hans
> > - Only leave 1/6, the other ones are in another PR
> > - Fix the return tag and NULLify the urbs on return
> > - Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
> > ---
> > drivers/media/usb/siano/smsusb.c | 36 ++++++++++++++++++++++++++----------
> > 1 file changed, 26 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
> > index 723510520d09..2e25b970946a 100644
> > --- a/drivers/media/usb/siano/smsusb.c
> > +++ b/drivers/media/usb/siano/smsusb.c
> > @@ -40,7 +40,7 @@ struct smsusb_urb_t {
> > struct smscore_buffer_t *cb;
> > struct smsusb_device_t *dev;
> >
> > - struct urb urb;
> > + struct urb *urb;
> >
> > /* For the bottom half */
> > struct work_struct wq;
> > @@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> > }
> >
> > usb_fill_bulk_urb(
> > - &surb->urb,
> > + surb->urb,
> > dev->udev,
> > usb_rcvbulkpipe(dev->udev, dev->in_ep),
> > surb->cb->p,
> > @@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> > smsusb_onresponse,
> > surb
> > );
> > - surb->urb.transfer_flags |= URB_FREE_BUFFER;
> > + surb->urb->transfer_flags |= URB_FREE_BUFFER;
> >
> > - return usb_submit_urb(&surb->urb, GFP_ATOMIC);
> > + return usb_submit_urb(surb->urb, GFP_ATOMIC);
> > }
> >
> > static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> > @@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> > int i;
> >
> > for (i = 0; i < MAX_URBS; i++) {
> > - usb_kill_urb(&dev->surbs[i].urb);
> > + usb_kill_urb(dev->surbs[i].urb);
> > if (dev->surbs[i].wq.func)
> > cancel_work_sync(&dev->surbs[i].wq);
> >
> > @@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
> > struct smsusb_device_t *dev = usb_get_intfdata(intf);
> >
> > if (dev) {
> > + int i;
> > +
> > dev->state = SMSUSB_DISCONNECTED;
> >
> > smsusb_stop_streaming(dev);
> > @@ -346,6 +348,11 @@ static void smsusb_term_device(struct usb_interface *intf)
> > if (dev->coredev)
> > smscore_unregister_device(dev->coredev);
> >
> > + for (i = 0; i < MAX_URBS; i++) {
> > + usb_free_urb(dev->surbs[i].urb);
> > + dev->surbs[i].urb = NULL;
>
> You don't need to assign to NULL here...
>
> > + }
> > +
> > pr_debug("device 0x%p destroyed\n", dev);
> > kfree(dev);
>
> ...since here the whole dev struct is freed.
>
> > }
> > @@ -390,6 +397,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> > void *mdev;
> > int i, rc;
> > int align = 0;
> > + int n_urb = 0;
> >
> > /* create device object */
> > dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
> > @@ -461,16 +469,18 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> > dev->coredev->is_usb_device = true;
> >
> > /* initialize urbs */
> > - for (i = 0; i < MAX_URBS; i++) {
> > - dev->surbs[i].dev = dev;
> > - usb_init_urb(&dev->surbs[i].urb);
> > + for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
> > + dev->surbs[n_urb].dev = dev;
> > + dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
> > + if (!dev->surbs[n_urb].urb)
> > + goto free_urbs;
> > }
> >
> > pr_debug("smsusb_start_streaming(...).\n");
> > rc = smsusb_start_streaming(dev);
> > if (rc < 0) {
> > pr_err("smsusb_start_streaming(...) failed\n");
> > - goto err_unregister_device;
> > + goto free_urbs;
> > }
> >
> > dev->state = SMSUSB_ACTIVE;
> > @@ -478,13 +488,19 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> > rc = smscore_start_device(dev->coredev);
> > if (rc < 0) {
> > pr_err("smscore_start_device(...) failed\n");
> > - goto err_unregister_device;
> > + goto free_urbs;
> > }
> >
> > pr_debug("device 0x%p created\n", dev);
> >
> > return rc;
> >
> > +free_urbs:
> > + for (i = 0; i < n_urb; i++) {
> > + usb_free_urb(dev->surbs[n_urb].urb);
> > + dev->surbs[n_urb].urb = NULL;
>
> This should use index 'i', right? Not 'n_urb'.
>
> I'll wait for v3 :-)
>
ups :)
Good catch :)
> Regards,
>
> Hans
>
> > + }
> > +
> > err_unregister_device:
> > smsusb_term_device(intf);
> > #ifdef CONFIG_MEDIA_CONTROLLER_DVB
> >
> > ---
> > base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
> > change-id: 20240410-smatch-8f235d50753d
> >
> > Best regards,
>
--
Ricardo Ribalda
^ permalink raw reply
* Re: [PATCH v3] media: usb: siano: Fix allocation of urbs
From: Hans Verkuil @ 2024-04-15 12:38 UTC (permalink / raw)
To: Ricardo Ribalda, Mauro Carvalho Chehab, Yasunari Takiguchi,
Jean-Christophe Trotin, Lars-Peter Clausen, Dmitry Torokhov
Cc: linux-media, linux-kernel, linux-input
In-Reply-To: <20240415-smatch-v3-1-ed3f23f9d5ee@chromium.org>
On 15/04/2024 14:29, Ricardo Ribalda wrote:
> USB urbs must be allocated with usb_alloc_urb. Quoting the manual
>
> Only use this function (usb_init_urb) if you _really_ understand what you
> are doing.
>
> Fix the following smatch error:
>
> drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
>
> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
> ---
> Changes in v3: Thanks Hans
> - Remove unneeded NULL assignment
> - Use the proper variable :)
> - Link to v2: https://lore.kernel.org/r/20240415-smatch-v2-1-65215936d398@chromium.org
>
> Changes in v2: Thanks Hans
> - Only leave 1/6, the other ones are in another PR
> - Fix the return tag and NULLify the urbs on return
> - Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
> ---
> drivers/media/usb/siano/smsusb.c | 34 ++++++++++++++++++++++++----------
> 1 file changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
> index 723510520d09..ba2c02e1070e 100644
> --- a/drivers/media/usb/siano/smsusb.c
> +++ b/drivers/media/usb/siano/smsusb.c
> @@ -40,7 +40,7 @@ struct smsusb_urb_t {
> struct smscore_buffer_t *cb;
> struct smsusb_device_t *dev;
>
> - struct urb urb;
> + struct urb *urb;
>
> /* For the bottom half */
> struct work_struct wq;
> @@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> }
>
> usb_fill_bulk_urb(
> - &surb->urb,
> + surb->urb,
> dev->udev,
> usb_rcvbulkpipe(dev->udev, dev->in_ep),
> surb->cb->p,
> @@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
> smsusb_onresponse,
> surb
> );
> - surb->urb.transfer_flags |= URB_FREE_BUFFER;
> + surb->urb->transfer_flags |= URB_FREE_BUFFER;
>
> - return usb_submit_urb(&surb->urb, GFP_ATOMIC);
> + return usb_submit_urb(surb->urb, GFP_ATOMIC);
> }
>
> static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> @@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
> int i;
>
> for (i = 0; i < MAX_URBS; i++) {
> - usb_kill_urb(&dev->surbs[i].urb);
> + usb_kill_urb(dev->surbs[i].urb);
> if (dev->surbs[i].wq.func)
> cancel_work_sync(&dev->surbs[i].wq);
>
> @@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
> struct smsusb_device_t *dev = usb_get_intfdata(intf);
>
> if (dev) {
> + int i;
> +
> dev->state = SMSUSB_DISCONNECTED;
>
> smsusb_stop_streaming(dev);
> @@ -346,6 +348,9 @@ static void smsusb_term_device(struct usb_interface *intf)
> if (dev->coredev)
> smscore_unregister_device(dev->coredev);
>
> + for (i = 0; i < MAX_URBS; i++)
> + usb_free_urb(dev->surbs[i].urb);
> +
> pr_debug("device 0x%p destroyed\n", dev);
> kfree(dev);
> }
> @@ -390,6 +395,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> void *mdev;
> int i, rc;
> int align = 0;
> + int n_urb = 0;
>
> /* create device object */
> dev = kzalloc(sizeof(struct smsusb_device_t), GFP_KERNEL);
> @@ -461,16 +467,18 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> dev->coredev->is_usb_device = true;
>
> /* initialize urbs */
> - for (i = 0; i < MAX_URBS; i++) {
> - dev->surbs[i].dev = dev;
> - usb_init_urb(&dev->surbs[i].urb);
> + for (n_urb = 0; n_urb < MAX_URBS; n_urb++) {
> + dev->surbs[n_urb].dev = dev;
> + dev->surbs[n_urb].urb = usb_alloc_urb(0, GFP_KERNEL);
> + if (!dev->surbs[n_urb].urb)
> + goto free_urbs;
> }
>
> pr_debug("smsusb_start_streaming(...).\n");
> rc = smsusb_start_streaming(dev);
> if (rc < 0) {
> pr_err("smsusb_start_streaming(...) failed\n");
> - goto err_unregister_device;
> + goto free_urbs;
> }
>
> dev->state = SMSUSB_ACTIVE;
> @@ -478,13 +486,19 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
> rc = smscore_start_device(dev->coredev);
> if (rc < 0) {
> pr_err("smscore_start_device(...) failed\n");
> - goto err_unregister_device;
> + goto free_urbs;
> }
>
> pr_debug("device 0x%p created\n", dev);
>
> return rc;
>
> +free_urbs:
> + for (i = 0; i < n_urb; i++) {
> + usb_free_urb(dev->surbs[i].urb);
> + dev->surbs[i].urb = NULL;
> + }
> +
> err_unregister_device:
> smsusb_term_device(intf);
After re-reading the code, I see that smsusb_term_device() actually
frees all URBs. So the 'free_urbs' goto label is not needed, it can
go straight to err_unregister_device. A comment just above
the 'smsusb_term_device(intf);' line mentioning that it will free
any allocated urbs would be helpful, though.
Regards,
Hans
> #ifdef CONFIG_MEDIA_CONTROLLER_DVB
>
> ---
> base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
> change-id: 20240410-smatch-8f235d50753d
>
> Best regards,
^ permalink raw reply
* Re: [PATCH 01/18] backlight: Constify lcd_ops
From: Daniel Thompson @ 2024-04-15 12:46 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Lee Jones, Jingoo Han, Helge Deller, Bruno Prémont,
Jiri Kosina, Benjamin Tissoires, Alexander Shiyan, Sascha Hauer,
Pengutronix Kernel Team, Shawn Guo, Fabio Estevam, dri-devel,
linux-fbdev, linux-kernel, linux-input, linux-arm-kernel, imx,
linux-omap
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-1-9b37fcbf546a@kernel.org>
On Sun, Apr 14, 2024 at 06:35:59PM +0200, Krzysztof Kozlowski wrote:
> 'struct lcd_ops' passed in lcd_device_register() is not modified by core
> backlight code, so it can be made const for code safety. This allows
> drivers to also define the structure as const.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
^ permalink raw reply
* Re: [PATCH 02/18] backlight: ams369fg06: Constify lcd_ops
From: Daniel Thompson @ 2024-04-15 12:47 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Lee Jones, Jingoo Han, Helge Deller, Bruno Prémont,
Jiri Kosina, Benjamin Tissoires, Alexander Shiyan, Sascha Hauer,
Pengutronix Kernel Team, Shawn Guo, Fabio Estevam, dri-devel,
linux-fbdev, linux-kernel, linux-input, linux-arm-kernel, imx,
linux-omap
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-2-9b37fcbf546a@kernel.org>
On Sun, Apr 14, 2024 at 06:36:00PM +0200, Krzysztof Kozlowski wrote:
> 'struct lcd_ops' is not modified by core backlight code, so it can be
> made const for increased code safety.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
^ permalink raw reply
* [PATCH v4] media: usb: siano: Fix allocation of urbs
From: Ricardo Ribalda @ 2024-04-15 12:48 UTC (permalink / raw)
To: Mauro Carvalho Chehab, Yasunari Takiguchi, Jean-Christophe Trotin,
Lars-Peter Clausen, Dmitry Torokhov
Cc: Hans Verkuil, linux-media, linux-kernel, linux-input,
Ricardo Ribalda
USB urbs must be allocated with usb_alloc_urb. Quoting the manual
Only use this function (usb_init_urb) if you _really_ understand what you
are doing.
Fix the following smatch error:
drivers/media/usb/siano/smsusb.c:53:38: warning: array of flexible structures
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
---
Changes in v4:
- Remove unneeded label free_urbs
- Link to v3: https://lore.kernel.org/r/20240415-smatch-v3-1-ed3f23f9d5ee@chromium.org
Changes in v3: Thanks Hans
- Remove unneeded NULL assignment
- Use the proper variable :)
- Link to v2: https://lore.kernel.org/r/20240415-smatch-v2-1-65215936d398@chromium.org
Changes in v2: Thanks Hans
- Only leave 1/6, the other ones are in another PR
- Fix the return tag and NULLify the urbs on return
- Link to v1: https://lore.kernel.org/r/20240410-smatch-v1-0-785d009a852b@chromium.org
---
drivers/media/usb/siano/smsusb.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/drivers/media/usb/siano/smsusb.c b/drivers/media/usb/siano/smsusb.c
index 723510520d09..2c8179a84991 100644
--- a/drivers/media/usb/siano/smsusb.c
+++ b/drivers/media/usb/siano/smsusb.c
@@ -40,7 +40,7 @@ struct smsusb_urb_t {
struct smscore_buffer_t *cb;
struct smsusb_device_t *dev;
- struct urb urb;
+ struct urb *urb;
/* For the bottom half */
struct work_struct wq;
@@ -160,7 +160,7 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
}
usb_fill_bulk_urb(
- &surb->urb,
+ surb->urb,
dev->udev,
usb_rcvbulkpipe(dev->udev, dev->in_ep),
surb->cb->p,
@@ -168,9 +168,9 @@ static int smsusb_submit_urb(struct smsusb_device_t *dev,
smsusb_onresponse,
surb
);
- surb->urb.transfer_flags |= URB_FREE_BUFFER;
+ surb->urb->transfer_flags |= URB_FREE_BUFFER;
- return usb_submit_urb(&surb->urb, GFP_ATOMIC);
+ return usb_submit_urb(surb->urb, GFP_ATOMIC);
}
static void smsusb_stop_streaming(struct smsusb_device_t *dev)
@@ -178,7 +178,7 @@ static void smsusb_stop_streaming(struct smsusb_device_t *dev)
int i;
for (i = 0; i < MAX_URBS; i++) {
- usb_kill_urb(&dev->surbs[i].urb);
+ usb_kill_urb(dev->surbs[i].urb);
if (dev->surbs[i].wq.func)
cancel_work_sync(&dev->surbs[i].wq);
@@ -338,6 +338,8 @@ static void smsusb_term_device(struct usb_interface *intf)
struct smsusb_device_t *dev = usb_get_intfdata(intf);
if (dev) {
+ int i;
+
dev->state = SMSUSB_DISCONNECTED;
smsusb_stop_streaming(dev);
@@ -346,6 +348,9 @@ static void smsusb_term_device(struct usb_interface *intf)
if (dev->coredev)
smscore_unregister_device(dev->coredev);
+ for (i = 0; i < MAX_URBS; i++)
+ usb_free_urb(dev->surbs[i].urb);
+
pr_debug("device 0x%p destroyed\n", dev);
kfree(dev);
}
@@ -463,7 +468,9 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
/* initialize urbs */
for (i = 0; i < MAX_URBS; i++) {
dev->surbs[i].dev = dev;
- usb_init_urb(&dev->surbs[i].urb);
+ dev->surbs[i].urb = usb_alloc_urb(0, GFP_KERNEL);
+ if (!dev->surbs[i].urb)
+ goto err_unregister_device;
}
pr_debug("smsusb_start_streaming(...).\n");
@@ -486,6 +493,7 @@ static int smsusb_init_device(struct usb_interface *intf, int board_id)
return rc;
err_unregister_device:
+ /* smsusb_term_device() frees any allocated urb. */
smsusb_term_device(intf);
#ifdef CONFIG_MEDIA_CONTROLLER_DVB
media_device_unregister(mdev);
---
base-commit: 34d7bf1c8e59f5fbf438ee32c96389ebe41ca2e8
change-id: 20240410-smatch-8f235d50753d
Best regards,
--
Ricardo Ribalda <ribalda@chromium.org>
^ permalink raw reply related
* Re: [PATCH 03/18] backlight: corgi_lcd: Constify lcd_ops
From: Daniel Thompson @ 2024-04-15 12:48 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Lee Jones, Jingoo Han, Helge Deller, Bruno Prémont,
Jiri Kosina, Benjamin Tissoires, Alexander Shiyan, Sascha Hauer,
Pengutronix Kernel Team, Shawn Guo, Fabio Estevam, dri-devel,
linux-fbdev, linux-kernel, linux-input, linux-arm-kernel, imx,
linux-omap
In-Reply-To: <20240414-video-backlight-lcd-ops-v1-3-9b37fcbf546a@kernel.org>
On Sun, Apr 14, 2024 at 06:36:01PM +0200, Krzysztof Kozlowski wrote:
> 'struct lcd_ops' is not modified by core backlight code, so it can be
> made const for increased code safety.
>
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Daniel.
^ 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