6.1.39-rc1 review
Subsystems (8)
Greg Kroah-Hartman
maintainerPATCH 425/591 media: venus: helpers: Fix ALIGN() of non power of two
In reply to Greg Kroah-HartmanFrom: Rikard Falkeborn <[email protected]>
[ Upstream commit 927e78ac8bc58155316cf6f46026e1912bbbbcfc ]
ALIGN() expects its second argument to be a power of 2, otherwise incorrect results are produced for some inputs. The output can be both larger or smaller than what is expected.
For example, ALIGN(304, 192) equals 320 instead of 384, and ALIGN(65, 192) equals 256 instead of 192.
However, nestling two ALIGN() as is done in this case seem to only produce results equal to or bigger than the expected result if ALIGN() had handled non powers of two, and that in turn results in framesizes that are either the correct size or too large.
Fortunately, since 192 * 4 / 3 equals 256, it turns out that one ALIGN() is sufficient.
--- drivers/media/platform/qcom/venus/helpers.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/helpers.c +2 -2
@@ -1036,8 +1036,8 @@ static u32 get_framesize_raw_yuv420_tp10_ubwc(u32 width, u32 height)u32 extradata =SZ_16K ;u32 size; - y_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); - uv_stride =ALIGN (ALIGN (width,192 ) *4 /3 ,256 ); + y_stride =ALIGN (width *4 /3 ,256 ); + uv_stride =ALIGN (width *4 /3 ,256 ); y_sclines =ALIGN (height,16 ); uv_sclines =ALIGN ((height +1 ) >>1 ,16 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 426/591 media: atomisp: gmin_platform: fix out_len in gmin_get_config_dsm_var()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit 1657f2934daf89e8d9fa4b2697008909eb22c73e ]
Ideally, strlen(cur->string.pointer) and strlen(out) would be the same. But this code is using strscpy() to avoid a potential buffer overflow. So in the same way we should take the strlen() of the smaller string to avoid a buffer overflow in the caller, gmin_get_var_int().
--- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +1 -1
@@ -1280,7 +1280,7 @@ static int gmin_get_config_dsm_var(struct device *dev,dev_info (dev,"found _DSM entry for '%s': %s\n" , var, cur->string.pointer);strscpy (out, cur->string.pointer, *out_len); - *out_len =strlen (cur->string.pointer); + *out_len =strlen (out);ACPI_FREE (obj);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 427/591 sh: Avoid using IRQ0 on SH3 and SH4
In reply to Greg Kroah-HartmanFrom: Sergey Shtylyov <[email protected]>
[ Upstream commit a8ac2961148e8c720dc760f2e06627cd5c55a154 ]
IRQ0 is no longer returned by platform_get_irq() and its ilk -- they now return -EINVAL instead. However, the kernel code supporting SH3/4-based SoCs still maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed are using IRQ0 for the SMSC911x compatible Ethernet chip.
--- arch/sh/include/mach-common/mach/highlander.h | 2 +- arch/sh/include/mach-common/mach/r2d.h | 2 +- arch/sh/include/mach-dreamcast/mach/sysasic.h | 2 +- arch/sh/include/mach-se/mach/se7724.h | 2 +- arch/sh/kernel/cpu/sh3/entry.S | 4 ++-- include/linux/sh_intc.h | 6 +++--- 6 files changed, 9 insertions(+), 9 deletions(-)
arch/sh/include/mach-common/mach/highlander.h +1 -1
@@ -176,7 +176,7 @@#define IVDR_CK_ON 4/* iVDR Clock ON */ #endif -#define HL_FPGA_IRQ_BASE 200 +#define HL_FPGA_IRQ_BASE (200 + 16)#define HL_NR_IRL 15#define IRQ_AX88796 (HL_FPGA_IRQ_BASE + 0)
arch/sh/include/mach-common/mach/r2d.h +1 -1
@@ -47,7 +47,7 @@#define IRLCNTR1 (PA_BCR + 0)/* Interrupt Control Register1 */ -#define R2D_FPGA_IRQ_BASE 100 +#define R2D_FPGA_IRQ_BASE (100 + 16)#define IRQ_VOYAGER (R2D_FPGA_IRQ_BASE + 0)#define IRQ_EXT (R2D_FPGA_IRQ_BASE + 1)
arch/sh/include/mach-dreamcast/mach/sysasic.h +1 -1
@@ -22,7 +22,7 @@takes. */ -#define HW_EVENT_IRQ_BASE 48 +#define HW_EVENT_IRQ_BASE (48 + 16)/* IRQ 13 */ #define HW_EVENT_VSYNC (HW_EVENT_IRQ_BASE + 5)/* VSync */
arch/sh/include/mach-se/mach/se7724.h +1 -1
@@ -37,7 +37,7 @@#define IRQ2_IRQ evt2irq(0x640)/* Bits in IRQ012 registers */ -#define SE7724_FPGA_IRQ_BASE 220 +#define SE7724_FPGA_IRQ_BASE (220 + 16)/* IRQ0 */ #define IRQ0_BASE SE7724_FPGA_IRQ_BASE
arch/sh/kernel/cpu/sh3/entry.S +2 -2
@@ -470,9 +470,9 @@ ENTRY(handle_interrupt) mov r4, r0 ! save vector->jmp table offset for later shlr2 r4 ! vector to IRQ# conversion - add #-0x10, r4 - cmp/pz r4 ! is it a valid IRQ? + mov #0x10, r5 + cmp/hs r5, r4 ! is it a valid IRQ? bt 10f /*
include/linux/sh_intc.h +3 -3
@@ -13,9 +13,9 @@/* * Convert back and forth between INTEVT and IRQ values. */ -#ifdef CONFIG_CPU_HAS_INTEVT -#define evt2irq (evt) (((evt) >> 5) - 16) -#define irq2evt (irq) (((irq) + 16) << 5) +#ifdef CONFIG_CPU_HAS_INTEVT /* Avoid IRQ0 (invalid for platform devices) */ +#define evt2irq (evt) ((evt) >> 5) +#define irq2evt (irq) ((irq) << 5)#else #define evt2irq (evt) (evt)#define irq2evt (irq) (irq)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 428/591 gfs2: Fix duplicate should_fault_in_pages() call
In reply to Greg Kroah-HartmanFrom: Bob Peterson <[email protected]>
[ Upstream commit c8ed1b35931245087968fd95b2ec3dfc50f77769 ]
In gfs2_file_buffered_write(), we currently jump from the second call of function should_fault_in_pages() to above the first call, so should_fault_in_pages() is getting called twice in a row, causing it to accidentally fall back to single-page writes rather than trying the more efficient multi-page writes first.
Fix that by moving the retry label to the correct place, behind the first call to should_fault_in_pages().
--- fs/gfs2/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/file.c +1 -1
@@ -1029,8 +1029,8 @@ static ssize_t gfs2_file_buffered_write(struct kiocb *iocb, }gfs2_holder_init (ip->i_gl,LM_ST_EXCLUSIVE ,0 , gh); -retry:if (should_fault_in_pages (from, iocb, &prev_count, &window_size)) { +retry: window_size -=fault_in_iov_iter_readable (from, window_size);if (!window_size) { ret = -EFAULT ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 429/591 f2fs: fix potential deadlock due to unpaired node_write lock use
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit f082c6b205a06953f26c40bdc7621cc5a58ceb7c ]
If S_NOQUOTA is cleared from inode during data page writeback of quota file, it may miss to unlock node_write lock, result in potential deadlock, fix to use the lock in paired.
Kworker Thread
- writepage
if (IS_NOQUOTA())
f2fs_down_read(&sbi->node_write);
- vfs_cleanup_quota_inode
- inode->i_flags &= ~S_NOQUOTA;
if (IS_NOQUOTA())
f2fs_up_read(&sbi->node_write);
--- fs/f2fs/compress.c | 7 ++++--- fs/f2fs/data.c | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-)
fs/f2fs/compress.c +4 -3
@@ -1235,6 +1235,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,unsigned int last_index = cc->cluster_size -1 ;loff_t psize;int i, err; +bool quota_inode =IS_NOQUOTA (inode);/* we should bypass data pages to proceed the kworkder jobs */ if (unlikely (f2fs_cp_error (sbi))) {
@@ -1242,7 +1243,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, goto out_free; } -if (IS_NOQUOTA (inode)) { +if (quota_inode) {/* * We need to wait for node_write to avoid block allocation during * checkpoint. This can only happen to quota writes which can cause
@@ -1364,7 +1365,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,set_inode_flag (inode,FI_FIRST_BLOCK_WRITTEN );f2fs_put_dnode (&dn); -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write);else f2fs_unlock_op (sbi);
@@ -1390,7 +1391,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc, out_put_dnode:f2fs_put_dnode (&dn); out_unlock_op: -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write);else f2fs_unlock_op (sbi);
fs/f2fs/data.c +4 -3
@@ -2759,6 +2759,7 @@ int f2fs_write_single_data_page(struct page *page, int *submitted,loff_t psize = (loff_t)(page->index +1 ) <<PAGE_SHIFT ;unsigned offset =0 ;bool need_balance_fs = false; +bool quota_inode =IS_NOQUOTA (inode);int err =0 ;struct f2fs_io_info fio = { .sbi = sbi,
@@ -2816,19 +2817,19 @@ int f2fs_write_single_data_page(struct page *page, int *submitted, goto out;/* Dentry/quota blocks are controlled by checkpoint */ -if (S_ISDIR (inode->i_mode) ||IS_NOQUOTA (inode)) { +if (S_ISDIR (inode->i_mode) || quota_inode) {/* * We need to wait for node_write to avoid block allocation during * checkpoint. This can only happen to quota writes which can cause * the below discard race condition. */ -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_down_read (&sbi->node_write); fio.need_lock =LOCK_DONE ; err =f2fs_do_write_data_page (&fio); -if (IS_NOQUOTA (inode)) +if (quota_inode)f2fs_up_read (&sbi->node_write); goto done;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 430/591 f2fs: fix to avoid NULL pointer dereference f2fs_write_end_io()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit d8189834d4348ae608083e1f1f53792cfcc2a9bc ]
butt3rflyh4ck reports a bug as below:
When a thread always calls F2FS_IOC_RESIZE_FS to resize fs, if resize fs is failed, f2fs kernel thread would invoke callback function to update f2fs io info, it would call f2fs_write_end_io and may trigger null-ptr-deref in NODE_MAPPING.
general protection fault, probably for non-canonical address KASAN: null-ptr-deref in range [0x0000000000000030-0x0000000000000037] RIP: 0010:NODE_MAPPING fs/f2fs/f2fs.h:1972 [inline] RIP: 0010:f2fs_write_end_io+0x727/0x1050 fs/f2fs/data.c:370 <TASK> bio_endio+0x5af/0x6c0 block/bio.c:1608 req_bio_endio block/blk-mq.c:761 [inline] blk_update_request+0x5cc/0x1690 block/blk-mq.c:906 blk_mq_end_request+0x59/0x4c0 block/blk-mq.c:1023 lo_complete_rq+0x1c6/0x280 drivers/block/loop.c:370 blk_complete_reqs+0xad/0xe0 block/blk-mq.c:1101 __do_softirq+0x1d4/0x8ef kernel/softirq.c:571 run_ksoftirqd kernel/softirq.c:939 [inline] run_ksoftirqd+0x31/0x60 kernel/softirq.c:931 smpboot_thread_fn+0x659/0x9e0 kernel/smpboot.c:164 kthread+0x33e/0x440 kernel/kthread.c:379 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:308
The root cause is below race case can cause leaving dirty metadata in f2fs after filesystem is remount as ro:
Thread A Thread B
- f2fs_ioc_resize_fs
- f2fs_readonly --- return false
- f2fs_resize_fs
- f2fs_remount
- write_checkpoint
- set f2fs as ro
- free_segment_range
- update meta_inode's data
Then, if f2fs_put_super() fails to write_checkpoint due to readonly status, and meta_inode's dirty data will be writebacked after node_inode is put, finally, f2fs_write_end_io will access NULL pointer on sbi->node_inode.
Thread A IRQ context
- f2fs_put_super
- write_checkpoint fails
- iput(node_inode)
- node_inode = NULL
- iput(meta_inode)
- write_inode_now
- f2fs_write_meta_page
- f2fs_write_end_io
- NODE_MAPPING(sbi)
: access NULL pointer on node_inode
--- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/f2fs/gc.c | 21 ++++++++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-)
fs/f2fs/f2fs.h +1 -1
@@ -3817,7 +3817,7 @@ void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi);block_t f2fs_start_bidx_of_node (unsigned int node_ofs,struct inode *inode);int f2fs_gc (struct f2fs_sb_info *sbi,struct f2fs_gc_control *gc_control);void f2fs_build_gc_manager (struct f2fs_sb_info *sbi); -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count); +int f2fs_resize_fs (struct file *filp,__u64 block_count);int __init f2fs_create_garbage_collection_cache (void );void f2fs_destroy_garbage_collection_cache (void );
fs/f2fs/file.c +1 -1
@@ -3279,7 +3279,7 @@ static int f2fs_ioc_resize_fs(struct file *filp, unsigned long arg) sizeof(block_count)))return -EFAULT ; -return f2fs_resize_fs (sbi, block_count); +return f2fs_resize_fs (filp, block_count); }static int f2fs_ioc_enable_verity (struct file *filp,unsigned long arg)
fs/f2fs/gc.c +18 -3
@@ -2110,8 +2110,9 @@ static void update_fs_metadata(struct f2fs_sb_info *sbi, int secs) } } -int f2fs_resize_fs (struct f2fs_sb_info *sbi,__u64 block_count) +int f2fs_resize_fs (struct file *filp,__u64 block_count) { +struct f2fs_sb_info *sbi =F2FS_I_SB (file_inode (filp));__u64 old_block_count, shrunk_blocks;struct cp_control cpc = {CP_RESIZE ,0 ,0 ,0 };unsigned int secs;
@@ -2149,12 +2150,18 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)return -EINVAL ; } + err =mnt_want_write_file (filp); +if (err) +return err; + shrunk_blocks = old_block_count - block_count; secs =div_u64 (shrunk_blocks,BLKS_PER_SEC (sbi));/* stop other GC */ -if (!f2fs_down_write_trylock (&sbi->gc_lock)) -return -EAGAIN ; +if (!f2fs_down_write_trylock (&sbi->gc_lock)) { + err = -EAGAIN ; + goto out_drop_write; + }/* stop CP to protect MAIN_SEC in free_segment_range */ f2fs_lock_op (sbi);
@@ -2174,10 +2181,18 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count) out_unlock:f2fs_unlock_op (sbi);f2fs_up_write (&sbi->gc_lock); +out_drop_write: +mnt_drop_write_file (filp);if (err)return err;freeze_super (sbi->sb); + +if (f2fs_readonly (sbi->sb)) { +thaw_super (sbi->sb); +return -EROFS ; + } +f2fs_down_write (&sbi->gc_lock);f2fs_down_write (&sbi->cp_global_sem);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 431/591 KVM: s390: fix KVM_S390_GET_CMMA_BITS for GFNs in memslot holes
In reply to Greg Kroah-HartmanFrom: Nico Boehr <[email protected]>
[ Upstream commit 285cff4c0454340a4dc53f46e67f2cb1c293bd74 ]
The KVM_S390_GET_CMMA_BITS ioctl may return incorrect values when userspace specifies a start_gfn outside of memslots.
This can occur when a VM has multiple memslots with a hole in between:
+-----+----------+--------+--------+
| ... | Slot N-1 | <hole> | Slot N |
+-----+----------+--------+--------+
^ ^ ^ ^
| | | |
GFN A A+B | |
A+B+C |
A+B+C+DWhen userspace specifies a GFN in [A+B, A+B+C), it would expect to get the CMMA values of the first dirty page in Slot N. However, userspace may get a start_gfn of A+B+C+D with a count of 0, hence completely skipping over any dirty pages in slot N.
The error is in kvm_s390_next_dirty_cmma(), which assumes gfn_to_memslot_approx() will return the memslot _below_ the specified GFN when the specified GFN lies outside a memslot. In reality it may return either the memslot below or above the specified GFN.
When a memslot above the specified GFN is returned this happens:
- ofs is calculated, but since the memslot's base_gfn is larger than the specified cur_gfn, ofs will underflow to a huge number.
- ofs is passed to find_next_bit(). Since ofs will exceed the memslot's number of pages, the number of pages in the memslot is returned, completely skipping over all bits in the memslot userspace would be interested in.
Fix this by resetting ofs to zero when a memslot _above_ cur_gfn is returned (cur_gfn < ms->base_gfn).
Message-Id: <[email protected]>
--- arch/s390/kvm/kvm-s390.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/s390/kvm/kvm-s390.c +4 -0
@@ -2147,6 +2147,10 @@ static unsigned long kvm_s390_next_dirty_cmma(struct kvm_memslots *slots, ms = container_of(mnode, struct kvm_memory_slot, gfn_node[slots->node_idx]); ofs =0 ; } + +if (cur_gfn < ms->base_gfn) + ofs =0 ; + ofs =find_next_bit (kvm_second_dirty_bitmap (ms), ms->npages, ofs);while (ofs >= ms->npages && (mnode =rb_next (mnode))) { ms = container_of(mnode, struct kvm_memory_slot, gfn_node[slots->node_idx]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 432/591 usb: dwc3: qcom: Release the correct resources in dwc3_qcom_remove()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 8fd95da2cfb5046c4bb5a3cdc9eb7963ba8b10dd ]
In the probe, some resources are allocated with dwc3_qcom_of_register_core() or dwc3_qcom_acpi_register_core(). The corresponding resources are already coorectly freed in the error handling path of the probe, but not in the remove function.
Fix it.
Message-ID: <c0215a84cdf18fb3514c81842783ec53cf149deb.1685891059.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-qcom.c +5 -1
@@ -950,11 +950,15 @@ static int dwc3_qcom_probe(struct platform_device *pdev)static int dwc3_qcom_remove (struct platform_device *pdev) {struct dwc3_qcom *qcom =platform_get_drvdata (pdev); +struct device_node *np = pdev->dev.of_node;struct device *dev = &pdev->dev;int i;device_remove_software_node (&qcom->dwc3->dev); -of_platform_depopulate (dev); +if (np) +of_platform_depopulate (&pdev->dev); +else +platform_device_put (pdev);for (i = qcom->num_clocks -1 ; i >=0 ; i--) {clk_disable_unprepare (qcom->clks[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 433/591 usb: dwc3: qcom: Fix an error handling path in dwc3_qcom_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 4a944da707123686d372ec01ea60056902fadf35 ]
If dwc3_qcom_create_urs_usb_platdev() fails, some resources still need to be released, as already done in the other error handling path of the probe.
Message-ID: <b69fa8dd68d816e7d24c88d3eda776ceb28c5dc5.1685890571.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-qcom.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/usb/dwc3/dwc3-qcom.c +3 -2
@@ -865,9 +865,10 @@ static int dwc3_qcom_probe(struct platform_device *pdev)if (IS_ERR_OR_NULL (qcom->urs_usb)) {dev_err (dev,"failed to create URS USB platdev\n" );if (!qcom->urs_usb) -return -ENODEV ; + ret = -ENODEV ;else -return PTR_ERR (qcom->urs_usb); + ret =PTR_ERR (qcom->urs_usb); + goto clk_disable; } } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 434/591 usb: common: usb-conn-gpio: Set last role to unknown before initial detection
In reply to Greg Kroah-HartmanFrom: Prashanth K <[email protected]>
[ Upstream commit edd60d24bd858cef165274e4cd6cab43bdc58d15 ]
Currently if we bootup a device without cable connected, then usb-conn-gpio won't call set_role() since last_role is same as current role. This happens because during probe last_role gets initialised to zero.
To avoid this, added a new constant in enum usb_role, last_role is set to USB_ROLE_UNKNOWN before performing initial detection.
While at it, also handle default case for the usb_role switch in cdns3, intel-xhci-usb-role-switch & musb/jz4740 to avoid build warnings.
Message-ID: <[email protected]>
--- drivers/usb/cdns3/core.c | 2 ++ drivers/usb/common/usb-conn-gpio.c | 3 +++ drivers/usb/musb/jz4740.c | 2 ++ drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 ++ include/linux/usb/role.h | 1 + 5 files changed, 10 insertions(+)
drivers/usb/cdns3/core.c +2 -0
@@ -252,6 +252,8 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; +default : +break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +3 -0
@@ -257,6 +257,9 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info);device_set_wakeup_capable (&pdev->dev, true); +/* Set last role to unknown before performing the initial detection */ + info->last_role =USB_ROLE_UNKNOWN ; +/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +2 -0
@@ -91,6 +91,8 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; +default : +break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +2 -0
@@ -97,6 +97,8 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; +default : +break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +1 -0
@@ -11,6 +11,7 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST ,USB_ROLE_DEVICE , + USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 435/591 usb: dwc3-meson-g12a: Fix an error handling path in dwc3_meson_g12a_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 01052b91c9808e3c3b068ae2721cb728ec9aa4c0 ]
If dwc3_meson_g12a_otg_init() fails, resources allocated by the previous of_platform_populate() call should be released, as already done in the error handling path.
Message-ID: <9d28466de1808ccc756b4cc25fc72c482d133d13.1686403934.git.christophe.jaillet@wanadoo.fr>
--- drivers/usb/dwc3/dwc3-meson-g12a.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/dwc3/dwc3-meson-g12a.c +4 -1
@@ -805,7 +805,7 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) ret =dwc3_meson_g12a_otg_init (pdev, priv);if (ret) - goto err_phys_power; + goto err_plat_depopulate;pm_runtime_set_active (dev);pm_runtime_enable (dev);
@@ -813,6 +813,9 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev)return 0 ; +err_plat_depopulate: +of_platform_depopulate (dev); + err_phys_power:for (i =0 ; i <PHY_COUNT ; ++i)phy_power_off (priv->phys[i]);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 436/591 mfd: wcd934x: Fix an error handling path in wcd934x_slim_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit f190b4891a3f9fac123a7afd378d4143a2723313 ]
If devm_gpiod_get_optional() fails, some resources need to be released, as already done in the .remove() function.
While at it, remove the unneeded error code from a dev_err_probe() call. It is already added in a human readable way by dev_err_probe() itself.
--- drivers/mfd/wcd934x.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mfd/wcd934x.c +7 -2
@@ -253,8 +253,9 @@ static int wcd934x_slim_probe(struct slim_device *sdev)usleep_range (600 ,650 ); reset_gpio =devm_gpiod_get_optional (dev,"reset" ,GPIOD_OUT_LOW );if (IS_ERR (reset_gpio)) { -return dev_err_probe (dev,PTR_ERR (reset_gpio), -"Failed to get reset gpio: err = %ld\n" ,PTR_ERR (reset_gpio)); + ret =dev_err_probe (dev,PTR_ERR (reset_gpio), +"Failed to get reset gpio\n" ); + goto err_disable_regulators; }msleep (20 );gpiod_set_value (reset_gpio,1 );
@@ -264,6 +265,10 @@ static int wcd934x_slim_probe(struct slim_device *sdev)dev_set_drvdata (dev, ddata);return 0 ; + +err_disable_regulators: +regulator_bulk_disable (WCD934X_MAX_SUPPLY , ddata->supplies); +return ret; }static void wcd934x_slim_remove (struct slim_device *sdev)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 437/591 mfd: intel-lpss: Add missing check for platform_get_resource
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit d918e0d5824495a75d00b879118b098fcab36fdb ]
Add the missing check for platform_get_resource and return error if it fails.
--- drivers/mfd/intel-lpss-acpi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mfd/intel-lpss-acpi.c +3 -0
@@ -183,6 +183,9 @@ static int intel_lpss_acpi_probe(struct platform_device *pdev)return -ENOMEM ; info->mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!info->mem) +return -ENODEV ; + info->irq =platform_get_irq (pdev,0 ); ret =intel_lpss_probe (&pdev->dev, info);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 438/591 Revert "usb: common: usb-conn-gpio: Set last role to unknown before initial detection"
In reply to Greg Kroah-HartmanFrom: Greg Kroah-Hartman <[email protected]>
[ Upstream commit df49f2a0ac4a34c0cb4b5c233fcfa0add644c43c ]
This reverts commit edd60d24bd858cef165274e4cd6cab43bdc58d15.
Heikki reports that this should not be a global flag just to work around one broken driver and should be fixed differently, so revert it.
--- drivers/usb/cdns3/core.c | 2 -- drivers/usb/common/usb-conn-gpio.c | 3 --- drivers/usb/musb/jz4740.c | 2 -- drivers/usb/roles/intel-xhci-usb-role-switch.c | 2 -- include/linux/usb/role.h | 1 - 5 files changed, 10 deletions(-)
drivers/usb/cdns3/core.c +0 -2
@@ -252,8 +252,6 @@ static enum usb_role cdns_hw_role_state_machine(struct cdns *cdns)if (!vbus) role =USB_ROLE_NONE ;break ; -default : -break ; }dev_dbg (cdns->dev,"role %d -> %d\n" , cdns->role, role);
drivers/usb/common/usb-conn-gpio.c +0 -3
@@ -257,9 +257,6 @@ static int usb_conn_probe(struct platform_device *pdev)platform_set_drvdata (pdev, info);device_set_wakeup_capable (&pdev->dev, true); -/* Set last role to unknown before performing the initial detection */ - info->last_role =USB_ROLE_UNKNOWN ; -/* Perform initial detection */ usb_conn_queue_dwork (info,0 );
drivers/usb/musb/jz4740.c +0 -2
@@ -91,8 +91,6 @@ static int jz4740_musb_role_switch_set(struct usb_role_switch *sw,case USB_ROLE_HOST :atomic_notifier_call_chain (&phy->notifier,USB_EVENT_ID , phy);break ; -default : -break ; }return 0 ;
drivers/usb/roles/intel-xhci-usb-role-switch.c +0 -2
@@ -97,8 +97,6 @@ static int intel_xhci_usb_set_role(struct usb_role_switch *sw, val |=SW_VBUS_VALID ; drd_config =DRD_CONFIG_STATIC_DEVICE ;break ; -default : -break ; } val |=SW_IDPIN_EN ;if (data->enable_sw_switch) {
include/linux/usb/role.h +0 -1
@@ -11,7 +11,6 @@ enum usb_role {USB_ROLE_NONE ,USB_ROLE_HOST , USB_ROLE_DEVICE, - USB_ROLE_UNKNOWN, }; typedef int (*usb_role_switch_set_t)(struct usb_role_switch *sw,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 439/591 serial: 8250_omap: Use force_suspend and resume for system suspend
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit 20a41a62618df85f3a2981008edec5cadd785e0a ]
We should not rely on autosuspend timeout for system suspend. Instead, let's use force_suspend and force_resume functions. Otherwise the serial port controller device may not be idled on suspend.
As we are doing a register write on suspend to configure the serial port, we still need to runtime PM resume the port on suspend.
While at it, let's switch to pm_runtime_resume_and_get() and check for errors returned. And let's add the missing line break before return to the suspend function while at it.
Message-ID: <[email protected]>
--- drivers/tty/serial/8250/8250_omap.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_omap.c +15 -5
@@ -1505,25 +1505,35 @@ static int omap8250_suspend(struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev);struct uart_8250_port *up =serial8250_get_port (priv->line); +int err;serial8250_suspend_port (priv->line); -pm_runtime_get_sync (dev); + err =pm_runtime_resume_and_get (dev); +if (err) +return err;if (!device_may_wakeup (dev)) priv->wer =0 ;serial_out (up,UART_OMAP_WER , priv->wer); -pm_runtime_mark_last_busy (dev); -pm_runtime_put_autosuspend (dev); - + err =pm_runtime_force_suspend (dev);flush_work (&priv->qos_work); -return 0 ; + +return err; }static int omap8250_resume (struct device *dev) {struct omap8250_priv *priv =dev_get_drvdata (dev); +int err; + err =pm_runtime_force_resume (dev); +if (err) +return err;serial8250_resume_port (priv->line); +/* Paired with pm_runtime_resume_and_get() in omap8250_suspend() */ +pm_runtime_mark_last_busy (dev); +pm_runtime_put_autosuspend (dev); +return 0 ; }#else
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 440/591 device property: Fix documentation for fwnode_get_next_parent()
In reply to Greg Kroah-HartmanFrom: Miaoqian Lin <[email protected]>
[ Upstream commit f18caf261398a7f2de4fa3f600deb87072fe7b8d ]
Use fwnode_handle_put() on the node pointer to release the refcount. Change fwnode_handle_node() to fwnode_handle_put().
Stable-dep-of: 39d422555e43 ("drivers: fwnode: fix fwnode_irq_get[_byname]()")
--- drivers/base/property.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/property.c +1 -1
@@ -601,7 +601,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);* node's parents. * * Returns a node pointer with refcount incremented, use -* fwnode_handle_node() on it when done. +* fwnode_handle_put() on it when done. */ struct fwnode_handle *fwnode_get_next_parent (struct fwnode_handle *fwnode) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 441/591 device property: Clarify description of returned value in some functions
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 295209ca7b5b3aa6375d6190311b2ae804dbcf65 ]
Some of the functions do not provide Return: section on absence of which kernel-doc complains. Besides that several functions return the fwnode handle with incremented reference count. Add a respective note to make sure that the caller decrements it when it's not needed anymore.
While at it, unify the style of the Return: sections.
Stable-dep-of: 39d422555e43 ("drivers: fwnode: fix fwnode_irq_get[_byname]()")
--- drivers/base/property.c | 124 +++++++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 34 deletions(-)
drivers/base/property.c +90 -34
@@ -30,6 +30,8 @@ EXPORT_SYMBOL_GPL(dev_fwnode);* @propname: Name of the property * * Check if property @propname is present in the device firmware description. +* +* Return: true if property @propname is present. Otherwise, returns false. */ bool device_property_present (struct device *dev,const char *propname) {
@@ -41,6 +43,8 @@ EXPORT_SYMBOL_GPL(device_property_present);* fwnode_property_present - check if a property of a firmware node is present * @fwnode: Firmware node whose property to check * @propname: Name of the property +* +* Return: true if property @propname is present. Otherwise, returns false. */ bool fwnode_property_present (const struct fwnode_handle *fwnode,const char *propname)
@@ -500,10 +504,10 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_string);* Obtain a reference based on a named property in an fwnode, with * integer arguments. * -* Caller is responsible to call fwnode_handle_put() on the returned -* args->fwnode pointer. +* The caller is responsible for calling fwnode_handle_put() on the returned +* @args->fwnode pointer. * -* Returns: %0 on success +* Return: %0 on success * %-ENOENT when the index is out of bounds, the index has an empty * reference or the property was not found * %-EINVAL on parse error
@@ -539,8 +543,11 @@ EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);* * @index can be used when the named reference holds a table of references. * -* Returns pointer to the reference fwnode, or ERR_PTR. Caller is responsible to -* call fwnode_handle_put() on the returned fwnode pointer. +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* +* Return: a pointer to the reference fwnode, when found. Otherwise, +* returns an error pointer. */ struct fwnode_handle *fwnode_find_reference(const struct fwnode_handle *fwnode, const char *name,
@@ -559,7 +566,7 @@ EXPORT_SYMBOL_GPL(fwnode_find_reference);* fwnode_get_name - Return the name of a node * @fwnode: The firmware node * -* Returns a pointer to the node name. +* Return: a pointer to the node name, or %NULL. */ const char *fwnode_get_name (const struct fwnode_handle *fwnode) {
@@ -571,7 +578,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_name);* fwnode_get_name_prefix - Return the prefix of node for printing purposes * @fwnode: The firmware node * -* Returns the prefix of a node, intended to be printed right before the node. +* Return: the prefix of a node, intended to be printed right before the node. * The prefix works also as a separator between the nodes. */ const char *fwnode_get_name_prefix (const struct fwnode_handle *fwnode)
@@ -583,7 +590,10 @@ const char *fwnode_get_name_prefix(const struct fwnode_handle *fwnode)* fwnode_get_parent - Return parent firwmare node * @fwnode: Firmware whose parent is retrieved * -* Return parent firmware node of the given node if possible or %NULL if no +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* +* Return: parent firmware node of the given node if possible or %NULL if no * parent was available. */ struct fwnode_handle *fwnode_get_parent (const struct fwnode_handle *fwnode)
@@ -600,8 +610,12 @@ EXPORT_SYMBOL_GPL(fwnode_get_parent);* on the passed node, making it suitable for iterating through a * node's parents. * -* Returns a node pointer with refcount incremented, use -* fwnode_handle_put() on it when done. +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. Note that this function also puts a reference to @fwnode +* unconditionally. +* +* Return: parent firmware node of the given node if possible or %NULL if no +* parent was available. */ struct fwnode_handle *fwnode_get_next_parent (struct fwnode_handle *fwnode) {
@@ -621,8 +635,10 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_parent);* firmware node that has a corresponding struct device and returns that struct * device. * -* The caller of this function is expected to call put_device() on the returned -* device when they are done. +* The caller is responsible for calling put_device() on the returned device +* pointer. +* +* Return: a pointer to the device of the @fwnode's closest ancestor. */ struct device *fwnode_get_next_parent_dev (struct fwnode_handle *fwnode) {
@@ -643,7 +659,7 @@ struct device *fwnode_get_next_parent_dev(struct fwnode_handle *fwnode)* fwnode_count_parents - Return the number of parents a node has * @fwnode: The node the parents of which are to be counted * -* Returns the number of parents a node has. +* Return: the number of parents a node has. */ unsigned int fwnode_count_parents (const struct fwnode_handle *fwnode) {
@@ -662,12 +678,12 @@ EXPORT_SYMBOL_GPL(fwnode_count_parents);* @fwnode: The node the parent of which is requested * @depth: Distance of the parent from the node * -* Returns the nth parent of a node. If there is no parent at the requested +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* +* Return: the nth parent of a node. If there is no parent at the requested * @depth, %NULL is returned. If @depth is 0, the functionality is equivalent to * fwnode_handle_get(). For @depth == 1, it is fwnode_get_parent() and so on. -* -* The caller is responsible for calling fwnode_handle_put() for the returned -* node. */ struct fwnode_handle *fwnode_get_nth_parent (struct fwnode_handle *fwnode,unsigned int depth)
@@ -692,7 +708,7 @@ EXPORT_SYMBOL_GPL(fwnode_get_nth_parent);* * A node is considered an ancestor of itself too. * -* Returns true if @ancestor is an ancestor of @child. Otherwise, returns false. +* Return: true if @ancestor is an ancestor of @child. Otherwise, returns false. */ bool fwnode_is_ancestor_of (struct fwnode_handle *ancestor,struct fwnode_handle *child) {
@@ -717,6 +733,10 @@ bool fwnode_is_ancestor_of(struct fwnode_handle *ancestor, struct fwnode_handle* fwnode_get_next_child_node - Return the next child node handle for a node * @fwnode: Firmware node to find the next child node for. * @child: Handle to one of the node's child nodes or a %NULL handle. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. Note that this function also puts a reference to @child +* unconditionally. */ struct fwnode_handle * fwnode_get_next_child_node(const struct fwnode_handle *fwnode,
@@ -727,10 +747,13 @@ fwnode_get_next_child_node(const struct fwnode_handle *fwnode,EXPORT_SYMBOL_GPL (fwnode_get_next_child_node);/** -* fwnode_get_next_available_child_node - Return the next -* available child node handle for a node +* fwnode_get_next_available_child_node - Return the next available child node handle for a node * @fwnode: Firmware node to find the next child node for. * @child: Handle to one of the node's child nodes or a %NULL handle. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. Note that this function also puts a reference to @child +* unconditionally. */ struct fwnode_handle * fwnode_get_next_available_child_node(const struct fwnode_handle *fwnode,
@@ -754,7 +777,11 @@ EXPORT_SYMBOL_GPL(fwnode_get_next_available_child_node);/** * device_get_next_child_node - Return the next child node handle for a device * @dev: Device to find the next child node for. -* @child: Handle to one of the device's child nodes or a null handle. +* @child: Handle to one of the device's child nodes or a %NULL handle. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. Note that this function also puts a reference to @child +* unconditionally. */ struct fwnode_handle *device_get_next_child_node (struct device *dev,struct fwnode_handle *child)
@@ -779,6 +806,9 @@ EXPORT_SYMBOL_GPL(device_get_next_child_node);* fwnode_get_named_child_node - Return first matching named child node handle * @fwnode: Firmware node to find the named child node for. * @childname: String to match child node name against. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. */ struct fwnode_handle * fwnode_get_named_child_node(const struct fwnode_handle *fwnode,
@@ -792,6 +822,9 @@ EXPORT_SYMBOL_GPL(fwnode_get_named_child_node);* device_get_named_child_node - Return first matching named child node handle * @dev: Device to find the named child node for. * @childname: String to match child node name against. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. */ struct fwnode_handle *device_get_named_child_node (struct device *dev,const char *childname)
@@ -804,7 +837,10 @@ EXPORT_SYMBOL_GPL(device_get_named_child_node);* fwnode_handle_get - Obtain a reference to a device node * @fwnode: Pointer to the device node to obtain the reference to. * -* Returns the fwnode handle. +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* +* Return: the fwnode handle. */ struct fwnode_handle *fwnode_handle_get (struct fwnode_handle *fwnode) {
@@ -833,6 +869,8 @@ EXPORT_SYMBOL_GPL(fwnode_handle_put);* fwnode_device_is_available - check if a device is available for use * @fwnode: Pointer to the fwnode of the device. * +* Return: true if device is available for use. Otherwise, returns false. +* * For fwnode node types that don't implement the .device_is_available() * operation, this function returns true. */
@@ -851,6 +889,8 @@ EXPORT_SYMBOL_GPL(fwnode_device_is_available);/** * device_get_child_node_count - return the number of child nodes for device * @dev: Device to cound the child nodes for +* +* Return: the number of child nodes for a given device. */ unsigned int device_get_child_node_count (struct device *dev) {
@@ -926,7 +966,7 @@ EXPORT_SYMBOL_GPL(device_get_phy_mode);* @fwnode: Pointer to the firmware node * @index: Index of the IO range * -* Returns a pointer to the mapped memory. +* Return: a pointer to the mapped memory. */ void __iomem *fwnode_iomap (struct fwnode_handle *fwnode,int index) {
@@ -939,8 +979,8 @@ EXPORT_SYMBOL(fwnode_iomap);* @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ * -* Returns Linux IRQ number on success. Other values are determined -* accordingly to acpi_/of_ irq_get() operation. +* Return: Linux IRQ number on success. Other values are determined +* according to acpi_irq_get() or of_irq_get() operation. */ int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index) {
@@ -959,8 +999,7 @@ EXPORT_SYMBOL(fwnode_irq_get);* number of the IRQ resource corresponding to the index of the matched * string. * -* Return: -* Linux IRQ number on success, or negative errno otherwise. +* Return: Linux IRQ number on success, or negative errno otherwise. */ int fwnode_irq_get_byname (const struct fwnode_handle *fwnode,const char *name) {
@@ -982,7 +1021,11 @@ EXPORT_SYMBOL(fwnode_irq_get_byname);* @fwnode: Pointer to the parent firmware node * @prev: Previous endpoint node or %NULL to get the first * -* Returns an endpoint firmware node pointer or %NULL if no more endpoints +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. Note that this function also puts a reference to @prev +* unconditionally. +* +* Return: an endpoint firmware node pointer or %NULL if no more endpoints * are available. */ struct fwnode_handle *
@@ -1022,6 +1065,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_next_endpoint);* fwnode_graph_get_port_parent - Return the device fwnode of a port endpoint * @endpoint: Endpoint firmware node of the port * +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* * Return: the firmware node of the device the @endpoint belongs to. */ struct fwnode_handle *
@@ -1043,6 +1089,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_port_parent);* @fwnode: Endpoint firmware node pointing to the remote endpoint * * Extracts firmware node of a remote device the @fwnode points to. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. */ struct fwnode_handle *fwnode_graph_get_remote_port_parent (const struct fwnode_handle *fwnode)
@@ -1063,6 +1112,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port_parent);* @fwnode: Endpoint firmware node pointing to the remote endpoint * * Extracts firmware node of a remote port the @fwnode points to. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. */ struct fwnode_handle *fwnode_graph_get_remote_port (const struct fwnode_handle *fwnode)
@@ -1076,6 +1128,9 @@ EXPORT_SYMBOL_GPL(fwnode_graph_get_remote_port);* @fwnode: Endpoint firmware node pointing to the remote endpoint * * Extracts firmware node of a remote endpoint the @fwnode points to. +* +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. */ struct fwnode_handle *fwnode_graph_get_remote_endpoint (const struct fwnode_handle *fwnode)
@@ -1103,8 +1158,11 @@ static bool fwnode_graph_remote_available(struct fwnode_handle *ep)* @endpoint: identifier of the endpoint node under the port node * @flags: fwnode lookup flags * -* Return the fwnode handle of the local endpoint corresponding the port and -* endpoint IDs or NULL if not found. +* The caller is responsible for calling fwnode_handle_put() on the returned +* fwnode pointer. +* +* Return: the fwnode handle of the local endpoint corresponding the port and +* endpoint IDs or %NULL if not found. * * If FWNODE_GRAPH_ENDPOINT_NEXT is passed in @flags and the specified endpoint * has not been found, look for the closest endpoint ID greater than the
@@ -1112,9 +1170,6 @@ static bool fwnode_graph_remote_available(struct fwnode_handle *ep)* * Does not return endpoints that belong to disabled devices or endpoints that * are unconnected, unless FWNODE_GRAPH_DEVICE_DISABLED is passed in @flags. -* -* The returned endpoint needs to be released by calling fwnode_handle_put() on -* it when it is not needed any more. */ struct fwnode_handle * fwnode_graph_get_endpoint_by_id(const struct fwnode_handle *fwnode,
@@ -1320,7 +1375,8 @@ EXPORT_SYMBOL_GPL(fwnode_connection_find_match);* @fwnode and other device nodes. @match will be used to convert the * connection description to data the caller is expecting to be returned * through the @matches array. -* If @matches is NULL @matches_len is ignored and the total number of resolved +* +* If @matches is %NULL @matches_len is ignored and the total number of resolved * matches is returned. * * Return: Number of matches resolved, or negative errno.
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 442/591 drivers: fwnode: fix fwnode_irq_get[_byname]()
In reply to Greg Kroah-HartmanFrom: Matti Vaittinen <[email protected]>
[ Upstream commit 39d422555e43379516d4d13f5b7162a3dee6e646 ]
The fwnode_irq_get() and the fwnode_irq_get_byname() return 0 upon device-tree IRQ mapping failure. This is contradicting the fwnode_irq_get_byname() function documentation and can potentially be a source of errors like:
int probe(...) {
...
irq = fwnode_irq_get_byname();
if (irq <= 0)
return irq;
...
}Here we do correctly check the return value from fwnode_irq_get_byname() but the driver probe will now return success. (There was already one such user in-tree).
Change the fwnode_irq_get_byname() to work as documented and make also the fwnode_irq_get() follow same common convention returning a negative errno upon failure.
Message-ID: <3e64fe592dc99e27ef9a0b247fc49fa26b6b8a58.1685340157.git.mazziesaccount@gmail.com>
--- drivers/base/property.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/base/property.c +9 -3
@@ -979,12 +979,18 @@ EXPORT_SYMBOL(fwnode_iomap);* @fwnode: Pointer to the firmware node * @index: Zero-based index of the IRQ * -* Return: Linux IRQ number on success. Other values are determined -* according to acpi_irq_get() or of_irq_get() operation. +* Return: Linux IRQ number on success. Negative errno on failure. */ int fwnode_irq_get (const struct fwnode_handle *fwnode,unsigned int index) { -return fwnode_call_int_op (fwnode, irq_get, index); +int ret; + + ret =fwnode_call_int_op (fwnode, irq_get, index); +/* We treat mapping errors as invalid case */ +if (ret ==0 ) +return -EINVAL ; + +return ret; }EXPORT_SYMBOL (fwnode_irq_get);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 443/591 nvmem: sunplus-ocotp: release otp->clk before return
In reply to Greg Kroah-HartmanFrom: Yi Yingao <[email protected]>
[ Upstream commit 095bb8ba45f28ed15296eb5b7662e03e57d5e34e ]
Smatch reports:drivers/nvmem/sunplus-ocotp.c:205 sp_ocotp_probe()
warn: 'otp->clk' from clk_prepare() not released on lines: 196.
In the function sp_ocotp_probe(struct platform_device *pdev), otp->clk may not be released before return.
To fix this issue, using function clk_unprepare() to release otp->clk.
Message-ID: <[email protected]>
--- drivers/nvmem/sunplus-ocotp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/nvmem/sunplus-ocotp.c +7 -2
@@ -192,9 +192,11 @@ static int sp_ocotp_probe(struct platform_device *pdev) sp_ocotp_nvmem_config.dev = dev; nvmem =devm_nvmem_register (dev, &sp_ocotp_nvmem_config); -if (IS_ERR (nvmem)) -return dev_err_probe (&pdev->dev,PTR_ERR (nvmem), +if (IS_ERR (nvmem)) { + ret =dev_err_probe (&pdev->dev,PTR_ERR (nvmem),"register nvmem device fail\n" ); + goto err; + }platform_set_drvdata (pdev, nvmem);
@@ -203,6 +205,9 @@ static int sp_ocotp_probe(struct platform_device *pdev) (int)OTP_WORD_SIZE, (int)QAC628_OTP_SIZE);return 0 ; +err: +clk_unprepare (otp->clk); +return ret; }static const struct of_device_id sp_ocotp_dt_ids[] = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 444/591 nvmem: rmem: Use NVMEM_DEVID_AUTO
In reply to Greg Kroah-HartmanFrom: Phil Elwell <[email protected]>
[ Upstream commit 09dd7b993eddb3b48634fd5ddf27aa799785a9ee ]
It is reasonable to declare multiple nvmem blocks. Unless a unique 'id' is passed in for each block there may be name clashes.
Avoid this by using the magic token NVMEM_DEVID_AUTO.
Message-ID: <[email protected]>
--- drivers/nvmem/rmem.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/rmem.c +1 -0
@@ -71,6 +71,7 @@ static int rmem_probe(struct platform_device *pdev) config.dev = dev; config.priv = priv; config.name ="rmem" ; + config.id =NVMEM_DEVID_AUTO ; config.size = mem->size; config.reg_read = rmem_read;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 445/591 bus: fsl-mc: dont assume child devices are all fsl-mc devices
In reply to Greg Kroah-HartmanFrom: Laurentiu Tudor <[email protected]>
[ Upstream commit 303c9c63abb9390e906052863f82bb4e9824e5c0 ]
Changes in VFIO caused a pseudo-device to be created as child of fsl-mc devices causing a crash [1] when trying to bind a fsl-mc device to VFIO. Fix this by checking the device type when enumerating fsl-mc child devices.
[1]
Modules linked in: Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP CPU: 6 PID: 1289 Comm: sh Not tainted 6.2.0-rc5-00047-g7c46948a6e9c #2 Hardware name: NXP Layerscape LX2160ARDB (DT) pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : mc_send_command+0x24/0x1f0 lr : dprc_get_obj_region+0xfc/0x1c0
sp : ffff80000a88b900
x29: ffff80000a88b900 x28: ffff48a9429e1400 x27: 00000000000002b2
x26: ffff48a9429e1718 x25: 0000000000000000 x24: 0000000000000000
x23: ffffd59331ba3918 x22: ffffd59331ba3000 x21: 0000000000000000
x20: ffff80000a88b9b8 x19: 0000000000000000 x18: 0000000000000001
x17: 7270642f636d2d6c x16: 73662e3030303030 x15: ffffffffffffffff
x14: ffffd59330f1d668 x13: ffff48a8727dc389 x12: ffff48a8727dc386
x11: 0000000000000002 x10: 00008ceaf02f35d4 x9 : 0000000000000012 x8 : 0000000000000000 x7 : 0000000000000006 x6 : ffff80000a88bab0 x5 : 0000000000000000 x4 : 0000000000000000 x3 : ffff80000a88b9e8 x2 : ffff80000a88b9e8 x1 : 0000000000000000 x0 : ffff48a945142b80
Call trace: mc_send_command+0x24/0x1f0 dprc_get_obj_region+0xfc/0x1c0 fsl_mc_device_add+0x340/0x590 fsl_mc_obj_device_add+0xd0/0xf8 dprc_scan_objects+0x1c4/0x340 dprc_scan_container+0x38/0x60 vfio_fsl_mc_probe+0x9c/0xf8 fsl_mc_driver_probe+0x24/0x70 really_probe+0xbc/0x2a8 __driver_probe_device+0x78/0xe0 device_driver_attach+0x30/0x68 bind_store+0xa8/0x130 drv_attr_store+0x24/0x38 sysfs_kf_write+0x44/0x60 kernfs_fop_write_iter+0x128/0x1b8 vfs_write+0x334/0x448 ksys_write+0x68/0xf0 __arm64_sys_write+0x1c/0x28 invoke_syscall+0x44/0x108 el0_svc_common.constprop.1+0x94/0xf8 do_el0_svc+0x38/0xb0 el0_svc+0x20/0x50 el0t_64_sync_handler+0x98/0xc0 el0t_64_sync+0x174/0x178 Code: aa0103f4 a9025bf5 d5384100 b9400801 (79401260) ---[ end trace 0000000000000000 ]---
Message-ID: <[email protected]>
--- drivers/bus/fsl-mc/dprc-driver.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/bus/fsl-mc/dprc-driver.c +6 -0
@@ -46,6 +46,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)struct fsl_mc_child_objs *objs;struct fsl_mc_device *mc_dev; +if (!dev_is_fsl_mc (dev)) +return 0 ; + mc_dev =to_fsl_mc_device (dev); objs = data;
@@ -65,6 +68,9 @@ static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)static int __fsl_mc_device_remove (struct device *dev,void *data) { +if (!dev_is_fsl_mc (dev)) +return 0 ; +fsl_mc_device_remove (to_fsl_mc_device (dev));return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 446/591 mfd: stmfx: Fix error path in stmfx_chip_init
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit f592cf624531286f8b52e40dcfc157a5a7fb115c ]
In error path, disable vdd regulator if it exists, but don't overload ret. Because if regulator_disable() is successful, stmfx_chip_init will exit successfully while chip init failed.
--- drivers/mfd/stmfx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/stmfx.c +1 -1
@@ -387,7 +387,7 @@ static int stmfx_chip_init(struct i2c_client *client) err:if (stmfx->vdd) -return regulator_disable (stmfx->vdd); +regulator_disable (stmfx->vdd);return ret; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 447/591 mfd: stmfx: Nullify stmfx->vdd in case of error
In reply to Greg Kroah-HartmanFrom: Amelie Delaunay <[email protected]>
[ Upstream commit 7c81582c0bccb4757186176f0ee12834597066ad ]
Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error. And simplify code by returning an error only if return code is not -ENODEV, which means there is no vdd regulator and it is not an issue.
--- drivers/mfd/stmfx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mfd/stmfx.c +2 -3
@@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client) stmfx->vdd =devm_regulator_get_optional (&client->dev,"vdd" ); ret =PTR_ERR_OR_ZERO (stmfx->vdd);if (ret) { -if (ret == -ENODEV ) - stmfx->vdd =NULL ; -else + stmfx->vdd =NULL ; +if (ret != -ENODEV )return dev_err_probe (&client->dev, ret,"Failed to get VDD regulator\n" ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 448/591 KVM: s390: vsie: fix the length of APCB bitmap
In reply to Greg Kroah-HartmanFrom: Pierre Morel <[email protected]>
[ Upstream commit 246be7d2720ea9a795b576067ecc5e5c7a1e7848 ]
bit_and() uses the count of bits as the woking length. Fix the previous implementation and effectively use the right bitmap size.
--- arch/s390/kvm/vsie.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
arch/s390/kvm/vsie.c +4 -2
@@ -169,7 +169,8 @@ static int setup_apcb00(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb0)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb0 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb0 ));return 0 ; }
@@ -191,7 +192,8 @@ static int setup_apcb11(struct kvm_vcpu *vcpu, unsigned long *apcb_s, sizeof(struct kvm_s390_apcb1)))return -EFAULT ; -bitmap_and (apcb_s, apcb_s, apcb_h,sizeof (struct kvm_s390_apcb1 )); +bitmap_and (apcb_s, apcb_s, apcb_h, +BITS_PER_BYTE *sizeof (struct kvm_s390_apcb1 ));return 0 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 449/591 KVM: s390/diag: fix racy access of physical cpu number in diag 9c handler
In reply to Greg Kroah-HartmanFrom: Christian Borntraeger <[email protected]>
[ Upstream commit 0bc380beb78aa352eadbc21d934dd9606fcee808 ]
We do check for target CPU == -1, but this might change at the time we are going to use it. Hold the physical target CPU in a local variable to avoid out-of-bound accesses to the cpu arrays.
--- arch/s390/kvm/diag.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/s390/kvm/diag.c +5 -3
@@ -166,6 +166,7 @@ static int diag9c_forwarding_overrun(void)static int __diag_time_slice_end_directed (struct kvm_vcpu *vcpu) {struct kvm_vcpu *tcpu; +int tcpu_cpu;int tid; tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa &0xf0 ) >>4 ];
@@ -181,14 +182,15 @@ static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu) goto no_yield;/* target guest VCPU already running */ -if (READ_ONCE (tcpu->cpu) >=0 ) { + tcpu_cpu =READ_ONCE (tcpu->cpu); +if (tcpu_cpu >=0 ) {if (!diag9c_forwarding_hz ||diag9c_forwarding_overrun ()) goto no_yield;/* target host CPU already running */ -if (!vcpu_is_preempted (tcpu->cpu)) +if (!vcpu_is_preempted (tcpu_cpu)) goto no_yield; -smp_yield_cpu (tcpu->cpu); +smp_yield_cpu (tcpu_cpu);VCPU_EVENT (vcpu,5 ,"diag time slice end directed to %d: yield forwarded" , tid);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 450/591 cpufreq: mediatek: correct voltages for MT7622 and MT7623
In reply to Greg Kroah-HartmanFrom: Daniel Golle <[email protected]>
[ Upstream commit f85534113f5ae90a52521cdb9e9977a43ee42626 ]
The MT6380 regulator typically used together with MT7622 does not support the current maximum processor and SRAM voltage in the cpufreq driver (1360000uV).
For MT7622 limit processor and SRAM supply voltages to 1350000uV to avoid having the tracking algorithm request unsupported voltages from the regulator.
On MT7623 there is no separate SRAM supply and the maximum voltage used is 1300000uV. Create dedicated platform data for MT7623 to cover that case as well.
--- drivers/cpufreq/mediatek-cpufreq.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/cpufreq/mediatek-cpufreq.c +10 -3
@@ -696,9 +696,16 @@ static const struct mtk_cpufreq_platform_data mt2701_platform_data = {static const struct mtk_cpufreq_platform_data mt7622_platform_data = { .min_volt_shift =100000 , .max_volt_shift =200000 , - .proc_max_volt =1360000 , + .proc_max_volt =1350000 , .sram_min_volt =0 , - .sram_max_volt =1360000 , + .sram_max_volt =1350000 , + .ccifreq_supported = false, +}; + +static const struct mtk_cpufreq_platform_data mt7623_platform_data = { + .min_volt_shift =100000 , + .max_volt_shift =200000 , + .proc_max_volt =1300000 , .ccifreq_supported = false, };
@@ -734,7 +741,7 @@ static const struct of_device_id mtk_cpufreq_machines[] __initconst = { { .compatible = "mediatek,mt2701", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt2712", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt7622", .data = &mt7622_platform_data }, - { .compatible = "mediatek,mt7623", .data = &mt7622_platform_data }, + { .compatible = "mediatek,mt7623", .data = &mt7623_platform_data }, { .compatible = "mediatek,mt8167", .data = &mt8516_platform_data }, { .compatible = "mediatek,mt817x", .data = &mt2701_platform_data }, { .compatible = "mediatek,mt8173", .data = &mt2701_platform_data },
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 451/591 misc: fastrpc: check return value of devm_kasprintf()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit af2e19d82a116bc622eea84c9faadd5f7e20bec4 ]
devm_kasprintf() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/misc/fastrpc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/fastrpc.c +3 -0
@@ -2030,6 +2030,9 @@ static int fastrpc_device_register(struct device *dev, struct fastrpc_channel_ct fdev->miscdev.fops = &fastrpc_fops; fdev->miscdev.name =devm_kasprintf (dev,GFP_KERNEL ,"fastrpc-%s%s" , domain, is_secured ?"-secure" :"" ); +if (!fdev->miscdev.name) +return -ENOMEM ; + err =misc_register (&fdev->miscdev);if (!err) {if (is_secured)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 452/591 clk: qcom: mmcc-msm8974: fix MDSS_GDSC power flags
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 4e13c7a55cf752887f2b8d8008711dbbc64ea796 ]
Using PWRSTS_RET on msm8974's MDSS_GDSC causes display to stop working. The gdsc doesn't fully come out of retention mode. Change it's pwrsts flags to PWRSTS_OFF_ON.
--- drivers/clk/qcom/mmcc-msm8974.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-msm8974.c +1 -1
@@ -2372,7 +2372,7 @@ static struct gdsc mdss_gdsc = { .pd = { .name = "mdss", }, - .pwrsts = PWRSTS_RET_ON, + .pwrsts = PWRSTS_OFF_ON, };static struct gdsc camss_jpeg_gdsc = {
Greg Kroah-Hartman
maintainerPATCH 453/591 hwtracing: hisi_ptt: Fix potential sleep in atomic context
In reply to Greg Kroah-HartmanFrom: Yicong Yang <[email protected]>
[ Upstream commit 6c50384ef8b94a527445e3694ae6549e1f15d859 ]
We're using pci_irq_vector() to obtain the interrupt number and then bind it to the CPU start perf under the protection of spinlock in pmu::start(). pci_irq_vector() might sleep since [1] because it will call msi_domain_get_virq() to get the MSI interrupt number and it needs to acquire dev->msi.data->mutex. Getting a mutex will sleep on contention. So use pci_irq_vector() in an atomic context is problematic.
This patch cached the interrupt number in the probe() and uses the cached data instead to avoid potential sleep.
[1] commit 82ff8e6b78fc ("PCI/MSI: Use msi_get_virq() in pci_get_vector()")
--- drivers/hwtracing/ptt/hisi_ptt.c | 12 +++++------- drivers/hwtracing/ptt/hisi_ptt.h | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/hwtracing/ptt/hisi_ptt.c +5 -7
@@ -341,13 +341,13 @@ static int hisi_ptt_register_irq(struct hisi_ptt *hisi_ptt)if (ret <0 )return ret; - ret =devm_request_threaded_irq (&pdev->dev, -pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ), + hisi_ptt->trace_irq =pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ); + ret =devm_request_threaded_irq (&pdev->dev, hisi_ptt->trace_irq,NULL , hisi_ptt_isr,0 ,DRV_NAME , hisi_ptt);if (ret) {pci_err (pdev,"failed to request irq %d, ret = %d\n" , -pci_irq_vector (pdev,HISI_PTT_TRACE_DMA_IRQ ), ret); + hisi_ptt->trace_irq, ret);return ret; }
@@ -757,8 +757,7 @@ static void hisi_ptt_pmu_start(struct perf_event *event, int flags)* core in event_function_local(). If CPU passed is offline we'll fail * here, just log it since we can do nothing here. */ - ret =irq_set_affinity (pci_irq_vector (hisi_ptt->pdev,HISI_PTT_TRACE_DMA_IRQ ), -cpumask_of (cpu)); + ret =irq_set_affinity (hisi_ptt->trace_irq,cpumask_of (cpu));if (ret)dev_warn (dev,"failed to set the affinity of trace interrupt\n" );
@@ -1018,8 +1017,7 @@ static int hisi_ptt_cpu_teardown(unsigned int cpu, struct hlist_node *node)* Also make sure the interrupt bind to the migrated CPU as well. Warn * the user on failure here. */ -if (irq_set_affinity (pci_irq_vector (hisi_ptt->pdev,HISI_PTT_TRACE_DMA_IRQ ), -cpumask_of (target))) +if (irq_set_affinity (hisi_ptt->trace_irq,cpumask_of (target)))dev_warn (dev,"failed to set the affinity of trace interrupt\n" ); hisi_ptt->trace_ctrl.on_cpu = target;
drivers/hwtracing/ptt/hisi_ptt.h +2 -0
@@ -166,6 +166,7 @@ struct hisi_ptt_pmu_buf {* @pdev: pci_dev of this PTT device * @tune_lock: lock to serialize the tune process * @pmu_lock: lock to serialize the perf process +* @trace_irq: interrupt number used by trace * @upper_bdf: the upper BDF range of the PCI devices managed by this PTT device * @lower_bdf: the lower BDF range of the PCI devices managed by this PTT device * @port_filters: the filter list of root ports
@@ -180,6 +181,7 @@ struct hisi_ptt {struct pci_dev *pdev;struct mutex tune_lock;spinlock_t pmu_lock; +int trace_irq;u32 upper_bdf;u32 lower_bdf;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 454/591 mfd: stmpe: Only disable the regulators if they are enabled
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 104d32bd81f620bb9f67fbf7d1159c414e89f05f ]
In stmpe_probe(), if some regulator_enable() calls fail, probing continues and there is only a dev_warn().
So, if stmpe_probe() is called the regulator may not be enabled. It is cleaner to test it before calling regulator_disable() in the remove function.
--- drivers/mfd/stmpe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mfd/stmpe.c +2 -2
@@ -1485,9 +1485,9 @@ int stmpe_probe(struct stmpe_client_info *ci, enum stmpe_partnum partnum)void stmpe_remove (struct stmpe *stmpe) { -if (!IS_ERR (stmpe->vio)) +if (!IS_ERR (stmpe->vio) &®ulator_is_enabled (stmpe->vio))regulator_disable (stmpe->vio); -if (!IS_ERR (stmpe->vcc)) +if (!IS_ERR (stmpe->vcc) &®ulator_is_enabled (stmpe->vcc))regulator_disable (stmpe->vcc);__stmpe_disable (stmpe,STMPE_BLOCK_ADC );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 455/591 phy: tegra: xusb: check return value of devm_kzalloc()
In reply to Greg Kroah-HartmanFrom: Claudiu Beznea <[email protected]>
[ Upstream commit 44faada0f38fc333d392af04c343b0e23f8f5d81 ]
devm_kzalloc() returns a pointer to dynamically allocated memory. Pointer could be NULL in case allocation fails. Check pointer validity. Identified with coccinelle (kmerr.cocci script).
--- drivers/phy/tegra/xusb.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/tegra/xusb.c +3 -0
@@ -670,6 +670,9 @@ static int tegra_xusb_setup_usb_role_switch(struct tegra_xusb_port *port) port->dev.driver =devm_kzalloc (&port->dev,sizeof (struct device_driver ),GFP_KERNEL ); +if (!port->dev.driver) +return -ENOMEM ; + port->dev.driver->owner =THIS_MODULE ; port->usb_role_sw = usb_role_switch_register(&port->dev,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 456/591 lib/bitmap: drop optimization of bitmap_{from,to}_arr64
In reply to Greg Kroah-HartmanFrom: Yury Norov <[email protected]>
[ Upstream commit c1d2ba10f594046831d14b03f194e8d05e78abad ]
bitmap_{from,to}_arr64() optimization is overly optimistic on 32-bit LE architectures when it's wired to bitmap_copy_clear_tail().
bitmap_copy_clear_tail() takes care of unused bits in the bitmap up to the next word boundary. But on 32-bit machines when copying bits from bitmap to array of 64-bit words, it's expected that the unused part of a recipient array must be cleared up to 64-bit boundary, so the last 4 bytes may stay untouched when nbits % 64 <= 32.
While the copying part of the optimization works correct, that clear-tail trick makes corresponding tests reasonably fail:
test_bitmap: bitmap_to_arr64(nbits == 1): tail is not safely cleared: 0xa5a5a5a500000001 (must be 0x0000000000000001)
Fix it by removing bitmap_{from,to}_arr64() optimization for 32-bit LE arches.
--- include/linux/bitmap.h | 8 +++----- lib/bitmap.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-)
include/linux/bitmap.h +3 -5
@@ -302,12 +302,10 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap,#endif /* -* On 64-bit systems bitmaps are represented as u64 arrays internally. On LE32 -* machines the order of hi and lo parts of numbers match the bitmap structure. -* In both cases conversion is not needed when copying data from/to arrays of -* u64. +* On 64-bit systems bitmaps are represented as u64 arrays internally. So, +* the conversion is not needed when copying data from/to arrays of u64. */ -#if (BITS_PER_LONG ==32 ) && defined(__BIG_ENDIAN) +#if BITS_PER_LONG ==32 void bitmap_from_arr64 (unsigned long *bitmap,const u64 *buf,unsigned int nbits);void bitmap_to_arr64 (u64 *buf,const unsigned long *bitmap,unsigned int nbits);#else
lib/bitmap.c +1 -1
@@ -1495,7 +1495,7 @@ void bitmap_to_arr32(u32 *buf, const unsigned long *bitmap, unsigned int nbits)EXPORT_SYMBOL (bitmap_to_arr32);#endif -#if (BITS_PER_LONG ==32 ) && defined(__BIG_ENDIAN) +#if BITS_PER_LONG ==32 /** * bitmap_from_arr64 - copy the contents of u64 array of bits to bitmap * @bitmap: array of unsigned longs, the destination bitmap
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 457/591 pwm: imx-tpm: force real_period to be zero in suspend
In reply to Greg Kroah-HartmanFrom: Fancy Fang <[email protected]>
[ Upstream commit 661dfb7f46298e53f6c3deaa772fa527aae86193 ]
During suspend, all the tpm registers will lose values. So the 'real_period' value of struct 'imx_tpm_pwm_chip' should be forced to be zero to force the period update code can be executed after system resume back.
--- drivers/pwm/pwm-imx-tpm.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/pwm/pwm-imx-tpm.c +7 -0
@@ -399,6 +399,13 @@ static int __maybe_unused pwm_imx_tpm_suspend(struct device *dev)if (tpm->enable_count >0 )return -EBUSY ; +/* +* Force 'real_period' to be zero to force period update code +* can be executed after system resume back, since suspend causes +* the period related registers to become their reset values. +*/ + tpm->real_period =0 ; +clk_disable_unprepare (tpm->clk);return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 458/591 pwm: sysfs: Do not apply state to already disabled PWMs
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 38ba83598633373f47951384cfc389181c8d1bed ]
If the PWM is exported but not enabled, do not call pwm_class_apply_state(). First of all, in this case, period may still be unconfigured and this would make pwm_class_apply_state() return -EINVAL, and then suspend would fail. Second, it makes little sense to apply state onto PWM that is not enabled before suspend.
Failing case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo mem > /sys/power/state ... pwm pwmchip4: PM: dpm_run_callback(): pwm_class_suspend+0x1/0xa8 returns -22 pwm pwmchip4: PM: failed to suspend: error -22 PM: Some devices failed to suspend, or early wake event detected "
Working case:
"
$ echo 1 > /sys/class/pwm/pwmchip4/export $ echo 100 > /sys/class/pwm/pwmchip4/pwm1/period $ echo 10 > /sys/class/pwm/pwmchip4/pwm1/duty_cycle $ echo mem > /sys/power/state ... "
Do not call pwm_class_apply_state() in case the PWM is disabled to fix this issue.
--- drivers/pwm/sysfs.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/pwm/sysfs.c +17 -0
@@ -424,6 +424,13 @@ static int pwm_class_resume_npwm(struct device *parent, unsigned int npwm)if (!export)continue ; +/* If pwmchip was not enabled before suspend, do nothing. */ +if (!export->suspend.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = export->suspend.enabled; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 )
@@ -448,7 +455,17 @@ static int pwm_class_suspend(struct device *parent)if (!export)continue ; +/* +* If pwmchip was not enabled before suspend, save +* state for resume time and do nothing else. +*/ export->suspend = state; +if (!state.enabled) { +/* release lock taken in pwm_class_get_state */ +mutex_unlock (&export->lock); +continue ; + } + state.enabled = false; ret =pwm_class_apply_state (export, pwm, &state);if (ret <0 ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 459/591 pwm: ab8500: Fix error code in probe()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit cdcffafc4d845cc0c6392cba168c7a942734cce7 ]
This code accidentally return positive EINVAL instead of negative -EINVAL.
--- drivers/pwm/pwm-ab8500.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-ab8500.c +1 -1
@@ -96,7 +96,7 @@ static int ab8500_pwm_probe(struct platform_device *pdev)int err;if (pdev->id <1 || pdev->id >31 ) -return dev_err_probe (&pdev->dev,EINVAL ,"Invalid device id %d\n" , pdev->id); +return dev_err_probe (&pdev->dev, -EINVAL ,"Invalid device id %d\n" , pdev->id);/* * Nothing to be done in probe, this is required to get the
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 460/591 pwm: mtk_disp: Fix the disable flow of disp_pwm
In reply to Greg Kroah-HartmanFrom: Shuijing Li <[email protected]>
[ Upstream commit bc13d60e4e1e945b34769a4a4c2b172e8552abe5 ]
There is a flow error in the original mtk_disp_pwm_apply() function. If this function is called when the clock is disabled, there will be a chance to operate the disp_pwm register, resulting in disp_pwm exception. Fix this accordingly.
--- drivers/pwm/pwm-mtk-disp.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/pwm/pwm-mtk-disp.c +5 -8
@@ -79,14 +79,11 @@ static int mtk_disp_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,if (state->polarity !=PWM_POLARITY_NORMAL )return -EINVAL ; -if (!state->enabled) { -mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , mdp->data->enable_mask, -0x0 ); - -if (mdp->enabled) { -clk_disable_unprepare (mdp->clk_mm); -clk_disable_unprepare (mdp->clk_main); - } +if (!state->enabled && mdp->enabled) { +mtk_disp_pwm_update_bits (mdp,DISP_PWM_EN , + mdp->data->enable_mask,0x0 ); +clk_disable_unprepare (mdp->clk_mm); +clk_disable_unprepare (mdp->clk_main); mdp->enabled = false;return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 461/591 md/raid10: fix the condition to call bio_end_io_acct()
In reply to Greg Kroah-HartmanFrom: Li Nan <[email protected]>
[ Upstream commit 125bfc7cd750e68c99f1d446e2c22abea08c237f ]
/sys/block/[device]/queue/iostats is used to control whether to count io stat. Write 0 to it will clear queue_flags QUEUE_FLAG_IO_STAT which means iostats is disabled. If we disable iostats and later endable it, the io issued during this period will be counted incorrectly, inflight will be decreased to -1.
//T1 set iostats
echo 0 > /sys/block/md0/queue/iostats
clear QUEUE_FLAG_IO_STAT
//T2 issue io if (QUEUE_FLAG_IO_STAT) -> false bio_start_io_acct inflight++
echo 1 > /sys/block/md0/queue/iostats
set QUEUE_FLAG_IO_STAT
//T3 io end if (QUEUE_FLAG_IO_STAT) -> true bio_end_io_acct inflight-- -> -1
Also, if iostats is enabled while issuing io but disabled while io end, inflight will never be decreased.
Fix it by checking start_time when io end. If start_time is not 0, call bio_end_io_acct().
--- drivers/md/raid10.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid10.c +1 -1
@@ -325,7 +325,7 @@ static void raid_end_bio_io(struct r10bio *r10_bio)if (!test_bit (R10BIO_Uptodate, &r10_bio->state)) bio->bi_status =BLK_STS_IOERR ; -if (blk_queue_io_stat (bio->bi_bdev->bd_disk->queue)) +if (r10_bio->start_time)bio_end_io_acct (bio, r10_bio->start_time);bio_endio (bio);/*
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 462/591 blk-cgroup: Optimize blkcg_rstat_flush()
In reply to Greg Kroah-HartmanFrom: Waiman Long <[email protected]>
[ Upstream commit 3b8cc6298724021da845f2f9fd7dd4b6829a6817 ]
For a system with many CPUs and block devices, the time to do blkcg_rstat_flush() from cgroup_rstat_flush() can be rather long. It can be especially problematic as interrupt is disabled during the flush. It was reported that it might take seconds to complete in some extreme cases leading to hard lockup messages.
As it is likely that not all the percpu blkg_iostat_set's has been updated since the last flush, those stale blkg_iostat_set's don't need to be flushed in this case. This patch optimizes blkcg_rstat_flush() by keeping a lockless list of recently updated blkg_iostat_set's in a newly added percpu blkcg->lhead pointer.
The blkg_iostat_set is added to a lockless list on the update side in blk_cgroup_bio_start(). It is removed from the lockless list when flushed in blkcg_rstat_flush(). Due to racing, it is possible that blk_iostat_set's in the lockless list may have no new IO stats to be flushed, but that is OK.
To protect against destruction of blkg, a percpu reference is gotten when putting into the lockless list and put back when removed.
When booting up an instrumented test kernel with this patch on a 2-socket 96-thread system with cgroup v2, out of the 2051 calls to cgroup_rstat_flush() after bootup, 1788 of the calls were exited immediately because of empty lockless list. After an all-cpu kernel build, the ratio became 6295424/6340513. That was more than 99%.
Stable-dep-of: ad7c3b41e86b ("blk-throttle: Fix io statistics for cgroup v1")
--- block/blk-cgroup.c | 76 ++++++++++++++++++++++++++++++++++++++++++---- block/blk-cgroup.h | 10 ++++++ 2 files changed, 80 insertions(+), 6 deletions(-)
block/blk-cgroup.c +70 -6
@@ -60,6 +60,37 @@ static struct workqueue_struct *blkcg_punt_bio_wq;#define BLKG_DESTROY_BATCH_SIZE 64 +/* +* Lockless lists for tracking IO stats update +* +* New IO stats are stored in the percpu iostat_cpu within blkcg_gq (blkg). +* There are multiple blkg's (one for each block device) attached to each +* blkcg. The rstat code keeps track of which cpu has IO stats updated, +* but it doesn't know which blkg has the updated stats. If there are many +* block devices in a system, the cost of iterating all the blkg's to flush +* out the IO stats can be high. To reduce such overhead, a set of percpu +* lockless lists (lhead) per blkcg are used to track the set of recently +* updated iostat_cpu's since the last flush. An iostat_cpu will be put +* onto the lockless list on the update side [blk_cgroup_bio_start()] if +* not there yet and then removed when being flushed [blkcg_rstat_flush()]. +* References to blkg are gotten and then put back in the process to +* protect against blkg removal. +* +* Return: 0 if successful or -ENOMEM if allocation fails. +*/ +static int init_blkcg_llists (struct blkcg *blkcg) +{ +int cpu; + + blkcg->lhead = alloc_percpu_gfp(struct llist_head, GFP_KERNEL); +if (!blkcg->lhead) +return -ENOMEM ; + +for_each_possible_cpu (cpu) +init_llist_head (per_cpu_ptr (blkcg->lhead, cpu)); +return 0 ; +} +/** * blkcg_css - find the current css *
@@ -237,8 +268,10 @@ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct gendisk *disk, blkg->blkcg = blkcg;u64_stats_init (&blkg->iostat.sync); -for_each_possible_cpu (cpu) +for_each_possible_cpu (cpu) {u64_stats_init (&per_cpu_ptr (blkg->iostat_cpu, cpu)->sync); +per_cpu_ptr (blkg->iostat_cpu, cpu)->blkg = blkg; + }for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];
@@ -831,7 +864,9 @@ static void blkcg_iostat_update(struct blkcg_gq *blkg, struct blkg_iostat *cur,static void blkcg_rstat_flush (struct cgroup_subsys_state *css,int cpu) {struct blkcg *blkcg =css_to_blkcg (css); -struct blkcg_gq *blkg; +struct llist_head *lhead =per_cpu_ptr (blkcg->lhead, cpu); +struct llist_node *lnode; +struct blkg_iostat_set *bisc, *next_bisc;/* Root-level stats are sourced from system-wide IO stats */ if (!cgroup_parent (css->cgroup))
@@ -839,12 +874,21 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)rcu_read_lock (); -hlist_for_each_entry_rcu (blkg, &blkcg->blkg_list, blkcg_node) { + lnode =llist_del_all (lhead); +if (!lnode) + goto out; + +/* +* Iterate only the iostat_cpu's queued in the lockless list. +*/ +llist_for_each_entry_safe (bisc, next_bisc, lnode, lnode) { +struct blkcg_gq *blkg = bisc->blkg;struct blkcg_gq *parent = blkg->parent; -struct blkg_iostat_set *bisc =per_cpu_ptr (blkg->iostat_cpu, cpu);struct blkg_iostat cur;unsigned int seq; +WRITE_ONCE (bisc->lqueued, false); +/* fetch the current per-cpu values */ do { seq = u64_stats_fetch_begin(&bisc->sync);
@@ -857,8 +901,10 @@ static void blkcg_rstat_flush(struct cgroup_subsys_state *css, int cpu)if (parent && parent->parent)blkcg_iostat_update (parent, &blkg->iostat.cur, &blkg->iostat.last); +percpu_ref_put (&blkg->refcnt); } +out:rcu_read_unlock (); }
@@ -1136,6 +1182,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)mutex_unlock (&blkcg_pol_mutex); +free_percpu (blkcg->lhead);kfree (blkcg); }
@@ -1158,6 +1205,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css) } } +if (init_blkcg_llists (blkcg)) + goto free_blkcg; +for (i =0 ; i <BLKCG_MAX_POLS ; i++) {struct blkcg_policy *pol = blkcg_policy[i];struct blkcg_policy_data *cpd;
@@ -1199,7 +1249,8 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)for (i--; i >=0 ; i--)if (blkcg->cpd[i]) blkcg_policy[i]->cpd_free_fn (blkcg->cpd[i]); - +free_percpu (blkcg->lhead); +free_blkcg:if (blkcg != &blkcg_root)kfree (blkcg); unlock:
@@ -1952,6 +2003,7 @@ static int blk_cgroup_io_type(struct bio *bio)void blk_cgroup_bio_start (struct bio *bio) { +struct blkcg *blkcg = bio->bi_blkg->blkcg;int rwd =blk_cgroup_io_type (bio), cpu;struct blkg_iostat_set *bis;unsigned long flags;
@@ -1970,9 +2022,21 @@ void blk_cgroup_bio_start(struct bio *bio) } bis->cur.ios[rwd]++; +/* +* If the iostat_cpu isn't in a lockless list, put it into the +* list to indicate that a stat update is pending. +*/ +if (!READ_ONCE (bis->lqueued)) { +struct llist_head *lhead =this_cpu_ptr (blkcg->lhead); + +llist_add (&bis->lnode, lhead); +WRITE_ONCE (bis->lqueued, true); +percpu_ref_get (&bis->blkg->refcnt); + } +u64_stats_update_end_irqrestore (&bis->sync, flags);if (cgroup_subsys_on_dfl (io_cgrp_subsys)) -cgroup_rstat_updated (bio->bi_blkg->blkcg->css.cgroup, cpu); +cgroup_rstat_updated (blkcg->css.cgroup, cpu);put_cpu (); }
block/blk-cgroup.h +10 -0
@@ -18,6 +18,7 @@#include <linux/cgroup.h> #include <linux/kthread.h> #include <linux/blk-mq.h> +#include <linux/llist.h> struct blkcg_gq ;struct blkg_policy_data ;
@@ -43,6 +44,9 @@ struct blkg_iostat {struct blkg_iostat_set {struct u64_stats_sync sync; +struct blkcg_gq *blkg; +struct llist_node lnode; +int lqueued;/* queued in llist */ struct blkg_iostat cur;struct blkg_iostat last; };
@@ -97,6 +101,12 @@ struct blkcg {struct blkcg_policy_data *cpd[BLKCG_MAX_POLS ];struct list_head all_blkcgs_node; + +/* +* List of updated percpu blkg_iostat_set's since the last flush. +*/ +struct llist_head __percpu *lhead; +#ifdef CONFIG_BLK_CGROUP_FC_APPID char fc_app_id[FC_APPID_LEN ];#endif
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 463/591 blk-cgroup: dont update io stat for root cgroup
In reply to Greg Kroah-HartmanFrom: Ming Lei <[email protected]>
[ Upstream commit 0416f3be58c6b1ea066cd52e354b857693feb01e ]
We source root cgroup stats from the system-wide stats, see blkcg_print_stat and blkcg_rstat_flush, so don't update io state for root cgroup.
Fixes blkg leak issue introduced in commit 3b8cc6298724 ("blk-cgroup: Optimize blkcg_rstat_flush()") which starts to grab blkg's reference when adding iostat_cpu into percpu
blkcg list, but this state won't be consumed by blkcg_rstat_flush() where
the blkg reference is dropped.
Stable-dep-of: ad7c3b41e86b ("blk-throttle: Fix io statistics for cgroup v1")
--- block/blk-cgroup.c | 4 ++++ 1 file changed, 4 insertions(+)
block/blk-cgroup.c +4 -0
@@ -2008,6 +2008,10 @@ void blk_cgroup_bio_start(struct bio *bio)struct blkg_iostat_set *bis;unsigned long flags; +/* Root-level stats are sourced from system-wide IO stats */ +if (!cgroup_parent (blkcg->css.cgroup)) +return ; + cpu =get_cpu (); bis =per_cpu_ptr (bio->bi_blkg->iostat_cpu, cpu); flags =u64_stats_update_begin_irqsave (&bis->sync);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 464/591 blk-throttle: Fix io statistics for cgroup v1
In reply to Greg Kroah-HartmanFrom: Jinke Han <[email protected]>
[ Upstream commit ad7c3b41e86b59943a903d23c7b037d820e6270c ]
After commit f382fb0bcef4 ("block: remove legacy IO schedulers"), blkio.throttle.io_serviced and blkio.throttle.io_service_bytes become the only stable io stats interface of cgroup v1, and these statistics are done in the blk-throttle code. But the current code only counts the bios that are actually throttled. When the user does not add the throttle limit, the io stats for cgroup v1 has nothing. I fix it according to the statistical method of v2, and made it count all ios accurately.
--- block/blk-cgroup.c | 6 ++++-- block/blk-throttle.c | 6 ------ block/blk-throttle.h | 9 +++++++++ 3 files changed, 13 insertions(+), 8 deletions(-)
block/blk-cgroup.c +4 -2
@@ -2008,6 +2008,9 @@ void blk_cgroup_bio_start(struct bio *bio)struct blkg_iostat_set *bis;unsigned long flags; +if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) +return ; +/* Root-level stats are sourced from system-wide IO stats */ if (!cgroup_parent (blkcg->css.cgroup))return ;
@@ -2039,8 +2042,7 @@ void blk_cgroup_bio_start(struct bio *bio) }u64_stats_update_end_irqrestore (&bis->sync, flags); -if (cgroup_subsys_on_dfl (io_cgrp_subsys)) -cgroup_rstat_updated (blkcg->css.cgroup, cpu); +cgroup_rstat_updated (blkcg->css.cgroup, cpu);put_cpu (); }
block/blk-throttle.c +0 -6
@@ -2167,12 +2167,6 @@ bool __blk_throtl_bio(struct bio *bio)rcu_read_lock (); -if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) { -blkg_rwstat_add (&tg->stat_bytes, bio->bi_opf, - bio->bi_iter.bi_size); -blkg_rwstat_add (&tg->stat_ios, bio->bi_opf,1 ); - } -spin_lock_irq (&q->queue_lock);throtl_update_latency_buckets (td);
block/blk-throttle.h +9 -0
@@ -185,6 +185,15 @@ static inline bool blk_should_throtl(struct bio *bio)struct throtl_grp *tg =blkg_to_tg (bio->bi_blkg);int rw =bio_data_dir (bio); +if (!cgroup_subsys_on_dfl (io_cgrp_subsys)) { +if (!bio_flagged (bio,BIO_CGROUP_ACCT )) { +bio_set_flag (bio,BIO_CGROUP_ACCT ); +blkg_rwstat_add (&tg->stat_bytes, bio->bi_opf, + bio->bi_iter.bi_size); + } +blkg_rwstat_add (&tg->stat_ios, bio->bi_opf,1 ); + } +/* iops limit is always counted */ if (tg->has_rules_iops[rw])return true;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 465/591 rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit 06c6e1b01d9261f03629cefd1f3553503291e6cf ]
If an error occurs after clk_get(), the corresponding resources should be released.
Use devm_clk_get() to fix it.
--- drivers/rtc/rtc-st-lpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-st-lpc.c +1 -1
@@ -228,7 +228,7 @@ static int st_rtc_probe(struct platform_device *pdev)enable_irq_wake (rtc->irq);disable_irq (rtc->irq); - rtc->clk =clk_get (&pdev->dev,NULL ); + rtc->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (rtc->clk)) {dev_err (&pdev->dev,"Unable to request clock\n" );return PTR_ERR (rtc->clk);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 466/591 drm/i915/psr: Use hw.adjusted mode when calculating io/fast wake times
In reply to Greg Kroah-HartmanFrom: Jouni Högander <[email protected]>
[ Upstream commit 5311892a0ad1d301aafd53ca0154091b3eb407ea ]
Encoder compute config is changing hw.adjusted mode. Uapi.adjusted mode doesn't get updated before psr compute config gets called. This causes io and fast wake line calculation using adjusted mode containing values before encoder adjustments. Fix this by using hw.adjusted mode instead of uapi.adjusted mode.
--- drivers/gpu/drm/i915/display/intel_psr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/display/intel_psr.c +2 -2
@@ -857,9 +857,9 @@ static bool _compute_psr2_wake_times(struct intel_dp *intel_dp, } io_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, io_wake_time); + &crtc_state->hw.adjusted_mode, io_wake_time); fast_wake_lines =intel_usecs_to_scanlines ( - &crtc_state->uapi.adjusted_mode, fast_wake_time); + &crtc_state->hw.adjusted_mode, fast_wake_time);if (io_wake_lines > max_wake_lines || fast_wake_lines > max_wake_lines)
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 467/591 drm/i915/guc/slpc: Apply min softlimit correctly
In reply to Greg Kroah-HartmanFrom: Vinay Belgaumkar <[email protected]>
[ Upstream commit 3e49de73fb89272dea01ba420c7ccbcf6b96aed7 ]
The scenario being fixed here is depicted in the following sequence-
modprobe i915
echo 1 > /sys/class/drm/card0/gt/gt0/slpc_ignore_eff_freq echo 300 > /sys/class/drm/card0/gt_min_freq_mhz (RPn)
cat /sys/class/drm/card0/gt_cur_freq_mhz --> cur == RPn as expected echo 1 > /sys/kernel/debug/dri/0/gt0/reset --> reset
cat /sys/class/drm/card0/gt_min_freq_mhz --> cached freq is RPn cat /sys/class/drm/card0/gt_cur_freq_mhz --> it's not RPn, but RPe!!
When SLPC reinitializes, it sets SLPC min freq to efficient frequency. Even if we disable efficient freq post that, we should restore the cached min freq (via H2G) for it to take effect.
v2: Clarify commit message (Ashutosh)
--- drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gt/uc/intel_guc_slpc.c +1 -1
@@ -580,7 +580,7 @@ static int slpc_set_softlimits(struct intel_guc_slpc *slpc)if (unlikely (ret))return ret;slpc_to_gt (slpc)->defaults.min_freq = slpc->min_freq_softlimit; - }else if (slpc->min_freq_softlimit != slpc->min_freq) { + }else {return intel_guc_slpc_set_min_freq (slpc, slpc->min_freq_softlimit); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 468/591 f2fs: check return value of freeze_super()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 8bec7dd1b3f7d7769d433d67bde404de948a2d95 ]
freeze_super() can fail, it needs to check its return value and do error handling in f2fs_resize_fs().
--- fs/f2fs/gc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/gc.c +3 -1
@@ -2186,7 +2186,9 @@ int f2fs_resize_fs(struct file *filp, __u64 block_count)if (err)return err; -freeze_super (sbi->sb); + err =freeze_super (sbi->sb); +if (err) +return err;if (f2fs_readonly (sbi->sb)) {thaw_super (sbi->sb);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 469/591 media: cec: i2c: ch7322: also select REGMAP
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 29f96ac23648b2259f42d40703c47dd18fd172ca ]
Selecting only REGMAP_I2C can leave REGMAP unset, causing build errors, so also select REGMAP to prevent the build errors.
../drivers/media/cec/i2c/ch7322.c:158:21: error: variable 'ch7322_regmap' has initializer but incomplete type
158 | static const struct regmap_config ch7322_regmap = {../drivers/media/cec/i2c/ch7322.c:159:10: error: 'const struct regmap_config' has no member named 'reg_bits'
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:159:21: warning: excess elements in struct initializer
159 | .reg_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:10: error: 'const struct regmap_config' has no member named 'val_bits'
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:160:21: warning: excess elements in struct initializer
160 | .val_bits = 8,../drivers/media/cec/i2c/ch7322.c:161:10: error: 'const struct regmap_config' has no member named 'max_register'
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:161:25: warning: excess elements in struct initializer
161 | .max_register = 0x7f,../drivers/media/cec/i2c/ch7322.c:162:10: error: 'const struct regmap_config' has no member named 'disable_locking'
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c:162:28: warning: excess elements in struct initializer
162 | .disable_locking = true,../drivers/media/cec/i2c/ch7322.c: In function 'ch7322_probe':../drivers/media/cec/i2c/ch7322.c:468:26: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c:468:24: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
468 | ch7322->regmap = devm_regmap_init_i2c(client, &ch7322_regmap);../drivers/media/cec/i2c/ch7322.c: At top level:../drivers/media/cec/i2c/ch7322.c:158:35: error: storage size of 'ch7322_regmap' isn't known
158 | static const struct regmap_config ch7322_regmap = {
--- drivers/media/cec/i2c/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/media/cec/i2c/Kconfig +1 -0
@@ -5,6 +5,7 @@ config CEC_CH7322 tristate "Chrontel CH7322 CEC controller" depends on I2C + select REGMAP select REGMAP_I2C select CEC_CORE help
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 470/591 sctp: fix potential deadlock on &net->sctp.addr_wq_lock
In reply to Greg Kroah-HartmanFrom: Chengfeng Ye <[email protected]>
[ Upstream commit 6feb37b3b06e9049e20dcf7e23998f92c9c5be9a ]
As &net->sctp.addr_wq_lock is also acquired by the timer sctp_addr_wq_timeout_handler() in protocal.c, the same lock acquisition at sctp_auto_asconf_init() seems should disable irq since it is called from sctp_accept() under process context.
Possible deadlock scenario:sctp_accept()
-> sctp_sock_migrate()
-> sctp_auto_asconf_init()
-> spin_lock(&net->sctp.addr_wq_lock)
<timer interrupt>
-> sctp_addr_wq_timeout_handler()
-> spin_lock_bh(&net->sctp.addr_wq_lock); (deadlock here)This flaw was found using an experimental static analysis tool we are developing for irq-related deadlock.
The tentative patch fix the potential deadlock by spin_lock_bh().
--- net/sctp/socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/sctp/socket.c +2 -2
@@ -363,9 +363,9 @@ static void sctp_auto_asconf_init(struct sctp_sock *sp)struct net *net =sock_net (&sp->inet.sk);if (net->sctp.default_auto_asconf) { -spin_lock (&net->sctp.addr_wq_lock); +spin_lock_bh (&net->sctp.addr_wq_lock);list_add_tail (&sp->auto_asconf_list, &net->sctp.auto_asconf_splist); -spin_unlock (&net->sctp.addr_wq_lock); +spin_unlock_bh (&net->sctp.addr_wq_lock); sp->do_auto_asconf =1 ; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 471/591 net/sched: act_ipt: add sanity checks on table name and hook locations
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit b4ee93380b3c891fea996af8d1d3ca0e36ad31f0 ]
Looks like "tc" hard-codes "mangle" as the only supported table name, but on kernel side there are no checks.
This is wrong. Not all xtables targets are safe to call from tc. E.g. "nat" targets assume skb has a conntrack object assigned to it. Normally those get called from netfilter nat core which consults the nat table to obtain the address mapping.
"tc" userspace either sets PRE or POSTROUTING as hook number, but there is no validation of this on kernel side, so update netlink policy to reject bogus numbers. Some targets may assume skb_dst is set for input/forward hooks, so prevent those from being used.
act_ipt uses the hook number in two places:
1. the state hook number, this is fine as-is
2. to set par.hook_mask
The latter is a bit mask, so update the assignment to make xt_check_target() to the right thing.
Followup patch adds required checks for the skb/packet headers before calling the targets evaluation function.
--- net/sched/act_ipt.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
net/sched/act_ipt.c +20 -7
@@ -47,7 +47,7 @@ static int ipt_init_target(struct net *net, struct xt_entry_target *t, par.entryinfo = &e; par.target = target; par.targinfo = t->data; - par.hook_mask = hook; + par.hook_mask =1 << hook; par.family =NFPROTO_IPV4 ; ret =xt_check_target (&par, t->u.target_size -sizeof (*t),0 , false);
@@ -84,7 +84,8 @@ static void tcf_ipt_release(struct tc_action *a)static const struct nla_policy ipt_policy[TCA_IPT_MAX +1 ] = { [TCA_IPT_TABLE ] = { .type =NLA_STRING , .len =IFNAMSIZ }, - [TCA_IPT_HOOK ] = { .type =NLA_U32 }, + [TCA_IPT_HOOK ] =NLA_POLICY_RANGE (NLA_U32 ,NF_INET_PRE_ROUTING , +NF_INET_NUMHOOKS ), [TCA_IPT_INDEX ] = { .type =NLA_U32 }, [TCA_IPT_TARG ] = { .len =sizeof (struct xt_entry_target ) }, };
@@ -157,15 +158,27 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,return -EEXIST ; } } + + err = -EINVAL ; hook =nla_get_u32 (tb[TCA_IPT_HOOK ]); +switch (hook) { +case NF_INET_PRE_ROUTING : +break ; +case NF_INET_POST_ROUTING : +break ; +default : + goto err1; + } + +if (tb[TCA_IPT_TABLE ]) { +/* mangle only for now */ +if (nla_strcmp (tb[TCA_IPT_TABLE ],"mangle" )) + goto err1; + } - err = -ENOMEM ; - tname =kmalloc (IFNAMSIZ ,GFP_KERNEL ); + tname =kstrdup ("mangle" ,GFP_KERNEL );if (unlikely (!tname)) goto err1; -if (tb[TCA_IPT_TABLE ] ==NULL || -nla_strscpy (tname, tb[TCA_IPT_TABLE ],IFNAMSIZ ) >=IFNAMSIZ ) -strcpy (tname,"mangle" ); t =kmemdup (td, td->u.target_size,GFP_KERNEL );if (unlikely (!t))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 472/591 net: add a couple of helpers for iph tot_len
In reply to Greg Kroah-HartmanFrom: Xin Long <[email protected]>
[ Upstream commit 058a8f7f73aae1cc22b53fcefec031b9e391b54d ]
This patch adds three APIs to replace the iph->tot_len setting and getting in all places where IPv4 BIG TCP packets may reach, they will be used in the following patches.
Note that iph_totlen() will be used when iph is not in linear data of the skb.
Stable-dep-of: b2dc32dcba08 ("net/sched: act_ipt: add sanity checks on skb before calling target")
--- include/linux/ip.h | 21 +++++++++++++++++++++ include/net/route.h | 3 --- 2 files changed, 21 insertions(+), 3 deletions(-)
include/linux/ip.h +21 -0
@@ -35,4 +35,25 @@ static inline unsigned int ip_transport_len(const struct sk_buff *skb) {return ntohs (ip_hdr (skb)->tot_len) -skb_network_header_len (skb); } + +static inline unsigned int iph_totlen (const struct sk_buff *skb,const struct iphdr *iph) +{ +u32 len =ntohs (iph->tot_len); + +return (len || !skb_is_gso (skb) || !skb_is_gso_tcp (skb)) ? + len : skb->len -skb_network_offset (skb); +} + +static inline unsigned int skb_ip_totlen (const struct sk_buff *skb) +{ +return iph_totlen (skb,ip_hdr (skb)); +} + +/* IPv4 datagram length is stored into 16bit field (tot_len) */ +#define IP_MAX_MTU 0xFFFFU + +static inline void iph_set_totlen (struct iphdr *iph,unsigned int len) +{ + iph->tot_len = len <=IP_MAX_MTU ?htons (len) :0 ; +}#endif /* _LINUX_IP_H */
include/net/route.h +0 -3
@@ -35,9 +35,6 @@#include <linux/cache.h> #include <linux/security.h> -/* IPv4 datagram length is stored into 16bit field (tot_len) */ -#define IP_MAX_MTU 0xFFFFU -#define RTO_ONLINK 0x01#define RT_CONN_FLAGS (sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 473/591 net/sched: act_ipt: add sanity checks on skb before calling target
In reply to Greg Kroah-HartmanFrom: Florian Westphal <[email protected]>
[ Upstream commit b2dc32dcba08bf55cec600caa76f4afd2e3614df ]
Netfilter targets make assumptions on the skb state, for example iphdr is supposed to be in the linear area.
This is normally done by IP stack, but in act_ipt case no such checks are made.
Some targets can even assume that skb_dst will be valid. Make a minimum effort to check for this:
- Don't call the targets eval function for non-ipv4 skbs.
- Don't call the targets eval function for POSTROUTING emulation when the skb has no dst set.
v3: use skb_protocol helper (Davide Caratti)
--- net/sched/act_ipt.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
net/sched/act_ipt.c +33 -0
@@ -229,6 +229,26 @@ static int tcf_xt_init(struct net *net, a, &act_xt_ops, tp, flags); } +static bool tcf_ipt_act_check (struct sk_buff *skb) +{ +const struct iphdr *iph; +unsigned int nhoff, len; + +if (!pskb_may_pull (skb,sizeof (struct iphdr ))) +return false; + + nhoff =skb_network_offset (skb); + iph =ip_hdr (skb); +if (iph->ihl <5 || iph->version !=4 ) +return false; + + len =skb_ip_totlen (skb); +if (skb->len < nhoff + len || len < (iph->ihl *4u )) +return false; + +return pskb_may_pull (skb, iph->ihl *4u ); +} +static int tcf_ipt_act (struct sk_buff *skb,const struct tc_action *a,struct tcf_result *res) {
@@ -242,9 +262,22 @@ static int tcf_ipt_act(struct sk_buff *s .pf = NFPROTO_IPV4, }; +if (skb_protocol (skb, false) !=htons (ETH_P_IP )) +return TC_ACT_UNSPEC ; +if (skb_unclone (skb,GFP_ATOMIC ))return TC_ACT_UNSPEC ; +if (!tcf_ipt_act_check (skb)) +return TC_ACT_UNSPEC ; + +if (state.hook ==NF_INET_POST_ROUTING ) { +if (!skb_dst (skb)) +return TC_ACT_UNSPEC ; + + state.out = skb->dev; + } +spin_lock (&ipt->tcf_lock);tcf_lastuse_update (&ipt->tcf_tm);
Greg Kroah-Hartman
maintainerPATCH 474/591 spi: spi-geni-qcom: enable SPI_CONTROLLER_MUST_TX for GPI DMA mode
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit d10005837be83906bbd2078c3b4f9dfcbd6c95b6 ]
The GPI DMA mode requires for TX DMA to be prepared. Force SPI core to provide TX buffer even if the caller didn't provide one by setting the SPI_CONTROLLER_MUST_TX flag.
--- drivers/spi/spi-geni-qcom.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/spi/spi-geni-qcom.c +6 -0
@@ -979,6 +979,12 @@ static int spi_geni_probe(struct platform_device *pdev)if (mas->cur_xfer_mode ==GENI_SE_FIFO ) spi->set_cs = spi_geni_set_cs; +/* +* TX is required per GSI spec, see setup_gsi_xfer(). +*/ +if (mas->cur_xfer_mode ==GENI_GPI_DMA ) + spi->flags =SPI_CONTROLLER_MUST_TX ; + ret =request_irq (mas->irq, geni_spi_isr,0 ,dev_name (dev), spi);if (ret) goto spi_geni_release_dma;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 475/591 net: mscc: ocelot: dont report that RX timestamping is enabled by default
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 4fd44b82b7aceaa35c2901c6546d2c4198e0799d ]
PTP RX timestamping should be enabled when the user requests it, not by default. If it is enabled by default, it can be problematic when the ocelot driver is a DSA master, and it sidesteps what DSA tries to avoid through __dsa_master_hwtstamp_validate().
Additionally, after the change which made ocelot trap PTP packets only to the CPU at ocelot_hwtstamp_set() time, it is no longer even true that RX timestamping is enabled by default, because until ocelot_hwtstamp_set() is called, the PTP traps are actually not set up. So the rx_filter field of ocelot->hwtstamp_config reflects an incorrect reality.
--- drivers/net/ethernet/mscc/ocelot_ptp.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/net/ethernet/mscc/ocelot_ptp.c +0 -5
@@ -824,11 +824,6 @@ int ocelot_init_timestamp(struct ocelot *ocelot,ocelot_write (ocelot,PTP_CFG_MISC_PTP_EN ,PTP_CFG_MISC ); -/* There is no device reconfiguration, PTP Rx stamping is always -* enabled. -*/ - ocelot->hwtstamp_config.rx_filter =HWTSTAMP_FILTER_PTP_V2_EVENT ; -return 0 ; }EXPORT_SYMBOL (ocelot_init_timestamp);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 476/591 net: mscc: ocelot: dont keep PTP configuration of all ports in single structure
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 45d0fcb5bc9558d0bf3d2fa7fabc5d8a88d35439 ]
In a future change, the driver will need to determine whether PTP RX timestamping is enabled on a port (including whether traps were set up on that port in particular) and that is currently not possible.
The driver supports different RX filters (L2, L4) and kinds of TX timestamping (one-step, two-step) on its ports, but it saves all configuration in a single struct hwtstamp_config that is global to the switch. So, the latest timestamping configuration on one port (including a request to disable timestamping) affects what gets reported for all ports, even though the configuration itself is still individual to each port.
The port timestamping configurations are only coupled because of the common structure, so replace the hwtstamp_config with a mask of trapped protocols saved per port. We also have the ptp_cmd to distinguish between one-step and two-step PTP timestamping, so with those 2 bits of information we can fully reconstruct a descriptive struct hwtstamp_config for each port, during the SIOCGHWTSTAMP ioctl.
--- drivers/net/ethernet/mscc/ocelot.c | 1 - drivers/net/ethernet/mscc/ocelot_ptp.c | 61 +++++++++++++++++--------- include/soc/mscc/ocelot.h | 10 +++-- 3 files changed, 48 insertions(+), 24 deletions(-)
drivers/net/ethernet/mscc/ocelot.c +0 -1
@@ -2728,7 +2728,6 @@ int ocelot_init(struct ocelot *ocelot) } } -mutex_init (&ocelot->ptp_lock);mutex_init (&ocelot->mact_lock);mutex_init (&ocelot->fwd_domain_lock);mutex_init (&ocelot->tas_lock);
drivers/net/ethernet/mscc/ocelot_ptp.c +41 -20
101 lines not on this page · raw message
include/soc/mscc/ocelot.h +7 -3
@@ -902,6 +902,11 @@ enum macaccess_entry_type { ENTRYTYPE_MACv6, }; +enum ocelot_proto { +OCELOT_PROTO_PTP_L2 =BIT (0 ), +OCELOT_PROTO_PTP_L4 =BIT (1 ), +}; +#define OCELOT_QUIRK_PCS_PERFORMS_RATE_ADAPTATION BIT(0)#define OCELOT_QUIRK_QSGMII_PORTS_MUST_BE_UP BIT(1)
@@ -939,6 +944,8 @@ struct ocelot_port {unsigned int ptp_skbs_in_flight;struct sk_buff_head tx_skbs; +unsigned int trap_proto; +u16 mrp_ring_id;u8 ptp_cmd;
@@ -1032,12 +1039,9 @@ struct ocelot { u8 ptp:1;struct ptp_clock *ptp_clock;struct ptp_clock_info ptp_info; -struct hwtstamp_config hwtstamp_config;unsigned int ptp_skbs_in_flight;/* Protects the 2-step TX timestamp ID logic */ spinlock_t ts_id_lock; -/* Protects the PTP interface state */ -struct mutex ptp_lock;/* Protects the PTP clock */ spinlock_t ptp_clock_lock;struct ptp_pin_desc ptp_pins[OCELOT_PTP_PINS_NUM ];
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 477/591 net: dsa: felix: dont drop PTP frames with tag_8021q when RX timestamping is disabled
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 2edcfcbb3c5946609be1d8875473a240b170673b ]
The driver implements a workaround for the fact that it doesn't have an IRQ source to tell it whether PTP frames are available through the extraction registers, for those frames to be processed and passed towards the network stack. That workaround is to configure the switch, through felix_hwtstamp_set() -> felix_update_trapping_destinations(), to create two copies of PTP packets: one sent over Ethernet to the DSA master, and one to be consumed through the aforementioned CPU extraction queue registers.
The reason why we want PTP packets to be consumed through the CPU extraction registers in the first place is because we want to see their hardware RX timestamp. With tag_8021q, that is only visible that way, and it isn't visible with the copy of the packet that's transmitted over Ethernet.
The problem with the workaround implementation is that it drops the packet received over Ethernet, in expectation of its copy being present in the CPU extraction registers. However, if felix_hwtstamp_set() hasn't run (aka PTP RX timestamping is disabled), the driver will drop the original PTP frame and there will be no copy of it in the CPU extraction registers. So, the network stack will simply not see any PTP frame.
Look at the port's trapping configuration to see whether the driver has previously enabled the CPU extraction registers. If it hasn't, just don't RX timestamp the frame and let it be passed up the stack by DSA, which is perfectly fine.
--- drivers/net/dsa/ocelot/felix.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/dsa/ocelot/felix.c +12 -0
@@ -1705,6 +1705,18 @@ static bool felix_rxtstamp(struct dsa_switch *ds, int port,u32 tstamp_hi;u64 tstamp; +switch (type &PTP_CLASS_PMASK ) { +case PTP_CLASS_L2 : +if (!(ocelot->ports[port]->trap_proto &OCELOT_PROTO_PTP_L2 )) +return false; +break ; +case PTP_CLASS_IPV4 : +case PTP_CLASS_IPV6 : +if (!(ocelot->ports[port]->trap_proto &OCELOT_PROTO_PTP_L4 )) +return false; +break ; + } +/* If the "no XTR IRQ" workaround is in use, tell DSA to defer this skb * for RX timestamping. Then free it, and poll for its copy through * MMIO in the CPU port module, and inject that into the stack from
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 478/591 net: dsa: sja1105: always enable the INCL_SRCPT option
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit b4638af8885af93cd70351081da1909c59342440 ]
Link-local traffic on bridged SJA1105 ports is sometimes tagged by the hardware with source port information (when the port is under a VLAN aware bridge).
The tag_8021q source port identification has become more loose ("imprecise") and will report a plausible rather than exact bridge port, when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local traffic always needs to know the precise source port.
Modify the driver logic (and therefore: the tagging protocol itself) to always include the source port information with link-local packets, regardless of whether the port is standalone, under a VLAN-aware or VLAN-unaware bridge. This makes it possible for the tagging driver to give priority to that information over the tag_8021q VLAN header.
The big drawback with INCL_SRCPT is that it makes it impossible to distinguish between an original MAC DA of 01:80:C2:XX:YY:ZZ and 01:80:C2:AA:BB:ZZ, because the tagger just patches MAC DA bytes 3 and 4 with zeroes. Only if PTP RX timestamping is enabled, the switch will generate a META follow-up frame containing the RX timestamp and the original bytes 3 and 4 of the MAC DA. Those will be used to patch up the original packet. Nonetheless, in the absence of PTP RX timestamping, we have to live with this limitation, since it is more important to have the more precise source port information for link-local traffic.
--- drivers/net/dsa/sja1105/sja1105_main.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/net/dsa/sja1105/sja1105_main.c +2 -7
@@ -866,11 +866,11 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .hostprio = 7, .mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A, .mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK, - .incl_srcpt1 = false, + .incl_srcpt1 = true, .send_meta1 = false, .mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B, .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, - .incl_srcpt0 = false, + .incl_srcpt0 = true, .send_meta0 = false,/* Default to an invalid value */ .mirr_port = priv->ds->num_ports,
@@ -2407,11 +2407,6 @@ int sja1105_vlan_filtering(struct dsa_switch *ds, int port, bool enabled, general_params->tpid = tpid;/* EtherType used to identify outer tagged (S-tag) VLAN traffic */ general_params->tpid2 = tpid2; -/* When VLAN filtering is on, we need to at least be able to -* decode management traffic through the "backup plan". -*/ - general_params->incl_srcpt1 = enabled; - general_params->incl_srcpt0 = enabled;for (port =0 ; port < ds->num_ports; port++) {if (dsa_is_unused_port (ds, port))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 479/591 net: dsa: tag_sja1105: always prefer source port information from INCL_SRCPT
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit c1ae02d876898b1b8ca1e12c6f84d7b406263800 ]
Currently the sja1105 tagging protocol prefers using the source port information from the VLAN header if that is available, falling back to the INCL_SRCPT option if it isn't. The VLAN header is available for all frames except for META frames initiated by the switch (containing RX timestamps), and thus, the "if (is_link_local)" branch is practically dead.
The tag_8021q source port identification has become more loose ("imprecise") and will report a plausible rather than exact bridge port, when under a bridge (be it VLAN-aware or VLAN-unaware). But link-local traffic always needs to know the precise source port. With incorrect source port reporting, for example PTP traffic over 2 bridged ports will all be seen on sockets opened on the first such port, which is incorrect.
Now that the tagging protocol has been changed to make link-local frames always contain source port information, we can reverse the order of the checks so that we always give precedence to that information (which is always precise) in lieu of the tag_8021q VID which is only precise for a standalone port.
--- net/dsa/tag_sja1105.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-)
net/dsa/tag_sja1105.c +29 -9
@@ -540,10 +540,7 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb, is_link_local =sja1105_is_link_local (skb); is_meta =sja1105_is_meta_frame (skb); -if (sja1105_skb_has_tag_8021q (skb)) { -/* Normal traffic path. */ -sja1105_vlan_rcv (skb, &source_port, &switch_id, &vbid, &vid); - }else if (is_link_local) { +if (is_link_local) {/* Management traffic path. Switch embeds the switch ID and * port ID into bytes of the destination MAC, courtesy of * the incl_srcpt options.
@@ -557,16 +554,39 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,sja1105_meta_unpack (skb, &meta); source_port = meta.source_port; switch_id = meta.switch_id; - }else { + } + +/* Normal data plane traffic and link-local frames are tagged with +* a tag_8021q VLAN which we have to strip +*/ +if (sja1105_skb_has_tag_8021q (skb)) { +int tmp_source_port =-1 , tmp_switch_id =-1 ; + +sja1105_vlan_rcv (skb, &tmp_source_port, &tmp_switch_id, &vbid, + &vid); +/* Preserve the source information from the INCL_SRCPT option, +* if available. This allows us to not overwrite a valid source +* port and switch ID with zeroes when receiving link-local +* frames from a VLAN-unaware bridged port (non-zero vbid) or a +* VLAN-aware bridged port (non-zero vid). +*/ +if (source_port ==-1 ) + source_port = tmp_source_port; +if (switch_id ==-1 ) + switch_id = tmp_switch_id; + }else if (source_port ==-1 && switch_id ==-1 ) { +/* Packets with no source information have no chance of +* getting accepted, drop them straight away. +*/ return NULL ; } -if (vbid >=1 ) +if (source_port !=-1 && switch_id !=-1 ) + skb->dev =dsa_master_find_slave (netdev, switch_id, source_port); +else if (vbid >=1 ) skb->dev =dsa_tag_8021q_find_port_by_vbid (netdev, vbid); -else if (source_port ==-1 || switch_id ==-1 ) - skb->dev =dsa_find_designated_bridge_port_by_vid (netdev, vid);else - skb->dev =dsa_master_find_slave (netdev, switch_id, source_port); + skb->dev =dsa_find_designated_bridge_port_by_vid (netdev, vid);if (!skb->dev) {netdev_warn (netdev,"Couldn't decode source port\n" );return NULL ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 480/591 Add MODULE_FIRMWARE() for FIRMWARE_TG357766.
In reply to Greg Kroah-HartmanFrom: Tobias Heider <[email protected]>
[ Upstream commit 046f753da6143ee16452966915087ec8b0de3c70 ]
Fixes a bug where on the M1 mac mini initramfs-tools fails to include the necessary firmware into the initrd.
--- drivers/net/ethernet/broadcom/tg3.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/broadcom/tg3.c +1 -0
@@ -224,6 +224,7 @@ MODULE_AUTHOR("David S. Miller ([email protected]) and Jeff Garzik (jgarzik@poboxMODULE_DESCRIPTION ("Broadcom Tigon3 ethernet driver" );MODULE_LICENSE ("GPL" );MODULE_FIRMWARE (FIRMWARE_TG3 ); +MODULE_FIRMWARE (FIRMWARE_TG357766 );MODULE_FIRMWARE (FIRMWARE_TG3TSO );MODULE_FIRMWARE (FIRMWARE_TG3TSO5 );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 481/591 Bluetooth: fix invalid-bdaddr quirk for non-persistent setup
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 0cb7365850bacb8c2a9975cae672d65714d8daa1 ]
Devices that lack persistent storage for the device address can indicate this by setting the HCI_QUIRK_INVALID_BDADDR which causes the controller to be marked as unconfigured until user space has set a valid address.
Once configured, the device address must be set on every setup for controllers with HCI_QUIRK_NON_PERSISTENT_SETUP to avoid marking the controller as unconfigured and requiring the address to be set again.
--- net/bluetooth/hci_sync.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
net/bluetooth/hci_sync.c +11 -17
@@ -4567,23 +4567,17 @@ static int hci_dev_setup_sync(struct hci_dev *hdev) invalid_bdaddr =test_bit (HCI_QUIRK_INVALID_BDADDR , &hdev->quirks);if (!ret) { -if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) { -if (!bacmp (&hdev->public_addr,BDADDR_ANY )) -hci_dev_get_bd_addr_from_property (hdev); - -if (bacmp (&hdev->public_addr,BDADDR_ANY ) && - hdev->set_bdaddr) { - ret = hdev->set_bdaddr (hdev, - &hdev->public_addr); - -/* If setting of the BD_ADDR from the device -* property succeeds, then treat the address -* as valid even if the invalid BD_ADDR -* quirk indicates otherwise. -*/ -if (!ret) - invalid_bdaddr = false; - } +if (test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks) && + !bacmp (&hdev->public_addr,BDADDR_ANY )) +hci_dev_get_bd_addr_from_property (hdev); + +if ((invalid_bdaddr || +test_bit (HCI_QUIRK_USE_BDADDR_PROPERTY , &hdev->quirks)) && +bacmp (&hdev->public_addr,BDADDR_ANY ) && + hdev->set_bdaddr) { + ret = hdev->set_bdaddr (hdev, &hdev->public_addr); +if (!ret) + invalid_bdaddr = false; } }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 482/591 Bluetooth: ISO: use hci_sync for setting CIG parameters
In reply to Greg Kroah-HartmanFrom: Pauli Virtanen <[email protected]>
[ Upstream commit 6b9545dc9f8ff01d8bc1229103960d9cd265343f ]
When reconfiguring CIG after disconnection of the last CIS, LE Remove CIG shall be sent before LE Set CIG Parameters. Otherwise, it fails because CIG is in the inactive state and not configurable (Core v5.3 Vol 6 Part B Sec. 4.5.14.3). This ordering is currently wrong under suitable timing conditions, because LE Remove CIG is sent via the hci_sync queue and may be delayed, but Set CIG Parameters is via hci_send_cmd.
Make the ordering well-defined by sending also Set CIG Parameters via hci_sync.
--- net/bluetooth/hci_conn.c | 47 +++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-)
net/bluetooth/hci_conn.c +39 -8
@@ -770,6 +770,11 @@ static void le_conn_timeout(struct work_struct *work)hci_abort_conn (conn,HCI_ERROR_REMOTE_USER_TERM ); } +struct iso_cig_params { +struct hci_cp_le_set_cig_params cp; +struct hci_cis_params cis[0x1f ]; +}; + struct iso_list_data { union { u8 cig;
@@ -781,10 +786,7 @@ struct iso_list_data {u16 sync_handle; };int count; -struct { -struct hci_cp_le_set_cig_params cp; -struct hci_cis_params cis[0x11 ]; - } pdu; +struct iso_cig_params pdu; };static void bis_list (struct hci_conn *conn,void *data)
@@ -1705,10 +1707,33 @@ static int hci_le_create_big(struct hci_conn *conn, struct bt_iso_qos *qos)return hci_send_cmd (hdev,HCI_OP_LE_CREATE_BIG ,sizeof (cp), &cp); } +static void set_cig_params_complete (struct hci_dev *hdev,void *data,int err) +{ +struct iso_cig_params *pdu = data; + +bt_dev_dbg (hdev,"" ); + +if (err) +bt_dev_err (hdev,"Unable to set CIG parameters: %d" , err); + +kfree (pdu); +} + +static int set_cig_params_sync (struct hci_dev *hdev,void *data) +{ +struct iso_cig_params *pdu = data; +u32 plen; + + plen =sizeof (pdu->cp) + pdu->cp.num_cis *sizeof (pdu->cis[0 ]); +return __hci_cmd_sync_status (hdev,HCI_OP_LE_SET_CIG_PARAMS , plen, pdu, +HCI_CMD_TIMEOUT ); +} +static bool hci_le_set_cig_params (struct hci_conn *conn,struct bt_iso_qos *qos) {struct hci_dev *hdev = conn->hdev;struct iso_list_data data; +struct iso_cig_params *pdu;memset (&data,0 ,sizeof (data));
@@ -1779,12 +1804,18 @@ static bool hci_le_set_cig_params(struct hci_conn *conn, struct bt_iso_qos *qos)if (qos->cis ==BT_ISO_QOS_CIS_UNSET || !data.pdu.cp.num_cis)return false; -if (hci_send_cmd (hdev,HCI_OP_LE_SET_CIG_PARAMS , -sizeof (data.pdu.cp) + - (data.pdu.cp.num_cis *sizeof (*data.pdu.cis)), - &data.pdu) <0 ) + pdu =kzalloc (sizeof (*pdu),GFP_KERNEL ); +if (!pdu)return false; +memcpy (pdu, &data.pdu,sizeof (*pdu)); + +if (hci_cmd_sync_queue (hdev, set_cig_params_sync, pdu, + set_cig_params_complete) <0 ) { +kfree (pdu); +return false; + } +return true; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 483/591 Bluetooth: MGMT: add CIS feature bits to controller information
In reply to Greg Kroah-HartmanFrom: Pauli Virtanen <[email protected]>
[ Upstream commit 2394186a2cefb9a45a029281a55749804dd8c556 ]
Userspace needs to know whether the adapter has feature support for Connected Isochronous Stream - Central/Peripheral, so it can set up LE Audio features accordingly.
Expose these feature bits as settings in MGMT controller info.
Stable-dep-of: 73f55453ea52 ("Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable")
--- include/net/bluetooth/mgmt.h | 2 ++ net/bluetooth/mgmt.c | 12 ++++++++++++ 2 files changed, 14 insertions(+)
include/net/bluetooth/mgmt.h +2 -0
@@ -109,6 +109,8 @@ struct mgmt_rp_read_index_list {#define MGMT_SETTING_STATIC_ADDRESS 0x00008000#define MGMT_SETTING_PHY_CONFIGURATION 0x00010000#define MGMT_SETTING_WIDEBAND_SPEECH 0x00020000 +#define MGMT_SETTING_CIS_CENTRAL 0x00040000 +#define MGMT_SETTING_CIS_PERIPHERAL 0x00080000#define MGMT_OP_READ_INFO 0x0004#define MGMT_READ_INFO_SIZE 0
net/bluetooth/mgmt.c +12 -0
@@ -859,6 +859,12 @@ static u32 get_supported_settings(struct hci_dev *hdev) hdev->set_bdaddr) settings |=MGMT_SETTING_CONFIGURATION ; +if (cis_central_capable (hdev)) + settings |=MGMT_SETTING_CIS_CENTRAL ; + +if (cis_peripheral_capable (hdev)) + settings |=MGMT_SETTING_CIS_PERIPHERAL ; + settings |=MGMT_SETTING_PHY_CONFIGURATION ;return settings;
@@ -932,6 +938,12 @@ static u32 get_current_settings(struct hci_dev *hdev)if (hci_dev_test_flag (hdev,HCI_WIDEBAND_SPEECH_ENABLED )) settings |=MGMT_SETTING_WIDEBAND_SPEECH ; +if (cis_central_capable (hdev)) + settings |=MGMT_SETTING_CIS_CENTRAL ; + +if (cis_peripheral_capable (hdev)) + settings |=MGMT_SETTING_CIS_PERIPHERAL ; +return settings; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 484/591 Bluetooth: MGMT: Use BIT macro when defining bitfields
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit a80d2c545ded86d0350b9a870735565d8b749786 ]
This makes use of BIT macro when defining bitfields which makes it clearer what bit it is toggling.
Stable-dep-of: 73f55453ea52 ("Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable")
--- include/net/bluetooth/mgmt.h | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-)
include/net/bluetooth/mgmt.h +40 -40
@@ -91,26 +91,26 @@ struct mgmt_rp_read_index_list {#define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1)#define MGMT_MAX_SHORT_NAME_LENGTH (HCI_MAX_SHORT_NAME_LENGTH + 1) -#define MGMT_SETTING_POWERED 0x00000001 -#define MGMT_SETTING_CONNECTABLE 0x00000002 -#define MGMT_SETTING_FAST_CONNECTABLE 0x00000004 -#define MGMT_SETTING_DISCOVERABLE 0x00000008 -#define MGMT_SETTING_BONDABLE 0x00000010 -#define MGMT_SETTING_LINK_SECURITY 0x00000020 -#define MGMT_SETTING_SSP 0x00000040 -#define MGMT_SETTING_BREDR 0x00000080 -#define MGMT_SETTING_HS 0x00000100 -#define MGMT_SETTING_LE 0x00000200 -#define MGMT_SETTING_ADVERTISING 0x00000400 -#define MGMT_SETTING_SECURE_CONN 0x00000800 -#define MGMT_SETTING_DEBUG_KEYS 0x00001000 -#define MGMT_SETTING_PRIVACY 0x00002000 -#define MGMT_SETTING_CONFIGURATION 0x00004000 -#define MGMT_SETTING_STATIC_ADDRESS 0x00008000 -#define MGMT_SETTING_PHY_CONFIGURATION 0x00010000 -#define MGMT_SETTING_WIDEBAND_SPEECH 0x00020000 -#define MGMT_SETTING_CIS_CENTRAL 0x00040000 -#define MGMT_SETTING_CIS_PERIPHERAL 0x00080000 +#define MGMT_SETTING_POWERED BIT(0) +#define MGMT_SETTING_CONNECTABLE BIT(1) +#define MGMT_SETTING_FAST_CONNECTABLE BIT(2) +#define MGMT_SETTING_DISCOVERABLE BIT(3) +#define MGMT_SETTING_BONDABLE BIT(4) +#define MGMT_SETTING_LINK_SECURITY BIT(5) +#define MGMT_SETTING_SSP BIT(6) +#define MGMT_SETTING_BREDR BIT(7) +#define MGMT_SETTING_HS BIT(8) +#define MGMT_SETTING_LE BIT(9) +#define MGMT_SETTING_ADVERTISING BIT(10) +#define MGMT_SETTING_SECURE_CONN BIT(11) +#define MGMT_SETTING_DEBUG_KEYS BIT(12) +#define MGMT_SETTING_PRIVACY BIT(13) +#define MGMT_SETTING_CONFIGURATION BIT(14) +#define MGMT_SETTING_STATIC_ADDRESS BIT(15) +#define MGMT_SETTING_PHY_CONFIGURATION BIT(16) +#define MGMT_SETTING_WIDEBAND_SPEECH BIT(17) +#define MGMT_SETTING_CIS_CENTRAL BIT(18) +#define MGMT_SETTING_CIS_PERIPHERAL BIT(19)#define MGMT_OP_READ_INFO 0x0004#define MGMT_READ_INFO_SIZE 0
@@ -635,21 +635,21 @@ struct mgmt_rp_get_phy_configuration { } __packed;#define MGMT_GET_PHY_CONFIGURATION_SIZE 0 -#define MGMT_PHY_BR_1M_1SLOT 0x00000001 -#define MGMT_PHY_BR_1M_3SLOT 0x00000002 -#define MGMT_PHY_BR_1M_5SLOT 0x00000004 -#define MGMT_PHY_EDR_2M_1SLOT 0x00000008 -#define MGMT_PHY_EDR_2M_3SLOT 0x00000010 -#define MGMT_PHY_EDR_2M_5SLOT 0x00000020 -#define MGMT_PHY_EDR_3M_1SLOT 0x00000040 -#define MGMT_PHY_EDR_3M_3SLOT 0x00000080 -#define MGMT_PHY_EDR_3M_5SLOT 0x00000100 -#define MGMT_PHY_LE_1M_TX 0x00000200 -#define MGMT_PHY_LE_1M_RX 0x00000400 -#define MGMT_PHY_LE_2M_TX 0x00000800 -#define MGMT_PHY_LE_2M_RX 0x00001000 -#define MGMT_PHY_LE_CODED_TX 0x00002000 -#define MGMT_PHY_LE_CODED_RX 0x00004000 +#define MGMT_PHY_BR_1M_1SLOT BIT(0) +#define MGMT_PHY_BR_1M_3SLOT BIT(1) +#define MGMT_PHY_BR_1M_5SLOT BIT(2) +#define MGMT_PHY_EDR_2M_1SLOT BIT(3) +#define MGMT_PHY_EDR_2M_3SLOT BIT(4) +#define MGMT_PHY_EDR_2M_5SLOT BIT(5) +#define MGMT_PHY_EDR_3M_1SLOT BIT(6) +#define MGMT_PHY_EDR_3M_3SLOT BIT(7) +#define MGMT_PHY_EDR_3M_5SLOT BIT(8) +#define MGMT_PHY_LE_1M_TX BIT(9) +#define MGMT_PHY_LE_1M_RX BIT(10) +#define MGMT_PHY_LE_2M_TX BIT(11) +#define MGMT_PHY_LE_2M_RX BIT(12) +#define MGMT_PHY_LE_CODED_TX BIT(13) +#define MGMT_PHY_LE_CODED_RX BIT(14)#define MGMT_PHY_BREDR_MASK (MGMT_PHY_BR_1M_1SLOT | MGMT_PHY_BR_1M_3SLOT | \ MGMT_PHY_BR_1M_5SLOT | MGMT_PHY_EDR_2M_1SLOT | \
@@ -974,11 +974,11 @@ struct mgmt_ev_auth_failed {__u8 status; } __packed; -#define MGMT_DEV_FOUND_CONFIRM_NAME 0x01 -#define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02 -#define MGMT_DEV_FOUND_NOT_CONNECTABLE 0x04 -#define MGMT_DEV_FOUND_INITIATED_CONN 0x08 -#define MGMT_DEV_FOUND_NAME_REQUEST_FAILED 0x10 +#define MGMT_DEV_FOUND_CONFIRM_NAME BIT(0) +#define MGMT_DEV_FOUND_LEGACY_PAIRING BIT(1) +#define MGMT_DEV_FOUND_NOT_CONNECTABLE BIT(2) +#define MGMT_DEV_FOUND_INITIATED_CONN BIT(3) +#define MGMT_DEV_FOUND_NAME_REQUEST_FAILED BIT(4)#define MGMT_EV_DEVICE_FOUND 0x0012struct mgmt_ev_device_found {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 485/591 Bluetooth: MGMT: Fix marking SCAN_RSP as not connectable
In reply to Greg Kroah-HartmanFrom: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 73f55453ea5236a586a7f1b3d5e2ee051d655351 ]
When receiving a scan response there is no way to know if the remote device is connectable or not, so when it cannot be merged don't make any assumption and instead just mark it with a new flag defined as MGMT_DEV_FOUND_SCAN_RSP so userspace can tell it is a standalone SCAN_RSP.
--- include/net/bluetooth/mgmt.h | 1 + net/bluetooth/hci_event.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-)
include/net/bluetooth/mgmt.h +1 -0
@@ -979,6 +979,7 @@ struct mgmt_ev_auth_failed {#define MGMT_DEV_FOUND_NOT_CONNECTABLE BIT(2)#define MGMT_DEV_FOUND_INITIATED_CONN BIT(3)#define MGMT_DEV_FOUND_NAME_REQUEST_FAILED BIT(4) +#define MGMT_DEV_FOUND_SCAN_RSP BIT(5)#define MGMT_EV_DEVICE_FOUND 0x0012struct mgmt_ev_device_found {
net/bluetooth/hci_event.c +5 -10
@@ -6307,23 +6307,18 @@ static void process_adv_report(struct hci_dev *hdev, u8 type, bdaddr_t *bdaddr,return ; } -/* When receiving non-connectable or scannable undirected -* advertising reports, this means that the remote device is -* not connectable and then clearly indicate this in the -* device found event. -* -* When receiving a scan response, then there is no way to +/* When receiving a scan response, then there is no way to * know if the remote device is connectable or not. However * since scan responses are merged with a previously seen * advertising report, the flags field from that report * will be used. * -* In the really unlikely case that a controller get confused -* and just sends a scan response event, then it is marked as -* not connectable as well. +* In the unlikely case that a controller just sends a scan +* response event that doesn't match the pending report, then +* it is marked as a standalone SCAN_RSP. */ if (type ==LE_ADV_SCAN_RSP ) - flags =MGMT_DEV_FOUND_NOT_CONNECTABLE ; + flags =MGMT_DEV_FOUND_SCAN_RSP ;/* If there's nothing pending either store the data from this * event or send an immediate device found event if the data
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 486/591 ibmvnic: Do not reset dql stats on NON_FATAL err
In reply to Greg Kroah-HartmanFrom: Nick Child <[email protected]>
[ Upstream commit 48538ccb825b05544ec308a509e2cc9c013402db ]
All ibmvnic resets, make a call to netdev_tx_reset_queue() when re-opening the device. netdev_tx_reset_queue() resets the num_queued and num_completed byte counters. These stats are used in Byte Queue Limit (BQL) algorithms. The difference between these two stats tracks the number of bytes currently sitting on the physical NIC. ibmvnic increases the number of queued bytes though calls to netdev_tx_sent_queue() in the drivers xmit function. When, VIOS reports that it is done transmitting bytes, the ibmvnic device increases the number of completed bytes through calls to netdev_tx_completed_queue(). It is important to note that the driver batches its transmit calls and num_queued is increased every time that an skb is added to the next batch, not necessarily when the batch is sent to VIOS for transmission.
Unlike other reset types, a NON FATAL reset will not flush the sub crq tx buffers. Therefore, it is possible for the batched skb array to be partially full. So if there is call to netdev_tx_reset_queue() when re-opening the device, the value of num_queued (0) would not account for the skb's that are currently batched. Eventually, when the batch is sent to VIOS, the call to netdev_tx_completed_queue() would increase num_completed to a value greater than the num_queued. This causes a BUG_ON crash:
ibmvnic 30000002: Firmware reports error, cause: adapter problem. Starting recovery...
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
ibmvnic 30000002: tx error 600
------------[ cut here ]------------ kernel BUG at lib/dynamic_queue_limits.c:27! Oops: Exception in kernel mode, sig: 5 [....] NIP dql_completed+0x28/0x1c0 LR ibmvnic_complete_tx.isra.0+0x23c/0x420 [ibmvnic] Call Trace: ibmvnic_complete_tx.isra.0+0x3f8/0x420 [ibmvnic] (unreliable) ibmvnic_interrupt_tx+0x40/0x70 [ibmvnic] __handle_irq_event_percpu+0x98/0x270 ---[ end trace ]---
Therefore, do not reset the dql stats when performing a NON_FATAL reset.
--- drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/ethernet/ibm/ibmvnic.c +8 -1
@@ -1625,7 +1625,14 @@ static int __ibmvnic_open(struct net_device *netdev)if (prev_state ==VNIC_CLOSED )enable_irq (adapter->tx_scrq[i]->irq);enable_scrq_irq (adapter, adapter->tx_scrq[i]); -netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); +/* netdev_tx_reset_queue will reset dql stats. During NON_FATAL +* resets, don't reset the stats because there could be batched +* skb's waiting to be sent. If we reset dql stats, we risk +* num_completed being greater than num_queued. This will cause +* a BUG_ON in dql_completed(). +*/ +if (adapter->reset_reason !=VNIC_RESET_NON_FATAL ) +netdev_tx_reset_queue (netdev_get_tx_queue (netdev, i)); } rc =set_link_state (adapter,IBMVNIC_LOGICAL_LNK_UP );
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 487/591 net: dsa: vsc73xx: fix MTU configuration
In reply to Greg Kroah-HartmanFrom: Pawel Dembicki <[email protected]>
[ Upstream commit 3cf62c8177adb0db9e15c8b898c44f997acf3ebf ]
Switch in MAXLEN register stores the maximum size of a data frame. The MTU size is 18 bytes smaller than the frame size.
The current settings are causing problems with packet forwarding. This patch fixes the MTU settings to proper values.
--- drivers/net/dsa/vitesse-vsc73xx-core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/vitesse-vsc73xx-core.c +3 -3
@@ -1025,17 +1025,17 @@ static int vsc73xx_change_mtu(struct dsa_switch *ds, int port, int new_mtu)struct vsc73xx *vsc = ds->priv;return vsc73xx_write (vsc,VSC73XX_BLOCK_MAC , port, -VSC73XX_MAXLEN , new_mtu); +VSC73XX_MAXLEN , new_mtu +ETH_HLEN +ETH_FCS_LEN ); }/* According to application not "VSC7398 Jumbo Frames" setting -* up the MTU to 9.6 KB does not affect the performance on standard +* up the frame size to 9.6 KB does not affect the performance on standard * frames. It is clear from the application note that * "9.6 kilobytes" == 9600 bytes. */ static int vsc73xx_get_max_mtu (struct dsa_switch *ds,int port) { -return 9600 ; +return 9600 -ETH_HLEN -ETH_FCS_LEN ; }static const struct dsa_switch_ops vsc73xx_ds_ops = {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 488/591 mlxsw: minimal: fix potential memory leak in mlxsw_m_linecards_init
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 08fc75735fda3be97194bfbf3c899c87abb3d0fe ]
The line cards array is not freed in the error path of mlxsw_m_linecards_init(), which can lead to a memory leak. Fix by freeing the array in the error path, thereby making the error path identical to mlxsw_m_linecards_fini().
--- drivers/net/ethernet/mellanox/mlxsw/minimal.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/minimal.c +1 -0
@@ -430,6 +430,7 @@ static int mlxsw_m_linecards_init(struct mlxsw_m *mlxsw_m) err_kmalloc_array:for (i--; i >=0 ; i--)kfree (mlxsw_m->line_cards[i]); +kfree (mlxsw_m->line_cards); err_kcalloc:kfree (mlxsw_m->ports);return err;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 489/591 spi: bcm-qspi: return error if neither hif_mspi nor mspi is available
In reply to Greg Kroah-HartmanFrom: Jonas Gorski <[email protected]>
[ Upstream commit 7c1f23ad34fcdace50275a6aa1e1969b41c6233f ]
If neither a "hif_mspi" nor "mspi" resource is present, the driver will just early exit in probe but still return success. Apart from not doing anything meaningful, this would then also lead to a null pointer access on removal, as platform_get_drvdata() would return NULL, which it would then try to dereference when trying to unregister the spi master.
Fix this by unconditionally calling devm_ioremap_resource(), as it can handle a NULL res and will then return a viable ERR_PTR() if we get one.
The "return 0;" was previously a "goto qspi_resource_err;" where then ret was returned, but since ret was still initialized to 0 at this place this was a valid conversion in 63c5395bb7a9 ("spi: bcm-qspi: Fix use-after-free on unbind"). The issue was not introduced by this commit, only made more obvious.
--- drivers/spi/spi-bcm-qspi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/spi/spi-bcm-qspi.c +3 -7
@@ -1543,13 +1543,9 @@ int bcm_qspi_probe(struct platform_device *pdev, res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mspi" ); -if (res) { - qspi->base[MSPI ] =devm_ioremap_resource (dev, res); -if (IS_ERR (qspi->base[MSPI ])) -return PTR_ERR (qspi->base[MSPI ]); - }else { -return 0 ; - } + qspi->base[MSPI ] =devm_ioremap_resource (dev, res); +if (IS_ERR (qspi->base[MSPI ])) +return PTR_ERR (qspi->base[MSPI ]); res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"bspi" );if (res) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 490/591 drm/amdgpu: fix number of fence calculations
In reply to Greg Kroah-HartmanFrom: Christian König <[email protected]>
[ Upstream commit 570b295248b00c3cf4cf59e397de5cb2361e10c2 ]
Since adding gang submit we need to take the gang size into account while reserving fences.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -5
@@ -129,9 +129,6 @@ static int amdgpu_cs_p1_user_fence(struct amdgpu_cs_parser *p, bo =amdgpu_bo_ref (gem_to_amdgpu_bo (gobj)); p->uf_entry.priority =0 ; p->uf_entry.tv.bo = &bo->tbo; -/* One for TTM and two for the CS job */ - p->uf_entry.tv.num_shared =3 ; -drm_gem_object_put (gobj); size =amdgpu_bo_size (bo);
@@ -883,15 +880,19 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,mutex_lock (&p->bo_list->bo_list_mutex); -/* One for TTM and one for the CS job */ +/* One for TTM and one for each CS job */ amdgpu_bo_list_for_each_entry (e, p->bo_list) - e->tv.num_shared =2 ; + e->tv.num_shared =1 + p->gang_size; + p->uf_entry.tv.num_shared =1 + p->gang_size;amdgpu_bo_list_get_list (p->bo_list, &p->validated);INIT_LIST_HEAD (&duplicates);amdgpu_vm_get_pd_bo (&fpriv->vm, &p->validated, &p->vm_pd); +/* Two for VM updates, one for TTM and one for each CS job */ + p->vm_pd.tv.num_shared =3 + p->gang_size; +if (p->uf_entry.tv.bo && !ttm_to_amdgpu_bo (p->uf_entry.tv.bo)->parent)list_add (&p->uf_entry.tv.head, &p->validated);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 491/591 drm/amd: Dont try to enable secure display TA multiple times
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
[ Upstream commit 5c6d52ff4b61e5267b25be714eb5a9ba2a338199 ]
If the securedisplay TA failed to load the first time, it's unlikely to work again after a suspend/resume cycle or reset cycle and it appears to be causing problems in futher attempts.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c +2 -0
@@ -1959,6 +1959,8 @@ static int psp_securedisplay_initialize(struct psp_context *psp)psp_securedisplay_parse_resp_status (psp, securedisplay_cmd->status);dev_err (psp->adev->dev,"SECUREDISPLAY: query securedisplay TA failed. ret 0x%x\n" , securedisplay_cmd->securedisplay_out_message.query_ta.query_cmd_ret); +/* don't try again */ + psp->securedisplay_context.context.bin_desc.size_bytes =0 ; }return 0 ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 492/591 mailbox: ti-msgmgr: Fill non-message tx data fields with 0x0
In reply to Greg Kroah-HartmanFrom: Nishanth Menon <[email protected]>
[ Upstream commit 1b712f18c461bd75f018033a15cf381e712806b5 ]
Sec proxy/message manager data buffer is 60 bytes with the last of the registers indicating transmission completion. This however poses a bit of a challenge.
The backing memory for sec_proxy / message manager is regular memory, and all sec proxy does is to trigger a burst of all 60 bytes of data over to the target thread backing ring accelerator. It doesn't do a memory scrub when it moves data out in the burst. When we transmit multiple messages, remnants of previous message is also transmitted which results in some random data being set in TISCI fields of messages that have been expanded forward.
The entire concept of backward compatibility hinges on the fact that the unused message fields remain 0x0 allowing for 0x0 value to be specially considered when backward compatibility of message extension is done.
So, instead of just writing the completion register, we continue to fill the message buffer up with 0x0 (note: for partial message involving completion, we already do this).
This allows us to scale and introduce ABI changes back also work with other boot stages that may have left data in the internal memory.
While at this, be consistent and explicit with the data_reg pointer increment.
--- drivers/mailbox/ti-msgmgr.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/mailbox/ti-msgmgr.c +9 -3
@@ -430,14 +430,20 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data)/* Ensure all unused data is 0 */ data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes));writel (data_trail, data_reg); - data_reg++; + data_reg +=sizeof (u32); } +/* * 'data_reg' indicates next register to write. If we did not already * write on tx complete reg(last reg), we must do so for transmit +* In addition, we also need to make sure all intermediate data +* registers(if any required), are reset to 0 for TISCI backward +* compatibility to be maintained. */ -if (data_reg <= qinst->queue_buff_end) -writel (0 , qinst->queue_buff_end); +while (data_reg <= qinst->queue_buff_end) { +writel (0 , data_reg); + data_reg +=sizeof (u32); + }/* If we are in polled mode, wait for a response before proceeding */ if (ti_msgmgr_chan_has_polled_queue_rx (message->chan_rx))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 493/591 f2fs: fix error path handling in truncate_dnode()
In reply to Greg Kroah-HartmanFrom: Chao Yu <[email protected]>
[ Upstream commit 0135c482fa97e2fd8245cb462784112a00ed1211 ]
If truncate_node() fails in truncate_dnode(), it missed to call f2fs_put_page(), fix it.
--- fs/f2fs/node.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/f2fs/node.c +3 -1
@@ -941,8 +941,10 @@ static int truncate_dnode(struct dnode_of_data *dn) dn->ofs_in_node =0 ;f2fs_truncate_data_blocks (dn); err =truncate_node (dn); -if (err) +if (err) { +f2fs_put_page (page,1 );return err; + }return 1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 494/591 octeontx2-af: Fix mapping for NIX block from CGX connection
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 2e7bc57b976bb016c6569a54d95c1b8d88f9450a ]
Firmware configures NIX block mapping for all MAC blocks. The current implementation reads the configuration and creates the mapping between RVU PF and NIX blocks. But this configuration is only valid for silicons that support multiple blocks. For all other silicons, all MAC blocks map to NIX0.
This patch corrects the mapping by adding a check for the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu.h | 11 +++++++++++ drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +11 -0
@@ -23,6 +23,7 @@#define PCI_DEVID_OCTEONTX2_LBK 0xA061/* Subsystem Device ID */ +#define PCI_SUBSYS_DEVID_98XX 0xB100#define PCI_SUBSYS_DEVID_96XX 0xB200#define PCI_SUBSYS_DEVID_CN10K_A 0xB900#define PCI_SUBSYS_DEVID_CNF10K_B 0xBC00
@@ -646,6 +647,16 @@ static inline u16 rvu_nix_chan_cpt(struct rvu *rvu, u8 chan)return rvu->hw->cpt_chan_base + chan; } +static inline bool is_rvu_supports_nix1 (struct rvu *rvu) +{ +struct pci_dev *pdev = rvu->pdev; + +if (pdev->subsystem_device ==PCI_SUBSYS_DEVID_98XX ) +return true; + +return false; +} +/* Function Prototypes * RVU */
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -112,7 +112,7 @@ static void rvu_map_cgx_nix_block(struct rvu *rvu, int pf, p2x =cgx_lmac_get_p2x (cgx_id, lmac_id);/* Firmware sets P2X_SELECT as either NIX0 or NIX1 */ pfvf->nix_blkaddr =BLKADDR_NIX0 ; -if (p2x ==CMR_P2X_SEL_NIX1 ) +if (is_rvu_supports_nix1 (rvu) && p2x ==CMR_P2X_SEL_NIX1 ) pfvf->nix_blkaddr =BLKADDR_NIX1 ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 495/591 octeontx2-af: Add validation before accessing cgx and lmac
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 79ebb53772c95d3a6ae51b3c65f9985fdd430df6 ]
with the addition of new MAC blocks like CN10K RPM and CN10KB RPM_USX, LMACs are noncontiguous and CGX blocks are also noncontiguous. But during RVU driver initialization, the driver is assuming they are contiguous and trying to access cgx or lmac with their id which is resulting in kernel panic.
This patch fixes the issue by adding proper checks.
[ 23.219150] pc : cgx_lmac_read+0x38/0x70 [ 23.219154] lr : rvu_program_channels+0x3f0/0x498 [ 23.223852] sp : ffff000100d6fc80 [ 23.227158] x29: ffff000100d6fc80 x28: ffff00010009f880 x27: 000000000000005a [ 23.234288] x26: ffff000102586768 x25: 0000000000002500 x24:
fffffffffff0f000
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +7 -0
@@ -167,6 +167,9 @@ void cgx_lmac_write(int cgx_id, int lmac_id, u64 offset, u64 val) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return ;cgx_write (cgx_dev, lmac_id, offset, val); }
@@ -174,6 +177,10 @@ u64 cgx_lmac_read(int cgx_id, int lmac_id, u64 offset) {struct cgx *cgx_dev =cgx_get_pdata (cgx_id); +/* Software must not access disabled LMAC registers */ +if (!is_lmac_valid (cgx_dev, lmac_id)) +return 0 ; +return cgx_read (cgx_dev, lmac_id, offset); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 496/591 ntfs: Fix panic about slab-out-of-bounds caused by ntfs_listxattr()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit 3c675ddffb17a8b1e32efad5c983254af18b12c2 ]
Here is a BUG report from syzbot:
BUG: KASAN: slab-out-of-bounds in ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] BUG: KASAN: slab-out-of-bounds in ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 Read of size 1 at addr ffff888021acaf3d by task syz-executor128/3632 Call Trace: ntfs_list_ea fs/ntfs3/xattr.c:191 [inline] ntfs_listxattr+0x401/0x570 fs/ntfs3/xattr.c:710 vfs_listxattr fs/xattr.c:457 [inline] listxattr+0x293/0x2d0 fs/xattr.c:804
Fix the logic of ea_all iteration. When the ea->name_len is 0, return immediately, or Add2Ptr() would visit invalid memory in the next loop.
--- fs/ntfs3/xattr.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/xattr.c +3 -0
@@ -178,6 +178,9 @@ static ssize_t ntfs_list_ea(struct ntfs_inode *ni, char *buffer,for (ret =0 , off =0 ; off < size; off +=unpacked_ea_size (ea)) { ea =Add2Ptr (ea_all, off); +if (!ea->name_len) +break ; +if (buffer) {if (ret + ea->name_len +1 > bytes_per_buffer) { err = -ERANGE ;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 497/591 powerpc: allow PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 39f49684036d24af800ff194c33c7b2653c591d7 ]
In a randconfig with CONFIG_SERIAL_CPM=m and CONFIG_PPC_EARLY_DEBUG_CPM=y, there is a build error:
ERROR: modpost: "udbg_putc" [drivers/tty/serial/cpm_uart/cpm_uart.ko] undefined!
Prevent the build error by allowing PPC_EARLY_DEBUG_CPM only when SERIAL_CPM=y.
--- arch/powerpc/Kconfig.debug | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/Kconfig.debug +1 -1
@@ -240,7 +240,7 @@ config PPC_EARLY_DEBUG_40x config PPC_EARLY_DEBUG_CPM bool "Early serial debugging for Freescale CPM-based serial ports" - depends on SERIAL_CPM + depends on SERIAL_CPM=y help Select this to enable early debugging for Freescale chips using a CPM-based serial port. This assumes that the bootwrapper
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 498/591 powerpc: dts: turris1x.dts: Fix PCIe MEM size for pci2 node
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit abaa02fc944f2f9f2c2e1925ddaceaf35c48528c ]
Freescale PCIe controllers on their PCIe Root Ports do not have any mappable PCI BAR allocate from PCIe MEM.
Information about 1MB window on BAR0 of PCIe Root Port was misleading because Freescale PCIe controllers have at BAR0 position different register PEXCSRBAR, and kernel correctly skipts BAR0 for these Freescale PCIe Root Ports.
So update comment about P2020 PCIe Root Port and decrease PCIe MEM size required for PCIe controller (pci2 node) on which is on-board xHCI controller.
lspci confirms that on P2020 PCIe Root Port is no PCI BAR and /proc/iomem sees that only c0000000-c000ffff and c0010000-c0011fff ranges are used.
--- arch/powerpc/boot/dts/turris1x.dts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/powerpc/boot/dts/turris1x.dts +3 -3
@@ -453,12 +453,12 @@ pci2: pcie@ffe08000 { * channel 1 (but only USB 2.0 subset) to USB 2.0 pins on mPCIe * slot 1 (CN5), channels 2 and 3 to connector P600. * - * P2020 PCIe Root Port uses 1MB of PCIe MEM and xHCI controller + * P2020 PCIe Root Port does not use PCIe MEM and xHCI controller * uses 64kB + 8kB of PCIe MEM. No PCIe IO is used or required. - * So allocate 2MB of PCIe MEM for this PCIe bus. + * So allocate 128kB of PCIe MEM for this PCIe bus. */ reg = <0 0xffe08000 0 0x1000>; - ranges = <0x02000000 0x0 0xc0000000 0 0xc0000000 0x0 0x00200000>, /* MEM */ + ranges = <0x02000000 0x0 0xc0000000 0 0xc0000000 0x0 0x00020000>, /* MEM */ <0x01000000 0x0 0x00000000 0 0xffc20000 0x0 0x00010000>; /* IO */ pcie@0 {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 499/591 net: bridge: keep ports without IFF_UNICAST_FLT in BR_PROMISC mode
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 6ca3c005d0604e8d2b439366e3923ea58db99641 ]
According to the synchronization rules for .ndo_get_stats() as seen in Documentation/networking/netdevices.rst, acquiring a plain spin_lock() should not be illegal, but the bridge driver implementation makes it so.
After running these commands, I am being faced with the following lockdep splat:
$ ip link add link swp0 name macsec0 type macsec encrypt on && ip link set swp0 up $ ip link add dev br0 type bridge vlan_filtering 1 && ip link set br0 up $ ip link set macsec0 master br0 && ip link set macsec0 up
========================================================
WARNING: possible irq lock inversion dependency detected 6.4.0-04295-g31b577b4bd4a #603 Not tainted
--------------------------------------------------------
swapper/1/0 just changed the state of lock:
ffff6bd348724cd8 (&br->lock){+.-.}-{3:3}, at: br_forward_delay_timer_expired+0x34/0x198 but this lock took another, SOFTIRQ-unsafe lock in the past:
(&ocelot->stats_lock){+.+.}-{3:3}
and interrupts could create inverse lock ordering between them.
other info that might help us debug this:
Chain exists of:
&br->lock --> &br->hash_lock --> &ocelot->stats_lockPossible interrupt unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&ocelot->stats_lock);
local_irq_disable();
lock(&br->lock);
lock(&br->hash_lock);
<Interrupt>
lock(&br->lock);*** DEADLOCK ***
(details about the 3 locks skipped)
swp0 is instantiated by drivers/net/dsa/ocelot/felix.c, and this only matters to the extent that its .ndo_get_stats64() method calls spin_lock(&ocelot->stats_lock).
Documentation/locking/lockdep-design.rst says:
| A lock is irq-safe means it was ever used in an irq context, while a lock | is irq-unsafe means it was ever acquired with irq enabled.
(...)
| Furthermore, the following usage based lock dependencies are not allowed | between any two lock-classes:: | | <hardirq-safe> -> <hardirq-unsafe> | <softirq-safe> -> <softirq-unsafe>
Lockdep marks br->hash_lock as softirq-safe, because it is sometimes taken in softirq context (for example br_fdb_update() which runs in NET_RX softirq), and when it's not in softirq context it blocks softirqs by using spin_lock_bh().
Lockdep marks ocelot->stats_lock as softirq-unsafe, because it never blocks softirqs from running, and it is never taken from softirq context. So it can always be interrupted by softirqs.
There is a call path through which a function that holds br->hash_lock:fdb_add_hw_addr() will call a function that acquires ocelot->stats_lock:ocelot_port_get_stats64(). This can be seen below:
ocelot_port_get_stats64+0x3c/0x1e0 felix_get_stats64+0x20/0x38 dsa_slave_get_stats64+0x3c/0x60 dev_get_stats+0x74/0x2c8 rtnl_fill_stats+0x4c/0x150 rtnl_fill_ifinfo+0x5cc/0x7b8 rtmsg_ifinfo_build_skb+0xe4/0x150 rtmsg_ifinfo+0x5c/0xb0 __dev_notify_flags+0x58/0x200 __dev_set_promiscuity+0xa0/0x1f8 dev_set_promiscuity+0x30/0x70 macsec_dev_change_rx_flags+0x68/0x88 __dev_set_promiscuity+0x1a8/0x1f8 __dev_set_rx_mode+0x74/0xa8 dev_uc_add+0x74/0xa0 fdb_add_hw_addr+0x68/0xd8 fdb_add_local+0xc4/0x110 br_fdb_add_local+0x54/0x88 br_add_if+0x338/0x4a0 br_add_slave+0x20/0x38 do_setlink+0x3a4/0xcb8 rtnl_newlink+0x758/0x9d0 rtnetlink_rcv_msg+0x2f0/0x550 netlink_rcv_skb+0x128/0x148 rtnetlink_rcv+0x24/0x38
the plain English explanation for it is:
The macsec0 bridge port is created without p->flags & BR_PROMISC, because it is what br_manage_promisc() decides for a VLAN filtering bridge with a single auto port.
As part of the br_add_if() procedure, br_fdb_add_local() is called for the MAC address of the device, and this results in a call to dev_uc_add() for macsec0 while the softirq-safe br->hash_lock is taken.
Because macsec0 does not have IFF_UNICAST_FLT, dev_uc_add() ends up calling __dev_set_promiscuity() for macsec0, which is propagated by its implementation, macsec_dev_change_rx_flags(), to the lower device: swp0. This triggers the call path:
dev_set_promiscuity(swp0)
-> rtmsg_ifinfo()
-> dev_get_stats()
-> ocelot_port_get_stats64()
with a calling context that lockdep doesn't like (br->hash_lock held).
Normally we don't see this, because even though many drivers that can be bridge ports don't support IFF_UNICAST_FLT, we need a driver that
(a) doesn't support IFF_UNICAST_FLT, *and*
(b) it forwards the IFF_PROMISC flag to another driver, and
(c) *that* driver implements ndo_get_stats64() using a softirq-unsafe spinlock.
Condition (b) is necessary because the first __dev_set_rx_mode() calls __dev_set_promiscuity() with "bool notify=false", and thus, the rtmsg_ifinfo() code path won't be entered.
The same criteria also hold true for DSA switches which don't report IFF_UNICAST_FLT. When the DSA master uses a spin_lock() in its ndo_get_stats64() method, the same lockdep splat can be seen.
I think the deadlock possibility is real, even though I didn't reproduce it, and I'm thinking of the following situation to support that claim:
fdb_add_hw_addr() runs on a CPU A, in a context with softirqs locally disabled and br->hash_lock held, and may end up attempting to acquire ocelot->stats_lock.
In parallel, ocelot->stats_lock is currently held by a thread B (say, ocelot_check_stats_work()), which is interrupted while holding it by a softirq which attempts to lock br->hash_lock.
Thread B cannot make progress because br->hash_lock is held by A. Whereas thread A cannot make progress because ocelot->stats_lock is held by B.
When taking the issue at face value, the bridge can avoid that problem by simply making the ports promiscuous from a code path with a saner calling context (br->hash_lock not held). A bridge port without IFF_UNICAST_FLT is going to become promiscuous as soon as we call dev_uc_add() on it (which we do unconditionally), so why not be preemptive and make it promiscuous right from the beginning, so as to not be taken by surprise.
With this, we've broken the links between code that holds br->hash_lock or br->lock and code that calls into the ndo_change_rx_flags() or ndo_get_stats64() ops of the bridge port.
--- net/bridge/br_if.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/bridge/br_if.c +3 -2
@@ -166,8 +166,9 @@ void br_manage_promisc(struct net_bridge *br)* This lets us disable promiscuous mode and write * this config to hw. */ -if (br->auto_cnt ==0 || - (br->auto_cnt ==1 &&br_auto_port (p))) +if ((p->dev->priv_flags &IFF_UNICAST_FLT ) && + (br->auto_cnt ==0 || + (br->auto_cnt ==1 &&br_auto_port (p))))br_port_clear_promisc (p);else br_port_set_promisc (p);
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 500/591 net: dsa: tag_sja1105: fix source port decoding in vlan_filtering=0 bridge mode
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit a398b9ea0c3b791b7a0f4c6029a62cf628f97f22 ]
There was a regression introduced by the blamed commit, where pinging to a VLAN-unaware bridge would fail with the repeated message "Couldn't decode source port" coming from the tagging protocol driver.
When receiving packets with a bridge_vid as determined by dsa_tag_8021q_bridge_join(), dsa_8021q_rcv() will decode:
- source_port = 0 (which isn't really valid, more like "don't know")
- switch_id = 0 (which isn't really valid, more like "don't know")
- vbid = value in range 1-7
Since the blamed patch has reversed the order of the checks, we are now going to believe that source_port != -1 and switch_id != -1, so they're valid, but they aren't.
The minimal solution to the problem is to only populate source_port and switch_id with what dsa_8021q_rcv() came up with, if the vbid is zero, i.e. the source port information is trustworthy.
--- net/dsa/tag_sja1105.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/dsa/tag_sja1105.c +6 -3
@@ -568,11 +568,14 @@ static struct sk_buff *sja1105_rcv(struct sk_buff *skb,* if available. This allows us to not overwrite a valid source * port and switch ID with zeroes when receiving link-local * frames from a VLAN-unaware bridged port (non-zero vbid) or a -* VLAN-aware bridged port (non-zero vid). +* VLAN-aware bridged port (non-zero vid). Furthermore, the +* tag_8021q source port information is only of trust when the +* vbid is 0 (precise port). Otherwise, tmp_source_port and +* tmp_switch_id will be zeroes. */ -if (source_port ==-1 ) +if (vbid ==0 && source_port ==-1 ) source_port = tmp_source_port; -if (switch_id ==-1 ) +if (vbid ==0 && switch_id ==-1 ) switch_id = tmp_switch_id; }else if (source_port ==-1 && switch_id ==-1 ) {/* Packets with no source information have no chance of
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 501/591 net: fix net_dev_start_xmit trace event vs skb_transport_offset()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit f88fcb1d7d961b4b402d675109726f94db87571c ]
After blamed commit, we must be more careful about using skb_transport_offset(), as reminded us by syzbot:
WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 skb_transport_offset include/linux/skbuff.h:2977 [inline] WARNING: CPU: 0 PID: 10 at include/linux/skbuff.h:2868 perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14 Modules linked in: CPU: 0 PID: 10 Comm: kworker/u4:1 Not tainted 6.1.30-syzkaller #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/27/2023 Workqueue: bat_events batadv_iv_send_outstanding_bat_ogm_packet RIP: 0010:skb_transport_header include/linux/skbuff.h:2868 [inline] RIP: 0010:skb_transport_offset include/linux/skbuff.h:2977 [inline] RIP: 0010:perf_trace_net_dev_start_xmit+0x89a/0xce0 include/trace/events/net.h:14 Code: 8b 04 25 28 00 00 00 48 3b 84 24 c0 00 00 00 0f 85 4e 04 00 00 48 8d 65 d8 5b 41 5c 41 5d 41 5e 41 5f 5d c3 cc e8 56 22 01 fd <0f> 0b e9 f6 fc ff ff 89 f9 80 e1 07 80 c1 03 38 c1 0f 8c 86 f9 ff RSP: 0018:ffffc900002bf700 EFLAGS: 00010293 RAX: ffffffff8485d8ca RBX: 000000000000ffff RCX: ffff888100914280 RDX: 0000000000000000 RSI: 000000000000ffff RDI: 000000000000ffff RBP: ffffc900002bf818 R08: ffffffff8485d5b6 R09: fffffbfff0f8fb5e R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff110217d8f67 R13: ffff88810bec7b3a R14: dffffc0000000000 R15: dffffc0000000000 FS: 0000000000000000(0000) GS:ffff8881f6a00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f96cf6d52f0 CR3: 000000012224c000 CR4: 0000000000350ef0 Call Trace: <TASK> [<ffffffff84715e35>] trace_net_dev_start_xmit include/trace/events/net.h:14 [inline] [<ffffffff84715e35>] xmit_one net/core/dev.c:3643 [inline] [<ffffffff84715e35>] dev_hard_start_xmit+0x705/0x980 net/core/dev.c:3660 [<ffffffff8471a232>] __dev_queue_xmit+0x16b2/0x3370 net/core/dev.c:4324 [<ffffffff85416493>] dev_queue_xmit include/linux/netdevice.h:3030 [inline] [<ffffffff85416493>] batadv_send_skb_packet+0x3f3/0x680 net/batman-adv/send.c:108 [<ffffffff85416744>] batadv_send_broadcast_skb+0x24/0x30 net/batman-adv/send.c:127 [<ffffffff853bc52a>] batadv_iv_ogm_send_to_if net/batman-adv/bat_iv_ogm.c:393 [inline] [<ffffffff853bc52a>] batadv_iv_ogm_emit net/batman-adv/bat_iv_ogm.c:421 [inline] [<ffffffff853bc52a>] batadv_iv_send_outstanding_bat_ogm_packet+0x69a/0x840 net/batman-adv/bat_iv_ogm.c:1701 [<ffffffff8151023c>] process_one_work+0x8ac/0x1170 kernel/workqueue.c:2289 [<ffffffff81511938>] worker_thread+0xaa8/0x12d0 kernel/workqueue.c:2436
--- include/trace/events/net.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/trace/events/net.h +2 -1
@@ -51,7 +51,8 @@ TRACE_EVENT(net_dev_start_xmit, __entry->network_offset =skb_network_offset (skb); __entry->transport_offset_valid =skb_transport_header_was_set (skb); - __entry->transport_offset =skb_transport_offset (skb); + __entry->transport_offset =skb_transport_header_was_set (skb) ? +skb_transport_offset (skb) :0 ; __entry->tx_flags =skb_shinfo (skb)->tx_flags; __entry->gso_size =skb_shinfo (skb)->gso_size; __entry->gso_segs =skb_shinfo (skb)->gso_segs;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 502/591 tcp: annotate data races in __tcp_oow_rate_limited()
In reply to Greg Kroah-HartmanFrom: Eric Dumazet <[email protected]>
[ Upstream commit 998127cdb4699b9d470a9348ffe9f1154346be5f ]
request sockets are lockless, __tcp_oow_rate_limited() could be called on the same object from different cpus. This is harmless.
Add READ_ONCE()/WRITE_ONCE() annotations to avoid a KCSAN report.
--- net/ipv4/tcp_input.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/ipv4/tcp_input.c +9 -3
@@ -3590,8 +3590,11 @@ static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32static bool __tcp_oow_rate_limited (struct net *net,int mib_idx,u32 *last_oow_ack_time) { -if (*last_oow_ack_time) { -s32 elapsed = (s32)(tcp_jiffies32 - *last_oow_ack_time); +/* Paired with the WRITE_ONCE() in this function. */ +u32 val =READ_ONCE (*last_oow_ack_time); + +if (val) { +s32 elapsed = (s32)(tcp_jiffies32 - val);if (0 <= elapsed && elapsed <READ_ONCE (net->ipv4.sysctl_tcp_invalid_ratelimit)) {
@@ -3600,7 +3603,10 @@ static bool __tcp_oow_rate_limited(struct net *net, int mib_idx, } } - *last_oow_ack_time = tcp_jiffies32; +/* Paired with the prior READ_ONCE() and with itself, +* as we might be lockless. +*/ +WRITE_ONCE (*last_oow_ack_time, tcp_jiffies32);return false;/* not rate-limited: go ahead, send dupack now! */ }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 503/591 bpf, btf: Warn but return no error for NULL btf from __register_btf_kfunc_id_set()
In reply to Greg Kroah-HartmanFrom: SeongJae Park <[email protected]>
[ Upstream commit 3de4d22cc9ac7c9f38e10edcf54f9a8891a9c2aa ]
__register_btf_kfunc_id_set() assumes .BTF to be part of the module's .ko file if CONFIG_DEBUG_INFO_BTF is enabled. If that's not the case, the function prints an error message and return an error. As a result, such modules cannot be loaded.
However, the section could be stripped out during a build process. It would be better to let the modules loaded, because their basic functionalities have no problem [0], though the BTF functionalities will not be supported. Make the function to lower the level of the message from error to warn, and return no error.
[0] https://lore.kernel.org/bpf/[email protected]
--- kernel/bpf/btf.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/bpf/btf.c +2 -4
@@ -7469,10 +7469,8 @@ int register_btf_kfunc_id_set(enum bpf_prog_type prog_type,pr_err ("missing vmlinux BTF, cannot register kfuncs\n" );return -ENOENT ; } -if (kset->owner &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF_MODULES )) { -pr_err ("missing module BTF, cannot register kfuncs\n" ); -return -ENOENT ; - } +if (kset->owner &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF_MODULES )) +pr_warn ("missing module BTF, cannot register kfuncs\n" );return 0 ; }if (IS_ERR (btf))
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 504/591 xsk: Honor SO_BINDTODEVICE on bind
In reply to Greg Kroah-HartmanFrom: Ilya Maximets <[email protected]>
[ Upstream commit f7306acec9aae9893d15e745c8791124d42ab10a ]
Initial creation of an AF_XDP socket requires CAP_NET_RAW capability. A privileged process might create the socket and pass it to a non-privileged process for later use. However, that process will be able to bind the socket to any network interface. Even though it will not be able to receive any traffic without modification of the BPF map, the situation is not ideal.
Sockets already have a mechanism that can be used to restrict what interface they can be attached to. That is SO_BINDTODEVICE.
To change the SO_BINDTODEVICE binding the process will need CAP_NET_RAW.
Make xsk_bind() honor the SO_BINDTODEVICE in order to allow safer workflow when non-privileged process is using AF_XDP.
The intended workflow is following:
1. First process creates a bare socket with socket(AF_XDP, ...).
2. First process loads the XSK program to the interface.
3. First process adds the socket fd to a BPF map.
4. First process ties socket fd to a particular interface using SO_BINDTODEVICE.
5. First process sends socket fd to a second process.
6. Second process allocates UMEM.
7. Second process binds socket to the interface with bind(...).
8. Second process sends/receives the traffic.
All the steps above are possible today if the first process is privileged and the second one has sufficient RLIMIT_MEMLOCK and no capabilities. However, the second process will be able to bind the socket to any interface it wants on step 7 and send traffic from it. With the proposed change, the second process will be able to bind the socket only to a specific interface chosen by the first process at step 4.
--- Documentation/networking/af_xdp.rst | 9 +++++++++ net/xdp/xsk.c | 5 +++++ 2 files changed, 14 insertions(+)
Documentation/networking/af_xdp.rst +9 -0
@@ -433,6 +433,15 @@ start N bytes into the buffer leaving the first N bytes for the application to use. The final option is the flags field, but it will be dealt with in separate sections for each UMEM flag. +SO_BINDTODEVICE setsockopt +-------------------------- + +This is a generic SOL_SOCKET option that can be used to tie AF_XDP +socket to a particular network interface. It is useful when a socket +is created by a privileged process and passed to a non-privileged one. +Once the option is set, kernel will refuse attempts to bind that socket +to a different interface. Updating the value requires CAP_NET_RAW. + XDP_STATISTICS getsockopt -------------------------
net/xdp/xsk.c +5 -0
@@ -886,6 +886,7 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)struct sock *sk = sock->sk;struct xdp_sock *xs =xdp_sk (sk);struct net_device *dev; +int bound_dev_if;u32 flags, qid;int err =0 ;
@@ -899,6 +900,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) XDP_USE_NEED_WAKEUP))return -EINVAL ; + bound_dev_if =READ_ONCE (sk->sk_bound_dev_if); +if (bound_dev_if && bound_dev_if != sxdp->sxdp_ifindex) +return -EINVAL ; +rtnl_lock ();mutex_lock (&xs->mutex);if (xs->state !=XSK_READY ) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 505/591 net/sched: act_pedit: Add size check for TCA_PEDIT_PARMS_EX
In reply to Greg Kroah-HartmanFrom: Lin Ma <[email protected]>
[ Upstream commit 30c45b5361d39b4b793780ffac5538090b9e2eb1 ]
The attribute TCA_PEDIT_PARMS_EX is not be included in pedit_policy and one malicious user could fake a TCA_PEDIT_PARMS_EX whose length is smaller than the intended sizeof(struct tc_pedit). Hence, the dereference in tcf_pedit_init() could access dirty heap data.
static int tcf_pedit_init(...)
{
// ...
pattr = tb[TCA_PEDIT_PARMS]; // TCA_PEDIT_PARMS is included if (!pattr)
pattr = tb[TCA_PEDIT_PARMS_EX]; // but this is not
// ... parm = nla_data(pattr);
index = parm->index; // parm is able to be smaller than 4 bytes
// and this dereference gets dirty skb_buff
// data created in netlink_sendmsg
}This commit adds TCA_PEDIT_PARMS_EX length in pedit_policy which avoid the above case, just like the TCA_PEDIT_PARMS.
--- net/sched/act_pedit.c | 1 + 1 file changed, 1 insertion(+)
net/sched/act_pedit.c +1 -0
@@ -28,6 +28,7 @@ static struct tc_action_ops act_pedit_opstatic const struct nla_policy pedit_policy[TCA_PEDIT_MAX +1 ] = { [TCA_PEDIT_PARMS ] = { .len =sizeof (struct tc_pedit ) }, + [TCA_PEDIT_PARMS_EX ] = { .len =sizeof (struct tc_pedit ) }, [TCA_PEDIT_KEYS_EX ] = { .type =NLA_NESTED }, };
Greg Kroah-Hartman
maintainerPATCH 506/591 fanotify: disallow mount/sb marks on kernel internal pseudo fs
In reply to Greg Kroah-HartmanFrom: Amir Goldstein <[email protected]>
[ Upstream commit 69562eb0bd3e6bb8e522a7b254334e0fb30dff0c ]
Hopefully, nobody is trying to abuse mount/sb marks for watching all anonymous pipes/inodes.
I cannot think of a good reason to allow this - it looks like an oversight that dated back to the original fanotify API.
Message-Id: <[email protected]>
--- fs/notify/fanotify/fanotify_user.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/notify/fanotify/fanotify_user.c +14 -0
@@ -1574,6 +1574,20 @@ static int fanotify_events_supported(struct fsnotify_group *group, path->mnt->mnt_sb->s_type->fs_flags & FS_DISALLOW_NOTIFY_PERM)return -EINVAL ; +/* +* mount and sb marks are not allowed on kernel internal pseudo fs, +* like pipe_mnt, because that would subscribe to events on all the +* anonynous pipes in the system. +* +* SB_NOUSER covers all of the internal pseudo fs whose objects are not +* exposed to user's mount namespace, but there are other SB_KERNMOUNT +* fs, like nsfs, debugfs, for which the value of allowing sb and mount +* mark is questionable. For now we leave them alone. +*/ +if (mark_type !=FAN_MARK_INODE && + path->mnt->mnt_sb->s_flags &SB_NOUSER ) +return -EINVAL ; +/* * We shouldn't have allowed setting dirent events and the directory * flags FAN_ONDIR and FAN_EVENT_ON_CHILD in mask of non-dir inode,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 507/591 riscv: move memblock_allow_resize() after linear mapping is ready
In reply to Greg Kroah-HartmanFrom: Woody Zhang <[email protected]>
[ Upstream commit 85fadc0d04119c2fe4a20287767ab904c6d21ba1 ]
The initial memblock metadata is accessed from kernel image mapping. The regions arrays need to "reallocated" from memblock and accessed through linear mapping to cover more memblock regions. So the resizing should not be allowed until linear mapping is ready. Note that there are memblock allocations when building linear mapping.
This patch is similar to 24cc61d8cb5a ("arm64: memblock: don't permit memblock resizing until linear mapping is up").
In following log, many memblock regions are reserved before create_linear_mapping_page_table(). And then it triggered reallocation of memblock.reserved.regions and memcpy the old array in kernel image mapping to the new array in linear mapping which caused a page fault.
[ 0.000000] memblock_reserve: [0x00000000bf01f000-0x00000000bf01ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf021000-0x00000000bf021fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf023000-0x00000000bf023fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf025000-0x00000000bf025fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf027000-0x00000000bf027fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf029000-0x00000000bf029fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02b000-0x00000000bf02bfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02d000-0x00000000bf02dfff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf02f000-0x00000000bf02ffff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] memblock_reserve: [0x00000000bf030000-0x00000000bf030fff] early_init_fdt_scan_reserved_mem+0x28c/0x2c6 [ 0.000000] OF: reserved mem: 0x0000000080000000..0x000000008007ffff (512 KiB) map non-reusable mmode_resv0@80000000 [ 0.000000] memblock_reserve: [0x00000000bf000000-0x00000000bf001fed] paging_init+0x19a/0x5ae [ 0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c [ 0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] memblock: reserved is doubled to 256 at [0x000000017fffd000-0x000000017fffe7ff] [ 0.000000] Unable to handle kernel paging request at virtual address ff600000ffffd000 [ 0.000000] Oops [#1] [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 6.4.0-rc1-00011-g99a670b2069c #66 [ 0.000000] Hardware name: riscv-virtio,qemu (DT) [ 0.000000] epc : __memcpy+0x60/0xf8 [ 0.000000] ra : memblock_double_array+0x192/0x248 [ 0.000000] epc : ffffffff8081d214 ra : ffffffff80a3dfc0 sp : ffffffff81403bd0 [ 0.000000] gp : ffffffff814fbb38 tp : ffffffff8140dac0 t0 : 0000000001600000 [ 0.000000] t1 : 0000000000000000 t2 : 000000008f001000 s0 : ffffffff81403c60 [ 0.000000] s1 : ffffffff80c0bc98 a0 : ff600000ffffd000 a1 : ffffffff80c0bcd8 [ 0.000000] a2 : 0000000000000c00 a3 : ffffffff80c0c8d8 a4 : 0000000080000000 [ 0.000000] a5 : 0000000000080000 a6 : 0000000000000000 a7 : 0000000080200000 [ 0.000000] s2 : ff600000ffffd000 s3 : 0000000000002000 s4 : 0000000000000c00 [ 0.000000] s5 : ffffffff80c0bc60 s6 : ffffffff80c0bcc8 s7 : 0000000000000000 [ 0.000000] s8 : ffffffff814fd0a8 s9 : 000000017fffe7ff s10: 0000000000000000 [ 0.000000] s11: 0000000000001000 t3 : 0000000000001000 t4 : 0000000000000000 [ 0.000000] t5 : 000000008f003000 t6 : ff600000ffffd000 [ 0.000000] status: 0000000200000100 badaddr: ff600000ffffd000 cause: 000000000000000f [ 0.000000] [<ffffffff8081d214>] __memcpy+0x60/0xf8 [ 0.000000] [<ffffffff80a3e1a2>] memblock_add_range.isra.14+0x12c/0x162 [ 0.000000] [<ffffffff80a3e36a>] memblock_reserve+0x6e/0x8c [ 0.000000] [<ffffffff80a123fc>] memblock_alloc_range_nid+0xb8/0x128 [ 0.000000] [<ffffffff80a1256a>] memblock_phys_alloc_range+0x5e/0x6a [ 0.000000] [<ffffffff80a04732>] alloc_pmd_fixmap+0x14/0x1c [ 0.000000] [<ffffffff80a0475a>] alloc_p4d_fixmap+0xc/0x14 [ 0.000000] [<ffffffff80a04a36>] create_pgd_mapping+0x98/0x17c [ 0.000000] [<ffffffff80a04e9e>] create_linear_mapping_range.constprop.10+0xe4/0x112 [ 0.000000] [<ffffffff80a05bb8>] paging_init+0x3ec/0x5ae [ 0.000000] [<ffffffff80a03354>] setup_arch+0xb2/0x576 [ 0.000000] [<ffffffff80a00726>] start_kernel+0x72/0x57e [ 0.000000] Code: b303 0285 b383 0305 be03 0385 be83 0405 bf03 0485 (b023) 00ef [ 0.000000] ---[ end trace 0000000000000000 ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]---
--- arch/riscv/mm/init.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/riscv/mm/init.c +3 -1
@@ -255,7 +255,6 @@ static void __init setup_bootmem(void)dma_contiguous_reserve (dma32_phys_limit);if (IS_ENABLED (CONFIG_64BIT ))hugetlb_cma_reserve (PUD_SHIFT -PAGE_SHIFT ); -memblock_allow_resize (); }#ifdef CONFIG_MMU
@@ -1211,6 +1210,9 @@ void __init paging_init(void) {setup_bootmem ();setup_vm_final (); + +/* Depend on that Linear Mapping is ready */ +memblock_allow_resize (); }void __init misc_mem_init (void )
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 508/591 pptp: Fix fib lookup calls.
In reply to Greg Kroah-HartmanFrom: Guillaume Nault <[email protected]>
[ Upstream commit 84bef5b6037c15180ef88ac4216dc621d16df1a6 ]
PPTP uses pppox sockets (struct pppox_sock). These sockets don't embed an inet_sock structure, so it's invalid to call inet_sk() on them.
Therefore, the ip_route_output_ports() call in pptp_connect() has two problems:
* The tos variable is set with RT_CONN_FLAGS(sk), which calls inet_sk() on the pppox socket.
* ip_route_output_ports() tries to retrieve routing flags using inet_sk_flowi_flags(), which is also going to call inet_sk() on the pppox socket.
While PPTP doesn't use inet sockets, it's actually really layered on top of IP and therefore needs a proper way to do fib lookups. So let's define pptp_route_output() to get a struct rtable from a pptp socket. Let's also replace the ip_route_output_ports() call of pptp_xmit() for consistency.
In practice, this means that:
* pptp_connect() sets ->flowi4_tos and ->flowi4_flags to zero instead of using bits of unrelated struct pppox_sock fields.
* pptp_xmit() now respects ->sk_mark and ->sk_uid.
* pptp_xmit() now calls the security_sk_classify_flow() security
hook, thus allowing to set ->flowic_secid.
* pptp_xmit() now passes the pppox socket to xfrm_lookup_route().
Found by code inspection.
--- drivers/net/ppp/pptp.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/ppp/pptp.c +20 -11
@@ -24,6 +24,7 @@#include <linux/in.h> #include <linux/ip.h> #include <linux/rcupdate.h> +#include <linux/security.h> #include <linux/spinlock.h> #include <net/sock.h>
@@ -128,6 +129,23 @@ static void del_chan(struct pppox_sock *sock)spin_unlock (&chan_lock); } +static struct rtable *pptp_route_output (struct pppox_sock *po, +struct flowi4 *fl4) +{ +struct sock *sk = &po->sk; +struct net *net; + + net =sock_net (sk); +flowi4_init_output (fl4, sk->sk_bound_dev_if, sk->sk_mark,0 , +RT_SCOPE_UNIVERSE ,IPPROTO_GRE ,0 , + po->proto.pptp.dst_addr.sin_addr.s_addr, + po->proto.pptp.src_addr.sin_addr.s_addr, +0 ,0 ,sock_net_uid (net, sk)); +security_sk_classify_flow (sk,flowi4_to_flowi_common (fl4)); + +return ip_route_output_flow (net, fl4, sk); +} +static int pptp_xmit (struct ppp_channel *chan,struct sk_buff *skb) {struct sock *sk = (struct sock *) chan->private;
@@ -151,11 +169,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)if (sk_pppox (po)->sk_state &PPPOX_DEAD ) goto tx_error; - rt =ip_route_output_ports (net, &fl4,NULL , - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 ,IPPROTO_GRE , -RT_TOS (0 ), sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) goto tx_error;
@@ -438,12 +452,7 @@ static int pptp_connect(struct socket *sock, struct sockaddr *uservaddr, po->chan.private = sk; po->chan.ops = &pptp_chan_ops; - rt =ip_route_output_ports (sock_net (sk), &fl4, sk, - opt->dst_addr.sin_addr.s_addr, - opt->src_addr.sin_addr.s_addr, -0 ,0 , -IPPROTO_GRE ,RT_CONN_FLAGS (sk), - sk->sk_bound_dev_if); + rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) { error = -EHOSTUNREACH ; goto end;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 509/591 net: dsa: tag_sja1105: fix MAC DA patching from meta frames
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit 1dcf6efd5f0c1f4496b3ef7ec5a7db104a53b38c ]
The SJA1105 manual says that at offset 4 into the meta frame payload we have "MAC destination byte 2" and at offset 5 we have "MAC destination byte 1". These are counted from the LSB, so byte 1 is h_dest[ETH_HLEN-2] aka h_dest[4] and byte 2 is h_dest[ETH_HLEN-3] aka h_dest[3].
The sja1105_meta_unpack() function decodes these the other way around, so a frame with MAC DA 01:80:c2:11:22:33 is received by the network stack as having 01:80:c2:22:11:33.
--- net/dsa/tag_sja1105.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/dsa/tag_sja1105.c +2 -2
@@ -113,8 +113,8 @@ static void sja1105_meta_unpack(const struct sk_buff *skb,* a unified unpacking command for both device series. */ packing (buf, &meta->tstamp,31 ,0 ,4 ,UNPACK ,0 ); -packing (buf +4 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 ); -packing (buf +5 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +4 , &meta->dmac_byte_3,7 ,0 ,1 ,UNPACK ,0 ); +packing (buf +5 , &meta->dmac_byte_4,7 ,0 ,1 ,UNPACK ,0 );packing (buf +6 , &meta->source_port,7 ,0 ,1 ,UNPACK ,0 );packing (buf +7 , &meta->switch_id,7 ,0 ,1 ,UNPACK ,0 ); }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 510/591 net: dsa: sja1105: always enable the send_meta options
In reply to Greg Kroah-HartmanFrom: Vladimir Oltean <[email protected]>
[ Upstream commit a372d66af48506d9f7aaae2a474cd18f14d98cb8 ]
incl_srcpt has the limitation, mentioned in commit b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"), that frames with a MAC DA of 01:80:c2:xx:yy:zz will be received as 01:80:c2:00:00:zz unless PTP RX timestamping is enabled.
The incl_srcpt option was initially unconditionally enabled, then that changed with commit 42824463d38d ("net: dsa: sja1105: Limit use of incl_srcpt to bridge+vlan mode"), then again with b4638af8885a ("net:
dsa: sja1105: always enable the INCL_SRCPT option"). Bottom line is that it now needs to be always enabled, otherwise the driver does not have a reliable source of information regarding source_port and switch_id for link-local traffic (tag_8021q VLANs may be imprecise since now they identify an entire bridging domain when ports are not standalone).
If we accept that PTP RX timestamping (and therefore, meta frame generation) is always enabled in hardware, then that limitation could be avoided and packets with any MAC DA can be properly received, because meta frames do contain the original bytes from the MAC DA of their associated link-local packet.
This change enables meta frame generation unconditionally, which also has the nice side effects of simplifying the switch control path (a switch reset is no longer required on hwtstamping settings change) and the tagger data path (it no longer needs to be informed whether to expect meta frames or not - it always does).
--- drivers/net/dsa/sja1105/sja1105.h | 2 +- drivers/net/dsa/sja1105/sja1105_main.c | 5 ++- drivers/net/dsa/sja1105/sja1105_ptp.c | 48 +++----------------------- include/linux/dsa/sja1105.h | 4 --- net/dsa/tag_sja1105.c | 45 ------------------------ 5 files changed, 7 insertions(+), 97 deletions(-)
drivers/net/dsa/sja1105/sja1105.h +1 -1
@@ -250,6 +250,7 @@ struct sja1105_private {unsigned long ucast_egress_floods;unsigned long bcast_egress_floods;unsigned long hwts_tx_en; +unsigned long hwts_rx_en;const struct sja1105_info *info;size_t max_xfer_len;struct spi_device *spidev;
@@ -287,7 +288,6 @@ struct sja1105_spi_message {/* From sja1105_main.c */ enum sja1105_reset_reason {SJA1105_VLAN_FILTERING =0 , -SJA1105_RX_HWTSTAMPING ,SJA1105_AGEING_TIME ,SJA1105_SCHEDULING ,SJA1105_BEST_EFFORT_POLICING ,
drivers/net/dsa/sja1105/sja1105_main.c +2 -3
@@ -867,11 +867,11 @@ static int sja1105_init_general_params(struct sja1105_private *priv) .mac_fltres1 = SJA1105_LINKLOCAL_FILTER_A, .mac_flt1 = SJA1105_LINKLOCAL_FILTER_A_MASK, .incl_srcpt1 = true, - .send_meta1 = false, + .send_meta1 = true, .mac_fltres0 = SJA1105_LINKLOCAL_FILTER_B, .mac_flt0 = SJA1105_LINKLOCAL_FILTER_B_MASK, .incl_srcpt0 = true, - .send_meta0 = false, + .send_meta0 = true,/* Default to an invalid value */ .mirr_port = priv->ds->num_ports,/* No TTEthernet */
@@ -2215,7 +2215,6 @@ static int sja1105_reload_cbs(struct sja1105_private *priv)static const char *const sja1105_reset_reasons[] = { [SJA1105_VLAN_FILTERING ] ="VLAN filtering" , - [SJA1105_RX_HWTSTAMPING ] ="RX timestamping" , [SJA1105_AGEING_TIME ] ="Ageing time" , [SJA1105_SCHEDULING ] ="Time-aware scheduling" , [SJA1105_BEST_EFFORT_POLICING ] ="Best-effort policing" ,
drivers/net/dsa/sja1105/sja1105_ptp.c +4 -44
90 lines not on this page · raw message
include/linux/dsa/sja1105.h +0 -4
@@ -48,13 +48,9 @@ struct sja1105_deferred_xmit_work {/* Global tagger data */ struct sja1105_tagger_data { -/* Tagger to switch */ void (*xmit_work_fn)(struct kthread_work *work);void (*meta_tstamp_handler)(struct dsa_switch *ds,int port,u8 ts_id,enum sja1110_meta_tstamp dir,u64 tstamp); -/* Switch to tagger */ -bool (*rxtstamp_get_state)(struct dsa_switch *ds); -void (*rxtstamp_set_state)(struct dsa_switch *ds,bool on); };struct sja1105_skb_cb {
net/dsa/tag_sja1105.c +0 -45
89 lines not on this page · raw message
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 511/591 octeontx-af: fix hardware timestamp configuration
In reply to Greg Kroah-HartmanFrom: Hariprasad Kelam <[email protected]>
[ Upstream commit 14bb236b29922c4f57d8c05bfdbcb82677f917c9 ]
MAC block on CN10K (RPM) supports hardware timestamp configuration. The previous patch which added timestamp configuration support has a bug. Though the netdev driver requests to disable timestamp configuration, the driver is always enabling it.
This patch fixes the same.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +1 -1
@@ -751,7 +751,7 @@ static int rvu_cgx_ptp_rx_cfg(struct rvu *rvu, u16 pcifunc, bool enable) cgxd =rvu_cgx_pdata (cgx_id, rvu); mac_ops =get_mac_ops (cgxd); - mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, true); + mac_ops->mac_enadis_ptp_config (cgxd, lmac_id, enable);/* If PTP is enabled then inform NPC that packets to be * parsed by this PF will have their data shifted by 8 bytes * and if PTP is disabled then no shift is required
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 512/591 afs: Fix accidental truncation when storing data
In reply to Greg Kroah-HartmanFrom: David Howells <[email protected]>
[ Upstream commit 03275585cabd0240944f19f33d7584a1b099a3a8 ]
When an AFS FS.StoreData RPC call is made, amongst other things it is given the resultant file size to be. On the server, this is processed by truncating the file to new size and then writing the data.
Now, kafs has a lock (vnode->io_lock) that serves to serialise operations against a specific vnode (ie. inode), but the parameters for the op are set before the lock is taken. This allows two writebacks (say sync and kswapd) to race - and if writes are ongoing the writeback for a later write could occur before the writeback for an earlier one if the latter gets interrupted.
Note that afs_writepages() cannot take i_mutex and only takes a shared lock on vnode->validate_lock.
Also note that the server does the truncation and the write inside a lock, so there's no problem at that end.
Fix this by moving the calculation for the proposed new i_size inside the vnode->io_lock. Also reset the iterator (which we might have read from) and update the mtime setting there.
--- fs/afs/write.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/afs/write.c +5 -3
@@ -381,17 +381,19 @@ static int afs_store_data(struct afs_vnode *vnode, struct iov_iter *iter, loff_tafs_op_set_vnode (op,0 , vnode); op->file[0 ].dv_delta =1 ; op->file[0 ].modification = true; - op->store.write_iter = iter; op->store.pos = pos; op->store.size = size; - op->store.i_size =max (pos + size, vnode->netfs.remote_i_size); op->store.laundering = laundering; - op->mtime = vnode->netfs.inode.i_mtime; op->flags |=AFS_OPERATION_UNINTR ; op->ops = &afs_store_data_operation; try_next_key:afs_begin_vnode_operation (op); + + op->store.write_iter = iter; + op->store.i_size =max (pos + size, vnode->netfs.remote_i_size); + op->mtime = vnode->netfs.inode.i_mtime; +afs_wait_for_operation (op);switch (op->error) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 513/591 s390/qeth: Fix vipa deletion
In reply to Greg Kroah-HartmanFrom: Thorsten Winkler <[email protected]>
[ Upstream commit 80de809bd35e2a8999edf9f5aaa2d8de18921f11 ]
Change boolean parameter of function "qeth_l3_vipa_store" inside the "qeth_l3_dev_vipa_del4_store" function from "true" to "false" because "true" is used for adding a virtual ip address and "false" for deleting.
--- drivers/s390/net/qeth_l3_sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_l3_sys.c +1 -1
@@ -652,7 +652,7 @@ static QETH_DEVICE_ATTR(vipa_add4, add4, 0644,static ssize_t qeth_l3_dev_vipa_del4_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { -return qeth_l3_vipa_store (dev, buf, true, count,QETH_PROT_IPV4 ); +return qeth_l3_vipa_store (dev, buf, false, count,QETH_PROT_IPV4 ); } static QETH_DEVICE_ATTR(vipa_del4, del4, 0200, NULL,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 514/591 sh: dma: Fix DMA channel offset calculation
In reply to Greg Kroah-HartmanFrom: Artur Rojek <[email protected]>
[ Upstream commit e82e47584847129a20b8c9f4a1dcde09374fb0e0 ]
Various SoCs of the SH3, SH4 and SH4A family, which use this driver, feature a differing number of DMA channels, which can be distributed between up to two DMAC modules. The existing implementation fails to correctly accommodate for all those variations, resulting in wrong channel offset calculations and leading to kernel panics.
Rewrite dma_base_addr() in order to properly calculate channel offsets in a DMAC module. Fix dmaor_read_reg() and dmaor_write_reg(), so that the correct DMAC module base is selected for the DMAOR register.
--- arch/sh/drivers/dma/dma-sh.c | 37 +++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-)
arch/sh/drivers/dma/dma-sh.c +24 -13
@@ -18,6 +18,18 @@#include <cpu/dma-register.h> #include <cpu/dma.h> +/* +* Some of the SoCs feature two DMAC modules. In such a case, the channels are +* distributed equally among them. +*/ +#ifdef SH_DMAC_BASE1 +#define SH_DMAC_NR_MD_CH (CONFIG_NR_ONCHIP_DMA_CHANNELS / 2) +#else +#define SH_DMAC_NR_MD_CH CONFIG_NR_ONCHIP_DMA_CHANNELS +#endif + +#define SH_DMAC_CH_SZ 0x10 +/* * Define the default configuration for dual address memory-memory transfer. * The 0x400 value represents auto-request, external->external.
@@ -29,7 +41,7 @@ static unsigned long dma_find_base(unsigned int chan)unsigned long base =SH_DMAC_BASE0 ;#ifdef SH_DMAC_BASE1 -if (chan >=6 ) +if (chan >=SH_DMAC_NR_MD_CH ) base =SH_DMAC_BASE1 ;#endif
@@ -40,13 +52,13 @@ static unsigned long dma_base_addr(unsigned int chan) {unsigned long base =dma_find_base (chan); -/* Normalize offset calculation */ -if (chan >=9 ) - chan -=6 ; -if (chan >=4 ) - base +=0x10 ; + chan = (chan %SH_DMAC_NR_MD_CH ) *SH_DMAC_CH_SZ ; + +/* DMAOR is placed inside the channel register space. Step over it. */ +if (chan >=DMAOR ) + base +=SH_DMAC_CH_SZ ; -return base + (chan *0x10 ); +return base + chan; }#ifdef CONFIG_SH_DMA_IRQ_MULTI
@@ -250,12 +262,11 @@ static int sh_dmac_get_dma_residue(struct dma_channel *chan)#define NR_DMAOR 1#endif -/* -* DMAOR bases are broken out amongst channel groups. DMAOR0 manages -* channels 0 - 5, DMAOR1 6 - 11 (optional). -*/ -#define dmaor_read_reg (n) __raw_readw(dma_find_base((n)*6)) -#define dmaor_write_reg (n, data) __raw_writew(data, dma_find_base(n)*6) +#define dmaor_read_reg (n) __raw_readw(dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR) +#define dmaor_write_reg (n, data) __raw_writew(data, \ + dma_find_base((n) * \ + SH_DMAC_NR_MD_CH) + DMAOR)static inline int dmaor_reset (int no) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 515/591 apparmor: fix missing error check for rhashtable_insert_fast
In reply to Greg Kroah-HartmanFrom: Danila Chernetsov <[email protected]>
[ Upstream commit 000518bc5aef25d3f703592a0296d578c98b1517 ]
rhashtable_insert_fast() could return err value when memory allocation is failed. but unpack_profile() do not check values and this always returns success value. This patch just adds error check code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- security/apparmor/policy_unpack.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
security/apparmor/policy_unpack.c +7 -2
@@ -917,8 +917,13 @@ static struct aa_profile *unpack_profile(struct aa_ext *e, char **ns_name) goto fail; } -rhashtable_insert_fast (profile->data, &data->head, - profile->data->p); +if (rhashtable_insert_fast (profile->data, &data->head, + profile->data->p)) { +kfree_sensitive (data->key); +kfree_sensitive (data); + info ="failed to insert data to table" ; + goto fail; + } }if (!unpack_nameX (e,AA_STRUCTEND ,NULL )) {
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 516/591 i2c: xiic: Dont try to handle more interrupt events after error
In reply to Greg Kroah-HartmanFrom: Robert Hancock <[email protected]>
[ Upstream commit cb6e45c9a0ad9e0f8664fd06db0227d185dc76ab ]
In xiic_process, it is possible that error events such as arbitration lost or TX error can be raised in conjunction with other interrupt flags such as TX FIFO empty or bus not busy. Error events result in the controller being reset and the error returned to the calling request, but the function could potentially try to keep handling the other events, such as by writing more messages into the TX FIFO. Since the transaction has already failed, this is not helpful and will just cause issues.
This problem has been present ever since:
commit 7f9906bd7f72 ("i2c: xiic: Service all interrupts in isr")
which allowed non-error events to be handled after errors, but became more obvious after:
commit 743e227a8959 ("i2c: xiic: Defer xiic_wakeup() and __xiic_start_xfer() in xiic_process()")
which reworked the code to add a WARN_ON which triggers if both the xfer_more and wakeup_req flags were set, since this combination is not supposed to happen, but was occurring in this scenario.
Skip further interrupt handling after error flags are detected to avoid this problem.
--- drivers/i2c/busses/i2c-xiic.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/i2c/busses/i2c-xiic.c +2 -0
@@ -431,6 +431,8 @@ static irqreturn_t xiic_process(int irq, void *dev_id) wakeup_req =1 ; wakeup_code =STATE_ERROR ; } +/* don't try to handle other events */ + goto out; }if (pend &XIIC_INTR_RX_FULL_MASK ) {/* Receive register/FIFO is full */
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 517/591 dm: fix undue/missing spaces
In reply to Greg Kroah-HartmanFrom: Heinz Mauelshagen <[email protected]>
[ Upstream commit 43be9c743c2553519c2093d1798b542f28095a51 ]
Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
--- drivers/md/dm-ioctl.c | 4 ++-- drivers/md/dm-mpath.c | 2 +- drivers/md/dm-ps-service-time.c | 3 +-- drivers/md/dm-snap.c | 6 +++--- drivers/md/dm-table.c | 2 +- drivers/md/dm-uevent.h | 2 +- drivers/md/dm-writecache.c | 4 ++-- drivers/md/dm-zoned-metadata.c | 2 +- 8 files changed, 12 insertions(+), 13 deletions(-)
drivers/md/dm-ioctl.c +2 -2
@@ -1572,7 +1572,7 @@ static void retrieve_deps(struct dm_table *table,/* * Count the devices. */ -list_for_each (tmp,dm_table_get_devices (table)) +list_for_each (tmp,dm_table_get_devices (table)) count++;/*
@@ -1589,7 +1589,7 @@ static void retrieve_deps(struct dm_table *table,*/ deps->count = count; count =0 ; -list_for_each_entry (dd,dm_table_get_devices (table), list) +list_for_each_entry (dd,dm_table_get_devices (table), list) deps->dev[count++] =huge_encode_dev (dd->dm_dev->bdev->bd_dev); param->data_size = param->data_start + needed;
drivers/md/dm-mpath.c +1 -1
@@ -1086,7 +1086,7 @@ static int parse_hw_handler(struct dm_arg_set *as, struct multipath *m) goto fail; } j =sprintf (p,"%d" , hw_argc -1 ); -for (i =0 , p+=j+1 ; i <= hw_argc -2 ; i++, p+=j+1 ) +for (i =0 , p += j +1 ; i <= hw_argc -2 ; i++, p += j +1 ) j =sprintf (p,"%s" , as->argv[i]); }dm_consume_args (as, hw_argc -1 );
drivers/md/dm-ps-service-time.c +1 -2
@@ -127,8 +127,7 @@ static int st_add_path(struct path_selector *ps, struct dm_path *path,* The valid range: 0-<ST_MAX_RELATIVE_THROUGHPUT> * If not given, minimum value '1' is used. * If '0' is given, the path isn't selected while -* other paths having a positive value are -* available. +* other paths having a positive value are available. */ if (argc >2 ) { *error ="service-time ps: incorrect number of arguments" ;
drivers/md/dm-snap.c +3 -3
@@ -388,7 +388,7 @@ static struct origin *__lookup_origin(struct block_device *origin)struct origin *o; ol = &_origins[origin_hash (origin)]; - list_for_each_entry (o, ol, hash_list) +list_for_each_entry (o, ol, hash_list)if (bdev_equal (o->bdev, origin))return o;
@@ -407,7 +407,7 @@ static struct dm_origin *__lookup_dm_origin(struct block_device *origin)struct dm_origin *o; ol = &_dm_origins[origin_hash (origin)]; - list_for_each_entry (o, ol, hash_list) +list_for_each_entry (o, ol, hash_list)if (bdev_equal (o->dev->bdev, origin))return o;
@@ -2446,7 +2446,7 @@ static int __origin_write(struct list_head *snapshots, sector_t sector,chunk_t chunk;/* Do all the snapshots on this origin */ - list_for_each_entry (snap, snapshots, list) { +list_for_each_entry (snap, snapshots, list) {/* * Don't make new exceptions in a merging snapshot * because it has effectively been deleted
drivers/md/dm-table.c +1 -1
@@ -211,7 +211,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev) {struct dm_dev_internal *dd; - list_for_each_entry (dd, l, list) +list_for_each_entry (dd, l, list)if (dd->dm_dev->bdev->bd_dev == dev)return dd;
drivers/md/dm-uevent.h +1 -1
@@ -3,7 +3,7 @@* Device Mapper Uevent Support * * Copyright IBM Corporation, 2007 -* Author: Mike Anderson <[email protected]> +* Author: Mike Anderson <[email protected]> */ #ifndef DM_UEVENT_H #define DM_UEVENT_H
drivers/md/dm-writecache.c +2 -2
@@ -85,12 +85,12 @@ struct wc_entry {unsigned short wc_list_contiguous; bool write_in_progress#if BITS_PER_LONG ==64 - :1 + : 1#endif ; unsigned long index#if BITS_PER_LONG ==64 - :47 + : 47#endif ;unsigned long age;
drivers/md/dm-zoned-metadata.c +1 -1
@@ -1013,7 +1013,7 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_sb *dsb, } sb_block =le64_to_cpu (sb->sb_block); -if (sb_block != (u64 )dsb->zone->id << zmd->zone_nr_blocks_shift ) { +if (sb_block != (u64 )dsb->zone->id << zmd->zone_nr_blocks_shift) { dmz_dev_err(dev, "Invalid superblock position " "(is %llu expected %llu)", sb_block,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 518/591 dm: avoid split of quoted strings where possible
In reply to Greg Kroah-HartmanFrom: Heinz Mauelshagen <[email protected]>
[ Upstream commit 2e84fecf19e1694338deec8bf6c90ff84f8f31fb ]
Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
--- drivers/md/dm-crypt.c | 3 +-- drivers/md/dm-ioctl.c | 6 ++---- drivers/md/dm-log-userspace-transfer.c | 5 ++--- drivers/md/dm-log.c | 3 +-- drivers/md/dm-raid1.c | 7 +++---- drivers/md/dm-snap-persistent.c | 6 ++---- drivers/md/dm-snap-transient.c | 3 +-- drivers/md/dm-snap.c | 21 +++++++-------------- drivers/md/dm-stripe.c | 12 ++++-------- drivers/md/dm-table.c | 18 ++++++------------ drivers/md/dm-thin-metadata.c | 8 ++++---- drivers/md/dm-zoned-metadata.c | 12 ++++-------- 12 files changed, 37 insertions(+), 67 deletions(-)
drivers/md/dm-crypt.c +1 -2
@@ -733,8 +733,7 @@ static int crypt_iv_eboiv_ctr(struct crypt_config *cc, struct dm_target *ti, }if (crypto_skcipher_blocksize (any_tfm (cc)) != cc->iv_size) { - ti->error ="Block size of EBOIV cipher does " -"not match IV size of block cipher" ; + ti->error ="Block size of EBOIV cipher does not match IV size of block cipher" ;return -EINVAL ; }
drivers/md/dm-ioctl.c +2 -4
@@ -434,8 +434,7 @@ static struct mapped_device *dm_hash_rename(struct dm_ioctl *param, hc =__get_name_cell (new);if (hc) { -DMERR ("Unable to change %s on mapped device %s to one that " -"already exists: %s" , +DMERR ("Unable to change %s on mapped device %s to one that already exists: %s" , change_uuid ?"uuid" :"name" , param->name, new);dm_put (hc->md);
@@ -1822,8 +1821,7 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)if ((DM_VERSION_MAJOR != version[0 ]) || (DM_VERSION_MINOR < version[1 ])) { -DMERR ("ioctl interface mismatch: " -"kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)" , +DMERR ("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)" ,DM_VERSION_MAJOR ,DM_VERSION_MINOR ,DM_VERSION_PATCHLEVEL , version[0 ], version[1 ], version[2 ], cmd);
drivers/md/dm-log-userspace-transfer.c +2 -3
@@ -108,9 +108,8 @@ static int fill_pkg(struct cn_msg *msg, struct dm_ulog_request *tfr)if (pkg->error != -EAGAIN ) *(pkg->data_size) =0 ; }else if (tfr->data_size > *(pkg->data_size)) { -DMERR ("Insufficient space to receive package [%u] " -"(%u vs %zu)" , tfr->request_type, - tfr->data_size, *(pkg->data_size)); +DMERR ("Insufficient space to receive package [%u] (%u vs %zu)" , + tfr->request_type, tfr->data_size, *(pkg->data_size)); *(pkg->data_size) =0 ; pkg->error = -ENOSPC ;
drivers/md/dm-log.c +1 -2
@@ -382,8 +382,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,else if (!strcmp (argv[1 ],"nosync" )) sync =NOSYNC ;else { -DMWARN ("unrecognised sync argument to " -"dirty region log: %s" , argv[1 ]); +DMWARN ("unrecognised sync argument to dirty region log: %s" , argv[1 ]);return -EINVAL ; } }
drivers/md/dm-raid1.c +3 -4
@@ -236,8 +236,8 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)* Better to issue requests to same failing device * than to risk returning corrupt data. */ -DMERR ("Primary mirror (%s) failed while out-of-sync: " -"Reads may fail." , m->dev->name); +DMERR ("Primary mirror (%s) failed while out-of-sync: Reads may fail." , + m->dev->name); goto out; }
@@ -517,8 +517,7 @@ static void read_callback(unsigned long error, void *context)fail_mirror (m,DM_RAID1_READ_ERROR );if (likely (default_ok (m)) ||mirror_available (m->ms, bio)) { -DMWARN_LIMIT ("Read failure on mirror device %s. " -"Trying alternative device." , +DMWARN_LIMIT ("Read failure on mirror device %s. Trying alternative device." , m->dev->name);queue_bio (m->ms, bio,bio_data_dir (bio));return ;
drivers/md/dm-snap-persistent.c +2 -4
@@ -354,8 +354,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)return 0 ;if (chunk_size_supplied) -DMWARN ("chunk size %u in device metadata overrides " -"table chunk size of %u." , +DMWARN ("chunk size %u in device metadata overrides table chunk size of %u." , chunk_size, ps->store->chunk_size);/* We had a bogus chunk_size. Fix stuff up. */
@@ -958,8 +957,7 @@ int dm_persistent_snapshot_init(void) r =dm_exception_store_type_register (&_persistent_compat_type);if (r) { -DMERR ("Unable to register old-style persistent exception " -"store type" ); +DMERR ("Unable to register old-style persistent exception store type" );dm_exception_store_type_unregister (&_persistent_type);return r; }
drivers/md/dm-snap-transient.c +1 -2
@@ -140,8 +140,7 @@ int dm_transient_snapshot_init(void) r =dm_exception_store_type_register (&_transient_compat_type);if (r) { -DMWARN ("Unable to register old-style transient " -"exception store type" ); +DMWARN ("Unable to register old-style transient exception store type" );dm_exception_store_type_unregister (&_transient_type);return r; }
drivers/md/dm-snap.c +7 -14
@@ -490,8 +490,7 @@ static int __validate_exception_handover(struct dm_snapshot *snap)if ((__find_snapshots_sharing_cow (snap, &snap_src, &snap_dest, &snap_merge) ==2 ) || snap_dest) { - snap->ti->error ="Snapshot cow pairing for exception " -"table handover failed" ; + snap->ti->error ="Snapshot cow pairing for exception table handover failed" ;return -EINVAL ; }
@@ -518,8 +517,7 @@ static int __validate_exception_handover(struct dm_snapshot *snap)if (!snap_src->store->type->prepare_merge || !snap_src->store->type->commit_merge) { - snap->ti->error ="Snapshot exception store does not " -"support snapshot-merge." ; + snap->ti->error ="Snapshot exception store does not support snapshot-merge." ;return -EINVAL ; }
@@ -937,8 +935,7 @@ static int __remove_single_exception_chunk(struct dm_snapshot *s, e =dm_lookup_exception (&s->complete, old_chunk);if (!e) { -DMERR ("Corruption detected: exception for block %llu is " -"on disk but not in memory" , +DMERR ("Corruption detected: exception for block %llu is on disk but not in memory" , (unsigned long long )old_chunk);return -EINVAL ; }
@@ -965,8 +962,7 @@ static int __remove_single_exception_chunk(struct dm_snapshot *s, e->new_chunk++; }else if (old_chunk != e->old_chunk +dm_consecutive_chunk_count (e)) { - DMERR("Attempt to merge block %llu from the " - "middle of a chunk range [%llu - %llu]", + DMERR("Attempt to merge block %llu from the middle of a chunk range [%llu - %llu]", (unsigned long long)old_chunk, (unsigned long long)e->old_chunk, (unsigned long long)
@@ -1059,8 +1055,7 @@ static void snapshot_merge_next_chunks(struct dm_snapshot *s) &new_chunk);if (linear_chunks <=0 ) {if (linear_chunks <0 ) { -DMERR ("Read error in exception store: " -"shutting down merge" ); +DMERR ("Read error in exception store: shutting down merge" );down_write (&s->lock); s->merge_failed = true;up_write (&s->lock);
@@ -2208,12 +2203,10 @@ static int snapshot_preresume(struct dm_target *ti)if (snap_src && snap_dest) {down_read (&snap_src->lock);if (s == snap_src) { -DMERR ("Unable to resume snapshot source until " -"handover completes." ); +DMERR ("Unable to resume snapshot source until handover completes." ); r = -EINVAL ; }else if (!dm_suspended (snap_src->ti)) { -DMERR ("Unable to perform snapshot handover until " -"source is suspended." ); +DMERR ("Unable to perform snapshot handover until source is suspended." ); r = -EINVAL ; }up_read (&snap_src->lock);
drivers/md/dm-stripe.c +4 -8
@@ -108,15 +108,13 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv) width = ti->len;if (sector_div (width, stripes)) { - ti->error ="Target length not divisible by " -"number of stripes" ; + ti->error ="Target length not divisible by number of stripes" ;return -EINVAL ; } tmp_len = width;if (sector_div (tmp_len, chunk_size)) { - ti->error ="Target length not divisible by " -"chunk size" ; + ti->error ="Target length not divisible by chunk size" ;return -EINVAL ; }
@@ -124,15 +122,13 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)* Do we have enough arguments for that many stripes ? */ if (argc != (2 +2 * stripes)) { - ti->error ="Not enough destinations " -"specified" ; + ti->error ="Not enough destinations specified" ;return -EINVAL ; } sc =kmalloc (struct_size (sc, stripe, stripes),GFP_KERNEL );if (!sc) { - ti->error ="Memory allocation for striped context " -"failed" ; + ti->error ="Memory allocation for striped context failed" ;return -ENOMEM ; }
drivers/md/dm-table.c +6 -12
@@ -234,8 +234,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,return 0 ;if ((start >= dev_size) || (start + len > dev_size)) { - DMERR("%s: %pg too small for target: " - "start=%llu, len=%llu, dev_size=%llu", + DMERR("%s: %pg too small for target: start=%llu, len=%llu, dev_size=%llu", dm_device_name(ti->table->md), bdev, (unsigned long long)start, (unsigned long long)len,
@@ -280,8 +279,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,return 0 ;if (start & (logical_block_size_sectors -1 )) { -DMERR ("%s: start=%llu not aligned to h/w " -"logical block size %u of %pg" , +DMERR ("%s: start=%llu not aligned to h/w logical block size %u of %pg" ,dm_device_name (ti->table->md), (unsigned long long )start, limits->logical_block_size, bdev);
@@ -289,8 +287,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev, }if (len & (logical_block_size_sectors -1 )) { -DMERR ("%s: len=%llu not aligned to h/w " -"logical block size %u of %pg" , +DMERR ("%s: len=%llu not aligned to h/w logical block size %u of %pg" ,dm_device_name (ti->table->md), (unsigned long long )len, limits->logical_block_size, bdev);
@@ -880,8 +877,7 @@ static int dm_table_determine_type(struct dm_table *t) bio_based =1 ;if (bio_based && request_based) { -DMERR ("Inconsistent table: different target types" -" can't be mixed up" ); +DMERR ("Inconsistent table: different target types can't be mixed up" );return -EINVAL ; } }
@@ -1184,8 +1180,7 @@ static int dm_table_register_integrity(struct dm_table *t)* profile the new profile should not conflict. */ if (blk_integrity_compare (dm_disk (md), template_disk) <0 ) { -DMERR ("%s: conflict with existing integrity profile: " -"%s profile mismatch" , +DMERR ("%s: conflict with existing integrity profile: %s profile mismatch" ,dm_device_name (t->md), template_disk->disk_name);return 1 ;
@@ -1698,8 +1693,7 @@ int dm_calculate_queue_limits(struct dm_table *t,* for the table. */ if (blk_stack_limits (limits, &ti_limits,0 ) <0 ) - DMWARN("%s: adding target device " - "(start sect %llu len %llu) " + DMWARN("%s: adding target device (start sect %llu len %llu) " "caused an alignment inconsistency", dm_device_name(t->md), (unsigned long long) ti->begin,
drivers/md/dm-thin-metadata.c +4 -4
@@ -265,15 +265,15 @@ static int sb_check(struct dm_block_validator *v,__le32 csum_le;if (dm_block_location (b) !=le64_to_cpu (disk_super->blocknr)) { -DMERR ("sb_check failed: blocknr %llu: " -"wanted %llu" ,le64_to_cpu (disk_super->blocknr), +DMERR ("sb_check failed: blocknr %llu: wanted %llu" , +le64_to_cpu (disk_super->blocknr), (unsigned long long )dm_block_location (b));return -ENOTBLK ; }if (le64_to_cpu (disk_super->magic) !=THIN_SUPERBLOCK_MAGIC ) { -DMERR ("sb_check failed: magic %llu: " -"wanted %llu" ,le64_to_cpu (disk_super->magic), +DMERR ("sb_check failed: magic %llu: wanted %llu" , +le64_to_cpu (disk_super->magic), (unsigned long long )THIN_SUPERBLOCK_MAGIC );return -EILSEQ ; }
drivers/md/dm-zoned-metadata.c +4 -8
@@ -1014,10 +1014,8 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_sb *dsb, sb_block =le64_to_cpu (sb->sb_block);if (sb_block != (u64 )dsb->zone->id << zmd->zone_nr_blocks_shift) { -dmz_dev_err (dev,"Invalid superblock position " -"(is %llu expected %llu)" , - sb_block, - (u64 )dsb->zone->id << zmd->zone_nr_blocks_shift); +dmz_dev_err (dev,"Invalid superblock position (is %llu expected %llu)" , + sb_block, (u64 )dsb->zone->id << zmd->zone_nr_blocks_shift);return -EINVAL ; }if (zmd->sb_version >1 ) {
@@ -1030,16 +1028,14 @@ static int dmz_check_sb(struct dmz_metadata *zmd, struct dmz_sb *dsb, }else if (uuid_is_null (&zmd->uuid)) {uuid_copy (&zmd->uuid, &sb_uuid); }else if (!uuid_equal (&zmd->uuid, &sb_uuid)) { -dmz_dev_err (dev,"mismatching DM-Zoned uuid, " -"is %pUl expected %pUl" , +dmz_dev_err (dev,"mismatching DM-Zoned uuid, is %pUl expected %pUl" , &sb_uuid, &zmd->uuid);return -ENXIO ; }if (!strlen (zmd->label))memcpy (zmd->label, sb->dmz_label,BDEVNAME_SIZE );else if (memcmp (zmd->label, sb->dmz_label,BDEVNAME_SIZE )) { -dmz_dev_err (dev,"mismatching DM-Zoned label, " -"is %s expected %s" , +dmz_dev_err (dev,"mismatching DM-Zoned label, is %s expected %s" , sb->dmz_label, zmd->label);return -ENXIO ; }
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 519/591 dm ioctl: have constant on the right side of the test
In reply to Greg Kroah-HartmanFrom: Heinz Mauelshagen <[email protected]>
[ Upstream commit 5cae0aa77397015f530aeb34f3ced32db6ac2875 ]
Stable-dep-of: 249bed821b4d ("dm ioctl: Avoid double-fetch of version")
--- drivers/md/dm-ioctl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-ioctl.c +2 -2
@@ -1819,8 +1819,8 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)if (copy_from_user (version, user->version,sizeof (version)))return -EFAULT ; -if ((DM_VERSION_MAJOR != version[0 ]) || - (DM_VERSION_MINOR < version[1 ])) { +if ((version[0 ] !=DM_VERSION_MAJOR ) || + (version[1 ] >DM_VERSION_MINOR )) { DMERR("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)", DM_VERSION_MAJOR, DM_VERSION_MINOR, DM_VERSION_PATCHLEVEL,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 520/591 dm ioctl: Avoid double-fetch of version
In reply to Greg Kroah-HartmanFrom: Demi Marie Obenour <[email protected]>
[ Upstream commit 249bed821b4db6d95a99160f7d6d236ea5fe6362 ]
The version is fetched once in check_version(), which then does some validation and then overwrites the version in userspace with the API version supported by the kernel. copy_params() then fetches the version from userspace *again*, and this time no validation is done. The result is that the kernel's version number is completely controllable by userspace, provided that userspace can win a race condition.
Fix this flaw by not copying the version back to the kernel the second time. This is not exploitable as the version is not further used in the kernel. However, it could become a problem if future patches start relying on the version field.
--- drivers/md/dm-ioctl.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
drivers/md/dm-ioctl.c +21 -12
@@ -1811,30 +1811,36 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)* As well as checking the version compatibility this always * copies the kernel interface version out. */ -static int check_version (unsigned int cmd,struct dm_ioctl __user *user) +static int check_version (unsigned int cmd,struct dm_ioctl __user *user, +struct dm_ioctl *kernel_params) { -uint32_t version[3 ];int r =0 ; -if (copy_from_user (version, user->version,sizeof (version))) +/* Make certain version is first member of dm_ioctl struct */ +BUILD_BUG_ON (offsetof(struct dm_ioctl , version) !=0 ); + +if (copy_from_user (kernel_params->version, user->version,sizeof (kernel_params->version)))return -EFAULT ; -if ((version[0 ] !=DM_VERSION_MAJOR ) || - (version[1 ] >DM_VERSION_MINOR )) { +if ((kernel_params->version[0 ] !=DM_VERSION_MAJOR ) || + (kernel_params->version[1 ] >DM_VERSION_MINOR )) {DMERR ("ioctl interface mismatch: kernel(%u.%u.%u), user(%u.%u.%u), cmd(%d)" ,DM_VERSION_MAJOR ,DM_VERSION_MINOR ,DM_VERSION_PATCHLEVEL , - version[0 ], version[1 ], version[2 ], cmd); + kernel_params->version[0 ], + kernel_params->version[1 ], + kernel_params->version[2 ], + cmd); r = -EINVAL ; }/* * Fill in the kernel version. */ - version[0 ] =DM_VERSION_MAJOR ; - version[1 ] =DM_VERSION_MINOR ; - version[2 ] =DM_VERSION_PATCHLEVEL ; -if (copy_to_user (user->version, version,sizeof (version))) + kernel_params->version[0 ] =DM_VERSION_MAJOR ; + kernel_params->version[1 ] =DM_VERSION_MINOR ; + kernel_params->version[2 ] =DM_VERSION_PATCHLEVEL ; +if (copy_to_user (user->version, kernel_params->version,sizeof (kernel_params->version)))return -EFAULT ;return r;
@@ -1860,7 +1866,10 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl *param_kernconst size_t minimum_data_size = offsetof(struct dm_ioctl , data);unsigned int noio_flag; -if (copy_from_user (param_kernel, user, minimum_data_size)) +/* check_version() already copied version from userspace, avoid TOCTOU */ +if (copy_from_user ((char *)param_kernel +sizeof (param_kernel->version), + (char __user *)user +sizeof (param_kernel->version), + minimum_data_size -sizeof (param_kernel->version)))return -EFAULT ;if (param_kernel->data_size < minimum_data_size) {
@@ -1972,7 +1981,7 @@ static int ctl_ioctl(struct file *file, uint command, struct dm_ioctl __user *us* Check the interface version passed in. This also * writes out the kernel's interface version. */ - r =check_version (cmd, user); + r =check_version (cmd, user, ¶m_kernel);if (r)return r;
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 521/591 extcon: usbc-tusb320: Convert to i2cs .probe_new()
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit 5313121b22fd11db0d14f305c110168b8176efdc ]
The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
Stable-dep-of: 3adbaa30d973 ("extcon: usbc-tusb320: Unregister typec port on driver removal")
--- drivers/extcon/extcon-usbc-tusb320.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +2 -3
@@ -428,8 +428,7 @@ static int tusb320_typec_probe(struct i2c_client *client,return 0 ; } -static int tusb320_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int tusb320_probe (struct i2c_client *client) {struct tusb320_priv *priv;const void *match_data;
@@ -502,7 +501,7 @@ static const struct of_device_id tusb320_extcon_dt_match[] = {MODULE_DEVICE_TABLE (of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { - .probe = tusb320_probe, + .probe_new = tusb320_probe, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 522/591 extcon: usbc-tusb320: Unregister typec port on driver removal
In reply to Greg Kroah-HartmanFrom: Alvin Šipraga <[email protected]>
[ Upstream commit 3adbaa30d973093a4f37927baf9596cca51b593d ]
The driver can register a typec port if suitable firmware properties are present. But if the driver is removed through sysfs unbind, rmmod or similar, then it does not clean up after itself and the typec port device remains registered. This can be seen in sysfs, where stale typec ports get left over in /sys/class/typec.
In order to fix this we have to add an i2c_driver remove function and call typec_unregister_port(), which is a no-op in the case where no typec port is created and the pointer remains NULL.
In the process we should also put the fwnode_handle when the typec port isn't registered anymore, including if an error occurs during probe. The typec subsystem does not increase or decrease the reference counter for us, so we track it in the driver's private data.
Note that the conditional check on TYPEC_PWR_MODE_PD was removed in the probe path because a call to tusb320_set_adv_pwr_mode() will perform an even more robust validation immediately after, hence there is no functional change here.
--- drivers/extcon/extcon-usbc-tusb320.c | 42 ++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 8 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +34 -8
@@ -78,6 +78,7 @@ struct tusb320_priv {struct typec_capability cap;enum typec_port_type port_type;enum typec_pwr_opmode pwr_opmode; +struct fwnode_handle *connector_fwnode; };static const char *const tusb_attached_states[] = {
@@ -391,27 +392,25 @@ static int tusb320_typec_probe(struct i2c_client *client,/* Type-C connector found. */ ret =typec_get_fw_cap (&priv->cap, connector);if (ret) -return ret; + goto err_put; priv->port_type = priv->cap.type;/* This goes into register 0x8 field CURRENT_MODE_ADVERTISE */ ret =fwnode_property_read_string (connector,"typec-power-opmode" , &cap_str);if (ret) -return ret; + goto err_put; ret =typec_find_pwr_opmode (cap_str);if (ret <0 ) -return ret; -if (ret ==TYPEC_PWR_MODE_PD ) -return -EINVAL ; + goto err_put; priv->pwr_opmode = ret;/* Initialize the hardware with the devicetree settings. */ ret =tusb320_set_adv_pwr_mode (priv);if (ret) -return ret; + goto err_put; priv->cap.revision =USB_TYPEC_REV_1_1 ; priv->cap.accessory[0 ] =TYPEC_ACCESSORY_AUDIO ;
@@ -422,10 +421,25 @@ static int tusb320_typec_probe(struct i2c_client *client, priv->cap.fwnode = connector; priv->port =typec_register_port (&client->dev, &priv->cap); -if (IS_ERR (priv->port)) -return PTR_ERR (priv->port); +if (IS_ERR (priv->port)) { + ret =PTR_ERR (priv->port); + goto err_put; + } + + priv->connector_fwnode = connector;return 0 ; + +err_put: +fwnode_handle_put (connector); + +return ret; +} + +static void tusb320_typec_remove (struct tusb320_priv *priv) +{ +typec_unregister_port (priv->port); +fwnode_handle_put (priv->connector_fwnode); }static int tusb320_probe (struct i2c_client *client)
@@ -438,7 +452,9 @@ static int tusb320_probe(struct i2c_client *client) priv =devm_kzalloc (&client->dev,sizeof (*priv),GFP_KERNEL );if (!priv)return -ENOMEM ; + priv->dev = &client->dev; +i2c_set_clientdata (client, priv); priv->regmap =devm_regmap_init_i2c (client, &tusb320_regmap_config);if (IS_ERR (priv->regmap))
@@ -489,10 +505,19 @@ static int tusb320_probe(struct i2c_client *client) tusb320_irq_handler,IRQF_TRIGGER_FALLING |IRQF_ONESHOT , client->name, priv); +if (ret) +tusb320_typec_remove (priv);return ret; } +static void tusb320_remove (struct i2c_client *client) +{ +struct tusb320_priv *priv =i2c_get_clientdata (client); + +tusb320_typec_remove (priv); +} +static const struct of_device_id tusb320_extcon_dt_match[] = { { .compatible ="ti,tusb320" , .data = &tusb320_ops, }, { .compatible ="ti,tusb320l" , .data = &tusb320l_ops, },
@@ -502,6 +527,7 @@ MODULE_DEVICE_TABLE(of, tusb320_extcon_dt_match);static struct i2c_driver tusb320_extcon_driver = { .probe_new = tusb320_probe, + .remove = tusb320_remove, .driver = { .name ="extcon-tusb320" , .of_match_table = tusb320_extcon_dt_match,
Signature · 1 line
2.39.2
Greg Kroah-Hartman
maintainerPATCH 523/591 btrfs: do not BUG_ON() on tree mod log failure at balance_level()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
[ Upstream commit 39020d8abc7ec62c4de9b260e3d10d4a1c2478ce ]
At balance_level(), instead of doing a BUG_ON() in case we fail to record tree mod log operations, do a transaction abort and return the error to the callers. There's really no need for the BUG_ON() as we can release all resources in this context, and we have to abort because other future tree searches that use the tree mod log (btrfs_search_old_slot()) may get inconsistent results if other operations modify the tree after that failure and before the tree mod log based search.
--- fs/btrfs/ctree.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/btrfs/ctree.c +14 -3
@@ -935,7 +935,12 @@ static noinline int balance_level(struct } ret =btrfs_tree_mod_log_insert_root (root->node, child, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (child); +free_extent_buffer (child); +btrfs_abort_transaction (trans, ret); + goto enospc; + }rcu_assign_pointer (root->node, child);add_root_to_dirty_list (root);
@@ -1017,7 +1022,10 @@ static noinline int balance_level(structbtrfs_node_key (right, &right_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot +1 ,BTRFS_MOD_LOG_KEY_REPLACE ,GFP_NOFS ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &right_key, pslot +1 );btrfs_mark_buffer_dirty (parent); }
@@ -1063,7 +1071,10 @@ static noinline int balance_level(structbtrfs_node_key (mid, &mid_key,0 ); ret =btrfs_tree_mod_log_insert_key (parent, pslot,BTRFS_MOD_LOG_KEY_REPLACE ,GFP_NOFS ); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_abort_transaction (trans, ret); + goto enospc; + }btrfs_set_node_key (parent, &mid_key, pslot);btrfs_mark_buffer_dirty (parent); }
Greg Kroah-Hartman
maintainerPATCH 524/591 i2c: qup: Add missing unwind goto in qup_i2c_probe()
In reply to Greg Kroah-HartmanFrom: Shuai Jiang <[email protected]>
commit cd9489623c29aa2f8cc07088168afb6e0d5ef06d upstream.
Smatch Warns:
drivers/i2c/busses/i2c-qup.c:1784 qup_i2c_probe() warn: missing unwind goto?
The goto label "fail_runtime" and "fail" will disable qup->pclk, but here qup->pclk failed to obtain, in order to be consistent, change the direct return to goto label "fail_dma".
--- drivers/i2c/busses/i2c-qup.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-qup.c +14 -7
@@ -1752,16 +1752,21 @@ nodma:if (!clk_freq || clk_freq >I2C_MAX_FAST_MODE_PLUS_FREQ ) {dev_err (qup->dev,"clock frequency not supported %d\n" , clk_freq); -return -EINVAL ; + ret = -EINVAL ; + goto fail_dma; } qup->base =devm_platform_ioremap_resource (pdev,0 ); -if (IS_ERR (qup->base)) -return PTR_ERR (qup->base); +if (IS_ERR (qup->base)) { + ret =PTR_ERR (qup->base); + goto fail_dma; + } qup->irq =platform_get_irq (pdev,0 ); -if (qup->irq <0 ) -return qup->irq; +if (qup->irq <0 ) { + ret = qup->irq; + goto fail_dma; + }if (has_acpi_companion (qup->dev)) { ret = device_property_read_u32(qup->dev,
@@ -1775,13 +1780,15 @@ nodma: qup->clk =devm_clk_get (qup->dev,"core" );if (IS_ERR (qup->clk)) {dev_err (qup->dev,"Could not get core clock\n" ); -return PTR_ERR (qup->clk); + ret =PTR_ERR (qup->clk); + goto fail_dma; } qup->pclk =devm_clk_get (qup->dev,"iface" );if (IS_ERR (qup->pclk)) {dev_err (qup->dev,"Could not get iface clock\n" ); -return PTR_ERR (qup->pclk); + ret =PTR_ERR (qup->pclk); + goto fail_dma; }qup_i2c_enable_clocks (qup); src_clk_freq =clk_get_rate (qup->clk);
Greg Kroah-Hartman
maintainerPATCH 525/591 irqchip/loongson-pch-pic: Fix potential incorrect hwirq assignment
In reply to Greg Kroah-HartmanFrom: Liu Peibao <[email protected]>
commit 783422e704ca0fa41cb2fe9ed79e46b6fe7eae29 upstream.
In DeviceTree path, when ht_vec_base is not zero, the hwirq of PCH PIC will be assigned incorrectly. Because when pch_pic_domain_translate() adds the ht_vec_base to hwirq, the hwirq does not have the ht_vec_base subtracted when calling irq_domain_set_info().
The ht_vec_base is designed for the parent irq chip/domain of the PCH PIC. It seems not proper to deal this in callbacks of the PCH PIC domain and let's put this back like the initial commit ef8c01eb64ca ("irqchip: Add Loongson PCH PIC controller").
--- drivers/irqchip/irq-loongson-pch-pic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/irqchip/irq-loongson-pch-pic.c +2 -2
@@ -162,7 +162,7 @@ static int pch_pic_domain_translate(struif (fwspec->param_count <2 )return -EINVAL ; - *hwirq = fwspec->param[0 ] + priv->ht_vec_base; + *hwirq = fwspec->param[0 ]; *type = fwspec->param[1 ] &IRQ_TYPE_SENSE_MASK ; }else { *hwirq = fwspec->param[0 ] - priv->gsi_base;
@@ -188,7 +188,7 @@ static int pch_pic_alloc(struct irq_doma parent_fwspec.fwnode = domain->parent->fwnode; parent_fwspec.param_count =1 ; - parent_fwspec.param[0 ] = hwirq; + parent_fwspec.param[0 ] = hwirq + priv->ht_vec_base; err =irq_domain_alloc_irqs_parent (domain, virq,1 , &parent_fwspec);if (err)
Greg Kroah-Hartman
maintainerPATCH 526/591 NFSD: add encoding of op_recall flag for write delegation
In reply to Greg Kroah-HartmanFrom: Dai Ngo <[email protected]>
commit 58f5d894006d82ed7335e1c37182fbc5f08c2f51 upstream.
Modified nfsd4_encode_open to encode the op_recall flag properly for OPEN result with write delegation granted.
--- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/nfs4xdr.c +1 -1
@@ -3872,7 +3872,7 @@ nfsd4_encode_open(struct nfsd4_compoundr p =xdr_reserve_space (xdr,32 );if (!p)return nfserr_resource; - *p++ =cpu_to_be32 (0 ); + *p++ =cpu_to_be32 (open->op_recall);/* * TODO: space_limit's in delegations
Greg Kroah-Hartman
maintainerPATCH 527/591 irqchip/loongson-pch-pic: Fix initialization of HT vector register
In reply to Greg Kroah-HartmanFrom: Jianmin Lv <[email protected]>
commit f679616565f1cf1a4acb245dbc0032dafcd40637 upstream.
In an ACPI-based dual-bridge system, IRQ of each bridge's PCH PIC sent to CPU is always a zero-based number, which means that the IRQ on PCH PIC of each bridge is mapped into vector range from 0 to 63 of upstream irqchip(e.g. EIOINTC).
EIOINTC N: [0 ... 63 | 64 ... 255]
-------- ----------
^ ^
| |
PCH PIC N |
PCH MSI N
For example, the IRQ vector number of sata controller on PCH PIC of each bridge is 16, which is sent to upstream irqchip of EIOINTC when an interrupt occurs, which will set bit 16 of EIOINTC. Since hwirq of 16 on EIOINTC has been mapped to a irq_desc for sata controller during hierarchy irq allocation, the related mapped IRQ will be found through irq_resolve_mapping() in the IRQ domain of EIOINTC.
So, the IRQ number set in HT vector register should be fixed to be a zero-based number.
--- drivers/irqchip/irq-loongson-pch-pic.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/irqchip/irq-loongson-pch-pic.c +2 -4
@@ -350,14 +350,12 @@ static int __init acpi_cascade_irqdomainint __init pch_pic_acpi_init (struct irq_domain *parent,struct acpi_madt_bio_pic *acpi_pchpic) { -int ret, vec_base; +int ret;struct fwnode_handle *domain_handle;if (find_pch_pic (acpi_pchpic->gsi_base) >=0 )return 0 ; - vec_base = acpi_pchpic->gsi_base -GSI_MIN_PCH_IRQ ; - domain_handle =irq_domain_alloc_fwnode (&acpi_pchpic->address);if (!domain_handle) {pr_err ("Unable to allocate domain handle\n" );
@@ -365,7 +363,7 @@ int __init pch_pic_acpi_init(struct irq_ } ret =pch_pic_init (acpi_pchpic->address, acpi_pchpic->size, - vec_base, parent, domain_handle, acpi_pchpic->gsi_base); +0 , parent, domain_handle, acpi_pchpic->gsi_base);if (ret <0 ) {irq_domain_free_fwnode (domain_handle);
Greg Kroah-Hartman
maintainerPATCH 528/591 io_uring: wait interruptibly for request completions on exit
In reply to Greg Kroah-HartmanFrom: Jens Axboe <[email protected]>
commit 4826c59453b3b4677d6bf72814e7ababdea86949 upstream.
WHen the ring exits, cleanup is done and the final cancelation and waiting on completions is done by io_ring_exit_work. That function is invoked by kworker, which doesn't take any signals. Because of that, it doesn't really matter if we wait for completions in TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE state. However, it does matter to the hung task detection checker!
Normally we expect cancelations and completions to happen rather quickly. Some test cases, however, will exit the ring and park the owning task stopped (eg via SIGSTOP). If the owning task needs to run task_work to complete requests, then io_ring_exit_work won't make any progress until the task is runnable again. Hence io_ring_exit_work can trigger the hung task detection, which is particularly problematic if panic-on-hung-task is enabled.
As the ring exit doesn't take signals to begin with, have it wait interruptibly rather than uninterruptibly. io_uring has a separate stuck-exit warning that triggers independently anyway, so we're not really missing anything by making this switch.
--- io_uring/io_uring.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
io_uring/io_uring.c +18 -2
@@ -2748,7 +2748,18 @@ static __cold void io_ring_exit_work(str/* there is little hope left, don't run it too often */ interval =HZ *60 ; } - }while (!wait_for_completion_timeout (&ctx->ref_comp, interval)); +/* +* This is really an uninterruptible wait, as it has to be +* complete. But it's also run from a kworker, which doesn't +* take signals, so it's fine to make it interruptible. This +* avoids scenarios where we knowingly can wait much longer +* on completions, for example if someone does a SIGSTOP on +* a task that needs to finish task_work to make this loop +* complete. That's a synthetic situation that should not +* cause a stuck task backtrace, and hence a potential panic +* on stuck tasks if that is enabled. +*/ + }while (!wait_for_completion_interruptible_timeout (&ctx->ref_comp, interval));init_completion (&exit.completion);init_task_work (&exit.task_work, io_tctx_exit_cb);
@@ -2772,7 +2783,12 @@ static __cold void io_ring_exit_work(strcontinue ;mutex_unlock (&ctx->uring_lock); -wait_for_completion (&exit.completion); +/* +* See comment above for +* wait_for_completion_interruptible_timeout() on why this +* wait is marked as interruptible. +*/ +wait_for_completion_interruptible (&exit.completion);mutex_lock (&ctx->uring_lock); }mutex_unlock (&ctx->uring_lock);
Greg Kroah-Hartman
maintainerPATCH 529/591 mmc: core: disable TRIM on Kingston EMMC04G-M627
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit f1738a1f816233e6dfc2407f24a31d596643fd90 upstream.
It seems that Kingston EMMC04G-M627 despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing I/O errors in OpenWrt under 6.1 on Zyxel NBG7815 that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES.
Trying to use fstrim seems to also throw errors like:
[93010.835112] I/O error, dev loop0, sector 16902 op 0x3:(DISCARD) flags 0x800 phys_seg 1 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -110,6 +110,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Kingston EMMC04G-M627 advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("M62704" ,CID_MANFID_KINGSTON ,0x0100 , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 530/591 mmc: core: disable TRIM on Micron MTFC4GACAJCN-1M
In reply to Greg Kroah-HartmanFrom: Robert Marko <[email protected]>
commit dbfbddcddcebc9ce8a08757708d4e4a99d238e44 upstream.
It seems that Micron MTFC4GACAJCN-1M despite advertising TRIM support does not work when the core is trying to use REQ_OP_WRITE_ZEROES.
We are seeing the following errors in OpenWrt under 6.1 on Qnap Qhora 301W that we did not previously have and tracked it down to REQ_OP_WRITE_ZEROES:
[ 18.085950] I/O error, dev loop0, sector 596 op 0x9:(WRITE_ZEROES) flags 0x800 phys_seg 0 prio class 2
Disabling TRIM makes the error go away, so lets add a quirk for this eMMC to disable TRIM.
--- drivers/mmc/core/quirks.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/mmc/core/quirks.h +7 -0
@@ -117,6 +117,13 @@ static const struct mmc_fixup __maybe_un MMC_QUIRK_TRIM_BROKEN),/* +* Micron MTFC4GACAJCN-1M advertises TRIM but it does not seems to +* support being used to offload WRITE_ZEROES. +*/ +MMC_FIXUP ("Q2J54A" ,CID_MANFID_MICRON ,0x014e , add_quirk_mmc, +MMC_QUIRK_TRIM_BROKEN ), + +/* * Some SD cards reports discard support while they don't */ MMC_FIXUP(CID_NAME_ANY, CID_MANFID_SANDISK_SD, 0x5344, add_quirk_sd,
Greg Kroah-Hartman
maintainerPATCH 531/591 mmc: mmci: Set PROBE_PREFER_ASYNCHRONOUS
In reply to Greg Kroah-HartmanFrom: Ulf Hansson <[email protected]>
commit 3108eb2e8aa7e955a9dd3a4c1bf19a7898961822 upstream.
All mmc host drivers should have the asynchronous probe option enabled, but it seems like we failed to set it for mmci, so let's do that now.
--- drivers/mmc/host/mmci.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/host/mmci.c +1 -0
@@ -2456,6 +2456,7 @@ static struct amba_driver mmci_driver = .drv = { .name = DRIVER_NAME, .pm = &mmci_dev_pm_ops, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, }, .probe = mmci_probe, .remove = mmci_remove,
Greg Kroah-Hartman
maintainerPATCH 532/591 mmc: sdhci: fix DMA configure compatibility issue when 64bit DMA mode is used.
In reply to Greg Kroah-HartmanFrom: Chevron Li <[email protected]>
commit 20dbd07ef0a8bc29eb03d6a95258ac8934cbe52d upstream.
Bayhub SD host has hardware limitation:
1.The upper 32bit address is inhibited to be written at SD Host Register
[03E][13]=0 (32bits addressing) mode, is admitted to be written only at SD Host Register [03E][13]=1 (64bits addressing) mode.
2.Because of above item#1, need to configure SD Host Register [03E][13] to
1(64bits addressing mode) before set 64bit ADMA system address's higher 32bits SD Host Register [05F~05C] if 64 bits addressing mode is used.
The hardware limitation is reasonable for below reasons:
1.Normal flow should set DMA working mode first, then do
DMA-transfer-related configuration, such as system address.
2.The hardware limitation may avoid the software to configure wrong higher
32bit address at 32bits addressing mode although it is redundant.
The change that set 32bits/64bits addressing mode before set ADMA address,
has no side-effect to other host IPs for below reason:
The setting order is reasonable and standard: DMA Mode setting first and
then DMA address setting. It meets all DMA setting sequence.
--- drivers/mmc/host/sdhci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci.c +2 -2
@@ -1181,6 +1181,8 @@ static void sdhci_prepare_data(struct sd } } +sdhci_config_dma (host); +if (host->flags &SDHCI_REQ_USE_DMA ) {int sg_cnt =sdhci_pre_dma_transfer (host, data,COOKIE_MAPPED );
@@ -1200,8 +1202,6 @@ static void sdhci_prepare_data(struct sd } } -sdhci_config_dma (host); -if (!(host->flags &SDHCI_REQ_USE_DMA )) {int flags;
Greg Kroah-Hartman
maintainerPATCH 533/591 wifi: cfg80211: fix regulatory disconnect for non-MLO
In reply to Greg Kroah-HartmanFrom: Johannes Berg <[email protected]>
commit b22552fcaf1970360005c805d7fba4046cf2ab4a upstream.
The multi-link loop here broke disconnect when multi-link operation (MLO) isn't active for a given interface, since in that case valid_links is 0 (indicating no links, i.e. no MLO.)
Fix this by taking that into account properly and skipping the link only if there are valid_links in the first place.
--- net/wireless/reg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/wireless/reg.c +1 -1
@@ -2390,7 +2390,7 @@ static bool reg_wdev_chan_valid(struct wif (!wdev->valid_links && link >0 )break ; -if (!(wdev->valid_links &BIT (link))) +if (wdev->valid_links && !(wdev->valid_links &BIT (link)))continue ;switch (iftype) {case NL80211_IFTYPE_AP :
Greg Kroah-Hartman
maintainerPATCH 534/591 wifi: ath10k: Serialize wake_tx_queue ops
In reply to Greg Kroah-HartmanFrom: Alexander Wetzel <[email protected]>
commit b719ebc37a1eacd4fd4f1264f731b016e5ec0c6e upstream.
Serialize the ath10k implementation of the wake_tx_queue ops. ath10k_mac_op_wake_tx_queue() must not run concurrent since it's using ieee80211_txq_schedule_start().
The intend of this patch is to sort out an issue discovered in the discussion referred to by the Link tag.
I can't test it with real hardware and thus just implemented the per-ac queue lock Felix suggested. One obvious alternative to the per-ac lock would be to bring back the txqs_lock commit bb2edb733586 ("ath10k: migrate to mac80211 txq scheduling") dropped.
--- drivers/net/wireless/ath/ath10k/core.c | 3 +++ drivers/net/wireless/ath/ath10k/core.h | 3 +++ drivers/net/wireless/ath/ath10k/mac.c | 6 ++++-- 3 files changed, 10 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath10k/core.c +3 -0
@@ -3634,6 +3634,9 @@ struct ath10k *ath10k_core_create(size_tmutex_init (&ar->dump_mutex);spin_lock_init (&ar->data_lock); +for (int ac =0 ; ac <IEEE80211_NUM_ACS ; ac++) +spin_lock_init (&ar->queue_lock[ac]); +INIT_LIST_HEAD (&ar->peers);init_waitqueue_head (&ar->peer_mapping_wq);init_waitqueue_head (&ar->htt.empty_tx_wq);
drivers/net/wireless/ath/ath10k/core.h +3 -0
@@ -1170,6 +1170,9 @@ struct ath10k {/* protects shared structure data */ spinlock_t data_lock; +/* serialize wake_tx_queue calls per ac */ +spinlock_t queue_lock[IEEE80211_NUM_ACS ]; +struct list_head arvifs;struct list_head peers;struct ath10k_peer *peer_map[ATH10K_MAX_NUM_PEER_IDS ];
drivers/net/wireless/ath/ath10k/mac.c +4 -2
@@ -4732,13 +4732,14 @@ static void ath10k_mac_op_wake_tx_queue( {struct ath10k *ar = hw->priv;int ret; -u8 ac; +u8 ac = txq->ac;ath10k_htt_tx_txq_update (hw, txq);if (ar->htt.tx_q_state.mode !=HTT_TX_MODE_SWITCH_PUSH )return ; - ac = txq->ac; +spin_lock_bh (&ar->queue_lock[ac]); +ieee80211_txq_schedule_start (hw, ac); txq =ieee80211_next_txq (hw, ac);if (!txq)
@@ -4753,6 +4754,7 @@ static void ath10k_mac_op_wake_tx_queue(ath10k_htt_tx_txq_update (hw, txq); out:ieee80211_txq_schedule_end (hw, ac); +spin_unlock_bh (&ar->queue_lock[ac]); }/* Must not be called with conf_mutex held as workers can use that also. */
Greg Kroah-Hartman
maintainerPATCH 535/591 wifi: mt76: mt7921e: fix init command fail with enabled device
In reply to Greg Kroah-HartmanFrom: Quan Zhou <[email protected]>
commit 525c469e5de9bf7e53574396196e80fc716ac9eb upstream.
For some cases as below, we may encounter the unpreditable chip stats in driver probe()
* The system reboot flow do not work properly, such as kernel oops while rebooting, and then the driver do not go back to default status at this moment.
* Similar to the flow above. If the device was enabled in BIOS or UEFI, the system may switch to Linux without driver fully shutdown.
To avoid the problem, force push the device back to default in probe()
* mt7921e_mcu_fw_pmctrl() : return control privilege to chip side.
* mt7921_wfsys_reset() : cleanup chip config before resource init.
Error log
[59007.600714] mt7921e 0000:02:00.0: ASIC revision: 79220010 [59010.889773] mt7921e 0000:02:00.0: Message 00000010 (seq 1) timeout [59010.889786] mt7921e 0000:02:00.0: Failed to get patch semaphore [59014.217839] mt7921e 0000:02:00.0: Message 00000010 (seq 2) timeout [59014.217852] mt7921e 0000:02:00.0: Failed to get patch semaphore [59017.545880] mt7921e 0000:02:00.0: Message 00000010 (seq 3) timeout [59017.545893] mt7921e 0000:02:00.0: Failed to get patch semaphore [59020.874086] mt7921e 0000:02:00.0: Message 00000010 (seq 4) timeout [59020.874099] mt7921e 0000:02:00.0: Failed to get patch semaphore [59024.202019] mt7921e 0000:02:00.0: Message 00000010 (seq 5) timeout [59024.202033] mt7921e 0000:02:00.0: Failed to get patch semaphore [59027.530082] mt7921e 0000:02:00.0: Message 00000010 (seq 6) timeout [59027.530096] mt7921e 0000:02:00.0: Failed to get patch semaphore [59030.857888] mt7921e 0000:02:00.0: Message 00000010 (seq 7) timeout [59030.857904] mt7921e 0000:02:00.0: Failed to get patch semaphore [59034.185946] mt7921e 0000:02:00.0: Message 00000010 (seq 8) timeout [59034.185961] mt7921e 0000:02:00.0: Failed to get patch semaphore [59037.514249] mt7921e 0000:02:00.0: Message 00000010 (seq 9) timeout [59037.514262] mt7921e 0000:02:00.0: Failed to get patch semaphore [59040.842362] mt7921e 0000:02:00.0: Message 00000010 (seq 10) timeout [59040.842375] mt7921e 0000:02:00.0: Failed to get patch semaphore [59040.923845] mt7921e 0000:02:00.0: hardware init failed
Message-ID: <39fcb7cee08d4ab940d38d82f21897483212483f.1688569385.git.deren.wu@mediatek.com>
--- drivers/net/wireless/mediatek/mt76/mt7921/dma.c | 4 ---- drivers/net/wireless/mediatek/mt76/mt7921/mcu.c | 8 -------- drivers/net/wireless/mediatek/mt76/mt7921/pci.c | 8 ++++++++ 3 files changed, 8 insertions(+), 12 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/dma.c +0 -4
@@ -231,10 +231,6 @@ int mt7921_dma_init(struct mt7921_dev *dif (ret)return ret; - ret =mt7921_wfsys_reset (dev); -if (ret) -return ret; -/* init tx queue */ ret = mt76_connac_init_tx_queues(dev->phy.mt76, MT7921_TXQ_BAND0, MT7921_TX_RING_SIZE,
drivers/net/wireless/mediatek/mt76/mt7921/mcu.c +0 -8
@@ -449,12 +449,6 @@ static int mt7921_load_firmware(struct m {int ret; - ret =mt76_get_field (dev,MT_CONN_ON_MISC ,MT_TOP_MISC2_FW_N9_RDY ); -if (ret &&mt76_is_mmio (&dev->mt76)) { -dev_dbg (dev->mt76.dev,"Firmware is already download\n" ); - goto fw_loaded; - } - ret =mt76_connac2_load_patch (&dev->mt76,mt7921_patch_name (dev));if (ret)return ret;
@@ -477,8 +471,6 @@ static int mt7921_load_firmware(struct mreturn -EIO ; } -fw_loaded: -#ifdef CONFIG_PM dev->mt76.hw->wiphy->wowlan = &mt76_connac_wowlan_support;#endif /* CONFIG_PM */
drivers/net/wireless/mediatek/mt76/mt7921/pci.c +8 -0
@@ -316,6 +316,10 @@ static int mt7921_pci_probe(struct pci_d bus_ops->rmw = mt7921_rmw; dev->mt76.bus = bus_ops; + ret =mt7921e_mcu_fw_pmctrl (dev); +if (ret) + goto err_free_dev; + ret =__mt7921e_mcu_drv_pmctrl (dev);if (ret) goto err_free_dev;
@@ -324,6 +328,10 @@ static int mt7921_pci_probe(struct pci_d (mt7921_l1_rr (dev,MT_HW_REV ) &0xff );dev_info (mdev->dev,"ASIC revision: %04x\n" , mdev->rev); + ret =mt7921_wfsys_reset (dev); +if (ret) + goto err_free_dev; +mt76_wr (dev,MT_WFDMA0_HOST_INT_ENA ,0 );mt76_wr (dev,MT_PCIE_MAC_INT_ENABLE ,0xff );
Greg Kroah-Hartman
maintainerPATCH 536/591 bcache: fixup btree_cache_wait list damage
In reply to Greg Kroah-HartmanFrom: Mingzhe Zou <[email protected]>
commit f0854489fc07d2456f7cc71a63f4faf9c716ffbe upstream.
We get a kernel crash about "list_add corruption. next->prev should be prev (ffff9c801bc01210), but was ffff9c77b688237c. (next=ffffae586d8afe68)."
crash> struct list_head 0xffff9c801bc01210
struct list_head {
next = 0xffffae586d8afe68,
prev = 0xffffae586d8afe68
}
crash> struct list_head 0xffff9c77b688237c
struct list_head {
next = 0x0,
prev = 0x0
}
crash> struct list_head 0xffffae586d8afe68
struct list_head struct: invalid kernel virtual address: ffffae586d8afe68 type: "gdb_readmem_callback" Cannot access memory at address 0xffffae586d8afe68
[230469.019492] Call Trace: [230469.032041] prepare_to_wait+0x8a/0xb0 [230469.044363] ? bch_btree_keys_free+0x6c/0xc0 [escache] [230469.056533] mca_cannibalize_lock+0x72/0x90 [escache] [230469.068788] mca_alloc+0x2ae/0x450 [escache] [230469.080790] bch_btree_node_get+0x136/0x2d0 [escache] [230469.092681] bch_btree_check_thread+0x1e1/0x260 [escache] [230469.104382] ? finish_wait+0x80/0x80 [230469.115884] ? bch_btree_check_recurse+0x1a0/0x1a0 [escache] [230469.127259] kthread+0x112/0x130 [230469.138448] ? kthread_flush_work_fn+0x10/0x10 [230469.149477] ret_from_fork+0x35/0x40
bch_btree_check_thread() and bch_dirty_init_thread() may call mca_cannibalize() to cannibalize other cached btree nodes. Only one thread can do it at a time, so the op of other threads will be added to the btree_cache_wait list.
We must call finish_wait() to remove op from btree_cache_wait before free it's memory address. Otherwise, the list will be damaged. Also should call bch_cannibalize_unlock() to release the btree_cache_alloc_lock and wake_up other waiters.
--- drivers/md/bcache/btree.c | 11 ++++++++++- drivers/md/bcache/btree.h | 1 + drivers/md/bcache/writeback.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +10 -1
@@ -885,7 +885,7 @@ static struct btree *mca_cannibalize(str* cannibalize_bucket() will take. This means every time we unlock the root of * the btree, we need to release this lock if we have it held. */ -static void bch_cannibalize_unlock (struct cache_set *c) +void bch_cannibalize_unlock (struct cache_set *c) {spin_lock (&c->btree_cannibalize_lock);if (c->btree_cache_alloc_lock == current) {
@@ -1968,6 +1968,15 @@ static int bch_btree_check_thread(void * c->gc_stats.nodes++;bch_btree_op_init (&op,0 ); ret =bcache_btree (check_recurse, p, c->root, &op); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op)->wait);if (ret) goto out; }
drivers/md/bcache/btree.h +1 -0
@@ -282,6 +282,7 @@ void bch_initial_gc_finish(struct cache_void bch_moving_gc (struct cache_set *c);int bch_btree_check (struct cache_set *c);void bch_initial_mark_key (struct cache_set *c,int level,struct bkey *k); +void bch_cannibalize_unlock (struct cache_set *c);static inline void wake_up_gc (struct cache_set *c) {
drivers/md/bcache/writeback.c +10 -0
@@ -890,6 +890,16 @@ static int bch_root_node_dirty_init(struif (ret <0 )pr_warn ("sectors dirty init failed, ret=%d!\n" , ret); +/* +* The op may be added to cache_set's btree_cache_wait +* in mca_cannibalize(), must ensure it is removed from +* the list and release btree_cache_alloc_lock before +* free op memory. +* Otherwise, the btree_cache_wait will be damaged. +*/ +bch_cannibalize_unlock (c); +finish_wait (&c->btree_cache_wait, &(&op.op)->wait); +return ret; }
Greg Kroah-Hartman
maintainerPATCH 537/591 bcache: Remove unnecessary NULL point check in node allocations
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 028ddcac477b691dd9205c92f991cc15259d033e upstream.
Due to the previous fix of __bch_btree_node_alloc, the return value will never be a NULL pointer. So IS_ERR is enough to handle the failure situation. Fix it by replacing IS_ERR_OR_NULL check by an IS_ERR check.
--- drivers/md/bcache/btree.c | 10 +++++----- drivers/md/bcache/super.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-)
drivers/md/bcache/btree.c +5 -5
@@ -1138,7 +1138,7 @@ static struct btree *btree_node_alloc_re {struct btree *n =bch_btree_node_alloc (b->c, op, b->level, b->parent); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {mutex_lock (&n->write_lock);bch_btree_sort_into (&b->keys, &n->keys, &b->c->sort);bkey_copy_key (&n->key, &b->key);
@@ -1340,7 +1340,7 @@ static int btree_gc_coalesce(struct btrememset (new_nodes,0 ,sizeof (new_nodes));closure_init_stack (&cl); -while (nodes <GC_MERGE_NODES && !IS_ERR_OR_NULL (r[nodes].b)) +while (nodes <GC_MERGE_NODES && !IS_ERR (r[nodes].b)) keys += r[nodes++].keys; blocks =btree_default_blocks (b->c) *2 /3 ;
@@ -1352,7 +1352,7 @@ static int btree_gc_coalesce(struct btrefor (i =0 ; i < nodes; i++) { new_nodes[i] =btree_node_alloc_replacement (r[i].b,NULL ); -if (IS_ERR_OR_NULL (new_nodes[i])) +if (IS_ERR (new_nodes[i])) goto out_nocoalesce; }
@@ -1487,7 +1487,7 @@ out_nocoalesce:bch_keylist_free (&keylist);for (i =0 ; i < nodes; i++) -if (!IS_ERR_OR_NULL (new_nodes[i])) { +if (!IS_ERR (new_nodes[i])) {btree_node_free (new_nodes[i]);rw_unlock (true, new_nodes[i]); }
@@ -1669,7 +1669,7 @@ static int bch_btree_gc_root(struct btreif (should_rewrite) { n =btree_node_alloc_replacement (b,NULL ); -if (!IS_ERR_OR_NULL (n)) { +if (!IS_ERR (n)) {bch_btree_node_write_sync (n);bch_btree_set_root (n);
drivers/md/bcache/super.c +2 -2
@@ -1724,7 +1724,7 @@ static void cache_set_flush(struct closuif (!IS_ERR_OR_NULL (c->gc_thread))kthread_stop (c->gc_thread); -if (!IS_ERR_OR_NULL (c->root)) +if (!IS_ERR (c->root))list_add (&c->root->list, &c->btree_cache);/*
@@ -2088,7 +2088,7 @@ static int run_cache_set(struct cache_se err ="cannot allocate new btree root" ; c->root =__bch_btree_node_alloc (c,NULL ,0 , true,NULL ); -if (IS_ERR_OR_NULL (c->root)) +if (IS_ERR (c->root)) goto err;mutex_lock (&c->root->write_lock);
Greg Kroah-Hartman
maintainerPATCH 538/591 bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 upstream.
In some specific situations, the return value of __bch_btree_node_alloc may be NULL. This may lead to a potential NULL pointer dereference in caller function like a calling chain :btree_split->bch_btree_node_alloc->__bch_btree_node_alloc.
Fix it by initializing the return value in __bch_btree_node_alloc.
--- drivers/md/bcache/btree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/btree.c +3 -1
@@ -1090,10 +1090,12 @@ struct btree *__bch_btree_node_alloc(str struct btree *parent) {BKEY_PADDED (key) k; -struct btree *b =ERR_PTR (-EAGAIN ); +struct btree *b;mutex_lock (&c->bucket_lock); retry: +/* return ERR_PTR(-EAGAIN) when it fails */ + b =ERR_PTR (-EAGAIN );if (__bch_bucket_alloc_set (c,RESERVE_BTREE , &k.key, wait)) goto err;
Greg Kroah-Hartman
maintainerPATCH 539/591 watch_queue: prevent dangling pipe pointer
In reply to Greg Kroah-HartmanFrom: Siddh Raman Pant <[email protected]>
commit 943211c87427f25bd22e0e63849fb486bb5f87fa upstream.
NULL the dangling pipe reference while clearing watch_queue.
If not done, a reference to a freed pipe remains in the watch_queue, as this function is called before freeing a pipe in free_pipe_info() (see line 834 of fs/pipe.c).
The sole use of wqueue->defunct is for checking if the watch queue has been cleared, but wqueue->pipe is also NULLed while clearing.
Thus, wqueue->defunct is superfluous, as wqueue->pipe can be checked for NULL. Hence, the former can be removed.
Tested with keyutils testsuite.
Message-Id: <[email protected]>
--- include/linux/watch_queue.h | 3 +-- kernel/watch_queue.c | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-)
include/linux/watch_queue.h +1 -2
@@ -38,7 +38,7 @@ struct watch_filter {struct watch_queue {struct rcu_head rcu;struct watch_filter __rcu *filter; -struct pipe_inode_info *pipe;/* The pipe we're using as a buffer */ +struct pipe_inode_info *pipe;/* Pipe we use as a buffer, NULL if queue closed */ struct hlist_head watches;/* Contributory watches */ struct page **notes;/* Preallocated notifications */ unsigned long *notes_bitmap;/* Allocation bitmap for notes */
@@ -46,7 +46,6 @@ struct watch_queue {spinlock_t lock;unsigned int nr_notes;/* Number of notes */ unsigned int nr_pages;/* Number of pages in notes[] */ -bool defunct;/* T when queues closed */ };/*
kernel/watch_queue.c +6 -6
@@ -43,7 +43,7 @@ MODULE_LICENSE("GPL");static inline bool lock_wqueue (struct watch_queue *wqueue) {spin_lock_bh (&wqueue->lock); -if (unlikely (wqueue->defunct)) { +if (unlikely (!wqueue->pipe)) {spin_unlock_bh (&wqueue->lock);return false; }
@@ -105,9 +105,6 @@ static bool post_one_notification(structunsigned int head, tail, mask, note, offset, len;bool done = false; -if (!pipe) -return false; -spin_lock_irq (&pipe->rd_wait.lock); mask = pipe->ring_size -1 ;
@@ -604,8 +601,11 @@ void watch_queue_clear(struct watch_queurcu_read_lock ();spin_lock_bh (&wqueue->lock); -/* Prevent new notifications from being stored. */ - wqueue->defunct = true; +/* +* This pipe can be freed by callers like free_pipe_info(). +* Removing this reference also prevents new notifications. +*/ + wqueue->pipe =NULL ;while (!hlist_empty (&wqueue->watches)) { watch = hlist_entry(wqueue->watches.first, struct watch, queue_node);
Greg Kroah-Hartman
maintainerPATCH 540/591 um: Use HOST_DIR for mrproper
In reply to Greg Kroah-HartmanFrom: Kees Cook <[email protected]>
commit a5a319ec2c2236bb96d147c16196d2f1f3799301 upstream.
When HEADER_ARCH was introduced, the MRPROPER_FILES (then MRPROPER_DIRS) list wasn't adjusted, leaving SUBARCH as part of the path argument. This resulted in the "mrproper" target not cleaning up arch/x86/... when SUBARCH was specified. Since HOST_DIR is arch/$(HEADER_ARCH), use it instead to get the correct path.
--- arch/um/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/um/Makefile +1 -1
@@ -148,7 +148,7 @@ export LDFLAGS_vmlinux := $(LDFLAGS_EXEC # When cleaning we don't include .config, so we don't include # TT or skas makefiles and don't clean skas_ptregs.h. CLEAN_FILES += linux x.i gmon.out -MRPROPER_FILES += arch/$(SUBARCH)/include/generated +MRPROPER_FILES += $(HOST_DIR)/include/generated archclean: @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
Greg Kroah-Hartman
maintainerPATCH 541/591 integrity: Fix possible multiple allocation in integrity_inode_get()
In reply to Greg Kroah-HartmanFrom: Tianjia Zhang <[email protected]>
commit 9df6a4870dc371136e90330cfbbc51464ee66993 upstream.
When integrity_inode_get() is querying and inserting the cache, there is a conditional race in the concurrent environment.
The race condition is the result of not properly implementing "double-checked locking". In this case, it first checks to see if the iint cache record exists before taking the lock, but doesn't check again after taking the integrity_iint_lock.
--- security/integrity/iint.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
security/integrity/iint.c +9 -6
@@ -43,12 +43,10 @@ static struct integrity_iint_cache *__inelse if (inode > iint->inode) n = n->rb_right;else -break ; +return iint; } -if (!n) -return NULL ; -return iint; +return NULL ; }/*
@@ -121,10 +119,15 @@ struct integrity_iint_cache *integrity_i parent = *p; test_iint = rb_entry(parent, struct integrity_iint_cache, rb_node); -if (inode < test_iint->inode) +if (inode < test_iint->inode) { p = &(*p)->rb_left; -else + }else if (inode > test_iint->inode) { p = &(*p)->rb_right; + }else { +write_unlock (&integrity_iint_lock); +kmem_cache_free (iint_cache, iint); +return test_iint; + } } iint->inode = inode;
Greg Kroah-Hartman
maintainerPATCH 542/591 autofs: use flexible array in ioctl structure
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit e910c8e3aa02dc456e2f4c32cb479523c326b534 upstream.
Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") introduced a warning for the autofs_dev_ioctl structure:
In function 'check_name',
inlined from 'validate_dev_ioctl' at fs/autofs/dev-ioctl.c:131:9,
inlined from '_autofs_dev_ioctl' at fs/autofs/dev-ioctl.c:624:8:fs/autofs/dev-ioctl.c:33:14: error: 'strchr' reading 1 or more bytes from a region of size 0 [-Werror=stringop-overread]
33 | if (!strchr(name, '/'))
| ^~~~~~~~~~~~~~~~~
In file included from include/linux/auto_dev-ioctl.h:10,
from fs/autofs/autofs_i.h:10,
from fs/autofs/dev-ioctl.c:14:
include/uapi/linux/auto_dev-ioctl.h: In function '_autofs_dev_ioctl':
include/uapi/linux/auto_dev-ioctl.h:112:14: note: source object 'path' of size 0
112 | char path[0];
| ^~~~This is easily fixed by changing the gnu 0-length array into a c99 flexible array. Since this is a uapi structure, we have to be careful about possible regressions but this one should be fine as they are equivalent here. While it would break building with ancient gcc versions that predate c99, it helps building with --std=c99 and -Wpedantic builds in user space, as well as non-gnu compilers. This means we probably also want it fixed in stable kernels.
--- Documentation/filesystems/autofs-mount-control.rst | 2 +- Documentation/filesystems/autofs.rst | 2 +- include/uapi/linux/auto_dev-ioctl.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Documentation/filesystems/autofs-mount-control.rst +1 -1
@@ -196,7 +196,7 @@ information and return operation results struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; The ioctlfd field is a mount point file descriptor of an autofs mount
Documentation/filesystems/autofs.rst +1 -1
@@ -467,7 +467,7 @@ Each ioctl is passed a pointer to an `au struct args_ismountpoint ismountpoint; }; - char path[0]; + char path[]; }; For the **OPEN_MOUNT** and **IS_MOUNTPOINT** commands, the target
include/uapi/linux/auto_dev-ioctl.h +1 -1
@@ -109,7 +109,7 @@ struct autofs_dev_ioctl {struct args_ismountpoint ismountpoint; }; -char path[0 ]; +char path[]; };static inline void init_autofs_dev_ioctl (struct autofs_dev_ioctl *in)
Greg Kroah-Hartman
maintainerPATCH 543/591 mm/damon/ops-common: atomically test and clear young on ptes and pmds
In reply to Greg Kroah-HartmanFrom: Ryan Roberts <[email protected]>
commit c11d34fa139e4b0fb4249a30f37b178353533fa1 upstream.
It is racy to non-atomically read a pte, then clear the young bit, then write it back as this could discard dirty information. Further, it is bad practice to directly set a pte entry within a table. Instead clearing young must go through the arch-provided helper, ptep_test_and_clear_young() to ensure it is modified atomically and to give the arch code visibility and allow it to check (and potentially modify) the operation.
--- mm/damon/ops-common.c | 16 ++++++---------- mm/damon/ops-common.h | 4 ++-- mm/damon/paddr.c | 4 ++-- mm/damon/vaddr.c | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-)
mm/damon/ops-common.c +6 -10
@@ -33,7 +33,7 @@ struct page *damon_get_page(unsigned lonreturn page; } -void damon_ptep_mkold (pte_t *pte,struct mm_struct *mm,unsigned long addr) +void damon_ptep_mkold (pte_t *pte,struct vm_area_struct *vma,unsigned long addr) {bool referenced = false;struct page *page =damon_get_page (pte_pfn (*pte));
@@ -41,13 +41,11 @@ void damon_ptep_mkold(pte_t *pte, structif (!page)return ; -if (pte_young (*pte)) { +if (ptep_test_and_clear_young (vma, addr, pte)) referenced = true; - *pte =pte_mkold (*pte); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, addr +PAGE_SIZE )) +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr +PAGE_SIZE )) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
@@ -58,7 +56,7 @@ void damon_ptep_mkold(pte_t *pte, structput_page (page); } -void damon_pmdp_mkold (pmd_t *pmd,struct mm_struct *mm,unsigned long addr) +void damon_pmdp_mkold (pmd_t *pmd,struct vm_area_struct *vma,unsigned long addr) {#ifdef CONFIG_TRANSPARENT_HUGEPAGE bool referenced = false;
@@ -67,13 +65,11 @@ void damon_pmdp_mkold(pmd_t *pmd, structif (!page)return ; -if (pmd_young (*pmd)) { +if (pmdp_test_and_clear_young (vma, addr, pmd)) referenced = true; - *pmd =pmd_mkold (*pmd); - }#ifdef CONFIG_MMU_NOTIFIER -if (mmu_notifier_clear_young (mm, addr, addr +HPAGE_PMD_SIZE )) +if (mmu_notifier_clear_young (vma->vm_mm, addr, addr +HPAGE_PMD_SIZE )) referenced = true;#endif /* CONFIG_MMU_NOTIFIER */
mm/damon/ops-common.h +2 -2
@@ -9,8 +9,8 @@struct page *damon_get_page (unsigned long pfn); -void damon_ptep_mkold (pte_t *pte,struct mm_struct *mm,unsigned long addr); -void damon_pmdp_mkold (pmd_t *pmd,struct mm_struct *mm,unsigned long addr); +void damon_ptep_mkold (pte_t *pte,struct vm_area_struct *vma,unsigned long addr); +void damon_pmdp_mkold (pmd_t *pmd,struct vm_area_struct *vma,unsigned long addr);int damon_cold_score (struct damon_ctx *c,struct damon_region *r,struct damos *s);
mm/damon/paddr.c +2 -2
@@ -24,9 +24,9 @@ static bool __damon_pa_mkold(struct foliwhile (page_vma_mapped_walk (&pvmw)) { addr = pvmw.address;if (pvmw.pte) -damon_ptep_mkold (pvmw.pte, vma->vm_mm, addr); +damon_ptep_mkold (pvmw.pte, vma, addr);else -damon_pmdp_mkold (pvmw.pmd, vma->vm_mm, addr); +damon_pmdp_mkold (pvmw.pmd, vma, addr); }return true; }
mm/damon/vaddr.c +2 -2
@@ -311,7 +311,7 @@ static int damon_mkold_pmd_entry(pmd_t * }if (pmd_trans_huge (*pmd)) { -damon_pmdp_mkold (pmd, walk->mm, addr); +damon_pmdp_mkold (pmd, walk->vma, addr);spin_unlock (ptl);return 0 ; }
@@ -323,7 +323,7 @@ static int damon_mkold_pmd_entry(pmd_t * pte =pte_offset_map_lock (walk->mm, pmd, addr, &ptl);if (!pte_present (*pte)) goto out; -damon_ptep_mkold (pte, walk->mm, addr); +damon_ptep_mkold (pte, walk->vma, addr); out:pte_unmap_unlock (pte, ptl);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 544/591 shmem: use ramfs_kill_sb() for kill_sb method of ramfs-based tmpfs
In reply to Greg Kroah-HartmanFrom: Roberto Sassu <[email protected]>
commit 36ce9d76b0a93bae799e27e4f5ac35478c676592 upstream.
As the ramfs-based tmpfs uses ramfs_init_fs_context() for the init_fs_context method, which allocates fc->s_fs_info, use ramfs_kill_sb() to free it and avoid a memory leak.
--- fs/ramfs/inode.c | 2 +- include/linux/ramfs.h | 1 + mm/shmem.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-)
fs/ramfs/inode.c +1 -1
@@ -278,7 +278,7 @@ int ramfs_init_fs_context(struct fs_contreturn 0 ; } -static void ramfs_kill_sb (struct super_block *sb) +void ramfs_kill_sb (struct super_block *sb) {kfree (sb->s_fs_info);kill_litter_super (sb);
include/linux/ramfs.h +1 -0
@@ -7,6 +7,7 @@struct inode *ramfs_get_inode (struct super_block *sb,const struct inode *dir,umode_t mode,dev_t dev);extern int ramfs_init_fs_context (struct fs_context *fc); +extern void ramfs_kill_sb (struct super_block *sb);#ifdef CONFIG_MMU static inline int
mm/shmem.c +1 -1
@@ -4137,7 +4137,7 @@ static struct file_system_type shmem_fs_ .name = "tmpfs", .init_fs_context = ramfs_init_fs_context, .parameters = ramfs_fs_parameters, - .kill_sb = kill_litter_super, + .kill_sb = ramfs_kill_sb, .fs_flags = FS_USERNS_MOUNT, };
Greg Kroah-Hartman
maintainerPATCH 545/591 jffs2: reduce stack usage in jffs2_build_xattr_subsystem()
In reply to Greg Kroah-HartmanFrom: Fabian Frederick <[email protected]>
commit 1168f095417643f663caa341211e117db552989f upstream.
Use kcalloc() for allocation/flush of 128 pointers table to reduce stack usage.
Function now returns -ENOMEM or 0 on success.
stackusage
Before:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 1208
dynamic,bounded
After:./fs/jffs2/xattr.c:775 jffs2_build_xattr_subsystem 192
dynamic,bounded
Also update definition when CONFIG_JFFS2_FS_XATTR is not enabled
Tested with an MTD mount point and some user set/getfattr.
Many current target on OpenWRT also suffer from a compilation warning (that become an error with CONFIG_WERROR) with the following output:
fs/jffs2/xattr.c: In function 'jffs2_build_xattr_subsystem':fs/jffs2/xattr.c:887:1: error: the frame size of 1088 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
887 | }
| ^
Using dynamic allocation fix this compilation warning.
Message-Id: <[email protected]>
--- fs/jffs2/build.c | 5 ++++- fs/jffs2/xattr.c | 13 +++++++++---- fs/jffs2/xattr.h | 4 ++-- 3 files changed, 15 insertions(+), 7 deletions(-)
fs/jffs2/build.c +4 -1
@@ -211,7 +211,10 @@ static int jffs2_build_filesystem(struct ic->scan_dents =NULL ;cond_resched (); } -jffs2_build_xattr_subsystem (c); + ret =jffs2_build_xattr_subsystem (c); +if (ret) + goto exit; + c->flags &= ~JFFS2_SB_FLAG_BUILDING ;dbg_fsbuild ("FS build complete\n" );
fs/jffs2/xattr.c +9 -4
@@ -772,10 +772,10 @@ void jffs2_clear_xattr_subsystem(struct }#define XREF_TMPHASH_SIZE (128) -void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) +int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c) {struct jffs2_xattr_ref *ref, *_ref; -struct jffs2_xattr_ref *xref_tmphash[XREF_TMPHASH_SIZE ]; +struct jffs2_xattr_ref **xref_tmphash;struct jffs2_xattr_datum *xd, *_xd;struct jffs2_inode_cache *ic;struct jffs2_raw_node_ref *raw;
@@ -784,9 +784,12 @@ void jffs2_build_xattr_subsystem(structBUG_ON (!(c->flags &JFFS2_SB_FLAG_BUILDING )); + xref_tmphash =kcalloc (XREF_TMPHASH_SIZE , +sizeof (struct jffs2_xattr_ref *),GFP_KERNEL ); +if (!xref_tmphash) +return -ENOMEM ; +/* Phase.1 : Merge same xref */ -for (i=0 ; i <XREF_TMPHASH_SIZE ; i++) - xref_tmphash[i] =NULL ;for (ref=c->xref_temp; ref; ref=_ref) {struct jffs2_xattr_ref *tmp;
@@ -884,6 +887,8 @@ void jffs2_build_xattr_subsystem(struct"%u of xref (%u dead, %u orphan) found.\n" , xdatum_count, xdatum_unchecked_count, xdatum_orphan_count, xref_count, xref_dead_count, xref_orphan_count); +kfree (xref_tmphash); +return 0 ; } struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
fs/jffs2/xattr.h +2 -2
@@ -71,7 +71,7 @@ static inline int is_xattr_ref_dead(stru#ifdef CONFIG_JFFS2_FS_XATTR extern void jffs2_init_xattr_subsystem (struct jffs2_sb_info *c); -extern void jffs2_build_xattr_subsystem (struct jffs2_sb_info *c); +extern int jffs2_build_xattr_subsystem (struct jffs2_sb_info *c);extern void jffs2_clear_xattr_subsystem (struct jffs2_sb_info *c); extern struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
@@ -103,7 +103,7 @@ extern ssize_t jffs2_listxattr(struct de#else #define jffs2_init_xattr_subsystem (c) -#define jffs2_build_xattr_subsystem (c) +#define jffs2_build_xattr_subsystem (c) (0)#define jffs2_clear_xattr_subsystem (c)#define jffs2_xattr_do_crccheck_inode (c, ic)
Greg Kroah-Hartman
maintainerPATCH 546/591 fs: avoid empty option when generating legacy mount string
In reply to Greg Kroah-HartmanFrom: Thomas Weißschuh <[email protected]>
commit 62176420274db5b5127cd7a0083a9aeb461756ee upstream.
As each option string fragment is always prepended with a comma it would happen that the whole string always starts with a comma. This could be interpreted by filesystem drivers as an empty option and may produce errors.
For example the NTFS driver from ntfs.ko behaves like this and fails when mounted via the new API.
Message-Id: <[email protected]>
--- fs/fs_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/fs_context.c +2 -1
@@ -561,7 +561,8 @@ static int legacy_parse_param(struct fs_return -ENOMEM ; } - ctx->legacy_data[size++] =',' ; +if (size) + ctx->legacy_data[size++] =',' ; len =strlen (param->key);memcpy (ctx->legacy_data + size, param->key, len); size += len;
Greg Kroah-Hartman
maintainerPATCH 547/591 ext4: Remove ext4 locking of moved directory
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 3658840cd363f2be094f5dfd2f0b174a9055dd0f upstream.
Remove locking of moved directory in ext4_rename2(). We will take care of it in VFS instead. This effectively reverts commit 0813299c586b ("ext4: Fix possible corruption when moving a directory") and followup fixes.
Message-Id: <[email protected]>
--- fs/ext4/namei.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
fs/ext4/namei.c +2 -15
@@ -3834,19 +3834,10 @@ static int ext4_rename(struct user_namesreturn retval; } -/* -* We need to protect against old.inode directory getting converted -* from inline directory format into a normal one. -*/ -if (S_ISDIR (old.inode->i_mode)) -inode_lock_nested (old.inode,I_MUTEX_NONDIR2 ); - old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de, &old.inlined); -if (IS_ERR (old.bh)) { - retval =PTR_ERR (old.bh); - goto unlock_moved_dir; - } +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors.
@@ -4043,10 +4034,6 @@ release_bh:brelse (old.bh);brelse (new.bh); -unlock_moved_dir: -if (S_ISDIR (old.inode->i_mode)) -inode_unlock (old.inode); -return retval; }
Greg Kroah-Hartman
maintainerPATCH 548/591 Revert "f2fs: fix potential corruption when moving a directory"
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit cde3c9d7e2a359e337216855dcb333a19daaa436 upstream.
This reverts commit d94772154e524b329a168678836745d2773a6e02. The locking is going to be provided by VFS.
Message-Id: <[email protected]>
--- fs/f2fs/namei.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
fs/f2fs/namei.c +1 -15
@@ -1002,20 +1002,12 @@ static int f2fs_rename(struct user_names goto out; } -/* -* Copied from ext4_rename: we need to protect against old.inode -* directory getting converted from inline directory format into -* a normal one. -*/ -if (S_ISDIR (old_inode->i_mode)) -inode_lock_nested (old_inode,I_MUTEX_NONDIR2 ); - err = -ENOENT ; old_entry =f2fs_find_entry (old_dir, &old_dentry->d_name, &old_page);if (!old_entry) {if (IS_ERR (old_page)) err =PTR_ERR (old_page); - goto out_unlock_old; + goto out; }if (S_ISDIR (old_inode->i_mode)) {
@@ -1123,9 +1115,6 @@ static int f2fs_rename(struct user_namesf2fs_unlock_op (sbi); -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); -if (IS_DIRSYNC (old_dir) ||IS_DIRSYNC (new_dir))f2fs_sync_fs (sbi->sb,1 );
@@ -1140,9 +1129,6 @@ out_dir:f2fs_put_page (old_dir_page,0 ); out_old:f2fs_put_page (old_page,0 ); -out_unlock_old: -if (S_ISDIR (old_inode->i_mode)) -inode_unlock (old_inode); out:iput (whiteout);return err;
Greg Kroah-Hartman
maintainerPATCH 549/591 fs: Establish locking order for unrelated directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit f23ce757185319886ca80c4864ce5f81ac6cc9e9 upstream.
Currently the locking order of inode locks for directories that are not in ancestor relationship is not defined because all operations that needed to lock two directories like this were serialized by sb->s_vfs_rename_mutex. However some filesystems need to lock two subdirectories for RENAME_EXCHANGE operations and for this we need the locking order established even for two tree-unrelated directories. Provide a helper function lock_two_inodes() that establishes lock ordering for any two inodes and use it in lock_two_directories().
Message-Id: <[email protected]>
--- fs/inode.c | 42 ++++++++++++++++++++++++++++++++++++++++++ fs/internal.h | 2 ++ fs/namei.c | 4 ++-- 3 files changed, 46 insertions(+), 2 deletions(-)
fs/inode.c +42 -0
@@ -1104,6 +1104,48 @@ void discard_new_inode(struct inode *inoEXPORT_SYMBOL (discard_new_inode);/** +* lock_two_inodes - lock two inodes (may be regular files but also dirs) +* +* Lock any non-NULL argument. The caller must make sure that if he is passing +* in two directories, one is not ancestor of the other. Zero, one or two +* objects may be locked by this function. +* +* @inode1: first inode to lock +* @inode2: second inode to lock +* @subclass1: inode lock subclass for the first lock obtained +* @subclass2: inode lock subclass for the second lock obtained +*/ +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2) +{ +if (!inode1 || !inode2) { +/* +* Make sure @subclass1 will be used for the acquired lock. +* This is not strictly necessary (no current caller cares) but +* let's keep things consistent. +*/ +if (!inode1) +swap (inode1, inode2); + goto lock; + } + +/* +* If one object is directory and the other is not, we must make sure +* to lock directory first as the other object may be its child. +*/ +if (S_ISDIR (inode2->i_mode) ==S_ISDIR (inode1->i_mode)) { +if (inode1 > inode2) +swap (inode1, inode2); + }else if (!S_ISDIR (inode1->i_mode)) +swap (inode1, inode2); +lock: +if (inode1) +inode_lock_nested (inode1, subclass1); +if (inode2 && inode2 != inode1) +inode_lock_nested (inode2, subclass2); +} + +/** * lock_two_nondirectories - take two i_mutexes on non-directory objects * * Lock any non-NULL argument that is not a directory.
fs/internal.h +2 -0
@@ -153,6 +153,8 @@ extern long prune_icache_sb(struct superint dentry_needs_remove_privs (struct user_namespace *,struct dentry *dentry);bool in_group_or_capable (struct user_namespace *mnt_userns,const struct inode *inode,vfsgid_t vfsgid); +void lock_two_inodes (struct inode *inode1,struct inode *inode2, +unsigned subclass1,unsigned subclass2);/* * fs-writeback.c
fs/namei.c +2 -2
@@ -3007,8 +3007,8 @@ struct dentry *lock_rename(struct dentryreturn p; } -inode_lock_nested (p1->d_inode,I_MUTEX_PARENT ); -inode_lock_nested (p2->d_inode,I_MUTEX_PARENT2 ); +lock_two_inodes (p1->d_inode, p2->d_inode, +I_MUTEX_PARENT ,I_MUTEX_PARENT2 );return NULL ; }EXPORT_SYMBOL (lock_rename);
Greg Kroah-Hartman
maintainerPATCH 550/591 fs: Lock moved directories
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 28eceeda130f5058074dd007d9c59d2e8bc5af2e upstream.
When a directory is moved to a different directory, some filesystems (udf, ext4, ocfs2, f2fs, and likely gfs2, reiserfs, and others) need to update their pointer to the parent and this must not race with other operations on the directory. Lock the directories when they are moved. Although not all filesystems need this locking, we perform it in vfs_rename() because getting the lock ordering right is really difficult and we don't want to expose these locking details to filesystems.
Message-Id: <[email protected]>
--- Documentation/filesystems/directory-locking.rst | 26 ++++++++++++------------ fs/namei.c | 22 ++++++++++++-------- 2 files changed, 28 insertions(+), 20 deletions(-)
Documentation/filesystems/directory-locking.rst +14 -12
@@ -22,12 +22,11 @@ exclusive. 3) object removal. Locking rules: caller locks parent, finds victim, locks victim and calls the method. Locks are exclusive. -4) rename() that is _not_ cross-directory. Locking rules: caller locks -the parent and finds source and target. In case of exchange (with -RENAME_EXCHANGE in flags argument) lock both. In any case, -if the target already exists, lock it. If the source is a non-directory, -lock it. If we need to lock both, lock them in inode pointer order. -Then call the method. All locks are exclusive. +4) rename() that is _not_ cross-directory. Locking rules: caller locks the +parent and finds source and target. We lock both (provided they exist). If we +need to lock two inodes of different type (dir vs non-dir), we lock directory +first. If we need to lock two inodes of the same type, lock them in inode +pointer order. Then call the method. All locks are exclusive. NB: we might get away with locking the source (and target in exchange case) shared.
@@ -44,15 +43,17 @@ All locks are exclusive. rules: * lock the filesystem - * lock parents in "ancestors first" order. + * lock parents in "ancestors first" order. If one is not ancestor of + the other, lock them in inode pointer order. * find source and target. * if old parent is equal to or is a descendent of target fail with -ENOTEMPTY * if new parent is equal to or is a descendent of source fail with -ELOOP - * If it's an exchange, lock both the source and the target. - * If the target exists, lock it. If the source is a non-directory, - lock it. If we need to lock both, do so in inode pointer order. + * Lock both the source and the target provided they exist. If we + need to lock two inodes of different type (dir vs non-dir), we lock + the directory first. If we need to lock two inodes of the same type, + lock them in inode pointer order. * call the method. All ->i_rwsem are taken exclusive. Again, we might get away with locking
@@ -66,8 +67,9 @@ If no directory is its own ancestor, the Proof: - First of all, at any moment we have a partial ordering of the - objects - A < B iff A is an ancestor of B. + First of all, at any moment we have a linear ordering of the + objects - A < B iff (A is an ancestor of B) or (B is not an ancestor + of A and ptr(A) < ptr(B)). That ordering can change. However, the following is true:
fs/namei.c +14 -8
@@ -4661,7 +4661,7 @@ SYSCALL_DEFINE2(link, const char __user* sb->s_vfs_rename_mutex. We might be more accurate, but that's another * story. * c) we have to lock _four_ objects - parents and victim (if it exists), -* and source (if it is not a directory). +* and source. * And that - after we got ->i_mutex on parents (until then we don't know * whether the target exists). Solution: try to be smart with locking * order for inodes. We rely on the fact that tree topology may change
@@ -4745,10 +4745,16 @@ int vfs_rename(struct renamedata *rd)take_dentry_name_snapshot (&old_name, old_dentry);dget (new_dentry); -if (!is_dir || (flags &RENAME_EXCHANGE )) -lock_two_nondirectories (source, target); -else if (target) -inode_lock (target); +/* +* Lock all moved children. Moved directories may need to change parent +* pointer so they need the lock to prevent against concurrent +* directory changes moving parent pointer. For regular files we've +* historically always done this. The lockdep locking subclasses are +* somewhat arbitrary but RENAME_EXCHANGE in particular can swap +* regular files and directories so it's difficult to tell which +* subclasses to use. +*/ +lock_two_inodes (source, target,I_MUTEX_NORMAL ,I_MUTEX_NONDIR2 ); error = -EPERM ;if (IS_SWAPFILE (source) || (target &&IS_SWAPFILE (target)))
@@ -4796,9 +4802,9 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (!is_dir || (flags &RENAME_EXCHANGE )) -unlock_two_nondirectories (source, target); -else if (target) +if (source) +inode_unlock (source); +if (target)inode_unlock (target);dput (new_dentry);if (!error) {
Greg Kroah-Hartman
maintainerPATCH 551/591 i2c: nvidia-gpu: Add ACPI property to align with device-tree
In reply to Greg Kroah-HartmanFrom: Wayne Chang <[email protected]>
commit f510b0a3565b9231e828e23a7e0f9790b97edf96 upstream.
Device-tree uses the 'firmware-name' string property to pass a name of the firmware build to the Cypress CCGx driver. Add a new ACPI string property to the NVIDIA GPU I2C driver to align with device-tree so that we can migrate to using a common property name for both ACPI and device-tree.
--- drivers/i2c/busses/i2c-nvidia-gpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-nvidia-gpu.c +1 -0
@@ -261,6 +261,7 @@ MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = {/* Use FW built for NVIDIA (nv) only */ PROPERTY_ENTRY_U16 ("ccgx,firmware-build" , ('n' <<8 ) |'v' ), +PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), { } };
Greg Kroah-Hartman
maintainerPATCH 552/591 i2c: nvidia-gpu: Remove ccgx,firmware-build property
In reply to Greg Kroah-HartmanFrom: Wayne Chang <[email protected]>
commit 430b38764fbb931c6dbd1af13c8b2e4508994662 upstream.
Now the Cypress CCG driver has been updated to support the 'firmware-name' property to align with device-tree, remove the 'ccgx,firmware-build' property as this is no longer needed.
--- drivers/i2c/busses/i2c-nvidia-gpu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/i2c/busses/i2c-nvidia-gpu.c +1 -2
@@ -259,8 +259,7 @@ static const struct pci_device_id gpu_i2MODULE_DEVICE_TABLE (pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = { -/* Use FW built for NVIDIA (nv) only */ -PROPERTY_ENTRY_U16 ("ccgx,firmware-build" , ('n' <<8 ) |'v' ), +/* Use FW built for NVIDIA GPU only */ PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), { } };
Greg Kroah-Hartman
maintainerPATCH 553/591 usb: typec: ucsi: Mark dGPUs as DEVICE scope
In reply to Greg Kroah-HartmanFrom: Mario Limonciello <[email protected]>
commit a7fbfd44c0204f0629288edfd0d77829edb4a2f8 upstream.
power_supply_is_system_supplied() checks whether any power supplies are present that aren't batteries to decide whether the system is running on DC or AC. Downstream drivers use this to make performance decisions.
Navi dGPUs include an UCSI function that has been exported since commit 17631e8ca2d3 ("i2c: designware: Add driver support for AMD NAVI GPU").
This UCSI function registers a power supply since commit 992a60ed0d5e ("usb: typec: ucsi: register with power_supply class") but this is not a system power supply.
As the power supply for a dGPU is only for powering devices connected to dGPU, create a device property to indicate that the UCSI endpoint is only for the scope of POWER_SUPPLY_SCOPE_DEVICE.
--- drivers/i2c/busses/i2c-designware-pcidrv.c | 13 ++++++++++++- drivers/i2c/busses/i2c-nvidia-gpu.c | 3 +++ drivers/usb/typec/ucsi/psy.c | 14 ++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-designware-pcidrv.c +12 -1
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/pci.h> #include <linux/pm_runtime.h> +#include <linux/power_supply.h> #include <linux/sched.h> #include <linux/slab.h>
@@ -234,6 +235,16 @@ static const struct dev_pm_ops i2c_dw_pm SET_RUNTIME_PM_OPS(i2c_dw_pci_runtime_suspend, i2c_dw_pci_runtime_resume, NULL) }; +static const struct property_entry dgpu_properties[] = { +/* USB-C doesn't power the system */ +PROPERTY_ENTRY_U8 ("scope" ,POWER_SUPPLY_SCOPE_DEVICE ), + {} +}; + +static const struct software_node dgpu_node = { + .properties = dgpu_properties, +}; +static int i2c_dw_pci_probe (struct pci_dev *pdev,const struct pci_device_id *id) {
@@ -325,7 +336,7 @@ static int i2c_dw_pci_probe(struct pci_d }if ((dev->flags &MODEL_MASK ) ==MODEL_AMD_NAVI_GPU ) { - dev->slave =i2c_new_ccgx_ucsi (&dev->adapter, dev->irq,NULL ); + dev->slave =i2c_new_ccgx_ucsi (&dev->adapter, dev->irq, &dgpu_node);if (IS_ERR (dev->slave))return dev_err_probe (dev->dev,PTR_ERR (dev->slave),"register UCSI failed\n" );
drivers/i2c/busses/i2c-nvidia-gpu.c +3 -0
@@ -14,6 +14,7 @@#include <linux/platform_device.h> #include <linux/pm.h> #include <linux/pm_runtime.h> +#include <linux/power_supply.h> #include <asm/unaligned.h>
@@ -261,6 +262,8 @@ MODULE_DEVICE_TABLE(pci, gpu_i2c_ids);static const struct property_entry ccgx_props[] = {/* Use FW built for NVIDIA GPU only */ PROPERTY_ENTRY_STRING ("firmware-name" ,"nvidia,gpu" ), +/* USB-C doesn't power the system */ +PROPERTY_ENTRY_U8 ("scope" ,POWER_SUPPLY_SCOPE_DEVICE ), { } };
drivers/usb/typec/ucsi/psy.c +14 -0
@@ -27,8 +27,20 @@ static enum power_supply_property ucsi_pPOWER_SUPPLY_PROP_VOLTAGE_NOW ,POWER_SUPPLY_PROP_CURRENT_MAX ,POWER_SUPPLY_PROP_CURRENT_NOW , + POWER_SUPPLY_PROP_SCOPE, }; +static int ucsi_psy_get_scope (struct ucsi_connector *con, +union power_supply_propval *val) +{ +u8 scope =POWER_SUPPLY_SCOPE_UNKNOWN ; +struct device *dev = con->ucsi->dev; + +device_property_read_u8 (dev,"scope" , &scope); + val->intval = scope; +return 0 ; +} +static int ucsi_psy_get_online (struct ucsi_connector *con,union power_supply_propval *val) {
@@ -194,6 +206,8 @@ static int ucsi_psy_get_prop(struct powereturn ucsi_psy_get_current_max (con, val);case POWER_SUPPLY_PROP_CURRENT_NOW :return ucsi_psy_get_current_now (con, val); +case POWER_SUPPLY_PROP_SCOPE : +return ucsi_psy_get_scope (con, val);default :return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 554/591 ipvs: increase ip_vs_conn_tab_bits range for 64BIT
In reply to Greg Kroah-HartmanFrom: Abhijeet Rastogi <[email protected]>
commit 04292c695f82b6cf0d25dd5ae494f16ddbb621f6 upstream.
Current range [8, 20] is set purely due to historical reasons because at the time, ~1M (2^20) was considered sufficient. With this change, 27 is the upper limit for 64-bit, 20 otherwise.
Previous change regarding this limit is here.
--- net/netfilter/ipvs/Kconfig | 27 ++++++++++++++------------- net/netfilter/ipvs/ip_vs_conn.c | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-)
net/netfilter/ipvs/Kconfig +14 -13
@@ -44,7 +44,8 @@ config IP_VS_DEBUG config IP_VS_TAB_BITS int "IPVS connection table size (the Nth power of 2)" - range 8 20 + range 8 20 if !64BIT + range 8 27 if 64BIT default 12 help The IPVS connection hash table uses the chaining scheme to handle
@@ -54,24 +55,24 @@ config IP_VS_TAB_BITS Note the table size must be power of 2. The table size will be the value of 2 to the your input number power. The number to choose is - from 8 to 20, the default number is 12, which means the table size - is 4096. Don't input the number too small, otherwise you will lose - performance on it. You can adapt the table size yourself, according - to your virtual server application. It is good to set the table size - not far less than the number of connections per second multiplying - average lasting time of connection in the table. For example, your - virtual server gets 200 connections per second, the connection lasts - for 200 seconds in average in the connection table, the table size - should be not far less than 200x200, it is good to set the table - size 32768 (2**15). + from 8 to 27 for 64BIT(20 otherwise), the default number is 12, + which means the table size is 4096. Don't input the number too + small, otherwise you will lose performance on it. You can adapt the + table size yourself, according to your virtual server application. + It is good to set the table size not far less than the number of + connections per second multiplying average lasting time of + connection in the table. For example, your virtual server gets 200 + connections per second, the connection lasts for 200 seconds in + average in the connection table, the table size should be not far + less than 200x200, it is good to set the table size 32768 (2**15). Another note that each connection occupies 128 bytes effectively and each hash entry uses 8 bytes, so you can estimate how much memory is needed for your box. You can overwrite this number setting conn_tab_bits module parameter - or by appending ip_vs.conn_tab_bits=? to the kernel command line - if IP VS was compiled built-in. + or by appending ip_vs.conn_tab_bits=? to the kernel command line if + IP VS was compiled built-in. comment "IPVS transport protocol load balancing support"
net/netfilter/ipvs/ip_vs_conn.c +2 -2
@@ -1484,8 +1484,8 @@ int __init ip_vs_conn_init(void)int idx;/* Compute size and mask */ -if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >20 ) { -pr_info ("conn_tab_bits not in [8, 20]. Using default value\n" ); +if (ip_vs_conn_tab_bits <8 || ip_vs_conn_tab_bits >27 ) { +pr_info ("conn_tab_bits not in [8, 27]. Using default value\n" ); ip_vs_conn_tab_bits =CONFIG_IP_VS_TAB_BITS ; } ip_vs_conn_tab_size =1 << ip_vs_conn_tab_bits;
Greg Kroah-Hartman
maintainerPATCH 555/591 btrfs: add handling for RAID1C23/DUP to btrfs_reduce_alloc_profile
In reply to Greg Kroah-HartmanFrom: Matt Corallo <[email protected]>
commit 160fe8f6fdb13da6111677be6263e5d65e875987 upstream.
Callers of btrfs_reduce_alloc_profile expect it to return exactly one allocation profile flag, and failing to do so may ultimately result in a WARN_ON and remount-ro when allocating new blocks, like the below transaction abort on 6.1.
btrfs_reduce_alloc_profile has two ways of determining the profile, first it checks if a conversion balance is currently running and uses the profile we're converting to. If no balance is currently running, it returns the max-redundancy profile which at least one block in the selected block group has.
This works by simply checking each known allocation profile bit in redundancy order. However, btrfs_reduce_alloc_profile has not been updated as new flags have been added - first with the DUP profile and later with the RAID1C34 profiles.
Because of the way it checks, if we have blocks with different profiles and at least one is known, that profile will be selected. However, if none are known we may return a flag set with multiple allocation profiles set.
This is currently only possible when a balance from one of the three unhandled profiles to another of the unhandled profiles is canceled after allocating at least one block using the new profile.
In that case, a transaction abort like the below will occur and the filesystem will need to be mounted with -o skip_balance to get it mounted rw again (but the balance cannot be resumed without a similar abort).
[770.648] ------------[ cut here ]------------ [770.648] BTRFS: Transaction aborted (error -22) [770.648] WARNING: CPU: 43 PID: 1159593 at fs/btrfs/extent-tree.c:4122 find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] CPU: 43 PID: 1159593 Comm: btrfs Tainted: G W 6.1.0-0.deb11.7-powerpc64le #1 Debian 6.1.20-2~bpo11+1a~test [770.648] Hardware name: T2P9D01 REV 1.00 POWER9 0x4e1202 opal:skiboot-bc106a0 PowerNV [770.648] NIP: c00800000f6784fc LR: c00800000f6784f8 CTR: c000000000d746c0 [770.648] REGS: c000200089afe9a0 TRAP: 0700 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 9000000002029033 <SF,HV,VEC,EE,ME,IR,DR,RI,LE> CR: 28848282 XER: 20040000 [770.648] CFAR: c000000000135110 IRQMASK: 0 GPR00: c00800000f6784f8 c000200089afec40 c00800000f7ea800 0000000000000026 GPR04: 00000001004820c2 c000200089afea00 c000200089afe9f8 0000000000000027 GPR08: c000200ffbfe7f98 c000000002127f90 ffffffffffffffd8 0000000026d6a6e8 GPR12: 0000000028848282 c000200fff7f3800 5deadbeef0000122 c00000002269d000 GPR16: c0002008c7797c40 c000200089afef17 0000000000000000 0000000000000000 GPR20: 0000000000000000 0000000000000001 c000200008bc5a98 0000000000000001 GPR24: 0000000000000000 c0000003c73088d0 c000200089afef17 c000000016d3a800 GPR28: c0000003c7308800 c00000002269d000 ffffffffffffffea 0000000000000001 [770.648] NIP [c00800000f6784fc] find_free_extent+0x1d94/0x1e00 [btrfs] [770.648] LR [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] [770.648] Call Trace: [770.648] [c000200089afec40] [c00800000f6784f8] find_free_extent+0x1d90/0x1e00 [btrfs] (unreliable) [770.648] [c000200089afed30] [c00800000f681398] btrfs_reserve_extent+0x1a0/0x2f0 [btrfs] [770.648] [c000200089afeea0] [c00800000f681bf0] btrfs_alloc_tree_block+0x108/0x670 [btrfs] [770.648] [c000200089afeff0] [c00800000f66bd68] __btrfs_cow_block+0x170/0x850 [btrfs] [770.648] [c000200089aff100] [c00800000f66c58c] btrfs_cow_block+0x144/0x288 [btrfs] [770.648] [c000200089aff1b0] [c00800000f67113c] btrfs_search_slot+0x6b4/0xcb0 [btrfs] [770.648] [c000200089aff2a0] [c00800000f679f60] lookup_inline_extent_backref+0x128/0x7c0 [btrfs] [770.648] [c000200089aff3b0] [c00800000f67b338] lookup_extent_backref+0x70/0x190 [btrfs] [770.648] [c000200089aff470] [c00800000f67b54c] __btrfs_free_extent+0xf4/0x1490 [btrfs] [770.648] [c000200089aff5a0] [c00800000f67d770] __btrfs_run_delayed_refs+0x328/0x1530 [btrfs] [770.648] [c000200089aff740] [c00800000f67ea2c] btrfs_run_delayed_refs+0xb4/0x3e0 [btrfs] [770.648] [c000200089aff800] [c00800000f699aa4] btrfs_commit_transaction+0x8c/0x12b0 [btrfs] [770.648] [c000200089aff8f0] [c00800000f6dc628] reset_balance_state+0x1c0/0x290 [btrfs] [770.648] [c000200089aff9a0] [c00800000f6e2f7c] btrfs_balance+0x1164/0x1500 [btrfs] [770.648] [c000200089affb40] [c00800000f6f8e4c] btrfs_ioctl+0x2b54/0x3100 [btrfs] [770.648] [c000200089affc80] [c00000000053be14] sys_ioctl+0x794/0x1310 [770.648] [c000200089affd70] [c00000000002af98] system_call_exception+0x138/0x250 [770.648] [c000200089affe10] [c00000000000c654] system_call_common+0xf4/0x258 [770.648] --- interrupt: c00 at 0x7fff94126800 [770.648] NIP: 00007fff94126800 LR: 0000000107e0b594 CTR: 0000000000000000 [770.648] REGS: c000200089affe80 TRAP: 0c00 Tainted: G W (6.1.0-0.deb11.7-powerpc64le Debian 6.1.20-2~bpo11+1a~test) [770.648] MSR: 900000000000d033 <SF,HV,EE,PR,ME,IR,DR,RI,LE> CR: 24002848 XER: 00000000 [770.648] IRQMASK: 0 GPR00: 0000000000000036 00007fffc9439da0 00007fff94217100 0000000000000003 GPR04: 00000000c4009420 00007fffc9439ee8 0000000000000000 0000000000000000 GPR08: 00000000803c7416 0000000000000000 0000000000000000 0000000000000000 GPR12: 0000000000000000 00007fff9467d120 0000000107e64c9c 0000000107e64d0a GPR16: 0000000107e64d06 0000000107e64cf1 0000000107e64cc4 0000000107e64c73 GPR20: 0000000107e64c31 0000000107e64bf1 0000000107e64be7 0000000000000000 GPR24: 0000000000000000 00007fffc9439ee0 0000000000000003 0000000000000001 GPR28: 00007fffc943f713 0000000000000000 00007fffc9439ee8 0000000000000000 [770.648] NIP [00007fff94126800] 0x7fff94126800 [770.648] LR [0000000107e0b594] 0x107e0b594 [770.648] --- interrupt: c00 [770.648] Instruction dump: [770.648] 3b00ffe4 e8898828 481175f5 60000000 4bfff4fc 3be00000 4bfff570 3d220000 [770.648] 7fc4f378 e8698830 4811cd95 e8410018 <0fe00000> f9c10060 f9e10068 fa010070 [770.648] ---[ end trace 0000000000000000 ]--- [770.648] BTRFS: error (device dm-2: state A) in find_free_extent_update_loop:4122: errno=-22 unknown [770.648] BTRFS info (device dm-2: state EA): forced readonly [770.648] BTRFS: error (device dm-2: state EA) in __btrfs_free_extent:3070: errno=-22 unknown [770.648] BTRFS error (device dm-2: state EA): failed to run delayed ref for logical 17838685708288 num_bytes 24576 type 184 action 2 ref_mod 1: -22 [770.648] BTRFS: error (device dm-2: state EA) in btrfs_run_delayed_refs:2144: errno=-22 unknown [770.648] BTRFS: error (device dm-2: state EA) in reset_balance_state:3599: errno=-22 unknown
--- fs/btrfs/block-group.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +8 -1
@@ -79,14 +79,21 @@ static u64 btrfs_reduce_alloc_profile(st } allowed &= flags; -if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) +/* Select the highest-redundancy RAID level. */ +if (allowed &BTRFS_BLOCK_GROUP_RAID1C4 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C4 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID6 ) allowed =BTRFS_BLOCK_GROUP_RAID6 ; +else if (allowed &BTRFS_BLOCK_GROUP_RAID1C3 ) + allowed =BTRFS_BLOCK_GROUP_RAID1C3 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID5 ) allowed =BTRFS_BLOCK_GROUP_RAID5 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID10 ) allowed =BTRFS_BLOCK_GROUP_RAID10 ;else if (allowed &BTRFS_BLOCK_GROUP_RAID1 ) allowed =BTRFS_BLOCK_GROUP_RAID1 ; +else if (allowed &BTRFS_BLOCK_GROUP_DUP ) + allowed =BTRFS_BLOCK_GROUP_DUP ;else if (allowed &BTRFS_BLOCK_GROUP_RAID0 ) allowed =BTRFS_BLOCK_GROUP_RAID0 ;
Greg Kroah-Hartman
maintainerPATCH 556/591 btrfs: delete unused BGs while reclaiming BGs
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 3ed01616bad6c7e3de196676b542ae3df8058592 upstream.
The reclaiming process only starts after the filesystem volumes are allocated to a certain level (75% by default). Thus, the list of reclaiming target block groups can build up so huge at the time the reclaim process kicks in. On a test run, there were over 1000 BGs in the reclaim list.
As the reclaim involves rewriting the data, it takes really long time to reclaim the BGs. While the reclaim is running, btrfs_delete_unused_bgs() won't proceed because the reclaim side is holding fs_info->reclaim_bgs_lock. As a result, we will have a large number of unused BGs kept in the unused list. On my test run, I got 1057 unused BGs.
Since deleting a block group is relatively easy and fast work, we can call btrfs_delete_unused_bgs() while it reclaims BGs, to avoid building up unused BGs.
--- fs/btrfs/block-group.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/block-group.c +14 -0
@@ -1636,10 +1636,24 @@ void btrfs_reclaim_bgs_work(struct work_ next:btrfs_put_block_group (bg); + +mutex_unlock (&fs_info->reclaim_bgs_lock); +/* +* Reclaiming all the block groups in the list can take really +* long. Prioritize cleaning up unused block groups. +*/ +btrfs_delete_unused_bgs (fs_info); +/* +* If we are interrupted by a balance, we can just bail out. The +* cleaner thread restart again if necessary. +*/ +if (!mutex_trylock (&fs_info->reclaim_bgs_lock)) + goto end;spin_lock (&fs_info->unused_bgs_lock); }spin_unlock (&fs_info->unused_bgs_lock);mutex_unlock (&fs_info->reclaim_bgs_lock); +end:btrfs_exclop_finish (fs_info);sb_end_write (fs_info->sb); }
Greg Kroah-Hartman
maintainerPATCH 557/591 btrfs: bail out reclaim process if filesystem is read-only
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 93463ff7b54626f8276c0bd3d3f968fbf8d5d380 upstream.
When a filesystem is read-only, we cannot reclaim a block group as it cannot rewrite the data. Just bail out in that case.
Note that it can drop block groups in this case. As we did sb_start_write(), read-only filesystem means we got a fatal error and forced read-only. There is no chance to reclaim them again.
--- fs/btrfs/block-group.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/btrfs/block-group.c +9 -2
@@ -1603,8 +1603,15 @@ void btrfs_reclaim_bgs_work(struct work_ }spin_unlock (&bg->lock); -/* Get out fast, in case we're unmounting the filesystem */ -if (btrfs_fs_closing (fs_info)) { +/* +* Get out fast, in case we're read-only or unmounting the +* filesystem. It is OK to drop block groups from the list even +* for the read-only case. As we did sb_start_write(), +* "mount -o remount,ro" won't happen and read-only filesystem +* means it is forced read-only due to a fatal error. So, it +* never gets back to read-write to let us reclaim again. +*/ +if (btrfs_need_cleaner_sleep (fs_info)) {up_write (&space_info->groups_sem); goto next; }
Greg Kroah-Hartman
maintainerPATCH 558/591 btrfs: add block-group tree to lockdep classes
In reply to Greg Kroah-HartmanFrom: David Sterba <[email protected]>
commit 1a1b0e729d227f9f758f7b5f1c997e874e94156e upstream.
The block group tree was not present among the lockdep classes. We could get potentially lockdep warnings but so far none has been seen, also because block-group-tree is a relatively new feature.
--- fs/btrfs/locking.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/locking.c +3 -2
@@ -56,8 +56,8 @@static struct btrfs_lockdep_keyset {u64 id;/* root objectid */ -/* Longest entry: btrfs-free-space-00 */ -char names[BTRFS_MAX_LEVEL ][20 ]; +/* Longest entry: btrfs-block-group-00 */ +char names[BTRFS_MAX_LEVEL ][24 ];struct lock_class_key keys[BTRFS_MAX_LEVEL ]; } btrfs_lockdep_keysets[] = { { .id =BTRFS_ROOT_TREE_OBJECTID ,DEFINE_NAME ("root" ) },
@@ -71,6 +71,7 @@ static struct btrfs_lockdep_keyset { { .id = BTRFS_DATA_RELOC_TREE_OBJECTID, DEFINE_NAME("dreloc") }, { .id = BTRFS_UUID_TREE_OBJECTID, DEFINE_NAME("uuid") }, { .id = BTRFS_FREE_SPACE_TREE_OBJECTID, DEFINE_NAME("free-space") }, + { .id = BTRFS_BLOCK_GROUP_TREE_OBJECTID, DEFINE_NAME("block-group") }, { .id = 0, DEFINE_NAME("tree") }, };
Greg Kroah-Hartman
maintainerPATCH 559/591 btrfs: reinsert BGs failed to reclaim
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit 7e27180994383b7c741ad87749db01e4989a02ba upstream.
The reclaim process can temporarily fail. For example, if the space is getting tight, it fails to make the block group read-only. If there are no further writes on that block group, the block group will never get back to the reclaim list, and the BG never gets reclaimed. In a certain workload, we can leave many such block groups never reclaimed.
So, let's get it back to the list and give it a chance to be reclaimed.
--- fs/btrfs/block-group.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/block-group.c +2 -0
@@ -1642,6 +1642,8 @@ void btrfs_reclaim_bgs_work(struct work_ } next: +if (ret) +btrfs_mark_bg_to_reclaim (bg);btrfs_put_block_group (bg);mutex_unlock (&fs_info->reclaim_bgs_lock);
Greg Kroah-Hartman
maintainerPATCH 560/591 btrfs: move out now unused BG from the reclaim list
In reply to Greg Kroah-HartmanFrom: Naohiro Aota <[email protected]>
commit a9f189716cf15913c453299d72f69c51a9b0f86b upstream.
An unused block group is easy to remove to free up space and should be reclaimed fast. Such block group can often already be a target of the reclaim process. As we check list_empty(&bg->bg_list), we keep it in the reclaim list. That block group is never reclaimed until the file system is filled e.g. up to 75%.
Instead, we can move unused block group to the unused list and delete it fast.
--- fs/btrfs/block-group.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/btrfs/block-group.c +4 -1
@@ -1503,11 +1503,14 @@ void btrfs_mark_bg_unused(struct btrfs_b {struct btrfs_fs_info *fs_info = bg->fs_info; +trace_btrfs_add_unused_block_group (bg);spin_lock (&fs_info->unused_bgs_lock);if (list_empty (&bg->bg_list)) {btrfs_get_block_group (bg); -trace_btrfs_add_unused_block_group (bg);list_add_tail (&bg->bg_list, &fs_info->unused_bgs); + }else { +/* Pull out the block group from the reclaim_bgs list. */ +list_move_tail (&bg->bg_list, &fs_info->unused_bgs); }spin_unlock (&fs_info->unused_bgs_lock); }
Greg Kroah-Hartman
maintainerPATCH 561/591 btrfs: fix race when deleting quota root from the dirty cow roots list
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit b31cb5a6eb7a48b0a7bfdf06832b1fd5088d8c79 upstream.
When disabling quotas we are deleting the quota root from the list fs_info->dirty_cowonly_roots without taking the lock that protects it, which is struct btrfs_fs_info::trans_lock. This unsynchronized list manipulation may cause chaos if there's another concurrent manipulation of this list, such as when adding a root to it with ctree.c:add_root_to_dirty_list().
This can result in all sorts of weird failures caused by a race, such as the following crash:
[337571.278245] general protection fault, probably for non-canonical address 0xdead000000000108: 0000 [#1] PREEMPT SMP PTI [337571.278933] CPU: 1 PID: 115447 Comm: btrfs Tainted: G W 6.4.0-rc6-btrfs-next-134+ #1 [337571.279153] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/2014 [337571.279572] RIP: 0010:commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.279928] Code: 85 38 06 00 (...) [337571.280363] RSP: 0018:ffff9f63446efba0 EFLAGS: 00010206 [337571.280582] RAX: ffff942d98ec2638 RBX: ffff9430b82b4c30 RCX: 0000000449e1c000 [337571.280798] RDX: dead000000000100 RSI: ffff9430021e4900 RDI: 0000000000036070 [337571.281015] RBP: ffff942d98ec2000 R08: ffff942d98ec2000 R09: 000000000000015b [337571.281254] R10: 0000000000000009 R11: 0000000000000001 R12: ffff942fe8fbf600 [337571.281476] R13: ffff942dabe23040 R14: ffff942dabe20800 R15: ffff942d92cf3b48 [337571.281723] FS: 00007f478adb7340(0000) GS:ffff94349fa40000(0000) knlGS:0000000000000000 [337571.281950] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [337571.282184] CR2: 00007f478ab9a3d5 CR3: 000000001e02c001 CR4: 0000000000370ee0 [337571.282416] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [337571.282647] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [337571.282874] Call Trace: [337571.283101] <TASK> [337571.283327] ? __die_body+0x1b/0x60 [337571.283570] ? die_addr+0x39/0x60 [337571.283796] ? exc_general_protection+0x22e/0x430 [337571.284022] ? asm_exc_general_protection+0x22/0x30 [337571.284251] ? commit_cowonly_roots+0x11f/0x250 [btrfs] [337571.284531] btrfs_commit_transaction+0x42e/0xf90 [btrfs] [337571.284803] ? _raw_spin_unlock+0x15/0x30 [337571.285031] ? release_extent_buffer+0x103/0x130 [btrfs] [337571.285305] reset_balance_state+0x152/0x1b0 [btrfs] [337571.285578] btrfs_balance+0xa50/0x11e0 [btrfs] [337571.285864] ? __kmem_cache_alloc_node+0x14a/0x410 [337571.286086] btrfs_ioctl+0x249a/0x3320 [btrfs] [337571.286358] ? mod_objcg_state+0xd2/0x360 [337571.286577] ? refill_obj_stock+0xb0/0x160 [337571.286798] ? seq_release+0x25/0x30 [337571.287016] ? __rseq_handle_notify_resume+0x3ba/0x4b0 [337571.287235] ? percpu_counter_add_batch+0x2e/0xa0 [337571.287455] ? __x64_sys_ioctl+0x88/0xc0 [337571.287675] __x64_sys_ioctl+0x88/0xc0 [337571.287901] do_syscall_64+0x38/0x90 [337571.288126] entry_SYSCALL_64_after_hwframe+0x72/0xdc [337571.288352] RIP: 0033:0x7f478aaffe9b
So fix this by locking struct btrfs_fs_info::trans_lock before deleting the quota root from that list.
--- fs/btrfs/qgroup.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/qgroup.c +2 -0
@@ -1296,7 +1296,9 @@ int btrfs_quota_disable(struct btrfs_fs_ goto out; } +spin_lock (&fs_info->trans_lock);list_del ("a_root->dirty_list); +spin_unlock (&fs_info->trans_lock);btrfs_tree_lock (quota_root->node);btrfs_clean_tree_block (quota_root->node);
Greg Kroah-Hartman
maintainerPATCH 562/591 btrfs: fix extent buffer leak after tree mod log failure at split_node()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit ede600e497b1461d06d22a7d17703d9096868bc3 upstream.
At split_node(), if we fail to log the tree mod log copy operation, we return without unlocking the split extent buffer we just allocated and without decrementing the reference we own on it. Fix this by unlocking it and decrementing the ref count before returning.
--- fs/btrfs/ctree.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/ctree.c +2 -0
@@ -2861,6 +2861,8 @@ static noinline int split_node(struct bt ret =btrfs_tree_mod_log_eb_copy (split, c,0 , mid, c_nritems - mid);if (ret) { +btrfs_tree_unlock (split); +free_extent_buffer (split);btrfs_abort_transaction (trans, ret);return ret; }
Greg Kroah-Hartman
maintainerPATCH 563/591 btrfs: do not BUG_ON() on tree mod log failure at __btrfs_cow_block()
In reply to Greg Kroah-HartmanFrom: Filipe Manana <[email protected]>
commit 40b0a749388517de244643c09bdbb98f7dcb6ef1 upstream.
At __btrfs_cow_block(), instead of doing a BUG_ON() in case we fail to record a tree mod log root insertion operation, do a transaction abort instead. There's really no need for the BUG_ON(), we can properly release all resources in this context and turn the filesystem to RO mode and in an error state instead.
--- fs/btrfs/ctree.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fs/btrfs/ctree.c +7 -2
@@ -475,9 +475,14 @@ static noinline int __btrfs_cow_block(st btrfs_header_backref_rev(buf) < BTRFS_MIXED_BACKREF_REV) parent_start = buf->start; -atomic_inc (&cow->refs); ret =btrfs_tree_mod_log_insert_root (root->node, cow, true); -BUG_ON (ret <0 ); +if (ret <0 ) { +btrfs_tree_unlock (cow); +free_extent_buffer (cow); +btrfs_abort_transaction (trans, ret); +return ret; + } +atomic_inc (&cow->refs);rcu_assign_pointer (root->node, cow); btrfs_free_tree_block(trans, btrfs_root_id(root), buf,
Greg Kroah-Hartman
maintainerPATCH 564/591 ASoC: mediatek: mt8173: Fix irq error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit f9c058d14f4fe23ef523a7ff73734d51c151683c upstream.
After reordering the irq probe, the error path was not properly done. Lets fix it.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +5 -4
@@ -1070,6 +1070,10 @@ static int mt8173_afe_pcm_dev_probe(stru afe->dev = &pdev->dev; + irq_id =platform_get_irq (pdev,0 ); +if (irq_id <=0 ) +return irq_id <0 ? irq_id : -ENXIO ; + afe->base_addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (afe->base_addr))return PTR_ERR (afe->base_addr);
@@ -1175,14 +1179,11 @@ static int mt8173_afe_pcm_dev_probe(struif (ret) goto err_cleanup_components; - irq_id =platform_get_irq (pdev,0 ); -if (irq_id <=0 ) -return irq_id <0 ? irq_id : -ENXIO ; ret =devm_request_irq (afe->dev, irq_id, mt8173_afe_irq_handler,0 ,"Afe_ISR_Handle" , (void *)afe);if (ret) {dev_err (afe->dev,"could not request_irq\n" ); - goto err_pm_disable; + goto err_cleanup_components; }dev_info (&pdev->dev,"MT8173 AFE driver initialized.\n" );
Greg Kroah-Hartman
maintainerPATCH 565/591 ASoC: mediatek: mt8173: Fix snd_soc_component_initialize error path
In reply to Greg Kroah-HartmanFrom: Ricardo Ribalda Delgado <[email protected]>
commit a46d37012a5be1737393b8f82fd35665e4556eee upstream.
If the second component fails to initialize, cleanup the first on.
--- sound/soc/mediatek/mt8173/mt8173-afe-pcm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/mediatek/mt8173/mt8173-afe-pcm.c +2 -2
@@ -1160,14 +1160,14 @@ static int mt8173_afe_pcm_dev_probe(stru comp_hdmi =devm_kzalloc (&pdev->dev,sizeof (*comp_hdmi),GFP_KERNEL );if (!comp_hdmi) { ret = -ENOMEM ; - goto err_pm_disable; + goto err_cleanup_components; } ret =snd_soc_component_initialize (comp_hdmi, &mt8173_afe_hdmi_dai_component, &pdev->dev);if (ret) - goto err_pm_disable; + goto err_cleanup_components;#ifdef CONFIG_DEBUG_FS comp_hdmi->debugfs_prefix ="hdmi" ;
Greg Kroah-Hartman
maintainerPATCH 566/591 regulator: tps65219: Fix matching interrupts for their regulators
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit f050e56de80591fee55bedbdf5b6b998c740cd0c upstream.
The driver's probe() first registers regulators in a loop and then in a second loop passes them as irq data to the interrupt handlers. However the function to get the regulator for given name tps65219_get_rdev_by_name() was a no-op due to argument passed by value, not pointer, thus the second loop assigned always same value - from previous loop. The interrupts, when fired, where executed with wrong data. Compiler also noticed it:
drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]
--- drivers/regulator/tps65219-regulator.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/tps65219-regulator.c +3 -3
@@ -289,13 +289,13 @@ static irqreturn_t tps65219_regulator_irstatic int tps65219_get_rdev_by_name (const char *regulator_name,struct regulator_dev *rdevtbl[7 ], -struct regulator_dev *dev) +struct regulator_dev **dev) {int i;for (i =0 ; i <ARRAY_SIZE (regulators); i++) {if (strcmp (regulator_name, regulators[i].name) ==0 ) { - dev = rdevtbl[i]; + *dev = rdevtbl[i];return 0 ; } }
@@ -348,7 +348,7 @@ static int tps65219_regulator_probe(stru irq_data[i].dev = tps->dev; irq_data[i].type = irq_type; -tps65219_get_rdev_by_name (irq_type->regulator_name, rdevtbl, rdev); +tps65219_get_rdev_by_name (irq_type->regulator_name, rdevtbl, &rdev);if (IS_ERR (rdev)) {dev_err (tps->dev,"Failed to get rdev for %s\n" , irq_type->regulator_name);
Greg Kroah-Hartman
maintainerPATCH 567/591 ARM: dts: qcom: ipq4019: fix broken NAND controller properties override
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
commit edcbdd57de499305e2a3737d4a73fe387f71d84c upstream.
After renaming NAND controller node name from "qpic-nand" to "nand-controller", the board DTS/DTSI also have to be updated:
Warning (unit_address_vs_reg): /soc/qpic-nand@79b0000: node has a unit name, but no reg or ranges property
--- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts | 8 ++++---- arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi | 10 +++++----- arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi | 12 ++++++------ 3 files changed, 15 insertions(+), 15 deletions(-)
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts +4 -4
@@ -11,9 +11,9 @@ dma-controller@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - status = "okay"; - }; }; }; + +&nand { + status = "okay"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi +5 -5
@@ -102,10 +102,10 @@ status = "okay"; perst-gpios = <&tlmm 38 GPIO_ACTIVE_LOW>; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; +};
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi +6 -6
@@ -65,11 +65,11 @@ dma-controller@7984000 { status = "okay"; }; - - qpic-nand@79b0000 { - pinctrl-0 = <&nand_pins>; - pinctrl-names = "default"; - status = "okay"; - }; }; }; + +&nand { + pinctrl-0 = <&nand_pins>; + pinctrl-names = "default"; + status = "okay"; +};
Greg Kroah-Hartman
maintainerPATCH 568/591 ARM: orion5x: fix d2net gpio initialization
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
commit f8ef1233939495c405a9faa4bd1ae7d3f581bae4 upstream.
The DT version of this board has a custom file with the gpio device. However, it does nothing because the d2net_init() has no caller or prototype:
arch/arm/mach-orion5x/board-d2net.c:101:13: error: no previous prototype for 'd2net_init'
Call it from the board-dt file as intended.
--- arch/arm/mach-orion5x/board-dt.c | 3 +++ arch/arm/mach-orion5x/common.h | 6 ++++++ 2 files changed, 9 insertions(+)
arch/arm/mach-orion5x/board-dt.c +3 -0
@@ -60,6 +60,9 @@ static void __init orion5x_dt_init(void)if (of_machine_is_compatible ("maxtor,shared-storage-2" ))mss2_init (); +if (of_machine_is_compatible ("lacie,d2-network" )) +d2net_init (); +of_platform_default_populate (NULL , orion5x_auxdata_lookup,NULL ); }
arch/arm/mach-orion5x/common.h +6 -0
@@ -75,6 +75,12 @@ extern void mss2_init(void);static inline void mss2_init (void ) {}#endif +#ifdef CONFIG_MACH_D2NET_DT +void d2net_init (void ); +#else +static inline void d2net_init (void ) {} +#endif +/***************************************************************************** * Helpers to access Orion registers ****************************************************************************/
Greg Kroah-Hartman
maintainerPATCH 569/591 leds: trigger: netdev: Recheck NETDEV_LED_MODE_LINKUP on dev rename
In reply to Greg Kroah-HartmanFrom: Christian Marangi <[email protected]>
commit cee4bd16c3195a701be683f7da9e88c6e11acb73 upstream.
Dev can be renamed also while up for supported device. We currently wrongly clear the NETDEV_LED_MODE_LINKUP flag on NETDEV_CHANGENAME event.
Fix this by rechecking if the carrier is ok on NETDEV_CHANGENAME and correctly set the NETDEV_LED_MODE_LINKUP bit.
--- drivers/leds/trigger/ledtrig-netdev.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/leds/trigger/ledtrig-netdev.c +3 -0
@@ -318,6 +318,9 @@ static int netdev_trig_notify(struct notclear_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode);switch (evt) {case NETDEV_CHANGENAME : +if (netif_carrier_ok (dev)) +set_bit (NETDEV_LED_MODE_LINKUP , &trigger_data->mode); + fallthrough;case NETDEV_REGISTER :if (trigger_data->net_dev)dev_put (trigger_data->net_dev);
Greg Kroah-Hartman
maintainerPATCH 570/591 blktrace: use inline function for blk_trace_remove() while blktrace is disabled
In reply to Greg Kroah-HartmanFrom: Yu Kuai <[email protected]>
commit cbe7cff4a76bc749dd70264ca5cf924e2adf9296 upstream.
If config is disabled, call blk_trace_remove() directly will trigger build warning, hence use inline function instead, prepare to fix blktrace debugfs entries leakage.
--- include/linux/blktrace_api.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/linux/blktrace_api.h +5 -1
@@ -85,10 +85,14 @@ extern int blk_trace_remove(struct reque# define blk_add_driver_data (rq, data, len) do {} while (0)# define blk_trace_setup (q, name, dev, bdev, arg) (-ENOTTY)# define blk_trace_startstop (q, start) (-ENOTTY) -# define blk_trace_remove (q) (-ENOTTY)# define blk_add_trace_msg (q, fmt, ...) do { } while (0)# define blk_add_cgroup_trace_msg (q, cg, fmt, ...) do { } while (0)# define blk_trace_note_message_enabled (q) (false) + +static inline int blk_trace_remove (struct request_queue *q) +{ +return -ENOTTY ; +}#endif /* CONFIG_BLK_DEV_IO_TRACE */ #ifdef CONFIG_COMPAT
Greg Kroah-Hartman
maintainerPATCH 571/591 fs: no need to check source
In reply to Greg Kroah-HartmanFrom: Jan Kara <[email protected]>
commit 66d8fc0539b0d49941f313c9509a8384e4245ac1 upstream.
The @source inode must be valid. It is even checked via IS_SWAPFILE() above making it pretty clear. So no need to check it when we unlock.
What doesn't need to exist is the @target inode. The lock_two_inodes() helper currently swaps the @inode1 and @inode2 arguments if @inode1 is NULL to have consistent lock class usage. However, we know that at least for vfs_rename() that @inode1 is @source and thus is never NULL as per above. We also know that @source is a different inode than @target as that is checked right at the beginning of vfs_rename(). So we know that @source is valid and locked and that @target is locked. So drop the check whether @source is non-NULL.
Message-Id: <[email protected]>
--- fs/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/namei.c +1 -2
@@ -4802,8 +4802,7 @@ int vfs_rename(struct renamedata *rd)d_exchange (old_dentry, new_dentry); } out: -if (source) -inode_unlock (source); +inode_unlock (source);if (target)inode_unlock (target);dput (new_dentry);