6.1.2-rc1 review
Subsystems (14)
Greg Kroah-Hartman
maintainerPATCH 675/1146 RDMA/hns: Fix error code of CMD
In reply to Greg Kroah-HartmanFrom: Chengchang Tang <[email protected]>
[ Upstream commit 667d6164b84884c64de3fc18670cd5a98b0b10cf ]
The error code is fixed to EIO when CMD fails to excute. This patch converts the error status reported by firmware to linux errno.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 26 +++++++++++++++++++++- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +25 -1
@@ -1273,6 +1273,30 @@ static void update_cmdq_status(struct hns_roce_dev *hr_dev) hr_dev->cmd.state =HNS_ROCE_CMDQ_STATE_FATAL_ERR ; } +static int hns_roce_cmd_err_convert_errno (u16 desc_ret) +{ +struct hns_roce_cmd_errcode errcode_table[] = { + {CMD_EXEC_SUCCESS ,0 }, + {CMD_NO_AUTH , -EPERM }, + {CMD_NOT_EXIST , -EOPNOTSUPP }, + {CMD_CRQ_FULL , -EXFULL }, + {CMD_NEXT_ERR , -ENOSR }, + {CMD_NOT_EXEC , -ENOTBLK }, + {CMD_PARA_ERR , -EINVAL }, + {CMD_RESULT_ERR , -ERANGE }, + {CMD_TIMEOUT , -ETIME }, + {CMD_HILINK_ERR , -ENOLINK }, + {CMD_INFO_ILLEGAL , -ENXIO }, + {CMD_INVALID , -EBADR }, + }; +u16 i; + +for (i =0 ; i <ARRAY_SIZE (errcode_table); i++) +if (desc_ret == errcode_table[i].return_status) +return errcode_table[i].errno; +return -EIO ; +} +static int __hns_roce_cmq_send (struct hns_roce_dev *hr_dev,struct hns_roce_cmq_desc *desc,int num) {
@@ -1318,7 +1342,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev,dev_err_ratelimited (hr_dev->dev,"Cmdq IO error, opcode = 0x%x, return = 0x%x.\n" , desc->opcode, desc_ret); - ret = -EIO ; + ret =hns_roce_cmd_err_convert_errno (desc_ret); } }else {/* FW/HW reset or incorrect number of desc */
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +5 -0
@@ -272,6 +272,11 @@ enum hns_roce_cmd_return_status {CMD_OTHER_ERR =0xff }; +struct hns_roce_cmd_errcode { +enum hns_roce_cmd_return_status return_status; +int errno; +}; +enum hns_roce_sgid_type {GID_TYPE_FLAG_ROCE_V1 =0 ,GID_TYPE_FLAG_ROCE_V2_IPV4 ,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 676/1146 RDMA/hns: Fix XRC caps on HIP08
In reply to Greg Kroah-HartmanFrom: Chengchang Tang <[email protected]>
[ Upstream commit 682c0722addae4b4a1440c9db9d8c86cb8e09ce5 ]
XRC caps has been set by default. But in fact, XRC is not supported in HIP08.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -2
@@ -2047,13 +2047,14 @@ static void set_default_caps(struct hns_roce_dev *hr_dev) caps->flags |=HNS_ROCE_CAP_FLAG_ATOMIC |HNS_ROCE_CAP_FLAG_MW |HNS_ROCE_CAP_FLAG_SRQ |HNS_ROCE_CAP_FLAG_FRMR | -HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL |HNS_ROCE_CAP_FLAG_XRC ; +HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL ; caps->gid_table_len[0 ] =HNS_ROCE_V2_GID_INDEX_NUM ;if (hr_dev->pci_dev->revision >=PCI_REVISION_ID_HIP09 ) { caps->flags |=HNS_ROCE_CAP_FLAG_STASH | -HNS_ROCE_CAP_FLAG_DIRECT_WQE ; +HNS_ROCE_CAP_FLAG_DIRECT_WQE | +HNS_ROCE_CAP_FLAG_XRC ; caps->max_sq_inline =HNS_ROCE_V3_MAX_SQ_INLINE ; }else { caps->max_sq_inline =HNS_ROCE_V2_MAX_SQ_INLINE ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 677/1146 RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path
In reply to Greg Kroah-HartmanFrom: Andrew Bresticker <[email protected]>
[ Upstream commit b0f4c74eadbf69a3298f38566bfaa2e202541f2f ]
The return to userspace path in entry.S may enable interrupts without the corresponding lockdep annotation, producing a splat[0] when DEBUG_LOCKDEP is enabled. Simply calling __trace_hardirqs_on() here gets a bit messy due to the use of RA to point back to ret_from_exception, so just move the whole slow-path loop into C. It's more readable and it lets us use local_irq_{enable,disable}(), avoiding the need for manual annotations altogether.
[0]:
------------[ cut here ]------------ DEBUG_LOCKS_WARN_ON(!lockdep_hardirqs_enabled()) WARNING: CPU: 2 PID: 1 at kernel/locking/lockdep.c:5512 check_flags+0x10a/0x1e0 Modules linked in: CPU: 2 PID: 1 Comm: init Not tainted 6.1.0-rc4-00160-gb56b6e2b4f31 #53 Hardware name: riscv-virtio,qemu (DT) epc : check_flags+0x10a/0x1e0 ra : check_flags+0x10a/0x1e0 <snip> status: 0000000200000100 badaddr: 0000000000000000 cause: 0000000000000003 [<ffffffff808edb90>] lock_is_held_type+0x78/0x14e [<ffffffff8003dae2>] __might_resched+0x26/0x22c [<ffffffff8003dd24>] __might_sleep+0x3c/0x66 [<ffffffff80022c60>] get_signal+0x9e/0xa70 [<ffffffff800054a2>] do_notify_resume+0x6e/0x422 [<ffffffff80003c68>] ret_from_exception+0x0/0x10 irq event stamp: 44512 hardirqs last enabled at (44511): [<ffffffff808f901c>] _raw_spin_unlock_irqrestore+0x54/0x62 hardirqs last disabled at (44512): [<ffffffff80008200>] __trace_hardirqs_off+0xc/0x14 softirqs last enabled at (44472): [<ffffffff808f9fbe>] __do_softirq+0x3de/0x51e softirqs last disabled at (44467): [<ffffffff80017760>] irq_exit+0xd6/0x104 ---[ end trace 0000000000000000 ]--- possible reason: unannotated irqs-on.
--- arch/riscv/kernel/entry.S | 18 +++++------------- arch/riscv/kernel/signal.c | 34 +++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 26 deletions(-)
arch/riscv/kernel/entry.S +5 -13
@@ -263,12 +263,11 @@ ret_from_exception: #endif bnez s0, resume_kernel -resume_userspace: /* Interrupts must be disabled here so flags are checked atomically */ REG_L s0, TASK_TI_FLAGS(tp) /* current_thread_info->flags */ andi s1, s0, _TIF_WORK_MASK - bnez s1, work_pending - + bnez s1, resume_userspace_slow +resume_userspace: #ifdef CONFIG_CONTEXT_TRACKING_USER call user_enter_callable #endif
@@ -368,19 +367,12 @@ resume_kernel: j restore_all #endif -work_pending: +resume_userspace_slow: /* Enter slow path for supplementary processing */ - la ra, ret_from_exception - andi s1, s0, _TIF_NEED_RESCHED - bnez s1, work_resched -work_notifysig: - /* Handle pending signals and notify-resume requests */ - csrs CSR_STATUS, SR_IE /* Enable interrupts for do_notify_resume() */ move a0, sp /* pt_regs */ move a1, s0 /* current_thread_info->flags */ - tail do_notify_resume -work_resched: - tail schedule + call do_work_pending + j resume_userspace /* Slow paths for ptrace. */ handle_syscall_trace_enter:
arch/riscv/kernel/signal.c +21 -13
@@ -313,19 +313,27 @@ static void do_signal(struct pt_regs *regs) }/* -* notification of userspace execution resumption -* - triggered by the _TIF_WORK_MASK flags +* Handle any pending work on the resume-to-userspace path, as indicated by +* _TIF_WORK_MASK. Entered from assembly with IRQs off. */ -asmlinkage __visible void do_notify_resume(struct pt_regs *regs, -unsigned long thread_info_flags) +asmlinkage __visible void do_work_pending(struct pt_regs *regs, +unsigned long thread_info_flags) { -if (thread_info_flags & _TIF_UPROBE) -uprobe_notify_resume (regs); - -/* Handle pending signal delivery */ -if (thread_info_flags & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) -do_signal (regs); - -if (thread_info_flags & _TIF_NOTIFY_RESUME) -resume_user_mode_work (regs); +do { +if (thread_info_flags & _TIF_NEED_RESCHED) { +schedule (); + }else { +local_irq_enable (); +if (thread_info_flags & _TIF_UPROBE) +uprobe_notify_resume (regs); +/* Handle pending signal delivery */ +if (thread_info_flags & (_TIF_SIGPENDING | + _TIF_NOTIFY_SIGNAL)) +do_signal (regs); +if (thread_info_flags & _TIF_NOTIFY_RESUME) +resume_user_mode_work (regs); + } +local_irq_disable (); + thread_info_flags =read_thread_flags (); + }while (thread_info_flags & _TIF_WORK_MASK); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 678/1146 RISC-V: Fix MEMREMAP_WB for systems with Svpbmt
In reply to Greg Kroah-HartmanFrom: Anup Patel <[email protected]>
[ Upstream commit b91676fc16cd384a81e3af52c641aa61985cc231 ]
Currently, the memremap() called with MEMREMAP_WB maps memory using the generic ioremap() function which breaks on system with Svpbmt because memory mapped using _PAGE_IOREMAP page attributes is treated as strongly-ordered non-cacheable IO memory.
To address this, we implement RISC-V specific arch_memremap_wb() which maps memory using _PAGE_KERNEL page attributes resulting in write-back cacheable mapping on systems with Svpbmt.
--- arch/riscv/include/asm/io.h | 5 +++++ 1 file changed, 5 insertions(+)
arch/riscv/include/asm/io.h +5 -0
@@ -135,4 +135,9 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw())#include <asm-generic/io.h> +#ifdef CONFIG_MMU +#define arch_memremap_wb (addr, size) \ + ((__force void *)ioremap_prot((addr), (size), _PAGE_KERNEL)) +#endif +#endif /* _ASM_RISCV_IO_H */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 679/1146 riscv: Fix crash during early errata patching
In reply to Greg Kroah-HartmanFrom: Samuel Holland <[email protected]>
[ Upstream commit 0c49688174f5347c3f8012e84c0ffa0d2b2890c8 ]
The patch function for the T-Head PBMT errata calls __pa_symbol() before relocation. This crashes when CONFIG_DEBUG_VIRTUAL is enabled, because __pa_symbol() forwards to __phys_addr_symbol(), and __phys_addr_symbol() checks against the absolute kernel start/end address.
Fix this by checking against the kernel map instead of a symbol address.
--- arch/riscv/mm/physaddr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/physaddr.c +1 -1
@@ -22,7 +22,7 @@ EXPORT_SYMBOL(__virt_to_phys);phys_addr_t __phys_addr_symbol (unsigned long x) {unsigned long kernel_start = kernel_map.virt_addr; -unsigned long kernel_end = (unsigned long )_end; +unsigned long kernel_end = kernel_start + kernel_map.size;/* * Boundary checking aginst the kernel image mapping.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 680/1146 crypto: img-hash - Fix variable dereferenced before check hdev->req
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 04ba54e5af8f8f0137b08cb51a0b3a2e1ea46c94 ]
Smatch report warning as follows:
drivers/crypto/img-hash.c:366 img_hash_dma_task() warn: variable dereferenced before check 'hdev->req'
Variable dereferenced should be done after check 'hdev->req', fix it.
--- drivers/crypto/img-hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/crypto/img-hash.c +6 -2
@@ -358,12 +358,16 @@ static int img_hash_dma_init(struct img_hash_dev *hdev)static void img_hash_dma_task (unsigned long d) {struct img_hash_dev *hdev = (struct img_hash_dev *)d; -struct img_hash_request_ctx *ctx =ahash_request_ctx (hdev->req); +struct img_hash_request_ctx *ctx;u8 *addr;size_t nbytes, bleft, wsend, len, tbc;struct scatterlist tsg; -if (!hdev->req || !ctx->sg) +if (!hdev->req) +return ; + + ctx =ahash_request_ctx (hdev->req); +if (!ctx->sg)return ; addr =sg_virt (ctx->sg);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 681/1146 hwrng: amd - Fix PCI device refcount leak
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit ecadb5b0111ea19fc7c240bb25d424a94471eb7d ]
for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL.
If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. Add the missing pci_dev_put() for the normal and error path.
--- drivers/char/hw_random/amd-rng.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/char/hw_random/amd-rng.c +13 -5
@@ -143,15 +143,19 @@ static int __init amd_rng_mod_init(void) found: err =pci_read_config_dword (pdev,0x58 , &pmbase);if (err) -return err; + goto put_dev; pmbase &=0x0000FF00 ; -if (pmbase ==0 ) -return -EIO ; +if (pmbase ==0 ) { + err = -EIO ; + goto put_dev; + } priv =kzalloc (sizeof (*priv),GFP_KERNEL ); -if (!priv) -return -ENOMEM ; +if (!priv) { + err = -ENOMEM ; + goto put_dev; + }if (!request_region (pmbase +PMBASE_OFFSET ,PMBASE_SIZE ,DRV_NAME )) { dev_err(&pdev->dev, DRV_NAME " region 0x%x already in use!\n",
@@ -185,6 +189,8 @@ static int __init amd_rng_mod_init(void)release_region (pmbase +PMBASE_OFFSET ,PMBASE_SIZE ); out:kfree (priv); +put_dev: +pci_dev_put (pdev);return err; }
@@ -200,6 +206,8 @@ static void __exit amd_rng_mod_exit(void)release_region (priv->pmbase +PMBASE_OFFSET ,PMBASE_SIZE ); +pci_dev_put (priv->pcidev); +kfree (priv); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 682/1146 hwrng: geode - Fix PCI device refcount leak
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 9f6ec8dc574efb7f4f3d7ee9cd59ae307e78f445 ]
for_each_pci_dev() is implemented by pci_get_device(). The comment of pci_get_device() says that it will increase the reference count for the returned pci_dev and also decrease the reference count for the input pci_dev @from if it is not NULL.
If we break for_each_pci_dev() loop with pdev not NULL, we need to call pci_dev_put() to decrease the reference count. We add a new struct 'amd_geode_priv' to record pointer of the pci_dev and membase, and then add missing pci_dev_put() for the normal and error path.
--- drivers/char/hw_random/geode-rng.c | 36 +++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-)
drivers/char/hw_random/geode-rng.c +28 -8
@@ -51,6 +51,10 @@ static const struct pci_device_id pci_tbl[] = { };MODULE_DEVICE_TABLE (pci, pci_tbl); +struct amd_geode_priv { +struct pci_dev *pcidev; +void __iomem *membase; +};static int geode_rng_data_read (struct hwrng *rng,u32 *data) {
@@ -90,6 +94,7 @@ static int __init geode_rng_init(void)const struct pci_device_id *ent;void __iomem *mem;unsigned long rng_base; +struct amd_geode_priv *priv;for_each_pci_dev (pdev) { ent =pci_match_id (pci_tbl, pdev);
@@ -97,17 +102,26 @@ static int __init geode_rng_init(void) goto found; }/* Device not found. */ - goto out; +return err; found: + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) { + err = -ENOMEM ; + goto put_dev; + } + rng_base =pci_resource_start (pdev,0 );if (rng_base ==0 ) - goto out; + goto free_priv; err = -ENOMEM ; mem =ioremap (rng_base,0x58 );if (!mem) - goto out; - geode_rng.priv = (unsigned long )mem; + goto free_priv; + + geode_rng.priv = (unsigned long )priv; + priv->membase = mem; + priv->pcidev = pdev;pr_info ("AMD Geode RNG detected\n" ); err =hwrng_register (&geode_rng);
@@ -116,20 +130,26 @@ static int __init geode_rng_init(void) err); goto err_unmap; } -out:return err; err_unmap:iounmap (mem); - goto out; +free_priv: +kfree (priv); +put_dev: +pci_dev_put (pdev); +return err; } static void __exit geode_rng_exit(void) { -void __iomem *mem = (void __iomem *)geode_rng.priv; +struct amd_geode_priv *priv; + priv = (struct amd_geode_priv *)geode_rng.priv;hwrng_unregister (&geode_rng); -iounmap (mem); +iounmap (priv->membase); +pci_dev_put (priv->pcidev); +kfree (priv); }module_init (geode_rng_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 683/1146 IB/IPoIB: Fix queue count inconsistency for PKEY child interfaces
In reply to Greg Kroah-HartmanFrom: Dragos Tatulea <[email protected]>
[ Upstream commit dbc94a0fb81771a38733c0e8f2ea8c4fa6934dc1 ]
There are 2 ways to create IPoIB PKEY child interfaces:
1) Writing a PKEY to /sys/class/net/<ib parent interface>/create_child.
2) Using netlink with iproute.
While with sysfs the child interface has the same number of tx and rx queues as the parent, with netlink there will always be 1 tx and 1 rx queue for the child interface. That's because the get_num_tx/rx_queues() netlink ops are missing and the default value of 1 is taken for the number of queues (in rtnl_create_link()).
This change adds the get_num_tx/rx_queues() ops which allows for interfaces with multiple queues to be created over netlink. This constant only represents the max number of tx and rx queues on that net device.
--- drivers/infiniband/ulp/ipoib/ipoib_netlink.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_netlink.c +7 -0
@@ -41,6 +41,11 @@ static const struct nla_policy ipoib_policy[IFLA_IPOIB_MAX + 1] = { [IFLA_IPOIB_UMCAST] = { .type = NLA_U16 }, }; +static unsigned int ipoib_get_max_num_queues (void ) +{ + return min_t(unsigned int, num_possible_cpus(), 128); +} +static int ipoib_fill_info (struct sk_buff *skb,const struct net_device *dev) {struct ipoib_dev_priv *priv =ipoib_priv (dev);
@@ -172,6 +177,8 @@ static struct rtnl_link_ops ipoib_link_ops __read_mostly = { .changelink = ipoib_changelink, .get_size = ipoib_get_size, .fill_info = ipoib_fill_info, + .get_num_rx_queues = ipoib_get_max_num_queues, + .get_num_tx_queues = ipoib_get_max_num_queues, };struct rtnl_link_ops *ipoib_get_link_ops (void )
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 684/1146 RISC-V: Align the shadow stack
In reply to Greg Kroah-HartmanFrom: Palmer Dabbelt <[email protected]>
[ Upstream commit b003b3b77d65133a0011ae3b7b255347438c12f6 ]
The standard RISC-V ABIs all require 16-byte stack alignment. We're only calling that one function on the shadow stack so I doubt it'd result in a real issue, but might as well keep this lined up.
--- arch/riscv/kernel/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/kernel/traps.c +1 -1
@@ -214,7 +214,7 @@ static DEFINE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)],* shadow stack, handled_ kernel_ stack_ overflow(in kernel/entry.S) is used * to get per-cpu overflow stack(get_overflow_stack). */ -long shadow_stack[SHADOW_OVERFLOW_STACK_SIZE /sizeof (long )]; +long shadow_stack[SHADOW_OVERFLOW_STACK_SIZE /sizeof (long )]__aligned(16) ;asmlinkage unsigned long get_overflow_stack (void ) { return (unsigned long)this_cpu_ptr(overflow_stack) +
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 685/1146 f2fs: fix iostat parameter for discard
In reply to Greg Kroah-HartmanFrom: Yangtao Li <[email protected]>
[ Upstream commit 15e38ee44d50cad264da80ef75626b9224ddc4a3 ]
Just like other data we count uses the number of bytes as the basic unit, but discard uses the number of cmds as the statistical unit. In fact the discard command contains the number of blocks, so let's change to the number of bytes as the base unit.
--- fs/f2fs/segment.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/segment.c +1 -1
@@ -1170,7 +1170,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,atomic_inc (&dcc->issued_discard); -f2fs_update_iostat (sbi,NULL ,FS_DISCARD ,1 ); +f2fs_update_iostat (sbi,NULL ,FS_DISCARD , len *F2FS_BLKSIZE ); lstart += len; start += len;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 686/1146 riscv: Fix P4D_SHIFT definition for 3-level page table mode
In reply to Greg Kroah-HartmanFrom: Alexandre Ghiti <[email protected]>
[ Upstream commit 71fc3621efc38ace9640ee6a0db3300900689592 ]
RISC-V kernels support 3,4,5-level page tables at runtime by folding upper levels.
In case of a 3-level page table, PGDIR is folded into P4D which in turn is folded into PUD: PGDIR_SHIFT value is correctly set to the same value as PUD_SHIFT, but P4D_SHIFT is not, then any use of P4D_SHIFT will access invalid address bits (all set to 1).
Fix this by dynamically defining P4D_SHIFT value, like we already do for PGDIR_SHIFT.
--- arch/riscv/include/asm/pgtable-64.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/riscv/include/asm/pgtable-64.h +5 -1
@@ -25,7 +25,11 @@ extern bool pgtable_l5_enabled;#define PGDIR_MASK (~(PGDIR_SIZE - 1))/* p4d is folded into pgd in case of 4-level page table */ -#define P4D_SHIFT 39 +#define P4D_SHIFT_L3 30 +#define P4D_SHIFT_L4 39 +#define P4D_SHIFT_L5 39 +#define P4D_SHIFT (pgtable_l5_enabled ? P4D_SHIFT_L5 : \ + (pgtable_l4_enabled ? P4D_SHIFT_L4 : P4D_SHIFT_L3))#define P4D_SIZE (_AC(1, UL) << P4D_SHIFT)#define P4D_MASK (~(P4D_SIZE - 1))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 687/1146 drivers: dio: fix possible memory leak in dio_init()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit e63e99397b2613d50a5f4f02ed07307e67a190f1 ]
If device_register() returns error, the 'dev' and name needs be freed. Add a release function, and then call put_device() in the error path, so the name is freed in kobject_cleanup() and to the 'dev' is freed in release function.
--- drivers/dio/dio.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dio/dio.c +8 -0
@@ -109,6 +109,12 @@ static char dio_no_name[] = { 0 };#endif /* CONFIG_DIO_CONSTANTS */ +static void dio_dev_release (struct device *dev) +{ + struct dio_dev *ddev = container_of(dev, typeof(struct dio_dev), dev); +kfree (ddev); +} +int __init dio_find (int deviceid) {/* Called to find a DIO device before the full bus scan has run.
@@ -225,6 +231,7 @@ static int __init dio_init(void) dev->bus = &dio_bus; dev->dev.parent = &dio_bus.dev; dev->dev.bus = &dio_bus_type; + dev->dev.release = dio_dev_release; dev->scode = scode; dev->resource.start = pa; dev->resource.end = pa +DIO_SIZE (scode, va);
@@ -252,6 +259,7 @@ static int __init dio_init(void)if (error) {pr_err ("DIO: Error registering device %s\n" , dev->name); +put_device (&dev->dev);continue ; } error =dio_create_sysfs_dev_files (dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 688/1146 serial: tegra: Read DMA status before terminating
In reply to Greg Kroah-HartmanFrom: Kartik <[email protected]>
[ Upstream commit 109a951a9f1fd8a34ebd1896cbbd5d5cede880a7 ]
Read the DMA status before terminating the DMA, as doing so deletes the DMA desc.
Also, to get the correct transfer status information, pause the DMA using dmaengine_pause() before reading the DMA status.
--- drivers/tty/serial/serial-tegra.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/tty/serial/serial-tegra.c +4 -2
@@ -619,8 +619,9 @@ static void tegra_uart_stop_tx(struct uart_port *u)if (tup->tx_in_progress !=TEGRA_UART_TX_DMA )return ; -dmaengine_terminate_all (tup->tx_dma_chan); +dmaengine_pause (tup->tx_dma_chan);dmaengine_tx_status (tup->tx_dma_chan, tup->tx_cookie, &state); +dmaengine_terminate_all (tup->tx_dma_chan); count = tup->tx_bytes_requested - state.residue;async_tx_ack (tup->tx_dma_desc);uart_xmit_advance (&tup->uport, count);
@@ -763,8 +764,9 @@ static void tegra_uart_terminate_rx_dma(struct tegra_uart_port *tup)return ; } -dmaengine_terminate_all (tup->rx_dma_chan); +dmaengine_pause (tup->rx_dma_chan);dmaengine_tx_status (tup->rx_dma_chan, tup->rx_cookie, &state); +dmaengine_terminate_all (tup->rx_dma_chan);tegra_uart_rx_buffer_push (tup, state.residue); tup->rx_dma_active = false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 689/1146 serial: 8250_bcm7271: Fix error handling in brcmuart_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 6a3ff858915fa8ca36c7eb02c87c9181ae2fc333 ]
A problem about 8250_bcm7271 create debugfs failed is triggered with the following log given:
[ 324.516635] debugfs: Directory 'bcm7271-uart' with parent '/' already present!
The reason is that brcmuart_init() returns platform_driver_register() directly without checking its return value, if platform_driver_register() failed, it returns without destroy the newly created debugfs, resulting the debugfs of 8250_bcm7271 can never be created later.
brcmuart_init()
debugfs_create_dir() # create debugfs directory platform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without destroy debugfs directory
Fix by removing debugfs when platform_driver_register() returns error.
--- drivers/tty/serial/8250/8250_bcm7271.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_bcm7271.c +9 -1
@@ -1212,9 +1212,17 @@ static struct platform_driver brcmuart_platform_driver = {static int __init brcmuart_init (void ) { +int ret; + brcmuart_debugfs_root =debugfs_create_dir ( brcmuart_platform_driver.driver.name,NULL ); -return platform_driver_register (&brcmuart_platform_driver); + ret =platform_driver_register (&brcmuart_platform_driver); +if (ret) { +debugfs_remove_recursive (brcmuart_debugfs_root); +return ret; + } + +return 0 ; }module_init (brcmuart_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 690/1146 drivers: staging: r8188eu: Fix sleep-in-atomic-context bug in rtw_join_timeout_handler
In reply to Greg Kroah-HartmanFrom: Duoming Zhou <[email protected]>
[ Upstream commit ce8cc75c7419ad54cb99437543a54c97c7446db5 ]
The rtw_join_timeout_handler() is a timer handler that runs in atomic context, but it could call msleep(). As a result, the sleep-in-atomic-context bug will happen. The process is shown below:
(atomic context)rtw_join_timeout_handler
_rtw_join_timeout_handler
rtw_do_join
rtw_select_and_join_from_scanned_queue
rtw_indicate_disconnect
rtw_lps_ctrl_wk_cmd
lps_ctrl_wk_hdl
LPS_Leave
LPS_RF_ON_check
msleep //sleep in atomic context
Fix by removing msleep() and replacing with mdelay().
--- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/core/rtw_pwrctrl.c +1 -1
@@ -273,7 +273,7 @@ static s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) err =-1 ;break ; } -msleep (1 ); +mdelay (1 ); }return err;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 691/1146 class: fix possible memory leak in __class_register()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8c3e8a6bdb5253b97ad532570f8b5db5f7a06407 ]
If class_add_groups() returns error, the 'cp->subsys' need be unregister, and the 'cp' need be freed.
We can not call kset_unregister() here, because the 'cls' will be freed in callback function class_release() and it's also freed in caller's error path, it will cause double free.
So fix this by calling kobject_del() and kfree_const(name) to cleanup kobject. Besides, call kfree() to free the 'cp'.
Fault injection test can trigger this:
unreferenced object 0xffff888102fa8190 (size 8):
comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 8 bytes):
70 6b 74 63 64 76 64 00 pktcdvd.
backtrace:
[<00000000e7c7703d>] __kmalloc_track_caller+0x1ae/0x320
[<000000005e4d70bc>] kstrdup+0x3a/0x70
[<00000000c2e5e85a>] kstrdup_const+0x68/0x80
[<000000000049a8c7>] kvasprintf_const+0x10b/0x190
[<0000000029123163>] kobject_set_name_vargs+0x56/0x150
[<00000000747219c9>] kobject_set_name+0xab/0xe0
[<0000000005f1ea4e>] __class_register+0x15c/0x49aunreferenced object 0xffff888037274000 (size 1024):
comm "modprobe", pid 502, jiffies 4294906074 (age 49.296s) hex dump (first 32 bytes):
00 40 27 37 80 88 ff ff 00 40 27 37 80 88 ff ff .@'7.....@'7....
00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00 .....N..........
backtrace:
[<00000000151f9600>] kmem_cache_alloc_trace+0x17c/0x2f0
[<00000000ecf3dd95>] __class_register+0x86/0x49a--- drivers/base/class.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/base/class.c +5 -0
@@ -192,6 +192,11 @@ int __class_register(struct class *cls, struct lock_class_key *key) } error =class_add_groups (class_get (cls), cls->class_groups);class_put (cls); +if (error) { +kobject_del (&cp->subsys.kobj); +kfree_const (cp->subsys.kobj.name); +kfree (cp); + }return error; }EXPORT_SYMBOL_GPL (__class_register);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 692/1146 vfio: platform: Do not pass return buffer to ACPI _RST method
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit e67e070632a665c932d534b8b800477bb3111449 ]
The ACPI _RST method has no return value, there's no need to pass a return buffer to acpi_evaluate_object().
--- drivers/vfio/platform/vfio_platform_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/vfio/platform/vfio_platform_common.c +1 -2
@@ -72,12 +72,11 @@ static int vfio_platform_acpi_call_reset(struct vfio_platform_device *vdev, const char **extra_dbg) {#ifdef CONFIG_ACPI -struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };struct device *dev = vdev->device;acpi_handle handle =ACPI_HANDLE (dev);acpi_status acpi_ret; - acpi_ret =acpi_evaluate_object (handle,"_RST" ,NULL , &buffer); + acpi_ret =acpi_evaluate_object (handle,"_RST" ,NULL ,NULL );if (ACPI_FAILURE (acpi_ret)) {if (extra_dbg) *extra_dbg =acpi_format_exception (acpi_ret);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 693/1146 vfio/iova_bitmap: Fix PAGE_SIZE unaligned bitmaps
In reply to Greg Kroah-HartmanFrom: Joao Martins <[email protected]>
[ Upstream commit f38044e5ef58ad0346fdabd7027ea5c1e1a3b624 ]
iova_bitmap_set() doesn't consider the end of the page boundary when the first bitmap page offset isn't zero, and wrongly changes the consecutive page right after. Consequently this leads to missing dirty pages from reported by the device as seen from the VMM.
The current logic iterates over a given number of base pages and clamps it to the remaining indexes to iterate in the last page. Instead of having to consider extra pages to pin (e.g. first and extra pages), just handle the first page as its own range and let the rest of the bitmap be handled as if it was base page aligned.
This is done by changing iova_bitmap_mapped_remaining() to return PAGE_SIZE
- pgoff (on the first bitmap page), and leads to pgoff being set to 0 on following iterations.
--- drivers/vfio/iova_bitmap.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/vfio/iova_bitmap.c +6 -2
@@ -295,11 +295,15 @@ void iova_bitmap_free(struct iova_bitmap *bitmap)*/ static unsigned long iova_bitmap_mapped_remaining (struct iova_bitmap *bitmap) { -unsigned long remaining; +unsigned long remaining, bytes; + +/* Cap to one page in the first iteration, if PAGE_SIZE unaligned. */ + bytes = !bitmap->mapped.pgoff ? bitmap->mapped.npages <<PAGE_SHIFT : +PAGE_SIZE - bitmap->mapped.pgoff; remaining = bitmap->mapped_total_index - bitmap->mapped_base_index; remaining = min_t(unsigned long, remaining, - (bitmap->mapped.npages <<PAGE_SHIFT ) /sizeof (*bitmap->bitmap)); + bytes /sizeof (*bitmap->bitmap));return remaining; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 694/1146 uio: uio_dmem_genirq: Fix missing unlock in irq configuration
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 9de255c461d1b3f0242b3ad1450c3323a3e00b34 ]
Commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") started calling disable_irq() without holding the spinlock because it can sleep. However, that fix introduced another bug: if interrupt is already disabled and a new disable request comes in, then the spinlock is not unlocked:
root@localhost:~# printf '\x00\x00\x00\x00' > /dev/uio0 root@localhost:~# printf '\x00\x00\x00\x00' > /dev/uio0 root@localhost:~# [ 14.851538] BUG: scheduling while atomic: bash/223/0x00000002 [ 14.851991] Modules linked in: uio_dmem_genirq uio myfpga(OE) bochs drm_vram_helper drm_ttm_helper ttm drm_kms_helper drm snd_pcm ppdev joydev psmouse snd_timer snd e1000fb_sys_fops syscopyarea parport sysfillrect soundcore sysimgblt input_leds pcspkr i2c_piix4 serio_raw floppy evbug qemu_fw_cfg mac_hid pata_acpi ip_tables x_tables autofs4 [last unloaded: parport_pc] [ 14.854206] CPU: 0 PID: 223 Comm: bash Tainted: G OE 6.0.0-rc7 #21 [ 14.854786] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 [ 14.855664] Call Trace: [ 14.855861] <TASK> [ 14.856025] dump_stack_lvl+0x4d/0x67 [ 14.856325] dump_stack+0x14/0x1a [ 14.856583] __schedule_bug.cold+0x4b/0x5c [ 14.856915] __schedule+0xe81/0x13d0 [ 14.857199] ? idr_find+0x13/0x20 [ 14.857456] ? get_work_pool+0x2d/0x50 [ 14.857756] ? __flush_work+0x233/0x280 [ 14.858068] ? __schedule+0xa95/0x13d0 [ 14.858307] ? idr_find+0x13/0x20 [ 14.858519] ? get_work_pool+0x2d/0x50 [ 14.858798] schedule+0x6c/0x100 [ 14.859009] schedule_hrtimeout_range_clock+0xff/0x110 [ 14.859335] ? tty_write_room+0x1f/0x30 [ 14.859598] ? n_tty_poll+0x1ec/0x220 [ 14.859830] ? tty_ldisc_deref+0x1a/0x20 [ 14.860090] schedule_hrtimeout_range+0x17/0x20 [ 14.860373] do_select+0x596/0x840 [ 14.860627] ? __kernel_text_address+0x16/0x50 [ 14.860954] ? poll_freewait+0xb0/0xb0 [ 14.861235] ? poll_freewait+0xb0/0xb0 [ 14.861517] ? rpm_resume+0x49d/0x780 [ 14.861798] ? common_interrupt+0x59/0xa0 [ 14.862127] ? asm_common_interrupt+0x2b/0x40 [ 14.862511] ? __uart_start.isra.0+0x61/0x70 [ 14.862902] ? __check_object_size+0x61/0x280 [ 14.863255] core_sys_select+0x1c6/0x400 [ 14.863575] ? vfs_write+0x1c9/0x3d0 [ 14.863853] ? vfs_write+0x1c9/0x3d0 [ 14.864121] ? _copy_from_user+0x45/0x70 [ 14.864526] do_pselect.constprop.0+0xb3/0xf0 [ 14.864893] ? do_syscall_64+0x6d/0x90 [ 14.865228] ? do_syscall_64+0x6d/0x90 [ 14.865556] __x64_sys_pselect6+0x76/0xa0 [ 14.865906] do_syscall_64+0x60/0x90 [ 14.866214] ? syscall_exit_to_user_mode+0x2a/0x50 [ 14.866640] ? do_syscall_64+0x6d/0x90 [ 14.866972] ? do_syscall_64+0x6d/0x90 [ 14.867286] ? do_syscall_64+0x6d/0x90 [ 14.867626] entry_SYSCALL_64_after_hwframe+0x63/0xcd [...] stripped [ 14.872959] </TASK>
('myfpga' is a simple 'uio_dmem_genirq' driver I wrote to test this)
The implementation of "uio_dmem_genirq" was based on "uio_pdrv_genirq" and it is used in a similar manner to the "uio_pdrv_genirq" driver with respect to interrupt configuration and handling. At the time "uio_dmem_genirq" was introduced, both had the same implementation of the 'uio_info' handlers irqcontrol() and handler(). Then commit 34cb27528398 ("UIO: Fix concurrency issue"), which was only applied to "uio_pdrv_genirq", ended up making them a little different. That commit, among other things, changed disable_irq() to disable_irq_nosync() in the implementation of irqcontrol(). The motivation there was to avoid a deadlock between irqcontrol() and handler(), since it added a spinlock in the irq handler, and disable_irq() waits for the completion of the irq handler.
By changing disable_irq() to disable_irq_nosync() in irqcontrol(), we also avoid the sleeping-while-atomic bug that commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") was trying to fix. Thus, this fixes the missing unlock in irqcontrol() by importing the implementation of irqcontrol() handler from the "uio_pdrv_genirq" driver. In the end, it reverts commit b74351287d4b ("uio: fix a sleep-in-atomic-context bug in uio_dmem_genirq_irqcontrol()") and change disable_irq() to disable_irq_nosync().
It is worth noting that this still does not address the concurrency issue fixed by commit 34cb27528398 ("UIO: Fix concurrency issue"). It will be addressed separately in the next commits.
Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").
--- drivers/uio/uio_dmem_genirq.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/uio/uio_dmem_genirq.c +3 -5
@@ -132,13 +132,11 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)if (irq_on) {if (test_and_clear_bit (0 , &priv->flags))enable_irq (dev_info->irq); -spin_unlock_irqrestore (&priv->lock, flags); }else { -if (!test_and_set_bit (0 , &priv->flags)) { -spin_unlock_irqrestore (&priv->lock, flags); -disable_irq (dev_info->irq); - } +if (!test_and_set_bit (0 , &priv->flags)) +disable_irq_nosync (dev_info->irq); } +spin_unlock_irqrestore (&priv->lock, flags);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 695/1146 uio: uio_dmem_genirq: Fix deadlock between irq config and handling
In reply to Greg Kroah-HartmanFrom: Rafael Mendonca <[email protected]>
[ Upstream commit 118b918018175d9fcd8db667f905012e986cc2c9 ]
This fixes a concurrency issue addressed in commit 34cb27528398 ("UIO: Fix concurrency issue"):
"In a SMP case there was a race condition issue between Uio_pdrv_genirq_irqcontrol() running on one CPU and irq handler on another CPU. Fix it by spin_locking shared resources access inside irq handler."
The implementation of "uio_dmem_genirq" was based on "uio_pdrv_genirq" and it is used in a similar manner to the "uio_pdrv_genirq" driver with respect to interrupt configuration and handling. At the time "uio_dmem_genirq" was merged, both had the same implementation of the 'uio_info' handlers irqcontrol() and handler(), thus, both had the same concurrency issue mentioned by the above commit. However, the above patch was only applied to the "uio_pdrv_genirq" driver.
Split out from commit 34cb27528398 ("UIO: Fix concurrency issue").
--- drivers/uio/uio_dmem_genirq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/uio/uio_dmem_genirq.c +4 -1
@@ -110,8 +110,10 @@ static irqreturn_t uio_dmem_genirq_handler(int irq, struct uio_info *dev_info)* remember the state so we can allow user space to enable it later. */ +spin_lock (&priv->lock);if (!test_and_set_bit (0 , &priv->flags))disable_irq_nosync (irq); +spin_unlock (&priv->lock);return IRQ_HANDLED ; }
@@ -125,7 +127,8 @@ static int uio_dmem_genirq_irqcontrol(struct uio_info *dev_info, s32 irq_on)* in the interrupt controller, but keep track of the * state to prevent per-irq depth damage. * -* Serialize this operation to support multiple tasks. +* Serialize this operation to support multiple tasks and concurrency +* with irq handler on SMP systems. */ spin_lock_irqsave (&priv->lock, flags);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 696/1146 usb: fotg210-udc: Fix ages old endianness issues
In reply to Greg Kroah-HartmanFrom: Linus Walleij <[email protected]>
[ Upstream commit 46ed6026ca2181c917c8334a82e3eaf40a6234dd ]
The code in the FOTG210 driver isn't entirely endianness-agnostic as reported by the kernel robot sparse testing. This came to the surface while moving the files around.
The driver is only used on little-endian systems, so this causes no real-world regression, but it is nice to be strict and have some compile coverage also on big endian machines, so fix it up with the right LE accessors.
--- drivers/usb/gadget/udc/fotg210-udc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/fotg210-udc.c +6 -6
@@ -629,10 +629,10 @@ static void fotg210_request_error(struct fotg210_udc *fotg210)static void fotg210_set_address (struct fotg210_udc *fotg210,struct usb_ctrlrequest *ctrl) { -if (ctrl->wValue >=0x0100 ) { +if (le16_to_cpu (ctrl->wValue) >=0x0100 ) {fotg210_request_error (fotg210); }else { -fotg210_set_dev_addr (fotg210, ctrl->wValue); +fotg210_set_dev_addr (fotg210,le16_to_cpu (ctrl->wValue));fotg210_set_cxdone (fotg210); } }
@@ -713,17 +713,17 @@ static void fotg210_get_status(struct fotg210_udc *fotg210,switch (ctrl->bRequestType &USB_RECIP_MASK ) {case USB_RECIP_DEVICE : - fotg210->ep0_data =1 <<USB_DEVICE_SELF_POWERED ; + fotg210->ep0_data =cpu_to_le16 (1 <<USB_DEVICE_SELF_POWERED );break ;case USB_RECIP_INTERFACE : - fotg210->ep0_data =0 ; + fotg210->ep0_data =cpu_to_le16 (0 );break ;case USB_RECIP_ENDPOINT : epnum = ctrl->wIndex &USB_ENDPOINT_NUMBER_MASK ;if (epnum) fotg210->ep0_data = -fotg210_is_epnstall (fotg210->ep[epnum]) - <<USB_ENDPOINT_HALT ; +cpu_to_le16 (fotg210_is_epnstall (fotg210->ep[epnum]) + <<USB_ENDPOINT_HALT );else fotg210_request_error (fotg210);break ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 697/1146 interconnect: qcom: sc7180: fix dropped const of qcom_icc_bcm
In reply to Greg Kroah-HartmanFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f24227a640344f894522045f74bb2decbdc4f55e ]
Pointers to struct qcom_icc_bcm are const, but the change was dropped during merge.
--- drivers/interconnect/qcom/sc7180.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/sc7180.c +1 -1
@@ -369,7 +369,7 @@ static const struct qcom_icc_desc sc7180_gem_noc = { .num_bcms = ARRAY_SIZE(gem_noc_bcms), }; -static struct qcom_icc_bcm *mc_virt_bcms[] = { +static struct qcom_icc_bcm *const mc_virt_bcms[] = { &bcm_acv, &bcm_mc0, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 698/1146 staging: vme_user: Fix possible UAF in tsi148_dma_list_add
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit 357057ee55d3c99a5de5abe8150f7bca04f8e53b ]
Smatch report warning as follows:
drivers/staging/vme_user/vme_tsi148.c:1757 tsi148_dma_list_add() warn:
'&entry->list' not removed from list
In tsi148_dma_list_add(), the error path "goto err_dma" will not remove entry->list from list->entries, but entry will be freed, then list traversal may cause UAF.
Fix by removeing it from list->entries before free().
--- drivers/staging/vme_user/vme_tsi148.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/vme_user/vme_tsi148.c +1 -0
@@ -1751,6 +1751,7 @@ static int tsi148_dma_list_add(struct vme_dma_list *list,return 0 ; err_dma: +list_del (&entry->list); err_dest: err_source: err_align:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 699/1146 usb: typec: Check for ops->exit instead of ops->enter in altmode_exit
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit b6ddd180e3d9f92c1e482b3cdeec7dda086b1341 ]
typec_altmode_exit checks if ops->enter is not NULL but then calls ops->exit a few lines below. Fix that and check for the function pointer it's about to call instead.
--- drivers/usb/typec/bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/bus.c +1 -1
@@ -134,7 +134,7 @@ int typec_altmode_exit(struct typec_altmode *adev)if (!adev || !adev->active)return 0 ; -if (!pdev->ops || !pdev->ops->enter) +if (!pdev->ops || !pdev->ops->exit)return -EOPNOTSUPP ;/* Moving to USB Safe State */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 700/1146 usb: typec: tcpci: fix of node refcount leak in tcpci_register_port()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 0384e87e3fec735e47f1c133c796f32ef7a72a9b ]
I got the following report while doing device(mt6370-tcpc) load test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/pmic@34/tcpc/connector
The 'fwnode' set in tcpci_parse_config() which is called in tcpci_register_port(), its node refcount is increased in device_get_named_child_node(). It needs be put while exiting, so call fwnode_handle_put() in the error path of tcpci_register_port() and in tcpci_unregister_port() to avoid leak.
--- drivers/usb/typec/tcpm/tcpci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/typec/tcpm/tcpci.c +4 -1
@@ -794,8 +794,10 @@ struct tcpci *tcpci_register_port(struct device *dev, struct tcpci_data *data)return ERR_PTR (err); tcpci->port =tcpm_register_port (tcpci->dev, &tcpci->tcpc); -if (IS_ERR (tcpci->port)) +if (IS_ERR (tcpci->port)) { +fwnode_handle_put (tcpci->tcpc.fwnode);return ERR_CAST (tcpci->port); + }return tcpci; }
@@ -804,6 +806,7 @@ EXPORT_SYMBOL_GPL(tcpci_register_port);void tcpci_unregister_port (struct tcpci *tcpci) {tcpm_unregister_port (tcpci->port); +fwnode_handle_put (tcpci->tcpc.fwnode); }EXPORT_SYMBOL_GPL (tcpci_unregister_port);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 701/1146 usb: typec: tipd: Cleanup resources if devm_tps6598_psy_register fails
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit 19c220e9ab00f50edefb9667e3101e84a5112df2 ]
We can't just return if devm_tps6598_psy_register fails since previous resources are not devres managed and have yet to be cleaned up.
--- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
@@ -814,7 +814,7 @@ static int tps6598x_probe(struct i2c_client *client) ret =devm_tps6598_psy_register (tps);if (ret) -return ret; + goto err_role_put; tps->port =typec_register_port (&client->dev, &typec_cap);if (IS_ERR (tps->port)) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 702/1146 usb: typec: tipd: Fix spurious fwnode_handle_put in error path
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit 782c70edc4852a5d39be12377a85501546236212 ]
The err_role_put error path always calls fwnode_handle_put to release the fwnode. This path can be reached after probe itself has already released that fwnode though. Fix that by moving fwnode_handle_put in the happy path to the very end.
--- drivers/usb/typec/tipd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/tipd/core.c +1 -1
@@ -821,7 +821,6 @@ static int tps6598x_probe(struct i2c_client *client) ret =PTR_ERR (tps->port); goto err_role_put; } -fwnode_handle_put (fwnode);if (status &TPS_STATUS_PLUG_PRESENT ) { ret =tps6598x_read16 (tps,TPS_REG_POWER_STATUS , &tps->pwr_status);
@@ -845,6 +844,7 @@ static int tps6598x_probe(struct i2c_client *client) }i2c_set_clientdata (client, tps); +fwnode_handle_put (fwnode);return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 703/1146 usb: typec: tipd: Fix typec_unregister_port error paths
In reply to Greg Kroah-HartmanFrom: Sven Peter <[email protected]>
[ Upstream commit 4c8f27ba9ede0118cac9d775204f9b0ecdb877b0 ]
typec_unregister_port is only called for some error paths after typec_register_port was successful. Ensure it's called in all cases.
--- drivers/usb/typec/tipd/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/usb/typec/tipd/core.c +4 -3
@@ -826,7 +826,7 @@ static int tps6598x_probe(struct i2c_client *client) ret =tps6598x_read16 (tps,TPS_REG_POWER_STATUS , &tps->pwr_status);if (ret <0 ) {dev_err (tps->dev,"failed to read power status: %d\n" , ret); - goto err_role_put; + goto err_unregister_port; } ret =tps6598x_connect (tps, status);if (ret)
@@ -839,8 +839,7 @@ static int tps6598x_probe(struct i2c_client *client) dev_name(&client->dev), tps);if (ret) {tps6598x_disconnect (tps,0 ); -typec_unregister_port (tps->port); - goto err_role_put; + goto err_unregister_port; }i2c_set_clientdata (client, tps);
@@ -848,6 +847,8 @@ static int tps6598x_probe(struct i2c_client *client)return 0 ; +err_unregister_port: +typec_unregister_port (tps->port); err_role_put:usb_role_switch_put (tps->role_sw); err_fwnode_put:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 704/1146 usb: musb: omap2430: Fix probe regression for missing resources
In reply to Greg Kroah-HartmanFrom: Tony Lindgren <[email protected]>
[ Upstream commit ffbe2feac59b37c8dc536727552b4f375e1b9aec ]
Probe for omap2430 glue layer is now broken for interrupt resources in all cases.
Commit 239071064732 ("partially Revert "usb: musb: Set the DT node on the child device"") broke probing for SoCs using ti-sysc interconnect target module as the dt node is not found.
Commit a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core") caused omap3 to fail with error "-ENXIO: IRQ mc not found" as the IRQ resources are no longer automatically populated from devicetree.
Let's fix the issues by calling device_set_of_node_from_dev() only if the SoC has been updated to probe with ti-sysc. And for legacy SoCs, let's populate the resources manually as needed.
Note that once we have updated the SoCs to probe with proper devicetree data in all cases, this is no longer needed. But doing that requires patching both devicetree and SoC code, so let's fix the probe issues first.
--- drivers/usb/musb/omap2430.c | 54 +++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
drivers/usb/musb/omap2430.c +54 -0
@@ -15,6 +15,7 @@#include <linux/list.h> #include <linux/io.h> #include <linux/of.h> +#include <linux/of_irq.h> #include <linux/platform_device.h> #include <linux/dma-mapping.h> #include <linux/pm_runtime.h>
@@ -310,6 +311,7 @@ static int omap2430_probe(struct platform_device *pdev)struct device_node *control_node;struct platform_device *control_pdev;int ret = -ENOMEM , val; +bool populate_irqs = false;if (!np)return -ENODEV ;
@@ -328,6 +330,18 @@ static int omap2430_probe(struct platform_device *pdev) musb->dev.dma_mask = &omap2430_dmamask; musb->dev.coherent_dma_mask = omap2430_dmamask; +/* +* Legacy SoCs using omap_device get confused if node is moved +* because of interconnect properties mixed into the node. +*/ +if (of_get_property (np,"ti,hwmods" ,NULL )) { +dev_warn (&pdev->dev,"please update to probe with ti-sysc\n" ); + populate_irqs = true; + }else { +device_set_of_node_from_dev (&musb->dev, &pdev->dev); + } +of_node_put (np); + glue->dev = &pdev->dev; glue->musb = musb; glue->status =MUSB_UNKNOWN ;
@@ -389,6 +403,46 @@ static int omap2430_probe(struct platform_device *pdev) goto err2; } +if (populate_irqs) { +struct resource musb_res[3 ]; +struct resource *res; +int i =0 ; + +memset (musb_res,0 ,sizeof (*musb_res) *ARRAY_SIZE (musb_res)); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) + goto err2; + + musb_res[i].start = res->start; + musb_res[i].end = res->end; + musb_res[i].flags = res->flags; + musb_res[i].name = res->name; + i++; + + ret =of_irq_get_byname (np,"mc" ); +if (ret >0 ) { + musb_res[i].start = ret; + musb_res[i].flags =IORESOURCE_IRQ ; + musb_res[i].name ="mc" ; + i++; + } + + ret =of_irq_get_byname (np,"dma" ); +if (ret >0 ) { + musb_res[i].start = ret; + musb_res[i].flags =IORESOURCE_IRQ ; + musb_res[i].name ="dma" ; + i++; + } + + ret =platform_device_add_resources (musb, musb_res, i); +if (ret) { +dev_err (&pdev->dev,"failed to add IRQ resources\n" ); + goto err2; + } + } + ret =platform_device_add_data (musb, pdata,sizeof (*pdata));if (ret) {dev_err (&pdev->dev,"failed to add platform_data\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 705/1146 extcon: usbc-tusb320: Update state on probe even if no IRQ pending
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 581c848b610dbf3fe1ed4d85fd53d0743c61faba ]
Currently this driver triggers extcon and typec state update in its probe function, to read out current state reported by the chip and report the correct state to upper layers. This synchronization is performed correctly, but only in case the chip indicates a pending interrupt in reg09 register.
This fails to cover the situation where all interrupts reported by the chip were already handled by Linux before reboot, then the system rebooted, and then Linux starts again. In this case, the TUSB320 no longer reports any interrupts in reg09, and the state update does not perform any update as it depends on that interrupt indication.
Fix this by turning tusb320_irq_handler() into a thin wrapper around tusb320_state_update_handler(), where the later now contains the bulk of the code of tusb320_irq_handler(), but adds new function parameter "force_update". The "force_update" parameter can be used by the probe function to assure that the state synchronization is always performed, independent of the interrupt indicated in reg09. The interrupt handler tusb320_irq_handler() callback uses force_update=false to avoid state updates on potential spurious interrupts and retain current behavior.
--- drivers/extcon/extcon-usbc-tusb320.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/extcon/extcon-usbc-tusb320.c +12 -5
@@ -313,9 +313,9 @@ static void tusb320_typec_irq_handler(struct tusb320_priv *priv, u8 reg9)typec_set_pwr_opmode (port,TYPEC_PWR_MODE_USB ); } -static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +static irqreturn_t tusb320_state_update_handler (struct tusb320_priv *priv, +bool force_update) { -struct tusb320_priv *priv = dev_id;unsigned int reg;if (regmap_read (priv->regmap,TUSB320_REG9 , ®)) {
@@ -323,7 +323,7 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_NONE ; } -if (!(reg &TUSB320_REG9_INTERRUPT_STATUS )) +if (!force_update && !(reg &TUSB320_REG9_INTERRUPT_STATUS ))return IRQ_NONE ;tusb320_extcon_irq_handler (priv, reg);
@@ -340,6 +340,13 @@ static irqreturn_t tusb320_irq_handler(int irq, void *dev_id)return IRQ_HANDLED ; } +static irqreturn_t tusb320_irq_handler (int irq,void *dev_id) +{ +struct tusb320_priv *priv = dev_id; + +return tusb320_state_update_handler (priv, false); +} +static const struct regmap_config tusb320_regmap_config = { .reg_bits =8 , .val_bits =8 ,
@@ -466,7 +473,7 @@ static int tusb320_probe(struct i2c_client *client,return ret;/* update initial state */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true);/* Reset chip to its default state */ ret =tusb320_reset (priv);
@@ -477,7 +484,7 @@ static int tusb320_probe(struct i2c_client *client,* State and polarity might change after a reset, so update * them again and make sure the interrupt status bit is cleared. */ -tusb320_irq_handler (client->irq, priv); +tusb320_state_update_handler (priv, true); ret = devm_request_threaded_irq(priv->dev, client->irq, NULL, tusb320_irq_handler,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 706/1146 USB: gadget: Fix use-after-free during usb config switch
In reply to Greg Kroah-HartmanFrom: Jiantao Zhang <[email protected]>
[ Upstream commit afdc12887f2b2ecf20d065a7d81ad29824155083 ]
In the process of switching USB config from rndis to other config, if the hardware does not support the ->pullup callback, or the hardware encounters a low probability fault, both of them may cause the ->pullup callback to fail, which will then cause a system panic (use after free).
The gadget drivers sometimes need to be unloaded regardless of the hardware's behavior.
Analysis as follows:
=======================================================================
(1) write /config/usb_gadget/g1/UDC "none"
gether_disconnect+0x2c/0x1f8 rndis_disable+0x4c/0x74 composite_disconnect+0x74/0xb0 configfs_composite_disconnect+0x60/0x7c usb_gadget_disconnect+0x70/0x124 usb_gadget_unregister_driver+0xc8/0x1d8 gadget_dev_desc_UDC_store+0xec/0x1e4
(2) rm /config/usb_gadget/g1/configs/b.1/f1
rndis_deregister+0x28/0x54 rndis_free+0x44/0x7c usb_put_function+0x14/0x1c config_usb_cfg_unlink+0xc4/0xe0 configfs_unlink+0x124/0x1c8 vfs_unlink+0x114/0x1dc
(3) rmdir /config/usb_gadget/g1/functions/rndis.gs4
panic+0x1fc/0x3d0 do_page_fault+0xa8/0x46c do_mem_abort+0x3c/0xac el1_sync_handler+0x40/0x78 0xffffff801138f880 rndis_close+0x28/0x34 eth_stop+0x74/0x110 dev_close_many+0x48/0x194 rollback_registered_many+0x118/0x814 unregister_netdev+0x20/0x30 gether_cleanup+0x1c/0x38 rndis_attr_release+0xc/0x14 kref_put+0x74/0xb8 configfs_rmdir+0x314/0x374
If gadget->ops->pullup() return an error, function rndis_close() will be called, then it will causes a use-after-free problem.
=======================================================================
--- drivers/usb/gadget/udc/core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/usb/gadget/udc/core.c +6 -6
@@ -734,13 +734,13 @@ int usb_gadget_disconnect(struct usb_gadget *gadget) } ret = gadget->ops->pullup (gadget,0 ); -if (!ret) { +if (!ret) gadget->connected =0 ; -mutex_lock (&udc_lock); -if (gadget->udc->driver) - gadget->udc->driver->disconnect (gadget); -mutex_unlock (&udc_lock); - } + +mutex_lock (&udc_lock); +if (gadget->udc->driver) + gadget->udc->driver->disconnect (gadget); +mutex_unlock (&udc_lock); out:trace_usb_gadget_disconnect (gadget, ret);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 707/1146 serial: amba-pl011: avoid SBSA UART accessing DMACR register
In reply to Greg Kroah-HartmanFrom: Jiamei Xie <[email protected]>
[ Upstream commit 94cdb9f33698478b0e7062586633c42c6158a786 ]
Chapter "B Generic UART" in "ARM Server Base System Architecture" [1] documentation describes a generic UART interface. Such generic UART does not support DMA. In current code, sbsa_uart_pops and amba_pl011_pops share the same stop_rx operation, which will invoke pl011_dma_rx_stop, leading to an access of the DMACR register. This commit adds a using_rx_dma check in pl011_dma_rx_stop to avoid the access to DMACR register for SBSA UARTs which does not support DMA.
When the kernel enables DMA engine with "CONFIG_DMA_ENGINE=y", Linux
SBSA PL011 driver will access PL011 DMACR register in some functions.
For most real SBSA Pl011 hardware implementations, the DMACR write
behaviour will be ignored. So these DMACR operations will not cause
obvious problems. But for some virtual SBSA PL011 hardware, like Xen
virtual SBSA PL011 (vpl011) device, the behaviour might be different.
Xen vpl011 emulation will inject a data abort to guest, when guest is
accessing an unimplemented UART register. As Xen VPL011 is SBSA
compatible, it will not implement DMACR register. So when Linux SBSA
PL011 driver access DMACR register, it will get an unhandled data abort
fault and the application will get a segmentation fault:
Unhandled fault at 0xffffffc00944d048
Mem abort info:
ESR = 0x96000000
EC = 0x25: DABT (current EL), IL = 32 bits
SET = 0, FnV = 0
EA = 0, S1PTW = 0
FSC = 0x00: ttbr address size fault
Data abort info:
ISV = 0, ISS = 0x00000000
CM = 0, WnR = 0
swapper pgtable: 4k pages, 39-bit VAs, pgdp=0000000020e2e000
[ffffffc00944d048] pgd=100000003ffff803, p4d=100000003ffff803, pud=100000003ffff803, pmd=100000003fffa803, pte=006800009c090f13
Internal error: ttbr address size fault: 96000000 [#1] PREEMPT SMP ... Call trace: pl011_stop_rx+0x70/0x80 tty_port_shutdown+0x7c/0xb4 tty_port_close+0x60/0xcc uart_close+0x34/0x8c tty_release+0x144/0x4c0 __fput+0x78/0x220 ____fput+0x1c/0x30 task_work_run+0x88/0xc0 do_notify_resume+0x8d0/0x123c el0_svc+0xa8/0xc0 el0t_64_sync_handler+0xa4/0x130 el0t_64_sync+0x1a0/0x1a4 Code: b9000083 b901f001 794038a0 8b000042 (b9000041) ---[ end trace 83dd93df15c3216f ]---
note: bootlogd[132] exited with preempt_count 1 /etc/rcS.d/S07bootlogd: line 47: 132 Segmentation fault start-stop-daemon
This has been discussed in the Xen community, and we think it should fix this in Linux. See [2] for more information.
[1] https://developer.arm.com/documentation/den0094/c/?lang=en
[2] https://lists.xenproject.org/archives/html/xen-devel/2022-11/msg00543.html
--- drivers/tty/serial/amba-pl011.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/serial/amba-pl011.c +3 -0
@@ -1045,6 +1045,9 @@ static void pl011_dma_rx_callback(void *data)*/ static inline void pl011_dma_rx_stop (struct uart_amba_port *uap) { +if (!uap->using_rx_dma) +return ; +/* FIXME. Just disable the DMA enable */ uap->dmacr &= ~UART011_RXDMAE ;pl011_write (uap->dmacr, uap,REG_DMACR );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 708/1146 serial: pl011: Do not clear RX FIFO & RX interrupt in unthrottle.
In reply to Greg Kroah-HartmanFrom: delisun <[email protected]>
[ Upstream commit 032d5a71ed378ffc6a2d41a187d8488a4f9fe415 ]
Clearing the RX FIFO will cause data loss.
Copy the pl011_enabl_interrupts implementation, and remove the clear interrupt and FIFO part of the code.
--- drivers/tty/serial/amba-pl011.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/tty/serial/amba-pl011.c +10 -1
@@ -1831,8 +1831,17 @@ static void pl011_enable_interrupts(struct uart_amba_port *uap)static void pl011_unthrottle_rx (struct uart_port *port) { struct uart_amba_port *uap = container_of(port, struct uart_amba_port, port); +unsigned long flags; -pl011_enable_interrupts (uap); +spin_lock_irqsave (&uap->port.lock, flags); + + uap->im =UART011_RTIM ; +if (!pl011_dma_rx_running (uap)) + uap->im |=UART011_RXIM ; + +pl011_write (uap->im, uap,REG_IMSC ); + +spin_unlock_irqrestore (&uap->port.lock, flags); }static int pl011_startup (struct uart_port *port)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 709/1146 serial: stm32: move dma_request_chan() before clk_prepare_enable()
In reply to Greg Kroah-HartmanFrom: Valentin Caron <[email protected]>
[ Upstream commit 0d114e9ff940ebad8e88267013bf96c605a6b336 ]
If dma_request_chan() returns a PROBE_DEFER error, clk_disable_unprepare() will be called and USART clock will be disabled. But early console can be still active on the same USART.
While moving dma_request_chan() before clk_prepare_enable(), the clock won't be taken in case of a DMA PROBE_DEFER error, and so it doesn't need to be disabled. Then USART is still clocked for early console.
--- drivers/tty/serial/stm32-usart.c | 47 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 24 deletions(-)
drivers/tty/serial/stm32-usart.c +23 -24
@@ -1681,22 +1681,10 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)if (!stm32port->info)return -EINVAL ; - ret =stm32_usart_init_port (stm32port, pdev); -if (ret) -return ret; - -if (stm32port->wakeup_src) { -device_set_wakeup_capable (&pdev->dev, true); - ret =dev_pm_set_wake_irq (&pdev->dev, stm32port->port.irq); -if (ret) - goto err_deinit_port; - } - stm32port->rx_ch =dma_request_chan (&pdev->dev,"rx" ); -if (PTR_ERR (stm32port->rx_ch) == -EPROBE_DEFER ) { - ret = -EPROBE_DEFER ; - goto err_wakeirq; - } +if (PTR_ERR (stm32port->rx_ch) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +/* Fall back in interrupt mode for any non-deferral error */ if (IS_ERR (stm32port->rx_ch)) stm32port->rx_ch =NULL ;
@@ -1710,6 +1698,17 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)if (IS_ERR (stm32port->tx_ch)) stm32port->tx_ch =NULL ; + ret =stm32_usart_init_port (stm32port, pdev); +if (ret) + goto err_dma_tx; + +if (stm32port->wakeup_src) { +device_set_wakeup_capable (&pdev->dev, true); + ret =dev_pm_set_wake_irq (&pdev->dev, stm32port->port.irq); +if (ret) + goto err_deinit_port; + } +if (stm32port->rx_ch &&stm32_usart_of_dma_rx_probe (stm32port, pdev)) {/* Fall back in interrupt mode */ dma_release_channel (stm32port->rx_ch);
@@ -1746,19 +1745,11 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)pm_runtime_set_suspended (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); -if (stm32port->tx_ch) { +if (stm32port->tx_ch)stm32_usart_of_dma_tx_remove (stm32port, pdev); -dma_release_channel (stm32port->tx_ch); - } -if (stm32port->rx_ch)stm32_usart_of_dma_rx_remove (stm32port, pdev); -err_dma_rx: -if (stm32port->rx_ch) -dma_release_channel (stm32port->rx_ch); - -err_wakeirq:if (stm32port->wakeup_src)dev_pm_clear_wake_irq (&pdev->dev);
@@ -1768,6 +1759,14 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)stm32_usart_deinit_port (stm32port); +err_dma_tx: +if (stm32port->tx_ch) +dma_release_channel (stm32port->tx_ch); + +err_dma_rx: +if (stm32port->rx_ch) +dma_release_channel (stm32port->rx_ch); +return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 710/1146 serial: pch: Fix PCI device refcount leak in pch_request_dma()
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 8be3a7bf773700534a6e8f87f6ed2ed111254be5 ]
As comment of pci_get_slot() says, it returns a pci_device with its refcount increased. The caller must decrement the reference count by calling pci_dev_put().
Since 'dma_dev' is only used to filter the channel in filter(), we can call pci_dev_put() before exiting from pch_request_dma(). Add the missing pci_dev_put() for the normal and error path.
--- drivers/tty/serial/pch_uart.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/tty/serial/pch_uart.c +4 -0
@@ -694,6 +694,7 @@ static void pch_request_dma(struct uart_port *port)if (!chan) {dev_err (priv->port.dev,"%s:dma_request_channel FAILS(Tx)\n" , __func__); +pci_dev_put (dma_dev);return ; } priv->chan_tx = chan;
@@ -710,6 +711,7 @@ static void pch_request_dma(struct uart_port *port) __func__);dma_release_channel (priv->chan_tx); priv->chan_tx =NULL ; +pci_dev_put (dma_dev);return ; }
@@ -717,6 +719,8 @@ static void pch_request_dma(struct uart_port *port) priv->rx_buf_virt =dma_alloc_coherent (port->dev, port->fifosize, &priv->rx_buf_dma,GFP_KERNEL ); priv->chan_rx = chan; + +pci_dev_put (dma_dev); }static void pch_dma_rx_complete (void *arg)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 711/1146 serial: altera_uart: fix locking in polling mode
In reply to Greg Kroah-HartmanFrom: Gabriel Somlo <[email protected]>
[ Upstream commit 1307c5d33cce8a41dd77c2571e4df65a5b627feb ]
Since altera_uart_interrupt() may also be called from a poll timer in "serving_softirq" context, use spin_[lock_irqsave|unlock_irqrestore] variants, which are appropriate for both softirq and hardware interrupt contexts.
--- drivers/tty/serial/altera_uart.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/tty/serial/altera_uart.c +3 -2
@@ -278,16 +278,17 @@ static irqreturn_t altera_uart_interrupt(int irq, void *data) {struct uart_port *port = data; struct altera_uart *pp = container_of(port, struct altera_uart, port); +unsigned long flags;unsigned int isr; isr =altera_uart_readl (port,ALTERA_UART_STATUS_REG ) & pp->imr; -spin_lock (&port->lock); +spin_lock_irqsave (&port->lock, flags);if (isr &ALTERA_UART_STATUS_RRDY_MSK )altera_uart_rx_chars (port);if (isr &ALTERA_UART_STATUS_TRDY_MSK )altera_uart_tx_chars (port); -spin_unlock (&port->lock); +spin_unlock_irqrestore (&port->lock, flags);return IRQ_RETVAL (isr); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 712/1146 serial: sunsab: Fix error handling in sunsab_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 1a6ec673fb627c26e2267ca0a03849f91dbd9b40 ]
The sunsab_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the allocated sunsab_ports is leaked.
Fix by free sunsab_ports and set it to NULL when platform_driver_register() failed.
--- drivers/tty/serial/sunsab.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/sunsab.c +7 -1
@@ -1133,7 +1133,13 @@ static int __init sunsab_init(void) } } -return platform_driver_register (&sab_driver); + err =platform_driver_register (&sab_driver); +if (err) { +kfree (sunsab_ports); + sunsab_ports =NULL ; + } + +return err; } static void __exit sunsab_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 713/1146 habanalabs: fix return value check in hl_fw_get_sec_attest_data()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 8749c27895a369a99e4a21709b3e3bec4785778f ]
If hl_cpu_accessible_dma_pool_alloc() fails, we should check 'req_cpu_addr', fix it.
--- drivers/misc/habanalabs/common/firmware_if.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/habanalabs/common/firmware_if.c +1 -1
@@ -2983,7 +2983,7 @@ static int hl_fw_get_sec_attest_data(struct hl_device *hdev, u32 packet_id, voidint rc; req_cpu_addr =hl_cpu_accessible_dma_pool_alloc (hdev, size, &req_dma_addr); -if (!data) { +if (!req_cpu_addr) {dev_err (hdev->dev,"Failed to allocate DMA memory for CPU-CP packet %u\n" , packet_id);return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 714/1146 test_firmware: fix memory leak in test_firmware_init()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit 7610615e8cdb3f6f5bbd9d8e7a5d8a63e3cabf2e ]
When misc_register() failed in test_firmware_init(), the memory pointed by test_fw_config->name is not released. The memory leak information is as follows:
unreferenced object 0xffff88810a34cb00 (size 32):
comm "insmod", pid 7952, jiffies 4294948236 (age 49.060s) hex dump (first 32 bytes):
74 65 73 74 2d 66 69 72 6d 77 61 72 65 2e 62 69 test-firmware.bi
6e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 n...............
backtrace:
[<ffffffff81b21fcb>] __kmalloc_node_track_caller+0x4b/0xc0
[<ffffffff81affb96>] kstrndup+0x46/0xc0
[<ffffffffa0403a49>] __test_firmware_config_init+0x29/0x380 [test_firmware]
[<ffffffffa040f068>] 0xffffffffa040f068
[<ffffffff81002c41>] do_one_initcall+0x141/0x780
[<ffffffff816a72c3>] do_init_module+0x1c3/0x630
[<ffffffff816adb9e>] load_module+0x623e/0x76a0
[<ffffffff816af471>] __do_sys_finit_module+0x181/0x240
[<ffffffff89978f99>] do_syscall_64+0x39/0xb0
[<ffffffff89a0008b>] entry_SYSCALL_64_after_hwframe+0x63/0xcd--- lib/test_firmware.c | 1 + 1 file changed, 1 insertion(+)
lib/test_firmware.c +1 -0
@@ -1491,6 +1491,7 @@ static int __init test_firmware_init(void) rc =misc_register (&test_fw_misc_device);if (rc) { +__test_firmware_config_free ();kfree (test_fw_config);pr_err ("could not register misc device: %d\n" , rc);return rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 715/1146 misc: ocxl: fix possible name leak in ocxl_file_register_afu()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit a4cb1004aeed2ab893a058fad00a5b41a12c4691 ]
If device_register() returns error in ocxl_file_register_afu(), the name allocated by dev_set_name() need be freed. As comment of device_register() says, it should use put_device() to give up the reference in the error path. So fix this by calling put_device(), then the name can be freed in kobject_cleanup(), and info is freed in info_release().
--- drivers/misc/ocxl/file.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/misc/ocxl/file.c +5 -2
@@ -541,8 +541,11 @@ int ocxl_file_register_afu(struct ocxl_afu *afu) goto err_put; rc =device_register (&info->dev); -if (rc) - goto err_put; +if (rc) { +free_minor (info); +put_device (&info->dev); +return rc; + } rc =ocxl_sysfs_register_afu (info);if (rc)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 716/1146 ocxl: fix pci device refcount leak when calling get_function_0()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 27158c72678b39ee01cc01de1aba6b51c71abe2f ]
get_function_0() calls pci_get_domain_bus_and_slot(), as comment says, it returns a pci device with refcount increment, so after using it, pci_dev_put() needs be called.
Get the device reference when get_function_0() is not called, so pci_dev_put() can be called in the error path and callers unconditionally. And add comment above get_dvsec_vendor0() to tell callers to call pci_dev_put().
--- drivers/misc/ocxl/config.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/misc/ocxl/config.c +19 -1
@@ -193,6 +193,18 @@ static int read_dvsec_vendor(struct pci_dev *dev)return 0 ; } +/** +* get_dvsec_vendor0() - Find a related PCI device (function 0) +* @dev: PCI device to match +* @dev0: The PCI device (function 0) found +* @out_pos: The position of PCI device (function 0) +* +* Returns 0 on success, negative on failure. +* +* NOTE: If it's successful, the reference of dev0 is increased, +* so after using it, the callers must call pci_dev_put() to give +* up the reference. +*/ static int get_dvsec_vendor0 (struct pci_dev *dev,struct pci_dev **dev0,int *out_pos) {
@@ -202,10 +214,14 @@ static int get_dvsec_vendor0(struct pci_dev *dev, struct pci_dev **dev0, dev =get_function_0 (dev);if (!dev)return -1 ; + }else { + dev =pci_dev_get (dev); } pos =find_dvsec (dev,OCXL_DVSEC_VENDOR_ID ); -if (!pos) +if (!pos) { +pci_dev_put (dev);return -1 ; + } *dev0 = dev; *out_pos = pos;return 0 ;
@@ -222,6 +238,7 @@ int ocxl_config_get_reset_reload(struct pci_dev *dev, int *val)pci_read_config_dword (dev0, pos +OCXL_DVSEC_VENDOR_RESET_RELOAD , &reset_reload); +pci_dev_put (dev0); *val = !!(reset_reload &BIT (0 ));return 0 ; }
@@ -243,6 +260,7 @@ int ocxl_config_set_reset_reload(struct pci_dev *dev, int val) reset_reload &= ~BIT (0 );pci_write_config_dword (dev0, pos +OCXL_DVSEC_VENDOR_RESET_RELOAD , reset_reload); +pci_dev_put (dev0);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 717/1146 misc: tifm: fix possible memory leak in tifm_7xx1_switch_media()
In reply to Greg Kroah-HartmanFrom: ruanjinjie <[email protected]>
[ Upstream commit fd2c930cf6a5b9176382c15f9acb1996e76e25ad ]
If device_register() returns error in tifm_7xx1_switch_media(), name of kobject which is allocated in dev_set_name() called in device_add() is leaked.
Never directly free @dev after calling device_register(), even if it returned an error! Always use put_device() to give up the reference initialized.
--- drivers/misc/tifm_7xx1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/tifm_7xx1.c +1 -1
@@ -190,7 +190,7 @@ static void tifm_7xx1_switch_media(struct work_struct *work)spin_unlock_irqrestore (&fm->lock, flags); }if (sock) -tifm_free_device (&sock->dev); +put_device (&sock->dev); }spin_lock_irqsave (&fm->lock, flags); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 718/1146 misc: sgi-gru: fix use-after-free error in gru_set_context_option, gru_fault and gru_handle_user_call_os
In reply to Greg Kroah-HartmanFrom: Zheng Wang <[email protected]>
[ Upstream commit 643a16a0eb1d6ac23744bb6e90a00fc21148a9dc ]
In some bad situation, the gts may be freed gru_check_chiplet_assignment. The call chain can be gru_unload_context->gru_free_gru_context->gts_drop and kfree finally. However, the caller didn't know if the gts is freed or not and use it afterwards. This will trigger a Use after Free bug.
Fix it by introducing a return value to see if it's in error path or not. Free the gts in caller if gru_check_chiplet_assignment check failed.
--- drivers/misc/sgi-gru/grufault.c | 13 +++++++++++-- drivers/misc/sgi-gru/grumain.c | 22 ++++++++++++++++++---- drivers/misc/sgi-gru/grutables.h | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-)
drivers/misc/sgi-gru/grufault.c +11 -2
@@ -648,6 +648,7 @@ int gru_handle_user_call_os(unsigned long cb)if ((cb & (GRU_HANDLE_STRIDE -1 )) || ucbnum >=GRU_NUM_CB )return -EINVAL ; +again: gts =gru_find_lock_gts (cb);if (!gts)return -EINVAL ;
@@ -656,7 +657,11 @@ int gru_handle_user_call_os(unsigned long cb)if (ucbnum >= gts->ts_cbr_au_count *GRU_CBR_AU_SIZE ) goto exit; -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +gru_unlock_gts (gts); +gru_unload_context (gts,1 ); + goto again; + }/* * CCH may contain stale data if ts_force_cch_reload is set.
@@ -874,7 +879,11 @@ int gru_set_context_option(unsigned long arg) }else { gts->ts_user_blade_id = req.val1; gts->ts_user_chiplet_id = req.val0; -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +gru_unlock_gts (gts); +gru_unload_context (gts,1 ); +return ret; + } }break ;case sco_gseg_owner:
drivers/misc/sgi-gru/grumain.c +18 -4
@@ -716,9 +716,10 @@ static int gru_check_chiplet_assignment(struct gru_state *gru,* chiplet. Misassignment can occur if the process migrates to a different * blade or if the user changes the selected blade/chiplet. */ -void gru_check_context_placement (struct gru_thread_state *gts) +int gru_check_context_placement (struct gru_thread_state *gts) {struct gru_state *gru; +int ret =0 ;/* * If the current task is the context owner, verify that the
@@ -726,15 +727,23 @@ void gru_check_context_placement(struct gru_thread_state *gts)* references. Pthread apps use non-owner references to the CBRs. */ gru = gts->ts_gru; +/* +* If gru or gts->ts_tgid_owner isn't initialized properly, return +* success to indicate that the caller does not need to unload the +* gru context.The caller is responsible for their inspection and +* reinitialization if needed. +*/ if (!gru || gts->ts_tgid_owner != current->tgid) -return ; +return ret;if (!gru_check_chiplet_assignment (gru, gts)) {STAT (check_context_unload); -gru_unload_context (gts,1 ); + ret = -EINVAL ; }else if (gru_retarget_intr (gts)) {STAT (check_context_retarget_intr); } + +return ret; }
@@ -934,7 +943,12 @@ vm_fault_t gru_fault(struct vm_fault *vmf)mutex_lock (>s->ts_ctxlock);preempt_disable (); -gru_check_context_placement (gts); +if (gru_check_context_placement (gts)) { +preempt_enable (); +mutex_unlock (>s->ts_ctxlock); +gru_unload_context (gts,1 ); +return VM_FAULT_NOPAGE ; + }if (!gts->ts_gru) {STAT (load_user_context);
drivers/misc/sgi-gru/grutables.h +1 -1
@@ -632,7 +632,7 @@ extern int gru_user_flush_tlb(unsigned long arg);extern int gru_user_unload_context (unsigned long arg);extern int gru_get_exception_detail (unsigned long arg);extern int gru_set_context_option (unsigned long address); -extern void gru_check_context_placement (struct gru_thread_state *gts); +extern int gru_check_context_placement (struct gru_thread_state *gts);extern int gru_cpu_fault_map_id (void );extern struct vm_area_struct *gru_find_vma (unsigned long vaddr);extern void gru_flush_all_tlb (struct gru_state *gru);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 719/1146 firmware: raspberrypi: fix possible memory leak in rpi_firmware_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 7b51161696e803fd5f9ad55b20a64c2df313f95c ]
In rpi_firmware_probe(), if mbox_request_channel() fails, the 'fw' will not be freed through rpi_firmware_delete(), fix this leak by calling kfree() in the error path.
--- drivers/firmware/raspberrypi.c | 1 + 1 file changed, 1 insertion(+)
drivers/firmware/raspberrypi.c +1 -0
@@ -272,6 +272,7 @@ static int rpi_firmware_probe(struct platform_device *pdev)int ret =PTR_ERR (fw->chan);if (ret != -EPROBE_DEFER )dev_err (dev,"Failed to get mbox channel: %d\n" , ret); +kfree (fw);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 720/1146 cxl: fix possible null-ptr-deref in cxl_guest_init_afu|adapter()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 61c80d1c3833e196256fb060382db94f24d3d9a7 ]
If device_register() fails in cxl_register_afu|adapter(), the device is not added, device_unregister() can not be called in the error path, otherwise it will cause a null-ptr-deref because of removing not added device.
As comment of device_register() says, it should use put_device() to give up the reference in the error path. So split device_unregister() into device_del() and put_device(), then goes to put dev when register fails.
--- drivers/misc/cxl/guest.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-)
drivers/misc/cxl/guest.c +14 -10
@@ -965,10 +965,10 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_n* if it returns an error! */ if ((rc =cxl_register_afu (afu))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_afu_add (afu))) - goto err_put1; + goto err_del_dev;/* * pHyp doesn't expose the programming models supported by the
@@ -984,7 +984,7 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_n afu->modes_supported =CXL_MODE_DIRECTED ;if ((rc =cxl_afu_select_best_mode (afu))) - goto err_put2; + goto err_remove_sysfs; adapter->afu[afu->slice] = afu;
@@ -1004,10 +1004,12 @@ int cxl_guest_init_afu(struct cxl *adapter, int slice, struct device_node *afu_nreturn 0 ; -err_put2: +err_remove_sysfs:cxl_sysfs_afu_remove (afu); -err_put1: -device_unregister (&afu->dev); +err_del_dev: +device_del (&afu->dev); +err_put_dev: +put_device (&afu->dev); free = false;guest_release_serr_irq (afu); err2:
@@ -1141,18 +1143,20 @@ struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_devic* even if it returns an error! */ if ((rc =cxl_register_adapter (adapter))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_adapter_add (adapter))) - goto err_put1; + goto err_del_dev;/* release the context lock as the adapter is configured */ cxl_adapter_context_unlock (adapter);return adapter; -err_put1: -device_unregister (&adapter->dev); +err_del_dev: +device_del (&adapter->dev); +err_put_dev: +put_device (&adapter->dev); free = false;cxl_guest_remove_chardev (adapter); err1:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 721/1146 cxl: fix possible null-ptr-deref in cxl_pci_init_afu|adapter()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 02cd3032b154fa02fdf90e7467abaeed889330b2 ]
If device_register() fails in cxl_pci_afu|adapter(), the device is not added, device_unregister() can not be called in the error path, otherwise it will cause a null-ptr-deref because of removing not added device.
As comment of device_register() says, it should use put_device() to give up the reference in the error path. So split device_unregister() into device_del() and put_device(), then goes to put dev when register fails.
--- drivers/misc/cxl/pci.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)
drivers/misc/cxl/pci.c +12 -8
@@ -1164,10 +1164,10 @@ static int pci_init_afu(struct cxl *adapter, int slice, struct pci_dev *dev)* if it returns an error! */ if ((rc =cxl_register_afu (afu))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_afu_add (afu))) - goto err_put1; + goto err_del_dev; adapter->afu[afu->slice] = afu;
@@ -1176,10 +1176,12 @@ static int pci_init_afu(struct cxl *adapter, int slice, struct pci_dev *dev)return 0 ; -err_put1: +err_del_dev: +device_del (&afu->dev); +err_put_dev:pci_deconfigure_afu (afu);cxl_debugfs_afu_remove (afu); -device_unregister (&afu->dev); +put_device (&afu->dev);return rc; err_free_native:
@@ -1667,23 +1669,25 @@ static struct cxl *cxl_pci_init_adapter(struct pci_dev *dev)* even if it returns an error! */ if ((rc =cxl_register_adapter (adapter))) - goto err_put1; + goto err_put_dev;if ((rc =cxl_sysfs_adapter_add (adapter))) - goto err_put1; + goto err_del_dev;/* Release the context lock as adapter is configured */ cxl_adapter_context_unlock (adapter);return adapter; -err_put1: +err_del_dev: +device_del (&adapter->dev); +err_put_dev:/* This should mirror cxl_remove_adapter, except without the * sysfs parts */ cxl_debugfs_adapter_remove (adapter);cxl_deconfigure_adapter (adapter); -device_unregister (&adapter->dev); +put_device (&adapter->dev);return ERR_PTR (rc); err_release:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 722/1146 iio: temperature: ltc2983: make bulk write buffer DMA-safe
In reply to Greg Kroah-HartmanFrom: Cosmin Tanislav <[email protected]>
[ Upstream commit 5e0176213949724fbe9a8e4a39817edce337b8a0 ]
regmap_bulk_write() does not guarantee implicit DMA-safety, even though the current implementation duplicates the given buffer. Do not rely on it.
--- drivers/iio/temperature/ltc2983.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/iio/temperature/ltc2983.c +5 -5
@@ -209,6 +209,7 @@ struct ltc2983_data {* Holds the converted temperature */ __be32 temp__aligned(IIO_DMA_MINALIGN) ; +__be32 chan_val; };struct ltc2983_sensor {
@@ -313,19 +314,18 @@ static int __ltc2983_fault_handler(const struct ltc2983_data *st,return 0 ; } -static int __ltc2983_chan_assign_common (const struct ltc2983_data *st, +static int __ltc2983_chan_assign_common (struct ltc2983_data *st,const struct ltc2983_sensor *sensor,u32 chan_val) {u32 reg =LTC2983_CHAN_START_ADDR (sensor->chan); -__be32 __chan_val; chan_val |=LTC2983_CHAN_TYPE (sensor->type);dev_dbg (&st->spi->dev,"Assign reg:0x%04X, val:0x%08X\n" , reg, chan_val); - __chan_val =cpu_to_be32 (chan_val); -return regmap_bulk_write (st->regmap, reg, &__chan_val, -sizeof (__chan_val)); + st->chan_val =cpu_to_be32 (chan_val); +return regmap_bulk_write (st->regmap, reg, &st->chan_val, +sizeof (st->chan_val)); } static int __ltc2983_chan_custom_sensor_assign(struct ltc2983_data *st,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 723/1146 iio: adis: add __adis_enable_irq() implementation
In reply to Greg Kroah-HartmanFrom: Ramona Bolboaca <[email protected]>
[ Upstream commit 99c05e4283a19a02a256f14100ca4ec3b2da3f62 ]
Add '__adis_enable_irq()' implementation which is the unlocked version of 'adis_enable_irq()'.
Call '__adis_enable_irq()' instead of 'adis_enable_irq()' from '__adis_intial_startup()' to keep the expected unlocked functionality.
This fix is needed to remove a deadlock for all devices which are using 'adis_initial_startup()'. The deadlock occurs because the same mutex is acquired twice, without releasing it.
The mutex is acquired once inside 'adis_initial_startup()', before calling '__adis_initial_startup()', and once inside 'adis_enable_irq()', which is called by '__adis_initial_startup()'. The deadlock is removed by calling '__adis_enable_irq()', instead of 'adis_enable_irq()' from within '__adis_initial_startup()'.
--- drivers/iio/imu/adis.c | 28 ++++++++++------------------ include/linux/iio/imu/adis.h | 13 ++++++++++++- 2 files changed, 22 insertions(+), 19 deletions(-)
drivers/iio/imu/adis.c +10 -18
@@ -270,23 +270,19 @@ EXPORT_SYMBOL_NS(adis_debugfs_reg_access, IIO_ADISLIB);#endif /** -* adis_enable_irq() - Enable or disable data ready IRQ +* __adis_enable_irq() - Enable or disable data ready IRQ (unlocked) * @adis: The adis device * @enable: Whether to enable the IRQ * * Returns 0 on success, negative error code otherwise */ -int adis_enable_irq (struct adis *adis,bool enable) +int __adis_enable_irq (struct adis *adis,bool enable) { -int ret =0 ; +int ret;u16 msc; -mutex_lock (&adis->state_lock); - -if (adis->data->enable_irq) { - ret = adis->data->enable_irq (adis, enable); - goto out_unlock; - } +if (adis->data->enable_irq) +return adis->data->enable_irq (adis, enable);if (adis->data->unmasked_drdy) {if (enable)
@@ -294,12 +290,12 @@ int adis_enable_irq(struct adis *adis, bool enable)else disable_irq (adis->spi->irq); - goto out_unlock; +return 0 ; } ret =__adis_read_reg_16 (adis, adis->data->msc_ctrl_reg, &msc);if (ret) - goto out_unlock; +return ret; msc |=ADIS_MSC_CTRL_DATA_RDY_POL_HIGH ; msc &= ~ADIS_MSC_CTRL_DATA_RDY_DIO2 ;
@@ -308,13 +304,9 @@ int adis_enable_irq(struct adis *adis, bool enable)else msc &= ~ADIS_MSC_CTRL_DATA_RDY_EN ; - ret =__adis_write_reg_16 (adis, adis->data->msc_ctrl_reg, msc); - -out_unlock: -mutex_unlock (&adis->state_lock); -return ret; +return __adis_write_reg_16 (adis, adis->data->msc_ctrl_reg, msc); } -EXPORT_SYMBOL_NS (adis_enable_irq,IIO_ADISLIB ); +EXPORT_SYMBOL_NS (__adis_enable_irq,IIO_ADISLIB );/** * __adis_check_status() - Check the device for error conditions (unlocked)
@@ -445,7 +437,7 @@ int __adis_initial_startup(struct adis *adis)* with 'IRQF_NO_AUTOEN' anyways. */ if (!adis->data->unmasked_drdy) -adis_enable_irq (adis, false); +__adis_enable_irq (adis, false);if (!adis->data->prod_id_reg)return 0 ;
include/linux/iio/imu/adis.h +12 -1
@@ -402,9 +402,20 @@ static inline int adis_update_bits_base(struct adis *adis, unsigned int reg,__adis_update_bits_base (adis, reg, mask, val,sizeof (val)); \ }) -int adis_enable_irq (struct adis *adis,bool enable);int __adis_check_status (struct adis *adis);int __adis_initial_startup (struct adis *adis); +int __adis_enable_irq (struct adis *adis,bool enable); + +static inline int adis_enable_irq (struct adis *adis,bool enable) +{ +int ret; + +mutex_lock (&adis->state_lock); + ret =__adis_enable_irq (adis, enable); +mutex_unlock (&adis->state_lock); + +return ret; +}static inline int adis_check_status (struct adis *adis) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 724/1146 counter: stm32-lptimer-cnt: fix the check on arr and cmp registers update
In reply to Greg Kroah-HartmanFrom: Fabrice Gasnier <[email protected]>
[ Upstream commit fd5ac974fc25feed084c2d1599d0dddb4e0556bc ]
The ARR (auto reload register) and CMP (compare) registers are successively written. The status bits to check the update of these registers are polled together with regmap_read_poll_timeout(). The condition to end the loop may become true, even if one of the register isn't correctly updated.
So ensure both status bits are set before clearing them.
--- drivers/counter/stm32-lptimer-cnt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/counter/stm32-lptimer-cnt.c +1 -1
@@ -69,7 +69,7 @@ static int stm32_lptim_set_enable_state(struct stm32_lptim_cnt *priv,/* ensure CMP & ARR registers are properly written */ ret =regmap_read_poll_timeout (priv->regmap,STM32_LPTIM_ISR , val, - (val &STM32_LPTIM_CMPOK_ARROK ), + (val &STM32_LPTIM_CMPOK_ARROK ) ==STM32_LPTIM_CMPOK_ARROK ,100 ,1000 );if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 725/1146 coresight: trbe: remove cpuhp instance node before remove cpuhp state
In reply to Greg Kroah-HartmanFrom: Yang Shen <[email protected]>
[ Upstream commit 20ee8c223f792947378196307d8e707c9cdc2d61 ]
cpuhp_state_add_instance() and cpuhp_state_remove_instance() should be used in pairs. Or there will lead to the warn on cpuhp_remove_multi_state() since the cpuhp_step list is not empty.
The following is the error log with 'rmmod coresight-trbe':
Error: Removing state 215 which has instances left.
Call trace: __cpuhp_remove_state_cpuslocked+0x144/0x160 __cpuhp_remove_state+0xac/0x100 arm_trbe_device_remove+0x2c/0x60 [coresight_trbe] platform_remove+0x34/0x70 device_remove+0x54/0x90 device_release_driver_internal+0x1e4/0x250 driver_detach+0x5c/0xb0 bus_remove_driver+0x64/0xc0 driver_unregister+0x3c/0x70 platform_driver_unregister+0x20/0x30 arm_trbe_exit+0x1c/0x658 [coresight_trbe] __arm64_sys_delete_module+0x1ac/0x24c invoke_syscall+0x50/0x120 el0_svc_common.constprop.0+0x58/0x1a0 do_el0_svc+0x38/0xd0 el0_svc+0x2c/0xc0 el0t_64_sync_handler+0x1ac/0x1b0 el0t_64_sync+0x19c/0x1a0 ---[ end trace 0000000000000000 ]---
--- drivers/hwtracing/coresight/coresight-trbe.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwtracing/coresight/coresight-trbe.c +1 -0
@@ -1434,6 +1434,7 @@ static int arm_trbe_probe_cpuhp(struct trbe_drvdata *drvdata)static void arm_trbe_remove_cpuhp (struct trbe_drvdata *drvdata) { +cpuhp_state_remove_instance (drvdata->trbe_online, &drvdata->hotplug_node);cpuhp_remove_multi_state (drvdata->trbe_online); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 726/1146 coresight: cti: Fix null pointer error on CTI init before ETM
In reply to Greg Kroah-HartmanFrom: Mike Leach <[email protected]>
[ Upstream commit 3dc228b35387803d9c43ed1b098aabb1d3ae9c7d ]
When CTI is discovered first then the function coresight_set_assoc_ectdev_mutex() is called to set the association between CTI and ETM device. Recent lockdep fix passes a null pointer.
This patch passes the correct pointer.
Before patch: log of boot oops sequence with CTI discovered first:
[ 12.424091] cs_system_cfg: CoreSight Configuration manager initialised [ 12.483474] coresight cti_sys0: CTI initialized [ 12.488109] coresight cti_sys1: CTI initialized [ 12.503594] coresight cti_cpu0: CTI initialized [ 12.517877] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 12.523479] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized [ 12.529926] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized [ 12.541808] coresight stm0: STM32 initialized [ 12.544421] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized [ 12.585639] coresight cti_cpu1: CTI initialized [ 12.614028] coresight cti_cpu2: CTI initialized [ 12.631679] CSCFG registered etm0 [ 12.633920] coresight etm0: CPU0: etm v4.0 initialized [ 12.656392] coresight cti_cpu3: CTI initialized
...
[ 12.708383] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000348
...
[ 12.755094] Internal error: Oops: 0000000096000044 [#1] SMP [ 12.761817] Modules linked in: coresight_etm4x(+) coresight_tmc coresight_cpu_debug coresight_replicator coresight_funnel coresight_cti coresight_tpiu coresight_stm coresight [ 12.767210] CPU: 3 PID: 1346 Comm: systemd-udevd Not tainted 6.1.0-rc3tid-v6tid-v6-235166-gf7f7d7a2204a-dirty #498 [ 12.782827] Hardware name: Qualcomm Technologies, Inc. APQ 8016 SBC (DT) [ 12.793154] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 12.800010] pc : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight] [ 12.806694] lr : coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight]
...
[ 12.885064] Call trace: [ 12.892352] coresight_set_assoc_ectdev_mutex+0x30/0x50 [coresight] [ 12.894693] cti_add_assoc_to_csdev+0x144/0x1b0 [coresight_cti] [ 12.900943] coresight_register+0x2c8/0x320 [coresight] [ 12.906844] etm4_add_coresight_dev.isra.27+0x148/0x280 [coresight_etm4x] [ 12.912056] etm4_probe+0x144/0x1c0 [coresight_etm4x] [ 12.918998] etm4_probe_amba+0x40/0x78 [coresight_etm4x] [ 12.924032] amba_probe+0x11c/0x1f0
After patch: similar log
[ 12.444467] cs_system_cfg: CoreSight Configuration manager initialised [ 12.456329] coresight-cpu-debug 850000.debug: Coresight debug-CPU0 initialized [ 12.456754] coresight-cpu-debug 852000.debug: Coresight debug-CPU1 initialized [ 12.469672] coresight-cpu-debug 854000.debug: Coresight debug-CPU2 initialized [ 12.476098] coresight-cpu-debug 856000.debug: Coresight debug-CPU3 initialized [ 12.532409] coresight stm0: STM32 initialized [ 12.533708] coresight cti_sys0: CTI initialized [ 12.539478] coresight cti_sys1: CTI initialized [ 12.550106] coresight cti_cpu0: CTI initialized [ 12.633931] coresight cti_cpu1: CTI initialized [ 12.634664] coresight cti_cpu2: CTI initialized [ 12.638090] coresight cti_cpu3: CTI initialized [ 12.721136] CSCFG registered etm0
...
[ 12.762643] CSCFG registered etm1 [ 12.762666] coresight etm1: CPU1: etm v4.0 initialized [ 12.776258] CSCFG registered etm2 [ 12.776282] coresight etm2: CPU2: etm v4.0 initialized [ 12.784357] CSCFG registered etm3 [ 12.785455] coresight etm3: CPU3: etm v4.0 initialized
Error can also be triggered by manually starting the modules using modprobe in the following order:
root@linaro-developer:/home/linaro/cs-mods# modprobe coresight root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-cti root@linaro-developer:/home/linaro/cs-mods# modprobe coresight-etm4x
Tested on Dragonboard DB410c
Applies to coresight/next
--- drivers/hwtracing/coresight/coresight-cti-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwtracing/coresight/coresight-cti-core.c +1 -1
@@ -564,7 +564,7 @@ static void cti_add_assoc_to_csdev(struct coresight_device *csdev)* if we found a matching csdev then update the ECT * association pointer for the device with this CTI. */ -coresight_set_assoc_ectdev_mutex (csdev->ect_dev, +coresight_set_assoc_ectdev_mutex (csdev, ect_item->csdev);break ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 727/1146 tracing/user_events: Fix call print_fmt leak
In reply to Greg Kroah-HartmanFrom: Beau Belgrave <[email protected]>
[ Upstream commit 4bded7af8b9af6e97514b0521004f90267905aef ]
If user_event_trace_register() fails within user_event_parse() the call's print_fmt member is not freed. Add kfree call to fix this.
--- kernel/trace/trace_events_user.c | 1 + 1 file changed, 1 insertion(+)
kernel/trace/trace_events_user.c +1 -0
@@ -1359,6 +1359,7 @@ static int user_event_parse(struct user_event_group *group, char *name, put_user:user_event_destroy_fields (user);user_event_destroy_validators (user); +kfree (user->call.print_fmt);kfree (user);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 728/1146 usb: roles: fix of node refcount leak in usb_role_switch_is_parent()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 1ab30c610630da5391a373cddb8a065bf4c4bc01 ]
I got the following report while doing device(mt6370-tcpc) load test with CONFIG_OF_UNITTEST and CONFIG_OF_DYNAMIC enabled:
OF: ERROR: memory leak, expected refcount 1 instead of 2, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/pmic@34
The 'parent' returned by fwnode_get_parent() with refcount incremented. it needs be put after using.
--- drivers/usb/roles/class.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/usb/roles/class.c +4 -1
@@ -106,10 +106,13 @@ usb_role_switch_is_parent(struct fwnode_handle *fwnode)struct fwnode_handle *parent =fwnode_get_parent (fwnode);struct device *dev; -if (!parent || !fwnode_property_present (parent,"usb-role-switch" )) +if (!fwnode_property_present (parent,"usb-role-switch" )) { +fwnode_handle_put (parent);return NULL ; + } dev =class_find_device_by_fwnode (role_class, parent); +fwnode_handle_put (parent);return dev ?to_role_switch (dev) :ERR_PTR (-EPROBE_DEFER ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 729/1146 usb: core: hcd: Fix return value check in usb_hcd_setup_local_mem()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 3c347cdafa3db43337870006e5c2d7b78a8dae20 ]
If dmam_alloc_attrs() fails, it returns NULL pointer and never return ERR_PTR(), so repleace IS_ERR() with IS_ERR_OR_NULL() and if it's NULL, returns -ENOMEM.
--- drivers/usb/core/hcd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/core/hcd.c +5 -1
@@ -3133,8 +3133,12 @@ int usb_hcd_setup_local_mem(struct usb_hcd *hcd, phys_addr_t phys_addr,GFP_KERNEL , DMA_ATTR_WRITE_COMBINE); -if (IS_ERR (local_mem)) +if (IS_ERR_OR_NULL (local_mem)) { +if (!local_mem) +return -ENOMEM ; +return PTR_ERR (local_mem); + }/* * Here we pass a dma_addr_t but the arg type is a phys_addr_t.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 730/1146 usb: gadget: f_hid: fix f_hidg lifetime vs cdev
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit 89ff3dfac604614287ad5aad9370c3f984ea3f4b ]
The embedded struct cdev does not have its lifetime correctly tied to the enclosing struct f_hidg, so there is a use-after-free if /dev/hidgN is held open while the gadget is deleted.
This can readily be replicated with libusbgx's example programs (for conciseness - operating directly via configfs is equivalent):
gadget-hid exec 3<> /dev/hidg0 gadget-vid-pid-remove exec 3<&-
Pull the existing device up in to struct f_hidg and make use of the cdev_device_{add,del}() helpers. This changes the lifetime of the device object to match struct f_hidg, but note that it is still added and deleted at the same time.
--- drivers/usb/gadget/function/f_hid.c | 52 ++++++++++++++++------------- 1 file changed, 28 insertions(+), 24 deletions(-)
drivers/usb/gadget/function/f_hid.c +28 -24
@@ -71,7 +71,7 @@ struct f_hidg {wait_queue_head_t write_queue;struct usb_request *req; -int minor; +struct device dev;struct cdev cdev;struct usb_function func;
@@ -84,6 +84,14 @@ static inline struct f_hidg *func_to_hidg(struct usb_function *f) return container_of(f, struct f_hidg, func); } +static void hidg_release (struct device *dev) +{ + struct f_hidg *hidg = container_of(dev, struct f_hidg, dev); + +kfree (hidg->set_report_buf); +kfree (hidg); +} +/*-------------------------------------------------------------------------*/ /* Static descriptors */
@@ -904,9 +912,7 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)struct usb_ep *ep;struct f_hidg *hidg =func_to_hidg (f);struct usb_string *us; -struct device *device;int status; -dev_t dev;/* maybe allocate device-global string IDs, and patch descriptors */ us = usb_gstrings_attach(c->cdev, ct_func_strings,
@@ -999,21 +1005,11 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f)/* create char device */ cdev_init (&hidg->cdev, &f_hidg_fops); - dev =MKDEV (major, hidg->minor); - status =cdev_add (&hidg->cdev, dev,1 ); + status =cdev_device_add (&hidg->cdev, &hidg->dev);if (status) goto fail_free_descs; - device =device_create (hidg_class,NULL , dev,NULL , -"%s%d" ,"hidg" , hidg->minor); -if (IS_ERR (device)) { - status =PTR_ERR (device); - goto del; - } -return 0 ; -del: -cdev_del (&hidg->cdev); fail_free_descs:usb_free_all_descriptors (f); fail:
@@ -1244,9 +1240,7 @@ static void hidg_free(struct usb_function *f) hidg =func_to_hidg (f); opts = container_of(f->fi, struct f_hid_opts, func_inst); -kfree (hidg->report_desc); -kfree (hidg->set_report_buf); -kfree (hidg); +put_device (&hidg->dev);mutex_lock (&opts->lock); --opts->refcnt;mutex_unlock (&opts->lock);
@@ -1256,8 +1250,7 @@ static void hidg_unbind(struct usb_configuration *c, struct usb_function *f) {struct f_hidg *hidg =func_to_hidg (f); -device_destroy (hidg_class,MKDEV (major, hidg->minor)); -cdev_del (&hidg->cdev); +cdev_device_del (&hidg->cdev, &hidg->dev);usb_free_all_descriptors (f); }
@@ -1266,6 +1259,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) {struct f_hidg *hidg;struct f_hid_opts *opts; +int ret;/* allocate and initialize one new instance */ hidg =kzalloc (sizeof (*hidg),GFP_KERNEL );
@@ -1277,17 +1271,27 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi)mutex_lock (&opts->lock); ++opts->refcnt; - hidg->minor = opts->minor; +device_initialize (&hidg->dev); + hidg->dev.release = hidg_release; + hidg->dev.class = hidg_class; + hidg->dev.devt =MKDEV (major, opts->minor); + ret =dev_set_name (&hidg->dev,"hidg%d" , opts->minor); +if (ret) { + --opts->refcnt; +mutex_unlock (&opts->lock); +return ERR_PTR (ret); + } + hidg->bInterfaceSubClass = opts->subclass; hidg->bInterfaceProtocol = opts->protocol; hidg->report_length = opts->report_length; hidg->report_desc_length = opts->report_desc_length;if (opts->report_desc) { - hidg->report_desc =kmemdup (opts->report_desc, - opts->report_desc_length, -GFP_KERNEL ); + hidg->report_desc =devm_kmemdup (&hidg->dev, opts->report_desc, + opts->report_desc_length, +GFP_KERNEL );if (!hidg->report_desc) { -kfree (hidg); +put_device (&hidg->dev);mutex_unlock (&opts->lock);return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 731/1146 usb: gadget: f_hid: fix refcount leak on error path
In reply to Greg Kroah-HartmanFrom: John Keeping <[email protected]>
[ Upstream commit 70a3288a7586526315105c699b687d78cd32559a ]
When failing to allocate report_desc, opts->refcnt has already been incremented so it needs to be decremented to avoid leaving the options structure permanently locked.
--- drivers/usb/gadget/function/f_hid.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/function/f_hid.c +1 -0
@@ -1292,6 +1292,7 @@ static struct usb_function *hidg_alloc(struct usb_function_instance *fi) GFP_KERNEL);if (!hidg->report_desc) {put_device (&hidg->dev); + --opts->refcnt;mutex_unlock (&opts->lock);return ERR_PTR (-ENOMEM ); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 732/1146 drivers: mcb: fix resource leak in mcb_probe()
In reply to Greg Kroah-HartmanFrom: Zhengchao Shao <[email protected]>
[ Upstream commit d7237462561fcd224fa687c56ccb68629f50fc0d ]
When probe hook function failed in mcb_probe(), it doesn't put the device. Compiled test only.
--- drivers/mcb/mcb-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mcb/mcb-core.c +3 -1
@@ -71,8 +71,10 @@ static int mcb_probe(struct device *dev)get_device (dev); ret = mdrv->probe (mdev, found_id); -if (ret) +if (ret) {module_put (carrier_mod); +put_device (dev); + }return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 733/1146 mcb: mcb-parse: fix error handing in chameleon_parse_gdd()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 728ac3389296caf68638628c987aeae6c8851e2d ]
If mcb_device_register() returns error in chameleon_parse_gdd(), the refcount of bus and device name are leaked. Fix this by calling put_device() to give up the reference, so they can be released in mcb_release_dev() and kobject_cleanup().
--- drivers/mcb/mcb-parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mcb/mcb-parse.c +1 -1
@@ -108,7 +108,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,return 0 ; err: -mcb_free_dev (mdev); +put_device (&mdev->dev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 734/1146 chardev: fix error handling in cdev_device_add()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 11fa7fefe3d8fac7da56bc9aa3dd5fb3081ca797 ]
While doing fault injection test, I got the following report:
------------[ cut here ]------------ kobject: '(null)' (0000000039956980): is not initialized, yet kobject_put() is being called. WARNING: CPU: 3 PID: 6306 at kobject_put+0x23d/0x4e0 CPU: 3 PID: 6306 Comm: 283 Tainted: G W 6.1.0-rc2-00005-g307c1086d7c9 #1253 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 RIP: 0010:kobject_put+0x23d/0x4e0 Call Trace: <TASK> cdev_device_add+0x15e/0x1b0 __iio_device_register+0x13b4/0x1af0 [industrialio] __devm_iio_device_register+0x22/0x90 [industrialio] max517_probe+0x3d8/0x6b4 [max517] i2c_device_probe+0xa81/0xc00
When device_add() is injected fault and returns error, if dev->devt is not set, cdev_add() is not called, cdev_del() is not needed. Fix this by checking dev->devt in error path.
--- fs/char_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/char_dev.c +1 -1
@@ -547,7 +547,7 @@ int cdev_device_add(struct cdev *cdev, struct device *dev) } rc =device_add (dev); -if (rc) +if (rc && dev->devt)cdev_del (cdev);return rc;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 735/1146 vfio/iova_bitmap: refactor iova_bitmap_set() to better handle page boundaries
In reply to Greg Kroah-HartmanFrom: Joao Martins <[email protected]>
[ Upstream commit b058ea3ab5afea873ab8d976277539ca9e43869a ]
Commit f38044e5ef58 ("vfio/iova_bitmap: Fix PAGE_SIZE unaligned bitmaps") had fixed the unaligned bitmaps by capping the remaining iterable set at the start of the bitmap. Although, that mistakenly worked around iova_bitmap_set() incorrectly setting bits across page boundary.
Fix this by reworking the loop inside iova_bitmap_set() to iterate over a range of bits to set (cur_bit .. last_bit) which may span different pinned pages, thus updating @page_idx and @offset as it sets the bits. The previous cap to the first page is now adjusted to be always accounted rather than when there's only a non-zero pgoff.
While at it, make @page_idx , @offset and @nbits to be unsigned int given that it won't be more than 512 and 4096 respectively (even a bigger PAGE_SIZE or a smaller struct page size won't make this bigger than the above 32-bit max). Also, delete the stale kdoc on Return type.
--- drivers/vfio/iova_bitmap.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/vfio/iova_bitmap.c +13 -17
@@ -297,9 +297,7 @@ static unsigned long iova_bitmap_mapped_remaining(struct iova_bitmap *bitmap) {unsigned long remaining, bytes; -/* Cap to one page in the first iteration, if PAGE_SIZE unaligned. */ - bytes = !bitmap->mapped.pgoff ? bitmap->mapped.npages <<PAGE_SHIFT : -PAGE_SIZE - bitmap->mapped.pgoff; + bytes = (bitmap->mapped.npages <<PAGE_SHIFT ) - bitmap->mapped.pgoff; remaining = bitmap->mapped_total_index - bitmap->mapped_base_index; remaining = min_t(unsigned long, remaining,
@@ -398,29 +396,27 @@ int iova_bitmap_for_each(struct iova_bitmap *bitmap, void *opaque,* Set the bits corresponding to the range [iova .. iova+length-1] in * the user bitmap. * -* Return: The number of bits set. */ void iova_bitmap_set (struct iova_bitmap *bitmap,unsigned long iova,size_t length) {struct iova_bitmap_map *mapped = &bitmap->mapped; -unsigned long offset = (iova - mapped->iova) >> mapped->pgshift; - unsigned long nbits = max_t(unsigned long, 1, length >> mapped->pgshift); -unsigned long page_idx = offset /BITS_PER_PAGE ; -unsigned long page_offset = mapped->pgoff; -void *kaddr; - - offset = offset %BITS_PER_PAGE ; +unsigned long cur_bit = ((iova - mapped->iova) >> + mapped->pgshift) + mapped->pgoff *BITS_PER_BYTE ; +unsigned long last_bit = (((iova + length -1 ) - mapped->iova) >> + mapped->pgshift) + mapped->pgoff *BITS_PER_BYTE ;do { -unsigned long size =min (BITS_PER_PAGE - offset, nbits); +unsigned int page_idx = cur_bit /BITS_PER_PAGE ; +unsigned int offset = cur_bit %BITS_PER_PAGE ; +unsigned int nbits =min (BITS_PER_PAGE - offset, + last_bit - cur_bit +1 ); +void *kaddr; kaddr =kmap_local_page (mapped->pages[page_idx]); -bitmap_set (kaddr + page_offset, offset, size); +bitmap_set (kaddr, offset, nbits);kunmap_local (kaddr); - page_offset = offset =0 ; - nbits -= size; - page_idx++; - }while (nbits >0 ); + cur_bit += nbits; + }while (cur_bit <= last_bit); }EXPORT_SYMBOL_GPL (iova_bitmap_set);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 736/1146 i2c: pxa-pci: fix missing pci_disable_device() on error in ce4100_i2c_probe
In reply to Greg Kroah-HartmanFrom: Hui Tang <[email protected]>
[ Upstream commit d78a167332e1ca8113268ed922c1212fd71b73ad ]
Using pcim_enable_device() to avoid missing pci_disable_device().
--- drivers/i2c/busses/i2c-pxa-pci.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/i2c/busses/i2c-pxa-pci.c +3 -7
@@ -105,7 +105,7 @@ static int ce4100_i2c_probe(struct pci_dev *dev,int i;struct ce4100_devices *sds; - ret =pci_enable_device_mem (dev); + ret =pcim_enable_device (dev);if (ret)return ret;
@@ -114,10 +114,8 @@ static int ce4100_i2c_probe(struct pci_dev *dev,return -EINVAL ; } sds =kzalloc (sizeof (*sds),GFP_KERNEL ); -if (!sds) { - ret = -ENOMEM ; - goto err_mem; - } +if (!sds) +return -ENOMEM ;for (i =0 ; i <ARRAY_SIZE (sds->pdev); i++) { sds->pdev[i] =add_i2c_device (dev, i);
@@ -133,8 +131,6 @@ static int ce4100_i2c_probe(struct pci_dev *dev, err_dev_add:kfree (sds); -err_mem: -pci_disable_device (dev);return ret; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 737/1146 staging: rtl8192u: Fix use after free in ieee80211_rx()
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit bcc5e2dcf09089b337b76fc1a589f6ff95ca19ac ]
We cannot dereference the "skb" pointer after calling ieee80211_monitor_rx(), because it is a use after free.
--- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +3 -1
@@ -951,9 +951,11 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,#endif if (ieee->iw_mode ==IW_MODE_MONITOR ) { +unsigned int len = skb->len; +ieee80211_monitor_rx (ieee, skb, rx_stats); stats->rx_packets++; - stats->rx_bytes += skb->len; + stats->rx_bytes += len;return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 738/1146 staging: rtl8192e: Fix potential use-after-free in rtllib_rx_Monitor()
In reply to Greg Kroah-HartmanFrom: YueHaibing <[email protected]>
[ Upstream commit d30f4436f364b4ad915ca2c09be07cd0f93ceb44 ]
The skb is delivered to netif_rx() in rtllib_monitor_rx(), which may free it, after calling this, dereferencing skb may trigger use-after-free. Found by Smatch.
--- drivers/staging/rtl8192e/rtllib_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rtl8192e/rtllib_rx.c +1 -1
@@ -1489,9 +1489,9 @@ static int rtllib_rx_Monitor(struct rtllib_device *ieee, struct sk_buff *skb, hdrlen +=4 ; } -rtllib_monitor_rx (ieee, skb, rx_stats, hdrlen); ieee->stats.rx_packets++; ieee->stats.rx_bytes += skb->len; +rtllib_monitor_rx (ieee, skb, rx_stats, hdrlen);return 1 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 739/1146 vme: Fix error not catched in fake_init()
In reply to Greg Kroah-HartmanFrom: Chen Zhongjin <[email protected]>
[ Upstream commit 7bef797d707f1744f71156b21d41e3b8c946631f ]
In fake_init(), __root_device_register() is possible to fail but it's ignored, which can cause unregistering vme_root fail when exit.
general protection fault, probably for non-canonical address 0xdffffc000000008c KASAN: null-ptr-deref in range [0x0000000000000460-0x0000000000000467] RIP: 0010:root_device_unregister+0x26/0x60 Call Trace: <TASK> __x64_sys_delete_module+0x34f/0x540 do_syscall_64+0x38/0x90 entry_SYSCALL_64_after_hwframe+0x63/0xcd
Return error when __root_device_register() fails.
--- drivers/staging/vme_user/vme_fake.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/vme_user/vme_fake.c +2 -0
@@ -1073,6 +1073,8 @@ static int __init fake_init(void)/* We need a fake parent device */ vme_root =__root_device_register ("vme" ,THIS_MODULE ); +if (IS_ERR (vme_root)) +return PTR_ERR (vme_root);/* If we want to support more than one bridge at some point, we need to * dynamically allocate this so we get one per device.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 740/1146 gpiolib: cdev: fix NULL-pointer dereferences
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit 533aae7c94dbc2b14301cfd68ae7e0e90f0c8438 ]
There are several places where we can crash the kernel by requesting lines, unbinding the GPIO device, then calling any of the system calls relevant to the GPIO character device's annonymous file descriptors:ioctl(), read(), poll().
While I observed it with the GPIO simulator, it will also happen for any of the GPIO devices that can be hot-unplugged - for instance any HID GPIO expander (e.g. CP2112).
This affects both v1 and v2 uAPI.
This fixes it partially by checking if gdev->chip is not NULL but it doesn't entirely remedy the situation as we still have a race condition in which another thread can remove the device after the check.
--- drivers/gpio/gpiolib-cdev.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpio/gpiolib-cdev.c +27 -0
@@ -201,6 +201,9 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd,unsigned int i;int ret; +if (!lh->gdev->chip) +return -ENODEV ; +switch (cmd) {case GPIOHANDLE_GET_LINE_VALUES_IOCTL :/* NOTE: It's okay to read values of output lines */
@@ -1384,6 +1387,9 @@ static long linereq_ioctl(struct file *file, unsigned int cmd,struct linereq *lr = file->private_data;void __user *ip = (void __user *)arg; +if (!lr->gdev->chip) +return -ENODEV ; +switch (cmd) {case GPIO_V2_LINE_GET_VALUES_IOCTL :return linereq_get_values (lr, ip);
@@ -1410,6 +1416,9 @@ static __poll_t linereq_poll(struct file *file,struct linereq *lr = file->private_data;__poll_t events =0 ; +if (!lr->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &lr->wait, wait); if (!kfifo_is_empty_spinlocked_noirqsave(&lr->events,
@@ -1429,6 +1438,9 @@ static ssize_t linereq_read(struct file *file,ssize_t bytes_read =0 ;int ret; +if (!lr->gdev->chip) +return -ENODEV ; +if (count <sizeof (le))return -EINVAL ;
@@ -1716,6 +1728,9 @@ static __poll_t lineevent_poll(struct file *file,struct lineevent_state *le = file->private_data;__poll_t events =0 ; +if (!le->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &le->wait, wait);if (!kfifo_is_empty_spinlocked_noirqsave (&le->events, &le->wait.lock))
@@ -1740,6 +1755,9 @@ static ssize_t lineevent_read(struct file *file,ssize_t ge_size;int ret; +if (!le->gdev->chip) +return -ENODEV ; +/* * When compatible system call is being used the struct gpioevent_data, * in case of at least ia32, has different size due to the alignment
@@ -1821,6 +1839,9 @@ static long lineevent_ioctl(struct file *file, unsigned int cmd,void __user *ip = (void __user *)arg;struct gpiohandle_data ghd; +if (!le->gdev->chip) +return -ENODEV ; +/* * We can get the value for an event line but not set it, * because it is input by definition.
@@ -2407,6 +2428,9 @@ static __poll_t lineinfo_watch_poll(struct file *file,struct gpio_chardev_data *cdev = file->private_data;__poll_t events =0 ; +if (!cdev->gdev->chip) +return EPOLLHUP |EPOLLERR ; +poll_wait (file, &cdev->wait, pollt); if (!kfifo_is_empty_spinlocked_noirqsave(&cdev->events,
@@ -2425,6 +2449,9 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,int ret;size_t event_size; +if (!cdev->gdev->chip) +return -ENODEV ; +#ifndef CONFIG_GPIO_CDEV_V1 event_size =sizeof (struct gpio_v2_line_info_changed );if (count < event_size)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 741/1146 gpiolib: protect the GPIO device against being dropped while in use by user-space
In reply to Greg Kroah-HartmanFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit bdbbae241a04f387ba910b8609f95fad5f1470c7 ]
While any of the GPIO cdev syscalls is in progress, the kernel can call gpiochip_remove() (for instance, when a USB GPIO expander is disconnected) which will set gdev->chip to NULL after which any subsequent access will cause a crash.
To avoid that: use an RW-semaphore in which the syscalls take it for reading (so that we don't needlessly prohibit the user-space from calling syscalls simultaneously) while gpiochip_remove() takes it for writing so that it can only happen once all syscalls return.
--- drivers/gpio/gpiolib-cdev.c | 177 +++++++++++++++++++++++++++++++----- drivers/gpio/gpiolib.c | 4 + drivers/gpio/gpiolib.h | 5 + 3 files changed, 161 insertions(+), 25 deletions(-)
drivers/gpio/gpiolib-cdev.c +152 -25
@@ -55,6 +55,50 @@ static_assert(IS_ALIGNED(sizeof(struct gpio_v2_line_values), 8));* interface to gpiolib GPIOs via ioctl()s. */ +typedef __poll_t (*poll_fn )(struct file *,struct poll_table_struct *); +typedef long (*ioctl_fn )(struct file *,unsigned int ,unsigned long ); +typedef ssize_t (*read_fn )(struct file *,char __user *, +size_t count,loff_t *); + +static __poll_t call_poll_locked (struct file *file, +struct poll_table_struct *wait, +struct gpio_device *gdev,poll_fn func) +{ +__poll_t ret; + +down_read (&gdev->sem); + ret =func (file, wait); +up_read (&gdev->sem); + +return ret; +} + +static long call_ioctl_locked (struct file *file,unsigned int cmd, +unsigned long arg,struct gpio_device *gdev, +ioctl_fn func) +{ +long ret; + +down_read (&gdev->sem); + ret =func (file, cmd, arg); +up_read (&gdev->sem); + +return ret; +} + +static ssize_t call_read_locked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps, +struct gpio_device *gdev,read_fn func) +{ +ssize_t ret; + +down_read (&gdev->sem); + ret =func (file, buf, count, f_ps); +up_read (&gdev->sem); + +return ret; +} +/* * GPIO line handle management */
@@ -191,8 +235,8 @@ static long linehandle_set_config(struct linehandle_state *lh,return 0 ; } -static long linehandle_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long linehandle_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct linehandle_state *lh = file->private_data;void __user *ip = (void __user *)arg;
@@ -250,6 +294,15 @@ static long linehandle_ioctl(struct file *file, unsigned int cmd, } } +static long linehandle_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct linehandle_state *lh = file->private_data; + +return call_ioctl_locked (file, cmd, arg, lh->gdev, + linehandle_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long linehandle_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -1381,8 +1434,8 @@ static long linereq_set_config(struct linereq *lr, void __user *ip)return ret; } -static long linereq_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long linereq_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct linereq *lr = file->private_data;void __user *ip = (void __user *)arg;
@@ -1402,6 +1455,15 @@ static long linereq_ioctl(struct file *file, unsigned int cmd, } } +static long linereq_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct linereq *lr = file->private_data; + +return call_ioctl_locked (file, cmd, arg, lr->gdev, + linereq_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long linereq_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -1410,8 +1472,8 @@ static long linereq_ioctl_compat(struct file *file, unsigned int cmd, }#endif -static __poll_t linereq_poll (struct file *file, -struct poll_table_struct *wait) +static __poll_t linereq_poll_unlocked (struct file *file, +struct poll_table_struct *wait) {struct linereq *lr = file->private_data;__poll_t events =0 ;
@@ -1428,10 +1490,16 @@ static __poll_t linereq_poll(struct file *file,return events; } -static ssize_t linereq_read (struct file *file, -char __user *buf, -size_t count, -loff_t *f_ps) +static __poll_t linereq_poll (struct file *file, +struct poll_table_struct *wait) +{ +struct linereq *lr = file->private_data; + +return call_poll_locked (file, wait, lr->gdev, linereq_poll_unlocked); +} + +static ssize_t linereq_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) {struct linereq *lr = file->private_data;struct gpio_v2_line_event le;
@@ -1485,6 +1553,15 @@ static ssize_t linereq_read(struct file *file,return bytes_read; } +static ssize_t linereq_read (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) +{ +struct linereq *lr = file->private_data; + +return call_read_locked (file, buf, count, f_ps, lr->gdev, + linereq_read_unlocked); +} +static void linereq_free (struct linereq *lr) {unsigned int i;
@@ -1722,8 +1799,8 @@ struct lineevent_state { (GPIOEVENT_REQUEST_RISING_EDGE | \ GPIOEVENT_REQUEST_FALLING_EDGE) -static __poll_t lineevent_poll (struct file *file, -struct poll_table_struct *wait) +static __poll_t lineevent_poll_unlocked (struct file *file, +struct poll_table_struct *wait) {struct lineevent_state *le = file->private_data;__poll_t events =0 ;
@@ -1739,15 +1816,21 @@ static __poll_t lineevent_poll(struct file *file,return events; } +static __poll_t lineevent_poll (struct file *file, +struct poll_table_struct *wait) +{ +struct lineevent_state *le = file->private_data; + +return call_poll_locked (file, wait, le->gdev, lineevent_poll_unlocked); +} +struct compat_gpioeevent_data {compat_u64 timestamp;u32 id; }; -static ssize_t lineevent_read (struct file *file, -char __user *buf, -size_t count, -loff_t *f_ps) +static ssize_t lineevent_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) {struct lineevent_state *le = file->private_data;struct gpioevent_data ge;
@@ -1815,6 +1898,15 @@ static ssize_t lineevent_read(struct file *file,return bytes_read; } +static ssize_t lineevent_read (struct file *file,char __user *buf, +size_t count,loff_t *f_ps) +{ +struct lineevent_state *le = file->private_data; + +return call_read_locked (file, buf, count, f_ps, le->gdev, + lineevent_read_unlocked); +} +static void lineevent_free (struct lineevent_state *le) {if (le->irq)
@@ -1832,8 +1924,8 @@ static int lineevent_release(struct inode *inode, struct file *file)return 0 ; } -static long lineevent_ioctl (struct file *file,unsigned int cmd, -unsigned long arg) +static long lineevent_ioctl_unlocked (struct file *file,unsigned int cmd, +unsigned long arg) {struct lineevent_state *le = file->private_data;void __user *ip = (void __user *)arg;
@@ -1864,6 +1956,15 @@ static long lineevent_ioctl(struct file *file, unsigned int cmd,return -EINVAL ; } +static long lineevent_ioctl (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct lineevent_state *le = file->private_data; + +return call_ioctl_locked (file, cmd, arg, le->gdev, + lineevent_ioctl_unlocked); +} +#ifdef CONFIG_COMPAT static long lineevent_ioctl_compat (struct file *file,unsigned int cmd,unsigned long arg)
@@ -2422,8 +2523,8 @@ static int lineinfo_changed_notify(struct notifier_block *nb,return NOTIFY_OK ; } -static __poll_t lineinfo_watch_poll (struct file *file, -struct poll_table_struct *pollt) +static __poll_t lineinfo_watch_poll_unlocked (struct file *file, +struct poll_table_struct *pollt) {struct gpio_chardev_data *cdev = file->private_data;__poll_t events =0 ;
@@ -2440,8 +2541,17 @@ static __poll_t lineinfo_watch_poll(struct file *file,return events; } -static ssize_t lineinfo_watch_read (struct file *file,char __user *buf, -size_t count,loff_t *off) +static __poll_t lineinfo_watch_poll (struct file *file, +struct poll_table_struct *pollt) +{ +struct gpio_chardev_data *cdev = file->private_data; + +return call_poll_locked (file, pollt, cdev->gdev, + lineinfo_watch_poll_unlocked); +} + +static ssize_t lineinfo_watch_read_unlocked (struct file *file,char __user *buf, +size_t count,loff_t *off) {struct gpio_chardev_data *cdev = file->private_data;struct gpio_v2_line_info_changed event;
@@ -2519,6 +2629,15 @@ static ssize_t lineinfo_watch_read(struct file *file, char __user *buf,return bytes_read; } +static ssize_t lineinfo_watch_read (struct file *file,char __user *buf, +size_t count,loff_t *off) +{ +struct gpio_chardev_data *cdev = file->private_data; + +return call_read_locked (file, buf, count, off, cdev->gdev, + lineinfo_watch_read_unlocked); +} +/** * gpio_chrdev_open() - open the chardev for ioctl operations * @inode: inode for this chardev
@@ -2532,13 +2651,17 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)struct gpio_chardev_data *cdev;int ret = -ENOMEM ; +down_read (&gdev->sem); +/* Fail on open if the backing gpiochip is gone */ -if (!gdev->chip) -return -ENODEV ; +if (!gdev->chip) { + ret = -ENODEV ; + goto out_unlock; + } cdev =kzalloc (sizeof (*cdev),GFP_KERNEL );if (!cdev) -return -ENOMEM ; + goto out_unlock; cdev->watched_lines =bitmap_zalloc (gdev->chip->ngpio,GFP_KERNEL );if (!cdev->watched_lines)
@@ -2561,6 +2684,8 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)if (ret) goto out_unregister_notifier; +up_read (&gdev->sem); +return ret; out_unregister_notifier:
@@ -2570,6 +2695,8 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)bitmap_free (cdev->watched_lines); out_free_cdev:kfree (cdev); +out_unlock: +up_read (&gdev->sem);return ret; }
drivers/gpio/gpiolib.c +4 -0
@@ -735,6 +735,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,spin_unlock_irqrestore (&gpio_lock, flags);BLOCKING_INIT_NOTIFIER_HEAD (&gdev->notifier); +init_rwsem (&gdev->sem);#ifdef CONFIG_PINCTRL INIT_LIST_HEAD (&gdev->pin_ranges);
@@ -875,6 +876,8 @@ void gpiochip_remove(struct gpio_chip *gc)unsigned long flags;unsigned int i; +down_write (&gdev->sem); +/* FIXME: should the legacy sysfs handling be moved to gpio_device? */ gpiochip_sysfs_unregister (gdev);gpiochip_free_hogs (gc);
@@ -909,6 +912,7 @@ void gpiochip_remove(struct gpio_chip *gc)* gone. */ gcdev_unregister (gdev); +up_write (&gdev->sem);put_device (&gdev->dev); }EXPORT_SYMBOL_GPL (gpiochip_remove);
drivers/gpio/gpiolib.h +5 -0
@@ -15,6 +15,7 @@#include <linux/device.h> #include <linux/module.h> #include <linux/cdev.h> +#include <linux/rwsem.h> #define GPIOCHIP_NAME "gpiochip"
@@ -39,6 +40,9 @@* @list: links gpio_device:s together for traversal * @notifier: used to notify subscribers about lines being requested, released * or reconfigured +* @sem: protects the structure from a NULL-pointer dereference of @chip by +* user-space operations when the device gets unregistered during +* a hot-unplug event * @pin_ranges: range of pins served by the GPIO driver * * This state container holds most of the runtime variable data
@@ -60,6 +64,7 @@ struct gpio_device {void *data;struct list_head list;struct blocking_notifier_head notifier; +struct rw_semaphore sem;#ifdef CONFIG_PINCTRL /*
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 742/1146 i2c: mux: reg: check return value after calling platform_get_resource()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 2d47b79d2bd39cc6369eccf94a06568d84c906ae ]
It will cause null-ptr-deref in resource_size(), if platform_get_resource() returns NULL, move calling resource_size() after devm_ioremap_resource() that will check 'res' to avoid null-ptr-deref.
And use devm_platform_get_and_ioremap_resource() to simplify code.
--- drivers/i2c/muxes/i2c-mux-reg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/i2c/muxes/i2c-mux-reg.c +2 -3
@@ -183,13 +183,12 @@ static int i2c_mux_reg_probe(struct platform_device *pdev)if (!mux->data.reg) {dev_info (&pdev->dev,"Register not set, using platform resource\n" ); - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - mux->data.reg_size =resource_size (res); - mux->data.reg =devm_ioremap_resource (&pdev->dev, res); + mux->data.reg =devm_platform_get_and_ioremap_resource (pdev,0 , &res);if (IS_ERR (mux->data.reg)) { ret =PTR_ERR (mux->data.reg); goto err_put_parent; } + mux->data.reg_size =resource_size (res); } if (mux->data.reg_size != 4 && mux->data.reg_size != 2 &&
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 743/1146 i2c: ismt: Fix an out-of-bounds bug in ismt_access()
In reply to Greg Kroah-HartmanFrom: Zheyu Ma <[email protected]>
[ Upstream commit 39244cc754829bf707dccd12e2ce37510f5b1f8d ]
When the driver does not check the data from the user, the variable 'data->block[0]' may be very large to cause an out-of-bounds bug.
The following log can reveal it:
[ 33.995542] i2c i2c-1: ioctl, cmd=0x720, arg=0x7ffcb3dc3a20 [ 33.995978] ismt_smbus 0000:00:05.0: I2C_SMBUS_BLOCK_DATA: WRITE [ 33.996475] ================================================================== [ 33.996995] BUG: KASAN: out-of-bounds in ismt_access.cold+0x374/0x214b [ 33.997473] Read of size 18446744073709551615 at addr ffff88810efcfdb1 by task ismt_poc/485 [ 33.999450] Call Trace: [ 34.001849] memcpy+0x20/0x60 [ 34.002077] ismt_access.cold+0x374/0x214b [ 34.003382] __i2c_smbus_xfer+0x44f/0xfb0 [ 34.004007] i2c_smbus_xfer+0x10a/0x390 [ 34.004291] i2cdev_ioctl_smbus+0x2c8/0x710 [ 34.005196] i2cdev_ioctl+0x5ec/0x74c
Fix this bug by checking the size of 'data->block[0]' first.
--- drivers/i2c/busses/i2c-ismt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/i2c/busses/i2c-ismt.c +3 -0
@@ -509,6 +509,9 @@ static int ismt_access(struct i2c_adapter *adap, u16 addr,if (read_write ==I2C_SMBUS_WRITE ) {/* Block Write */ dev_dbg (dev,"I2C_SMBUS_BLOCK_DATA: WRITE\n" ); +if (data->block[0 ] <1 || data->block[0 ] >I2C_SMBUS_BLOCK_MAX ) +return -EINVAL ; + dma_size = data->block[0 ] +1 ; dma_direction =DMA_TO_DEVICE ; desc->wr_len_cmd = dma_size;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 744/1146 usb: storage: Add check for kcalloc
In reply to Greg Kroah-HartmanFrom: Jiasheng Jiang <[email protected]>
[ Upstream commit c35ca10f53c51eeb610d3f8fbc6dd6d511b58a58 ]
As kcalloc may return NULL pointer, the return value should be checked and return error if fails as same as the ones in alauda_read_map.
--- drivers/usb/storage/alauda.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/storage/alauda.c +2 -0
@@ -438,6 +438,8 @@ static int alauda_init_media(struct us_data *us) + MEDIA_INFO(us).blockshift + MEDIA_INFO(us).pageshift);MEDIA_INFO (us).pba_to_lba =kcalloc (num_zones,sizeof (u16 *),GFP_NOIO );MEDIA_INFO (us).lba_to_pba =kcalloc (num_zones,sizeof (u16 *),GFP_NOIO ); +if (MEDIA_INFO (us).pba_to_lba ==NULL ||MEDIA_INFO (us).lba_to_pba ==NULL ) +return USB_STOR_TRANSPORT_ERROR ;if (alauda_reset_media (us) !=USB_STOR_XFER_GOOD )return USB_STOR_TRANSPORT_ERROR ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 745/1146 usb: typec: wusb3801: fix fwnode refcount leak in wusb3801_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit dc18a4c7b3bd447cef2395deeb1f6ac16dfaca0e ]
I got the following report while doing fault injection test:
OF: ERROR: memory leak, expected refcount 1 instead of 4, of_node_get()/of_node_put() unbalanced - destroy cset entry:
attach overlay node /i2c/tcpc@60/connector
If wusb3801_hw_init() fails, fwnode_handle_put() needs be called to avoid refcount leak.
--- drivers/usb/typec/wusb3801.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/wusb3801.c +1 -1
@@ -364,7 +364,7 @@ static int wusb3801_probe(struct i2c_client *client)/* Initialize the hardware with the devicetree settings. */ ret =wusb3801_hw_init (wusb3801);if (ret) -return ret; + goto err_put_connector; wusb3801->cap.revision =USB_TYPEC_REV_1_2 ; wusb3801->cap.accessory[0 ] =TYPEC_ACCESSORY_AUDIO ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 746/1146 tracing/hist: Fix issue of losting command info in error_log
In reply to Greg Kroah-HartmanFrom: Zheng Yejian <[email protected]>
[ Upstream commit 608c6ed3337850c767ab0dd6c583477922233e29 ]
When input some constructed invalid 'trigger' command, command info in 'error_log' are lost [1].
The root cause is that there is a path that event_hist_trigger_parse() is recursely called once and 'last_cmd' which save origin command is cleared, then later calling of hist_err() will no longer record origin command info:
event_hist_trigger_parse() {
last_cmd_set() // <1> 'last_cmd' save origin command here at first
create_actions() {
onmatch_create() {
action_create() {
trace_action_create() {
trace_action_create_field_var() {
create_field_var_hist() {
event_hist_trigger_parse() { // <2> recursely called once
hist_err_clear() // <3> 'last_cmd' is cleared here
}
hist_err() // <4> No longer find origin command!!!Since 'glob' is empty string while running into the recurse call, we can trickly check it and bypass the call of hist_err_clear() to solve it.
[1]
# cd /sys/kernel/tracing
# echo "my_synth_event int v1; int v2; int v3;" >> synthetic_events
# echo 'hist:keys=pid' >> events/sched/sched_waking/trigger
# echo "hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(\
pid,pid1)" >> events/sched/sched_switch/trigger
# cat error_log
[ 8.405018] hist:sched:sched_switch: error: Couldn't find synthetic event
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.816902] hist:sched:sched_switch: error: Couldn't find field
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.816902] hist:sched:sched_switch: error: Couldn't parse field variable
Command:
hist:keys=next_pid:onmatch(sched.sched_waking).my_synth_event(pid,pid1)
^
[ 8.999880] : error: Couldn't find field
Command:
^
[ 8.999880] : error: Couldn't parse field variable
Command:
^
[ 8.999880] : error: Couldn't find field
Command:
^
[ 8.999880] : error: Couldn't create histogram for field
Command:
^--- kernel/trace/trace_events_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
@@ -6438,7 +6438,7 @@ static int event_hist_trigger_parse(struct event_command *cmd_ops,if (se) se->ref++; out: -if (ret ==0 ) +if (ret ==0 && glob[0 ])hist_err_clear ();return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 747/1146 ksmbd: Fix resource leak in ksmbd_session_rpc_open()
In reply to Greg Kroah-HartmanFrom: Xiu Jianfeng <[email protected]>
[ Upstream commit bc044414fa0326a4e5c3c509c00b1fcaf621b5f4 ]
When ksmbd_rpc_open() fails then it must call ksmbd_rpc_id_free() to undo the result of ksmbd_ipc_id_alloc().
--- fs/ksmbd/mgmt/user_session.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/ksmbd/mgmt/user_session.c +5 -3
@@ -108,15 +108,17 @@ int ksmbd_session_rpc_open(struct ksmbd_session *sess, char *rpc_name) entry->method = method; entry->id =ksmbd_ipc_id_alloc ();if (entry->id <0 ) - goto error; + goto free_entry; resp =ksmbd_rpc_open (sess, entry->id);if (!resp) - goto error; + goto free_id;kvfree (resp);return entry->id; -error: +free_id: +ksmbd_rpc_id_free (entry->id); +free_entry:list_del (&entry->list);kfree (entry);return -EINVAL ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 748/1146 samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit d1f0f50fbbbbca1e3e8157e51934613bf88f6d44 ]
Add missing pci_disable_device() in fail path of mdpy_fb_probe(). Besides, fix missing release functions in mdpy_fb_remove().
--- samples/vfio-mdev/mdpy-fb.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
samples/vfio-mdev/mdpy-fb.c +7 -1
@@ -109,7 +109,7 @@ static int mdpy_fb_probe(struct pci_dev *pdev, ret =pci_request_regions (pdev,"mdpy-fb" );if (ret <0 ) -return ret; + goto err_disable_dev;pci_read_config_dword (pdev,MDPY_FORMAT_OFFSET , &format);pci_read_config_dword (pdev,MDPY_WIDTH_OFFSET , &width);
@@ -191,6 +191,9 @@ static int mdpy_fb_probe(struct pci_dev *pdev, err_release_regions:pci_release_regions (pdev); +err_disable_dev: +pci_disable_device (pdev); +return ret; }
@@ -199,7 +202,10 @@ static void mdpy_fb_remove(struct pci_dev *pdev)struct fb_info *info =pci_get_drvdata (pdev);unregister_framebuffer (info); +iounmap (info->screen_base);framebuffer_release (info); +pci_release_regions (pdev); +pci_disable_device (pdev); }static struct pci_device_id mdpy_fb_pci_table[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 749/1146 thermal/drivers/imx8mm_thermal: Validate temperature range
In reply to Greg Kroah-HartmanFrom: Marcus Folkesson <[email protected]>
[ Upstream commit d37edc7370273306d8747097fafa62436c1cfe16 ]
Check against the upper temperature limit (125 degrees C) before consider the temperature valid.
--- drivers/thermal/imx8mm_thermal.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/thermal/imx8mm_thermal.c +7 -1
@@ -65,8 +65,14 @@ static int imx8mm_tmu_get_temp(void *data, int *temp)u32 val; val =readl_relaxed (tmu->base +TRITSR ) &TRITSR_TEMP0_VAL_MASK ; + +/* +* Do not validate against the V bit (bit 31) due to errata +* ERR051272: TMU: Bit 31 of registers TMU_TSCR/TMU_TRITSR/TMU_TRATSR invalid +*/ + *temp = val *1000 ; -if (*temp <VER1_TEMP_LOW_LIMIT ) +if (*temp <VER1_TEMP_LOW_LIMIT || *temp >VER2_TEMP_HIGH_LIMIT )return -EAGAIN ;return 0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 750/1146 thermal/drivers/k3_j72xx_bandgap: Fix the debug print message
In reply to Greg Kroah-HartmanFrom: Keerthy <[email protected]>
[ Upstream commit a7c42af78b19a11e98a5555a664c343e3a672632 ]
The debug print message to check the workaround applicability is inverted. Fix the same.
--- drivers/thermal/k3_j72xx_bandgap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/k3_j72xx_bandgap.c +1 -1
@@ -439,7 +439,7 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev) workaround_needed = false;dev_dbg (bgp->dev,"Work around %sneeded\n" , - workaround_needed ?"not " :"" ); + workaround_needed ?"" :"not " );if (!workaround_needed)init_table (5 , ref_table, golden_factors);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 751/1146 thermal/of: Fix memory leak on thermal_of_zone_register() failure
In reply to Greg Kroah-HartmanFrom: Ido Schimmel <[email protected]>
[ Upstream commit 7ef2f023c2c77a452ba5d0c9b1ad04a5a895d553 ]
The function does not free 'of_ops' upon failure, leading to a memory leak [1].
Fix by freeing 'of_ops' in the error path.
[1]
unreferenced object 0xffff8ee846198c80 (size 128):
comm "swapper/0", pid 1, jiffies 4294699704 (age 70.076s) hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
d0 3f 6e 8c ff ff ff ff 00 00 00 00 00 00 00 00 .?n.............
backtrace:
[<00000000d136f562>] __kmalloc_node_track_caller+0x42/0x120
[<0000000063f31678>] kmemdup+0x1d/0x40
[<00000000e6d24096>] thermal_of_zone_register+0x49/0x520
[<000000005e78c755>] devm_thermal_of_zone_register+0x54/0x90
[<00000000ee6b209e>] pmbus_add_sensor+0x1b4/0x1d0
[<00000000896105e3>] pmbus_add_sensor_attrs_one+0x123/0x440
[<0000000049e990a6>] pmbus_add_sensor_attrs+0xfe/0x1d0
[<00000000466b5440>] pmbus_do_probe+0x66b/0x14e0
[<0000000084d42285>] i2c_device_probe+0x13b/0x2f0
[<0000000029e2ae74>] really_probe+0xce/0x2c0
[<00000000692df15c>] driver_probe_device+0x19/0xd0
[<00000000547d9cce>] __device_attach_driver+0x6f/0x100
[<0000000020abd24b>] bus_for_each_drv+0x76/0xc0
[<00000000665d9563>] __device_attach+0xfc/0x180
[<000000008ddd4d6a>] bus_probe_device+0x82/0xa0
[<000000009e61132b>] device_add+0x3fe/0x920--- drivers/thermal/thermal_of.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/thermal/thermal_of.c +6 -2
@@ -604,13 +604,15 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,if (IS_ERR (np)) {if (PTR_ERR (np) != -ENODEV )pr_err ("Failed to find thermal zone for %pOFn id=%d\n" , sensor, id); -return ERR_CAST (np); + ret =PTR_ERR (np); + goto out_kfree_of_ops; } trips =thermal_of_trips_init (np, &ntrips);if (IS_ERR (trips)) {pr_err ("Failed to find trip points for %pOFn id=%d\n" , sensor, id); -return ERR_CAST (trips); + ret =PTR_ERR (trips); + goto out_kfree_of_ops; } ret =thermal_of_monitor_init (np, &delay, &pdelay);
@@ -659,6 +661,8 @@ struct thermal_zone_device *thermal_of_zone_register(struct device_node *sensor,kfree (tzp); out_kfree_trips:kfree (trips); +out_kfree_of_ops: +kfree (of_ops);return ERR_PTR (ret); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 752/1146 thermal/drivers/qcom/temp-alarm: Fix inaccurate warning for gen2
In reply to Greg Kroah-HartmanFrom: Luca Weiss <[email protected]>
[ Upstream commit 8763f8acbf8aef22a2321d4c978cd078aa3b8f64 ]
On gen2 chips the stage2 threshold is not 140 degC but 125 degC.
Make the warning message clearer by using this variable and also by including the temperature that was checked for.
--- drivers/thermal/qcom/qcom-spmi-temp-alarm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/thermal/qcom/qcom-spmi-temp-alarm.c +2 -1
@@ -252,7 +252,8 @@ static int qpnp_tm_update_critical_trip_temp(struct qpnp_tm_chip *chip, disable_s2_shutdown = true; else dev_warn(chip->dev, - "No ADC is configured and critical temperature is above the maximum stage 2 threshold of 140 C! Configuring stage 2 shutdown at 140 C.\n"); +"No ADC is configured and critical temperature %d mC is above the maximum stage 2 threshold of %ld mC! Configuring stage 2 shutdown at %ld mC.\n" , + temp, stage2_threshold_max, stage2_threshold_max); } skip:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 753/1146 thermal/drivers/qcom/lmh: Fix irq handler return value
In reply to Greg Kroah-HartmanFrom: Bjorn Andersson <[email protected]>
[ Upstream commit 46a891e45be97c6781ac34f5ec777d69370e252b ]
After enough invocations the LMh irq is eventually reported as bad, because the handler doesn't return IRQ_HANDLED, fix this.
--- drivers/thermal/qcom/lmh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/qcom/lmh.c +1 -1
@@ -45,7 +45,7 @@ static irqreturn_t lmh_handle_irq(int hw_irq, void *data)if (irq)generic_handle_irq (irq); -return 0 ; +return IRQ_HANDLED ; }static void lmh_enable_interrupt (struct irq_data *d)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 754/1146 fbdev: ssd1307fb: Drop optional dependency
In reply to Greg Kroah-HartmanFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 025e3b507a3a8e1ee96a3112bb67495c77d6cdb6 ]
Only a single out of three devices need a PWM, so from driver it's optional. Moreover it's a single driver in the entire kernel that currently selects PWM. Unfortunately this selection is a root cause of the circular dependencies when we want to enable optional PWM for some other drivers that select GPIOLIB.
--- drivers/video/fbdev/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/video/fbdev/Kconfig +0 -1
@@ -2217,7 +2217,6 @@ config FB_SSD1307 select FB_SYS_COPYAREA select FB_SYS_IMAGEBLIT select FB_DEFERRED_IO - select PWM select FB_BACKLIGHT help This driver implements support for the Solomon SSD1307
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 755/1146 fbdev: pm2fb: fix missing pci_disable_device()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit ed359a464846b48f76ea6cc5cd8257e545ac97f4 ]
Add missing pci_disable_device() in error path of probe() and remove() path.
--- drivers/video/fbdev/pm2fb.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/video/fbdev/pm2fb.c +7 -2
@@ -1533,8 +1533,10 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id) } info =framebuffer_alloc (sizeof (struct pm2fb_par ), &pdev->dev); -if (!info) -return -ENOMEM ; +if (!info) { + err = -ENOMEM ; + goto err_exit_disable; + } default_par = info->par;switch (pdev->device) {
@@ -1715,6 +1717,8 @@ static int pm2fb_probe(struct pci_dev *pdev, const struct pci_device_id *id)release_mem_region (pm2fb_fix.mmio_start, pm2fb_fix.mmio_len); err_exit_neither:framebuffer_release (info); + err_exit_disable: +pci_disable_device (pdev);return retval; }
@@ -1739,6 +1743,7 @@ static void pm2fb_remove(struct pci_dev *pdev)fb_dealloc_cmap (&info->cmap);kfree (info->pixmap.addr);framebuffer_release (info); +pci_disable_device (pdev); }static const struct pci_device_id pm2fb_id_table[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 756/1146 fbdev: via: Fix error in via_core_init()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 5886b130de953cfb8826f7771ec8640a79934a7f ]
via_core_init() won't exit the driver when pci_register_driver() failed. Exit the viafb-i2c and the viafb-gpio in failed path to prevent error.
VIA Graphics Integration Chipset framebuffer 2.4 initializing
Error: Driver 'viafb-i2c' is already registered, aborting...
Error: Driver 'viafb-gpio' is already registered, aborting...
--- drivers/video/fbdev/via/via-core.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/video/fbdev/via/via-core.c +8 -1
@@ -730,7 +730,14 @@ static int __init via_core_init(void)return ret;viafb_i2c_init ();viafb_gpio_init (); -return pci_register_driver (&via_driver); + ret =pci_register_driver (&via_driver); +if (ret) { +viafb_gpio_exit (); +viafb_i2c_exit (); +return ret; + } + +return 0 ; } static void __exit via_core_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 757/1146 fbdev: vermilion: decrease reference count in error path
In reply to Greg Kroah-HartmanFrom: Xiongfeng Wang <[email protected]>
[ Upstream commit 001f2cdb952a9566c77fb4b5470cc361db5601bb ]
pci_get_device() will increase the reference count for the returned pci_dev. For the error path, we need to use pci_dev_put() to decrease the reference count.
--- drivers/video/fbdev/vermilion/vermilion.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/vermilion/vermilion.c +3 -1
@@ -278,8 +278,10 @@ static int vmlfb_get_gpu(struct vml_par *par)mutex_unlock (&vml_mutex); -if (pci_enable_device (par->gpu) <0 ) +if (pci_enable_device (par->gpu) <0 ) { +pci_dev_put (par->gpu);return -ENODEV ; + }return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 758/1146 fbdev: ep93xx-fb: Add missing clk_disable_unprepare in ep93xxfb_probe()
In reply to Greg Kroah-HartmanFrom: Gaosheng Cui <[email protected]>
[ Upstream commit c84bf485a5aaf9aa0764a58832b7ef4375c29f03 ]
The clk_disable_unprepare() should be called in the error handling of register_framebuffer(), fix it.
--- drivers/video/fbdev/ep93xx-fb.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/video/fbdev/ep93xx-fb.c +3 -1
@@ -552,12 +552,14 @@ static int ep93xxfb_probe(struct platform_device *pdev) err =register_framebuffer (info);if (err) - goto failed_check; + goto failed_framebuffer;dev_info (info->dev,"registered. Mode = %dx%d-%d\n" , info->var.xres, info->var.yres, info->var.bits_per_pixel);return 0 ; +failed_framebuffer: +clk_disable_unprepare (fbi->clk); failed_check:if (fbi->mach_info->teardown) fbi->mach_info->teardown (pdev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 759/1146 fbdev: geode: dont build on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 71c53e19226b0166ba387d3c590d0509f541a0a1 ]
The geode fbdev driver uses struct cpuinfo fields that are not present on ARCH=um, so don't allow this driver to be built on UML.
Prevents these build errors:
In file included from ../arch/x86/include/asm/olpc.h:7:0,
from ../drivers/mfd/cs5535-mfd.c:17:
../arch/x86/include/asm/geode.h: In function ‘is_geode_gx’:../arch/x86/include/asm/geode.h:16:24: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:16:39: error: ‘X86_VENDOR_NSC’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&../arch/x86/include/asm/geode.h:17:17: error: ‘struct cpuinfo_um’ has no member named ‘x86’
(boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:18:17: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
(boot_cpu_data.x86_model == 5));../arch/x86/include/asm/geode.h: In function ‘is_geode_lx’:../arch/x86/include/asm/geode.h:23:24: error: ‘struct cpuinfo_um’ has no member named ‘x86_vendor’
return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:23:39: error: ‘X86_VENDOR_AMD’ undeclared (first use in this function); did you mean ‘X86_VENDOR_ANY’?
return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&../arch/x86/include/asm/geode.h:24:17: error: ‘struct cpuinfo_um’ has no member named ‘x86’
(boot_cpu_data.x86 == 5) &&../arch/x86/include/asm/geode.h:25:17: error: ‘struct cpuinfo_um’ has no member named ‘x86_model’
(boot_cpu_data.x86_model == 10));
--- drivers/video/fbdev/geode/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/geode/Kconfig +1 -0
@@ -5,6 +5,7 @@ config FB_GEODE bool "AMD Geode family framebuffer support" depends on FB && PCI && (X86_32 || (X86 && COMPILE_TEST)) + depends on !UML help Say 'Y' here to allow you to select framebuffer drivers for the AMD Geode family of processors.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 760/1146 fbdev: uvesafb: dont build on UML
In reply to Greg Kroah-HartmanFrom: Randy Dunlap <[email protected]>
[ Upstream commit 35b4f4d4a725cf8f8c10649163cd12aed509b953 ]
The uvesafb fbdev driver uses memory management information that is not available on ARCH=um, so don't allow this driver to be built on UML.
Prevents these build errors:
../drivers/video/fbdev/uvesafb.c: In function ‘uvesafb_vbe_init’:../drivers/video/fbdev/uvesafb.c:807:21: error: ‘__supported_pte_mask’ undeclared (first use in this function)
807 | if (__supported_pte_mask & _PAGE_NX) {../drivers/video/fbdev/uvesafb.c:807:44: error: ‘_PAGE_NX’ undeclared (first use in this function)
807 | if (__supported_pte_mask & _PAGE_NX) {
--- drivers/video/fbdev/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/Kconfig +1 -0
@@ -601,6 +601,7 @@ config FB_TGA config FB_UVESA tristate "Userspace VESA VGA graphics support" depends on FB && CONNECTOR + depends on !UML select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 761/1146 fbdev: uvesafb: Fixes an error handling path in uvesafb_probe()
In reply to Greg Kroah-HartmanFrom: Christophe JAILLET <[email protected]>
[ Upstream commit a94371040712031ba129c7e9d8ff04a06a2f8207 ]
If an error occurs after a successful uvesafb_init_mtrr() call, it must be undone by a corresponding arch_phys_wc_del() call, as already done in the remove function.
This has been added in the remove function in commit 63e28a7a5ffc ("uvesafb: Clean up MTRR code")
--- drivers/video/fbdev/uvesafb.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/uvesafb.c +1 -0
@@ -1758,6 +1758,7 @@ static int uvesafb_probe(struct platform_device *dev) out_unmap:iounmap (info->screen_base); out_mem: +arch_phys_wc_del (par->mtrr_handle);release_mem_region (info->fix.smem_start, info->fix.smem_len); out_reg:release_region (0x3c0 ,32 );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 762/1146 led: qcom-lpg: Fix sleeping in atomic
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 3031993b3474794ecb71b6f969a3e60e4bda9d8a ]
lpg_brighness_set() function can sleep, while led's brightness_set() callback must be non-blocking. Change LPG driver to use brightness_set_blocking() instead.
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:580 in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/0 preempt_count: 101, expected: 0 INFO: lockdep is turned off. CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W 6.1.0-rc1-00014-gbe99b089c6fc-dirty #85 Hardware name: Qualcomm Technologies, Inc. DB820c (DT) Call trace: dump_backtrace.part.0+0xe4/0xf0 show_stack+0x18/0x40 dump_stack_lvl+0x88/0xb4 dump_stack+0x18/0x34 __might_resched+0x170/0x254 __might_sleep+0x48/0x9c __mutex_lock+0x4c/0x400 mutex_lock_nested+0x2c/0x40 lpg_brightness_single_set+0x40/0x90 led_set_brightness_nosleep+0x34/0x60 led_heartbeat_function+0x80/0x170 call_timer_fn+0xb8/0x340 __run_timers.part.0+0x20c/0x254 run_timer_softirq+0x3c/0x7c _stext+0x14c/0x578 ____do_softirq+0x10/0x20 call_on_irq_stack+0x2c/0x5c do_softirq_own_stack+0x1c/0x30 __irq_exit_rcu+0x164/0x170 irq_exit_rcu+0x10/0x40 el1_interrupt+0x38/0x50 el1h_64_irq_handler+0x18/0x2c el1h_64_irq+0x64/0x68 cpuidle_enter_state+0xc8/0x380 cpuidle_enter+0x38/0x50 do_idle+0x244/0x2d0 cpu_startup_entry+0x24/0x30 rest_init+0x128/0x1a0 arch_post_acpi_subsys_init+0x0/0x18 start_kernel+0x6f4/0x734 __primary_switched+0xbc/0xc4
--- drivers/leds/rgb/leds-qcom-lpg.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/leds/rgb/leds-qcom-lpg.c +11 -7
@@ -602,8 +602,8 @@ static void lpg_brightness_set(struct lpg_led *led, struct led_classdev *cdev,lpg_lut_sync (lpg, lut_mask); } -static void lpg_brightness_single_set (struct led_classdev *cdev, -enum led_brightness value) +static int lpg_brightness_single_set (struct led_classdev *cdev, +enum led_brightness value) { struct lpg_led *led = container_of(cdev, struct lpg_led, cdev);struct mc_subled info;
@@ -614,10 +614,12 @@ static void lpg_brightness_single_set(struct led_classdev *cdev,lpg_brightness_set (led, cdev, &info);mutex_unlock (&led->lpg->lock); + +return 0 ; } -static void lpg_brightness_mc_set (struct led_classdev *cdev, -enum led_brightness value) +static int lpg_brightness_mc_set (struct led_classdev *cdev, +enum led_brightness value) {struct led_classdev_mc *mc =lcdev_to_mccdev (cdev); struct lpg_led *led = container_of(mc, struct lpg_led, mcdev);
@@ -628,6 +630,8 @@ static void lpg_brightness_mc_set(struct led_classdev *cdev,lpg_brightness_set (led, cdev, mc->subled_info);mutex_unlock (&led->lpg->lock); + +return 0 ; } static int lpg_blink_set(struct lpg_led *led,
@@ -1118,7 +1122,7 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np) led->mcdev.num_colors = num_channels; cdev = &led->mcdev.led_cdev; - cdev->brightness_set = lpg_brightness_mc_set; + cdev->brightness_set_blocking = lpg_brightness_mc_set; cdev->blink_set = lpg_blink_mc_set;/* Register pattern accessors only if we have a LUT block */
@@ -1132,7 +1136,7 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)return ret; cdev = &led->cdev; - cdev->brightness_set = lpg_brightness_single_set; + cdev->brightness_set_blocking = lpg_brightness_single_set; cdev->blink_set = lpg_blink_single_set;/* Register pattern accessors only if we have a LUT block */
@@ -1151,7 +1155,7 @@ static int lpg_add_led(struct lpg *lpg, struct device_node *np)else cdev->brightness =LED_OFF ; - cdev->brightness_set (cdev, cdev->brightness); + cdev->brightness_set_blocking (cdev, cdev->brightness); init_data.fwnode =of_fwnode_handle (np);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 763/1146 perf tools: Fix "kernel lock contention analysis" test by not printing warnings in quiet mode
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit 65319890c32db29fb56b41f84265a2c7029943f4 ]
Especially when CONFIG_LOCKDEP and other debug configs are enabled, Perf can print the following warning when running the "kernel lock contention analysis" test:
Warning:
Processed 1378918 events and lost 4 chunks!
Check IO/CPU overload!
Warning:
Processed 4593325 samples and lost 70.00%!
The test already supplies -q to run in quiet mode, so extend quiet mode to perf_stdio__warning() and also ui__warning() for consistency.
This fixes the following failure due to the extra lines counted:
perf test "lock cont" -vvv
82: kernel lock contention analysis test :
--- start ---
test child forked, pid 3125
Testing perf lock record and perf lock contention [Fail] Recorded result count is not 1: 9 test child finished with -1
---- end ----
kernel lock contention analysis test: FAILED!
--- tools/perf/ui/util.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/ui/util.c +5 -0
@@ -15,6 +15,9 @@ static int perf_stdio__error(const char *format, va_list args)static int perf_stdio__warning (const char *format,va_list args) { +if (quiet) +return 0 ; +fprintf (stderr,"Warning:\n" );vfprintf (stderr, format, args);return 0 ;
@@ -45,6 +48,8 @@ int ui__warning(const char *format, ...) {int ret;va_list args; +if (quiet) +return 0 ;va_start (args, format); ret = perf_eops->warning (format, args);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 764/1146 perf stat: Use evsel__is_hybrid() more
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit 93d5e700156e03e66eb1bf2158ba3b8a8b354c71 ]
In the stat-display code, it needs to check if the current evsel is hybrid but it uses perf_pmu__has_hybrid() which can return true for non-hybrid event too. I think it's better to use evsel__is_hybrid().
Also remove a NULL check for the 'config' parameter in the hybrid_merge() since it's called after config->no_merge check.
Stable-dep-of: fdc7d6082459 ("perf stat: Fix --metric-only --json output")
--- tools/perf/util/stat-display.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-)
tools/perf/util/stat-display.c +4 -16
@@ -704,7 +704,7 @@ static void uniquify_event_name(struct evsel *counter) counter->name = new_name; } }else { -if (perf_pmu__has_hybrid ()) { +if (evsel__is_hybrid (counter)) { ret =asprintf (&new_name,"%s/%s/" , counter->pmu_name, counter->name); }else {
@@ -744,26 +744,14 @@ static void collect_all_aliases(struct perf_stat_config *config, struct evsel *c } } -static bool is_uncore (struct evsel *evsel) -{ -struct perf_pmu *pmu =evsel__find_pmu (evsel); - -return pmu && pmu->is_uncore; -} - -static bool hybrid_uniquify (struct evsel *evsel) -{ -return perf_pmu__has_hybrid () && !is_uncore (evsel); -} -static bool hybrid_merge (struct evsel *counter,struct perf_stat_config *config,bool check) { -if (hybrid_uniquify (counter)) { +if (evsel__is_hybrid (counter)) {if (check) -return config && config->hybrid_merge; +return config->hybrid_merge;else -return config && !config->hybrid_merge; +return !config->hybrid_merge; }return false;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 765/1146 perf stat: Move common code in print_metric_headers()
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit f4e55f88da923f39f0b76edc3da3c52d0b72d429 ]
The struct perf_stat_output_ctx is set in a loop with the same values. Move the code out of the loop and keep the loop minimal.
Stable-dep-of: fdc7d6082459 ("perf stat: Fix --metric-only --json output")
--- tools/perf/util/stat-display.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
tools/perf/util/stat-display.c +8 -5
@@ -1130,11 +1130,16 @@ static void print_metric_headers(structstruct evlist *evlist, const char *prefix, bool no_indent) { - struct perf_stat_output_ctx out; struct evsel *counter;struct outstate os = { .fh = config->output }; +struct perf_stat_output_ctx out = { + .ctx = &os, + .print_metric = print_metric_header, + .new_line = new_line_metric, + .force_header = true, + };bool first = true;if (config->json_output && !config->interval)
@@ -1158,13 +1163,11 @@ static void print_metric_headers(struct/* Print metrics headers only */ evlist__for_each_entry (evlist, counter) { os.evsel = counter; - out.ctx = &os; - out.print_metric = print_metric_header; +if (!first && config->json_output)fprintf (config->output,", " ); first = false; - out.new_line = new_line_metric; - out.force_header = true; + perf_stat__print_shadow_stats(config, counter, 0, 0, &out,
Greg Kroah-Hartman
maintainerPATCH 766/1146 HSI: omap_ssi_core: fix unbalanced pm_runtime_disable()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit f5181c35ed7ba0ceb6e42872aad1334d994b0175 ]
In error label 'out1' path in ssi_probe(), the pm_runtime_enable() has not been called yet, so pm_runtime_disable() is not needed.
--- drivers/hsi/controllers/omap_ssi_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +1 -1
@@ -536,9 +536,9 @@ static int ssi_probe(struct platform_device *pd)device_for_each_child (&pd->dev,NULL , ssi_remove_ports); out2:ssi_remove_controller (ssi); +pm_runtime_disable (&pd->dev); out1:platform_set_drvdata (pd,NULL ); -pm_runtime_disable (&pd->dev);return err; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 767/1146 HSI: omap_ssi_core: fix possible memory leak in ssi_probe()
In reply to Greg Kroah-HartmanFrom: Yang Yingliang <[email protected]>
[ Upstream commit 1aff514e1d2bd47854dbbdf867970b9d463d4c57 ]
If ssi_add_controller() returns error, it should call hsi_put_controller() to give up the reference that was set in hsi_alloc_controller(), so that it can call hsi_controller_release() to free controller and ports that allocated in hsi_alloc_controller().
--- drivers/hsi/controllers/omap_ssi_core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +3 -1
@@ -502,8 +502,10 @@ static int ssi_probe(struct platform_device *pd)platform_set_drvdata (pd, ssi); err =ssi_add_controller (ssi, pd); -if (err <0 ) +if (err <0 ) { +hsi_put_controller (ssi); goto out1; + }pm_runtime_enable (&pd->dev);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 768/1146 power: supply: fix residue sysfs file in error handle route of __power_supply_register()
In reply to Greg Kroah-HartmanFrom: Zeng Heng <[email protected]>
[ Upstream commit 5b79480ce1978864ac3f06f2134dfa3b6691fe74 ]
If device_add() succeeds, we should call device_del() when want to get rid of it, so move it into proper jump symbol.
Otherwise, when __power_supply_register() returns fail and goto wakeup_init_failed to exit, there is still residue device file in sysfs. When attempt to probe device again, sysfs would complain as below:
sysfs: cannot create duplicate filename '/devices/platform/i2c/i2c-0/0-001c/power_supply/adp5061'
Call Trace: dump_stack_lvl+0x68/0x85 sysfs_warn_dup.cold+0x1c/0x29 sysfs_create_dir_ns+0x1b1/0x1d0 kobject_add_internal+0x143/0x390 kobject_add+0x108/0x170
--- drivers/power/supply/power_supply_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/power_supply_core.c +1 -1
@@ -1387,8 +1387,8 @@ __power_supply_register(struct device *parent, register_cooler_failed:psy_unregister_thermal (psy); register_thermal_failed: -device_del (dev); wakeup_init_failed: +device_del (dev); device_add_failed: check_supplies_failed: dev_set_name_failed:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 769/1146 watchdog: iTCO_wdt: Set NO_REBOOT if the watchdog is not already running
In reply to Greg Kroah-HartmanFrom: Mika Westerberg <[email protected]>
[ Upstream commit ef9b7bf52c2f47f0a9bf988543c577b92c92d15e ]
Daniel reported that the commit 1ae3e78c0820 ("watchdog: iTCO_wdt: No need to stop the timer in probe") makes QEMU implementation of the iTCO watchdog not to trigger reboot anymore when NO_REBOOT flag is initially cleared using this option (in QEMU command line):
-global ICH9-LPC.noreboot=false
The problem with the commit is that it left the unconditional setting of NO_REBOOT that is not cleared anymore when the kernel keeps pinging the watchdog (as opposed to the previous code that called iTCO_wdt_stop() that cleared it).
Fix this so that we only set NO_REBOOT if the watchdog was not initially running.
--- drivers/watchdog/iTCO_wdt.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/watchdog/iTCO_wdt.c +14 -7
@@ -423,14 +423,18 @@ static unsigned int iTCO_wdt_get_timeleft(struct watchdog_device *wd_dev)return time_left; } -static void iTCO_wdt_set_running (struct iTCO_wdt_private *p) +/* Returns true if the watchdog was running */ +static bool iTCO_wdt_set_running (struct iTCO_wdt_private *p) {u16 val; -/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is * enabled */ +/* Bit 11: TCO Timer Halt -> 0 = The TCO timer is enabled */ val =inw (TCO1_CNT (p)); -if (!(val &BIT (11 ))) +if (!(val &BIT (11 ))) {set_bit (WDOG_HW_RUNNING , &p->wddev.status); +return true; + } +return false; }/*
@@ -518,9 +522,6 @@ static int iTCO_wdt_probe(struct platform_device *pdev)return -ENODEV ;/* Cannot reset NO_REBOOT bit */ } -/* Set the NO_REBOOT bit to prevent later reboots, just for sure */ - p->update_no_reboot_bit (p->no_reboot_priv, true); -if (turn_SMI_watchdog_clear_off >= p->iTCO_version) {/* * Bit 13: TCO_EN -> 0
@@ -572,7 +573,13 @@ static int iTCO_wdt_probe(struct platform_device *pdev)watchdog_set_drvdata (&p->wddev, p);platform_set_drvdata (pdev, p); -iTCO_wdt_set_running (p); +if (!iTCO_wdt_set_running (p)) { +/* +* If the watchdog was not running set NO_REBOOT now to +* prevent later reboots. +*/ + p->update_no_reboot_bit (p->no_reboot_priv, true); + }/* Check that the heartbeat value is within it's range; if not reset to the default */
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 770/1146 perf trace: Return error if a system call doesnt exist
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit d4223e1776c30b2ce8d0e6eaadcbf696e60fca3c ]
When a system call is not detected, the reason is either because the system call ID is out of scope or failure to find the corresponding path in the sysfs, trace__read_syscall_info() returns zero. Finally, without returning an error value it introduces confusion for the caller.
This patch lets the function trace__read_syscall_info() to return -EEXIST when a system call doesn't exist.
--- tools/perf/builtin-trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +2 -2
@@ -1791,11 +1791,11 @@ static int trace__read_syscall_info(struct trace *trace, int id)#endif sc = trace->syscalls.table + id;if (sc->nonexistent) -return 0 ; +return -EEXIST ;if (name ==NULL ) { sc->nonexistent = true; -return 0 ; +return -EEXIST ; } sc->name = name;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 771/1146 perf trace: Use macro RAW_SYSCALL_ARGS_NUM to replace number
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit eadcab4c7a66e1df03d32da0db55d89fd9343fcc ]
This patch defines a macro RAW_SYSCALL_ARGS_NUM to replace the open coded number '6'.
Stable-dep-of: 03e9a5d8eb55 ("perf trace: Handle failure when trace point folder is missed")
--- tools/perf/builtin-trace.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
tools/perf/builtin-trace.c +7 -4
@@ -88,6 +88,8 @@# define F_LINUX_SPECIFIC_BASE 1024#endif +#define RAW_SYSCALL_ARGS_NUM 6 +/* * strtoul: Go from a string to a value, i.e. for msr: MSR_FS_BASE to 0xc0000100 */
@@ -108,7 +110,7 @@ struct syscall_fmt {const char *sys_enter, *sys_exit; } bpf_prog_name; -struct syscall_arg_fmt arg[6 ]; +struct syscall_arg_fmt arg[RAW_SYSCALL_ARGS_NUM ];u8 nr_args;bool errpid;bool timeout;
@@ -1226,7 +1228,7 @@ struct syscall {*/ struct bpf_map_syscall_entry {bool enabled; -u16 string_args_len[6 ]; +u16 string_args_len[RAW_SYSCALL_ARGS_NUM ]; };/*
@@ -1658,7 +1660,7 @@ static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args) {int idx; -if (nr_args ==6 && sc->fmt && sc->fmt->nr_args !=0 ) +if (nr_args ==RAW_SYSCALL_ARGS_NUM && sc->fmt && sc->fmt->nr_args !=0 ) nr_args = sc->fmt->nr_args; sc->arg_fmt =calloc (nr_args,sizeof (*sc->arg_fmt));
@@ -1809,7 +1811,8 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format =trace_event__tp_format ("syscalls" , tp_name); } -if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ?6 : sc->tp_format->format.nr_fields)) +if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ? +RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields))return -ENOMEM ;if (IS_ERR (sc->tp_format))
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 772/1146 perf trace: Handle failure when trace point folder is missed
In reply to Greg Kroah-HartmanFrom: Leo Yan <[email protected]>
[ Upstream commit 03e9a5d8eb552a1bf692a9c8a5ecd50f4e428006 ]
On Arm64 a case is perf tools fails to find the corresponding trace point folder for system calls listed in the table 'syscalltbl_arm64', e.g. the generated system call table contains "lookup_dcookie" but we cannot find out the matched trace point folder for it.
We need to figure out if there have any issue for the generated system call table, on the other hand, we need to handle the case when trace point folder is missed under sysfs, this patch sets the flag syscall::nonexistent as true and returns the error from trace__read_syscall_info().
Another problem is for trace__syscall_info(), it returns two different values if a system call doesn't exist: at the first time calling trace__syscall_info() it returns NULL when the system call doesn't exist, later if call trace__syscall_info() again for the same missed system call, it returns pointer of syscall. trace__syscall_info() checks the condition 'syscalls.table[id].name == NULL', but the name will be assigned in the first invoking even the system call is not found.
So checking system call's name in trace__syscall_info() is not the right thing to do, this patch simply checks flag syscall::nonexistent to make decision if a system call exists or not, finally trace__syscall_info() returns the consistent result (NULL) if a system call doesn't existed.
--- tools/perf/builtin-trace.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
tools/perf/builtin-trace.c +10 -7
@@ -1811,13 +1811,19 @@ static int trace__read_syscall_info(struct trace *trace, int id) sc->tp_format =trace_event__tp_format ("syscalls" , tp_name); } +/* +* Fails to read trace point format via sysfs node, so the trace point +* doesn't exist. Set the 'nonexistent' flag as true. +*/ +if (IS_ERR (sc->tp_format)) { + sc->nonexistent = true; +return PTR_ERR (sc->tp_format); + } +if (syscall__alloc_arg_fmts (sc,IS_ERR (sc->tp_format) ?RAW_SYSCALL_ARGS_NUM : sc->tp_format->format.nr_fields))return -ENOMEM ; -if (IS_ERR (sc->tp_format)) -return PTR_ERR (sc->tp_format); - sc->args = sc->tp_format->format.fields;/* * We need to check and discard the first variable '__syscall_nr'
@@ -2134,11 +2140,8 @@ static struct syscall *trace__syscall_info(struct trace *trace, (err = trace__read_syscall_info(trace, id)) != 0) goto out_cant_read; -if (trace->syscalls.table[id].name ==NULL ) { -if (trace->syscalls.table[id].nonexistent) -return NULL ; +if (trace->syscalls.table && trace->syscalls.table[id].nonexistent) goto out_cant_read; - }return &trace->syscalls.table[id];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 773/1146 perf symbol: correction while adjusting symbol
In reply to Greg Kroah-HartmanFrom: Ajay Kaher <[email protected]>
[ Upstream commit 6f520ce17920b3cdfbd2479b3ccf27f9706219d0 ]
perf doesn't provide proper symbol information for specially crafted .debug files.
Sometimes .debug file may not have similar program header as runtime ELF file. For example if we generate .debug file using objcopy --only-keep-debug resulting file will not contain .text, .data and other runtime sections. That means corresponding program headers will have zero FileSiz and modified Offset.
Example: program header of text section of libxxx.so:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x00000000003d3000 0x00000000003d3000 0x00000000003d3000
0x000000000055ae80 0x000000000055ae80 R E 0x1000
Same program header after executing:
objcopy --only-keep-debug libxxx.so libxxx.so.debug
LOAD 0x0000000000001000 0x00000000003d3000 0x00000000003d3000
0x0000000000000000 0x000000000055ae80 R E 0x1000
Offset and FileSiz have been changed.
Following formula will not provide correct value, if program header taken from .debug file (syms_ss):
sym.st_value -= phdr.p_vaddr - phdr.p_offset;
Correct program header information is located inside runtime ELF file (runtime_ss).
--- tools/perf/util/symbol-elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/symbol-elf.c +1 -1
@@ -1303,7 +1303,7 @@ dso__load_sym_internal(struct dso *dso, struct map *map, struct symsrc *syms_ss, (!used_opd && syms_ss->adjust_symbols)) {GElf_Phdr phdr; -if (elf_read_program_header (syms_ss->elf, +if (elf_read_program_header (runtime_ss->elf, (u64 )sym.st_value, &phdr)) { pr_debug4("%s: failed to find program header for " "symbol: %s st_value: %#" PRIx64 "\n",
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 774/1146 power: supply: z2_battery: Fix possible memleak in z2_batt_probe()
In reply to Greg Kroah-HartmanFrom: Zhang Qilong <[email protected]>
[ Upstream commit 955bee204f3dd307642c101b75e370662987e735 ]
If devm_gpiod_get_optional() returns error, the charger should be freed before z2_batt_probe returns according to the context. We fix it by just gotoing to 'err' branch.
--- drivers/power/supply/z2_battery.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/power/supply/z2_battery.c +4 -2
@@ -206,10 +206,12 @@ static int z2_batt_probe(struct i2c_client *client, charger->charge_gpiod =devm_gpiod_get_optional (&client->dev,NULL ,GPIOD_IN ); -if (IS_ERR (charger->charge_gpiod)) -return dev_err_probe (&client->dev, +if (IS_ERR (charger->charge_gpiod)) { + ret =dev_err_probe (&client->dev,PTR_ERR (charger->charge_gpiod),"failed to get charge GPIO\n" ); + goto err; + }if (charger->charge_gpiod) {gpiod_set_consumer_name (charger->charge_gpiod,"BATT CHRG" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 775/1146 power: supply: cw2015: Fix potential null-ptr-deref in cw_bat_probe()
In reply to Greg Kroah-HartmanFrom: Shang XiaoJing <[email protected]>
[ Upstream commit 97f2b4ddb0aa700d673691a7d5e44d226d22bab7 ]
cw_bat_probe() calls create_singlethread_workqueue() and not checked the ret value, which may return NULL. And a null-ptr-deref may happen:
cw_bat_probe()
create_singlethread_workqueue() # failed, cw_bat->wq is NULL
queue_delayed_work()
queue_delayed_work_on()
__queue_delayed_work() # warning here, but continue
__queue_work() # access wq->flags, null-ptr-derefCheck the ret value and return -ENOMEM if it is NULL.
--- drivers/power/supply/cw2015_battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/cw2015_battery.c +3 -0
@@ -699,6 +699,9 @@ static int cw_bat_probe(struct i2c_client *client) } cw_bat->battery_workqueue =create_singlethread_workqueue ("rk_battery" ); +if (!cw_bat->battery_workqueue) +return -ENOMEM ; +devm_delayed_work_autocancel (&client->dev, &cw_bat->battery_delay_work, cw_bat_work); queue_delayed_work(cw_bat->battery_workqueue,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 776/1146 HSI: omap_ssi_core: Fix error handling in ssi_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit 3ffa9f713c39a213a08d9ff13ab983a8aa5d8b5d ]
The ssi_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, the ssi_pdriver is not unregistered.
Fix by unregister ssi_pdriver when the last platform_driver_register() failed.
--- drivers/hsi/controllers/omap_ssi_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +7 -1
@@ -631,7 +631,13 @@ static int __init ssi_init(void) {if (ret)return ret; -return platform_driver_register (&ssi_port_pdriver); + ret =platform_driver_register (&ssi_port_pdriver); +if (ret) { +platform_driver_unregister (&ssi_pdriver); +return ret; + } + +return 0 ; }module_init (ssi_init);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 777/1146 power: supply: ab8500: Fix error handling in ab8500_charger_init()
In reply to Greg Kroah-HartmanFrom: Yuan Can <[email protected]>
[ Upstream commit c4d33381b134da188ccd1084aef21e2b8c3c422e ]
The ab8500_charger_init() returns the platform_driver_register() directly without checking its return value, if platform_driver_register() failed, all ab8500_charger_component_drivers are not unregistered.
Fix by unregister ab8500_charger_component_drivers when platform_driver_register() failed.
--- drivers/power/supply/ab8500_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/supply/ab8500_charger.c +8 -1
@@ -3719,7 +3719,14 @@ static int __init ab8500_charger_init(void)if (ret)return ret; -return platform_driver_register (&ab8500_charger_driver); + ret =platform_driver_register (&ab8500_charger_driver); +if (ret) { +platform_unregister_drivers (ab8500_charger_component_drivers, +ARRAY_SIZE (ab8500_charger_component_drivers)); +return ret; + } + +return 0 ; } static void __exit ab8500_charger_exit(void)
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 778/1146 power: supply: Fix refcount leak in rk817_charger_probe
In reply to Greg Kroah-HartmanFrom: Qiheng Lin <[email protected]>
[ Upstream commit 54c03bfd094fb74f9533a9c28250219afe182382 ]
of_get_child_by_name() returns a node pointer with refcount incremented, we should use of_node_put() on it when not need anymore. Add missing of_node_put() to avoid refcount leak.
--- drivers/power/supply/rk817_charger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/power/supply/rk817_charger.c +3 -1
@@ -1060,8 +1060,10 @@ static int rk817_charger_probe(struct platform_device *pdev)return -ENODEV ; charger =devm_kzalloc (&pdev->dev,sizeof (*charger),GFP_KERNEL ); -if (!charger) +if (!charger) { +of_node_put (node);return -ENOMEM ; + } charger->rk808 = rk808;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 779/1146 power: supply: bq25890: Factor out regulator registration code
In reply to Greg Kroah-HartmanFrom: Marek Vasut <[email protected]>
[ Upstream commit 5f5c10ecaf3fdeba9b2b0af5301977420c2c4df0 ]
Pull the regulator registration code into separate function, so it can be extended to register more regulators later. Currently this is only moving ifdeffery into one place and other preparatory changes. The dev_err_probe() output string is changed to explicitly list vbus regulator failure, so that once more regulators are registered, it would be clear which one failed.
Stable-dep-of: a7aaa80098d5 ("power: supply: bq25890: Ensure pump_express_work is cancelled on remove")
--- drivers/power/supply/bq25890_charger.c | 51 ++++++++++++++++++-------- 1 file changed, 35 insertions(+), 16 deletions(-)
drivers/power/supply/bq25890_charger.c +35 -16
@@ -1049,6 +1049,36 @@ static const struct regulator_desc bq25890_vbus_desc = { .fixed_uV = 5000000, .n_voltages = 1, }; + +static int bq25890_register_regulator (struct bq25890_device *bq) +{ +struct bq25890_platform_data *pdata =dev_get_platdata (bq->dev); +struct regulator_config cfg = { + .dev = bq->dev, + .driver_data = bq, + }; +struct regulator_dev *reg; + +if (!IS_ERR_OR_NULL (bq->usb_phy)) +return 0 ; + +if (pdata) + cfg.init_data = pdata->regulator_init_data; + + reg =devm_regulator_register (bq->dev, &bq25890_vbus_desc, &cfg); +if (IS_ERR (reg)) { +return dev_err_probe (bq->dev,PTR_ERR (reg), +"registering vbus regulator" ); + } + +return 0 ; +} +#else +static inline int +bq25890_register_regulator (struct bq25890_device *bq) +{ +return 0 ; +}#endif static int bq25890_get_chip_version (struct bq25890_device *bq)
@@ -1244,27 +1274,16 @@ static int bq25890_probe(struct i2c_client *client,/* OTG reporting */ bq->usb_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); + + ret =bq25890_register_regulator (bq); +if (ret) +return ret; +if (!IS_ERR_OR_NULL (bq->usb_phy)) {INIT_WORK (&bq->usb_work, bq25890_usb_work); bq->usb_nb.notifier_call = bq25890_usb_notifier;usb_register_notifier (bq->usb_phy, &bq->usb_nb); } -#ifdef CONFIG_REGULATOR - else { -struct bq25890_platform_data *pdata =dev_get_platdata (dev); -struct regulator_config cfg = { }; -struct regulator_dev *reg; - - cfg.dev = dev; - cfg.driver_data = bq; -if (pdata) - cfg.init_data = pdata->regulator_init_data; - - reg =devm_regulator_register (dev, &bq25890_vbus_desc, &cfg); -if (IS_ERR (reg)) -return dev_err_probe (dev,PTR_ERR (reg),"registering regulator" ); - } -#endif ret =bq25890_power_supply_init (bq);if (ret <0 ) {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 780/1146 power: supply: bq25890: Convert to i2cs .probe_new()
In reply to Greg Kroah-HartmanFrom: Uwe Kleine-König <[email protected]>
[ Upstream commit c5cddca2351b291c8787b45cd046b1dfeb86979f ]
The probe function doesn't make use of the i2c_device_id * parameter so it can be trivially converted.
Stable-dep-of: a7aaa80098d5 ("power: supply: bq25890: Ensure pump_express_work is cancelled on remove")
--- drivers/power/supply/bq25890_charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/power/supply/bq25890_charger.c +2 -3
@@ -1219,8 +1219,7 @@ static int bq25890_fw_probe(struct bq25890_device *bq)return 0 ; } -static int bq25890_probe (struct i2c_client *client, -const struct i2c_device_id *id) +static int bq25890_probe (struct i2c_client *client) {struct device *dev = &client->dev;struct bq25890_device *bq;
@@ -1419,7 +1418,7 @@ static struct i2c_driver bq25890_driver = { .acpi_match_table = ACPI_PTR(bq25890_acpi_match), .pm = &bq25890_pm, }, - .probe = bq25890_probe, + .probe_new = bq25890_probe, .remove = bq25890_remove, .shutdown = bq25890_shutdown, .id_table = bq25890_i2c_ids,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 781/1146 power: supply: bq25890: Ensure pump_express_work is cancelled on remove
In reply to Greg Kroah-HartmanFrom: Hans de Goede <[email protected]>
[ Upstream commit a7aaa80098d5b7608b2dc1e883e3c3f929415243 ]
The pump_express_work which gets queued from an external_power_changed callback might be pending / running on remove() (or on probe failure).
Add a devm action cancelling the work, to ensure that it is cancelled.
Note the devm action is added before devm_power_supply_register(), making it run after devm unregisters the power_supply, so that the work cannot be queued anymore (this is also why a devm action is used for this).
--- drivers/power/supply/bq25890_charger.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
drivers/power/supply/bq25890_charger.c +15 -0
@@ -1219,6 +1219,13 @@ static int bq25890_fw_probe(struct bq25890_device *bq)return 0 ; } +static void bq25890_non_devm_cleanup (void *data) +{ +struct bq25890_device *bq = data; + +cancel_delayed_work_sync (&bq->pump_express_work); +} +static int bq25890_probe (struct i2c_client *client) {struct device *dev = &client->dev;
@@ -1274,6 +1281,14 @@ static int bq25890_probe(struct i2c_client *client)/* OTG reporting */ bq->usb_phy =devm_usb_get_phy (dev,USB_PHY_TYPE_USB2 ); +/* +* This must be before bq25890_power_supply_init(), so that it runs +* after devm unregisters the power_supply. +*/ + ret =devm_add_action_or_reset (dev, bq25890_non_devm_cleanup, bq); +if (ret) +return ret; + ret =bq25890_register_regulator (bq);if (ret)return ret;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 782/1146 perf branch: Fix interpretation of branch records
In reply to Greg Kroah-HartmanFrom: James Clark <[email protected]>
[ Upstream commit 20ed9fa4965875fdde5bfd65d838465e38d46b22 ]
Commit 93315e46b000fc80 ("perf/core: Add speculation info to branch entries") added a new field in between type and new_type. Perf has its own copy of this struct so update it to match the kernel side.
This doesn't currently cause any issues because new_type is only used by the Arm BRBE driver which isn't merged yet.
Committer notes:
Is this really an ABI? How are we supposed to deal with old perf.data files with new tools and vice versa? :-\
--- tools/perf/util/branch.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/branch.h +2 -1
@@ -24,9 +24,10 @@ struct branch_flags { u64 abort:1; u64 cycles:16; u64 type:4; + u64 spec:2; u64 new_type:4; u64 priv:3; - u64 reserved:33; + u64 reserved:31; }; }; };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 783/1146 power: supply: fix null pointer dereferencing in power_supply_get_battery_info
In reply to Greg Kroah-HartmanFrom: ruanjinjie <[email protected]>
[ Upstream commit 104bb8a663451404a26331263ce5b96c34504049 ]
when kmalloc() fail to allocate memory in kasprintf(), propname will be NULL, strcmp() called by of_get_property() will cause null pointer dereference.
So return ENOMEM if kasprintf() return NULL pointer.
--- drivers/power/supply/power_supply_core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/power/supply/power_supply_core.c +5 -0
@@ -750,6 +750,11 @@ int power_supply_get_battery_info(struct power_supply *psy,int i, tab_len, size; propname =kasprintf (GFP_KERNEL ,"ocv-capacity-table-%d" , index); +if (!propname) { +power_supply_put_battery_info (psy, info); + err = -ENOMEM ; + goto out_put_node; + } list =of_get_property (battery_np, propname, &size);if (!list || !size) {dev_err (&psy->dev,"failed to get %s\n" , propname);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 784/1146 gfs2: Partially revert gfs2_inode_lookup change
In reply to Greg Kroah-HartmanFrom: Andreas Gruenbacher <[email protected]>
[ Upstream commit 88f4a9f813c549f6b8a6fbf12030949b48a4d5a4 ]
Commit c412a97cf6c5 changed delete_work_func() to always perform an inode lookup when gfs2_try_evict() fails. This doesn't make sense as a gfs2_try_evict() failure indicates that the inode is likely still in use. Revert that change.
--- fs/gfs2/glock.c | 2 ++ 1 file changed, 2 insertions(+)
fs/gfs2/glock.c +2 -0
@@ -1039,6 +1039,7 @@ static void delete_work_func(struct work_struct *work)if (gfs2_queue_delete_work (gl,5 *HZ ))return ; } + goto out; } inode = gfs2_lookup_by_inum(sdp, no_addr, gl->gl_no_formal_ino,
@@ -1051,6 +1052,7 @@ static void delete_work_func(struct work_struct *work)d_prune_aliases (inode);iput (inode); } +out:gfs2_glock_put (gl); }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 785/1146 leds: is31fl319x: Fix setting current limit for is31fl319{0,1,3}
In reply to Greg Kroah-HartmanFrom: Luca Weiss <[email protected]>
[ Upstream commit 135780f1048b3f956f5b10bb23dec9c2d2c4ef6d ]
The current setting lives in bits 4:2 (as also defined by the mask) but the current limit defines in the driver use bits 2:0 which should be shifted over so they don't get masked out completely (except for 17.5mA which became 10mA).
Now checking /sys/kernel/debug/regmap/1-0068/registers shows that the current limit is applied correctly and doesn't take the default b000 = 42mA.
--- drivers/leds/leds-is31fl319x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/leds-is31fl319x.c +2 -1
@@ -38,6 +38,7 @@#define IS31FL3190_CURRENT_uA_MIN 5000#define IS31FL3190_CURRENT_uA_DEFAULT 42000#define IS31FL3190_CURRENT_uA_MAX 42000 +#define IS31FL3190_CURRENT_SHIFT 2#define IS31FL3190_CURRENT_MASK GENMASK(4, 2)#define IS31FL3190_CURRENT_5_mA 0x02#define IS31FL3190_CURRENT_10_mA 0x01
@@ -553,7 +554,7 @@ static int is31fl319x_probe(struct i2c_client *client) is31fl3196_db_to_gain(is31->audio_gain_db)); else regmap_update_bits(is31->regmap, IS31FL3190_CURRENT, IS31FL3190_CURRENT_MASK, -is31fl3190_microamp_to_cs (dev ,aggregated_led_microamp )); + is31fl3190_microamp_to_cs(dev, aggregated_led_microamp) << IS31FL3190_CURRENT_SHIFT);for (i =0 ; i < is31->cdef->num_leds; i++) {struct is31fl319x_led *led = &is31->leds[i];
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 786/1146 perf off_cpu: Fix a typo in BTF tracepoint name, it should be btf_trace_sched_switch
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit 167b266bf66c5b93171011ef9d1f09b070c2c537 ]
In BTF, tracepoint definitions have the "btf_trace_" prefix. The off-cpu profiler needs to check the signature of the sched_switch event using that definition. But there's a typo (s/bpf/btf/) so it failed always.
--- tools/perf/util/bpf_off_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/bpf_off_cpu.c +1 -1
@@ -102,7 +102,7 @@ static void check_sched_switch_args(void)const struct btf_type *t1, *t2, *t3;u32 type_id; - type_id =btf__find_by_name_kind (btf,"bpf_trace_sched_switch" , + type_id =btf__find_by_name_kind (btf,"btf_trace_sched_switch" ,BTF_KIND_TYPEDEF );if ((s32 )type_id <0 )return ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 787/1146 ftrace: Allow WITH_ARGS flavour of graph tracer with shadow call stack
In reply to Greg Kroah-HartmanFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 38792972de4294163f44d6360fd221e6f2c22a05 ]
The recent switch on arm64 from DYNAMIC_FTRACE_WITH_REGS to DYNAMIC_FTRACE_WITH_ARGS failed to take into account that we currently require the former in order to allow the function graph tracer to be enabled in combination with shadow call stacks. This means that this is no longer permitted at all, in spite of the fact that either flavour of ftrace works perfectly fine in this combination.
So permit WITH_ARGS as well as WITH_REGS.
--- arch/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/Kconfig +1 -1
@@ -635,7 +635,7 @@ config ARCH_SUPPORTS_SHADOW_CALL_STACK config SHADOW_CALL_STACK bool "Shadow Call Stack" depends on ARCH_SUPPORTS_SHADOW_CALL_STACK - depends on DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER + depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER help This option enables the compiler's Shadow Call Stack, which uses a shadow stack to protect function return addresses from
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 788/1146 perf stat: Do not delay the workload with --delay
In reply to Greg Kroah-HartmanFrom: Namhyung Kim <[email protected]>
[ Upstream commit c587e77e100fa40eb6af10e00497c67acf493f33 ]
The -D/--delay option is to delay the measure after the program starts. But the current code goes to sleep before starting the program so the program is delayed too. This is not the intention, let's fix it.
Before:
$ time sudo ./perf stat -a -e cycles -D 3000 sleep 4 Events disabled Events enabled
Performance counter stats for 'system wide':
4,326,949,337 cycles
4.007494118 seconds time elapsed real 0m7.474s
user 0m0.356s
sys 0m0.120s
It ran the workload for 4 seconds and gave the 3 second delay. So it should skip the first 3 second and measure the last 1 second only. But as you can see, it delays 3 seconds and ran the workload after that for 4 seconds. So the total time (real) was 7 seconds.
After:
$ time sudo ./perf stat -a -e cycles -D 3000 sleep 4 Events disabled Events enabled
Performance counter stats for 'system wide':
1,063,551,013 cycles
1.002769510 seconds time elapsed real 0m4.484s
user 0m0.385s
sys 0m0.086s
The bug was introduced when it changed enablement of system-wide events with a command line workload. But it should've considered the initial delay case. The code was reworked since then (in bb8bc52e7578) so I'm afraid it won't be applied cleanly.
--- tools/perf/builtin-stat.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
tools/perf/builtin-stat.c +17 -16
@@ -528,26 +528,14 @@ static int enable_counters(void)return err; } -if (stat_config.initial_delay <0 ) { -pr_info (EVLIST_DISABLED_MSG ); -return 0 ; - } - -if (stat_config.initial_delay >0 ) { -pr_info (EVLIST_DISABLED_MSG ); -usleep (stat_config.initial_delay *USEC_PER_MSEC ); - } -/* * We need to enable counters only if: * - we don't have tracee (attaching to task or cpu) * - we have initial delay configured */ -if (!target__none (&target) || stat_config.initial_delay) { +if (!target__none (&target)) {if (!all_counters_use_bpf)evlist__enable (evsel_list); -if (stat_config.initial_delay >0 ) -pr_info (EVLIST_ENABLED_MSG ); }return 0 ; }
@@ -918,14 +906,27 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)return err; } - err =enable_counters (); -if (err) -return -1 ; +if (stat_config.initial_delay) { +pr_info (EVLIST_DISABLED_MSG ); + }else { + err =enable_counters (); +if (err) +return -1 ; + }/* Exec the command, if any */ if (forks)evlist__start_workload (evsel_list); +if (stat_config.initial_delay >0 ) { +usleep (stat_config.initial_delay *USEC_PER_MSEC ); + err =enable_counters (); +if (err) +return -1 ; + +pr_info (EVLIST_ENABLED_MSG ); + } + t0 =rdclock ();clock_gettime (CLOCK_MONOTONIC , &ref_time);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 789/1146 RDMA/siw: Fix pointer cast warning
In reply to Greg Kroah-HartmanFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 5244ca88671a1981ceec09c5c8809f003e6a62aa ]
The previous build fix left a remaining issue in configurations with 64-bit dma_addr_t on 32-bit architectures:
drivers/infiniband/sw/siw/siw_qp_tx.c: In function 'siw_get_pblpage':drivers/infiniband/sw/siw/siw_qp_tx.c:32:37: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
32 | return virt_to_page((void *)paddr);
| ^
Use the same double cast here that the driver uses elsewhere to convert between dma_addr_t and void*.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +1 -1
@@ -29,7 +29,7 @@ static struct page *siw_get_pblpage(struct siw_mem *mem, u64 addr, int *idx)dma_addr_t paddr =siw_pbl_get_buffer (pbl, offset,NULL , idx);if (paddr) -return virt_to_page ((void *)paddr); +return virt_to_page ((void *)(uintptr_t )paddr);return NULL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 790/1146 fs/ntfs3: Avoid UBSAN error on true_sectors_per_clst()
In reply to Greg Kroah-HartmanFrom: Shigeru Yoshida <[email protected]>
[ Upstream commit caad9dd8792a2622737b7273cb34835fd9536cd2 ]
syzbot reported UBSAN error as below:
[ 76.901829][ T6677] ================================================================================ [ 76.903908][ T6677] UBSAN: shift-out-of-bounds in fs/ntfs3/super.c:675:13 [ 76.905363][ T6677] shift exponent -247 is negative
This patch avoid this error.
--- fs/ntfs3/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/super.c +1 -1
@@ -672,7 +672,7 @@ static u32 true_sectors_per_clst(const struct NTFS_BOOT *boot)if (boot->sectors_per_clusters <=0x80 )return boot->sectors_per_clusters;if (boot->sectors_per_clusters >=0xf4 )/* limit shift to 2MB max */ -return 1U << (0 - boot->sectors_per_clusters); +return 1U << -(s8 )boot->sectors_per_clusters;return -EINVAL ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 791/1146 fs/ntfs3: Harden against integer overflows
In reply to Greg Kroah-HartmanFrom: Dan Carpenter <[email protected]>
[ Upstream commit e001e60869390686809663c02bceb1d3922548fb ]
Smatch complains that the "add_bytes" is not to be trusted. Use size_add() to prevent an integer overflow.
--- fs/ntfs3/xattr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/xattr.c +1 -1
@@ -107,7 +107,7 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,return -EFBIG ;/* Allocate memory for packed Ea. */ - ea_p =kmalloc (size + add_bytes,GFP_NOFS ); + ea_p =kmalloc (size_add (size, add_bytes),GFP_NOFS );if (!ea_p)return -ENOMEM ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 792/1146 phy: marvell: phy-mvebu-a3700-comphy: Reset COMPHY registers before USB 3.0 power on
In reply to Greg Kroah-HartmanFrom: Pali Rohár <[email protected]>
[ Upstream commit b01d622d76134e9401970ffd3fbbb9a7051f976a ]
Turris MOX board with older ARM Trusted Firmware version v1.5 is not able to detect any USB 3.0 device connected to USB-A port on Mox-A module after commit 0a6fc70d76bd ("phy: marvell: phy-mvebu-a3700-comphy: Remove broken reset support"). On the other hand USB 2.0 devices connected to the same USB-A port are working fine.
It looks as if the older firmware configures COMPHY registers for USB 3.0 somehow incompatibly for kernel driver. Experiments show that resetting COMPHY registers via setting SFT_RST auto-clearing bit in COMPHY_SFT_RESET register fixes this issue.
Reset the COMPHY in mvebu_a3700_comphy_usb3_power_on() function as a first step after selecting COMPHY lane and USB 3.0 function. With this change Turris MOX board can successfully detect USB 3.0 devices again.
Before the above mentioned commit this reset was implemented in PHY reset method, so this is the reason why there was no issue with older firmware version then.
--- drivers/phy/marvell/phy-mvebu-a3700-comphy.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/marvell/phy-mvebu-a3700-comphy.c +3 -0
@@ -826,6 +826,9 @@ mvebu_a3700_comphy_usb3_power_on(struct mvebu_a3700_comphy_lane *lane)if (ret)return ret; +/* COMPHY register reset (cleared automatically) */ +comphy_lane_reg_set (lane,COMPHY_SFT_RESET ,SFT_RST ,SFT_RST ); +/* * 0. Set PHY OTG Control(0x5d034), bit 4, Power up OTG module The * register belong to UTMI module, so it is set in UTMI phy driver.
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 793/1146 phy: qcom-qmp-pcie: drop bogus register update
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 2d93887cb4bac0a36ce9e146956f631ab7994680 ]
Since commit 0d58280cf1e6 ("phy: Update PHY power control sequence") the PHY is powered on before configuring the registers and only the MSM8996 PCIe PHY, which includes the POWER_DOWN_CONTROL register in its PCS initialisation table, may possibly require a second update afterwards.
To make things worse, the POWER_DOWN_CONTROL register lies at a different offset on more recent SoCs so that the second update, which still used a hard-coded offset, would write to an unrelated register (e.g. a revision-id register on SC8280XP).
As the MSM8996 PCIe PHY is now handled by a separate driver, simply drop the bogus register update.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +0 -6
@@ -1975,12 +1975,6 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num);qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec); -/* -* Pull out PHY from POWER DOWN state. -* This is active low enable signal to power-down PHY. -*/ -qphy_setbits (pcs,QPHY_V2_PCS_POWER_DOWN_CONTROL , cfg->pwrdn_ctrl); -if (cfg->has_pwrdn_delay)usleep_range (cfg->pwrdn_delay_min, cfg->pwrdn_delay_max);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 794/1146 dmaengine: idxd: Make max batch size attributes in sysfs invisible for Intel IAA
In reply to Greg Kroah-HartmanFrom: Xiaochen Shen <[email protected]>
[ Upstream commit 91123b37e8a99cc489d5bdcfebd1c25f29382504 ]
In current code, dev.max_batch_size and wq.max_batch_size attributes in sysfs are exposed to user to show or update the values.
Quoted 1 line
From Intel IAA spec [1], Intel IAA does not support batch processing. So
these sysfs attributes should not be supported on IAA device.
Fix this issue by making the attributes of max_batch_size invisible in sysfs through is_visible() filter when the device is IAA.
Add description in the ABI documentation to mention that the attributes are not visible when the device does not support batch.
[1]: https://cdrdv2.intel.com/v1/dl/getContent/721858
--- .../ABI/stable/sysfs-driver-dma-idxd | 2 ++ drivers/dma/idxd/sysfs.c | 32 +++++++++++++++++++ 2 files changed, 34 insertions(+)
Documentation/ABI/stable/sysfs-driver-dma-idxd +2 -0
@@ -22,6 +22,7 @@ Date: Oct 25, 2019 KernelVersion: 5.6.0 Contact: [email protected] Description: The largest number of work descriptors in a batch. + It's not visible when the device does not support batch. What: /sys/bus/dsa/devices/dsa<m>/max_work_queues_size Date: Oct 25, 2019
@@ -205,6 +206,7 @@ KernelVersion: 5.10.0 Contact: [email protected] Description: The max batch size for this workqueue. Cannot exceed device max batch size. Configurable parameter. + It's not visible when the device does not support batch. What: /sys/bus/dsa/devices/wq<m>.<n>/ats_disable Date: Nov 13, 2020
drivers/dma/idxd/sysfs.c +32 -0
@@ -1233,6 +1233,14 @@ static bool idxd_wq_attr_op_config_invisible(struct attribute *attr, !idxd->hw.wq_cap.op_config; } +static bool idxd_wq_attr_max_batch_size_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* Intel IAA does not support batch processing, make it invisible */ +return attr == &dev_attr_wq_max_batch_size.attr && + idxd->data->type ==IDXD_TYPE_IAX ; +} +static umode_t idxd_wq_attr_visible (struct kobject *kobj,struct attribute *attr,int n) {
@@ -1243,6 +1251,9 @@ static umode_t idxd_wq_attr_visible(struct kobject *kobj,if (idxd_wq_attr_op_config_invisible (attr, idxd))return 0 ; +if (idxd_wq_attr_max_batch_size_invisible (attr, idxd)) +return 0 ; +return attr->mode; }
@@ -1533,6 +1544,26 @@ static ssize_t cmd_status_store(struct device *dev, struct device_attribute *att }static DEVICE_ATTR_RW (cmd_status); +static bool idxd_device_attr_max_batch_size_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* Intel IAA does not support batch processing, make it invisible */ +return attr == &dev_attr_max_batch_size.attr && + idxd->data->type ==IDXD_TYPE_IAX ; +} + +static umode_t idxd_device_attr_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ + struct device *dev = container_of(kobj, struct device, kobj); +struct idxd_device *idxd =confdev_to_idxd (dev); + +if (idxd_device_attr_max_batch_size_invisible (attr, idxd)) +return 0 ; + +return attr->mode; +} +static struct attribute *idxd_device_attributes[] = { &dev_attr_version.attr, &dev_attr_max_groups.attr,
@@ -1560,6 +1591,7 @@ static struct attribute *idxd_device_attributes[] = {static const struct attribute_group idxd_device_attribute_group = { .attrs = idxd_device_attributes, + .is_visible = idxd_device_attr_visible, };static const struct attribute_group *idxd_attribute_groups[] = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 795/1146 dmaengine: apple-admac: Allocate cache SRAM to channels
In reply to Greg Kroah-HartmanFrom: Martin Povišer <[email protected]>
[ Upstream commit 568aa6dd641f63166bb60d769e256789b3ac42d4 ]
There's a previously unknown part of the controller interface: We have to assign SRAM carveouts to channels to store their in-flight samples in. So, obtain the size of the SRAM from a read-only register and divide it into 2K blocks for allocation to channels. The FIFO depths we configure will always fit into 2K.
(This fixes audio artifacts during simultaneous playback/capture on multiple channels -- which looking back is fully accounted for by having had the caches in the DMA controller overlap in memory.)
--- drivers/dma/apple-admac.c | 102 +++++++++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-)
drivers/dma/apple-admac.c +101 -1
@@ -21,6 +21,12 @@#define NCHANNELS_MAX 64#define IRQ_NOUTPUTS 4 +/* +* For allocation purposes we split the cache +* memory into blocks of fixed size (given in bytes). +*/ +#define SRAM_BLOCK 2048 +#define RING_WRITE_SLOT GENMASK(1, 0)#define RING_READ_SLOT GENMASK(5, 4)#define RING_FULL BIT(9)
@@ -36,6 +42,9 @@#define REG_TX_STOP 0x0004#define REG_RX_START 0x0008#define REG_RX_STOP 0x000c +#define REG_IMPRINT 0x0090 +#define REG_TX_SRAM_SIZE 0x0094 +#define REG_RX_SRAM_SIZE 0x0098#define REG_CHAN_CTL (ch) (0x8000 + (ch) * 0x200)#define REG_CHAN_CTL_RST_RINGS BIT(0)
@@ -53,7 +62,9 @@#define BUS_WIDTH_FRAME_2_WORDS 0x10#define BUS_WIDTH_FRAME_4_WORDS 0x20 -#define CHAN_BUFSIZE 0x8000 +#define REG_CHAN_SRAM_CARVEOUT (ch) (0x8050 + (ch) * 0x200) +#define CHAN_SRAM_CARVEOUT_SIZE GENMASK(31, 16) +#define CHAN_SRAM_CARVEOUT_BASE GENMASK(15, 0)#define REG_CHAN_FIFOCTL (ch) (0x8054 + (ch) * 0x200)#define CHAN_FIFOCTL_LIMIT GENMASK(31, 16)
@@ -76,6 +87,8 @@ struct admac_chan {struct dma_chan chan;struct tasklet_struct tasklet; +u32 carveout; +spinlock_t lock;struct admac_tx *current_tx;int nperiod_acks;
@@ -92,12 +105,24 @@ struct admac_chan {struct list_head to_free; }; +struct admac_sram { +u32 size; +/* +* SRAM_CARVEOUT has 16-bit fields, so the SRAM cannot be larger than +* 64K and a 32-bit bitfield over 2K blocks covers it. +*/ +u32 allocated; +}; +struct admac_data {struct dma_device dma;struct device *dev;__iomem void *base;struct reset_control *rstc; +struct mutex cache_alloc_lock; +struct admac_sram txcache, rxcache; +int irq;int irq_index;int nchannels;
@@ -118,6 +143,60 @@ struct admac_tx {struct list_head node; }; +static int admac_alloc_sram_carveout (struct admac_data *ad, +enum dma_transfer_direction dir, +u32 *out) +{ +struct admac_sram *sram; +int i, ret =0 , nblocks; + +if (dir ==DMA_MEM_TO_DEV ) + sram = &ad->txcache; +else + sram = &ad->rxcache; + +mutex_lock (&ad->cache_alloc_lock); + + nblocks = sram->size /SRAM_BLOCK ; +for (i =0 ; i < nblocks; i++) +if (!(sram->allocated &BIT (i))) +break ; + +if (i < nblocks) { + *out =FIELD_PREP (CHAN_SRAM_CARVEOUT_BASE , i *SRAM_BLOCK ) | +FIELD_PREP (CHAN_SRAM_CARVEOUT_SIZE ,SRAM_BLOCK ); + sram->allocated |=BIT (i); + }else { + ret = -EBUSY ; + } + +mutex_unlock (&ad->cache_alloc_lock); + +return ret; +} + +static void admac_free_sram_carveout (struct admac_data *ad, +enum dma_transfer_direction dir, +u32 carveout) +{ +struct admac_sram *sram; +u32 base =FIELD_GET (CHAN_SRAM_CARVEOUT_BASE , carveout); +int i; + +if (dir ==DMA_MEM_TO_DEV ) + sram = &ad->txcache; +else + sram = &ad->rxcache; + +if (WARN_ON (base >= sram->size)) +return ; + +mutex_lock (&ad->cache_alloc_lock); + i = base /SRAM_BLOCK ; + sram->allocated &= ~BIT (i); +mutex_unlock (&ad->cache_alloc_lock); +} +static void admac_modify (struct admac_data *ad,int reg,u32 mask,u32 val) {void __iomem *addr = ad->base + reg;
@@ -466,15 +545,28 @@ static void admac_synchronize(struct dma_chan *chan)static int admac_alloc_chan_resources (struct dma_chan *chan) {struct admac_chan *adchan =to_admac_chan (chan); +struct admac_data *ad = adchan->host; +int ret;dma_cookie_init (&adchan->chan); + ret =admac_alloc_sram_carveout (ad,admac_chan_direction (adchan->no), + &adchan->carveout); +if (ret <0 ) +return ret; + +writel_relaxed (adchan->carveout, + ad->base +REG_CHAN_SRAM_CARVEOUT (adchan->no));return 0 ; }static void admac_free_chan_resources (struct dma_chan *chan) { +struct admac_chan *adchan =to_admac_chan (chan); +admac_terminate_all (chan);admac_synchronize (chan); +admac_free_sram_carveout (adchan->host,admac_chan_direction (adchan->no), + adchan->carveout); } static struct dma_chan *admac_dma_of_xlate(struct of_phandle_args *dma_spec,
@@ -712,6 +804,7 @@ static int admac_probe(struct platform_device *pdev)platform_set_drvdata (pdev, ad); ad->dev = &pdev->dev; ad->nchannels = nchannels; +mutex_init (&ad->cache_alloc_lock);/* * The controller has 4 IRQ outputs. Try them all until
@@ -801,6 +894,13 @@ static int admac_probe(struct platform_device *pdev) goto free_irq; } + ad->txcache.size =readl_relaxed (ad->base +REG_TX_SRAM_SIZE ); + ad->rxcache.size =readl_relaxed (ad->base +REG_RX_SRAM_SIZE ); + +dev_info (&pdev->dev,"Audio DMA Controller\n" ); +dev_info (&pdev->dev,"imprint %x TX cache %u RX cache %u\n" , +readl_relaxed (ad->base +REG_IMPRINT ), ad->txcache.size, ad->rxcache.size); +return 0 ; free_irq:
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 796/1146 remoteproc: core: Auto select rproc-virtio device id
In reply to Greg Kroah-HartmanFrom: Shengjiu Wang <[email protected]>
[ Upstream commit 65fcf3872f83d63fb7268e05d4b02640df14126e ]
With multiple remoteproc device, there will below error:
sysfs: cannot create duplicate filename '/bus/platform/devices/rproc-virtio.0'
The rvdev_data.index is duplicate, that cause issue, so need to use the PLATFORM_DEVID_AUTO instead. After fixing device name it becomes something like:
/bus/platform/devices/rproc-virtio.2.auto
--- drivers/remoteproc/remoteproc_core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/remoteproc/remoteproc_core.c +7 -1
@@ -509,7 +509,13 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr, rvdev_data.rsc_offset = offset; rvdev_data.rsc = rsc; - pdev =platform_device_register_data (dev,"rproc-virtio" , rvdev_data.index, &rvdev_data, +/* +* When there is more than one remote processor, rproc->nb_vdev number is +* same for each separate instances of "rproc". If rvdev_data.index is used +* as device id, then we get duplication in sysfs, so need to use +* PLATFORM_DEVID_AUTO to auto select device id. +*/ + pdev =platform_device_register_data (dev,"rproc-virtio" ,PLATFORM_DEVID_AUTO , &rvdev_data,sizeof (rvdev_data));if (IS_ERR (pdev)) {dev_err (dev,"failed to create rproc-virtio device\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 797/1146 phy: qcom-qmp-pcie: drop power-down delay config
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit e71906144b432135b483e228d65be59fbb44c310 ]
The power-down delay was included in the first version of the QMP driver as an optional delay after powering on the PHY (using POWER_DOWN_CONTROL) and just before starting it. Later changes modified this sequence by powering on before initialising the PHY, but the optional delay stayed where it was (i.e. before starting the PHY).
The vendor driver does not use a delay before starting the PHY and this is likely not needed on any platform unless there is a corresponding delay in the vendor kernel init sequence tables (i.e. in devicetree).
Let's keep the delay for now, but drop the redundant delay period configuration while increasing the unnecessarily low timer slack somewhat.
Stable-dep-of: 4a9eac5ae220 ("phy: qcom-qmp-pcie: fix sc8180x initialisation")
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 27 +----------------------- 1 file changed, 1 insertion(+), 26 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1 -26
@@ -1346,9 +1346,6 @@ struct qmp_phy_cfg {/* true, if PHY needs delay after POWER_DOWN */ bool has_pwrdn_delay; -/* power_down delay in usec */ -int pwrdn_delay_min; -int pwrdn_delay_max;/* QMP PHY pipe clock interface rate */ unsigned long pipe_clock_rate;
@@ -1480,8 +1477,6 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {
@@ -1507,8 +1502,6 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ .pipe_clock_rate = 250000000, };
@@ -1538,8 +1531,6 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
@@ -1568,8 +1559,6 @@ static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
@@ -1596,8 +1585,6 @@ static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {
@@ -1634,8 +1621,6 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {
@@ -1672,8 +1657,6 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
@@ -1725,8 +1708,6 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
@@ -1755,8 +1736,6 @@ static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .phy_status = PHYSTATUS_4_20, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {
@@ -1785,8 +1764,6 @@ static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ };static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
@@ -1815,8 +1792,6 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .phy_status = PHYSTATUS_4_20, .has_pwrdn_delay = true, - .pwrdn_delay_min = 995, /* us */ - .pwrdn_delay_max = 1005, /* us */ }; static void qmp_pcie_configure_lane(void __iomem *base,
@@ -1976,7 +1951,7 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec);if (cfg->has_pwrdn_delay) -usleep_range (cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); +usleep_range (1000 ,1200 );/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 798/1146 phy: qcom-qmp-pcie: replace power-down delay
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 51bd33069f80705aba5f4725287bc5688ca6d92a ]
The power-down delay was included in the first version of the QMP driver as an optional delay after powering on the PHY (using POWER_DOWN_CONTROL) and just before starting it. Later changes modified this sequence by powering on before initialising the PHY, but the optional delay stayed where it was (i.e. before starting the PHY).
The vendor driver does not use a delay before starting the PHY and this is likely not needed on any platform unless there is a corresponding delay in the vendor kernel init sequence tables (i.e. in devicetree).
But as the vendor kernel do have a 1 ms delay *after* starting the PHY and before starting to poll the status it is possible that later contributors have simply not noticed that the mainline power-down delay is not equivalent.
As the current delay before even starting the PHY is pretty much pointless and likely a mistake, move the delay after starting the PHY which avoids a few iterations of polling and speeds up startup by 1 ms (the poll loop otherwise takes about 1.8 ms).
Note that MSM8998 has never used a power-down delay so add a flag to skip the delay in case starting the PHY is faster on MSM8998. This can be removed after someone takes a measurement.
Stable-dep-of: 4a9eac5ae220 ("phy: qcom-qmp-pcie: fix sc8180x initialisation")
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 33 +++++------------------- 1 file changed, 6 insertions(+), 27 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +6 -27
@@ -1344,8 +1344,7 @@ struct qmp_phy_cfg {/* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ unsigned int phy_status; -/* true, if PHY needs delay after POWER_DOWN */ -bool has_pwrdn_delay; +bool skip_start_delay;/* QMP PHY pipe clock interface rate */ unsigned long pipe_clock_rate;
@@ -1475,8 +1474,6 @@ static const struct qmp_phy_cfg ipq8074_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = {
@@ -1501,8 +1498,6 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, - .has_pwrdn_delay = true, - .pipe_clock_rate = 250000000, };
@@ -1529,8 +1524,6 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
@@ -1557,8 +1550,6 @@ static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = {
@@ -1583,8 +1574,6 @@ static const struct qmp_phy_cfg sdm845_qhp_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = {
@@ -1619,8 +1608,6 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x1_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = {
@@ -1655,8 +1642,6 @@ static const struct qmp_phy_cfg sm8250_qmp_gen3x2_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg msm8998_pciephy_cfg = {
@@ -1681,6 +1666,8 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, + + .skip_start_delay = true, };static const struct qmp_phy_cfg sc8180x_pciephy_cfg = {
@@ -1706,8 +1693,6 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
@@ -1734,8 +1719,6 @@ static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN, .phy_status = PHYSTATUS_4_20, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = {
@@ -1762,8 +1745,6 @@ static const struct qmp_phy_cfg sm8450_qmp_gen3x1_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, };static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = {
@@ -1790,8 +1771,6 @@ static const struct qmp_phy_cfg sm8450_qmp_gen4x2_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, .phy_status = PHYSTATUS_4_20, - - .has_pwrdn_delay = true, }; static void qmp_pcie_configure_lane(void __iomem *base,
@@ -1950,15 +1929,15 @@ static int qmp_pcie_power_on(struct phy *phy)qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl, cfg->pcs_misc_tbl_num);qmp_pcie_configure (pcs_misc, cfg->regs, cfg->pcs_misc_tbl_sec, cfg->pcs_misc_tbl_num_sec); -if (cfg->has_pwrdn_delay) -usleep_range (1000 ,1200 ); -/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );/* start SerDes and Phy-Coding-Sublayer */ qphy_setbits (pcs, cfg->regs[QPHY_START_CTRL ], cfg->start_ctrl); +if (!cfg->skip_start_delay) +usleep_range (1000 ,1200 ); + status = pcs + cfg->regs[QPHY_PCS_STATUS ]; mask = cfg->phy_status; ready =0 ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 799/1146 phy: qcom-qmp-pcie: fix sc8180x initialisation
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 4a9eac5ae2200f1b208dd33738777f89f93dc0fe ]
The phy_status mask was never set for SC8180X which meant that the driver would not wait for the PHY to be initialised during power-on and would never detect PHY initialisation timeouts.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1 -0
@@ -1693,6 +1693,7 @@ static const struct qmp_phy_cfg sc8180x_pciephy_cfg = { .start_ctrl = PCS_START | SERDES_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, + .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg sdx55_qmp_pciephy_cfg = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 800/1146 phy: qcom-qmp-pcie: fix ipq8074-gen3 initialisation
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 94b7288eadf6e2c09e6280c65a9d07cca01bf434 ]
The phy_status mask was never set for IPQ8074 (gen3) which meant that the driver would not wait for the PHY to be initialised during power-on and would never detect PHY initialisation timeouts.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1 -0
@@ -1497,6 +1497,7 @@ static const struct qmp_phy_cfg ipq8074_pciephy_gen3_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, + .phy_status = PHYSTATUS, .pipe_clock_rate = 250000000, };
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 801/1146 phy: qcom-qmp-pcie: fix ipq6018 initialisation
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 30518b19895789aa9101474af2ee0f62cd882d5e ]
The phy_status mask was never set for IPQ6018 which meant that the driver would not wait for the PHY to be initialised during power-on and would never detect PHY initialisation timeouts.
--- drivers/phy/qualcomm/phy-qcom-qmp-pcie.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-pcie.c +1 -0
@@ -1525,6 +1525,7 @@ static const struct qmp_phy_cfg ipq6018_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, + .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg sdm845_qmp_pciephy_cfg = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 802/1146 phy: qcom-qmp-usb: clean up power-down handling
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 645d3d04702401e002928b934b830bd25be9e277 ]
Always define the POWER_DOWN_CONTROL register instead of falling back to the v2 (and v3) offset during power on and power off.
Stable-dep-of: 922adfd59efd ("phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY")
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +6 -14
@@ -126,6 +126,7 @@ static const unsigned int usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d4, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0d8, [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x178, + [QPHY_PCS_POWER_DOWN_CONTROL] = 0x04, };static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -135,6 +136,7 @@ static const unsigned int qmp_v3_usb3phy_regs_layout[QPHY_LAYOUT_SIZE] = { [QPHY_PCS_AUTONOMOUS_MODE_CTRL] = 0x0d8, [QPHY_PCS_LFPS_RXTERM_IRQ_CLEAR] = 0x0dc, [QPHY_PCS_LFPS_RXTERM_IRQ_STATUS] = 0x170, + [QPHY_PCS_POWER_DOWN_CONTROL] = 0x04, };static const unsigned int qmp_v4_usb3phy_regs_layout[QPHY_LAYOUT_SIZE ] = {
@@ -2164,13 +2166,8 @@ static int qmp_usb_init(struct phy *phy)qphy_clrbits (dp_com,QPHY_V3_DP_COM_SW_RESET ,SW_RESET ); } -if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ]) -qphy_setbits (pcs, - cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], - cfg->pwrdn_ctrl); -else -qphy_setbits (pcs,QPHY_V2_PCS_POWER_DOWN_CONTROL , - cfg->pwrdn_ctrl); +qphy_setbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], + cfg->pwrdn_ctrl);return 0 ;
@@ -2277,13 +2274,8 @@ static int qmp_usb_power_off(struct phy *phy)qphy_clrbits (qphy->pcs, cfg->regs[QPHY_START_CTRL ], cfg->start_ctrl);/* Put PHY into POWER DOWN state: active low */ -if (cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ]) { -qphy_clrbits (qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], - cfg->pwrdn_ctrl); - }else { -qphy_clrbits (qphy->pcs,QPHY_V2_PCS_POWER_DOWN_CONTROL , - cfg->pwrdn_ctrl); - } +qphy_clrbits (qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], + cfg->pwrdn_ctrl);return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 803/1146 phy: qcom-qmp-usb: drop sc8280xp power-down delay
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 898ab85d6b1e8f6271d180c47ef8a024dea9e357 ]
The SC8280XP PHY does not need a delay before starting the PHY (which is what the has_pwrdn_delay config option really controls) so drop the unnecessary delay.
Stable-dep-of: 922adfd59efd ("phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY")
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +0 -4
@@ -1731,10 +1731,6 @@ static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, .phy_status = PHYSTATUS, - - .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 804/1146 phy: qcom-qmp-usb: drop power-down delay config
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 38cd167d1fc6b5bf038229b1fa02bb1f551a564f ]
The power-down delay was included in the first version of the QMP driver as an optional delay after powering on the PHY (using POWER_DOWN_CONTROL) and just before starting it. Later changes modified this sequence by powering on before initialising the PHY, but the optional delay stayed where it was (i.e. before starting the PHY).
The vendor driver does not use a delay before starting the PHY and this is likely not needed on any platform unless there is a corresponding delay in the vendor kernel init sequence tables (i.e. in devicetree).
Let's keep the delay for now, but drop the redundant delay period configuration while increasing the unnecessarily low timer slack somewhat.
Stable-dep-of: 922adfd59efd ("phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY")
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 35 +------------------------ 1 file changed, 1 insertion(+), 34 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +1 -34
@@ -63,8 +63,6 @@#define CLAMP_EN BIT(0)/* enables i/o clamp_n */ #define PHY_INIT_COMPLETE_TIMEOUT 10000 -#define POWER_DOWN_DELAY_US_MIN 10 -#define POWER_DOWN_DELAY_US_MAX 11struct qmp_phy_init_tbl {unsigned int offset;
@@ -1465,9 +1463,6 @@ struct qmp_phy_cfg {/* true, if PHY needs delay after POWER_DOWN */ bool has_pwrdn_delay; -/* power_down delay in usec */ -int pwrdn_delay_min; -int pwrdn_delay_max;/* true, if PHY has a separate DP_COM control block */ bool has_phy_dp_com_ctrl;
@@ -1673,9 +1668,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, - .has_phy_dp_com_ctrl = true, };
@@ -1703,9 +1695,6 @@ static const struct qmp_phy_cfg sc7180_usb3phy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, - .has_phy_dp_com_ctrl = true, };
@@ -1757,8 +1746,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg msm8998_usb3phy_cfg = {
@@ -1811,11 +1798,7 @@ static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { .pwrdn_ctrl = SW_PWRDN, .phy_status = PHYSTATUS, - .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, - .has_phy_dp_com_ctrl = true, };
@@ -1846,8 +1829,6 @@ static const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg sm8250_usb3phy_cfg = {
@@ -1877,9 +1858,6 @@ static const struct qmp_phy_cfg sm8250_usb3phy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, - .has_phy_dp_com_ctrl = true, };
@@ -1910,8 +1888,6 @@ static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = {
@@ -1941,8 +1917,6 @@ static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = {
@@ -1972,8 +1946,6 @@ static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg sm8350_usb3phy_cfg = {
@@ -2003,9 +1975,6 @@ static const struct qmp_phy_cfg sm8350_usb3phy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, - .has_phy_dp_com_ctrl = true, };
@@ -2036,8 +2005,6 @@ static const struct qmp_phy_cfg sm8350_usb3_uniphy_cfg = { .phy_status = PHYSTATUS, .has_pwrdn_delay = true, - .pwrdn_delay_min = POWER_DOWN_DELAY_US_MIN, - .pwrdn_delay_max = POWER_DOWN_DELAY_US_MAX, };static const struct qmp_phy_cfg qcm2290_usb3phy_cfg = {
@@ -2229,7 +2196,7 @@ static int qmp_usb_power_on(struct phy *phy)qmp_usb_configure (pcs, cfg->regs, cfg->pcs_tbl, cfg->pcs_tbl_num);if (cfg->has_pwrdn_delay) -usleep_range (cfg->pwrdn_delay_min, cfg->pwrdn_delay_max); +usleep_range (10 ,20 );/* Pull PHY out of reset state */ qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 805/1146 phy: qcom-qmp-usb: clean up status polling
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit f5ef85adece529a6cd1e7563081c41038923a9ed ]
Clean up the PHY status polling by dropping the configuration mask which is no longer needed since the QMP driver split.
Stable-dep-of: 922adfd59efd ("phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY")
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +2 -23
@@ -1458,8 +1458,6 @@ struct qmp_phy_cfg {unsigned int start_ctrl;unsigned int pwrdn_ctrl; -/* bit offset of PHYSTATUS in QPHY_PCS_STATUS register */ -unsigned int phy_status;/* true, if PHY needs delay after POWER_DOWN */ bool has_pwrdn_delay;
@@ -1617,7 +1615,6 @@ static const struct qmp_phy_cfg ipq8074_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
@@ -1641,7 +1638,6 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = {
@@ -1665,7 +1661,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true,
@@ -1692,7 +1687,6 @@ static const struct qmp_phy_cfg sc7180_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true,
@@ -1719,7 +1713,6 @@ static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
@@ -1743,7 +1736,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -1769,7 +1761,6 @@ static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, };static const struct qmp_phy_cfg sm8150_usb3phy_cfg = {
@@ -1796,7 +1787,6 @@ static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true,
@@ -1826,7 +1816,6 @@ static const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -1855,7 +1844,6 @@ static const struct qmp_phy_cfg sm8250_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true,
@@ -1885,7 +1873,6 @@ static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -1914,7 +1901,6 @@ static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -1943,7 +1929,6 @@ static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -1972,7 +1957,6 @@ static const struct qmp_phy_cfg sm8350_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true,
@@ -2002,7 +1986,6 @@ static const struct qmp_phy_cfg sm8350_usb3_uniphy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, .has_pwrdn_delay = true, };
@@ -2028,7 +2011,6 @@ static const struct qmp_phy_cfg qcm2290_usb3phy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN, - .phy_status = PHYSTATUS, }; static void qmp_usb_configure_lane(void __iomem *base,
@@ -2166,7 +2148,7 @@ static int qmp_usb_power_on(struct phy *phy)void __iomem *rx = qphy->rx;void __iomem *pcs = qphy->pcs;void __iomem *status; -unsigned int mask, val, ready; +unsigned int val;int ret;qmp_usb_serdes_init (qphy);
@@ -2205,10 +2187,7 @@ static int qmp_usb_power_on(struct phy *phy)qphy_setbits (pcs, cfg->regs[QPHY_START_CTRL ], cfg->start_ctrl); status = pcs + cfg->regs[QPHY_PCS_STATUS ]; - mask = cfg->phy_status; - ready =0 ; - - ret =readl_poll_timeout (status, val, (val & mask) == ready,10 , + ret =readl_poll_timeout (status, val, !(val &PHYSTATUS ),10 ,PHY_INIT_COMPLETE_TIMEOUT );if (ret) {dev_err (qmp->dev,"phy initialization timed-out\n" );
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 806/1146 phy: qcom-qmp-usb: drop start and pwrdn-ctrl abstraction
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 47b009db545ae90f0b50149029a6b8137685f524 ]
Drop the start and pwrdn-ctrl abstractions which are no longer needed since the QMP driver split.
Stable-dep-of: 922adfd59efd ("phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY")
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 61 ++----------------------- 1 file changed, 5 insertions(+), 56 deletions(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +5 -56
@@ -1456,9 +1456,6 @@ struct qmp_phy_cfg {/* array of registers with different offsets */ const unsigned int *regs; -unsigned int start_ctrl; -unsigned int pwrdn_ctrl; -/* true, if PHY needs delay after POWER_DOWN */ bool has_pwrdn_delay;
@@ -1612,9 +1609,6 @@ static const struct qmp_phy_cfg ipq8074_usb3phy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = usb3phy_regs_layout, - - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, };static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
@@ -1635,9 +1629,6 @@ static const struct qmp_phy_cfg msm8996_usb3phy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = usb3phy_regs_layout, - - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, };static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = {
@@ -1659,9 +1650,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3phy_cfg = { .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v3_usb3phy_regs_layout, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true, };
@@ -1685,9 +1673,6 @@ static const struct qmp_phy_cfg sc7180_usb3phy_cfg = { .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v3_usb3phy_regs_layout, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true, };
@@ -1710,9 +1695,6 @@ static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v4_usb3phy_regs_layout, - - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, };static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
@@ -1734,9 +1716,6 @@ static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = { .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v3_usb3phy_regs_layout, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -1758,9 +1737,6 @@ static const struct qmp_phy_cfg msm8998_usb3phy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v3_usb3phy_regs_layout, - - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, };static const struct qmp_phy_cfg sm8150_usb3phy_cfg = {
@@ -1785,9 +1761,6 @@ static const struct qmp_phy_cfg sm8150_usb3phy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x300, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true, };
@@ -1814,9 +1787,6 @@ static const struct qmp_phy_cfg sm8150_usb3_uniphy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x600, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -1842,9 +1812,6 @@ static const struct qmp_phy_cfg sm8250_usb3phy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x300, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true, };
@@ -1871,9 +1838,6 @@ static const struct qmp_phy_cfg sm8250_usb3_uniphy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x600, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -1899,9 +1863,6 @@ static const struct qmp_phy_cfg sdx55_usb3_uniphy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x600, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -1927,9 +1888,6 @@ static const struct qmp_phy_cfg sdx65_usb3_uniphy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x1000, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -1955,9 +1913,6 @@ static const struct qmp_phy_cfg sm8350_usb3phy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x300, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, .has_phy_dp_com_ctrl = true, };
@@ -1984,9 +1939,6 @@ static const struct qmp_phy_cfg sm8350_usb3_uniphy_cfg = { .regs = qmp_v4_usb3phy_regs_layout, .pcs_usb_offset = 0x1000, - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, - .has_pwrdn_delay = true, };
@@ -2008,9 +1960,6 @@ static const struct qmp_phy_cfg qcm2290_usb3phy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qcm2290_usb3phy_regs_layout, - - .start_ctrl = SERDES_START | PCS_START, - .pwrdn_ctrl = SW_PWRDN, }; static void qmp_usb_configure_lane(void __iomem *base,
@@ -2111,8 +2060,7 @@ static int qmp_usb_init(struct phy *phy)qphy_clrbits (dp_com,QPHY_V3_DP_COM_SW_RESET ,SW_RESET ); } -qphy_setbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], - cfg->pwrdn_ctrl); +qphy_setbits (pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ],SW_PWRDN );return 0 ;
@@ -2184,7 +2132,7 @@ static int qmp_usb_power_on(struct phy *phy)qphy_clrbits (pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );/* start SerDes and Phy-Coding-Sublayer */ -qphy_setbits (pcs, cfg->regs[QPHY_START_CTRL ], cfg->start_ctrl); +qphy_setbits (pcs, cfg->regs[QPHY_START_CTRL ],SERDES_START |PCS_START ); status = pcs + cfg->regs[QPHY_PCS_STATUS ]; ret = readl_poll_timeout(status, val, !(val & PHYSTATUS), 10,
@@ -2213,11 +2161,12 @@ static int qmp_usb_power_off(struct phy *phy)qphy_setbits (qphy->pcs, cfg->regs[QPHY_SW_RESET ],SW_RESET );/* stop SerDes and Phy-Coding-Sublayer */ -qphy_clrbits (qphy->pcs, cfg->regs[QPHY_START_CTRL ], cfg->start_ctrl); +qphy_clrbits (qphy->pcs, cfg->regs[QPHY_START_CTRL ], +SERDES_START |PCS_START );/* Put PHY into POWER DOWN state: active low */ qphy_clrbits (qphy->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL ], - cfg->pwrdn_ctrl); +SW_PWRDN );return 0 ; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 807/1146 phy: qcom-qmp-usb: correct registers layout for IPQ8074 USB3 PHY
In reply to Greg Kroah-HartmanFrom: Dmitry Baryshkov <[email protected]>
[ Upstream commit 922adfd59efd337059f8445a8d8968552b06ed4e ]
According to the kernel 4.4 sources from NHSS.QSDK.9.0.2 and according to hardware docs, the PHY registers layout used for IPQ8074 USB3 PHY is incorrect. This platform uses offset 0x174 for the PCS_STATUS register, 0xd8 for PCS_AUTONOMOUS_MODE_CTRL, etc.
Correct the PHY registers layout.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +1 -1
@@ -1608,7 +1608,7 @@ static const struct qmp_phy_cfg ipq8074_usb3phy_cfg = { .num_resets = ARRAY_SIZE(msm8996_usb3phy_reset_l), .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), - .regs = usb3phy_regs_layout, + .regs = qmp_v3_usb3phy_regs_layout, };static const struct qmp_phy_cfg msm8996_usb3phy_cfg = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 808/1146 iommu/s390: Fix duplicate domain attachments
In reply to Greg Kroah-HartmanFrom: Niklas Schnelle <[email protected]>
[ Upstream commit bf8d2dd2ed0825a58f31cc510245a1eb46f8a87e ]
Since commit fa7e9ecc5e1c ("iommu/s390: Tolerate repeat attach_dev calls") we can end up with duplicates in the list of devices attached to a domain. This is inefficient and confusing since only one domain can actually be in control of the IOMMU translations for a device. Fix this by detaching the device from the previous domain, if any, on attach. Add a WARN_ON() in case we still have attached devices on freeing the domain. While here remove the re-attach on failure dance as it was determined to be unlikely to help and may confuse debug and recovery.
--- drivers/iommu/s390-iommu.c | 106 ++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 61 deletions(-)
drivers/iommu/s390-iommu.c +45 -61
@@ -79,10 +79,36 @@ static void s390_domain_free(struct iommu_domain *domain) {struct s390_domain *s390_domain =to_s390_domain (domain); +WARN_ON (!list_empty (&s390_domain->devices));dma_cleanup_tables (s390_domain->dma_table);kfree (s390_domain); } +static void __s390_iommu_detach_device (struct zpci_dev *zdev) +{ +struct s390_domain *s390_domain = zdev->s390_domain; +struct s390_domain_device *domain_device, *tmp; +unsigned long flags; + +if (!s390_domain) +return ; + +spin_lock_irqsave (&s390_domain->list_lock, flags); +list_for_each_entry_safe (domain_device, tmp, &s390_domain->devices, + list) { +if (domain_device->zdev == zdev) { +list_del (&domain_device->list); +kfree (domain_device); +break ; + } + } +spin_unlock_irqrestore (&s390_domain->list_lock, flags); + +zpci_unregister_ioat (zdev,0 ); + zdev->s390_domain =NULL ; + zdev->dma_table =NULL ; +} +static int s390_iommu_attach_device (struct iommu_domain *domain,struct device *dev) {
@@ -90,7 +116,7 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,struct zpci_dev *zdev =to_zpci_dev (dev);struct s390_domain_device *domain_device;unsigned long flags; -int cc, rc; +int cc, rc =0 ;if (!zdev)return -ENODEV ;
@@ -99,24 +125,18 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,if (!domain_device)return -ENOMEM ; -if (zdev->dma_table && !zdev->s390_domain) { - cc =zpci_dma_exit_device (zdev); -if (cc) { - rc = -EIO ; - goto out_free; - } - } -if (zdev->s390_domain) -zpci_unregister_ioat (zdev,0 ); +__s390_iommu_detach_device (zdev); +else if (zdev->dma_table) +zpci_dma_exit_device (zdev); - zdev->dma_table = s390_domain->dma_table; cc =zpci_register_ioat (zdev,0 , zdev->start_dma, zdev->end_dma, -virt_to_phys (zdev->dma_table)); +virt_to_phys (s390_domain->dma_table));if (cc) { rc = -EIO ; - goto out_restore; + goto out_free; } + zdev->dma_table = s390_domain->dma_table;spin_lock_irqsave (&s390_domain->list_lock, flags);/* First device defines the DMA range limits */
@@ -127,9 +147,9 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,/* Allow only devices with identical DMA range limits */ }else if (domain->geometry.aperture_start != zdev->start_dma || domain->geometry.aperture_end != zdev->end_dma) { - rc = -EINVAL ;spin_unlock_irqrestore (&s390_domain->list_lock, flags); - goto out_restore; + rc = -EINVAL ; + goto out_unregister; } domain_device->zdev = zdev; zdev->s390_domain = s390_domain;
@@ -138,14 +158,9 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,return 0 ; -out_restore: -if (!zdev->s390_domain) { -zpci_dma_init_device (zdev); - }else { - zdev->dma_table = zdev->s390_domain->dma_table; -zpci_register_ioat (zdev,0 , zdev->start_dma, zdev->end_dma, -virt_to_phys (zdev->dma_table)); - } +out_unregister: +zpci_unregister_ioat (zdev,0 ); + zdev->dma_table =NULL ; out_free:kfree (domain_device);
@@ -155,32 +170,12 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,static void s390_iommu_detach_device (struct iommu_domain *domain,struct device *dev) { -struct s390_domain *s390_domain =to_s390_domain (domain);struct zpci_dev *zdev =to_zpci_dev (dev); -struct s390_domain_device *domain_device, *tmp; -unsigned long flags; -int found =0 ; -if (!zdev) -return ; +WARN_ON (zdev->s390_domain !=to_s390_domain (domain)); -spin_lock_irqsave (&s390_domain->list_lock, flags); -list_for_each_entry_safe (domain_device, tmp, &s390_domain->devices, - list) { -if (domain_device->zdev == zdev) { -list_del (&domain_device->list); -kfree (domain_device); - found =1 ; -break ; - } - } -spin_unlock_irqrestore (&s390_domain->list_lock, flags); - -if (found && (zdev->s390_domain == s390_domain)) { - zdev->s390_domain =NULL ; -zpci_unregister_ioat (zdev,0 ); -zpci_dma_init_device (zdev); - } +__s390_iommu_detach_device (zdev); +zpci_dma_init_device (zdev); }static struct iommu_device *s390_iommu_probe_device (struct device *dev)
@@ -198,24 +193,13 @@ static struct iommu_device *s390_iommu_probe_device(struct device *dev)static void s390_iommu_release_device (struct device *dev) {struct zpci_dev *zdev =to_zpci_dev (dev); -struct iommu_domain *domain;/* -* This is a workaround for a scenario where the IOMMU API common code -* "forgets" to call the detach_dev callback: After binding a device -* to vfio-pci and completing the VFIO_SET_IOMMU ioctl (which triggers -* the attach_dev), removing the device via -* "echo 1 > /sys/bus/pci/devices/.../remove" won't trigger detach_dev, -* only release_device will be called via the BUS_NOTIFY_REMOVED_DEVICE -* notifier. -* -* So let's call detach_dev from here if it hasn't been called before. +* release_device is expected to detach any domain currently attached +* to the device, but keep it attached to other devices in the group. */ -if (zdev && zdev->s390_domain) { - domain =iommu_get_domain_for_dev (dev); -if (domain) -s390_iommu_detach_device (domain, dev); - } +if (zdev) +__s390_iommu_detach_device (zdev); } static int s390_iommu_update_trans(struct s390_domain *s390_domain,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 809/1146 iommu/sun50i: Fix reset release
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 9ad0c1252e84dbc664f0462707182245ed603237 ]
Reset signal is asserted by writing 0 to the corresponding locations of masters we want to reset. So in order to deassert all reset signals, we should write 1's to all locations.
Current code writes 1's to locations of masters which were just reset which is good. However, at the same time it also writes 0's to other locations and thus asserts reset signals of remaining masters. Fix code by writing all 1's when we want to deassert all reset signals.
This bug was discovered when working with Cedrus (video decoder). When it faulted, display went blank due to reset signal assertion.
--- drivers/iommu/sun50i-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +2 -1
@@ -27,6 +27,7 @@#include <linux/types.h> #define IOMMU_RESET_REG 0x010 +#define IOMMU_RESET_RELEASE_ALL 0xffffffff#define IOMMU_ENABLE_REG 0x020#define IOMMU_ENABLE_ENABLE BIT(0)
@@ -893,7 +894,7 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)iommu_write (iommu,IOMMU_INT_CLR_REG , status);iommu_write (iommu,IOMMU_RESET_REG , ~status); -iommu_write (iommu,IOMMU_RESET_REG , status); +iommu_write (iommu,IOMMU_RESET_REG ,IOMMU_RESET_RELEASE_ALL );spin_unlock (&iommu->iommu_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 810/1146 iommu/sun50i: Consider all fault sources for reset
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit cef20703e2b2276aaa402ec5a65ec9a09963b83e ]
We have to reset masters for all faults - permissions, L1 fault or L2 fault. Currently it's done only for permissions. If other type of fault happens, master is in locked up state. Fix that by really considering all fault sources.
--- drivers/iommu/sun50i-iommu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/iommu/sun50i-iommu.c +6 -2
@@ -869,8 +869,8 @@ static phys_addr_t sun50i_iommu_handle_perm_irq(struct sun50i_iommu *iommu)static irqreturn_t sun50i_iommu_irq (int irq,void *dev_id) { +u32 status, l1_status, l2_status, resets;struct sun50i_iommu *iommu = dev_id; -u32 status;spin_lock (&iommu->iommu_lock);
@@ -880,6 +880,9 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)return IRQ_NONE ; } + l1_status =iommu_read (iommu,IOMMU_L1PG_INT_REG ); + l2_status =iommu_read (iommu,IOMMU_L2PG_INT_REG ); +if (status &IOMMU_INT_INVALID_L2PG ) sun50i_iommu_handle_pt_irq(iommu, IOMMU_INT_ERR_ADDR_L2_REG,
@@ -893,7 +896,8 @@ static irqreturn_t sun50i_iommu_irq(int irq, void *dev_id)iommu_write (iommu,IOMMU_INT_CLR_REG , status); -iommu_write (iommu,IOMMU_RESET_REG , ~status); + resets = (status | l1_status | l2_status) &IOMMU_INT_MASTER_MASK ; +iommu_write (iommu,IOMMU_RESET_REG , ~resets);iommu_write (iommu,IOMMU_RESET_REG ,IOMMU_RESET_RELEASE_ALL );spin_unlock (&iommu->iommu_lock);
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 811/1146 iommu/sun50i: Fix R/W permission check
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit eac0104dc69be50bed86926d6f32e82b44f8c921 ]
Because driver has enum type permissions and iommu subsystem has bitmap type, we have to be careful how check for combined read and write permissions is done. In such case, we have to mask both permissions and check that both are set at the same time.
Current code just masks both flags but doesn't check that both are set. In short, it always sets R/W permission, regardles if requested permissions were RO, WO or RW. Fix that.
--- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +1 -1
@@ -271,7 +271,7 @@ static u32 sun50i_mk_pte(phys_addr_t page, int prot)enum sun50i_iommu_aci aci;u32 flags =0 ; -if (prot & (IOMMU_READ |IOMMU_WRITE )) +if ((prot & (IOMMU_READ |IOMMU_WRITE )) == (IOMMU_READ |IOMMU_WRITE )) aci =SUN50I_IOMMU_ACI_RD_WR ;else if (prot &IOMMU_READ ) aci =SUN50I_IOMMU_ACI_RD ;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 812/1146 iommu/sun50i: Fix flush size
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit 67a8a67f9eceb72e4c73d1d09ed9ab04f4b8e12d ]
Function sun50i_table_flush() takes number of entries as an argument, not number of bytes. Fix that mistake in sun50i_dte_get_page_table().
--- drivers/iommu/sun50i-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/sun50i-iommu.c +1 -1
@@ -512,7 +512,7 @@ static u32 *sun50i_dte_get_page_table(struct sun50i_iommu_domain *sun50i_domain,sun50i_iommu_free_page_table (iommu, drop_pt); } -sun50i_table_flush (sun50i_domain, page_table,PT_SIZE ); +sun50i_table_flush (sun50i_domain, page_table,NUM_PT_ENTRIES );sun50i_table_flush (sun50i_domain, dte_addr,1 );return page_table;
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 813/1146 iommu/sun50i: Implement .iotlb_sync_map
In reply to Greg Kroah-HartmanFrom: Jernej Skrabec <[email protected]>
[ Upstream commit e563cc0c787c85a4d9def0a77078dc5d3f445e3d ]
Allocated iova ranges need to be invalidated immediately or otherwise they might or might not work when used by master or CPU. This was discovered when running video decoder conformity test with Cedrus. Some videos were now and then decoded incorrectly and generated page faults.
According to vendor driver, it's enough to invalidate just start and end TLB and PTW cache lines. Documentation says that neighbouring lines must be invalidated too. Finally, when page fault occurs, that iova must be invalidated the same way, according to documentation.
--- drivers/iommu/sun50i-iommu.c | 73 ++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+)
drivers/iommu/sun50i-iommu.c +73 -0
@@ -93,6 +93,8 @@#define NUM_PT_ENTRIES 256#define PT_SIZE (NUM_PT_ENTRIES * PT_ENTRY_SIZE) +#define SPAGE_SIZE 4096 +struct sun50i_iommu {struct iommu_device iommu;
@@ -295,6 +297,62 @@ static void sun50i_table_flush(struct sun50i_iommu_domain *sun50i_domain,dma_sync_single_for_device (iommu->dev, dma, size,DMA_TO_DEVICE ); } +static void sun50i_iommu_zap_iova (struct sun50i_iommu *iommu, +unsigned long iova) +{ +u32 reg; +int ret; + +iommu_write (iommu,IOMMU_TLB_IVLD_ADDR_REG , iova); +iommu_write (iommu,IOMMU_TLB_IVLD_ADDR_MASK_REG ,GENMASK (31 ,12 )); +iommu_write (iommu,IOMMU_TLB_IVLD_ENABLE_REG , +IOMMU_TLB_IVLD_ENABLE_ENABLE ); + + ret =readl_poll_timeout_atomic (iommu->base +IOMMU_TLB_IVLD_ENABLE_REG , + reg, !reg,1 ,2000 ); +if (ret) +dev_warn (iommu->dev,"TLB invalidation timed out!\n" ); +} + +static void sun50i_iommu_zap_ptw_cache (struct sun50i_iommu *iommu, +unsigned long iova) +{ +u32 reg; +int ret; + +iommu_write (iommu,IOMMU_PC_IVLD_ADDR_REG , iova); +iommu_write (iommu,IOMMU_PC_IVLD_ENABLE_REG , +IOMMU_PC_IVLD_ENABLE_ENABLE ); + + ret =readl_poll_timeout_atomic (iommu->base +IOMMU_PC_IVLD_ENABLE_REG , + reg, !reg,1 ,2000 ); +if (ret) +dev_warn (iommu->dev,"PTW cache invalidation timed out!\n" ); +} + +static void sun50i_iommu_zap_range (struct sun50i_iommu *iommu, +unsigned long iova,size_t size) +{ +assert_spin_locked (&iommu->iommu_lock); + +iommu_write (iommu,IOMMU_AUTO_GATING_REG ,0 ); + +sun50i_iommu_zap_iova (iommu, iova); +sun50i_iommu_zap_iova (iommu, iova +SPAGE_SIZE ); +if (size >SPAGE_SIZE ) { +sun50i_iommu_zap_iova (iommu, iova + size); +sun50i_iommu_zap_iova (iommu, iova + size +SPAGE_SIZE ); + } +sun50i_iommu_zap_ptw_cache (iommu, iova); +sun50i_iommu_zap_ptw_cache (iommu, iova +SZ_1M ); +if (size >SZ_1M ) { +sun50i_iommu_zap_ptw_cache (iommu, iova + size); +sun50i_iommu_zap_ptw_cache (iommu, iova + size +SZ_1M ); + } + +iommu_write (iommu,IOMMU_AUTO_GATING_REG ,IOMMU_AUTO_GATING_ENABLE ); +} +static int sun50i_iommu_flush_all_tlb (struct sun50i_iommu *iommu) {u32 reg;
@@ -344,6 +402,18 @@ static void sun50i_iommu_flush_iotlb_all(struct iommu_domain *domain)spin_unlock_irqrestore (&iommu->iommu_lock, flags); } +static void sun50i_iommu_iotlb_sync_map (struct iommu_domain *domain, +unsigned long iova,size_t size) +{ +struct sun50i_iommu_domain *sun50i_domain =to_sun50i_domain (domain); +struct sun50i_iommu *iommu = sun50i_domain->iommu; +unsigned long flags; + +spin_lock_irqsave (&iommu->iommu_lock, flags); +sun50i_iommu_zap_range (iommu, iova, size); +spin_unlock_irqrestore (&iommu->iommu_lock, flags); +} +static void sun50i_iommu_iotlb_sync (struct iommu_domain *domain,struct iommu_iotlb_gather *gather) {
@@ -767,6 +837,7 @@ static const struct iommu_ops sun50i_iommu_ops = { .attach_dev = sun50i_iommu_attach_device, .detach_dev = sun50i_iommu_detach_device, .flush_iotlb_all = sun50i_iommu_flush_iotlb_all, + .iotlb_sync_map = sun50i_iommu_iotlb_sync_map, .iotlb_sync = sun50i_iommu_iotlb_sync, .iova_to_phys = sun50i_iommu_iova_to_phys, .map = sun50i_iommu_map,
@@ -786,6 +857,8 @@ static void sun50i_iommu_report_fault(struct sun50i_iommu *iommu,report_iommu_fault (iommu->domain, iommu->dev, iova, prot); else dev_err(iommu->dev, "Page fault while iommu not attached to any domain?\n"); + +sun50i_iommu_zap_range (iommu, iova,SPAGE_SIZE ); } static phys_addr_t sun50i_iommu_handle_pt_irq(struct sun50i_iommu *iommu,
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 814/1146 iommu/rockchip: fix permission bits in page table entries v2
In reply to Greg Kroah-HartmanFrom: Michael Riesch <[email protected]>
[ Upstream commit 7eb99841f340b80be0d0973b0deb592d75fb8928 ]
As pointed out in the corresponding downstream fix [0], the permission bits of the page table entries are compatible between v1 and v2 of the IOMMU. This is in contrast to the current mainline code that incorrectly assumes that the read and write permission bits are switched. Fix the permission bits by reusing the v1 bit defines.
[0] https://github.com/rockchip-linux/kernel/commit/e3bc123a2260145e34b57454da3db0edd117eb8e
--- drivers/iommu/rockchip-iommu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/iommu/rockchip-iommu.c +4 -6
@@ -280,19 +280,17 @@ static u32 rk_mk_pte(phys_addr_t page, int prot)* 11:9 - Page address bit 34:32 * 8:4 - Page address bit 39:35 * 3 - Security -* 2 - Readable -* 1 - Writable +* 2 - Writable +* 1 - Readable * 0 - 1 if Page @ Page address is valid */ -#define RK_PTE_PAGE_READABLE_V2 BIT(2) -#define RK_PTE_PAGE_WRITABLE_V2 BIT(1)static u32 rk_mk_pte_v2 (phys_addr_t page,int prot) {u32 flags =0 ; - flags |= (prot &IOMMU_READ ) ?RK_PTE_PAGE_READABLE_V2 :0 ; - flags |= (prot &IOMMU_WRITE ) ?RK_PTE_PAGE_WRITABLE_V2 :0 ; + flags |= (prot &IOMMU_READ ) ?RK_PTE_PAGE_READABLE :0 ; + flags |= (prot &IOMMU_WRITE ) ?RK_PTE_PAGE_WRITABLE :0 ;return rk_mk_dte_v2 (page) | flags; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 815/1146 dmaengine: idxd: Make read buffer sysfs attributes invisible for Intel IAA
In reply to Greg Kroah-HartmanFrom: Xiaochen Shen <[email protected]>
[ Upstream commit 9a8ddb35a9d5d3ad76784a012459b256a9d7de7e ]
In current code, the following sysfs attributes are exposed to user to show or update the values:
max_read_buffers (max_tokens)
read_buffer_limit (token_limit) group/read_buffers_allowed (group/tokens_allowed) group/read_buffers_reserved (group/tokens_reserved) group/use_read_buffer_limit (group/use_token_limit)
Quoted 1 line
From Intel IAA spec [1], Intel IAA does not support Read Buffer
allocation control. So these sysfs attributes should not be supported on IAA device.
Fix this issue by making these sysfs attributes invisible through is_visible() filter when the device is IAA.
Add description in the ABI documentation to mention that these attributes are not visible when the device does not support Read Buffer allocation control.
[1]: https://cdrdv2.intel.com/v1/dl/getContent/721858
--- .../ABI/stable/sysfs-driver-dma-idxd | 10 ++++++ drivers/dma/idxd/sysfs.c | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+)
Documentation/ABI/stable/sysfs-driver-dma-idxd +10 -0
@@ -50,6 +50,8 @@ Description: The total number of read buffers supported by this device. The read buffers represent resources within the DSA implementation, and these resources are allocated by engines to support operations. See DSA spec v1.2 9.2.4 Total Read Buffers. + It's not visible when the device does not support Read Buffer + allocation control. What: /sys/bus/dsa/devices/dsa<m>/max_transfer_size Date: Oct 25, 2019
@@ -123,6 +125,8 @@ Contact: [email protected] Description: The maximum number of read buffers that may be in use at one time by operations that access low bandwidth memory in the device. See DSA spec v1.2 9.2.8 GENCFG on Global Read Buffer Limit. + It's not visible when the device does not support Read Buffer + allocation control. What: /sys/bus/dsa/devices/dsa<m>/cmd_status Date: Aug 28, 2020
@@ -252,6 +256,8 @@ KernelVersion: 5.17.0 Contact: [email protected] Description: Enable the use of global read buffer limit for the group. See DSA spec v1.2 9.2.18 GRPCFG Use Global Read Buffer Limit. + It's not visible when the device does not support Read Buffer + allocation control. What: /sys/bus/dsa/devices/group<m>.<n>/read_buffers_allowed Date: Dec 10, 2021
@@ -260,6 +266,8 @@ Contact: [email protected] Description: Indicates max number of read buffers that may be in use at one time by all engines in the group. See DSA spec v1.2 9.2.18 GRPCFG Read Buffers Allowed. + It's not visible when the device does not support Read Buffer + allocation control. What: /sys/bus/dsa/devices/group<m>.<n>/read_buffers_reserved Date: Dec 10, 2021
@@ -268,6 +276,8 @@ Contact: [email protected] Description: Indicates the number of Read Buffers reserved for the use of engines in the group. See DSA spec v1.2 9.2.18 GRPCFG Read Buffers Reserved. + It's not visible when the device does not support Read Buffer + allocation control. What: /sys/bus/dsa/devices/group<m>.<n>/desc_progress_limit Date: Sept 14, 2022
drivers/dma/idxd/sysfs.c +36 -0
@@ -528,6 +528,22 @@ static bool idxd_group_attr_progress_limit_invisible(struct attribute *attr, !idxd->hw.group_cap.progress_limit; } +static bool idxd_group_attr_read_buffers_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* +* Intel IAA does not support Read Buffer allocation control, +* make these attributes invisible. +*/ +return (attr == &dev_attr_group_use_token_limit.attr || + attr == &dev_attr_group_use_read_buffer_limit.attr || + attr == &dev_attr_group_tokens_allowed.attr || + attr == &dev_attr_group_read_buffers_allowed.attr || + attr == &dev_attr_group_tokens_reserved.attr || + attr == &dev_attr_group_read_buffers_reserved.attr) && + idxd->data->type ==IDXD_TYPE_IAX ; +} +static umode_t idxd_group_attr_visible (struct kobject *kobj,struct attribute *attr,int n) {
@@ -538,6 +554,9 @@ static umode_t idxd_group_attr_visible(struct kobject *kobj,if (idxd_group_attr_progress_limit_invisible (attr, idxd))return 0 ; +if (idxd_group_attr_read_buffers_invisible (attr, idxd)) +return 0 ; +return attr->mode; }
@@ -1552,6 +1571,20 @@ static bool idxd_device_attr_max_batch_size_invisible(struct attribute *attr, idxd->data->type ==IDXD_TYPE_IAX ; } +static bool idxd_device_attr_read_buffers_invisible (struct attribute *attr, +struct idxd_device *idxd) +{ +/* +* Intel IAA does not support Read Buffer allocation control, +* make these attributes invisible. +*/ +return (attr == &dev_attr_max_tokens.attr || + attr == &dev_attr_max_read_buffers.attr || + attr == &dev_attr_token_limit.attr || + attr == &dev_attr_read_buffer_limit.attr) && + idxd->data->type ==IDXD_TYPE_IAX ; +} +static umode_t idxd_device_attr_visible (struct kobject *kobj,struct attribute *attr,int n) {
@@ -1561,6 +1594,9 @@ static umode_t idxd_device_attr_visible(struct kobject *kobj,if (idxd_device_attr_max_batch_size_invisible (attr, idxd))return 0 ; +if (idxd_device_attr_read_buffers_invisible (attr, idxd)) +return 0 ; +return attr->mode; }
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 816/1146 phy: qcom-qmp-usb: fix sc8280xp PCS_USB offset
In reply to Greg Kroah-HartmanFrom: Johan Hovold <[email protected]>
[ Upstream commit 4c6b3af3906d0c59497d3bfb07760f3a082b4150 ]
The PCS_USB register block lives at an offset of 0x1000 from the PCS region on SC8280XP so add the missing offset to avoid corrupting unrelated registers on runtime suspend.
Note that the current binding is broken as it does not describe the PCS_USB region and the PCS register size does not cover PCS_USB and the regions in between. As Linux currently maps full pages, simply adding the offset to driver works until the binding has been fixed.
--- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 1 + 1 file changed, 1 insertion(+)
drivers/phy/qualcomm/phy-qcom-qmp-usb.c +1 -0
@@ -1695,6 +1695,7 @@ static const struct qmp_phy_cfg sc8280xp_usb3_uniphy_cfg = { .vreg_list = qmp_phy_vreg_l, .num_vregs = ARRAY_SIZE(qmp_phy_vreg_l), .regs = qmp_v4_usb3phy_regs_layout, + .pcs_usb_offset = 0x1000, };static const struct qmp_phy_cfg qmp_v3_usb3_uniphy_cfg = {
Signature · 1 line
2.35.1
Greg Kroah-Hartman
maintainerPATCH 817/1146 phy: usb: s2 WoL wakeup_count not incremented for USB->Eth devices
In reply to Greg Kroah-HartmanFrom: Al Cooper <[email protected]>
[ Upstream commit f7fc5b7090372fc4dd7798c874635ca41b8ba733 ]
The PHY's "wakeup_count" is not incrementing when waking from WoL. The wakeup count can be found in sysfs at:/sys/bus/platform/devices/rdb/*.usb-phy/power/wakeup_count. The problem is that the system wakup event handler was being passed the wrong "device" by the PHY driver.
--- drivers/phy/broadcom/phy-brcm-usb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/broadcom/phy-brcm-usb.c +3 -3
@@ -102,9 +102,9 @@ static int brcm_pm_notifier(struct notifier_block *notifier,static irqreturn_t brcm_usb_phy_wake_isr (int irq,void *dev_id) { -struct phy *gphy = dev_id; +struct device *dev = dev_id; -pm_wakeup_event (&gphy->dev,0 ); +pm_wakeup_event (dev,0 );return IRQ_HANDLED ; }
@@ -451,7 +451,7 @@ static int brcm_usb_phy_dvr_init(struct platform_device *pdev,if (priv->wake_irq >=0 ) { err =devm_request_irq (dev, priv->wake_irq, brcm_usb_phy_wake_isr,0 , -dev_name (dev), gphy); +dev_name (dev), dev);if (err <0 )return err;device_set_wakeup_capable (dev,1 );
Signature · 1 line
2.35.1