5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1366/1848 dt-bindings: vendor-prefixes: add Revotics
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 1acb40298366b8350d34db47dd9aae72ff18691e ]
Document vendor prefix for Revotics (Revolution Robotics, Inc.).
Stable-dep-of: ea55bba4c68a ("dt-bindings: vendor-prefixes: Add Retroid Pocket")
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -928,6 +928,8 @@ patternProperties: description: iMX6 Rex Project "^rervision,.*": description: Shenzhen Rervision Technology Co., Ltd. + "^revotics,.*": + description: Revolution Robotics, Inc. (Revotics) "^richtek,.*": description: Richtek Technology Corporation "^ricoh,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1367/1848 dt-bindings: vendor-prefixes: Add Retronix Technology Inc.
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Vasut <[email protected]>
[ Upstream commit da076d5562d2fc99138ff8ab04ff82eee7a4a3d8 ]
Add vendor prefix for Retronix Technology Inc.
https://www.retronix.com.tw/en/about.html
Stable-dep-of: ea55bba4c68a ("dt-bindings: vendor-prefixes: Add Retroid Pocket")
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -928,6 +928,8 @@ patternProperties: description: iMX6 Rex Project "^rervision,.*": description: Shenzhen Rervision Technology Co., Ltd. + "^retronix,.*": + description: Retronix Technology Inc. "^revotics,.*": description: Revolution Robotics, Inc. (Revotics) "^richtek,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1368/1848 dt-bindings: vendor-prefixes: Add Retroid Pocket
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Kling <[email protected]>
[ Upstream commit ea55bba4c68a49fcb527da6c71dd48879b705fd1 ]
Add an entry for Retroid Pocket (https://www.goretroid.com/)
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -928,6 +928,8 @@ patternProperties: description: iMX6 Rex Project "^rervision,.*": description: Shenzhen Rervision Technology Co., Ltd. + "^retroidpocket,.*": + description: Retroid Pocket "^retronix,.*": description: Retronix Technology Inc. "^revotics,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1369/1848 MIPS: Octeon: size the swiotlb for a modular OHCI platform driver
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Orgad Shaneh <[email protected]>
[ Upstream commit f1dd1f0c8d595a019be503d40060d25721313b4a ]
plat_swiotlb_setup() raises the swiotlb to 64 MB on OCTEON II with memory above 4 GB, because that OHCI can only DMA to 32 bits. The test is "#ifdef CONFIG_USB_OHCI_HCD_PLATFORM", which is false when the driver is a module - the usual way to build it - so the bump is silently skipped.
What is left depends on the rest of the function: with PCI enabled the "memory past the BAR1 hole" branch happens to ask for the same 64 MB, but with CONFIG_PCI off - which is normal on these SoCs when no PCI devices are wired - swiotlbsize stays at the PAGE_SIZE it was initialised to. A full- or low-speed device on an OCTEON II board with more than 4 GB of RAM then has no bounce buffer to speak of.
Use IS_ENABLED() so a modular OHCI gets the same sizing as a built-in one. Seen on a CN6635 board with 8 GB of RAM and CONFIG_USB_OHCI_HCD_PLATFORM=m.
--- arch/mips/cavium-octeon/dma-octeon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/cavium-octeon/dma-octeon.c +1 -1
@@ -231,7 +231,7 @@ void __init plat_swiotlb_setup(void) swiotlbsize = 64 * (1<<20); }#endif -#ifdef CONFIG_USB_OHCI_HCD_PLATFORM +#if IS_ENABLED (CONFIG_USB_OHCI_HCD_PLATFORM )/* OCTEON II ohci is only 32-bit. */ if (OCTEON_IS_OCTEON2 () && max_addr >=0x100000000ul ) swiotlbsize =64 * (1 <<20 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1370/1848 m68k: apollo: Fix interrupt setup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Palmer <[email protected]>
[ Upstream commit 6cdbe63badcb524c88f2c8b3cee08f2ffc099a1b ]
The user interrupt vector needs to be installed before the interrupts are unmasked otherwise the timer tick isn't handled and boot up gets stuck in calibrate_delay().
--- arch/m68k/apollo/dn_ints.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/m68k/apollo/dn_ints.c +6 -0
@@ -2,6 +2,7 @@#include <linux/interrupt.h> #include <linux/irq.h> +#include <asm/irq.h> #include <asm/traps.h> #include <asm/apollohw.h>
@@ -9,10 +10,13 @@ unsigned int apollo_irq_startup(struct irq_data *data) {unsigned int irq = data->irq; +m68k_irq_startup (data); +if (irq <8 ) *(volatile unsigned char *)(pica+1 ) &= ~(1 << irq);else *(volatile unsigned char *)(picb+1 ) &= ~(1 << (irq -8 )); +return 0 ; }
@@ -24,6 +28,8 @@ void apollo_irq_shutdown(struct irq_data *data) *(volatile unsigned char *)(pica+1 ) |= (1 << irq); else *(volatile unsigned char *)(picb+1 ) |= (1 << (irq -8 )); + +m68k_irq_shutdown (data); }void apollo_irq_eoi (struct irq_data *data)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1371/1848 drm/msm/a6xx: Fix secondary rail vote in ARC votes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akhil P Oommen <[email protected]>
[ Upstream commit 128a0edde50780ed9eb93ab5d2e18ca24c1f1c43 ]
Using the requested level can pick a secondary corner lower than the one required to support the chosen primary corner, under-voting the dependent rail. To fix this, match against the selected primary voltage instead.
Patchwork: https://patchwork.freedesktop.org/patch/755592/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gmu.c +5 -1
@@ -1252,10 +1252,14 @@ static int a6xx_gmu_rpmh_arc_votes_init(struct device *dev, u32 *votes,/* * Look for a level in in the secondary list that matches. If * nothing fits, use the maximum non zero vote +* +* The secondary rail depends on the primary rail, so match it +* against the quantized primary voltage (which is >= the +* requested level), not the requested level itself. */ for (j =0 ; j < sec_count; j++) { -if (sec[j] >= level) { +if (sec[j] >= pri[pindex]) { sindex = j;break ; }else if (sec[j]) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1372/1848 netfilter: synproxy: fix reset of ct seqadj when reopening a connection
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fernando Fernandez Mancera <[email protected]>
[ Upstream commit a8708aa9fe1095ca7859cb3f102b6a3fa0fb98bd ]
SYNPROXY is resetting conntrack seqadj when a closed connection is re-opened, but it was using nf_ct_seqadj_init() which is a no-op for a zero offset.
This patch introduces nf_ct_seqadj_reset() which sets the offset values directly to zero and avoid setting IPS_SEQ_ADJUST_BIT flag, it changes SYNPROXY code to use it when needed.
--- include/net/netfilter/nf_conntrack_seqadj.h | 1 + net/netfilter/nf_conntrack_seqadj.c | 17 +++++++++++++++++ net/netfilter/nf_synproxy_core.c | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-)
include/net/netfilter/nf_conntrack_seqadj.h +1 -0
@@ -33,6 +33,7 @@ static inline struct nf_conn_seqadj *nfct_seqadj_ext_add(struct nf_conn *ct)int nf_ct_seqadj_init (struct nf_conn *ct,enum ip_conntrack_info ctinfo,s32 off); +void nf_ct_seqadj_reset (struct nf_conn *ct,enum ip_conntrack_info ctinfo);int nf_ct_seqadj_set (struct nf_conn *ct,enum ip_conntrack_info ctinfo,__be32 seq,s32 off); void nf_ct_tcp_seqadj_set(struct sk_buff *skb, struct nf_conn *ct,
net/netfilter/nf_conntrack_seqadj.c +17 -0
@@ -29,6 +29,23 @@ int nf_ct_seqadj_init(struct nf_conn *ct, enum ip_conntrack_info ctinfo, }EXPORT_SYMBOL_GPL (nf_ct_seqadj_init); +void nf_ct_seqadj_reset (struct nf_conn *ct,enum ip_conntrack_info ctinfo) +{ +struct nf_conn_seqadj *seqadj =nfct_seqadj (ct); +enum ip_conntrack_dir dir =CTINFO2DIR (ctinfo); +struct nf_ct_seqadj *this_way; + +if (unlikely (!seqadj)) +return ; + +spin_lock_bh (&ct->lock); + this_way = &seqadj->seq[dir]; + this_way->offset_before =0 ; + this_way->offset_after =0 ; +spin_unlock_bh (&ct->lock); +} +EXPORT_SYMBOL_GPL (nf_ct_seqadj_reset); +int nf_ct_seqadj_set (struct nf_conn *ct,enum ip_conntrack_info ctinfo,__be32 seq,s32 off) {
net/netfilter/nf_synproxy_core.c +2 -2
@@ -709,7 +709,7 @@ ipv4_synproxy_hook(void *priv, struct sk_buff *skb,* adjustments, they will get initialized once the connection is * reestablished. */ -nf_ct_seqadj_init (ct, ctinfo,0 ); +nf_ct_seqadj_reset (ct, ctinfo); synproxy->tsoff =0 ;this_cpu_inc (snet->stats->conn_reopened); fallthrough;
@@ -1137,7 +1137,7 @@ ipv6_synproxy_hook(void *priv, struct sk_buff *skb,* adjustments, they will get initialized once the connection is * reestablished. */ -nf_ct_seqadj_init (ct, ctinfo,0 ); +nf_ct_seqadj_reset (ct, ctinfo); synproxy->tsoff =0 ;this_cpu_inc (snet->stats->conn_reopened); fallthrough;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1373/1848 ARM: dts: gemini: Use a level-high interrupt for TVE200
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 5bf1bb010712bba28eda926ed453db3cab91381a ]
TVE200's interrupt is configured as rising-edge. On the D-Link DIR-685, this can stop interrupt delivery after the first vertical interrupt, causing vblank and page-flip timeouts and delaying framebuffer console startup.
The vertical interrupt can remain pending after acknowledgment. Use level-high triggering so the pending condition is delivered again without requiring another edge.
Message-ID: <[email protected]>
--- arch/arm/boot/dts/gemini.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boot/dts/gemini.dtsi +1 -1
@@ -403,7 +403,7 @@ dma-controller@67000000 { display-controller@6a000000 { compatible = "cortina,gemini-tvc", "faraday,tve200"; reg = <0x6a000000 0x1000>; - interrupts = <13 IRQ_TYPE_EDGE_RISING>; + interrupts = <13 IRQ_TYPE_LEVEL_HIGH>; resets = <&syscon GEMINI_RESET_TVC>; clocks = <&syscon GEMINI_CLK_GATE_TVC>, <&syscon GEMINI_CLK_TVC>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1374/1848 iommu/vt-d: Report more information about invalidation errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit 6ca69e5841f01ccbfa45e56577e1b33e14e53504 ]
When the invalidation queue errors are encountered, dump the information logged by the VT-d hardware together with the pending queue invalidation descriptors.
Stable-dep-of: 754d07b940c4 ("iommu/vt-d: Fix IQE handling to cover all descriptors in submission range")
--- drivers/iommu/intel/dmar.c | 68 ++++++++++++++++++++++++++++++++++--- include/linux/intel-iommu.h | 6 ++++ 2 files changed, 70 insertions(+), 4 deletions(-)
drivers/iommu/intel/dmar.c +64 -4
@@ -1199,6 +1199,63 @@ static inline void reclaim_free_desc(struct q_inval *qi) } } +static const char *qi_type_string (u8 type) +{ +switch (type) { +case QI_CC_TYPE : +return "Context-cache Invalidation" ; +case QI_IOTLB_TYPE : +return "IOTLB Invalidation" ; +case QI_DIOTLB_TYPE : +return "Device-TLB Invalidation" ; +case QI_IEC_TYPE : +return "Interrupt Entry Cache Invalidation" ; +case QI_IWD_TYPE : +return "Invalidation Wait" ; +case QI_EIOTLB_TYPE : +return "PASID-based IOTLB Invalidation" ; +case QI_PC_TYPE : +return "PASID-cache Invalidation" ; +case QI_DEIOTLB_TYPE : +return "PASID-based Device-TLB Invalidation" ; +case QI_PGRP_RESP_TYPE : +return "Page Group Response" ; +default : +return "UNKNOWN" ; + } +} + +static void qi_dump_fault (struct intel_iommu *iommu,u32 fault) +{ +unsigned int head =dmar_readl (iommu->reg +DMAR_IQH_REG ); +u64 iqe_err =dmar_readq (iommu->reg +DMAR_IQER_REG ); +struct qi_desc *desc = iommu->qi->desc + head; + +if (fault &DMA_FSTS_IQE ) +pr_err ("VT-d detected Invalidation Queue Error: Reason %llx" , +DMAR_IQER_REG_IQEI (iqe_err)); +if (fault &DMA_FSTS_ITE ) +pr_err ("VT-d detected Invalidation Time-out Error: SID %llx" , +DMAR_IQER_REG_ITESID (iqe_err)); +if (fault &DMA_FSTS_ICE ) +pr_err ("VT-d detected Invalidation Completion Error: SID %llx" , +DMAR_IQER_REG_ICESID (iqe_err)); + +pr_err ("QI HEAD: %s qw0 = 0x%llx, qw1 = 0x%llx\n" , +qi_type_string (desc->qw0 &0xf ), + (unsigned long long )desc->qw0, + (unsigned long long )desc->qw1); + + head = ((head >>qi_shift (iommu)) +QI_LENGTH -1 ) %QI_LENGTH ; + head <<=qi_shift (iommu); + desc = iommu->qi->desc + head; + +pr_err ("QI PRIOR: %s qw0 = 0x%llx, qw1 = 0x%llx\n" , +qi_type_string (desc->qw0 &0xf ), + (unsigned long long )desc->qw0, + (unsigned long long )desc->qw1); +} +static int qi_check_fault (struct intel_iommu *iommu,int index,int wait_index) {u32 fault;
@@ -1210,6 +1267,8 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index)return -EAGAIN ; fault =readl (iommu->reg +DMAR_FSTS_REG ); +if (fault & (DMA_FSTS_IQE |DMA_FSTS_ITE |DMA_FSTS_ICE )) +qi_dump_fault (iommu, fault);/* * If IQE happens, the head points to the descriptor associated
@@ -1226,12 +1285,10 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index)* used by software as private data. We won't print * out these two qw's for security consideration. */ -pr_err ("VT-d detected invalid descriptor: qw0 = %llx, qw1 = %llx\n" , - (unsigned long long )desc->qw0, - (unsigned long long )desc->qw1);memcpy (desc, qi->desc + (wait_index << shift),1 << shift);writel (DMA_FSTS_IQE , iommu->reg +DMAR_FSTS_REG ); +pr_info ("Invalidation Queue Error (IQE) cleared\n" );return -EINVAL ; } }
@@ -1247,6 +1304,7 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index) tail = ((tail >> shift) -1 +QI_LENGTH ) %QI_LENGTH ;writel (DMA_FSTS_ITE , iommu->reg +DMAR_FSTS_REG ); +pr_info ("Invalidation Time-out Error (ITE) cleared\n" ); do { if (qi->desc_status[head] == QI_IN_USE)
@@ -1258,8 +1316,10 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index)return -EAGAIN ; } -if (fault &DMA_FSTS_ICE ) +if (fault &DMA_FSTS_ICE ) {writel (DMA_FSTS_ICE , iommu->reg +DMAR_FSTS_REG ); +pr_info ("Invalidation Completion Error (ICE) cleared\n" ); + }return 0 ; }
include/linux/intel-iommu.h +6 -0
@@ -20,6 +20,7 @@#include <linux/io-64-nonatomic-lo-hi.h> #include <linux/dmar.h> #include <linux/ioasid.h> +#include <linux/bitfield.h> #include <asm/cacheflush.h> #include <asm/iommu.h>
@@ -80,6 +81,7 @@#define DMAR_IQ_SHIFT 4/* Invalidation queue head/tail shift */ #define DMAR_IQA_REG 0x90/* Invalidation queue addr register */ #define DMAR_ICS_REG 0x9c/* Invalidation complete status register */ +#define DMAR_IQER_REG 0xb0/* Invalidation queue error record register */ #define DMAR_IRTA_REG 0xb8/* Interrupt remapping table addr register */ #define DMAR_PQH_REG 0xc0/* Page request queue head register */ #define DMAR_PQT_REG 0xc8/* Page request queue tail register */
@@ -126,6 +128,10 @@#define DMAR_VCMD_REG 0xe00/* Virtual command register */ #define DMAR_VCRSP_REG 0xe10/* Virtual command response register */ +#define DMAR_IQER_REG_IQEI (reg) FIELD_GET(GENMASK_ULL(3, 0), reg) +#define DMAR_IQER_REG_ITESID (reg) FIELD_GET(GENMASK_ULL(47, 32), reg) +#define DMAR_IQER_REG_ICESID (reg) FIELD_GET(GENMASK_ULL(63, 48), reg) +#define OFFSET_STRIDE (9)#define dmar_readq (a) readq(a)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1375/1848 iommu/vt-d: Fix IQE handling to cover all descriptors in submission range
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guanghui Feng <[email protected]>
[ Upstream commit 754d07b940c4ce025fab022b548fb5c3d11bf766 ]
When an Invalidation Queue Error (IQE) occurs, hardware halts fetching and IQH points at the faulting descriptor. The previous code only checked whether IQH matched the first descriptor index of the current submission, missing faults on any other descriptor within the batch.
Expand the check to cover the entire submission range [index, wait_index], accounting for circular wrap-around.
Furthermore, after detecting IQE, the old recovery only replaced the single faulting slot with a copy of the wait descriptor and immediately returned -EINVAL. This left two problems:
a) Hardware resumed fetching and could hit another invalid descriptor in the same abandoned batch, raising a second IQE that no submitter would claim — permanently deadlocking the queue.
b) The caller reclaimed all batch slots (QI_FREE) while hardware might still be asynchronously processing descriptors from that batch, allowing concurrent overwrite and descriptor corruption.
Fix both by introducing qi_drain_remaining_descs(): upon IQE detection, overwrite the stranded slots in [IQH, wait_index) with fenced no-op wait descriptors, resubmit the wait descriptor at wait_index, clear IQE, and spin until hardware signals QI_DONE (with DMAR_OPERATION_TIMEOUT). This guarantees hardware has fully drained the batch before the caller reclaims slots.
--- drivers/iommu/intel/dmar.c | 72 ++++++++++++++++++++++++++++++++------ 1 file changed, 61 insertions(+), 11 deletions(-)
drivers/iommu/intel/dmar.c +61 -11
@@ -1256,6 +1256,49 @@ static void qi_dump_fault(struct intel_iommu *iommu, u32 fault) (unsigned long long)desc->qw1); } +static int qi_drain_remaining_descs (struct intel_iommu *iommu,int head, +int wait_index) +{ +struct q_inval *qi = iommu->qi; +int shift =qi_shift (iommu); +struct qi_desc wait_desc = {}; +struct qi_desc nop_desc = {}; +cycles_t start; + + nop_desc.qw0 =QI_IWD_FENCE |QI_IWD_TYPE ; + + wait_desc.qw0 =QI_IWD_STATUS_DATA (QI_DONE ) |QI_IWD_PRQ_DRAIN | +QI_IWD_STATUS_WRITE |QI_IWD_FENCE |QI_IWD_TYPE ; + wait_desc.qw1 =virt_to_phys (&qi->desc_status[wait_index]); + +while (head != wait_index) { +memcpy (qi->desc + (head << shift), &nop_desc,1 << shift); + head = (head +1 ) %QI_LENGTH ; + } + +WRITE_ONCE (qi->desc_status[wait_index],QI_IN_USE ); +memcpy (qi->desc + (wait_index << shift), &wait_desc,1 << shift); + +/* +* Order the descriptor rewrites before the writel() that restarts +* the fetch engine. +*/ +wmb (); + +writel (DMA_FSTS_IQE , iommu->reg +DMAR_FSTS_REG ); + + start =get_cycles (); +while (READ_ONCE (qi->desc_status[wait_index]) !=QI_DONE ) { +if (DMAR_OPERATION_TIMEOUT < (get_cycles () - start)) { +pr_err ("Timeout draining invalidation queue after IQE\n" ); +return -ETIMEDOUT ; + } +cpu_relax (); + } + +return 0 ; +} +static int qi_check_fault (struct intel_iommu *iommu,int index,int wait_index) {u32 fault;
@@ -1276,18 +1319,25 @@ static int qi_check_fault(struct intel_iommu *iommu, int index, int wait_index)* is cleared. */ if (fault &DMA_FSTS_IQE ) { +int head_idx, ret; + head =readl (iommu->reg +DMAR_IQH_REG ); -if ((head >> shift) == index) { -struct qi_desc *desc = qi->desc + head; - -/* -* desc->qw2 and desc->qw3 are either reserved or -* used by software as private data. We won't print -* out these two qw's for security consideration. -*/ -memcpy (desc, qi->desc + (wait_index << shift), -1 << shift); -writel (DMA_FSTS_IQE , iommu->reg +DMAR_FSTS_REG ); + head_idx = (head >> shift) %QI_LENGTH ; + +/* +* The faulting descriptor can be anywhere within the current +* submission's range [index, wait_index]. Since the queue is +* circular, this submission may wrap around QI_LENGTH +* (index > wait_index in that case), so check both the +* non-wrapped and wrapped cases of the range. +*/ +if (index <= wait_index ? + (head_idx >= index && head_idx <= wait_index) : + (head_idx >= index || head_idx <= wait_index)) { + ret =qi_drain_remaining_descs (iommu, head_idx, wait_index); +if (ret) +return ret; +pr_info ("Invalidation Queue Error (IQE) cleared\n" );return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1376/1848 wifi: mac80211: Fix a race when expiring a mesh path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ginger Li <[email protected]>
[ Upstream commit 6571b6a24cc37c650a1815b1c320e30db5de466f ]
My static analyzer identified a potential issue in 'net/mac80211/mesh_pathtbl.c':mpath_expired() reads mpath->flags and mpath->exp_time without holding mpath->state_lock, while mesh_path_fix_nexthop() and the other writers update both fields under that lock. In mpath_lookup() and __mesh_path_lookup_by_idx() the unlocked check is followed by taking the lock and clearing MESH_PATH_ACTIVE, so the check and the update are not atomic:
CPU0 (mpath_lookup) CPU1 (mesh_path_fix_nexthop)
mpath_expired() reads the stale
flags/exp_time and returns true
spin_lock_bh(&mpath->state_lock)
mpath->exp_time = 0;
mpath->flags = FIXED|SN_VALID;
mesh_path_activate(mpath);
spin_unlock_bh(&mpath->state_lock) spin_lock_bh(&mpath->state_lock)
mpath->flags &= ~MESH_PATH_ACTIVE;
spin_unlock_bh(&mpath->state_lock)
A path which mesh_path_fix_nexthop() has just set up as MESH_PATH_FIXED and MESH_PATH_ACTIVE then has MESH_PATH_ACTIVE cleared again, and forwarding to that destination silently stops.
Take mpath->state_lock before evaluating mpath_expired() so that the check and the clearing of MESH_PATH_ACTIVE are atomic with respect to the writers.
--- net/mac80211/mesh_pathtbl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
net/mac80211/mesh_pathtbl.c +7 -6
@@ -210,9 +210,10 @@ static struct mesh_path *mpath_lookup(struct mesh_table *tbl, const u8 *dst, mpath =rhashtable_lookup (&tbl->rhead, dst, mesh_rht_params); -if (mpath &&mpath_expired (mpath)) { +if (mpath) {spin_lock_bh (&mpath->state_lock); - mpath->flags &= ~MESH_PATH_ACTIVE ; +if (mpath_expired (mpath)) + mpath->flags &= ~MESH_PATH_ACTIVE ;spin_unlock_bh (&mpath->state_lock); }return mpath;
@@ -253,11 +254,11 @@ __mesh_path_lookup_by_idx(struct mesh_table *tbl, int idx)if (!mpath)return NULL ; -if (mpath_expired (mpath)) { -spin_lock_bh (&mpath->state_lock); +spin_lock_bh (&mpath->state_lock); +if (mpath_expired (mpath)) mpath->flags &= ~MESH_PATH_ACTIVE ; -spin_unlock_bh (&mpath->state_lock); - } +spin_unlock_bh (&mpath->state_lock); +return mpath; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1377/1848 RDMA/hns: Refactor the MTR creation flow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xi Wang <[email protected]>
[ Upstream commit 0e0ab04b5bbe84b58097d6dabb3b01b93ce2bf77 ]
Split the hns_roce_mtr_create() into serval small functions, remove unused member in 'struct hns_roce_buf_attr' and delete unnecessary MTR page count check flow to make the MTR creation related codes clearer.
Stable-dep-of: ce29f6e74184 ("RDMA/hns: Pin CQ buffer writable to match device DMA write access")
--- drivers/infiniband/hw/hns/hns_roce_cq.c | 1 - drivers/infiniband/hw/hns/hns_roce_device.h | 1 - drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 1 - drivers/infiniband/hw/hns/hns_roce_mr.c | 291 +++++++++----------- drivers/infiniband/hw/hns/hns_roce_qp.c | 1 - drivers/infiniband/hw/hns/hns_roce_srq.c | 2 - 6 files changed, 125 insertions(+), 172 deletions(-)
drivers/infiniband/hw/hns/hns_roce_cq.c +0 -1
@@ -153,7 +153,6 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, buf_attr.region[0 ].size = hr_cq->cq_depth * hr_cq->cqe_size; buf_attr.region[0 ].hopnum = hr_dev->caps.cqe_hop_num; buf_attr.region_count =1 ; - buf_attr.fixed_page = true; ret = hns_roce_mtr_create(hr_dev, &hr_cq->mtr, &buf_attr, hr_dev->caps.cqe_ba_pg_sz + HNS_HW_PAGE_SHIFT,
drivers/infiniband/hw/hns/hns_roce_device.h +0 -1
@@ -343,7 +343,6 @@ struct hns_roce_buf_attr { } region[HNS_ROCE_MAX_BT_REGION ];unsigned int region_count;/* valid region count */ unsigned int page_shift;/* buffer page shift */ -bool fixed_page;/* decide page shift is fixed-size or maximum size */ unsigned int user_access;/* umem access flag */ bool mtt_only;/* only alloc buffer-required MTT memory */ };
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +0 -1
@@ -5882,7 +5882,6 @@ static int alloc_eq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_eq *eq) buf_attr.region[0 ].size = eq->entries * eq->eqe_size; buf_attr.region[0 ].hopnum = eq->hop_num; buf_attr.region_count =1 ; - buf_attr.fixed_page = true; err = hns_roce_mtr_create(hr_dev, &eq->mtr, &buf_attr, hr_dev->caps.eqe_ba_pg_sz +
drivers/infiniband/hw/hns/hns_roce_mr.c +125 -166
393 lines not on this page · raw message
drivers/infiniband/hw/hns/hns_roce_qp.c +0 -1
@@ -614,7 +614,6 @@ static int set_wqe_buf_attr(struct hns_roce_dev *hr_dev,return -EINVAL ; buf_attr->page_shift =HNS_HW_PAGE_SHIFT + hr_dev->caps.mtt_buf_pg_sz; - buf_attr->fixed_page = true; buf_attr->region_count = idx;return 0 ;
drivers/infiniband/hw/hns/hns_roce_srq.c +0 -2
@@ -195,7 +195,6 @@ static int alloc_srq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, srq->wqe_shift); buf_attr.region[0 ].hopnum = hr_dev->caps.srqwqe_hop_num; buf_attr.region_count =1 ; - buf_attr.fixed_page = true; err = hns_roce_mtr_create(hr_dev, &srq->buf_mtr, &buf_attr, hr_dev->caps.srqwqe_ba_pg_sz +
@@ -227,7 +226,6 @@ static int alloc_srq_idx(struct hns_roce_dev *hr_dev, struct hns_roce_srq *srq, srq->idx_que.entry_shift); buf_attr.region[0 ].hopnum = hr_dev->caps.idx_hop_num; buf_attr.region_count =1 ; - buf_attr.fixed_page = true; err = hns_roce_mtr_create(hr_dev, &idx_que->mtr, &buf_attr, hr_dev->caps.idx_ba_pg_sz + HNS_HW_PAGE_SHIFT,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1378/1848 RDMA/hns: Pin CQ buffer writable to match device DMA write access
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit ce29f6e741844a78ad1977f2a550ede27ecf95f8 ]
alloc_cq_buf() leaves user_access zero-initialized, but the device writes CQEs into the CQ buffer. Set IB_ACCESS_LOCAL_WRITE so the buffer is pinned writable, matching the device's write access.
--- drivers/infiniband/hw/hns/hns_roce_cq.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/hns/hns_roce_cq.c +1 -0
@@ -153,6 +153,7 @@ static int alloc_cq_buf(struct hns_roce_dev *hr_dev, struct hns_roce_cq *hr_cq, buf_attr.region[0 ].size = hr_cq->cq_depth * hr_cq->cqe_size; buf_attr.region[0 ].hopnum = hr_dev->caps.cqe_hop_num; buf_attr.region_count =1 ; + buf_attr.user_access =IB_ACCESS_LOCAL_WRITE ; ret = hns_roce_mtr_create(hr_dev, &hr_cq->mtr, &buf_attr, hr_dev->caps.cqe_ba_pg_sz + HNS_HW_PAGE_SHIFT,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1379/1848 RDMA/mlx5: Set WQ event handler before firmware RQ insertion
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit 28c559d1e25de46bb6dd39e6fa1e93ea6abdf1f6 ]
create_rq() inserts the RQ into dev->qp_table.tree, making it visible to rsc_event_notifier() before rwq->core_qp.event was assigned. A firmware WQ_CATAS_ERROR event in that window finds a NULL event pointer.
Move the assignment before create_rq().
--- drivers/infiniband/hw/mlx5/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/qp.c +1 -1
@@ -5131,6 +5131,7 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd, rwq =kzalloc (sizeof (*rwq),GFP_KERNEL );if (!rwq)return ERR_PTR (-ENOMEM ); + rwq->core_qp.event = mlx5_ib_wq_event; err =prepare_user_rq (pd, init_attr, udata, rwq);if (err) goto err;
@@ -5154,7 +5155,6 @@ struct ib_wq *mlx5_ib_create_wq(struct ib_pd *pd, goto err_copy; } - rwq->core_qp.event = mlx5_ib_wq_event; rwq->ibwq.event_handler = init_attr->event_handler;return &rwq->ibwq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1380/1848 RDMA/mlx5: Set SRQ event handler before xarray insertion
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit d2aa15620e98dc4c6516944397ebea03b7a62b90 ]
mlx5_cmd_create_srq() stores the SRQ into the xarray before srq->msrq.event was assigned. A firmware SRQ event arriving in that window calls through a NULL pointer.
Move the assignment before mlx5_cmd_create_srq().
--- drivers/infiniband/hw/mlx5/srq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/mlx5/srq.c +1 -2
@@ -301,6 +301,7 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq, in.pd =to_mpd (ib_srq->pd)->pdn; in.db_record = srq->db.dma; + srq->msrq.event = mlx5_ib_srq_event; err =mlx5_cmd_create_srq (dev, &srq->msrq, &in);kvfree (in.pas);if (err) {
@@ -309,8 +310,6 @@ int mlx5_ib_create_srq(struct ib_srq *ib_srq, }mlx5_ib_dbg (dev,"create SRQ with srqn 0x%x\n" , srq->msrq.srqn); - - srq->msrq.event = mlx5_ib_srq_event; srq->ibsrq.ext.xrc.srq_num = srq->msrq.srqn;if (udata) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1381/1848 RDMA/mlx5: Set RQ event handler for raw-packet QP
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit a4fa6497002c80b55ebe597242a1bba2ff268886 ]
create_raw_packet_qp() creates a separate firmware RQ object but never assigned rq->base.mqp.event. Any firmware event on this resource (e.g. WQ_CATAS_ERROR, WQ_ACCESS_ERROR) calls through a NULL pointer.
Set the event pointer before the RQ is inserted into the resource table.
--- drivers/infiniband/hw/mlx5/qp.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -1470,6 +1470,7 @@ static int create_raw_packet_qp(struct mlx5_ib_dev *dev, struct mlx5_ib_qp *qp,if (qp->rq.wqe_cnt) { rq->base.container_mibqp = qp; + rq->base.mqp.event = mlx5_ib_qp_event;if (qp->flags &IB_QP_CREATE_CVLAN_STRIPPING ) rq->flags |=MLX5_IB_RQ_CVLAN_STRIPPING ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1382/1848 RDMA/mlx5: Initialize QP/RQ/SQ resource refcount before publishing it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yishai Hadas <[email protected]>
[ Upstream commit 829a0e65deff3f826a7870a52404aeaf1a3fec3f ]
create_resource_common() inserted the resource into the radix tree before its initialization was complete. A firmware EQE in that window finds a zero refcount_t and calls refcount_inc() on it; the refcount API treats this as a use-after-free, saturates the counter, and permanently breaks the resource's lifecycle tracking.
Move the initialization before the radix_tree_insert().
--- drivers/infiniband/hw/mlx5/qpc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/qpc.c +4 -4
@@ -159,6 +159,10 @@ static int create_resource_common(struct mlx5_ib_dev *dev,int err; qp->common.res = rsc_type; +refcount_set (&qp->common.refcount,1 ); +init_completion (&qp->common.free); + qp->pid = current->pid; +spin_lock_irq (&table->lock); err = radix_tree_insert(&table->tree, qp->qpn | (rsc_type << MLX5_USER_INDEX_LEN),
@@ -167,10 +171,6 @@ static int create_resource_common(struct mlx5_ib_dev *dev,if (err)return err; -refcount_set (&qp->common.refcount,1 ); -init_completion (&qp->common.free); - qp->pid = current->pid; -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1383/1848 ALSA: via82xx: use helper to activate DXS controls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit aee7c43126e3184d7eefde6545b3b88628e5591a ]
The VIA DXS playback callbacks modify control access flags directly when a stream opens or closes. This bypasses the control core locking and notification path.
Use snd_ctl_activate_id() for both transitions so access changes are serialized by the control core and reported with the expected info event.
--- sound/pci/via82xx.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
sound/pci/via82xx.c +2 -9
@@ -1247,11 +1247,7 @@ static int snd_via8233_playback_open(struct snd_pcm_substream *substream)VIA_DXS_MAX_VOLUME - (dxs_init_volume &31 ); chip->playback_volume[stream][1 ] =VIA_DXS_MAX_VOLUME - (dxs_init_volume &31 ); - chip->dxs_controls[stream]->vd[0 ].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (chip->card,SNDRV_CTL_EVENT_MASK_VALUE | -SNDRV_CTL_EVENT_MASK_INFO , - &chip->dxs_controls[stream]->id); +snd_ctl_activate_id (chip->card, &chip->dxs_controls[stream]->id,1 ); }return 0 ; }
@@ -1337,10 +1333,7 @@ static int snd_via8233_playback_close(struct snd_pcm_substream *substream) stream = viadev->reg_offset /0x10 ;if (chip->dxs_controls[stream]) { - chip->dxs_controls[stream]->vd[0 ].access |= -SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (chip->card,SNDRV_CTL_EVENT_MASK_INFO , - &chip->dxs_controls[stream]->id); +snd_ctl_activate_id (chip->card, &chip->dxs_controls[stream]->id,0 ); }return snd_via82xx_pcm_close (substream); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1384/1848 drm/exynos/fimd: fix register offset type in fimd_trigger()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit f901c9b986b6355716822d5c6ad34ae5edd71085 ]
Sparse reports:
exynos_drm_fimd.c:992:39: warning: incorrect type in initializer (different address spaces)
exynos_drm_fimd.c:992:39: expected void *timing_base
exynos_drm_fimd.c:992:39: got void [noderef] __iomem *
exynos_drm_fimd.c:1005:33: warning: incorrect type in argument 1 (different address spaces)
exynos_drm_fimd.c:1005:33: expected void const volatile [noderef] __iomem *addr
exynos_drm_fimd.c:1005:33: got void *
exynos_drm_fimd.c:1007:33: warning: incorrect type in argument 2 (different address spaces)
exynos_drm_fimd.c:1007:33: expected void volatile [noderef] __iomem *addr
exynos_drm_fimd.c:1007:33: got void *
Add "__iomem" to *timing_base to fix its type.
--- drivers/gpu/drm/exynos/exynos_drm_fimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/exynos/exynos_drm_fimd.c +1 -1
@@ -944,7 +944,7 @@ static void fimd_trigger(struct device *dev) {struct fimd_context *ctx =dev_get_drvdata (dev);const struct fimd_driver_data *driver_data = ctx->driver_data; -void *timing_base = ctx->regs + driver_data->timing_base; +void __iomem *timing_base = ctx->regs + driver_data->timing_base;u32 reg;/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1385/1848 iio: dac: ad5758: Reject out-of-range raw values
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit ebc026be1b719e47bd7f2f1e72fabc875b590f87 ]
ad5758_write_raw() passes the value from userspace straight to ad5758_spi_reg_write(), which keeps only the low 16 bits. Writing -1 to the raw attribute gives full-scale output, and 65536 gives code 0.
Return -EINVAL for values outside 0 to U16_MAX, as ad5755 does.
--- drivers/iio/dac/ad5758.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/dac/ad5758.c +3 -0
@@ -558,6 +558,9 @@ static int ad5758_write_raw(struct iio_dev *indio_dev,switch (info) {case IIO_CHAN_INFO_RAW : +if (val <0 || val >U16_MAX ) +return -EINVAL ; +mutex_lock (&st->lock); ret =ad5758_spi_reg_write (st,AD5758_DAC_INPUT , val);mutex_unlock (&st->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1386/1848 iio: dac: ad5758: Fix the offset calculation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arka Mondal <[email protected]>
[ Upstream commit a3b3580713f3ac5a32dc2874ee546828977a1d68 ]
The offset is a count of DAC codes, so the microamp or microvolt units of min and max cancel out and the final division by 1000 is wrong. For the +-20 mA range the driver reports -32 instead of -32768. For the +-5 V and +-10 V ranges min * (1 << 16) also overflows int, and the reported offset is 0.
Drop the division and do the multiplication in 64 bits.
--- drivers/iio/dac/ad5758.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5758.c +2 -1
@@ -9,6 +9,7 @@#include <linux/bsearch.h> #include <linux/delay.h> #include <linux/kernel.h> +#include <linux/math64.h> #include <linux/module.h> #include <linux/property.h> #include <linux/of.h>
@@ -542,7 +543,7 @@ static int ad5758_read_raw(struct iio_dev *indio_dev,case IIO_CHAN_INFO_OFFSET : min = st->out_range.min; max = st->out_range.max; - *val = ((min * (1 <<16 )) / (max - min)) /1000 ; + *val =div_s64 ((s64 )min * (1 <<16 ), max - min);return IIO_VAL_INT ;default :return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1387/1848 ALSA: caiaq: Fix the Kore controller key map
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niko Huuskonen <[email protected]>
[ Upstream commit c0508fc6895137f9e2dd43c1a09cc834254cc149 ]
keycode_kore does not match the hardware in two places:
- Softkeys 5 to 8 are listed in reverse order, so pressing the fifth softkey reports BTN_8, the sixth BTN_7 and so on. Softkeys 1 to 4 are correct. The OpenKoreBridge project, which drives a Kore 2 through this driver, works around the same reversal in userspace.
- On the first Kore controller the touch sensors of the eight knobs are
scrambled: touching knob 1 reports KEY_BRL_DOT6, knob 2 KEY_BRL_DOT8, knob 3 KEY_BRL_DOT2, knob 6 KEY_BRL_DOT7, knob 7 KEY_BRL_DOT1 and knob 8 KEY_BRL_DOT3. Only knobs 4 and 5 are right.
Put the softkeys in order for both controllers, and give the first Kore controller its own touch sensor order, so that BTN_n and KEY_BRL_DOTn belong to the n-th knob. The touch sensor order of the Kore 2 is left alone, as it could not be checked.
Userspace that compensates for the old order needs to follow. It can read the key map with EVIOCGKEYCODE, which also makes it possible to support kernels with and without this change.
Tested on a Kore controller (USB ID 17cc:4711).
--- sound/usb/caiaq/input.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
sound/usb/caiaq/input.c +25 -4
@@ -41,11 +41,11 @@ static const unsigned short keycode_kore[] = {BTN_3 ,BTN_2 ,BTN_1 , -BTN_8 , -BTN_7 , -BTN_6 ,BTN_5 , -KEY_BRL_DOT4 ,/* touch sensitive knobs */ +BTN_6 , +BTN_7 , +BTN_8 , +KEY_BRL_DOT4 ,/* touch sensitive knobs (Kore 2 order) */ KEY_BRL_DOT3 ,KEY_BRL_DOT2 , KEY_BRL_DOT1,
@@ -55,6 +55,21 @@ static const unsigned short keycode_kore[] = { KEY_BRL_DOT5 }; +/* index of the first touch sensor in keycode_kore */ +#define KORE_TOUCH_KEYS 24 + +/* the first Kore controller reports its touch sensors in this order */ +static const unsigned short keycode_kore1_touch[] = { +KEY_BRL_DOT4 , +KEY_BRL_DOT8 , +KEY_BRL_DOT3 , +KEY_BRL_DOT7 , +KEY_BRL_DOT2 , +KEY_BRL_DOT6 , +KEY_BRL_DOT1 , +KEY_BRL_DOT5 +}; +#define MASCHINE_BUTTONS (42)#define MASCHINE_BUTTON (X ) ((X) + BTN_MISC)#define MASCHINE_PADS (16)
@@ -656,6 +671,12 @@ int snd_usb_caiaq_input_init(struct snd_usb_caiaqdev *cdev) input->absbit[BIT_WORD (ABS_MISC )] |=BIT_MASK (ABS_MISC );BUILD_BUG_ON (sizeof (cdev->keycode) <sizeof (keycode_kore));memcpy (cdev->keycode, keycode_kore,sizeof (keycode_kore)); +BUILD_BUG_ON (KORE_TOUCH_KEYS +ARRAY_SIZE (keycode_kore1_touch) > +ARRAY_SIZE (keycode_kore)); +if (cdev->chip.usb_id == +USB_ID (USB_VID_NATIVEINSTRUMENTS ,USB_PID_KORECONTROLLER )) +memcpy (cdev->keycode +KORE_TOUCH_KEYS , keycode_kore1_touch, +sizeof (keycode_kore1_touch)); input->keycodemax =ARRAY_SIZE (keycode_kore);input_set_abs_params (input,ABS_HAT0X ,0 ,999 ,0 ,10 );input_set_abs_params (input,ABS_HAT0Y ,0 ,999 ,0 ,10 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1388/1848 spi: spi-rspi: Add support to deassert/assert reset line
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit aadbff4af5c90919cbe67e2c4d77c68cdefa454e ]
On RZ/G2L SoC we need to explicitly deassert the reset line for the device to work, use this opportunity to deassert/assert reset line in spi-rspi driver.
This patch adds support to read the "resets" property (if available) from DT and perform deassert/assert when required.
Stable-dep-of: 7b85114d47f6 ("spi: rspi: Fix DMA mode when the DMA controller is built as a module")
--- drivers/spi/spi-rspi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/spi/spi-rspi.c +25 -0
@@ -21,6 +21,7 @@#include <linux/dma-mapping.h> #include <linux/of_device.h> #include <linux/pm_runtime.h> +#include <linux/reset.h> #include <linux/sh_dma.h> #include <linux/spi/spi.h> #include <linux/spi/rspi.h>
@@ -1226,8 +1227,14 @@ static const struct of_device_id rspi_of_match[] = {MODULE_DEVICE_TABLE (of, rspi_of_match); +static void rspi_reset_control_assert (void *data) +{ +reset_control_assert (data); +} +static int rspi_parse_dt (struct device *dev,struct spi_controller *ctlr) { +struct reset_control *rstc;u32 num_cs;int error;
@@ -1239,6 +1246,24 @@ static int rspi_parse_dt(struct device *dev, struct spi_controller *ctlr) } ctlr->num_chipselect = num_cs; + + rstc =devm_reset_control_get_optional_exclusive (dev,NULL ); +if (IS_ERR (rstc)) +return dev_err_probe (dev,PTR_ERR (rstc), +"failed to get reset ctrl\n" ); + + error =reset_control_deassert (rstc); +if (error) { +dev_err (dev,"failed to deassert reset %d\n" , error); +return error; + } + + error =devm_add_action_or_reset (dev, rspi_reset_control_assert, rstc); +if (error) { +dev_err (dev,"failed to register assert devm action, %d\n" , error); +return error; + } +return 0 ; }#else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1389/1848 spi: rspi: Get rid of unused struct rspi_plat_data
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit bdeef5dcea6b164f4bd614655821b1ef12ebec9a ]
No in-kernel users of struct rspi_plat_data. If required, the software nodes should be used for such users. For now just get rid of it.
Stable-dep-of: 7b85114d47f6 ("spi: rspi: Fix DMA mode when the DMA controller is built as a module")
--- drivers/spi/spi-rspi.c | 12 +----------- include/linux/spi/rspi.h | 18 ------------------ 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 include/linux/spi/rspi.h
drivers/spi/spi-rspi.c +1 -11
@@ -24,7 +24,6 @@#include <linux/reset.h> #include <linux/sh_dma.h> #include <linux/spi/spi.h> -#include <linux/spi/rspi.h> #include <linux/spinlock.h> #define RSPI_SPCR 0x00/* Control Register */
@@ -1131,16 +1130,12 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,static int rspi_request_dma (struct device *dev,struct spi_controller *ctlr,const struct resource *res) { -const struct rspi_plat_data *rspi_pd =dev_get_platdata (dev);unsigned int dma_tx_id, dma_rx_id;if (dev->of_node) {/* In the OF case we will get the slave IDs from the DT */ dma_tx_id =0 ; dma_rx_id =0 ; - }else if (rspi_pd && rspi_pd->dma_tx_id && rspi_pd->dma_rx_id) { - dma_tx_id = rspi_pd->dma_tx_id; - dma_rx_id = rspi_pd->dma_rx_id; }else {/* The driver assumes no error. */ return 0 ;
@@ -1292,7 +1287,6 @@ static int rspi_probe(struct platform_device *pdev)struct spi_controller *ctlr;struct rspi_data *rspi;int ret; -const struct rspi_plat_data *rspi_pd;const struct spi_ops *ops;unsigned long clksrc;
@@ -1307,11 +1301,7 @@ static int rspi_probe(struct platform_device *pdev) goto error1; }else { ops = (struct spi_ops *)pdev->id_entry->driver_data; - rspi_pd =dev_get_platdata (&pdev->dev); -if (rspi_pd && rspi_pd->num_chipselect) - ctlr->num_chipselect = rspi_pd->num_chipselect; -else - ctlr->num_chipselect =2 ;/* default */ + ctlr->num_chipselect =2 ;/* default */ } rspi =spi_controller_get_devdata (ctlr);
include/linux/spi/rspi.h deleted +0 -18
@@ -1,18 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Renesas SPI driver -* -* Copyright (C) 2012 Renesas Solutions Corp. -*/ - -#ifndef __LINUX_SPI_RENESAS_SPI_H__ -#define __LINUX_SPI_RENESAS_SPI_H__ - -struct rspi_plat_data { -unsigned int dma_tx_id; -unsigned int dma_rx_id; - -u16 num_chipselect; -}; - -#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1390/1848 spi: rspi: Fix DMA mode when the DMA controller is built as a module
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit 7b85114d47f693b709b2e8e22e44cdf58c04b111 ]
On the Renesas RZ/G2L platform, the RSPI driver falls back to PIO mode instead of using DMA when the DMA controller driver is built as a module (CONFIG_RZ_DMAC=m):
renesas_spi 1004b000.spi: dma_request_slave_channel_compat failed renesas_spi 1004b000.spi: DMA not available, using PIO
The driver requests DMA channels through dma_request_slave_channel_compat() which returns either a valid pointer or NULL and cannot handle -EPROBE_DEFER. If the DMA controller has not probed yet, the driver falls back to PIO directly.
Fix this by replacing the dma_request_slave_channel_compat() call with a regular dma_request_chan() call. dma_request_slave_channel_compat() is always passed a NULL fn_param in all code paths, so it actually behaves like a plain dma_request_chan() call.
--- drivers/spi/spi-rspi.c | 49 ++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 30 deletions(-)
drivers/spi/spi-rspi.c +19 -30
@@ -22,7 +22,6 @@#include <linux/of_device.h> #include <linux/pm_runtime.h> #include <linux/reset.h> -#include <linux/sh_dma.h> #include <linux/spi/spi.h> #include <linux/spinlock.h>
@@ -1091,24 +1090,15 @@ static irqreturn_t rspi_irq_tx(int irq, void *_sr)static struct dma_chan *rspi_request_dma_chan (struct device *dev,enum dma_transfer_direction dir, -unsigned int id,dma_addr_t port_addr) { -dma_cap_mask_t mask;struct dma_chan *chan;struct dma_slave_config cfg;int ret; -dma_cap_zero (mask); -dma_cap_set (DMA_SLAVE , mask); - - chan =dma_request_slave_channel_compat (mask, shdma_chan_filter, - (void *)(unsigned long )id, dev, - dir ==DMA_MEM_TO_DEV ?"tx" :"rx" ); -if (!chan) { -dev_warn (dev,"dma_request_slave_channel_compat failed\n" ); -return NULL ; - } + chan =dma_request_chan (dev, dir ==DMA_MEM_TO_DEV ?"tx" :"rx" ); +if (IS_ERR (chan)) +return chan;memset (&cfg,0 ,sizeof (cfg)); cfg.dst_addr = port_addr +RSPI_SPDR ;
@@ -1121,7 +1111,7 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,if (ret) {dev_warn (dev,"dmaengine_slave_config failed %d\n" , ret);dma_release_channel (chan); -return NULL ; +return ERR_PTR (ret); }return chan;
@@ -1130,29 +1120,23 @@ static struct dma_chan *rspi_request_dma_chan(struct device *dev,static int rspi_request_dma (struct device *dev,struct spi_controller *ctlr,const struct resource *res) { -unsigned int dma_tx_id, dma_rx_id; +struct dma_chan *chan; -if (dev->of_node) { -/* In the OF case we will get the slave IDs from the DT */ - dma_tx_id =0 ; - dma_rx_id =0 ; - }else { -/* The driver assumes no error. */ +if (!dev->of_node)return 0 ; - } - ctlr->dma_tx =rspi_request_dma_chan (dev,DMA_MEM_TO_DEV , dma_tx_id, - res->start); -if (!ctlr->dma_tx) -return -ENODEV ; + chan =rspi_request_dma_chan (dev,DMA_MEM_TO_DEV , res->start); +if (IS_ERR (chan)) +return PTR_ERR (chan); + ctlr->dma_tx = chan; - ctlr->dma_rx =rspi_request_dma_chan (dev,DMA_DEV_TO_MEM , dma_rx_id, - res->start); -if (!ctlr->dma_rx) { + chan =rspi_request_dma_chan (dev,DMA_DEV_TO_MEM , res->start); +if (IS_ERR (chan)) {dma_release_channel (ctlr->dma_tx); ctlr->dma_tx =NULL ; -return -ENODEV ; +return PTR_ERR (chan); } + ctlr->dma_rx = chan; ctlr->can_dma = rspi_can_dma;dev_info (dev,"DMA available" );
@@ -1377,6 +1361,11 @@ static int rspi_probe(struct platform_device *pdev) } ret =rspi_request_dma (&pdev->dev, ctlr, res); +if (ret == -EPROBE_DEFER ) { +dev_err_probe (&pdev->dev, ret, +"failed to request DMA channels\n" ); + goto error2; + }if (ret <0 )dev_warn (&pdev->dev,"DMA not available, using PIO\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1391/1848 soc: ti: k3-ringacc: Correct ring API kernel-doc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 45ea6911ad16859d4ce4f25780b0ebcf5660e43a ]
The ring accelerator header labels k3_ring_cfg as an enum, uses propname instead of property, and gives the DMA reset helper the ordinary reset helper's name. The DMA reset comment also omits occ, including the convention that zero requests a hardware occupancy read.
The proxy flag is parsed as a separate parameter, and the pop helpers describe pushing elements. Proxy access is supported in Message mode; the listed Credentials and Queue modes are not implemented. The phandle lookup returns encoded error pointers rather than integer error values.
Match the declarations and document these argument and operation roles.
--- include/linux/soc/ti/k3-ringacc.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-)
include/linux/soc/ti/k3-ringacc.h +12 -14
@@ -57,13 +57,13 @@ struct k3_ringacc;struct k3_ring ;/** -* enum k3_ring_cfg - RA ring configuration structure +* struct k3_ring_cfg - RA ring configuration structure * * @size: Ring size, number of elements * @elm_size: Ring element size * @mode: Ring operational mode * @flags: Ring configuration flags. Possible values: -* @K3_RINGACC_RING_SHARED: when set allows to request the same ring +* %K3_RINGACC_RING_SHARED: when set allows to request the same ring * few times. It's usable when the same ring is used as Free Host PD ring * for different flows, for example. * Note: Locking should be done by consumer if required
@@ -81,11 +81,10 @@ struct k3_ring_cfg {/** * of_k3_ringacc_get_by_phandle - find a RA by phandle property * @np: device node -* @propname: property name containing phandle on RA node +* @property: property name containing phandle on RA node * -* Returns pointer on the RA - struct k3_ringacc -* or -ENODEV if not found, -* or -EPROBE_DEFER if not yet registered +* Return: Pointer to the RA, or ERR_PTR(-ENODEV) if the phandle cannot +* be resolved, or ERR_PTR(-EPROBE_DEFER) if the RA is not yet registered. */ struct k3_ringacc *of_k3_ringacc_get_by_phandle (struct device_node *np,const char *property);
@@ -96,10 +95,8 @@ struct k3_ringacc *of_k3_ringacc_get_by_phandle(struct device_node *np,* k3_ringacc_request_ring - request ring from ringacc * @ringacc: pointer on ringacc * @id: ring id or K3_RINGACC_RING_ID_ANY for any general purpose ring -* @flags: -* @K3_RINGACC_RING_USE_PROXY: if set - proxy will be allocated and -* used to access ring memory. Sopported only for rings in -* Message/Credentials/Queue mode. +* @flags: Set %K3_RINGACC_RING_USE_PROXY to allocate a proxy for +* accessing ring memory in Message mode. * * Returns pointer on the Ring - struct k3_ring * or NULL in case of failure.
@@ -119,8 +116,9 @@ int k3_ringacc_request_rings_pair(struct k3_ringacc *ringacc,*/ void k3_ringacc_ring_reset (struct k3_ring *ring);/** -* k3_ringacc_ring_reset - ring reset for DMA rings +* k3_ringacc_ring_reset_dma - ring reset for DMA rings * @ring: pointer on Ring +* @occ: occupancy used by the DMA reset quirk, or zero to read it from hardware * * Resets ring internal state ((hw)occ, (hw)idx). Should be used for rings * which are read by K3 UDMA, like TX or Free Host PD rings.
@@ -210,8 +208,8 @@ int k3_ringacc_ring_push(struct k3_ring *ring, void *elem);* @ring: pointer on ring * @elem: pointer on ring element buffer * -* Push one ring element from the ring head. Size of the ring element is -* determined by ring configuration &struct k3_ring_cfg elm_size.. +* Pop one ring element from the ring head. Size of the ring element is +* determined by ring configuration &struct k3_ring_cfg elm_size. * * Returns 0 on success, errno otherwise. */
@@ -235,7 +233,7 @@ int k3_ringacc_ring_push_head(struct k3_ring *ring, void *elem);* @ring: pointer on ring * @elem: pointer on ring element buffer * -* Push one ring element from the ring tail. Size of the ring element is +* Pop one ring element from the ring tail. Size of the ring element is * determined by ring configuration &struct k3_ring_cfg elm_size. * * Returns 0 on success, errno otherwise.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1392/1848 RDMA/mlx5: Restore mr->pi_mr after temporary stack-local assignment
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 9728effe43d8fc4d58e12b697d0d6127355abdd5 ]
In handle_reg_mr_integrity, when mr->pi_mr is NULL (physical-address optimization path), the code points mr->pi_mr at a stack-local pa_pi_mr so set_pi_umr_wr can read it during this call. The pointer is never restored, so after the function returns mr->pi_mr dangles at a freed stack frame. A second IB_WR_REG_MR_INTEGRITY posted on the same MR without remapping reads the stale pointer and dereferences it.
Save the original pi_mr (captured at function entry) and restore it on the out path.
--- drivers/infiniband/hw/mlx5/wr.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/wr.c +1 -0
@@ -1146,6 +1146,7 @@ static int handle_reg_mr_integrity(struct mlx5_ib_dev *dev, qp->next_fence =MLX5_FENCE_MODE_INITIATOR_SMALL ; out: + mr->pi_mr = pi_mr;return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1393/1848 IB/isert: Dont share drop_cmd_list across concurrent connection teardowns
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit d30e9b1bc47bd9be4b2fc97b0e4074bc02c4203a ]
isert_put_unsol_pending_cmds() declares drop_cmd_list as a static LIST_HEAD, so the list is shared across all invocations of the function. It is called from isert_wait_conn(), the per-connection .iscsit_wait_conn transport callback, which runs independently for each connection during teardown.
conn->cmd_lock only protects each connection's own conn_cmd_list, not the shared drop_cmd_list. If two connections tear down at the same time, both threads list_move_tail() commands into the same drop_cmd_list without any mutual exclusion, and then both iterate and list_del/put it concurrently. This corrupts the linked list and can double-free iscsit_cmd structures.
Make drop_cmd_list a stack-local list, matching the pattern already used in isert_free_np().
--- drivers/infiniband/ulp/isert/ib_isert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/isert/ib_isert.c +1 -1
@@ -2579,7 +2579,7 @@ static void isert_put_unsol_pending_cmds(struct iscsi_conn *conn) {struct iscsit_cmd *cmd, *tmp; -static LIST_HEAD (drop_cmd_list); +LIST_HEAD (drop_cmd_list);spin_lock_bh (&conn->cmd_lock);list_for_each_entry_safe (cmd, tmp, &conn->conn_cmd_list, i_conn_node) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1394/1848 PCI/IOV: Read VF config values that need not match PF
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Odell <[email protected]>
[ Upstream commit ae43799529c480510dcc14bd0ed141a1d85b9259 ]
Per PCIe r7.0, sec 7.5.1.1.5 and 7.5.1.2.3, VF Revision IDs and Subsystem IDs may differ from the PF's. Read these values from VF config space instead of using cached values from VF 0.
Per 7.5.1.1.6 and 7.5.1.2.3, VF Class Codes and Subsystem Vendor IDs must be the same as the PF's. Use the PF's value instead of reading from VF config space.
Per 7.5.1.1.9, the Header Type for a VF must be 0, so hardcode that assignment.
--- drivers/pci/iov.c | 25 ------------------------- drivers/pci/pci.h | 4 ---- drivers/pci/probe.c | 15 ++++++++++----- 3 files changed, 10 insertions(+), 34 deletions(-)
drivers/pci/iov.c +0 -25
@@ -110,29 +110,6 @@ resource_size_t pci_iov_resource_size(struct pci_dev *dev, int resno)return dev->sriov->barsz[resno -PCI_IOV_RESOURCES ]; } -static void pci_read_vf_config_common (struct pci_dev *virtfn) -{ -struct pci_dev *physfn = virtfn->physfn; - -/* -* Some config registers are the same across all associated VFs. -* Read them once from VF0 so we can skip reading them from the -* other VFs. -* -* PCIe r4.0, sec 9.3.4.1, technically doesn't require all VFs to -* have the same Revision ID and Subsystem ID, but we assume they -* do. -*/ -pci_read_config_dword (virtfn,PCI_CLASS_REVISION , - &physfn->sriov->class); -pci_read_config_byte (virtfn,PCI_HEADER_TYPE , - &physfn->sriov->hdr_type); -pci_read_config_word (virtfn,PCI_SUBSYSTEM_VENDOR_ID , - &physfn->sriov->subsystem_vendor); -pci_read_config_word (virtfn,PCI_SUBSYSTEM_ID , - &physfn->sriov->subsystem_device); -} -int pci_iov_sysfs_link (struct pci_dev *dev,struct pci_dev *virtfn,int id) {
@@ -182,8 +159,6 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) virtfn->physfn =pci_dev_get (dev); virtfn->no_command_memory =1 ; -if (id ==0 ) -pci_read_vf_config_common (virtfn); rc =pci_setup_device (virtfn);if (rc)
drivers/pci/pci.h +0 -4
@@ -355,10 +355,6 @@ struct pci_sriov {u16 driver_max_VFs;/* Max num VFs driver supports */ struct pci_dev *dev;/* Lowest numbered PF */ struct pci_dev *self;/* This PF */ -u32 class;/* VF device */ -u8 hdr_type;/* VF header type */ -u16 subsystem_vendor;/* VF subsystem vendor */ -u16 subsystem_device;/* VF subsystem device */ resource_size_t barsz[PCI_SRIOV_NUM_BARS ];/* VF BAR size */ bool drivers_autoprobe;/* Auto probing of VFs by driver */ };
drivers/pci/probe.c +10 -5
@@ -1724,8 +1724,13 @@ static u32 pci_class(struct pci_dev *dev)u32 class;#ifdef CONFIG_PCI_IOV -if (dev->is_virtfn) -return dev->physfn->sriov->class; +if (dev->is_virtfn) { +u8 rev; + +if (pci_read_config_byte (dev,PCI_REVISION_ID , &rev)) + rev =0 ; +return (dev->physfn->class <<8 ) | rev; + }#endif pci_read_config_dword (dev,PCI_CLASS_REVISION , &class);return class;
@@ -1735,8 +1740,8 @@ static void pci_subsystem_ids(struct pci_dev *dev, u16 *vendor, u16 *device) {#ifdef CONFIG_PCI_IOV if (dev->is_virtfn) { - *vendor = dev->physfn->sriov->subsystem_vendor; - *device = dev->physfn->sriov->subsystem_device; + *vendor = dev->physfn->subsystem_vendor; +pci_read_config_word (dev,PCI_SUBSYSTEM_ID , device);return ; }#endif
@@ -1750,7 +1755,7 @@ static u8 pci_hdr_type(struct pci_dev *dev)#ifdef CONFIG_PCI_IOV if (dev->is_virtfn) -return dev->physfn->sriov->hdr_type; +return 0 ;#endif pci_read_config_byte (dev,PCI_HEADER_TYPE , &hdr_type);return hdr_type;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1395/1848 swim: Fix FDEJECT ioctl for exclusive open
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit c76b93df9ae61d8ddebf6aa3bc218252f85e80c6 ]
The eject command from the util-linux package does not work with the swim
driver: the drive doesn't eject anything and the command fails. Apparently, ioctl(fd, FDEJECT) returns -EBUSY when fd is opened O_EXCL. Fix this by checking ref_count for either 1 or -1. Either value means that the caller is the sole user of the disk.
--- drivers/block/swim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/block/swim.c +4 -3
@@ -711,10 +711,11 @@ static int floppy_ioctl(struct block_device *bdev, fmode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) -return -EBUSY ;mutex_lock (&swim_mutex); - err =floppy_eject (fs); +if (fs->ref_count ==-1 || fs->ref_count ==1 ) + err =floppy_eject (fs); +else + err = -EBUSY ;mutex_unlock (&swim_mutex);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1396/1848 swim3: Fix FDEJECT ioctl for exclusive open
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Finn Thain <[email protected]>
[ Upstream commit ce054fbe9a4bf4ffefef0f8e2504ea54da058ed2 ]
The eject command from the util-linux package does not work with the swim3 driver: the drive doesn't eject anything and the command fails. Apparently, ioctl(fd, FDEJECT) returns -EBUSY after fd was opened O_EXCL. Fix this by checking ref_count for either 1 or -1. Either value means that the caller is the sole user of the disk.
--- drivers/block/swim3.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/block/swim3.c +3 -5
@@ -869,7 +869,6 @@ static int floppy_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) {struct floppy_state *fs = bdev->bd_disk->private_data; -int err;if ((cmd &0x80 ) && !capable (CAP_SYS_ADMIN ))return -EPERM ;
@@ -880,10 +879,9 @@ static int floppy_locked_ioctl(struct block_device *bdev, fmode_t mode,switch (cmd) {case FDEJECT : -if (fs->ref_count !=1 ) -return -EBUSY ; - err =fd_eject (fs); -return err; +if (fs->ref_count ==-1 || fs->ref_count ==1 ) +return fd_eject (fs); +return -EBUSY ;case FDGETPRM :if (copy_to_user ((void __user *) param, &floppy_type,sizeof (struct floppy_struct )))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1397/1848 RDMA/bnxt_re: Fix integer overflow in send payload size computation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 3483cbbd7487163345b4b4d5eb8cad8540d1c3ba ]
bnxt_re_build_sgl() summed SGE lengths into a signed int, which could overflow. Make it return u32, and have bnxt_re_copy_wr_payload() report the size via a u32 out-parameter with the return value carrying only the error status, instead of overloading a signed int with both.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 44 +++++++++++++----------- 1 file changed, 24 insertions(+), 20 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +24 -20
@@ -104,10 +104,11 @@ static enum ib_access_flags __to_ib_access_flags(int qflags)return iflags; }; -static int bnxt_re_build_sgl (struct ib_sge *ib_sg_list, +static u32 bnxt_re_build_sgl (struct ib_sge *ib_sg_list,struct bnxt_qplib_sge *sg_list,int num) { -int i, total =0 ; +u32 total =0 ; +int i;for (i =0 ; i < num; i++) { sg_list[i].addr = ib_sg_list[i].addr;
@@ -2531,17 +2532,22 @@ static int bnxt_re_copy_inline_data(struct bnxt_re_dev *rdev,static int bnxt_re_copy_wr_payload (struct bnxt_re_dev *rdev,const struct ib_send_wr *wr, -struct bnxt_qplib_swqe *wqe) +struct bnxt_qplib_swqe *wqe, +u32 *payload_sz) { -int payload_sz =0 ; +int rc; -if (wr->send_flags &IB_SEND_INLINE ) - payload_sz =bnxt_re_copy_inline_data (rdev, wr, wqe); -else - payload_sz =bnxt_re_build_sgl (wr->sg_list, wqe->sg_list, - wqe->num_sge); +if (wr->send_flags &IB_SEND_INLINE ) { + rc =bnxt_re_copy_inline_data (rdev, wr, wqe); +if (rc <0 ) +return rc; + *payload_sz = rc; + }else { + *payload_sz =bnxt_re_build_sgl (wr->sg_list, wqe->sg_list, + wqe->num_sge); + } -return payload_sz; +return 0 ; }static void bnxt_ud_qp_hw_stall_workaround (struct bnxt_re_qp *qp)
@@ -2564,7 +2570,8 @@ static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev,struct bnxt_re_qp *qp, const struct ib_send_wr *wr) { - int rc = 0, payload_sz = 0; + int rc = 0; +u32 payload_sz =0 ;unsigned long flags;spin_lock_irqsave (&qp->sq_lock, flags);
@@ -2580,11 +2587,9 @@ static int bnxt_re_post_send_shadow_qp(struct bnxt_re_dev *rdev, goto bad; } - payload_sz =bnxt_re_copy_wr_payload (qp->rdev, wr, &wqe); -if (payload_sz <0 ) { - rc = -EINVAL ; + rc =bnxt_re_copy_wr_payload (qp->rdev, wr, &wqe, &payload_sz); +if (rc) goto bad; - } wqe.wr_id = wr->wr_id; wqe.type =BNXT_QPLIB_SWQE_TYPE_SEND ;
@@ -2612,7 +2617,8 @@ int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr, { struct bnxt_re_qp *qp = container_of(ib_qp, struct bnxt_re_qp, ib_qp);struct bnxt_qplib_swqe wqe; -int rc =0 , payload_sz =0 ; +int rc =0 ; +u32 payload_sz =0 ;unsigned long flags;spin_lock_irqsave (&qp->sq_lock, flags);
@@ -2629,11 +2635,9 @@ int bnxt_re_post_send(struct ib_qp *ib_qp, const struct ib_send_wr *wr, goto bad; } - payload_sz =bnxt_re_copy_wr_payload (qp->rdev, wr, &wqe); -if (payload_sz <0 ) { - rc = -EINVAL ; + rc =bnxt_re_copy_wr_payload (qp->rdev, wr, &wqe, &payload_sz); +if (rc) goto bad; - } wqe.wr_id = wr->wr_id;switch (wr->opcode) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1398/1848 RDMA/bnxt_re: Detect wrong sge_len passed for inline
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 81551ece0864c346080d241719d458c93f0e7fc9 ]
Avoid handling wrong sge_len by adding extra check to see if the passed length is more than the inline size supported.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +3 -2
@@ -2515,8 +2515,9 @@ static int bnxt_re_copy_inline_data(struct bnxt_re_dev *rdev, wr->sg_list[i].addr; sge_len = wr->sg_list[i].length; -if ((sge_len + wqe->inline_len) > -BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH ) { +if (sge_len >BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH || + ((sge_len + wqe->inline_len) > +BNXT_QPLIB_SWQE_MAX_INLINE_LENGTH )) {ibdev_err (&rdev->ibdev,"Inline data size requested > supported value" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1399/1848 RDMA/bnxt_re: Initialize wqe.flags in bnxt_re_post_srq_recv()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit 4d8168a3b7c93385c11dc836df569d337089b218 ]
wqe is declared once above the WR loop and never zeroed, so wqe.flags holds indeterminate stack contents on the first WR and the previous WR's stale value thereafter. This propagates straight into the hardware-visible srqe->flags in bnxt_qplib_post_srq_recv().
Most values of the wqe struct is set except flags. So initialize flags also.
--- drivers/infiniband/hw/bnxt_re/ib_verbs.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/bnxt_re/ib_verbs.c +1 -0
@@ -1769,6 +1769,7 @@ int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,spin_lock_irqsave (&srq->lock, flags);while (wr) {/* Transcribe each ib_recv_wr to qplib_swqe */ + wqe.flags =0 ; wqe.num_sge = wr->num_sge;bnxt_re_build_sgl (wr->sg_list, wqe.sg_list, wr->num_sge); wqe.wr_id = wr->wr_id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1400/1848 RDMA/bnxt_re: Fix the PD and DPI table size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Selvin Xavier <[email protected]>
[ Upstream commit aa6c2ef821a6ba7f3fd58cfcc031b2d16f3811c6 ]
The PD and DPI bitmaps were sized as max >> 3 (bytes), but bitmap ops (set_bit(), clear_bit(), find_first_bit(), test_and_set_bit()) operate on whole unsigned long words, so whenever max isn't a multiple of BITS_PER_LONG,
the buffer under-allocates and the top word's bitops read/write past the end of the kmalloc()'d buffer. Most exposed on the DPI table, since dpit->max comes from the firmware-reported dev_attr->max_dpi with no alignment guarantee.
Fix the size of both allocations withBITS_TO_LONGS(max) * sizeof(unsigned long).
--- drivers/infiniband/hw/bnxt_re/qplib_res.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/infiniband/hw/bnxt_re/qplib_res.c +5 -4
@@ -45,6 +45,7 @@#include <linux/dma-mapping.h> #include <linux/if_vlan.h> #include <linux/vmalloc.h> +#include <linux/bitops.h> #include <rdma/ib_verbs.h> #include <rdma/iter.h>
@@ -712,9 +713,9 @@ static int bnxt_qplib_alloc_pd_tbl(struct bnxt_qplib_res *res, {u32 bytes; - bytes = max >>3 ; + bytes =BITS_TO_LONGS (max) *sizeof (unsigned long );if (!bytes) - bytes =1 ; + bytes =sizeof (unsigned long ); pdt->tbl =kmalloc (bytes,GFP_KERNEL );if (!pdt->tbl)return -ENOMEM ;
@@ -819,9 +820,9 @@ static int bnxt_qplib_alloc_dpi_tbl(struct bnxt_qplib_res *res,if (!dpit->app_tbl) goto unmap_io; - bytes = dpit->max >>3 ; + bytes =BITS_TO_LONGS (dpit->max) *sizeof (unsigned long );if (!bytes) - bytes =1 ; + bytes =sizeof (unsigned long ); dpit->tbl =kmalloc (bytes,GFP_KERNEL );if (!dpit->tbl) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1401/1848 media: venus: Drop session events without an instance
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 8921f6da06fd869b6f1aa8d02e40a4e2e2a45fe4 ]
hfi_process_msg_packet() intentionally allows HFI_MSG_EVENT_NOTIFY packets without a matching session instance because HFI_EVENT_SYS_ERROR is a system event and has no session attached.
That exception currently applies to every event-notify packet. If the firmware reports a late or otherwise invalid session event after to_instance() fails, hfi_event_notify() can dispatch it to session-only handlers such as event_seq_changed() or event_release_buffer_ref(), which dereference inst.
Only system errors are valid without a session instance. Drop other event notifications before the session event handlers can dereference a NULL inst.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/media/platform/qcom/venus/hfi_msgs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/media/platform/qcom/venus/hfi_msgs.c +3 -0
@@ -185,6 +185,9 @@ static void hfi_event_notify(struct venus_core *core, struct venus_inst *inst,if (!packet)return ; +if (!inst && pkt->event_id !=HFI_EVENT_SYS_ERROR ) +return ; +switch (pkt->event_id) {case HFI_EVENT_SYS_ERROR :event_sys_error (core,EVT_SYS_ERROR , pkt);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1402/1848 IB/mad: fix UAF and double-free in RMPP receive reassembly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dairui Zhang <[email protected]>
[ Upstream commit 90e9b6357bec75f627cde1a85b5887215c80aad8 ]
mad_rmpp_recv.state is protected by two locks that do not exclude each other: recv_timeout_handler() (port workqueue) uses agent->lock, continue_rmpp() (CQ softirq) uses rmpp_recv->lock. Nothing serializes the check-then-set sequence on the state word:
T1 (CQ softirq) T2 (port workqueue)
continue_rmpp()
lock(rmpp_recv->lock)
state == ACTIVE [passes]
recv_timeout_handler()
lock(agent->lock)
state = TIMEOUT
list_del(&rmpp_recv->list)
unlock(agent->lock)
destroy_rmpp_recv()
wait_for_completion()
[blocks on T1's ref]
state = COMPLETE
unlock(rmpp_recv->lock)
complete_rmpp()
queue cleanup_work (+10s)
deref()
[unblocks]
kfree(rmpp_recv)
ib_free_recv_mad(done_wc) +10s: recv_cleanup_handler() runs lock/list_del/destroy on the
freed rmpp_recv -> UAF write and double free; nothing can
cancel that cleanup_work anymore, the entry is already off
agent->rmpp_list. done_wc is also returned to
ib_mad_complete_recv() and freed again -> UAF read and
double free.Reaching this requires sending MADs to a kernel RMPP agent from the InfiniBand/RoCE fabric: the per-port sa_query agent accepts subnet manager responses whose SLID/GID/TID are not authenticated on the fabric, and legacy user_mad agents registered without IB_USER_MAD_USER_RMPP start reassembly on any incoming RMPP DATA MAD with an attacker-chosen TID, no in-flight send required. The attacker controls segment timing and can run many transactions in parallel (agent->rmpp_list has no cap), so landing the microseconds-wide receive critical section on the 40-second timeout boundary is a matter of patience, not luck.
Unify state transitions under rmpp_recv->lock in recv_timeout_handler(), keeping list manipulation under agent->lock (which preserves the agent->lock -> rmpp_recv->lock ordering used by continue_rmpp()). State check/set in both paths is then serialized, so the loser of the race always observes the final state and bails out. recv_cleanup_handler() needs no change: with transitions serialized, a cleanup_work can only be pending after COMPLETE, in which case the timeout handler exits early.
The race is as old as the RMPP implementation itself.
--- drivers/infiniband/core/mad_rmpp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/infiniband/core/mad_rmpp.c +5 -2
@@ -245,12 +245,15 @@ static void recv_timeout_handler(struct work_struct *work)struct ib_mad_recv_wc *rmpp_wc;unsigned long flags; -spin_lock_irqsave (&rmpp_recv->agent->lock, flags); +spin_lock_irqsave (&rmpp_recv->lock, flags);if (rmpp_recv->state !=RMPP_STATE_ACTIVE ) { -spin_unlock_irqrestore (&rmpp_recv->agent->lock, flags); +spin_unlock_irqrestore (&rmpp_recv->lock, flags);return ; } rmpp_recv->state =RMPP_STATE_TIMEOUT ; +spin_unlock_irqrestore (&rmpp_recv->lock, flags); + +spin_lock_irqsave (&rmpp_recv->agent->lock, flags);list_del (&rmpp_recv->list);spin_unlock_irqrestore (&rmpp_recv->agent->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1403/1848 clk: ti: adpll: unregister OF clock provider on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 4c943ddfc24340f1b899762b1ff35c38306b7a35 ]
ti_adpll_probe() registers the driver's onecell clock provider with of_clk_add_provider(). The remove path only frees the clock resources, leaving the provider registered after the backing data has been torn down.
Unregister the OF clock provider before freeing the ADPLL resources so the provider no longer points at released driver data after device removal.
--- drivers/clk/ti/adpll.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/ti/adpll.c +1 -0
@@ -947,6 +947,7 @@ static int ti_adpll_remove(struct platform_device *pdev) {struct ti_adpll_data *d =dev_get_drvdata (&pdev->dev); +of_clk_del_provider (d->np);ti_adpll_free_resources (d);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1404/1848 RDMA/nldev: Fix NULL deref in dumps of objects abandoned by DRIVER_FAILURE
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yili Zhang <[email protected]>
[ Upstream commit 9f4c322be27bf617cad2f4a15f6c6024a69e220c ]
fill_res_cq_entry() dereferences cq->uobject->uevent.uobject.context->res.id unconditionally for user resources.
This is normally safe by ordering: destroy_hw() removes the resource from the restrack before uverbs_destroy_uobject() clears ->context, and the XA_ZERO_ENTRY marker set by rdma_restrack_begin_del() hides the entry from concurrent netlink dumps.
The ordering breaks when a driver keeps failing to destroy an object during ucontext teardown. uverbs_destroy_ufile_hw() then falls back to __uverbs_cleanup_ufile(RDMA_REMOVE_DRIVER_FAILURE), which abandons the object in place: the HW object and its restrack entry are intentionally leaked, while the uobject bookkeeping is torn down and ->context is explicitly set to NULL by uverbs_destroy_uobject(). rdma_restrack_del() is never reached, so the orphaned entry stays in the device restrack with a valid kref, reachable by any subsequent netlink dump.
Observed on 6.1.52 with MLNX_OFED 24.10, after an mlx5 FW failure left a process unable to tear down its CQ (destroy_cq FW command failing during FD close):
WARNING: ... uverbs_destroy_ufile_hw+0xe3/0x100
BUG: kernel NULL pointer dereference, address: 0000000000000058 RIP: 0010:fill_res_cq_entry+0x15e/0x180 [ib_core] res_get_common_dumpit+0x304/0x530 [ib_core] nldev_res_get_cq_dumpit+0x1a/0x20 [ib_core]
The faulting chain maps to the source (CR2 = 0x58):
cq->uobject (struct ib_cq +0x08, res at +0x98) uobject->context (struct ib_uobject +0x10, NULL after abandon) context->res.id (struct ib_ucontext +0x58)
The recent restrack rework (8d186210677c and its series) moved the restrack deletion to the start of the destroy flow and thus fences concurrent dumps from an object being destroyed, but it does not cover this case: when destroy fails, rdma_restrack_abort_del() restores the entry, and the RDMA_REMOVE_DRIVER_FAILURE sweep still never removes it from the restrack.
Quoted 1 line
From the fallback until the device is unregistered, any "rdma res
show cq" deterministically takes the NULL pointer dereference; this is a long-lived state, NOT A RACE. The dump path holds neither the restrack lock (dropped before the fill callback runs) nor ufile->hw_destroy_rwsem, and rdma_restrack_get() only guarantees that the res memory stays alive, not that ->context is still valid.
Fix the dump side: check the uobject context directly instead of the rdma_is_kernel_res() marker. A non-NULL uobject already implies a user resource, so kernel resources keep being skipped, and the additional ->context check skips the RES_CTXN attribute for orphaned entries instead of crashing the dump. The orphaned resource itself remains visible in "rdma res show" (cqn/cqe/usecnt/pid), which is what an operator needs after the accompanying uverbs WARN to diagnose the driver destroy failure.
fill_res_pd_entry() has the same pattern (pd->uobject->context->res.id) and is fixed the same way; a PD can even reach the fallback without its own driver callback failing, e.g. uverbs_free_pd() returns -EBUSY while another object that failed to destroy still holds the PD usecnt.
--- drivers/infiniband/core/nldev.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/nldev.c +3 -2
@@ -606,7 +606,8 @@ static int fill_res_cq_entry(struct sk_buff *msg, bool has_cap_net_admin,if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_CQN , res->id))return -EMSGSIZE ; -if (!rdma_is_kernel_res (res) && + +if (cq->uobject && cq->uobject->uevent.uobject.context &&nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_CTXN , cq->uobject->uevent.uobject.context->res.id))return -EMSGSIZE ;
@@ -693,7 +694,7 @@ static int fill_res_pd_entry(struct sk_buff *msg, bool has_cap_net_admin,if (nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_PDN , res->id)) goto err; -if (!rdma_is_kernel_res (res) && +if (pd->uobject && pd->uobject->context &&nla_put_u32 (msg,RDMA_NLDEV_ATTR_RES_CTXN , pd->uobject->context->res.id)) goto err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1405/1848 RDMA/rtrs-clt: Reject invalid queue_depth from the peer
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quanye Yang <[email protected]>
[ Upstream commit 724cd362162ca7ca5a250bec65efd74f7dad9f5c ]
queue_depth is taken from the server's CM private_data and later used as a session invariant. A peer can send 0, which the client stores and then trips WARN_ON() in create_con_cq_qp() when the next connection is set up.
Reject a zero queue_depth on ESTABLISHED, same as a bad magic or version, and fail the handshake with -ECONNRESET.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +4 -0
@@ -1727,6 +1727,10 @@ static int rtrs_rdma_conn_established(struct rtrs_clt_con *con, }if (con->c.cid ==0 ) { queue_depth =le16_to_cpu (msg->queue_depth); +if (!queue_depth) { +rtrs_err (clt,"Invalid queue depth %u\n" , queue_depth); +return -ECONNRESET ; + }if (sess->queue_depth >0 && queue_depth != sess->queue_depth) {rtrs_err (clt,"Error: queue depth changed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1406/1848 RDMA/mad: Reject receive completions shorter than GRH
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 2dc2126e690203d6adbddc7675927a242d810e43 ]
ib_mad_recv_done() derives the OPA MAD length by subtracting the GRH size from wc->byte_len without ensuring the receive completion covers the GRH. If it is shorter, the subtraction wraps before the result is stored in mad_len and an invalid length can be passed downstream.
Reject receive completions shorter than the GRH before inspecting the MAD header or deriving the MAD length.
--- drivers/infiniband/core/mad.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/core/mad.c +2 -0
@@ -2090,6 +2090,8 @@ static void ib_mad_recv_done(struct ib_cq *cq, struct ib_wc *wc) recv->header.mapping,mad_priv_dma_size (recv), DMA_FROM_DEVICE); +if (unlikely (wc->byte_len <sizeof (struct ib_grh ))) + goto out;/* Setup MAD receive work completion from "normal" work completion */ recv->header.wc = *wc;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1407/1848 timekeeping: add CONFIG_LEGACY_TIMER_TICK
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit b3550164a19d62e515af6cacb5a31f0b2b3f9501 ]
All platforms that currently do not use generic clockevents roughly call the same set of functions in their timer interrupts: xtime_update(), update_process_times() and profile_tick(), sometimes in a different sequence.
Add a helper function that performs all three of them, to make the callers more uniform and simplify the interface.
Stable-dep-of: 2927f7ca7844 ("time: Prevent time64_to_tm() day truncation on 32-bit")
--- include/linux/timekeeping.h | 1 + kernel/time/Kconfig | 7 +++++++ kernel/time/Makefile | 1 + kernel/time/tick-legacy.c | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 kernel/time/tick-legacy.c
include/linux/timekeeping.h +1 -0
@@ -12,6 +12,7 @@ extern int timekeeping_suspended;/* Architecture timer tick functions: */ extern void update_process_times (int user);extern void xtime_update (unsigned long ticks); +extern void legacy_timer_tick (unsigned long ticks);/* * Get and set timeofday
kernel/time/Kconfig +7 -0
@@ -61,6 +61,13 @@ config POSIX_CPU_TIMERS_TASK_WORK bool default y if POSIX_TIMERS && HAVE_POSIX_CPU_TIMERS_TASK_WORK +config LEGACY_TIMER_TICK + bool + help + The legacy timer tick helper is used by platforms that + lack support for the generic clockevent framework. + New platforms should use generic clockevents instead. + if GENERIC_CLOCKEVENTS menu "Timers subsystem"
kernel/time/Makefile +1 -0
@@ -16,6 +16,7 @@ ifeq ($(CONFIG_GENERIC_CLOCKEVENTS_BROADCAST),y) endif obj-$(CONFIG_GENERIC_SCHED_CLOCK) += sched_clock.o obj-$(CONFIG_TICK_ONESHOT) += tick-oneshot.o tick-sched.o +obj-$(CONFIG_LEGACY_TIMER_TICK) += tick-legacy.o obj-$(CONFIG_HAVE_GENERIC_VDSO) += vsyscall.o obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o
kernel/time/tick-legacy.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Timer tick function for architectures that lack generic clockevents, +* consolidated here from m68k/ia64/parisc/arm. +*/ + +#include <linux/irq.h> +#include <linux/profile.h> +#include <linux/timekeeper_internal.h> + +#include "tick-internal.h" + +void legacy_timer_tick (unsigned long ticks) +{ +if (ticks) +xtime_update (ticks); +update_process_times (user_mode (get_irq_regs ())); +profile_tick (CPU_PROFILING ); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1408/1848 clocksource: Provide kernel module to test clocksource watchdog
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul E. McKenney <[email protected]>
[ Upstream commit 1253b9b87e42ab6a3d5c2cb27af2bdd67d7e50ff ]
When the clocksource watchdog marks a clock as unstable, this might be due to that clock being unstable or it might be due to delays that happen to occur between the reads of the two clocks. It would be good to have a way of testing the clocksource watchdog's ability to distinguish between these two causes of clock skew and instability.
Therefore, provide a new clocksource-wdtest module selected by a new TEST_CLOCKSOURCE_WATCHDOG Kconfig option. This module has a single module parameter named "holdoff" that provides the number of seconds of delay before testing should start, which defaults to zero when built as a module and to 10 seconds when built directly into the kernel. Very large systems that boot slowly may need to increase the value of this module parameter.
This module uses hand-crafted clocksource structures to do its testing, thus avoiding messing up timing for the rest of the kernel and for user applications. This module first verifies that the ->uncertainty_margin field of the clocksource structures are set sanely. It then tests the delay-detection capability of the clocksource watchdog, increasing the number of consecutive delays injected, first provoking console messages complaining about the delays and finally forcing a clock-skew event. Unexpected test results cause at least one WARN_ON_ONCE() console splat. If there are no splats, the test has passed. Finally, it fuzzes the value returned from a clocksource to test the clocksource watchdog's ability to detect time skew.
This module checks the state of its clocksource after each test, and uses WARN_ON_ONCE() to emit a console splat if there are any failures. This should enable all types of test frameworks to detect any such failures.
This facility is intended for diagnostic use only, and should be avoided on production systems.
Stable-dep-of: 2927f7ca7844 ("time: Prevent time64_to_tm() day truncation on 32-bit")
--- .../admin-guide/kernel-parameters.txt | 6 + include/linux/clocksource.h | 3 + kernel/time/Makefile | 1 + kernel/time/clocksource-wdtest.c | 202 ++++++++++++++++++ kernel/time/clocksource.c | 6 +- lib/Kconfig.debug | 12 ++ 6 files changed, 228 insertions(+), 2 deletions(-) create mode 100644 kernel/time/clocksource-wdtest.c
Documentation/admin-guide/kernel-parameters.txt +6 -0
@@ -593,6 +593,12 @@ The actual CPUs are chosen randomly, with no replacement if the same CPU is chosen twice. + clocksource-wdtest.holdoff= [KNL] + Set the time in seconds that the clocksource + watchdog test waits before commencing its tests. + Defaults to zero when built as a module and to + 10 seconds when built into the kernel. + clearcpuid=BITNUM[,BITNUM...] [X86] Disable CPUID feature X for the kernel. See arch/x86/include/asm/cpufeatures.h for the valid bit
include/linux/clocksource.h +3 -0
@@ -285,4 +285,7 @@ static inline void timer_probe(void) {}#define TIMER_ACPI_DECLARE (name, table_id, fn) \ ACPI_DECLARE_PROBE_ENTRY(timer, name, table_id, 0, NULL, 0, fn) +extern ulong max_cswd_read_retries; +void clocksource_verify_percpu (struct clocksource *cs); +#endif /* _LINUX_CLOCKSOURCE_H */
kernel/time/Makefile +1 -0
@@ -21,3 +21,4 @@ obj-$(CONFIG_HAVE_GENERIC_VDSO) += vsyscall.o obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o obj-$(CONFIG_TIME_NS) += namespace.o +obj-$(CONFIG_TEST_CLOCKSOURCE_WATCHDOG) += clocksource-wdtest.o
kernel/time/clocksource-wdtest.c new file +202 -0
202 lines not on this page · raw message
kernel/time/clocksource.c +4 -2
@@ -201,8 +201,9 @@ void clocksource_mark_unstable(struct clocksource *cs)spin_unlock_irqrestore (&watchdog_lock, flags); } -static ulong max_cswd_read_retries =3 ; +ulong max_cswd_read_retries =3 ;module_param (max_cswd_read_retries, ulong,0644 ); +EXPORT_SYMBOL_GPL (max_cswd_read_retries);static int verify_n_cpus =8 ;module_param (verify_n_cpus, int,0644 );
@@ -324,7 +325,7 @@ static void clocksource_verify_one_cpu(void *csin) csnow_mid = cs->read (cs); } -static void clocksource_verify_percpu (struct clocksource *cs) +void clocksource_verify_percpu (struct clocksource *cs) {int64_t cs_nsec, cs_nsec_max =0 , cs_nsec_min =LLONG_MAX ;u64 csnow_begin, csnow_end;
@@ -380,6 +381,7 @@ static void clocksource_verify_percpu(struct clocksource *cs)pr_warn (" CPU %d check durations %lldns - %lldns for clocksource %s.\n" , testcpu, cs_nsec_min, cs_nsec_max, cs->name); } +EXPORT_SYMBOL_GPL (clocksource_verify_percpu);static inline void clocksource_reset_watchdog (void ) {
lib/Kconfig.debug +12 -0
@@ -2471,6 +2471,18 @@ config TEST_FPU If unsure, say N. +config TEST_CLOCKSOURCE_WATCHDOG + tristate "Test clocksource watchdog in kernel space" + depends on CLOCKSOURCE_WATCHDOG + help + Enable this option to create a kernel module that will trigger + a test of the clocksource watchdog. This module may be loaded + via modprobe or insmod in which case it will run upon being + loaded, or it may be built in, in which case it will run + shortly after boot. + + If unsure, say N. + endif # RUNTIME_TESTING_MENU config MEMTEST
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1409/1848 time: Improve performance of time64_to_tm()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cassio Neri <[email protected]>
[ Upstream commit 276010551664f73b6f1616dde471d6f0d63a73ba ]
The current implementation of time64_to_tm() contains unnecessary loops, branches and look-up tables. The new one uses an arithmetic-based algorithm appeared in [1] and is approximately 3x faster (YMMV).
The drawback is that the new code isn't intuitive and contains many 'magic numbers' (not unusual for this type of algorithm). However, [1] justifies all those numbers and, given this function's history, the code is unlikely to need much maintenance, if any at all.
Add a KUnit test for it which checks every day in a 160,000 years interval centered at 1970-01-01 against the expected result.
[1] Neri, Schneider, "Euclidean Affine Functions and Applications to Calendar Algorithms". https://arxiv.org/abs/2102.06959
Stable-dep-of: 2927f7ca7844 ("time: Prevent time64_to_tm() day truncation on 32-bit")
--- kernel/time/Kconfig | 9 +++ kernel/time/Makefile | 1 + kernel/time/time_test.c | 98 ++++++++++++++++++++++++++++++ kernel/time/timeconv.c | 128 ++++++++++++++++++++++------------------ 4 files changed, 178 insertions(+), 58 deletions(-) create mode 100644 kernel/time/time_test.c
kernel/time/Kconfig +9 -0
@@ -68,6 +68,15 @@ config LEGACY_TIMER_TICK lack support for the generic clockevent framework. New platforms should use generic clockevents instead. +config TIME_KUNIT_TEST + tristate "KUnit test for kernel/time functions" if !KUNIT_ALL_TESTS + depends on KUNIT + default KUNIT_ALL_TESTS + help + Enable this option to test RTC library functions. + + If unsure, say N. + if GENERIC_CLOCKEVENTS menu "Timers subsystem"
kernel/time/Makefile +1 -0
@@ -22,3 +22,4 @@ obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o obj-$(CONFIG_TIME_NS) += namespace.o obj-$(CONFIG_TEST_CLOCKSOURCE_WATCHDOG) += clocksource-wdtest.o +obj-$(CONFIG_TIME_KUNIT_TEST) += time_test.o
kernel/time/time_test.c new file +98 -0
98 lines not on this page · raw message
kernel/time/timeconv.c +70 -58
153 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1410/1848 time: Prevent time64_to_tm() day truncation on 32-bit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 2927f7ca78448781e11a4623d347cd653c28adf6 ]
time64_to_tm() accepts a 64-bit seconds value, but stores the quotient in long. On a 32-bit kernel the day count therefore wraps when it reaches 2^31, even though the corresponding year remains representable in struct tm.
This is reachable when formatting externally supplied timestamps. For example, NILFS recovery copies the little-endian 64-bit ss_create field from an on-disk segment summary into time64_t. Its sysfs attributes then print that value with %ptTs, whose formatter calls time64_to_tm(). A corrupted image can consequently produce an architecture-dependent printed date.
Keep the day quotient in s64 while leaving the seconds-within-day remainder as long. Use div_s64_rem() for the weekday calculation so 32-bit builds do not require compiler runtime division helpers.
--- kernel/time/timeconv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/time/timeconv.c +4 -2
@@ -49,8 +49,9 @@ void time64_to_tm(time64_t totalsecs, int offset, struct tm *result)u32 u32tmp, day_of_century, year_of_century, day_of_year, month, day;u64 u64tmp, udays, century, year;bool is_Jan_or_Feb, is_leap_year; -long days, rem;int remainder; +long rem; +s64 days; days =div_s64_rem (totalsecs,SECS_PER_DAY , &remainder); rem = remainder;
@@ -70,7 +71,8 @@ void time64_to_tm(time64_t totalsecs, int offset, struct tm *result) result->tm_sec = rem %60 ;/* January 1, 1970 was a Thursday. */ - result->tm_wday = (4 + days) %7 ; +div_s64_rem (days +4 ,7 , &remainder); + result->tm_wday = remainder;if (result->tm_wday <0 ) result->tm_wday +=7 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1411/1848 selftests/timers: clocksource-switch: Fix unchecked open()/read()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingshuang Fu <[email protected]>
[ Upstream commit 348f54c435bf3177baa78201952810b255d44b30 ]
get_clocksources() and get_cur_clocksource() open and read the clocksource sysfs files without checking the return values and without NUL-terminating the buffer.
If open() fails, read() is called on fd -1 and returns -1, which is stored in a size_t as SIZE_MAX. The token-scanning loop in get_clocksources() then walks past the uninitialized stack buffer, reading and writing out of bounds. Even on success the buffer is not NUL-terminated, so a fully read buffer makes the inner scan run past the data, and get_cur_clocksource() lets change_clocksource() call strlen() on a non-terminated buffer.
Check the open()/read() results, use ssize_t for the read length, NUL-terminate the buffer, and close the fd in get_cur_clocksource().
--- .../selftests/timers/clocksource-switch.c | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-)
tools/testing/selftests/timers/clocksource-switch.c +20 -3
@@ -40,16 +40,23 @@int get_clocksources (char list[][30 ]) {int fd, i; -size_t size; +ssize_t size;char buf[512 ];char *head, *tmp; fd =open ("/sys/devices/system/clocksource/clocksource0/available_clocksource" ,O_RDONLY ); +if (fd <0 ) +return 0 ; - size =read (fd, buf,512 ); + size =read (fd, buf,sizeof (buf) -1 );close (fd); +if (size <=0 ) +return 0 ; + + buf[size] ='\0' ; +for (i =0 ; i <10 ; i++) list[i][0 ] ='\0' ;
@@ -74,11 +81,21 @@ int get_clocksources(char list[][30])int get_cur_clocksource (char *buf,size_t size) { +ssize_t len;int fd; fd =open ("/sys/devices/system/clocksource/clocksource0/current_clocksource" ,O_RDONLY ); +if (fd <0 ) +return -1 ; + + len =read (fd, buf, size -1 ); + +close (fd); + +if (len <=0 ) +return -1 ; - size =read (fd, buf, size); + buf[len] ='\0' ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1412/1848 RDMA/siw: Fix length of first chunk in siw_try_1seg()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Serhat Kumral <[email protected]>
[ Upstream commit aac27aa8c5cfe3c3c6029b9c0f1113e0a53329de ]
When a short-single SGE payload crosses a page boundary, siw_try_1seg() computes the length of the first chunk as the amount that spills into the second page instead of the amount left in the first page
part = bytes - (PAGE_SIZE - off);
Use the remaining length of the first page as the first chunk.
--- 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
@@ -81,7 +81,7 @@ static int siw_try_1seg(struct siw_iwarp_tx *c_tx, void *paddr)if (likely (PAGE_SIZE - off >= bytes)) {memcpy (paddr, buffer + off, bytes); }else { -unsigned long part = bytes - (PAGE_SIZE - off); +unsigned long part =PAGE_SIZE - off;memcpy (paddr, buffer + off, part);kunmap (p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/1848 RDMA/hfi1: quiesce SDMA asynchronous cleanup on exit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit e95d076bc1fca7cc36fc8f2f0e9687f79fd314bd ]
The SDMA state reference and completion cover the software cleanup tasklet, but not the hardware cleanup tasklet, err_halt_worker, or flush_worker. Queued instances can therefore access an SDMA engine after per_sdma is released.
After the state machine has stopped, cancel err_halt_worker first because it can publish the hardware cleanup tasklet. Then kill that tasklet and drain the remaining flush work.
--- drivers/infiniband/hw/hfi1/sdma.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/hfi1/sdma.c +3 -0
@@ -1625,6 +1625,9 @@ void sdma_exit(struct hfi1_devdata *dd)* it is not running. */ sdma_finalput (&sde->state); +cancel_work_sync (&sde->err_halt_worker); +tasklet_kill (&sde->sdma_hw_clean_up_task); +cancel_work_sync (&sde->flush_worker); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/1848 kconfig: tests: Provide defconfig outfile for savedefconfig
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Schier <[email protected]>
[ Upstream commit 09bd92ba15bd00d937deea38a10a439458393043 ]
Let kconfig test framework's 'savedefconfig' forward the requested output 'defconfig' filename to 'conf'.
The original implementation was calling 'conf' with '--savedefconfig' but missed the mandatory filename for the defconfig output file.
While at it, honour the 'dot_config' argument which points to the input config file.
--- scripts/kconfig/tests/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/kconfig/tests/conftest.py +2 -1
@@ -209,7 +209,8 @@ class Conf: dot_config: .config file for input returncode: exit status of the Kconfig executable """ - return self._run_conf('--savedefconfig', out_file='defconfig') + return self._run_conf('--savedefconfig={}'.format(out_file), + dot_config=dot_config, out_file='defconfig') def listnewconfig(self, dot_config=None): """Run listnewconfig.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/1848 rtc: bd70528: properly enable wakeup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Kemnade <[email protected]>
[ Upstream commit cb8a6249236fd970fc3418d5d2b27dc37376f3ff ]
Wakeup on RTC alarm now only accidentially works when wakeup for the power button connected to the same PMIC is also enabled. Fix that by properly specifying the wakeup irq.
--- drivers/rtc/rtc-bd70528.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/rtc/rtc-bd70528.c +5 -0
@@ -10,6 +10,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/platform_device.h> +#include <linux/pm_wakeirq.h> #include <linux/regmap.h> #include <linux/rtc.h>
@@ -572,6 +573,10 @@ static int bd70528_probe(struct platform_device *pdev)device_set_wakeup_capable (&pdev->dev, true);device_wakeup_enable (&pdev->dev); + ret =devm_pm_set_wake_irq (&pdev->dev, irq); +if (ret) +return ret; + rtc =devm_rtc_allocate_device (&pdev->dev);if (IS_ERR (rtc)) {dev_err (&pdev->dev,"RTC device creation failed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/1848 dt-bindings: vendor-prefixes: add Source Parts and Lctech names
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Icenowy Zheng <[email protected]>
[ Upstream commit eef696356f58a4f5c17ec5d7cb1d495f75edf62e ]
Source Parts Inc. [1] is a company that makes a series of SBCs, SoMs, etc under a brand called Popcorn Computer [2].
Shenzen LC Technology [3] makes various boards and related products around IoT and AI technology. They used the "Cherry Pi" brand name before.
Add both companies' names to the vendor prefixes list.
[1] https://source.parts/
[2] https://popcorncomputer.com/
[3] http://www.chinalctech.com
Stable-dep-of: 538f8ec6b9c7 ("dt-bindings: vendor-prefixes: Add Sophos")
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +4 -0
@@ -599,6 +599,8 @@ patternProperties: description: Lantiq Semiconductor "^lattice,.*": description: Lattice Semiconductor + "^lctech,.*": + description: Shenzen LC Technology Co., Ltd. "^leadtek,.*": description: Shenzhen Leadtek Technology Co., Ltd. "^leeco,.*":
@@ -1050,6 +1052,8 @@ patternProperties: description: Solomon Systech Limited "^sony,.*": description: Sony Corporation + "^sourceparts,.*": + description: Source Parts Inc. "^spansion,.*": description: Spansion Inc. "^sprd,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/1848 dt-bindings: vendor-prefixes: add milkv/sophgo
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Wang <[email protected]>
[ Upstream commit 07f9b764062904f0c0fd6e54e58535f34ac3ac6f ]
Add new vendor strings to dt bindings. These new vendor strings are used by
- SOPHGO's SG2042 SoC [1]
- Milk-V Pioneer board [2], which uses SG2042 chip.
Stable-dep-of: 538f8ec6b9c7 ("dt-bindings: vendor-prefixes: Add Sophos")
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 4 ++++ 1 file changed, 4 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +4 -0
@@ -705,6 +705,8 @@ patternProperties: description: MikroElektronika d.o.o. "^mikrotik,.*": description: MikroTik + "^milkv,.*": + description: MilkV Technology Co., Ltd "^miniand,.*": description: Miniand Tech "^minix,.*":
@@ -1052,6 +1054,8 @@ patternProperties: description: Solomon Systech Limited "^sony,.*": description: Sony Corporation + "^sophgo,.*": + description: Sophgo Technology Inc. "^sourceparts,.*": description: Source Parts Inc. "^spansion,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/1848 dt-bindings: vendor-prefixes: Add Sophos
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolo Giuliani <[email protected]>
[ Upstream commit 538f8ec6b9c711833c5217a8bd8207a282265303 ]
Add the "sophos" vendor prefix for Sophos Ltd., a vendor of network security appliances.
--- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
@@ -1056,6 +1056,8 @@ patternProperties: description: Sony Corporation "^sophgo,.*": description: Sophgo Technology Inc. + "^sophos,.*": + description: Sophos Ltd. "^sourceparts,.*": description: Source Parts Inc. "^spansion,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/1848 x86/hibernate: Ignore page-zero RAM in E820 checksum
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Goergens <[email protected]>
[ Upstream commit 29671cabfc09afb1ee2426b21173cdde276a95ac ]
The legacy kexec_load path reconstructs the E820 map exported through sysfs. kexec-tools leaves the first 1 KiB unavailable for the real-mode transition, so a kernel entered through kexec_load can see conventional RAM starting at 0x400. A subsequent firmware boot reports the same RAM range starting at zero.
The hibernation E820 checksum compares those byte representations and rejects the image, even though the maps agree from page one onwards. A QEMU guest showed this transition:
firmware: RAM [0-0x9fbff] kexec_load: gap [0-0x3ff], RAM [0x400-0x9fbff] firmware: RAM [0-0x9fbff]
The checksum covers e820_table_firmware, which trim_bios_range() leaves alone. The nosave regions come from e820_table instead, where trim_bios_range() has already turned conventional RAM in page zero into reserved memory, so page zero never occurs in the image, whatever the firmware map says about it.
Canonicalise only the conventional-RAM portion below PAGE_SIZE before calculating the checksum. Preserve RESERVED, ACPI, NVS, UNUSABLE, PMEM and all other E820 types so that changes to exceptional mappings remain detectable.
This is deliberately narrower than Marco Scardovi's June proposal to checksum only RAM and its opt-in relaxed_memmap successor. Rafael noted that ignoring non-RAM changes could hide moved ACPI or UEFI regions still used by the resumed kernel. This patch preserves every non-RAM entry and ignores only RAM within page zero, which common setup already reserves and excludes from the image.
Bump RESTORE_MAGIC, since the checksum semantics change, so that an image written by a kernel without this change is refused by the magic check instead of being compared under different rules.
In the same guest, with the page-zero difference kept, hibernation and resume now work after both a direct boot and a kexec_load boot. An image written by an unpatched kernel is refused at resume with "Unrecognized hibernate image header format!", and the firmware-booted kernel carries on.
--- arch/x86/power/hibernate.c | 51 +++++++++++++++++++++++++++++++++----- 1 file changed, 45 insertions(+), 6 deletions(-)
arch/x86/power/hibernate.c +45 -6
@@ -62,6 +62,25 @@ struct restore_data_record {unsigned long e820_checksum; }; +static bool trim_e820_page_zero_ram (struct e820_entry *entry) +{ +u64 lowmem_size; + +/* +* Page zero is BIOS-owned and registered as nosave. Boot loaders may +* therefore omit part of its conventional RAM entry without changing +* any memory available to the image. Preserve all other E820 types. +*/ +if (entry->type !=E820_TYPE_RAM || entry->addr >=PAGE_SIZE ) +return true; + + lowmem_size =min_t (u64, entry->size,PAGE_SIZE - entry->addr); + entry->addr += lowmem_size; + entry->size -= lowmem_size; + +return entry->size; +} +/** * compute_e820_crc32 - calculate crc32 of a given e820 table *
@@ -69,18 +88,38 @@ struct restore_data_record {* * Return: the resulting checksum */ -static inline u32 compute_e820_crc32 (struct e820_table *table) +static u32 compute_e820_crc32 (struct e820_table *table) { -int size = offsetof(struct e820_table , entries) + -sizeof (struct e820_entry ) * table->nr_entries; +struct e820_entry entry; +u32 crc = ~0 ; +u32 nr_entries =0 ; +u32 i; + +for (i =0 ; i < table->nr_entries; i++) { + entry = table->entries[i]; +if (trim_e820_page_zero_ram (&entry)) + nr_entries++; + } + + crc =crc32_le (crc, (unsigned char const *)&nr_entries, +sizeof (nr_entries)); + +for (i =0 ; i < table->nr_entries; i++) { + entry = table->entries[i]; +if (!trim_e820_page_zero_ram (&entry)) +continue ; + + crc =crc32_le (crc, (unsigned char const *)&entry, +sizeof (entry)); + } -return ~crc32_le (~0 , (unsigned char const *)table, size); +return ~crc; }#ifdef CONFIG_X86_64 -#define RESTORE_MAGIC 0x23456789ABCDEF02UL +#define RESTORE_MAGIC 0x23456789ABCDEF03UL#else -#define RESTORE_MAGIC 0x12345679UL +#define RESTORE_MAGIC 0x1234567AUL#endif /**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/1848 ARM: mvebu: fix Cortex-A9 errata selection for Armada 38x
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qingfang Deng <[email protected]>
[ Upstream commit 76e67df8bc1cb72157368c3669119e64cdb0a6a6 ]
Armada 38x uses Cortex-A9 r4p1, but MACH_ARMADA_38X selects the workaround for erratum 720789, which was fixed in r2p0, and omits workarounds for errata that still affect r4p1.
Drop ARM_ERRATA_720789 and select ARM_ERRATA_754322 for faulty MMU translations following an ASID switch and ARM_ERRATA_764319 for unexpected undefined instruction exceptions when reading debug registers. Also select ARM_ERRATA_764369 when SMP is enabled to work around cache maintenance by MVA failing to reach other agents.
The Cortex-A9 r4 Software Developers Errata Notice (ARM UAN 0009D) lists these errata in sections 2.3.3, 2.5.10 and 2.3.4, respectively.
--- arch/arm/mach-mvebu/Kconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/mach-mvebu/Kconfig +3 -1
@@ -56,7 +56,9 @@ config MACH_ARMADA_375 config MACH_ARMADA_38X bool "Marvell Armada 380/385 boards" depends on ARCH_MULTI_V7 - select ARM_ERRATA_720789 + select ARM_ERRATA_754322 + select ARM_ERRATA_764319 + select ARM_ERRATA_764369 if SMP select PL310_ERRATA_753970 select ARM_GIC select ARM_GLOBAL_TIMER
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/1848 drm/msm/mdp5: drop cursor pipe for msm8x76
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit c33cee4c07f1533ad48ed8e3eef75df57edf44c1 ]
The MSM8976/56 family of platforms doe't have a separate cursor plane. Instead the cursor is a part of the LM block. Drop the erroneously added pipe configuration, letting LM to provide a legacy cursor instead.
Patchwork: https://patchwork.freedesktop.org/patch/753150/
--- drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c +0 -9
@@ -671,15 +671,6 @@ const struct mdp5_cfg_hw msm8x76_config = {MDP_PIPE_CAP_SW_PIX_EXT | 0, }, - .pipe_cursor = { - .count = 1, - .base = { 0x440DC }, - .caps =MDP_PIPE_CAP_HFLIP | -MDP_PIPE_CAP_VFLIP | -MDP_PIPE_CAP_SW_PIX_EXT | -MDP_PIPE_CAP_CURSOR | - 0, - }, .lm = { .count = 2, .base = { 0x44000, 0x45000 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/1848 staging: sm750fb: free cmap on framebuffer release
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Costa <[email protected]>
[ Upstream commit b7c885194b81a0376d1fdb457eac40d21d6fb65f ]
The cmap is allocated by lynxfb_set_fbinfo() but never freed, so it is leaked when the framebuffer is torn down. This happens on every unbind, and on the register_framebuffer() error path in sm750fb_framebuffer_alloc().
Add a lynxfb_unset_fbinfo() cleanup counterpart to lynxfb_set_fbinfo() which deallocates the cmap, and call it on teardown. In the alloc error path it is only called once lynxfb_set_fbinfo() has succeeded, so the cmap is only freed when it was actually allocated.
--- drivers/staging/sm750fb/sm750.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/staging/sm750fb/sm750.c +9 -1
@@ -865,6 +865,11 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)return ret; } +static void lynxfb_unset_fbinfo (struct fb_info *info) +{ +fb_dealloc_cmap (&info->cmap); +} +/* chip specific g_option configuration routine */ static void sm750fb_setup (struct sm750_dev *sm750_dev,char *src) {
@@ -951,6 +956,7 @@ static void sm750fb_framebuffer_release(struct sm750_dev *sm750_dev)while (sm750_dev->fb_count) { fb_info = sm750_dev->fbinfo[sm750_dev->fb_count -1 ];unregister_framebuffer (fb_info); +lynxfb_unset_fbinfo (fb_info);framebuffer_release (fb_info); sm750_dev->fb_count--; }
@@ -977,12 +983,14 @@ static int sm750fb_framebuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) err =register_framebuffer (fb_info);if (err <0 ) - goto release_fb; + goto unset_fb; sm750_dev->fb_count++;return 0 ; +unset_fb: +lynxfb_unset_fbinfo (fb_info); release_fb:framebuffer_release (fb_info);return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/1848 OPP: Fix the return value in dev_pm_opp_get_of_node() kernel-doc
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 706081c6b9327dd611dd72b20130a77f0f059b6e ]
dev_pm_opp_get_of_node() returns NULL when the OPP is invalid, but its kernel-doc says "else 0 on success", which was never true. Say NULL.
--- drivers/opp/of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/opp/of.c +1 -1
@@ -1213,7 +1213,7 @@ EXPORT_SYMBOL_GPL(of_get_required_opp_performance_state);* dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp * @opp: opp for which DT node has to be returned for * -* Return: DT node corresponding to the opp, else 0 on success. +* Return: DT node corresponding to the opp, else NULL. * * The caller needs to put the node with of_node_put() after using it. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/1848 ARM: vexpress: fix device_node refcount leak in vexpress_flags_set()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit 62b9ae8ae4a7f0b93efa1efa230782b37057b1e7 ]
vexpress_flags_set() obtains a reference to the "arm,vexpress-sysreg" device node via of_find_compatible_node() and passes it to of_iomap(), but never calls of_node_put() on it. of_iomap() only reads the node's reg property to create the mapping and does not take ownership, so the node reference is leaked. The function runs from the __init SMP prepare path and caches the mapping in a static, so this is a one-shot leak of a single refcount during boot, with no functional impact.
The lookup was added to drivers/mfd/vexpress-sysreg.c by the commit below and later moved here by commit 9b06fc39084e ("ARM: vexpress: Move vexpress_flags_set() into arch code").
Annotate node with the __free(device_node) cleanup attribute so the reference is released when it goes out of scope.
Found by static analysis tool CodeQL.
--- arch/arm/mach-vexpress/v2m.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-vexpress/v2m.c +2 -2
@@ -13,8 +13,8 @@ void vexpress_flags_set(u32 data)static void __iomem *base;if (!base) { -struct device_node *node =of_find_compatible_node (NULL ,NULL , -"arm,vexpress-sysreg" ); + struct device_node *node __free(device_node) = +of_find_compatible_node (NULL ,NULL ,"arm,vexpress-sysreg" ); base =of_iomap (node,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/1848 ARM: vexpress: fix device_node refcount leak in vexpress_smp_dt_prepare_cpus()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weigang He <[email protected]>
[ Upstream commit 27b98d331f1dcebe088ab51a7061a387a7440cb2 ]
vexpress_smp_dt_prepare_cpus() obtains a reference to the SCU device node via of_find_matching_node() and passes it to of_iomap(), but never calls of_node_put() on it. of_iomap() does not take ownership of the node, so the reference is leaked. The function is the .smp_prepare_cpus hook invoked once from the __init SMP bring-up path, so this is a one-shot leak of a single refcount during boot, with no functional impact.
Annotate scu with the __free(device_node) cleanup attribute so the reference is released when the function returns.
Found while reviewing a CodeQL report for vexpress_flags_set() on the same SMP bring-up path.
--- arch/arm/mach-vexpress/platsmp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-vexpress/platsmp.c +2 -2
@@ -64,8 +64,8 @@ static const struct of_device_id vexpress_smp_dt_scu_match[] __initconst = {static void __init vexpress_smp_dt_prepare_cpus (unsigned int max_cpus) { -struct device_node *scu =of_find_matching_node (NULL , - vexpress_smp_dt_scu_match); + struct device_node *scu __free(device_node) = +of_find_matching_node (NULL , vexpress_smp_dt_scu_match);if (scu)scu_enable (of_iomap (scu,0 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/1848 misc: enclosure: fix UAF on device_register() failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 0f3b12bab74e13a2b8686a49c5b83099da61e032 ]
After device_register() fails, the embedded struct device has already been initialized and must be released with put_device() so that enclosure_release() can drop the parent reference and free edev.
The error path currently does put_device(parent) + kfree(edev), which skips the device lifetime rules and can free the object while the device core still owns a reference (use-after-free).
--- drivers/misc/enclosure.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/misc/enclosure.c +1 -2
@@ -147,8 +147,7 @@ enclosure_register(struct device *dev, const char *name, int components,return edev; err: -put_device (edev->edev.parent); -kfree (edev); +put_device (&edev->edev);return ERR_PTR (err); }EXPORT_SYMBOL_GPL (enclosure_register);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/1848 pinctrl: mediatek: mt7629: fix the 2.4 GHz Wi-Fi pin mode array
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuanhong Guo <[email protected]>
[ Upstream commit 0b056aef31602cd10d2b35adc4746781b4fb8609 ]
The wf0_2g group contains nine pins but only eight mux values. mtk_pinmux_set_mux() indexes the mode array once for each pin, reading past its end when configuring pin 78 (WF0_2G_HB6). This can select an unrelated mux value or fail with -EINVAL, preventing the Wi-Fi device from probing.
Add the missing mode 1 entry for WF0_2G_HB6.
--- drivers/pinctrl/mediatek/pinctrl-mt7629.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/mediatek/pinctrl-mt7629.c +1 -1
@@ -294,7 +294,7 @@ static int mt7629_pwm_1_funcs[] = { 2, };/* WF 2G */ static int mt7629_wf0_2g_pins[] = {70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 , }; -static int mt7629_wf0_2g_funcs[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , }; +static int mt7629_wf0_2g_funcs[] = {1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 ,1 , };/* WF 5G */ static int mt7629_wf0_5g_pins[] = {0 ,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/1848 crypto: atmel - handle authenc requests without plaintext
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit ccbd95b3efbc0580b6abde2a905823417ca56022 ]
Authenc permits a nonempty associated-data string with no plaintext. The Atmel driver accepts such a request, has SHA process the associated data, and then unconditionally asks AES DMA to transfer zero bytes. The Atmel DMA engines reject the zero-length descriptor, so the valid request fails, normally with -ENOMEM.
Skip the AES transfer when textlen is zero and proceed directly to SHA finalization.
Once an HMAC transform has cached its inner and outer states, SHA can complete this path synchronously. The forced ahash completion callback then invokes the AES finalizer through a void function and discards its return value. This loses -EBADMSG for a mismatched tag and reports successful decryption.
For synchronous SHA completion, release the SHA device without invoking the ahash callback and call the AES finalizer directly. Its result then propagates through the synchronous call chain. Keep the existing callback path for asynchronous completion.
On a SAM9X75, the unpatched driver failed valid AAD-only requests and returned success for a bad tag after the transform had been used once. With this change, bad tags return -EBADMSG for both fresh and reused transforms.
--- drivers/crypto/atmel-aes.c | 2 ++ drivers/crypto/atmel-sha.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+)
drivers/crypto/atmel-aes.c +2 -0
@@ -1966,6 +1966,8 @@ static int atmel_aes_authenc_transfer(struct atmel_aes_dev *dd, int err, dd->is_async = true;if (err)return atmel_aes_complete (dd, err); +if (!rctx->textlen) +return atmel_aes_authenc_digest (dd);/* Prepare src and dst scatter-lists to transfer cipher/plain texts. */ src =scatterwalk_ffwd (rctx->src, req->src, req->assoclen);
drivers/crypto/atmel-sha.c +14 -0
@@ -2369,11 +2369,25 @@ static int atmel_sha_authenc_final_done(struct atmel_sha_dev *dd) {struct ahash_request *req = dd->req;struct atmel_sha_authenc_reqctx *authctx =ahash_request_ctx (req); +atmel_aes_authenc_fn_t cb; +struct atmel_aes_dev *aes_dev;size_t i, num_words = authctx->digestlen /sizeof (u32);for (i =0 ; i < num_words; ++i) authctx->digest[i] =atmel_sha_read (dd,SHA_REG_DIGEST (i)); +if (!dd->is_async) { +/* +* Return the AES finalizer's status directly for synchronous requests. +* The ahash callback cannot propagate it. +*/ + cb = authctx->cb; + aes_dev = authctx->aes_dev; + dd->force_complete = false; + (void )atmel_sha_complete (dd,0 ); +return cb (aes_dev,0 , false); + } +return atmel_sha_complete (dd,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/1848 crypto: tcrypt - include 1420 byte blocks in aead and skcipher benchmarks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
[ Upstream commit ad6d66bcac77e5145eb67449f8354ed0f936258c ]
WireGuard and IPsec both typically operate on input blocks that are ~1420 bytes in size, given the default Ethernet MTU of 1500 bytes and the overhead of the VPN metadata.
Many aead and sckipher implementations are optimized for power-of-2 block sizes, and whether they perform well when operating on 1420 byte blocks cannot be easily extrapolated from the performance on power-of-2 block size. So let's add 1420 bytes explicitly, and round it up to the next blocksize multiple of the algo in question if it does not support 1420 byte blocks.
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 81 +++++++++++++++++++++++++++---------------------- 1 file changed, 44 insertions(+), 37 deletions(-)
crypto/tcrypt.c +44 -37
@@ -77,8 +77,8 @@ static const char *check[] = { NULL }; -static u32 block_sizes[] = {16 ,64 ,256 ,1024 ,1472 ,8192 ,0 }; -static u32 aead_sizes[] = {16 ,64 ,256 ,512 ,1024 ,2048 ,4096 ,8192 ,0 }; +static const int block_sizes[] = {16 ,64 ,256 ,1024 ,1420 ,4096 ,0 }; +static const int aead_sizes[] = {16 ,64 ,256 ,512 ,1024 ,1420 ,4096 ,8192 ,0 };#define XBUFSIZE 8#define MAX_IVLEN 32
@@ -256,10 +256,10 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,struct test_mb_aead_data *data;struct crypto_aead *tfm;unsigned int i, j, iv_len; +const int *b_size;const char *key;const char *e;void *assoc; -u32 *b_size;char *iv;int ret;
@@ -337,15 +337,17 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, do { b_size = aead_sizes; do { - if (*b_size + authsize > XBUFSIZE * PAGE_SIZE) { + int bs = round_up(*b_size, crypto_aead_blocksize(tfm)); + + if (bs + authsize > XBUFSIZE * PAGE_SIZE) { pr_err("template (%u) too big for buffer (%lu)\n", - authsize + *b_size, + authsize + bs, XBUFSIZE * PAGE_SIZE); goto out; } pr_info("test %u (%d bit key, %d byte blocks): ", i, - *keysize * 8, *b_size); + *keysize * 8, bs); /* Set up tfm global state, i.e. the key */
@@ -380,11 +382,11 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,memset (assoc,0xff , aad_size);sg_init_aead (cur->sg, cur->xbuf, - *b_size + (enc ?0 : authsize), + bs + (enc ?0 : authsize), assoc, aad_size);sg_init_aead (cur->sgout, cur->xoutbuf, - *b_size + (enc ? authsize :0 ), + bs + (enc ? authsize :0 ), assoc, aad_size);aead_request_set_ad (cur->req, aad_size);
@@ -394,7 +396,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,aead_request_set_crypt (cur->req, cur->sgout, cur->sg, - *b_size, iv); + bs, iv); ret =crypto_aead_encrypt (cur->req); ret =do_one_aead_op (cur->req, ret);
@@ -406,18 +408,18 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, }aead_request_set_crypt (cur->req, cur->sg, - cur->sgout, *b_size + + cur->sgout, bs + (enc ?0 : authsize), iv); }if (secs) { - ret =test_mb_aead_jiffies (data, enc, *b_size, + ret =test_mb_aead_jiffies (data, enc, bs, secs, num_mb);cond_resched (); }else { - ret =test_mb_aead_cycles (data, enc, *b_size, + ret =test_mb_aead_cycles (data, enc, bs, num_mb); }
@@ -534,7 +536,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,char *xbuf[XBUFSIZE ];char *xoutbuf[XBUFSIZE ];char *axbuf[XBUFSIZE ]; -unsigned int *b_size; +const int *b_size;unsigned int iv_len;struct crypto_wait wait;
@@ -590,12 +592,14 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, do { b_size = aead_sizes; do { + u32 bs = round_up(*b_size, crypto_aead_blocksize(tfm)); + assoc = axbuf[0]; memset(assoc, 0xff, aad_size); - if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { + if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) { pr_err("template (%u) too big for tvmem (%lu)\n", - *keysize + *b_size, + *keysize + bs, TVMEMSIZE * PAGE_SIZE); goto out; }
@@ -616,7 +620,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,crypto_aead_clear_flags (tfm, ~0 );printk (KERN_INFO "test %u (%d bit key, %d byte blocks): " , - i, *keysize *8 , *b_size); + i, *keysize *8 , bs);memset (tvmem[0 ],0xff ,PAGE_SIZE );
@@ -627,11 +631,11 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, goto out; } -sg_init_aead (sg, xbuf, *b_size + (enc ?0 : authsize), +sg_init_aead (sg, xbuf, bs + (enc ?0 : authsize), assoc, aad_size);sg_init_aead (sgout, xoutbuf, - *b_size + (enc ? authsize :0 ), assoc, + bs + (enc ? authsize :0 ), assoc, aad_size);aead_request_set_ad (req, aad_size);
@@ -644,7 +648,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,* reversed (input <-> output) to calculate it */ aead_request_set_crypt (req, sgout, sg, - *b_size, iv); + bs, iv); ret =do_one_aead_op (req,crypto_aead_encrypt (req));
@@ -656,15 +660,15 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, }aead_request_set_crypt (req, sg, sgout, - *b_size + (enc ?0 : authsize), + bs + (enc ?0 : authsize), iv);if (secs) { - ret =test_aead_jiffies (req, enc, *b_size, + ret =test_aead_jiffies (req, enc, bs, secs);cond_resched (); }else { - ret =test_aead_cycles (req, enc, *b_size); + ret =test_aead_cycles (req, enc, bs); }if (ret) {
@@ -1253,9 +1257,9 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,struct test_mb_skcipher_data *data;struct crypto_skcipher *tfm;unsigned int i, j, iv_len; +const int *b_size;const char *key;const char *e; -u32 *b_size;char iv[128 ];int ret;
@@ -1307,14 +1311,16 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs, do { b_size = block_sizes; do { - if (*b_size > XBUFSIZE * PAGE_SIZE) { + u32 bs = round_up(*b_size, crypto_skcipher_blocksize(tfm)); + + if (bs > XBUFSIZE * PAGE_SIZE) { pr_err("template (%u) too big for buffer (%lu)\n", *b_size, XBUFSIZE * PAGE_SIZE); goto out; } pr_info("test %u (%d bit key, %d byte blocks): ", i, - *keysize * 8, *b_size); + *keysize * 8, bs); /* Set up tfm global state, i.e. the key */
@@ -1344,7 +1350,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,for (j =0 ; j < num_mb; ++j) {struct test_mb_skcipher_data *cur = &data[j]; -unsigned int k = *b_size; +unsigned int k = bs;unsigned int pages =DIV_ROUND_UP (k,PAGE_SIZE );unsigned int p =0 ;
@@ -1368,12 +1374,12 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,if (secs) { ret =test_mb_acipher_jiffies (data, enc, - *b_size, secs, + bs, secs, num_mb);cond_resched (); }else { ret =test_mb_acipher_cycles (data, enc, - *b_size, num_mb); + bs, num_mb); }if (ret) {
@@ -1488,8 +1494,8 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,char iv[128 ];struct skcipher_request *req;struct crypto_skcipher *tfm; +const int *b_size;const char *e; -u32 *b_size;if (enc ==ENCRYPT ) e ="encryption" ;
@@ -1524,17 +1530,18 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, b_size = block_sizes; do { + u32 bs = round_up(*b_size, crypto_skcipher_blocksize(tfm)); struct scatterlist sg[TVMEMSIZE]; - if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) { + if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) { pr_err("template (%u) too big for " - "tvmem (%lu)\n", *keysize + *b_size, + "tvmem (%lu)\n", *keysize + bs, TVMEMSIZE * PAGE_SIZE); goto out_free_req; } pr_info("test %u (%d bit key, %d byte blocks): ", i, - *keysize * 8, *b_size); + *keysize * 8, bs); memset(tvmem[0], 0xff, PAGE_SIZE);
@@ -1556,7 +1563,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, goto out_free_req; } - k = *keysize + *b_size; + k = *keysize + bs;sg_init_table (sg,DIV_ROUND_UP (k,PAGE_SIZE ));if (k >PAGE_SIZE ) {
@@ -1573,22 +1580,22 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,sg_set_buf (sg + j, tvmem[j], k);memset (tvmem[j],0xff , k); }else { -sg_set_buf (sg, tvmem[0 ] + *keysize, *b_size); +sg_set_buf (sg, tvmem[0 ] + *keysize, bs); } iv_len =crypto_skcipher_ivsize (tfm);if (iv_len)memset (&iv,0xff , iv_len); -skcipher_request_set_crypt (req, sg, sg, *b_size, iv); +skcipher_request_set_crypt (req, sg, sg, bs, iv);if (secs) { ret =test_acipher_jiffies (req, enc, - *b_size, secs); + bs, secs);cond_resched (); }else { ret =test_acipher_cycles (req, enc, - *b_size); + bs); }if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/1848 crypto: tcrypt - Fix missing return value check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianjia Zhang <[email protected]>
[ Upstream commit 7b3d52683b3a47c0ba1dfd6b5994a3a795b06972 ]
There are several places where the return value check of crypto_aead_setkey and crypto_aead_setauthsize were lost. It is necessary to add these checks.
At the same time, move the crypto_aead_setauthsize() call out of the loop, and only need to call it once after load transform.
Fixee: 53f52d7aecb4 ("crypto: tcrypt - Added speed tests for AEAD crypto alogrithms in tcrypt test suite")
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-)
crypto/tcrypt.c +19 -10
@@ -290,6 +290,11 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, } ret =crypto_aead_setauthsize (tfm, authsize); +if (ret) { +pr_err ("alg: aead: Failed to setauthsize for %s: %d\n" , algo, + ret); + goto out_free_tfm; + }for (i =0 ; i < num_mb; ++i)if (testmgr_alloc_buf (data[i].xbuf)) {
@@ -315,7 +320,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,for (i =0 ; i < num_mb; ++i) { data[i].req =aead_request_alloc (tfm,GFP_KERNEL );if (!data[i].req) { -pr_err ("alg: skcipher: Failed to allocate request for %s\n" , +pr_err ("alg: aead: Failed to allocate request for %s\n" , algo);while (i--)aead_request_free (data[i].req);
@@ -567,13 +572,19 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, sgout = &sg[9 ]; tfm =crypto_alloc_aead (algo,0 ,0 ); -if (IS_ERR (tfm)) {pr_err ("alg: aead: Failed to load transform for %s: %ld\n" , algo,PTR_ERR (tfm)); goto out_notfm; } + ret =crypto_aead_setauthsize (tfm, authsize); +if (ret) { +pr_err ("alg: aead: Failed to setauthsize for %s: %d\n" , algo, + ret); + goto out_noreq; + } +crypto_init_wait (&wait);printk (KERN_INFO "\ntesting speed of %s (%s) %s\n" , algo,get_driver_name (crypto_aead, tfm), e);
@@ -611,8 +622,13 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,break ; } } + ret =crypto_aead_setkey (tfm, key, *keysize); - ret =crypto_aead_setauthsize (tfm, authsize); +if (ret) { +pr_err ("setkey() failed flags=%x: %d\n" , +crypto_aead_get_flags (tfm), ret); + goto out; + } iv_len =crypto_aead_ivsize (tfm);if (iv_len)
@@ -622,15 +638,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,printk (KERN_INFO "test %u (%d bit key, %d byte blocks): " , i, *keysize *8 , bs); -memset (tvmem[0 ],0xff ,PAGE_SIZE ); -if (ret) { -pr_err ("setkey() failed flags=%x\n" , -crypto_aead_get_flags (tfm)); - goto out; - } -sg_init_aead (sg, xbuf, bs + (enc ?0 : authsize), assoc, aad_size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/1848 crypto: tcrypt - add asynchronous speed test for SM3
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianjia Zhang <[email protected]>
[ Upstream commit ba2c149d0812cee653a186c9cfe451699b211c91 ]
tcrypt supports testing of SM3 hash algorithms that use AVX instruction acceleration.
In order to add the sm3 asynchronous test to the appropriate position, shift the testcase sequence number of the multi buffer backward and start from 450.
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
crypto/tcrypt.c +9 -5
@@ -2566,31 +2566,35 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)if (mode >400 && mode <500 )break ; fallthrough;case 422 : +test_ahash_speed ("sm3" , sec, generic_hash_speed_template); +if (mode >400 && mode <500 )break ; + fallthrough; +case 450 :test_mb_ahash_speed ("sha1" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ; fallthrough; -case 423 : +case 451 :test_mb_ahash_speed ("sha256" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ; fallthrough; -case 424 : +case 452 :test_mb_ahash_speed ("sha512" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ; fallthrough; -case 425 : +case 453 :test_mb_ahash_speed ("sm3" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ; fallthrough; -case 426 : +case 454 :test_mb_ahash_speed ("streebog256" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ; fallthrough; -case 427 : +case 455 :test_mb_ahash_speed ("streebog512" , sec, generic_hash_speed_template, num_mb);if (mode >400 && mode <500 )break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/1848 crypto: tcrypt - remove all multibuffer ahash tests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianjia Zhang <[email protected]>
[ Upstream commit 388ac25efc8ce3bf9768ce7bf24268d6fac285d5 ]
The multibuffer algorithms was removed already in 2018, so it is necessary to clear the test code left by tcrypt.
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 224 ------------------------------------------------ 1 file changed, 224 deletions(-)
crypto/tcrypt.c +0 -224
@@ -724,200 +724,6 @@ static inline int do_one_ahash_op(struct ahash_request *req, int ret)return crypto_wait_req (ret, wait); } -struct test_mb_ahash_data { -struct scatterlist sg[XBUFSIZE ]; -char result[64 ]; -struct ahash_request *req; -struct crypto_wait wait; -char *xbuf[XBUFSIZE ]; -}; - -static inline int do_mult_ahash_op (struct test_mb_ahash_data *data,u32 num_mb, -int *rc) -{ -int i, err =0 ; - -/* Fire up a bunch of concurrent requests */ -for (i =0 ; i < num_mb; i++) - rc[i] =crypto_ahash_digest (data[i].req); - -/* Wait for all requests to finish */ -for (i =0 ; i < num_mb; i++) { - rc[i] =crypto_wait_req (rc[i], &data[i].wait); - -if (rc[i]) { -pr_info ("concurrent request %d error %d\n" , i, rc[i]); - err = rc[i]; - } - } - -return err; -} - -static int test_mb_ahash_jiffies (struct test_mb_ahash_data *data,int blen, -int secs,u32 num_mb) -{ -unsigned long start, end; -int bcount; -int ret =0 ; -int *rc; - - rc =kcalloc (num_mb,sizeof (*rc),GFP_KERNEL ); -if (!rc) -return -ENOMEM ; - -for (start = jiffies, end = start + secs *HZ , bcount =0 ; -time_before (jiffies, end); bcount++) { - ret =do_mult_ahash_op (data, num_mb, rc); -if (ret) - goto out; - } - -pr_cont ("%d operations in %d seconds (%llu bytes)\n" , - bcount * num_mb, secs, (u64 )bcount * blen * num_mb); - -out: -kfree (rc); -return ret; -} - -static int test_mb_ahash_cycles (struct test_mb_ahash_data *data,int blen, -u32 num_mb) -{ -unsigned long cycles =0 ; -int ret =0 ; -int i; -int *rc; - - rc =kcalloc (num_mb,sizeof (*rc),GFP_KERNEL ); -if (!rc) -return -ENOMEM ; - -/* Warm-up run. */ -for (i =0 ; i <4 ; i++) { - ret =do_mult_ahash_op (data, num_mb, rc); -if (ret) - goto out; - } - -/* The real thing. */ -for (i =0 ; i <8 ; i++) { -cycles_t start, end; - - start =get_cycles (); - ret =do_mult_ahash_op (data, num_mb, rc); - end =get_cycles (); - -if (ret) - goto out; - - cycles += end - start; - } - -pr_cont ("1 operation in %lu cycles (%d bytes)\n" , - (cycles +4 ) / (8 * num_mb), blen); - -out: -kfree (rc); -return ret; -} - -static void test_mb_ahash_speed (const char *algo,unsigned int secs, -struct hash_speed *speed,u32 num_mb) -{ -struct test_mb_ahash_data *data; -struct crypto_ahash *tfm; -unsigned int i, j, k; -int ret; - - data =kcalloc (num_mb,sizeof (*data),GFP_KERNEL ); -if (!data) -return ; - - tfm =crypto_alloc_ahash (algo,0 ,0 ); -if (IS_ERR (tfm)) { -pr_err ("failed to load transform for %s: %ld\n" , - algo,PTR_ERR (tfm)); - goto free_data; - } - -for (i =0 ; i < num_mb; ++i) { -if (testmgr_alloc_buf (data[i].xbuf)) - goto out; - -crypto_init_wait (&data[i].wait); - - data[i].req =ahash_request_alloc (tfm,GFP_KERNEL ); -if (!data[i].req) { -pr_err ("alg: hash: Failed to allocate request for %s\n" , - algo); - goto out; - } - -ahash_request_set_callback (data[i].req,0 , crypto_req_done, - &data[i].wait); - -sg_init_table (data[i].sg,XBUFSIZE ); -for (j =0 ; j <XBUFSIZE ; j++) { -sg_set_buf (data[i].sg + j, data[i].xbuf[j],PAGE_SIZE ); -memset (data[i].xbuf[j],0xff ,PAGE_SIZE ); - } - } - -pr_info ("\ntesting speed of multibuffer %s (%s)\n" , algo, -get_driver_name (crypto_ahash, tfm)); - -for (i =0 ; speed[i].blen !=0 ; i++) { -/* For some reason this only tests digests. */ -if (speed[i].blen != speed[i].plen) -continue ; - -if (speed[i].blen >XBUFSIZE *PAGE_SIZE ) { -pr_err ("template (%u) too big for tvmem (%lu)\n" , - speed[i].blen,XBUFSIZE *PAGE_SIZE ); - goto out; - } - -if (klen) -crypto_ahash_setkey (tfm, tvmem[0 ], klen); - -for (k =0 ; k < num_mb; k++) -ahash_request_set_crypt (data[k].req, data[k].sg, - data[k].result, speed[i].blen); - -pr_info ("test%3u " -"(%5u byte blocks,%5u bytes per update,%4u updates): " , - i, speed[i].blen, speed[i].plen, - speed[i].blen / speed[i].plen); - -if (secs) { - ret =test_mb_ahash_jiffies (data, speed[i].blen, secs, - num_mb); -cond_resched (); - }else { - ret =test_mb_ahash_cycles (data, speed[i].blen, num_mb); - } - - -if (ret) { -pr_err ("At least one hashing failed ret=%d\n" , ret); -break ; - } - } - -out: -for (k =0 ; k < num_mb; ++k) -ahash_request_free (data[k].req); - -for (k =0 ; k < num_mb; ++k) -testmgr_free_buf (data[k].xbuf); - -crypto_free_ahash (tfm); - -free_data: -kfree (data); -} -static int test_ahash_jiffies_digest (struct ahash_request *req,int blen,char *out,int secs) {
@@ -2569,36 +2375,6 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)test_ahash_speed ("sm3" , sec, generic_hash_speed_template);if (mode >400 && mode <500 )break ; fallthrough; -case 450 : -test_mb_ahash_speed ("sha1" , sec, generic_hash_speed_template, - num_mb); -if (mode >400 && mode <500 )break ; - fallthrough; -case 451 : -test_mb_ahash_speed ("sha256" , sec, generic_hash_speed_template, - num_mb); -if (mode >400 && mode <500 )break ; - fallthrough; -case 452 : -test_mb_ahash_speed ("sha512" , sec, generic_hash_speed_template, - num_mb); -if (mode >400 && mode <500 )break ; - fallthrough; -case 453 : -test_mb_ahash_speed ("sm3" , sec, generic_hash_speed_template, - num_mb); -if (mode >400 && mode <500 )break ; - fallthrough; -case 454 : -test_mb_ahash_speed ("streebog256" , sec, - generic_hash_speed_template, num_mb); -if (mode >400 && mode <500 )break ; - fallthrough; -case 455 : -test_mb_ahash_speed ("streebog512" , sec, - generic_hash_speed_template, num_mb); -if (mode >400 && mode <500 )break ; - fallthrough;case 499 :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/1848 crypto: tcrypt - Use pr_info/pr_err
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anirudh Venkataramanan <[email protected]>
[ Upstream commit 837a99f59043c3505d69761575172da1d09220b5 ]
Currently, there's mixed use of printk() and pr_info()/pr_err(). The latter prints the module name (because pr_fmt() is defined so) but the former does not. As a result there's inconsistency in the printed output. For example:
modprobe mode=211:
[...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes) [...] test 1 (160 bit key, 64 byte blocks): 1 operation in 2336 cycles (64 bytes)
modprobe mode=215:
[...] tcrypt: test 0 (160 bit key, 16 byte blocks): 1 operation in 2173 cycles (16 bytes) [...] tcrypt: test 1 (160 bit key, 64 byte blocks): 1 operation in 2241 cycles (64 bytes)
Replace all instances of printk() with pr_info()/pr_err() so that the module name is printed consistently.
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
crypto/tcrypt.c +7 -7
@@ -586,8 +586,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, }crypto_init_wait (&wait); -printk (KERN_INFO "\ntesting speed of %s (%s) %s\n" , algo, -get_driver_name (crypto_aead, tfm), e); +pr_info ("\ntesting speed of %s (%s) %s\n" , algo, +get_driver_name (crypto_aead, tfm), e); req =aead_request_alloc (tfm,GFP_KERNEL );if (!req) {
@@ -635,8 +635,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,memset (iv,0xff , iv_len);crypto_aead_clear_flags (tfm, ~0 ); -printk (KERN_INFO "test %u (%d bit key, %d byte blocks): " , - i, *keysize *8 , bs); +pr_info ("test %u (%d bit key, %d byte blocks): " , + i, *keysize *8 , bs);memset (tvmem[0 ],0xff ,PAGE_SIZE );
@@ -888,8 +888,8 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,return ; } -printk (KERN_INFO "\ntesting speed of async %s (%s)\n" , algo, -get_driver_name (crypto_ahash, tfm)); +pr_info ("\ntesting speed of async %s (%s)\n" , algo, +get_driver_name (crypto_ahash, tfm));if (crypto_ahash_digestsize (tfm) >MAX_DIGEST_SIZE ) { pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
@@ -2824,7 +2824,7 @@ static int __init tcrypt_mod_init(void) err =do_test (alg, type, mask, mode, num_mb);if (err) { -printk (KERN_ERR "tcrypt: one or more tests failed!\n" ); +pr_err ("one or more tests failed!\n" ); goto err_free_tv; }else {pr_debug ("all tests passed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/1848 crypto: tcrypt - Drop leading newlines from prints
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anirudh Venkataramanan <[email protected]>
[ Upstream commit 3513828cb8f6db714ee48b1559e6253a57ecf1f6 ]
The top level print banners have a leading newline. It's not entirely clear why this exists, but it makes it harder to parse tcrypt test output using a script. Drop said newlines.
tcrypt output before this patch:
[...]
testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption
[...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes)
tcrypt output with this patch:
[...] testing speed of rfc4106(gcm(aes)) (rfc4106-gcm-aesni) encryption [...] test 0 (160 bit key, 16 byte blocks): 1 operation in 2320 cycles (16 bytes)
Stable-dep-of: 3a31a4baad67 ("crypto: tcrypt - Avoid reading req->base after submission")
--- crypto/tcrypt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
crypto/tcrypt.c +5 -5
@@ -335,7 +335,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, crypto_req_done, &data[i].wait); } -pr_info ("\ntesting speed of multibuffer %s (%s) %s\n" , algo, +pr_info ("testing speed of multibuffer %s (%s) %s\n" , algo,get_driver_name (crypto_aead, tfm), e); i =0 ;
@@ -586,7 +586,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, }crypto_init_wait (&wait); -pr_info ("\ntesting speed of %s (%s) %s\n" , algo, +pr_info ("testing speed of %s (%s) %s\n" , algo,get_driver_name (crypto_aead, tfm), e); req =aead_request_alloc (tfm,GFP_KERNEL );
@@ -888,7 +888,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,return ; } -pr_info ("\ntesting speed of async %s (%s)\n" , algo, +pr_info ("testing speed of async %s (%s)\n" , algo,get_driver_name (crypto_ahash, tfm));if (crypto_ahash_digestsize (tfm) >MAX_DIGEST_SIZE ) {
@@ -1119,7 +1119,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,crypto_init_wait (&data[i].wait); } -pr_info ("\ntesting speed of multibuffer %s (%s) %s\n" , algo, +pr_info ("testing speed of multibuffer %s (%s) %s\n" , algo,get_driver_name (crypto_skcipher, tfm), e); i =0 ;
@@ -1327,7 +1327,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,return ; } -pr_info ("\ntesting speed of %s %s (%s) %s\n" , async ?"async" :"sync" , +pr_info ("testing speed of %s %s (%s) %s\n" , async ?"async" :"sync" , algo,get_driver_name (crypto_skcipher, tfm), e); req =skcipher_request_alloc (tfm,GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/1848 crypto: tcrypt - Avoid reading req->base after submission
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 3a31a4baad6726bf974bcc58a6398f6a36d10aa0 ]
Once a request has been submitted to the Crypto API, the value of req->base.data must not be read by the caller as it may change while the request is processed.
Avoid reading it in tcrypt by combining the crypto_wait struct with the request object into a tcrypt request object and pass that around instead of the request object.
--- crypto/tcrypt.c | 182 +++++++++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 81 deletions(-)
crypto/tcrypt.c +101 -81
@@ -53,6 +53,21 @@*/ #define get_driver_name (tfm_type, tfm) crypto_tfm_alg_driver_name(tfm_type ## _tfm(tfm)) +struct tcrypt_aead_request { +struct aead_request *req; +struct crypto_wait wait; +}; + +struct tcrypt_ahash_request { +struct ahash_request *req; +struct crypto_wait wait; +}; + +struct tcrypt_skcipher_request { +struct skcipher_request *req; +struct crypto_wait wait; +}; +/* * Used by test_cipher_speed() */
@@ -137,18 +152,15 @@ static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],sg_set_buf (&sg[k +1 ], xbuf[k], rem); } -static inline int do_one_aead_op (struct aead_request *req,int ret) +static inline int do_one_aead_op (struct tcrypt_aead_request *req,int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &req->wait); }struct test_mb_aead_data {struct scatterlist sg[XBUFSIZE ];struct scatterlist sgout[XBUFSIZE ]; -struct aead_request *req; -struct crypto_wait wait; +struct tcrypt_aead_request req;char *xbuf[XBUFSIZE ];char *xoutbuf[XBUFSIZE ];char *axbuf[XBUFSIZE ];
@@ -162,14 +174,14 @@ static int do_mult_aead_op(struct test_mb_aead_data *data, int enc,/* Fire up a bunch of concurrent requests */ for (i =0 ; i < num_mb; i++) {if (enc ==ENCRYPT ) - rc[i] =crypto_aead_encrypt (data[i].req); + rc[i] =crypto_aead_encrypt (data[i].req.req);else - rc[i] =crypto_aead_decrypt (data[i].req); + rc[i] =crypto_aead_decrypt (data[i].req.req); }/* Wait for all requests to finish */ for (i =0 ; i < num_mb; i++) { - rc[i] =crypto_wait_req (rc[i], &data[i].wait); + rc[i] =crypto_wait_req (rc[i], &data[i].req.wait);if (rc[i]) {pr_info ("concurrent request %d error %d\n" , i, rc[i]);
@@ -318,21 +330,21 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, }for (i =0 ; i < num_mb; ++i) { - data[i].req =aead_request_alloc (tfm,GFP_KERNEL ); -if (!data[i].req) { + data[i].req.req =aead_request_alloc (tfm,GFP_KERNEL ); +if (!data[i].req.req) {pr_err ("alg: aead: Failed to allocate request for %s\n" , algo);while (i--) -aead_request_free (data[i].req); +aead_request_free (data[i].req.req); goto out_free_xoutbuf; } }for (i =0 ; i < num_mb; ++i) { -crypto_init_wait (&data[i].wait); -aead_request_set_callback (data[i].req, +crypto_init_wait (&data[i].req.wait); +aead_request_set_callback (data[i].req.req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &data[i].wait); + crypto_req_done, &data[i].req.wait); } pr_info("testing speed of multibuffer %s (%s) %s\n", algo,
@@ -394,16 +406,16 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, bs + (enc ? authsize :0 ), assoc, aad_size); -aead_request_set_ad (cur->req, aad_size); +aead_request_set_ad (cur->req.req, aad_size);if (!enc) { -aead_request_set_crypt (cur->req, +aead_request_set_crypt (cur->req.req, cur->sgout, cur->sg, bs, iv); - ret =crypto_aead_encrypt (cur->req); - ret =do_one_aead_op (cur->req, ret); + ret =crypto_aead_encrypt (cur->req.req); + ret =do_one_aead_op (&cur->req, ret);if (ret) { pr_err("calculating auth failed (%d)\n",
@@ -412,7 +424,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, } } -aead_request_set_crypt (cur->req, cur->sg, +aead_request_set_crypt (cur->req.req, cur->sg, cur->sgout, bs + (enc ?0 : authsize), iv);
@@ -440,7 +452,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, out:for (i =0 ; i < num_mb; ++i) -aead_request_free (data[i].req); +aead_request_free (data[i].req.req); out_free_xoutbuf:for (i =0 ; i < num_mb; ++i)testmgr_free_buf (data[i].xoutbuf);
@@ -458,9 +470,10 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,kfree (iv); } -static int test_aead_jiffies (struct aead_request *req,int enc, +static int test_aead_jiffies (struct tcrypt_aead_request *treq,int enc,int blen,int secs) { +struct aead_request *req = treq->req;unsigned long start, end;int bcount;int ret;
@@ -468,9 +481,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) {if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req));if (ret)return ret;
@@ -481,8 +494,9 @@ static int test_aead_jiffies(struct aead_request *req, int enc,return 0 ; } -static int test_aead_cycles (struct aead_request *req,int enc,int blen) +static int test_aead_cycles (struct tcrypt_aead_request *treq,int enc,int blen) { +struct aead_request *req = treq->req;unsigned long cycles =0 ;int ret =0 ;int i;
@@ -490,9 +504,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)/* Warm-up run. */ for (i =0 ; i <4 ; i++) {if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req));if (ret) goto out;
@@ -504,9 +518,9 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen) start =get_cycles ();if (enc) - ret =do_one_aead_op (req,crypto_aead_encrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_encrypt (req));else - ret =do_one_aead_op (req,crypto_aead_decrypt (req)); + ret =do_one_aead_op (treq,crypto_aead_decrypt (req)); end =get_cycles ();if (ret)
@@ -528,6 +542,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, unsigned int tcount, u8 authsize, unsigned int aad_size, u8 *keysize) { + struct tcrypt_aead_request treq;unsigned int i, j;struct crypto_aead *tfm;int ret = -ENOMEM ;
@@ -543,7 +558,6 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,char *axbuf[XBUFSIZE ];const int *b_size;unsigned int iv_len; -struct crypto_wait wait; iv =kzalloc (MAX_IVLEN ,GFP_KERNEL );if (!iv)
@@ -585,7 +599,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, goto out_noreq; } -crypto_init_wait (&wait); +crypto_init_wait (&treq.wait);pr_info ("testing speed of %s (%s) %s\n" , algo,get_driver_name (crypto_aead, tfm), e);
@@ -595,9 +609,10 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, algo); goto out_noreq; } + treq.req = req;aead_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); i =0 ; do {
@@ -658,7 +673,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,*/ aead_request_set_crypt (req, sgout, sg, bs, iv); - ret =do_one_aead_op (req, + ret =do_one_aead_op (&treq,crypto_aead_encrypt (req));if (ret) {
@@ -673,11 +688,11 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, iv);if (secs) { - ret =test_aead_jiffies (req, enc, bs, + ret =test_aead_jiffies (&treq, enc, bs, secs);cond_resched (); }else { - ret =test_aead_cycles (req, enc, bs); + ret =test_aead_cycles (&treq, enc, bs); }if (ret) {
@@ -717,23 +732,22 @@ static void test_hash_sg_init(struct scatterlist *sg) } } -static inline int do_one_ahash_op (struct ahash_request *req,int ret) +static inline int do_one_ahash_op (struct tcrypt_ahash_request *treq,int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &treq->wait); } -static int test_ahash_jiffies_digest (struct ahash_request *req,int blen, -char *out,int secs) +static int test_ahash_jiffies_digest (struct tcrypt_ahash_request *treq, +int blen,char *out,int secs) { +struct ahash_request *req = treq->req;unsigned long start, end;int bcount;int ret;for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) { - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret)return ret; }
@@ -744,28 +758,29 @@ static int test_ahash_jiffies_digest(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_jiffies (struct ahash_request *req,int blen, +static int test_ahash_jiffies (struct tcrypt_ahash_request *treq,int blen,int plen,char *out,int secs) { +struct ahash_request *req = treq->req;unsigned long start, end;int bcount, pcount;int ret;if (plen == blen) -return test_ahash_jiffies_digest (req, blen, out, secs); +return test_ahash_jiffies_digest (treq, blen, out, secs);for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) { - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret)return ret;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret)return ret; }/* we assume there is enough space in 'out' for the result */ - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret)return ret; }
@@ -776,15 +791,16 @@ static int test_ahash_jiffies(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_cycles_digest (struct ahash_request *req,int blen, -char *out) +static int test_ahash_cycles_digest (struct tcrypt_ahash_request *treq, +int blen,char *out) { +struct ahash_request *req = treq->req;unsigned long cycles =0 ;int ret, i;/* Warm-up run. */ for (i =0 ; i <4 ; i++) { - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret) goto out; }
@@ -795,7 +811,7 @@ static int test_ahash_cycles_digest(struct ahash_request *req, int blen, start =get_cycles (); - ret =do_one_ahash_op (req,crypto_ahash_digest (req)); + ret =do_one_ahash_op (treq,crypto_ahash_digest (req));if (ret) goto out;
@@ -814,26 +830,27 @@ static int test_ahash_cycles_digest(struct ahash_request *req, int blen,return 0 ; } -static int test_ahash_cycles (struct ahash_request *req,int blen, +static int test_ahash_cycles (struct tcrypt_ahash_request *treq,int blen,int plen,char *out) { +struct ahash_request *req = treq->req;unsigned long cycles =0 ;int i, pcount, ret;if (plen == blen) -return test_ahash_cycles_digest (req, blen, out); +return test_ahash_cycles_digest (treq, blen, out);/* Warm-up run. */ for (i =0 ; i <4 ; i++) { - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret) goto out;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret) goto out; } - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret) goto out; }
@@ -844,15 +861,15 @@ static int test_ahash_cycles(struct ahash_request *req, int blen, start =get_cycles (); - ret =do_one_ahash_op (req,crypto_ahash_init (req)); + ret =do_one_ahash_op (treq,crypto_ahash_init (req));if (ret) goto out;for (pcount =0 ; pcount < blen; pcount += plen) { - ret =do_one_ahash_op (req,crypto_ahash_update (req)); + ret =do_one_ahash_op (treq,crypto_ahash_update (req));if (ret) goto out; } - ret =do_one_ahash_op (req,crypto_ahash_final (req)); + ret =do_one_ahash_op (treq,crypto_ahash_final (req));if (ret) goto out;
@@ -875,7 +892,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, struct hash_speed *speed, unsigned mask) {struct scatterlist sg[TVMEMSIZE ]; -struct crypto_wait wait; +struct tcrypt_ahash_request treq;struct ahash_request *req;struct crypto_ahash *tfm;char *output;
@@ -904,9 +921,10 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs, goto out; } -crypto_init_wait (&wait); + treq.req = req; +crypto_init_wait (&treq.wait);ahash_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); output =kmalloc (MAX_DIGEST_SIZE ,GFP_KERNEL );if (!output)
@@ -929,11 +947,11 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,ahash_request_set_crypt (req, sg, output, speed[i].plen);if (secs) { - ret =test_ahash_jiffies (req, speed[i].blen, + ret =test_ahash_jiffies (&treq, speed[i].blen, speed[i].plen, output, secs);cond_resched (); }else { - ret =test_ahash_cycles (req, speed[i].blen, + ret =test_ahash_cycles (&treq, speed[i].blen, speed[i].plen, output); }
@@ -1220,16 +1238,16 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,kfree (data); } -static inline int do_one_acipher_op (struct skcipher_request *req,int ret) +static inline int do_one_acipher_op (struct tcrypt_skcipher_request *req, +int ret) { -struct crypto_wait *wait = req->base.data; - -return crypto_wait_req (ret, wait); +return crypto_wait_req (ret, &req->wait); } -static int test_acipher_jiffies (struct skcipher_request *req,int enc, +static int test_acipher_jiffies (struct tcrypt_skcipher_request *treq,int enc,int blen,int secs) { +struct skcipher_request *req = treq->req;unsigned long start, end;int bcount;int ret;
@@ -1237,10 +1255,10 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,for (start = jiffies, end = start + secs *HZ , bcount =0 ;time_before (jiffies, end); bcount++) {if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req));if (ret)
@@ -1252,9 +1270,10 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc,return 0 ; } -static int test_acipher_cycles (struct skcipher_request *req,int enc, +static int test_acipher_cycles (struct tcrypt_skcipher_request *treq,int enc,int blen) { +struct skcipher_request *req = treq->req;unsigned long cycles =0 ;int ret =0 ;int i;
@@ -1262,10 +1281,10 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,/* Warm-up run. */ for (i =0 ; i <4 ; i++) {if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req));if (ret)
@@ -1278,10 +1297,10 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc, start =get_cycles ();if (enc) - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_encrypt (req));else - ret =do_one_acipher_op (req, + ret =do_one_acipher_op (treq,crypto_skcipher_decrypt (req)); end =get_cycles ();
@@ -1303,8 +1322,8 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,struct cipher_speed_template *template, unsigned int tcount, u8 *keysize, bool async) { + struct tcrypt_skcipher_request treq;unsigned int ret, i, j, k, iv_len; -struct crypto_wait wait;const char *key;char iv[128 ];struct skcipher_request *req;
@@ -1317,7 +1336,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,else e ="decryption" ; -crypto_init_wait (&wait); +crypto_init_wait (&treq.wait); tfm =crypto_alloc_skcipher (algo,0 , async ?0 :CRYPTO_ALG_ASYNC );
@@ -1337,8 +1356,9 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs, goto out; } + treq.req = req;skcipher_request_set_callback (req,CRYPTO_TFM_REQ_MAY_BACKLOG , - crypto_req_done, &wait); + crypto_req_done, &treq.wait); i =0 ; do {
@@ -1405,11 +1425,11 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,skcipher_request_set_crypt (req, sg, sg, bs, iv);if (secs) { - ret =test_acipher_jiffies (req, enc, + ret =test_acipher_jiffies (&treq, enc, bs, secs);cond_resched (); }else { - ret =test_acipher_cycles (req, enc, + ret =test_acipher_cycles (&treq, enc, bs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/1848 hwrng: intel - return -ENOMEM when kmalloc_obj() fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit a0590c556cdbf88373d38494a23f1503d39b0ab2 ]
intel_rng_mod_init() incorrectly returns -ENODEV when kmalloc_obj() fails. Return -ENOMEM instead.
--- drivers/char/hw_random/intel-rng.c | 1 + 1 file changed, 1 insertion(+)
drivers/char/hw_random/intel-rng.c +1 -0
@@ -349,6 +349,7 @@ static int __init mod_init(void) intel_rng_hw =kmalloc (sizeof (*intel_rng_hw),GFP_KERNEL );if (!intel_rng_hw) {pci_dev_put (dev); + err = -ENOMEM ; goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/1848 rtc: ftrtc010: fix integer overflow in time calculation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit 32f04694fa87b8ac9fa58f9ceb2dc6cbc476e2a1 ]
In ftrtc010_rtc_read_time() and ftrtc010_rtc_set_time(), all variables (offset, days, hour, min, sec) are u32. The expression "days * 86400 + hour * 3600 + min * 60 + sec" is evaluated in 32-bit arithmetic, which silently wraps around for dates beyond approximately year 2106 (U32_MAX / 86400 ≈ 49710 days).
In ftrtc010_rtc_read_time(), perform the addition in 32-bit arithmetic first to preserve two's complement wrapping for negative offsets, then cast the result to timeu64_t. In ftrtc010_rtc_set_time(), cast individual u32 operands to timeu64_t before multiplication to prevent overflow in the right-hand side of the offset calculation.
--- drivers/rtc/rtc-ftrtc010.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ftrtc010.c +3 -2
@@ -74,7 +74,7 @@ static int ftrtc010_rtc_read_time(struct device *dev, struct rtc_time *tm) days =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); offset =readl (rtc->rtc_base +FTRTC010_RTC_RECORD ); - time = offset + days *86400 + hour *3600 + min *60 + sec; + time = (timeu64_t)(offset + days *86400 + hour *3600 + min *60 + sec);rtc_time64_to_tm (time, tm);
@@ -94,7 +94,8 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) hour =readl (rtc->rtc_base +FTRTC010_RTC_HOUR ); day =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); - offset = time - (day *86400 + hour *3600 + min *60 + sec); + offset = time - ((timeu64_t )day *86400 + (timeu64_t )hour *3600 + + (timeu64_t )min *60 + (timeu64_t )sec);writel (offset, rtc->rtc_base +FTRTC010_RTC_RECORD );writel (0x01 , rtc->rtc_base +FTRTC010_RTC_CR );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/1848 hwrng: intel - return -ENOMEM when ioremap() fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 4c3ca7c8c152278332590bfd3df1b0f086364759 ]
intel_init_hw_struct() incorrectly returns -EBUSY when ioremap() fails. Return -ENOMEM instead.
--- drivers/char/hw_random/intel-rng.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/hw_random/intel-rng.c +2 -2
@@ -318,8 +318,8 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n"; } intel_rng_hw->mem =ioremap (INTEL_FWH_ADDR ,INTEL_FWH_ADDR_LEN ); -if (intel_rng_hw->mem ==NULL ) -return -EBUSY ; +if (!intel_rng_hw->mem) +return -ENOMEM ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/1848 clocksource/drivers/dbx500-prcmu: Check timer register mapping
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Slavin Liu <[email protected]>
[ Upstream commit 8f30b035a6676e292ee8e54334711d9905dd0495 ]
Return -ENOMEM if of_iomap() fails, before reading or configuring the timer register block.
Detected by static analysis and reviewed with AI-assisted source auditing.
--- drivers/clocksource/clksrc-dbx500-prcmu.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/clocksource/clksrc-dbx500-prcmu.c +2 -0
@@ -52,6 +52,8 @@ static struct clocksource clocksource_dbx500_prcmu = {static int __init clksrc_dbx500_prcmu_init (struct device_node *node) { clksrc_dbx500_timer_base =of_iomap (node,0 ); +if (!clksrc_dbx500_timer_base) +return -ENOMEM ;/* * The A9 sub system expects the timer to be configured as
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/1848 isofs: return long Joliet names whole
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Goergens <[email protected]>
[ Upstream commit b8253bcf92d6365b20eea6465f5a93c9fc4aa029 ]
get_joliet_filename() writes into a buffer allocated by its caller but is not told how big that buffer is. It hardcodes PAGE_SIZE as the output limit for utf16s_to_utf8s() and gives uni16_to_x8() no limit at all. PAGE_SIZE was never the right bound. Before commit b2eb2e288604 ("isofs: Drop support of directory entries straddling blocks") both callers allocated a page, but only its first 1024 bytes were for the name, the rest holding a copy of a directory record that straddled a block. It could not overflow only because a directory record holds at most 222 bytes of name (255 bytes, 33 of them fixed), which no converter expands beyond 1024 bytes.
It also keeps the converted length in an unsigned char. 222 bytes of name are 111 UTF-16 units, and the UTF-8 converter, used for iocharset=utf8 and when CONFIG_NLS_DEFAULT is "utf8", needs three bytes for each CJK, Thai or Devanagari character, so such a name can take up to 333 bytes. Past 255 the length wraps. readdir then reports a short name that usually ends in the middle of a UTF-8 sequence, and lookup finds the file only under that name, never under its real one; a name that wraps to exactly 0 bytes is not listed at all.
Such names are out of spec, since Joliet allows 64 units, but common tools write them: PowerISO 9.5 and UltraISO 9.76 both keep up to 110 units by default. Windows, for which Joliet was made, returns them whole, including 111-unit names in records that leave out the padding byte.
Return them whole here too. Pass the buffer size down and have both converters respect it. utf16s_to_utf8s() stops before a character that does not fit, and uni16_to_x8() now hands uni2char() the space that actually remains and stops on -ENAMETOOLONG, as fs/hfsplus/unicode.c does. Both callers pass JOLIET_NAME_MAX + 1, room for 111 units at three bytes each plus the terminator; no character set needs more than three bytes for a UTF-16 unit, and isofs_dir_record_valid() already rejects a record whose name_len claims more than the record holds, so no name is cut. Make the length an int, which is what both converters return.
These names are longer than NAME_MAX. POSIX lets the limit vary by filesystem, reported by pathconf(_PC_NAME_MAX), and the VFS limits a name only by PATH_MAX (verify_dirent_name() in fs/readdir.c).
vfat, exfat, hfsplus and ntfs3 already return names of up to 255 UTF-16 units, 765 bytes of UTF-8, and such names break the same things there:
copying the file to a filesystem with a 255-byte limit, such as ext4 or tmpfs, fails with ENAMETOOLONG, and cp, tar, rsync and Python's shutil report that file and carry on with the rest, so the copy is incomplete but says so. glibc's readdir() returns the names, but the deprecated readdir_r() skips them and fails with ENAMETOOLONG, and an inotify reader with the buffer size inotify(7) suggests gets EINVAL. In the kernel, fanotify reports events on such a file without its name and warns once in fanotify_info_copy_name(), and a directory with such a name cannot be reconnected from a file handle, because the generic get_name() in fs/exportfs, which isofs uses, skips names longer than NAME_MAX. Cutting at NAME_MAX would avoid these, but would list names that Windows does not show and that can coincide within a directory.
Every name of at most 255 bytes is returned exactly as before.
--- fs/isofs/dir.c | 4 +++- fs/isofs/isofs.h | 11 ++++++++++- fs/isofs/joliet.c | 27 ++++++++++++++++++++------- fs/isofs/namei.c | 3 ++- 4 files changed, 35 insertions(+), 10 deletions(-)
fs/isofs/dir.c +3 -1
@@ -215,7 +215,9 @@ static int do_isofs_readdir(struct inode *inode, struct file *file,if (map) {#ifdef CONFIG_JOLIET if (sbi->s_joliet_level) { - len =get_joliet_filename (de, tmpname, inode); + len =get_joliet_filename (de, tmpname, +JOLIET_NAME_MAX +1 , + inode); p = tmpname; } else#endif
fs/isofs/isofs.h +10 -1
@@ -116,7 +116,16 @@ extern int parse_rock_ridge_inode(struct iso_directory_record *, struct inode *,extern int get_rock_ridge_filename (struct iso_directory_record *,char *,struct inode *);extern int isofs_name_translate (struct iso_directory_record *,char *,struct inode *); -int get_joliet_filename (struct iso_directory_record *,unsigned char *,struct inode *); +/* +* The longest name the Joliet converter returns, in bytes. A directory +* record is at most 255 bytes long, which leaves room for 111 UTF-16 units +* of name, and no character set needs more than three bytes for one unit. +*/ +#define JOLIET_NAME_MAX \ + ((255 - sizeof(struct iso_directory_record)) / 2 * 3) + +int get_joliet_filename (struct iso_directory_record *de,unsigned char *outname, +int outsize,struct inode *inode);int get_acorn_filename (struct iso_directory_record *,char *,struct inode *);extern struct dentry *isofs_lookup (struct inode *,struct dentry *,unsigned int flags);
fs/isofs/joliet.c +20 -7
@@ -15,19 +15,26 @@* Convert Unicode 16 to UTF-8 or ASCII. */ static int -uni16_to_x8 (unsigned char *ascii,__be16 *uni,int len,struct nls_table *nls) +uni16_to_x8 (unsigned char *ascii,__be16 *uni,int len,struct nls_table *nls, +int outsize) {__be16 *ip, ch; -unsigned char *op; +unsigned char *op, *end; ip = uni; op = ascii; + end = ascii + outsize -1 ;/* leave room for the terminator */ while ((ch =get_unaligned (ip)) && len) {int llen; - llen = nls->uni2char (be16_to_cpu (ch), op,NLS_MAX_CHARSET_SIZE ); + +if (op >= end) +break ; + llen = nls->uni2char (be16_to_cpu (ch), op, end - op);if (llen >0 ) op += llen; +else if (llen == -ENAMETOOLONG ) +break ;else *op++ ='?' ; ip++;
@@ -38,21 +45,27 @@ uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls)return (op - ascii); } +/* +* Convert the Joliet name of @de into @outname, a buffer of @outsize bytes. +* The result is at most @outsize - 1 bytes long; a longer name is cut at a +* character boundary. +*/ int -get_joliet_filename (struct iso_directory_record * de,unsigned char *outname,struct inode * inode) +get_joliet_filename (struct iso_directory_record *de,unsigned char *outname, +int outsize,struct inode *inode) {struct nls_table *nls; -unsigned char len =0 ; +int len =0 ; nls =ISOFS_SB (inode->i_sb)->s_nls_iocharset;if (!nls) { len =utf16s_to_utf8s ((const wchar_t *) de->name, de->name_len[0 ] >>1 ,UTF16_BIG_ENDIAN , - outname,PAGE_SIZE ); + outname, outsize -1 ); }else { len =uni16_to_x8 (outname, (__be16 *) de->name, - de->name_len[0 ] >>1 , nls); + de->name_len[0 ] >>1 , nls, outsize); }if ((len >2 ) && (outname[len-2 ] ==';' ) && (outname[len-1 ] =='1' )) len -=2 ;
fs/isofs/namei.c +2 -1
@@ -112,7 +112,8 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, dpnt = tmpname; #ifdef CONFIG_JOLIET }else if (sbi->s_joliet_level) { - dlen =get_joliet_filename (de, tmpname, dir); + dlen =get_joliet_filename (de, tmpname, +JOLIET_NAME_MAX +1 , dir); dpnt = tmpname;#endif }else if (sbi->s_mapping =='a' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/1848 soc/tegra: flowctrl: Release OF node reference on error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 4eaed7ea6ab36e1160d660b05551702c36dfed6c ]
tegra_flowctrl_init() obtains a reference from of_find_matching_node() and currently releases it only after of_address_to_resource() succeeds.
Release the reference before checking the resource conversion result so the error path is balanced as well.
--- drivers/soc/tegra/flowctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/soc/tegra/flowctrl.c +5 -2
@@ -197,11 +197,14 @@ static int __init tegra_flowctrl_init(void) np =of_find_matching_node (NULL , tegra_flowctrl_match);if (np) { -if (of_address_to_resource (np,0 , &res) <0 ) { +int err =of_address_to_resource (np,0 , &res); + +of_node_put (np); + +if (err <0 ) {pr_err ("failed to get flowctrl register\n" );return -ENXIO ; } -of_node_put (np); }else if (IS_ENABLED (CONFIG_ARM )) {/* * Hardcoded fallback for 32-bit Tegra
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/1848 drm/msm/dp: reduce link rate if failed at link training 1
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
[ Upstream commit 4b85d405cfe938ae7ad61656484ae88dee289e3b ]
Reduce link rate and re start link training if link training 1 failed due to loss of clock recovery done to fix Link Layer CTS case 4.3.1.7. Also only update voltage and pre-emphasis swing level after link training started to fix Link Layer CTS case 4.3.1.6.
Changes in V2:
-- replaced cr_status with link_status[DP_LINK_STATUS_SIZE]
-- replaced dp_ctrl_any_lane_cr_done() with dp_ctrl_colco_recovery_any_ok() -- replaced dp_ctrl_any_ane_cr_lose() with !drm_dp_clock_recovery_ok()
Changes in V3:
-- return failed if lane_count <= 1
Stable-dep-of: a47987366e7f ("drm/msm/dp: don't report link training success after a reinit")
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 78 ++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 34 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +44 -34
@@ -80,13 +80,6 @@ struct dp_ctrl_private {struct completion video_comp; }; -struct dp_cr_status { -u8 lane_0_1; -u8 lane_2_3; -}; - -#define DP_LANE0_1_CR_DONE 0x11 -static int dp_aux_link_configure (struct drm_dp_aux *aux,struct dp_link_info *link) {
@@ -1073,7 +1066,7 @@ static int dp_ctrl_read_link_status(struct dp_ctrl_private *ctrl, }static int dp_ctrl_link_train_1 (struct dp_ctrl_private *ctrl, -struct dp_cr_status *cr,int *training_step) +int *training_step) {int tries, old_v_level, ret =0 ;u8 link_status[DP_LINK_STATUS_SIZE ];
@@ -1102,9 +1095,6 @@ static int dp_ctrl_link_train_1(struct dp_ctrl_private *ctrl,if (ret)return ret; - cr->lane_0_1 = link_status[0 ]; - cr->lane_2_3 = link_status[1 ]; -if (drm_dp_clock_recovery_ok (link_status, ctrl->link->link_params.num_lanes)) {return 0 ;
@@ -1181,7 +1171,7 @@ static void dp_ctrl_clear_training_pattern(struct dp_ctrl_private *ctrl) }static int dp_ctrl_link_train_2 (struct dp_ctrl_private *ctrl, -struct dp_cr_status *cr,int *training_step) +int *training_step) {int tries =0 , ret =0 ;char pattern;
@@ -1197,10 +1187,6 @@ static int dp_ctrl_link_train_2(struct dp_ctrl_private *ctrl,else pattern =DP_TRAINING_PATTERN_2 ; - ret =dp_ctrl_update_vx_px (ctrl); -if (ret) -return ret; - ret =dp_catalog_ctrl_set_pattern (ctrl->catalog, pattern);if (ret)return ret;
@@ -1213,8 +1199,6 @@ static int dp_ctrl_link_train_2(struct dp_ctrl_private *ctrl, ret =dp_ctrl_read_link_status (ctrl, link_status);if (ret)return ret; - cr->lane_0_1 = link_status[0 ]; - cr->lane_2_3 = link_status[1 ];if (drm_dp_channel_eq_ok (link_status, ctrl->link->link_params.num_lanes)) {
@@ -1234,7 +1218,7 @@ static int dp_ctrl_link_train_2(struct dp_ctrl_private *ctrl,static int dp_ctrl_reinitialize_mainlink (struct dp_ctrl_private *ctrl);static int dp_ctrl_link_train (struct dp_ctrl_private *ctrl, -struct dp_cr_status *cr,int *training_step) +int *training_step) {int ret =0 ;u8 encoding =DP_SET_ANSI_8B10B ;
@@ -1252,7 +1236,7 @@ static int dp_ctrl_link_train(struct dp_ctrl_private *ctrl,drm_dp_dpcd_write (ctrl->aux,DP_MAIN_LINK_CHANNEL_CODING_SET , &encoding,1 ); - ret =dp_ctrl_link_train_1 (ctrl, cr, training_step); + ret =dp_ctrl_link_train_1 (ctrl, training_step);if (ret) {DRM_ERROR ("link training #1 failed. ret=%d\n" , ret); goto end;
@@ -1261,7 +1245,7 @@ static int dp_ctrl_link_train(struct dp_ctrl_private *ctrl,/* print success info as this is a result of user initiated action */ DRM_DEBUG_DP ("link training #1 successful\n" ); - ret =dp_ctrl_link_train_2 (ctrl, cr, training_step); + ret =dp_ctrl_link_train_2 (ctrl, training_step);if (ret) {DRM_ERROR ("link training #2 failed. ret=%d\n" , ret); goto end;
@@ -1277,7 +1261,7 @@ static int dp_ctrl_link_train(struct dp_ctrl_private *ctrl, }static int dp_ctrl_setup_main_link (struct dp_ctrl_private *ctrl, -struct dp_cr_status *cr,int *training_step) +int *training_step) {int ret =0 ;
@@ -1293,7 +1277,7 @@ static int dp_ctrl_setup_main_link(struct dp_ctrl_private *ctrl,*/ dp_catalog_ctrl_reset (ctrl->catalog); - ret =dp_ctrl_link_train (ctrl, cr, training_step); + ret =dp_ctrl_link_train (ctrl, training_step);return ret; }
@@ -1489,7 +1473,6 @@ static int dp_ctrl_deinitialize_mainlink(struct dp_ctrl_private *ctrl)static int dp_ctrl_link_maintenance (struct dp_ctrl_private *ctrl) {int ret =0 ; -struct dp_cr_status cr;int training_step =DP_TRAINING_NONE ;dp_ctrl_push_idle (&ctrl->dp_ctrl);
@@ -1497,7 +1480,7 @@ static int dp_ctrl_link_maintenance(struct dp_ctrl_private *ctrl) ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; - ret =dp_ctrl_setup_main_link (ctrl, &cr, &training_step); + ret =dp_ctrl_setup_main_link (ctrl, &training_step);if (ret) goto end;
@@ -1628,6 +1611,25 @@ void dp_ctrl_handle_sink_request(struct dp_ctrl *dp_ctrl) } } +static bool dp_ctrl_clock_recovery_any_ok ( +const u8 link_status[DP_LINK_STATUS_SIZE ], +int lane_count) +{ +int reduced_cnt; + +if (lane_count <=1 ) +return false; + +/* +* only interested in the lane number after reduced +* lane_count = 4, then only interested in 2 lanes +* lane_count = 2, then only interested in 1 lane +*/ + reduced_cnt = lane_count >>1 ; + +return drm_dp_clock_recovery_ok (link_status, reduced_cnt); +} +int dp_ctrl_on_link (struct dp_ctrl *dp_ctrl) {int rc =0 ;
@@ -1635,7 +1637,7 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)u32 rate =0 ;int link_train_max_retries =5 ;u32 const phy_cts_pixel_clk_khz =148500 ; -struct dp_cr_status cr; +u8 link_status[DP_LINK_STATUS_SIZE ];unsigned int training_step;if (!dp_ctrl)
@@ -1668,19 +1670,21 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)while (--link_train_max_retries) { training_step =DP_TRAINING_NONE ; - rc =dp_ctrl_setup_main_link (ctrl, &cr, &training_step); + rc =dp_ctrl_setup_main_link (ctrl, &training_step);if (rc ==0 ) {/* training completed successfully */ break ; }else if (training_step ==DP_TRAINING_1 ) {/* link train_1 failed */ -if (!dp_catalog_link_is_connected (ctrl->catalog)) { +if (!dp_catalog_link_is_connected (ctrl->catalog))break ; - } + +dp_ctrl_read_link_status (ctrl, link_status); rc =dp_ctrl_link_rate_down_shift (ctrl);if (rc <0 ) {/* already in RBR = 1.6G */ -if (cr.lane_0_1 &DP_LANE0_1_CR_DONE ) { +if (dp_ctrl_clock_recovery_any_ok (link_status, + ctrl->link->link_params.num_lanes)) {/* * some lanes are ready, * reduce lane number
@@ -1696,12 +1700,18 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) } } }else if (training_step ==DP_TRAINING_2 ) { -/* link train_2 failed, lower lane rate */ -if (!dp_catalog_link_is_connected (ctrl->catalog)) { +/* link train_2 failed */ +if (!dp_catalog_link_is_connected (ctrl->catalog))break ; - } - rc =dp_ctrl_link_lane_down_shift (ctrl); +dp_ctrl_read_link_status (ctrl, link_status); + +if (!drm_dp_clock_recovery_ok (link_status, + ctrl->link->link_params.num_lanes)) + rc =dp_ctrl_link_rate_down_shift (ctrl); +else + rc =dp_ctrl_link_lane_down_shift (ctrl); +if (rc <0 ) {/* end with failure */ break ;/* lane == 1 already */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/1848 drm/msm/dp: do not end dp link training until video is ready
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuogee Hsieh <[email protected]>
[ Upstream commit 2e0adc765d884cc080baa501e250bfad97035b09 ]
Initialize both pre-emphasis and voltage swing level to 0 before start link training and do not end link training until video is ready to reduce the period between end of link training and video start to meet Link Layer CTS requirement. Some dongle main link symbol may become unlocked again if host did not end link training soon enough after completion of link training 2. Host have to re train main link if loss of symbol locked detected before end link training so that the coming video stream can be transmitted to sink properly. This fixes Link Layer CTS cases 4.3.2.1, 4.3.2.2, 4.3.2.3 and 4.3.2.4.
Changes in v3:
-- merge retrain link if loss of symbol locked happen into this patch -- replace dp_ctrl_loss_symbol_lock() with dp_ctrl_channel_eq_ok()
Stable-dep-of: a47987366e7f ("drm/msm/dp: don't report link training success after a reinit")
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 56 +++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 15 deletions(-)
drivers/gpu/drm/msm/dp/dp_ctrl.c +41 -15
@@ -1478,6 +1478,9 @@ static int dp_ctrl_link_maintenance(struct dp_ctrl_private *ctrl)dp_ctrl_push_idle (&ctrl->dp_ctrl);dp_catalog_ctrl_reset (ctrl->catalog); + ctrl->link->phy_params.p_level =0 ; + ctrl->link->phy_params.v_level =0 ; + ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; ret =dp_ctrl_setup_main_link (ctrl, &training_step);
@@ -1630,6 +1633,16 @@ static bool dp_ctrl_clock_recovery_any_ok(return drm_dp_clock_recovery_ok (link_status, reduced_cnt); } +static bool dp_ctrl_channel_eq_ok (struct dp_ctrl_private *ctrl) +{ +u8 link_status[DP_LINK_STATUS_SIZE ]; +int num_lanes = ctrl->link->link_params.num_lanes; + +dp_ctrl_read_link_status (ctrl, link_status); + +return drm_dp_channel_eq_ok (link_status, num_lanes); +} +int dp_ctrl_on_link (struct dp_ctrl *dp_ctrl) {int rc =0 ;
@@ -1664,6 +1677,9 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl) ctrl->link->link_params.rate, ctrl->link->link_params.num_lanes, ctrl->dp_ctrl.pixel_rate); + ctrl->link->phy_params.p_level =0 ; + ctrl->link->phy_params.v_level =0 ; + rc =dp_ctrl_enable_mainlink_clocks (ctrl);if (rc)return rc;
@@ -1728,17 +1744,19 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)if (ctrl->link->sink_request &DP_TEST_LINK_PHY_TEST_PATTERN )return rc; -/* stop txing train pattern */ -dp_ctrl_clear_training_pattern (ctrl); +if (rc ==0 ) {/* link train successfully */ +/* +* do not stop train pattern here +* stop link training at on_stream +* to pass compliance test +*/ + }else { +/* +* link training failed +* end txing train pattern here +*/ +dp_ctrl_clear_training_pattern (ctrl); -/* -* keep transmitting idle pattern until video ready -* to avoid main link from loss of sync -*/ -if (rc ==0 )/* link train successfully */ -dp_ctrl_push_idle (dp_ctrl); -else { -/* link training failed */ dp_ctrl_deinitialize_mainlink (ctrl); rc = -ECONNRESET ; }
@@ -1746,9 +1764,15 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)return rc; } +static int dp_ctrl_link_retrain (struct dp_ctrl_private *ctrl) +{ +int training_step =DP_TRAINING_NONE ; + +return dp_ctrl_setup_main_link (ctrl, &training_step); +} +int dp_ctrl_on_stream (struct dp_ctrl *dp_ctrl) { -u32 rate =0 ;int ret =0 ;bool mainlink_ready = false;struct dp_ctrl_private *ctrl;
@@ -1758,10 +1782,6 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl) ctrl = container_of(dp_ctrl, struct dp_ctrl_private, dp_ctrl); - rate = ctrl->panel->link_info.rate; - - ctrl->link->link_params.rate = rate; - ctrl->link->link_params.num_lanes = ctrl->panel->link_info.num_lanes; ctrl->dp_ctrl.pixel_rate = ctrl->panel->dp_mode.drm_mode.clock; DRM_DEBUG_DP("rate=%d, num_lanes=%d, pixel_rate=%d\n",
@@ -1776,6 +1796,12 @@ int dp_ctrl_on_stream(struct dp_ctrl *dp_ctrl) } } +if (!dp_ctrl_channel_eq_ok (ctrl)) +dp_ctrl_link_retrain (ctrl); + +/* stop txing train pattern to end link training */ +dp_ctrl_clear_training_pattern (ctrl); + ret =dp_ctrl_enable_stream_clocks (ctrl);if (ret) {DRM_ERROR ("Failed to start pixel clocks. ret=%d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/1848 drm/msm/dp: dont report link training success after a reinit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oleg Keri <[email protected]>
[ Upstream commit a47987366e7fc2c05aeffc97f8e1f776e583f792 ]
When every training attempt fails, the retry loop in msm_dp_ctrl_on_link() ends on a successful msm_dp_ctrl_reinitialize_mainlink(), leaving rc at 0. The caller then enables the stream on an untrained link and the display stays dark.
The retry counter only reaches zero in that case, so treat it as a training failure.
Patchwork: https://patchwork.freedesktop.org/patch/756528/
--- drivers/gpu/drm/msm/dp/dp_ctrl.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/msm/dp/dp_ctrl.c +3 -0
@@ -1744,6 +1744,9 @@ int dp_ctrl_on_link(struct dp_ctrl *dp_ctrl)if (ctrl->link->sink_request &DP_TEST_LINK_PHY_TEST_PATTERN )return rc; +if (!link_train_max_retries) + rc = -ETIMEDOUT ; +if (rc ==0 ) {/* link train successfully */ /* * do not stop train pattern here
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/1848 scsi: scsi_debug: Refuse a negative physblk_exp
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit a349876633f7a583429367daf16f9a4282118255 ]
sdebug_init() refuses a physblk_exp above 15, but the parameter is a signed int, so a negative value is accepted. The driver then shifts by it when it builds the Block Limits VPD page, which is undefined behaviour, and READ CAPACITY (16) reports an exponent of 15 for -1.
Refuse a negative value as well, and print it as a signed value.
--- drivers/scsi/scsi_debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +2 -2
@@ -6717,8 +6717,8 @@ static int __init scsi_debug_init(void)return -EINVAL ; } -if (sdebug_physblk_exp >15 ) { -pr_err ("invalid physblk_exp %u\n" , sdebug_physblk_exp); +if (sdebug_physblk_exp <0 || sdebug_physblk_exp >15 ) { +pr_err ("invalid physblk_exp %d\n" , sdebug_physblk_exp);return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/1848 scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 8d1cc285194dbcba88c136e1ff7c25cb10e38a5b ]
A device reset returns the drive's density and block size to their defaults. Commit 7081dc75df79 ("scsi: st: Restore some drive settings after reset") re-applies values changed by the user when the position is recovered with MTREW, MTSEEK or MTEOM. MTLOAD and MTRETEN are also allowed to clear the reset condition and also leave the same medium at BOT, but they restore nothing.
Because check_tape() reads the drive's block size with MODE SENSE on every open, the driver silently switches to the drive default after the reset. An application that set fixed-block mode with MTSETBLK and recovers with MTLOAD or MTRETEN keeps writing, but variable-length blocks, without any error.
Restore the changed density and block size for MTLOAD and MTRETEN as well. Both operations may make the drive report a new medium, and the new session started by check_tape() clears the "changed" flags and applies the mode defaults. So save the values before the operation, let check_tape() run first (do_load_unload() already calls it for MTLOAD; call it after MTRETEN), and then re-apply them. Retry the restore once in case a unit attention is still pending. Only restore when the drive is ready after the
operation: with an immediate-mode load and O_NONBLOCK, check_tape() does not wait and the drive may still be loading. In immediate mode (MT_ST_NOWAIT) MTRETEN may return before the retension has finished; do not wait for it there.
MTOFFL is not changed: the medium is unloaded and a different one may be loaded next, for which the mode defaults apply.
Reproduced with scsi_debug (which reports a new medium after MTRETEN and MTLOAD) and with IBM LTO drives on FC (which do not).
--- drivers/scsi/st.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+)
drivers/scsi/st.c +51 -0
@@ -3508,6 +3508,23 @@ static int partition_tape(struct scsi_tape *STp, int size) +/* +* Re-apply a density and block size that were changed by the user before a +* device reset (a negative value means "not changed"). A unit attention +* still pending after the operation (e.g. new medium after a load) fails the +* first MODE SELECT, so retry each once. As in the other post-reset restore +* path, errors are ignored and one setting failing does not prevent +* restoring the other. +*/ +static void st_restore_changed_settings (struct scsi_tape *STp,int density, +int blksize) +{ +if (density >=0 &&st_int_ioctl (STp,MTSETDENSITY , density)) +st_int_ioctl (STp,MTSETDENSITY , density); +if (blksize >=0 &&st_int_ioctl (STp,MTSETBLK , blksize)) +st_int_ioctl (STp,MTSETBLK , blksize); +} +/* The ioctl command */ static long st_ioctl_common (struct file *file,unsigned int cmd_in,void __user *p) {
@@ -3515,6 +3532,7 @@ static long st_ioctl_common(struct file *file, unsigned int cmd_in, void __userint retval =0 ;unsigned int blk;bool cmd_mtiocget; +int restore_density =-1 , restore_blksize =-1 ;struct scsi_tape *STp = file->private_data;struct st_modedef *STm;struct st_partstat *STps;
@@ -3654,6 +3672,17 @@ static long st_ioctl_common(struct file *file, unsigned int cmd_in, void __userst_int_ioctl (STp,MTSETDENSITY , STp->changed_density);if (STp->blksize_changed)st_int_ioctl (STp,MTSETBLK , STp->changed_blksize); + }else if (mtc.mt_op ==MTLOAD || mtc.mt_op ==MTRETEN ) { +/* +* The same medium ends up at BOT, so the settings +* apply as with MTREW. The operation may start a +* new session, which clears the "changed" flags: +* save the values and restore them afterwards. +*/ +if (STp->density_changed) + restore_density = STp->changed_density; +if (STp->blksize_changed) + restore_blksize = STp->changed_blksize; } }
@@ -3733,6 +3762,14 @@ static long st_ioctl_common(struct file *file, unsigned int cmd_in, void __userif (mtc.mt_op ==MTLOAD ) { retval =do_load_unload (STp, file,max (1 , mtc.mt_count)); +/* +* Restore only if the drive is ready: after an +* immediate-mode load with O_NONBLOCK, check_tape() +* does not wait and the drive may still be loading. +*/ +if (!retval && STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); goto out; }
@@ -3751,6 +3788,20 @@ static long st_ioctl_common(struct file *file, unsigned int cmd_in, void __user retval =st_compression (STp, (mtc.mt_count &1 )); else retval =st_int_ioctl (STp, mtc.mt_op, mtc.mt_count); +if (!retval && mtc.mt_op ==MTRETEN && !STp->immediate && + (restore_density >=0 || restore_blksize >=0 )) { +/* +* Retension reloads the medium and the drive may +* report a new medium. Let check_tape() start the new +* session (applying the mode defaults) now, as for +* MTLOAD; otherwise it happens at the next open and +* overrides the restored settings. +*/ +if (check_tape (STp, file) >=0 && + STp->ready ==ST_READY ) +st_restore_changed_settings (STp, restore_density, + restore_blksize); + } goto out; }if (!STm->defined) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/1848 scsi: st: Record the tape position after a successful MTLOAD
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurence Oberman <[email protected]>
[ Upstream commit 54ee0ee9bdeb7e9d3b70cc5c2bdf7e58c4423e8d ]
Commit 0b120edb37dc ("scsi: st: Add MTIOCGET and MTLOAD to ioctls allowed after device reset") allows MTLOAD to clear the reset condition because the tape location is known after MTLOAD. But the driver does not record it:reset_state() sets the file and block numbers to -1, and do_load_unload() leaves them there. check_tape() sets them to 0 only for a new session, which requires a new-medium unit attention. Drives that do not report one when the medium was already loaded (seen with IBM LTO drives) keep reporting file/block -1 in MTIOCGET and no BOT, although the tape is at the beginning.
After a successful load, reset the partition and the state of all partitions, as the new-session path in check_tape() does: partition 0, position at BOT, EOF state cleared and no pending write. Otherwise the driver may still record the previous partition, so that a later MTSETPART to that partition is not performed; a read after loading at EOD fails with EIO; and a partition left in the ST_WRITING state by a partition switch in read() or write() makes st_flush() write a filemark at the beginning of partition 0 when the device is closed.
--- drivers/scsi/st.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/scsi/st.c +24 -0
@@ -2657,6 +2657,30 @@ static int do_load_unload(struct scsi_tape *STp, struct file *filp, int load_codelse { STp->rew_at_close = STp->autorew_dev; retval =check_tape (STp, filp); +/* +* LOAD leaves the medium at the beginning of partition +* 0. check_tape() records that only for a new session; +* without a new-medium unit attention (the medium was +* already loaded) the partition and the partition state +* would be left as before the load. Reset them as a +* new session does, for all partitions: a stale +* ST_WRITING state would make st_flush() write a +* filemark at the beginning of partition 0. +*/ +if (retval ==CHKRES_READY ) { +int i; + + STp->partition = STp->new_partition =0 ; +for (i =0 ; i <ST_NBR_PARTITIONS ; i++) { + STps = &(STp->ps[i]); + STps->rw =ST_IDLE ; + STps->eof =ST_NOEOF ; + STps->at_sm =0 ; + STps->last_block_valid =0 ; + STps->drv_block =0 ; + STps->drv_file =0 ; + } + }if (retval >0 ) retval =0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/1848 md: take reconfig_mutex when enabling PPL on an inactive array
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyen Ngoc Thang <[email protected]>
[ Upstream commit 900bf42e0ff8009f66ffd4a679c56264957019dd ]
consistency_policy_store() sets MD_HAS_PPL for an external-metadata array that is not running yet, without holding reconfig_mutex. But ->pers is only assigned after pers->run() returns, so "not running" also covers an md_run() that is in progress under the lock.
If the write lands inside raid5_run() after log_init() has decided not to set up PPL, or after a failed ppl_init_log() has cleared the flag, the flag ends up set with conf->log_private still NULL. The next idle pass of raid5d() then does:
raid5d() -> handle_active_stripes() -> log_flush_stripe_to_raid()
-> ppl_write_stripe_run()
and dereferences the NULL ppl_conf:
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002 KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017] RIP: 0010:ppl_write_stripe_run+0x60/0x1320 drivers/md/raid5-ppl.c:538
Take reconfig_mutex around the update and refuse it with -EBUSY once the array is running, in which case ->change_consistency_policy() is the right interface.
--- drivers/md/md.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/md/md.c +9 -1
@@ -5474,7 +5474,15 @@ consistency_policy_store(struct mddev *mddev, const char *buf, size_t len)else err = -EBUSY ; }else if (mddev->external &&strncmp (buf,"ppl" ,3 ) ==0 ) { -set_bit (MD_HAS_PPL , &mddev->flags); +/* md_run() holds the lock until ->pers is set */ + err =mddev_lock (mddev); +if (err) +return err; +if (mddev->pers) + err = -EBUSY ; +else +set_bit (MD_HAS_PPL , &mddev->flags); +mddev_unlock (mddev); }else { err = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/1848 md/raid5: drain released_stripes before destroying the cache
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit af560e357a81964544be40c549e241b032ef7565 ]
grow_one_stripe() calls raid5_release_stripe() for each new stripe. When mddev->thread is already set, that queues the stripe on conf->released_stripes and wakes the thread. Only raid5d moves that list onto inactive_list.
Takeover calls setup_conf() while mddev->thread still belongs to the previous personality, so those stripes stay on released_stripes. If setup_conf() then fails, shrink_stripes() only frees inactive_list and kmem_cache_destroy() warns that objects remain.
Move stripes still queued on released_stripes onto inactive_list before shrink_stripes() frees them.
--- drivers/md/raid5.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/md/raid5.c +31 -0
@@ -2653,6 +2653,37 @@ static int drop_one_stripe(struct r5conf *conf)static void shrink_stripes (struct r5conf *conf) { +struct list_head temp[NR_STRIPE_HASH_LOCKS ]; +int i; + +/* +* grow_one_stripe() parks new stripes on released_stripes when +* mddev->thread is already set. Takeover leaves the previous +* personality's thread there, so raid5d never moves them to +* inactive_list. Drain them before the cache is destroyed. +* slab_cache is assigned only after device_lock and the hash +* lists exist; earlier abort paths have nothing to drain. +*/ +if (conf->slab_cache) { +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) +INIT_LIST_HEAD (&temp[i]); + +spin_lock_irq (&conf->device_lock); +release_stripe_list (conf, temp); +spin_unlock_irq (&conf->device_lock); + +for (i =0 ; i <NR_STRIPE_HASH_LOCKS ; i++) { +if (list_empty (&temp[i])) +continue ; +spin_lock_irq (conf->hash_locks + i); +if (list_empty (conf->inactive_list + i)) +atomic_dec (&conf->empty_inactive_list_nr); +list_splice_tail_init (&temp[i], + conf->inactive_list + i); +spin_unlock_irq (conf->hash_locks + i); + } + } +while (conf->max_nr_stripes &&drop_one_stripe (conf)) ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/1848 dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit ca9a67831805dc788407a05f276abb6b86b1174d ]
On the H6 SoC, the Video Engine has two memory ports, thus two IOMMU connections. The secondary one that is missing is likely used for reading reference frames. The newer H616 is the same. On the other hand, the D1 only has one memory port.
Add the missing IOMMU connection for the Video Engine.
--- .../allwinner,sun4i-a10-video-engine.yaml | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/media/allwinner,sun4i-a10-video-engine.yaml +20 -1
@@ -48,7 +48,10 @@ properties: description: Phandle to the device SRAM iommus: - maxItems: 1 + minItems: 1 + items: + - description: VE port on IOMMU + - description: VE_R port on IOMMU memory-region: description:
@@ -64,6 +67,22 @@ required: - resets - allwinner,sram +allOf: + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h6-video-engine + then: + properties: + iommus: + minItems: 2 + else: + properties: + iommus: + maxItems: 1 + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/1848 .gitignore: ignore only top-level modules.builtin
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Masahiro Yamada <[email protected]>
[ Upstream commit 40cb020305f40bafc2a13c7e879a33dbbd607507 ]
modules.builtin used to be created in every directory.
Since commit 8b41fc4454e3 ("kbuild: create modules.builtin without Makefile.modbuiltin or tristate.conf"), modules.builtin is created only in the top directory.
Add the '/' prefix so that it matches to only the modules.builtin located in the top directory.
It has been more than one year since that change. I hope this will not flood 'Untracked files' of 'git status'.
Stable-dep-of: a7d32fa14bc7 (".gitignore: drop Module.markers")
--- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
.gitignore +1 -1
@@ -46,7 +46,6 @@ *.xz *.zst Module.symvers -modules.builtin modules.order #
@@ -63,6 +62,7 @@ modules.order /vmlinuz /System.map /Module.markers +/modules.builtin /modules.builtin.modinfo /modules.nsdeps
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/1848 .gitignore: drop Module.markers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Stancek <[email protected]>
[ Upstream commit a7d32fa14bc74d1786a2f0513b6f0815bd4be311 ]
commit fc5377668c3d ("tracing: Remove markers") deleted the marker code and the modpost output. Follow-up commit 8723eaeff59a ("Kbuild: clean up marker") removed it from clean and mrproper targets. Both are from 2009, so the file is hopefully no longer in anyone's tree, drop it from .gitignore as well.
--- .gitignore | 1 - 1 file changed, 1 deletion(-)
.gitignore +0 -1
@@ -61,7 +61,6 @@ modules.order /vmlinux-gdb.py /vmlinuz /System.map -/Module.markers /modules.builtin /modules.builtin.modinfo /modules.nsdeps
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/1848 power: supply: ab8500_btemp: Fix event temperature reporting
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 95990cda8e42dda4bd3f1475d578323981bd8579 ]
The event-aware path initializes its local temperature to zero and compares that zero against the thermal thresholds. Consequently some events report the measured temperature after it crosses the event threshold, while others always report the threshold.
Start with the measured temperature, clamp it according to the active event, and convert to tenths of a degree only once. This path is used by AB8505 and later variants.
--- drivers/power/supply/ab8500_btemp.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/power/supply/ab8500_btemp.c +9 -19
@@ -756,39 +756,29 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,*/ int ab8500_btemp_get_temp (struct ab8500_btemp *di) { -int temp =0 ; +int temp = di->bat_temp;/* * The BTEMP events are not reliabe on AB8500 cut3.3 * and prior versions */ -if (is_ab8500_3p3_or_earlier (di->parent)) { - temp = di->bat_temp *10 ; - }else { +if (!is_ab8500_3p3_or_earlier (di->parent)) {if (di->events.btemp_low) {if (temp > di->btemp_ranges.btemp_low_limit) - temp = di->btemp_ranges.btemp_low_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_low_limit; }else if (di->events.btemp_high) {if (temp < di->btemp_ranges.btemp_high_limit) - temp = di->btemp_ranges.btemp_high_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_high_limit; }else if (di->events.btemp_lowmed) {if (temp > di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; }else if (di->events.btemp_medhigh) {if (temp < di->btemp_ranges.btemp_med_limit) - temp = di->btemp_ranges.btemp_med_limit *10 ; -else - temp = di->bat_temp *10 ; - }else - temp = di->bat_temp *10 ; + temp = di->btemp_ranges.btemp_med_limit; + } } -return temp; + +return temp *10 ; }EXPORT_SYMBOL (ab8500_btemp_get_temp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/1848 power: supply: Fix missing IRQF_ONESHOT as only threaded handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tian Tao <[email protected]>
[ Upstream commit df12470ce775cd126f26c96d240959b0c1929e23 ]
Coccinelle noticed:
drivers/power/supply/ab8500_btemp.c:1107:8-28: ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500_btemp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ab8500_btemp.c +1 -1
@@ -1093,7 +1093,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) } ret =request_threaded_irq (irq,NULL , ab8500_btemp_irq[i].isr, -IRQF_SHARED |IRQF_NO_SUSPEND , +IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , ab8500_btemp_irq[i].name, di);if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/1848 power: supply: ab8500: Use local helper
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ad89cb5f0a1ffad6ae9ba277f99fea830d135e7c ]
Use a local "dev" helper variable to make the probe() code easier to read in the ab8500 subdrivers.
Drop out-of-memory messages as these should come from the slab core.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500_btemp.c | 37 +++++++++--------- drivers/power/supply/ab8500_charger.c | 55 +++++++++++++-------------- drivers/power/supply/ab8500_fg.c | 39 +++++++++---------- 3 files changed, 64 insertions(+), 67 deletions(-)
drivers/power/supply/ab8500_btemp.c +18 -19
@@ -987,47 +987,46 @@ static int ab8500_btemp_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config psy_cfg = {}; +struct device *dev = &pdev->dev;struct ab8500_btemp *di;int irq, i, ret =0 ;u8 val; - di =devm_kzalloc (&pdev->dev,sizeof (*di),GFP_KERNEL ); -if (!di) { -dev_err (&pdev->dev,"%s no mem for ab8500_btemp\n" , __func__); + di =devm_kzalloc (dev,sizeof (*di),GFP_KERNEL ); +if (!di)return -ENOMEM ; - }if (!plat) { -dev_err (&pdev->dev,"no battery management data supplied\n" ); +dev_err (dev,"no battery management data supplied\n" );return -EINVAL ; } di->bm = plat;if (np) { - ret =ab8500_bm_of_probe (&pdev->dev, np, di->bm); + ret =ab8500_bm_of_probe (dev, np, di->bm);if (ret) { -dev_err (&pdev->dev,"failed to get battery information\n" ); +dev_err (dev,"failed to get battery information\n" );return ret; } }/* get parent data */ - di->dev = &pdev->dev; + di->dev = dev; di->parent =dev_get_drvdata (pdev->dev.parent);/* Get ADC channels */ - di->btemp_ball =devm_iio_channel_get (&pdev->dev,"btemp_ball" ); + di->btemp_ball =devm_iio_channel_get (dev,"btemp_ball" );if (IS_ERR (di->btemp_ball)) {if (PTR_ERR (di->btemp_ball) == -ENODEV )return -EPROBE_DEFER ; -dev_err (&pdev->dev,"failed to get BTEMP BALL ADC channel\n" ); +dev_err (dev,"failed to get BTEMP BALL ADC channel\n" );return PTR_ERR (di->btemp_ball); } - di->bat_ctrl =devm_iio_channel_get (&pdev->dev,"bat_ctrl" ); + di->bat_ctrl =devm_iio_channel_get (dev,"bat_ctrl" );if (IS_ERR (di->bat_ctrl)) {if (PTR_ERR (di->bat_ctrl) == -ENODEV )return -EPROBE_DEFER ; -dev_err (&pdev->dev,"failed to get BAT CTRL ADC channel\n" ); +dev_err (dev,"failed to get BAT CTRL ADC channel\n" );return PTR_ERR (di->bat_ctrl); }
@@ -1041,7 +1040,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev) di->btemp_wq =alloc_workqueue ("ab8500_btemp_wq" ,WQ_MEM_RECLAIM ,0 );if (di->btemp_wq ==NULL ) { -dev_err (di->dev,"failed to create work queue\n" ); +dev_err (dev,"failed to create work queue\n" );return -ENOMEM ; }
@@ -1053,10 +1052,10 @@ static int ab8500_btemp_probe(struct platform_device *pdev) di->btemp_ranges.btemp_low_limit =BTEMP_THERMAL_LOW_LIMIT ; di->btemp_ranges.btemp_med_limit =BTEMP_THERMAL_MED_LIMIT ; - ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , + ret =abx500_get_register_interruptible (dev,AB8500_CHARGER ,AB8500_BTEMP_HIGH_TH , &val);if (ret <0 ) { -dev_err (di->dev,"%s ab8500 read failed\n" , __func__); +dev_err (dev,"%s ab8500 read failed\n" , __func__); goto free_btemp_wq; }switch (val) {
@@ -1076,10 +1075,10 @@ static int ab8500_btemp_probe(struct platform_device *pdev) }/* Register BTEMP power supply class */ - di->btemp_psy =power_supply_register (di->dev, &ab8500_btemp_desc, + di->btemp_psy =power_supply_register (dev, &ab8500_btemp_desc, &psy_cfg);if (IS_ERR (di->btemp_psy)) { -dev_err (di->dev,"failed to register BTEMP psy\n" ); +dev_err (dev,"failed to register BTEMP psy\n" ); ret =PTR_ERR (di->btemp_psy); goto free_btemp_wq; }
@@ -1097,11 +1096,11 @@ static int ab8500_btemp_probe(struct platform_device *pdev) ab8500_btemp_irq[i].name, di);if (ret) { -dev_err (di->dev,"failed to request %s IRQ %d: %d\n" +dev_err (dev,"failed to request %s IRQ %d: %d\n" , ab8500_btemp_irq[i].name, irq, ret); goto free_irq; } -dev_dbg (di->dev,"Requested %s IRQ %d: %d\n" , +dev_dbg (dev,"Requested %s IRQ %d: %d\n" , ab8500_btemp_irq[i].name, irq, ret); }
drivers/power/supply/ab8500_charger.c +27 -28
159 lines not on this page · raw message
drivers/power/supply/ab8500_fg.c +19 -20
@@ -3044,26 +3044,25 @@ static int ab8500_fg_probe(struct platform_device *pdev)struct device_node *np = pdev->dev.of_node;struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config psy_cfg = {}; +struct device *dev = &pdev->dev;struct ab8500_fg *di;int i, irq;int ret =0 ; - di =devm_kzalloc (&pdev->dev,sizeof (*di),GFP_KERNEL ); -if (!di) { -dev_err (&pdev->dev,"%s no mem for ab8500_fg\n" , __func__); + di =devm_kzalloc (dev,sizeof (*di),GFP_KERNEL ); +if (!di)return -ENOMEM ; - }if (!plat) { -dev_err (&pdev->dev,"no battery management data supplied\n" ); +dev_err (dev,"no battery management data supplied\n" );return -EINVAL ; } di->bm = plat;if (np) { - ret =ab8500_bm_of_probe (&pdev->dev, np, di->bm); + ret =ab8500_bm_of_probe (dev, np, di->bm);if (ret) { -dev_err (&pdev->dev,"failed to get battery information\n" ); +dev_err (dev,"failed to get battery information\n" );return ret; } }
@@ -3071,14 +3070,14 @@ static int ab8500_fg_probe(struct platform_device *pdev)mutex_init (&di->cc_lock);/* get parent data */ - di->dev = &pdev->dev; + di->dev = dev; di->parent =dev_get_drvdata (pdev->dev.parent); - di->main_bat_v =devm_iio_channel_get (&pdev->dev,"main_bat_v" ); + di->main_bat_v =devm_iio_channel_get (dev,"main_bat_v" );if (IS_ERR (di->main_bat_v)) {if (PTR_ERR (di->main_bat_v) == -ENODEV )return -EPROBE_DEFER ; -dev_err (&pdev->dev,"failed to get main battery ADC channel\n" ); +dev_err (dev,"failed to get main battery ADC channel\n" );return PTR_ERR (di->main_bat_v); }
@@ -3101,7 +3100,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)/* Create a work queue for running the FG algorithm */ di->fg_wq =alloc_ordered_workqueue ("ab8500_fg_wq" ,WQ_MEM_RECLAIM );if (di->fg_wq ==NULL ) { -dev_err (di->dev,"failed to create work queue\n" ); +dev_err (dev,"failed to create work queue\n" );return -ENOMEM ; }
@@ -3136,7 +3135,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)/* Initialize OVV, and other registers */ ret =ab8500_fg_init_hw_registers (di);if (ret) { -dev_err (di->dev,"failed to initialize registers\n" ); +dev_err (dev,"failed to initialize registers\n" ); goto free_inst_curr_wq; }
@@ -3145,9 +3144,9 @@ static int ab8500_fg_probe(struct platform_device *pdev) di->flags.batt_id_received = false;/* Register FG power supply class */ - di->fg_psy =power_supply_register (di->dev, &ab8500_fg_desc, &psy_cfg); + di->fg_psy =power_supply_register (dev, &ab8500_fg_desc, &psy_cfg);if (IS_ERR (di->fg_psy)) { -dev_err (di->dev,"failed to register FG psy\n" ); +dev_err (dev,"failed to register FG psy\n" ); ret =PTR_ERR (di->fg_psy); goto free_inst_curr_wq; }
@@ -3175,11 +3174,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) ab8500_fg_irq_th[i].name, di);if (ret !=0 ) { -dev_err (di->dev,"failed to request %s IRQ %d: %d\n" , +dev_err (dev,"failed to request %s IRQ %d: %d\n" , ab8500_fg_irq_th[i].name, irq, ret); goto free_irq_th; } -dev_dbg (di->dev,"Requested %s IRQ %d: %d\n" , +dev_dbg (dev,"Requested %s IRQ %d: %d\n" , ab8500_fg_irq_th[i].name, irq, ret); }
@@ -3195,11 +3194,11 @@ static int ab8500_fg_probe(struct platform_device *pdev) ab8500_fg_irq_bh[0].name, di);if (ret !=0 ) { -dev_err (di->dev,"failed to request %s IRQ %d: %d\n" , +dev_err (dev,"failed to request %s IRQ %d: %d\n" , ab8500_fg_irq_bh[0 ].name, irq, ret); goto free_irq_th; } -dev_dbg (di->dev,"Requested %s IRQ %d: %d\n" , +dev_dbg (dev,"Requested %s IRQ %d: %d\n" , ab8500_fg_irq_bh[0 ].name, irq, ret); di->irq =platform_get_irq_byname (pdev,"CCEOC" );
@@ -3210,13 +3209,13 @@ static int ab8500_fg_probe(struct platform_device *pdev) ret =ab8500_fg_sysfs_init (di);if (ret) { -dev_err (di->dev,"failed to create sysfs entry\n" ); +dev_err (dev,"failed to create sysfs entry\n" ); goto free_irq; } ret =ab8500_fg_sysfs_psy_create_attrs (di);if (ret) { -dev_err (di->dev,"failed to create FG psy\n" ); +dev_err (dev,"failed to create FG psy\n" );ab8500_fg_sysfs_exit (di); goto free_irq; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/1848 power: supply: ab8500: Convert to dev_pm_ops
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit f8efa0a881e2504d55a1d8d9e8dff847a378d717 ]
Switch over to using generic dev_pm_ops since these drivers aren't even using the special power state passed to the legacy call.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500_btemp.c | 19 +++++++------------ drivers/power/supply/ab8500_charger.c | 19 +++++++------------ drivers/power/supply/ab8500_fg.c | 19 +++++++------------ drivers/power/supply/abx500_chargalg.c | 19 +++++++------------ 4 files changed, 28 insertions(+), 48 deletions(-)
drivers/power/supply/ab8500_btemp.c +7 -12
@@ -924,29 +924,23 @@ static struct ab8500_btemp_interrupts ab8500_btemp_irq[] = { {"BTEMP_MEDIUM_HIGH", ab8500_btemp_medhigh_handler}, }; -#if defined(CONFIG_PM ) -static int ab8500_btemp_resume (struct platform_device *pdev) +static int __maybe_unused ab8500_btemp_resume (struct device *dev) { -struct ab8500_btemp *di =platform_get_drvdata (pdev); +struct ab8500_btemp *di =dev_get_drvdata (dev);ab8500_btemp_periodic (di, true);return 0 ; } -static int ab8500_btemp_suspend (struct platform_device *pdev, -pm_message_t state) +static int __maybe_unused ab8500_btemp_suspend (struct device *dev) { -struct ab8500_btemp *di =platform_get_drvdata (pdev); +struct ab8500_btemp *di =dev_get_drvdata (dev);ab8500_btemp_periodic (di, false);return 0 ; } -#else -#define ab8500_btemp_suspend NULL -#define ab8500_btemp_resume NULL -#endif static int ab8500_btemp_remove (struct platform_device *pdev) {
@@ -1125,6 +1119,8 @@ static int ab8500_btemp_probe(struct platform_device *pdev)return ret; } +static SIMPLE_DEV_PM_OPS(ab8500_btemp_pm_ops, ab8500_btemp_suspend, ab8500_btemp_resume); +static const struct of_device_id ab8500_btemp_match[] = { { .compatible ="stericsson,ab8500-btemp" , }, { },
@@ -1134,11 +1130,10 @@ MODULE_DEVICE_TABLE(of, ab8500_btemp_match);static struct platform_driver ab8500_btemp_driver = { .probe = ab8500_btemp_probe, .remove = ab8500_btemp_remove, - .suspend = ab8500_btemp_suspend, - .resume = ab8500_btemp_resume, .driver = { .name ="ab8500-btemp" , .of_match_table = ab8500_btemp_match, + .pm = &ab8500_btemp_pm_ops, }, };
drivers/power/supply/ab8500_charger.c +7 -12
@@ -3225,11 +3225,10 @@ static int ab8500_charger_usb_notifier_call(struct notifier_block *nb,return NOTIFY_OK ; } -#if defined(CONFIG_PM ) -static int ab8500_charger_resume (struct platform_device *pdev) +static int __maybe_unused ab8500_charger_resume (struct device *dev) {int ret; -struct ab8500_charger *di =platform_get_drvdata (pdev); +struct ab8500_charger *di =dev_get_drvdata (dev);/* * For ABB revision 1.0 and 1.1 there is a bug in the watchdog
@@ -3263,10 +3262,9 @@ static int ab8500_charger_resume(struct platform_device *pdev)return 0 ; } -static int ab8500_charger_suspend (struct platform_device *pdev, -pm_message_t state) +static int __maybe_unused ab8500_charger_suspend (struct device *dev) { -struct ab8500_charger *di =platform_get_drvdata (pdev); +struct ab8500_charger *di =dev_get_drvdata (dev);/* Cancel any pending jobs */ cancel_delayed_work (&di->check_hw_failure_work);
@@ -3288,10 +3286,6 @@ static int ab8500_charger_suspend(struct platform_device *pdev,return 0 ; } -#else -#define ab8500_charger_suspend NULL -#define ab8500_charger_resume NULL -#endif static struct notifier_block charger_nb = { .notifier_call = ab8500_external_charger_prepare,
@@ -3674,6 +3668,8 @@ static int ab8500_charger_probe(struct platform_device *pdev)return ret; } +static SIMPLE_DEV_PM_OPS(ab8500_charger_pm_ops, ab8500_charger_suspend, ab8500_charger_resume); +static const struct of_device_id ab8500_charger_match[] = { { .compatible ="stericsson,ab8500-charger" , }, { },
@@ -3683,11 +3679,10 @@ MODULE_DEVICE_TABLE(of, ab8500_charger_match);static struct platform_driver ab8500_charger_driver = { .probe = ab8500_charger_probe, .remove = ab8500_charger_remove, - .suspend = ab8500_charger_suspend, - .resume = ab8500_charger_resume, .driver = { .name ="ab8500-charger" , .of_match_table = ab8500_charger_match, + .pm = &ab8500_charger_pm_ops, }, };
drivers/power/supply/ab8500_fg.c +7 -12
@@ -2949,10 +2949,9 @@ static void ab8500_fg_sysfs_psy_remove_attrs(struct ab8500_fg *di)/* Exposure to the sysfs interface <<END>> */ -#if defined(CONFIG_PM ) -static int ab8500_fg_resume (struct platform_device *pdev) +static int __maybe_unused ab8500_fg_resume (struct device *dev) { -struct ab8500_fg *di =platform_get_drvdata (pdev); +struct ab8500_fg *di =dev_get_drvdata (dev);/* * Change state if we're not charging. If we're charging we will wake
@@ -2966,10 +2965,9 @@ static int ab8500_fg_resume(struct platform_device *pdev)return 0 ; } -static int ab8500_fg_suspend (struct platform_device *pdev, -pm_message_t state) +static int __maybe_unused ab8500_fg_suspend (struct device *dev) { -struct ab8500_fg *di =platform_get_drvdata (pdev); +struct ab8500_fg *di =dev_get_drvdata (dev);flush_delayed_work (&di->fg_periodic_work);flush_work (&di->fg_work);
@@ -2987,10 +2985,6 @@ static int ab8500_fg_suspend(struct platform_device *pdev,return 0 ; } -#else -#define ab8500_fg_suspend NULL -#define ab8500_fg_resume NULL -#endif static int ab8500_fg_remove (struct platform_device *pdev) {
@@ -3251,6 +3245,8 @@ static int ab8500_fg_probe(struct platform_device *pdev)return ret; } +static SIMPLE_DEV_PM_OPS(ab8500_fg_pm_ops, ab8500_fg_suspend, ab8500_fg_resume); +static const struct of_device_id ab8500_fg_match[] = { { .compatible ="stericsson,ab8500-fg" , }, { },
@@ -3260,11 +3256,10 @@ MODULE_DEVICE_TABLE(of, ab8500_fg_match);static struct platform_driver ab8500_fg_driver = { .probe = ab8500_fg_probe, .remove = ab8500_fg_remove, - .suspend = ab8500_fg_suspend, - .resume = ab8500_fg_resume, .driver = { .name ="ab8500-fg" , .of_match_table = ab8500_fg_match, + .pm = &ab8500_fg_pm_ops, }, };
drivers/power/supply/abx500_chargalg.c +7 -12
@@ -1913,10 +1913,9 @@ static int abx500_chargalg_sysfs_init(struct abx500_chargalg *di) }/* Exposure to the sysfs interface <<END>> */ -#if defined(CONFIG_PM ) -static int abx500_chargalg_resume (struct platform_device *pdev) +static int __maybe_unused abx500_chargalg_resume (struct device *dev) { -struct abx500_chargalg *di =platform_get_drvdata (pdev); +struct abx500_chargalg *di =dev_get_drvdata (dev);/* Kick charger watchdog if charging (any charger online) */ if (di->chg_info.online_chg)
@@ -1931,10 +1930,9 @@ static int abx500_chargalg_resume(struct platform_device *pdev)return 0 ; } -static int abx500_chargalg_suspend (struct platform_device *pdev, -pm_message_t state) +static int __maybe_unused abx500_chargalg_suspend (struct device *dev) { -struct abx500_chargalg *di =platform_get_drvdata (pdev); +struct abx500_chargalg *di =dev_get_drvdata (dev);if (di->chg_info.online_chg)cancel_delayed_work_sync (&di->chargalg_wd_work);
@@ -1943,10 +1941,6 @@ static int abx500_chargalg_suspend(struct platform_device *pdev,return 0 ; } -#else -#define abx500_chargalg_suspend NULL -#define abx500_chargalg_resume NULL -#endif static int abx500_chargalg_remove (struct platform_device *pdev) {
@@ -2080,6 +2074,8 @@ static int abx500_chargalg_probe(struct platform_device *pdev)return ret; } +static SIMPLE_DEV_PM_OPS(abx500_chargalg_pm_ops, abx500_chargalg_suspend, abx500_chargalg_resume); +static const struct of_device_id ab8500_chargalg_match[] = { { .compatible ="stericsson,ab8500-chargalg" , }, { },
@@ -2088,11 +2084,10 @@ static const struct of_device_id ab8500_chargalg_match[] = {static struct platform_driver abx500_chargalg_driver = { .probe = abx500_chargalg_probe, .remove = abx500_chargalg_remove, - .suspend = abx500_chargalg_suspend, - .resume = abx500_chargalg_resume, .driver = { .name ="ab8500-chargalg" , .of_match_table = ab8500_chargalg_match, + .pm = &abx500_chargalg_pm_ops, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/1848 power: supply: ab8500_charger: Oneshot threaded IRQs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 532b623f3c86d5166a8bb8acaa94fc3629d8ba97 ]
Make sure the threaded IRQs requested by the charger are flagged as "oneshot". Usually this is what you want, and since the interrupts are shared with the USB phy on the AB8500 we will get a conflict like this if we don't, since the phy request them threaded oneshot:
genirq: Flags mismatch irq 83. 00004084 (USB_LINK_STATUS
vs. 00006084 (usb-link-status)
ab8500-charger ab8500-charger.0: failed to request
USB_LINK_STATUS IRQ 83: -16
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500_charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/ab8500_charger.c +1 -1
@@ -3612,7 +3612,7 @@ static int ab8500_charger_probe(struct platform_device *pdev) } ret =request_threaded_irq (irq,NULL , ab8500_charger_irq[i].isr, -IRQF_SHARED |IRQF_NO_SUSPEND , +IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , ab8500_charger_irq[i].name, di);if (ret !=0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/1848 power: supply: ab8500_fg: Request all IRQs as threaded
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 807042539d8ed11299c9278e55d2cb6df8d04a39 ]
Since these IRQs are cascaded from a nested IRQ, the generic IRQ system detects this and refuse to deliver a fastpath IRQ in response to request_irq():
nested = irq_settings_is_nested_thread(desc);
if (nested) {
if (!new->thread_fn) {
ret = -EINVAL;
goto out_mput;
}
(...)Threaded IRQs work just as well so let's just request threaded IRQs. One of the IRQs are alread requested as threaded anyways.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500_fg.c | 47 ++++++++------------------------ 1 file changed, 11 insertions(+), 36 deletions(-)
drivers/power/supply/ab8500_fg.c +11 -36
@@ -3008,14 +3008,11 @@ static int ab8500_fg_remove(struct platform_device *pdev) }/* ab8500 fg driver interrupts and their respective isr */ -static struct ab8500_fg_interrupts ab8500_fg_irq_th[] = { +static struct ab8500_fg_interrupts ab8500_fg_irq[] = { {"NCONV_ACCU" , ab8500_fg_cc_convend_handler}, {"BATT_OVV" , ab8500_fg_batt_ovv_handler}, {"LOW_BAT_F" , ab8500_fg_lowbatf_handler}, {"CC_INT_CALIB" , ab8500_fg_cc_int_calib_handler}, -}; - -static struct ab8500_fg_interrupts ab8500_fg_irq_bh[] = { {"CCEOC" , ab8500_fg_cc_data_end_handler}, };
@@ -3156,44 +3153,25 @@ static int ab8500_fg_probe(struct platform_device *pdev)init_completion (&di->ab8500_fg_complete);/* Register primary interrupt handlers */ -for (i =0 ; i <ARRAY_SIZE (ab8500_fg_irq_th); i++) { - irq =platform_get_irq_byname (pdev, ab8500_fg_irq_th[i].name); +for (i =0 ; i <ARRAY_SIZE (ab8500_fg_irq); i++) { + irq =platform_get_irq_byname (pdev, ab8500_fg_irq[i].name);if (irq <0 ) { ret = irq; - goto free_irq_th; + goto free_irq; } - ret =request_irq (irq, ab8500_fg_irq_th[i].isr, -IRQF_SHARED |IRQF_NO_SUSPEND , - ab8500_fg_irq_th[i].name, di); + ret =request_threaded_irq (irq,NULL , ab8500_fg_irq[i].isr, +IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , + ab8500_fg_irq[i].name, di);if (ret !=0 ) {dev_err (dev,"failed to request %s IRQ %d: %d\n" , - ab8500_fg_irq_th[i].name, irq, ret); - goto free_irq_th; + ab8500_fg_irq[i].name, irq, ret); + goto free_irq; }dev_dbg (dev,"Requested %s IRQ %d: %d\n" , - ab8500_fg_irq_th[i].name, irq, ret); - } - -/* Register threaded interrupt handler */ - irq =platform_get_irq_byname (pdev, ab8500_fg_irq_bh[0 ].name); -if (irq <0 ) { - ret = irq; - goto free_irq_th; - } - - ret =request_threaded_irq (irq,NULL , ab8500_fg_irq_bh[0 ].isr, -IRQF_SHARED |IRQF_NO_SUSPEND |IRQF_ONESHOT , - ab8500_fg_irq_bh[0 ].name, di); - -if (ret !=0 ) { -dev_err (dev,"failed to request %s IRQ %d: %d\n" , - ab8500_fg_irq_bh[0 ].name, irq, ret); - goto free_irq_th; + ab8500_fg_irq[i].name, irq, ret); } -dev_dbg (dev,"Requested %s IRQ %d: %d\n" , - ab8500_fg_irq_bh[0 ].name, irq, ret); di->irq =platform_get_irq_byname (pdev,"CCEOC" );disable_irq (di->irq);
@@ -3230,12 +3208,9 @@ static int ab8500_fg_probe(struct platform_device *pdev) free_irq:/* We also have to free all registered irqs */ - irq =platform_get_irq_byname (pdev, ab8500_fg_irq_bh[0 ].name); -free_irq (irq, di); -free_irq_th:while (--i >=0 ) {/* Last assignment of i from primary interrupt handlers */ - irq =platform_get_irq_byname (pdev, ab8500_fg_irq_th[i].name); + irq =platform_get_irq_byname (pdev, ab8500_fg_irq[i].name);free_irq (irq, di); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/1848 mfd: Standardise MFD_CELL_* helper names
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lee Jones <[email protected]>
[ Upstream commit db783e769a950b3f9502dfbc0f7fdbea499a1da6 ]
Start all helpers with "MFD_CELL_".
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/mfd/ab8500-core.c | 42 +++++++++++++++++++------------------- drivers/mfd/db8500-prcmu.c | 6 +++--- drivers/mfd/mt6360-core.c | 12 +++++------ include/linux/mfd/core.h | 6 +++--- 4 files changed, 33 insertions(+), 33 deletions(-)
drivers/mfd/ab8500-core.c +21 -21
@@ -604,52 +604,52 @@ int ab8500_suspend(struct ab8500 *ab8500) }static const struct mfd_cell ab8500_bm_devs[] = { -OF_MFD_CELL ("ab8500-charger" ,NULL , &ab8500_bm_data, +MFD_CELL_OF ("ab8500-charger" ,NULL , &ab8500_bm_data,sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-charger" ), -OF_MFD_CELL ("ab8500-btemp" ,NULL , &ab8500_bm_data, +MFD_CELL_OF ("ab8500-btemp" ,NULL , &ab8500_bm_data,sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-btemp" ), -OF_MFD_CELL ("ab8500-fg" ,NULL , &ab8500_bm_data, +MFD_CELL_OF ("ab8500-fg" ,NULL , &ab8500_bm_data,sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-fg" ), -OF_MFD_CELL ("ab8500-chargalg" ,NULL , &ab8500_bm_data, +MFD_CELL_OF ("ab8500-chargalg" ,NULL , &ab8500_bm_data,sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-chargalg" ), };static const struct mfd_cell ab8500_devs[] = { #ifdef CONFIG_DEBUG_FS -OF_MFD_CELL ("ab8500-debug" , +MFD_CELL_OF ("ab8500-debug" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-debug" ), #endif -OF_MFD_CELL ("ab8500-sysctrl" , +MFD_CELL_OF ("ab8500-sysctrl" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-sysctrl" ), -OF_MFD_CELL ("ab8500-ext-regulator" , +MFD_CELL_OF ("ab8500-ext-regulator" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-ext-regulator" ), -OF_MFD_CELL ("ab8500-regulator" , +MFD_CELL_OF ("ab8500-regulator" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-regulator" ), -OF_MFD_CELL ("ab8500-clk" , +MFD_CELL_OF ("ab8500-clk" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-clk" ), -OF_MFD_CELL ("ab8500-gpadc" , +MFD_CELL_OF ("ab8500-gpadc" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-gpadc" ), -OF_MFD_CELL ("ab8500-rtc" , +MFD_CELL_OF ("ab8500-rtc" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-rtc" ), -OF_MFD_CELL ("ab8500-acc-det" , +MFD_CELL_OF ("ab8500-acc-det" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-acc-det" ), -OF_MFD_CELL ("ab8500-poweron-key" , +MFD_CELL_OF ("ab8500-poweron-key" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-poweron-key" ), -OF_MFD_CELL ("ab8500-pwm" , +MFD_CELL_OF ("ab8500-pwm" ,NULL ,NULL ,0 ,1 ,"stericsson,ab8500-pwm" ), -OF_MFD_CELL ("ab8500-pwm" , +MFD_CELL_OF ("ab8500-pwm" ,NULL ,NULL ,0 ,2 ,"stericsson,ab8500-pwm" ), -OF_MFD_CELL ("ab8500-pwm" , +MFD_CELL_OF ("ab8500-pwm" ,NULL ,NULL ,0 ,3 ,"stericsson,ab8500-pwm" ), -OF_MFD_CELL ("ab8500-denc" , +MFD_CELL_OF ("ab8500-denc" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-denc" ), -OF_MFD_CELL ("pinctrl-ab8500" , +MFD_CELL_OF ("pinctrl-ab8500" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-gpio" ), -OF_MFD_CELL ("abx500-temp" , +MFD_CELL_OF ("abx500-temp" ,NULL ,NULL ,0 ,0 ,"stericsson,abx500-temp" ), -OF_MFD_CELL ("ab8500-usb" , +MFD_CELL_OF ("ab8500-usb" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-usb" ), -OF_MFD_CELL ("ab8500-codec" , +MFD_CELL_OF ("ab8500-codec" ,NULL ,NULL ,0 ,0 ,"stericsson,ab8500-codec" ), };
drivers/mfd/db8500-prcmu.c +3 -3
@@ -2952,12 +2952,12 @@ static const struct mfd_cell common_prcmu_devs[] = { };static const struct mfd_cell db8500_prcmu_devs[] = { -OF_MFD_CELL ("db8500-prcmu-regulators" ,NULL , +MFD_CELL_OF ("db8500-prcmu-regulators" ,NULL , &db8500_regulators,sizeof (db8500_regulators),0 ,"stericsson,db8500-prcmu-regulator" ), -OF_MFD_CELL ("cpuidle-dbx500" , +MFD_CELL_OF ("cpuidle-dbx500" ,NULL ,NULL ,0 ,0 ,"stericsson,cpuidle-dbx500" ), -OF_MFD_CELL ("db8500-thermal" , +MFD_CELL_OF ("db8500-thermal" ,NULL ,NULL ,0 ,0 ,"stericsson,db8500-thermal" ), };
drivers/mfd/mt6360-core.c +6 -6
@@ -292,17 +292,17 @@ static const struct resource mt6360_ldo_resources[] = { };static const struct mfd_cell mt6360_devs[] = { -OF_MFD_CELL ("mt6360_adc" , mt6360_adc_resources, +MFD_CELL_OF ("mt6360_adc" , mt6360_adc_resources,NULL ,0 ,0 ,"mediatek,mt6360_adc" ), -OF_MFD_CELL ("mt6360_chg" , mt6360_chg_resources, +MFD_CELL_OF ("mt6360_chg" , mt6360_chg_resources,NULL ,0 ,0 ,"mediatek,mt6360_chg" ), -OF_MFD_CELL ("mt6360_led" , mt6360_led_resources, +MFD_CELL_OF ("mt6360_led" , mt6360_led_resources,NULL ,0 ,0 ,"mediatek,mt6360_led" ), -OF_MFD_CELL ("mt6360_pmic" , mt6360_pmic_resources, +MFD_CELL_OF ("mt6360_pmic" , mt6360_pmic_resources,NULL ,0 ,0 ,"mediatek,mt6360_pmic" ), -OF_MFD_CELL ("mt6360_ldo" , mt6360_ldo_resources, +MFD_CELL_OF ("mt6360_ldo" , mt6360_ldo_resources,NULL ,0 ,0 ,"mediatek,mt6360_ldo" ), -OF_MFD_CELL ("mt6360_tcpc" ,NULL , +MFD_CELL_OF ("mt6360_tcpc" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6360_tcpc" ), };
include/linux/mfd/core.h +3 -3
@@ -28,13 +28,13 @@ .id = (_id), \ } -#define OF_MFD_CELL_REG (_name, _res, _pdata, _pdsize, _id, _compat, _of_reg) \ +#define MFD_CELL_OF_REG (_name, _res, _pdata, _pdsize, _id, _compat, _of_reg) \ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, _of_reg, true, NULL) -#define OF_MFD_CELL (_name, _res, _pdata, _pdsize, _id, _compat) \ +#define MFD_CELL_OF (_name, _res, _pdata, _pdsize, _id, _compat) \ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, _compat, 0, false, NULL) -#define ACPI_MFD_CELL (_name, _res, _pdata, _pdsize, _id, _match) \ +#define MFD_CELL_ACPI (_name, _res, _pdata, _pdsize, _id, _match) \ MFD_CELL_ALL(_name, _res, _pdata, _pdsize, _id, NULL, 0, false, _match)#define MFD_CELL_BASIC (_name, _res, _pdata, _pdsize, _id) \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1460/1848 power: ab8500: Require device tree
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 53207aa1a73e3e52b14c432b04d342c2b3af2e1c ]
The core AB8500 driver and the whole platform is completely dependent on being probed from device tree so remove the non-DT probe paths.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/Kconfig | 2 +- drivers/power/supply/ab8500_btemp.c | 10 ++++------ drivers/power/supply/ab8500_charger.c | 15 ++++++--------- drivers/power/supply/ab8500_fg.c | 10 ++++------ drivers/power/supply/abx500_chargalg.c | 10 ++++------ 5 files changed, 19 insertions(+), 28 deletions(-)
drivers/power/supply/Kconfig +1 -1
@@ -678,7 +678,7 @@ config BATTERY_GAUGE_LTC2941 config AB8500_BM bool "AB8500 Battery Management Driver" - depends on AB8500_CORE && AB8500_GPADC && (IIO = y) + depends on AB8500_CORE && AB8500_GPADC && (IIO = y) && OF help Say Y to include support for AB8500 battery management.
drivers/power/supply/ab8500_btemp.c +4 -6
@@ -996,12 +996,10 @@ static int ab8500_btemp_probe(struct platform_device *pdev) } di->bm = plat; -if (np) { - ret =ab8500_bm_of_probe (dev, np, di->bm); -if (ret) { -dev_err (dev,"failed to get battery information\n" ); -return ret; - } + ret =ab8500_bm_of_probe (dev, np, di->bm); +if (ret) { +dev_err (dev,"failed to get battery information\n" ); +return ret; }/* get parent data */
drivers/power/supply/ab8500_charger.c +6 -9
@@ -3376,15 +3376,12 @@ static int ab8500_charger_probe(struct platform_device *pdev) } di->bm = plat; -if (np) { - ret =ab8500_bm_of_probe (dev, np, di->bm); -if (ret) { -dev_err (dev,"failed to get battery information\n" ); -return ret; - } - di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); - }else - di->autopower_cfg = false; + ret =ab8500_bm_of_probe (dev, np, di->bm); +if (ret) { +dev_err (dev,"failed to get battery information\n" ); +return ret; + } + di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" );/* get parent data */ di->dev = dev;
drivers/power/supply/ab8500_fg.c +4 -6
@@ -3050,12 +3050,10 @@ static int ab8500_fg_probe(struct platform_device *pdev) } di->bm = plat; -if (np) { - ret =ab8500_bm_of_probe (dev, np, di->bm); -if (ret) { -dev_err (dev,"failed to get battery information\n" ); -return ret; - } + ret =ab8500_bm_of_probe (dev, np, di->bm); +if (ret) { +dev_err (dev,"failed to get battery information\n" ); +return ret; }mutex_init (&di->cc_lock);
drivers/power/supply/abx500_chargalg.c +4 -6
@@ -1997,12 +1997,10 @@ static int abx500_chargalg_probe(struct platform_device *pdev) } di->bm = plat; -if (np) { - ret =ab8500_bm_of_probe (&pdev->dev, np, di->bm); -if (ret) { -dev_err (&pdev->dev,"failed to get battery information\n" ); -return ret; - } + ret =ab8500_bm_of_probe (&pdev->dev, np, di->bm); +if (ret) { +dev_err (&pdev->dev,"failed to get battery information\n" ); +return ret; }/* get device struct and parent */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1461/1848 mfd/power: ab8500: Push data to power supply code
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 417c0fc24dd4dbd60d94fa8deb36bf1176930e06 ]
The global definition of platform data for the battery management code has no utility after the OF conversion, move the <linux/mfd/abx500/ab8500-bm.h> to be a local file in drivers/power/supply and stop defining the platform data in drivers/power/supply/ab8500_bmdata.c and broadcast to the kernel only to have it assigned as platform data to the MFD cells and then picked back into the same subsystem that defined it in the first place. This kills off a layer of indirection.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
---
drivers/mfd/ab8500-core.c | 17 +++++----
.../power/supply}/ab8500-bm.h | 19 ++--------
drivers/power/supply/ab8500_bmdata.c | 3 +-
drivers/power/supply/ab8500_btemp.c | 35 +++----------------
drivers/power/supply/ab8500_charger.c | 10 ++----
drivers/power/supply/ab8500_fg.c | 10 ++----
drivers/power/supply/abx500_chargalg.c | 10 ++----
drivers/power/supply/pm2301_charger.c | 2 +-
8 files changed, 27 insertions(+), 79 deletions(-)
rename {include/linux/mfd/abx500 => drivers/power/supply}/ab8500-bm.h (96%)drivers/mfd/ab8500-core.c +8 -9
@@ -19,7 +19,6 @@#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/mfd/dbx500-prcmu.h> #include <linux/regulator/ab8500.h> #include <linux/of.h>
@@ -604,14 +603,14 @@ int ab8500_suspend(struct ab8500 *ab8500) }static const struct mfd_cell ab8500_bm_devs[] = { -MFD_CELL_OF ("ab8500-charger" ,NULL , &ab8500_bm_data, -sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-charger" ), -MFD_CELL_OF ("ab8500-btemp" ,NULL , &ab8500_bm_data, -sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-btemp" ), -MFD_CELL_OF ("ab8500-fg" ,NULL , &ab8500_bm_data, -sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-fg" ), -MFD_CELL_OF ("ab8500-chargalg" ,NULL , &ab8500_bm_data, -sizeof (ab8500_bm_data),0 ,"stericsson,ab8500-chargalg" ), +MFD_CELL_OF ("ab8500-charger" ,NULL ,NULL ,0 ,0 , +"stericsson,ab8500-charger" ), +MFD_CELL_OF ("ab8500-btemp" ,NULL ,NULL ,0 ,0 , +"stericsson,ab8500-btemp" ), +MFD_CELL_OF ("ab8500-fg" ,NULL ,NULL ,0 ,0 , +"stericsson,ab8500-fg" ), +MFD_CELL_OF ("ab8500-chargalg" ,NULL ,NULL ,0 ,0 , +"stericsson,ab8500-chargalg" ), };static const struct mfd_cell ab8500_devs[] = {
drivers/power/supply/ab8500-bm.h renamed from include/linux/mfd/abx500/ab8500-bm.h +3 -16
@@ -1,12 +1,7 @@/* SPDX-License-Identifier: GPL-2.0-only */ -/* -* Copyright ST-Ericsson 2012. -* -* Author: Arun Murthy <[email protected]> -*/ -#ifndef _AB8500_BM_H -#define _AB8500_BM_H +#ifndef _AB8500_CHARGER_H_ +#define _AB8500_CHARGER_H_#include <linux/kernel.h> #include <linux/mfd/abx500.h>
@@ -453,16 +448,11 @@ struct ab8500_bm_data { };struct ab8500_btemp ; -struct ab8500_gpadc ;struct ab8500_fg ; -#ifdef CONFIG_AB8500_BM extern struct abx500_bm_data ab8500_bm_data;void ab8500_charger_usb_state_changed (u8 bm_usb_state,u16 mA); -struct ab8500_btemp *ab8500_btemp_get (void ); -int ab8500_btemp_get_batctrl_temp (struct ab8500_btemp *btemp); -int ab8500_btemp_get_temp (struct ab8500_btemp *btemp);struct ab8500_fg *ab8500_fg_get (void );int ab8500_fg_inst_curr_blocking (struct ab8500_fg *dev);int ab8500_fg_inst_curr_start (struct ab8500_fg *di);
@@ -470,7 +460,4 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);int ab8500_fg_inst_curr_started (struct ab8500_fg *di);int ab8500_fg_inst_curr_done (struct ab8500_fg *di); -#else -static struct abx500_bm_data ab8500_bm_data; -#endif -#endif /* _AB8500_BM_H */ +#endif /* _AB8500_CHARGER_H_ */
drivers/power/supply/ab8500_bmdata.c +2 -1
@@ -4,7 +4,8 @@#include <linux/of.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/abx500/ab8500-bm.h> + +#include "ab8500-bm.h" /* * These are the defined batteries that uses a NTC and ID resistor placed
drivers/power/supply/ab8500_btemp.c +4 -31
@@ -25,9 +25,10 @@#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/iio/consumer.h> +#include "ab8500-bm.h" +#define VTVOUT_V 1800#define BTEMP_THERMAL_LOW_LIMIT -10
@@ -119,16 +120,6 @@ static enum power_supply_property ab8500_btemp_props[] = {static LIST_HEAD (ab8500_btemp_list); -/** -* ab8500_btemp_get() - returns a reference to the primary AB8500 BTEMP -* (i.e. the first BTEMP in the instance list) -*/ -struct ab8500_btemp *ab8500_btemp_get (void ) -{ - return list_first_entry(&ab8500_btemp_list, struct ab8500_btemp, node); -} -EXPORT_SYMBOL (ab8500_btemp_get); -/** * ab8500_btemp_batctrl_volt_to_res() - convert batctrl voltage to resistance * @di: pointer to the ab8500_btemp structure
@@ -754,7 +745,7 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,* * Returns battery temperature */ -int ab8500_btemp_get_temp (struct ab8500_btemp *di) +static int ab8500_btemp_get_temp (struct ab8500_btemp *di) {int temp = di->bat_temp;
@@ -780,19 +771,6 @@ int ab8500_btemp_get_temp(struct ab8500_btemp *di)return temp *10 ; } -EXPORT_SYMBOL (ab8500_btemp_get_temp); - -/** -* ab8500_btemp_get_batctrl_temp() - get the temperature -* @btemp: pointer to the btemp structure -* -* Returns the batctrl temperature in millidegrees -*/ -int ab8500_btemp_get_batctrl_temp (struct ab8500_btemp *btemp) -{ -return btemp->bat_temp *1000 ; -} -EXPORT_SYMBOL (ab8500_btemp_get_batctrl_temp);/** * ab8500_btemp_get_property() - get the btemp properties
@@ -979,7 +957,6 @@ static const struct power_supply_desc ab8500_btemp_desc = {static int ab8500_btemp_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config psy_cfg = {};struct device *dev = &pdev->dev;struct ab8500_btemp *di;
@@ -990,11 +967,7 @@ static int ab8500_btemp_probe(struct platform_device *pdev)if (!di)return -ENOMEM ; -if (!plat) { -dev_err (dev,"no battery management data supplied\n" ); -return -EINVAL ; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret =ab8500_bm_of_probe (dev, np, di->bm);if (ret) {
drivers/power/supply/ab8500_charger.c +3 -7
@@ -28,12 +28,13 @@#include <linux/mfd/core.h> #include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/usb/otg.h> #include <linux/mutex.h> #include <linux/iio/consumer.h> +#include "ab8500-bm.h" +/* Charger constants */ #define NO_PW_CONN 0#define AC_PW_CONN 1
@@ -3360,7 +3361,6 @@ static const struct power_supply_desc ab8500_usb_chg_desc = {static int ab8500_charger_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config ac_psy_cfg = {}, usb_psy_cfg = {};struct ab8500_charger *di;int irq, i, charger_status, ret =0 , ch_stat;
@@ -3370,11 +3370,7 @@ static int ab8500_charger_probe(struct platform_device *pdev)if (!di)return -ENOMEM ; -if (!plat) { -dev_err (dev,"no battery management data supplied\n" ); -return -EINVAL ; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret =ab8500_bm_of_probe (dev, np, di->bm);if (ret) {
drivers/power/supply/ab8500_fg.c +3 -7
@@ -31,10 +31,11 @@#include <linux/mfd/core.h> #include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/iio/consumer.h> #include <linux/kernel.h> +#include "ab8500-bm.h" +#define MILLI_TO_MICRO 1000#define FG_LSB_IN_MA 1627#define QLSB_NANO_AMP_HOURS_X10 1071
@@ -3033,7 +3034,6 @@ static const struct power_supply_desc ab8500_fg_desc = {static int ab8500_fg_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config psy_cfg = {};struct device *dev = &pdev->dev;struct ab8500_fg *di;
@@ -3044,11 +3044,7 @@ static int ab8500_fg_probe(struct platform_device *pdev)if (!di)return -ENOMEM ; -if (!plat) { -dev_err (dev,"no battery management data supplied\n" ); -return -EINVAL ; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret =ab8500_bm_of_probe (dev, np, di->bm);if (ret) {
drivers/power/supply/abx500_chargalg.c +3 -7
@@ -29,9 +29,10 @@#include <linux/mfd/abx500.h> #include <linux/mfd/abx500/ab8500.h> #include <linux/mfd/abx500/ux500_chargalg.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/notifier.h> +#include "ab8500-bm.h" +/* Watchdog kick interval */ #define CHG_WD_INTERVAL (6 * HZ)
@@ -1980,7 +1981,6 @@ static const struct power_supply_desc abx500_chargalg_desc = {static int abx500_chargalg_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct abx500_bm_data *plat = pdev->dev.platform_data;struct power_supply_config psy_cfg = {};struct abx500_chargalg *di;int ret =0 ;
@@ -1991,11 +1991,7 @@ static int abx500_chargalg_probe(struct platform_device *pdev)return -ENOMEM ; } -if (!plat) { -dev_err (&pdev->dev,"no battery management data supplied\n" ); -return -EINVAL ; - } - di->bm = plat; + di->bm = &ab8500_bm_data; ret =ab8500_bm_of_probe (&pdev->dev, np, di->bm);if (ret) {
drivers/power/supply/pm2301_charger.c +1 -1
@@ -18,13 +18,13 @@#include <linux/i2c.h> #include <linux/workqueue.h> #include <linux/mfd/abx500/ab8500.h> -#include <linux/mfd/abx500/ab8500-bm.h> #include <linux/mfd/abx500/ux500_chargalg.h> #include <linux/pm2301_charger.h> #include <linux/gpio.h> #include <linux/pm_runtime.h> #include <linux/pm.h> +#include "ab8500-bm.h" #include "pm2301_charger.h" #define to_pm2xxx_charger_ac_device_info (x) container_of((x), \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1462/1848 power: supply: ab8500: Move to componentized binding
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1c1f13a006ed0d71bb5664c8b7e3e77a28da3beb ]
The driver has problems with the different components of the charging code racing with each other to probe().
This results in all four subdrivers populating battery information to ascertain that it is populated for their own needs for example.
Fix this by using component probing and thus expressing to the kernel that these are dependent components. The probes can happen in any order and will only acquire resources such as state container, regulators and interrupts and initialize the data structures, but no execution happens until the .bind() callback is called.
The charging driver is the main component and binds first, then bind in order the three subcomponents:
ab8500-fg, ab8500-btemp and ab8500-chargalg.
Do some housekeeping while we are moving the code around. Like use devm_* for IRQs so as to cut down on some boilerplate.
Stable-dep-of: 1098c619ce75 ("power: supply: ab8500_charger: Handle detection errors")
--- drivers/power/supply/ab8500-bm.h | 4 + drivers/power/supply/ab8500_btemp.c | 118 ++++----- drivers/power/supply/ab8500_charger.c | 339 ++++++++++++++----------- drivers/power/supply/ab8500_fg.c | 136 +++++----- drivers/power/supply/abx500_chargalg.c | 116 +++++---- 5 files changed, 379 insertions(+), 334 deletions(-)
drivers/power/supply/ab8500-bm.h +4 -0
@@ -460,4 +460,8 @@ int ab8500_fg_inst_curr_finalize(struct ab8500_fg *di, int *res);int ab8500_fg_inst_curr_started (struct ab8500_fg *di);int ab8500_fg_inst_curr_done (struct ab8500_fg *di); +extern struct platform_driver ab8500_fg_driver; +extern struct platform_driver ab8500_btemp_driver; +extern struct platform_driver abx500_chargalg_driver; +#endif /* _AB8500_CHARGER_H_ */
drivers/power/supply/ab8500_btemp.c +51 -67
190 lines not on this page · raw message
drivers/power/supply/ab8500_charger.c +196 -143
467 lines not on this page · raw message
drivers/power/supply/ab8500_fg.c +64 -72
227 lines not on this page · raw message
drivers/power/supply/abx500_chargalg.c +64 -52
194 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1463/1848 power: supply: ab8500_charger: Handle detection errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1098c619ce7595a77a8c2e366a703e9fc5f29bf7 ]
ab8500_charger_detect_chargers() returns either a charger bitmask or a negative register-access error. The probe and component-bind paths use a negative return value as a bitmask, making failed reads appear as both AC and USB connections.
Propagate detection errors and release the bind-time workqueue on failure.
--- drivers/power/supply/ab8500_charger.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/power/supply/ab8500_charger.c +8 -0
@@ -3330,6 +3330,10 @@ static int ab8500_charger_bind(struct device *dev) } ch_stat =ab8500_charger_detect_chargers (di, false); +if (ch_stat <0 ) { +destroy_workqueue (di->charger_wq); +return ch_stat; + }if (ch_stat &AC_PW_CONN ) {if (is_ab8500 (di->parent))
@@ -3618,6 +3622,10 @@ static int ab8500_charger_probe(struct platform_device *pdev)/* Identify the connected charger types during startup */ charger_status =ab8500_charger_detect_chargers (di, true); +if (charger_status <0 ) { + ret = charger_status; + goto remove_ab8500_bm; + }if (charger_status &AC_PW_CONN ) { di->ac.charger_connected =1 ; di->ac_conn = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1464/1848 power: supply: ab8500_fg: Avoid reserved AB8505 CCConf bit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit edafb2e4642b72b0f86ce5990d5c29c116bb642b ]
AB8500 defines CCConf bit 1 as CCDeepSleepEna, but AB8505 reserves bits 7:1 and only defines bit 0, CCPwrUpEna. The fuel-gauge driver currently writes both bits whenever it starts the coulomb counter.
The Samsung-GT-S7710-Skomer and related Samsung product trees use the same unconditional value in their fuel-gauge drivers, so they provide no AB8505 workaround to carry over. Select the value from the detected PMIC variant instead, retaining the deep-sleep enable bit on all existing non-AB8505 paths and avoiding the reserved bit on AB8505.
--- drivers/power/supply/ab8500_fg.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/power/supply/ab8500_fg.c +12 -2
@@ -455,6 +455,16 @@ static void ab8500_fg_fill_cap_sample(struct ab8500_fg *di, int sample) avg->avg = sample; } +static u8 ab8500_fg_cc_config (struct ab8500_fg *di) +{ +u8 config =CC_PWR_UP_ENA ; + +if (!is_ab8505 (di->parent)) + config |=CC_DEEP_SLEEP_ENA ; + +return config; +} +/** * ab8500_fg_coulomb_counter() - enable coulomb counter * @di: pointer to the ab8500_fg structure
@@ -485,7 +495,7 @@ static int ab8500_fg_coulomb_counter(struct ab8500_fg *di, bool enable)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto cc_err;
@@ -559,7 +569,7 @@ int ab8500_fg_inst_curr_start(struct ab8500_fg *di)/* Start the CC */ ret =abx500_set_register_interruptible (di->dev,AB8500_RTC ,AB8500_RTC_CC_CONF_REG , - (CC_DEEP_SLEEP_ENA |CC_PWR_UP_ENA )); +ab8500_fg_cc_config (di));if (ret) goto fail; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1465/1848 arm64: dts: rockchip: Rename rk3328 HDMI audio card
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Detlev Casanova <[email protected]>
[ Upstream commit daa0db717771d43c25d98c2798fa6a7b0252deb7 ]
Rename the card from "HDMI" to "RK3328 HDMI" so it identifies the SoC in user-visible ALSA fields and no longer collides with the identical "HDMI" string used by other Rockchip SoCs.
--- arch/arm64/boot/dts/rockchip/rk3328.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/rockchip/rk3328.dtsi +1 -1
@@ -194,7 +194,7 @@ hdmi_sound: hdmi-sound { compatible = "simple-audio-card"; simple-audio-card,format = "i2s"; simple-audio-card,mclk-fs = <128>; - simple-audio-card,name = "HDMI"; + simple-audio-card,name = "RK3328 HDMI"; status = "disabled"; simple-audio-card,cpu {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1466/1848 arm64: dts: rockchip: add infrared receiver node to RK3399 Firefly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Robinson <[email protected]>
[ Upstream commit 4fab8e3655e476170281884d999c4d758d405fac ]
This adds the RK3399 Firefly’s infrared receiver to its dts.
Stable-dep-of: 23eab1a5e360 ("arm64: dts: rockchip: fix analog headphone output on rk3399-firefly")
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +13 -0
@@ -88,6 +88,13 @@ power { }; }; + ir-receiver { + compatible = "gpio-ir-receiver"; + gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&ir_int>; + pinctrl-names = "default"; + }; + leds { compatible = "gpio-leds"; pinctrl-names = "default";
@@ -572,6 +579,12 @@ pwrbtn: pwrbtn { }; }; + ir { + ir_int: ir-int { + rockchip,pins = <0 RK_PA6 RK_FUNC_GPIO &pcfg_pull_none>; + }; + }; + lcd-panel { lcd_panel_reset: lcd-panel-reset { rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1467/1848 arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 23eab1a5e36099fd1269f8a18dc389e04dc19011 ]
The analog headphone jack on this board has never produced any sound with a mainline kernel.
GPIO4_C5 has to be high for audio to reach the jack. The board file muxes the pin to GPIO through the rt5640_hpcon pinctrl group and references that group from the codec node, but nothing ever requests or drives the line.
Describe it the way rk3399-roc-pc-plus.dts already does something similar, as a simple-audio-amplifier auxiliary component, so that DAPM asserts the GPIO while the headphone path is active.
Measured on a Firefly-RK3399 by toggling only this line while a 1 kHz tone kept playing, with the playback PCM in state: RUNNING throughout:
high -> audible, low -> silent, high -> audible
With this change the line is claimed and follows the audio path:
pin 149 (gpio4-21): headphones-amp gpio4:149
idle: gpio-21 (|enable) out lo
playing: gpio-21 (|enable) out hi
--- .../arm64/boot/dts/rockchip/rk3399-firefly.dts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +14 -4
@@ -88,6 +88,15 @@ power { }; }; + /* GPIO that enables the headphone output path */ + headphones_amp: headphones-amp { + compatible = "simple-audio-amplifier"; + enable-gpios = <&gpio4 RK_PC5 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&rt5640_hpcon>; + sound-name-prefix = "Headphone Amp"; + }; + ir-receiver { compatible = "gpio-ir-receiver"; gpios = <&gpio0 RK_PA6 GPIO_ACTIVE_LOW>;
@@ -124,8 +133,11 @@ rt5640-sound { simple-audio-card,routing = "Mic Jack", "MICBIAS1", "IN1P", "Mic Jack", - "Headphone Jack", "HPOL", - "Headphone Jack", "HPOR"; + "Headphone Amp INL", "HPOL", + "Headphone Amp INR", "HPOR", + "Headphone Jack", "Headphone Amp OUTL", + "Headphone Jack", "Headphone Amp OUTR"; + simple-audio-card,aux-devs = <&headphones_amp>; simple-audio-card,cpu { sound-dai = <&i2s1>;
@@ -506,8 +518,6 @@ rt5640: rt5640@1c { clock-names = "mclk"; realtek,in1-differential; #sound-dai-cells = <0>; - pinctrl-names = "default"; - pinctrl-0 = <&rt5640_hpcon>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1468/1848 arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yaozhong Li <[email protected]>
[ Upstream commit 9416a641cfe5b75dd9178c15960ee741c1091b45 ]
The board file enables i2s0, but no sound card references it: the on-board RT5640 is wired to i2s1 and the S/PDIF transmitter has its own controller. Keeping it enabled starves the other controllers, due to the pl330 instance that serves the audio block only having six channels.
The i2s0 pin groups also lists GPIO4_A0, which carries SCLK_I2S_8CH_OUT, providing the MCLK the codec runs on.
So add the pinmux for the MCLK signal to the i2s1 node.
The RT5640 and S/PDIF cards then register with no DMA errors, and a 1 kHz tone measured through the codec's internal HPOL/HPOR loopback is unchanged (L 2135 -> 2138, R 2202 -> 2203), confirming that MCLK still reaches the codec.
--- arch/arm64/boot/dts/rockchip/rk3399-firefly.dts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts +8 -6
@@ -540,13 +540,9 @@ accelerometer@68 { }; }; -&i2s0 { - rockchip,playback-channels = <8>; - rockchip,capture-channels = <8>; - status = "okay"; -}; - &i2s1 { + pinctrl-names = "default"; + pinctrl-0 = <&i2s_8ch_mclk_pin>, <&i2s1_2ch_bus>; rockchip,playback-channels = <2>; rockchip,capture-channels = <2>; status = "okay";
@@ -595,6 +591,12 @@ ir_int: ir-int { }; }; + i2s1 { + i2s_8ch_mclk_pin: i2s-8ch-mclk-pin { + rockchip,pins = <4 RK_PA0 1 &pcfg_pull_none>; + }; + }; + lcd-panel { lcd_panel_reset: lcd-panel-reset { rockchip,pins = <4 RK_PD6 RK_FUNC_GPIO &pcfg_pull_up>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/1848 cpufreq: sparc-us2e: fix frequency table index copy-paste error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit e5b33fa47792375ca7fc49ccadee87d8e4b72929 ]
In us2e_freq_cpu_init(), the last two frequency writes both use index [2] instead of [3] and [4] respectively, and the terminator uses [3] instead of [5]. This is a copy-paste error where the index was not incremented, causing the divider-6 and divider-8 entries to overwrite the already-written divider-4 entry.
As a result, only three frequency steps (div 1, 2, and 4) are actually available to the cpufreq core, while the intended dividers 6 and 8 are silently lost. The struct us2e_freq_percpu_info::table[6] has room for 5 entries plus a terminator, matching the 5 hardware dividers.
Fix the indices so all five frequency steps are correctly populated:
table[0]=div1, table[1]=div2, table[2]=div4, table[3]=div6, table[4]=div8, table[5]=TABLE_END.
--- drivers/cpufreq/sparc-us2e-cpufreq.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/cpufreq/sparc-us2e-cpufreq.c +5 -6
@@ -284,12 +284,11 @@ static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) table[1 ].frequency = clock_tick /2 ; table[2 ].driver_data =2 ; table[2 ].frequency = clock_tick /4 ; - table[2 ].driver_data =3 ; - table[2 ].frequency = clock_tick /6 ; - table[2 ].driver_data =4 ; - table[2 ].frequency = clock_tick /8 ; - table[2 ].driver_data =5 ; - table[3 ].frequency =CPUFREQ_TABLE_END ; + table[3 ].driver_data =3 ; + table[3 ].frequency = clock_tick /6 ; + table[4 ].driver_data =4 ; + table[4 ].frequency = clock_tick /8 ; + table[5 ].frequency =CPUFREQ_TABLE_END ; policy->cpuinfo.transition_latency =0 ; policy->cur = clock_tick;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/1848 cpufreq: sti: avoid NULL dereference in dev_err()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xueqin Luo <[email protected]>
[ Upstream commit fdbe4cae71c8196cd7681ad47254b5b0560d3c1e ]
ddata.cpu is NULL-checked, then immediately passed to dev_err(). Replace with pr_err() to avoid dereferencing NULL.
--- drivers/cpufreq/sti-cpufreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/cpufreq/sti-cpufreq.c +2 -2
@@ -265,7 +265,7 @@ static int sti_cpufreq_init(void) ddata.cpu =get_cpu_device (0 );if (!ddata.cpu) { -dev_err (ddata.cpu,"Failed to get device for CPU0\n" ); +pr_err ("Failed to get device for CPU0\n" ); goto skip_voltage_scaling; }
@@ -283,7 +283,7 @@ static int sti_cpufreq_init(void) goto register_cpufreq_dt; skip_voltage_scaling: -dev_err (ddata.cpu,"Not doing voltage scaling\n" ); +pr_err ("Not doing voltage scaling\n" ); register_cpufreq_dt:platform_device_register_simple ("cpufreq-dt" ,-1 ,NULL ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/1848 wifi: cfg80211: allow zero HE OBSS PD offsets
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominic White <[email protected]>
[ Upstream commit d9ecaa0a31732014a128e3b03243de54bbbd8394 ]
IEEE Std 802.11 permits the OBSS PD offset fields in the Spatial Reuse Parameter Set element to have a value of zero. (IEEE Std 802.11-2024, 26.10.2.4)
The standard specifies the offsets as unsigned values added to -82 dBm, with field presence signalled independently. The valid offset range is therefore 0..20.
nl80211 currently rejects zero for all three HE OBSS PD offset attributes during nested netlink policy validation, before the values reach cfg80211 or the driver. Allow zero while retaining the upper bound and the existing minimum/maximum relationship validation.
--- net/wireless/nl80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/wireless/nl80211.c +3 -3
@@ -332,11 +332,11 @@ nl80211_pmsr_attr_policy[NL80211_PMSR_ATTR_MAX + 1] = {static const struct nla_policy he_obss_pd_policy[NL80211_HE_OBSS_PD_ATTR_MAX +1 ] = { [NL80211_HE_OBSS_PD_ATTR_MIN_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_MAX_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_NON_SRG_MAX_OFFSET ] = -NLA_POLICY_RANGE (NLA_U8 ,1 ,20 ), +NLA_POLICY_RANGE (NLA_U8 ,0 ,20 ), [NL80211_HE_OBSS_PD_ATTR_BSS_COLOR_BITMAP ] =NLA_POLICY_EXACT_LEN (8 ), [NL80211_HE_OBSS_PD_ATTR_PARTIAL_BSSID_BITMAP] =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1472/1848 wifi: b43: dont pass unterminated string to sscanf()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 9b6cb072f9249e2cdb7c32be2b8069774c7e01e6 ]
The "buf" buffer is a PAGE_SIZE and allocated with kzalloc(). We store a string from the user in it and then pass it to sscanf() in the write functions such as shm32write__write_file(). Only a few numbers are stored in the buffer so it never comes close to filling up the whole PAGE_SIZE. Reserve the last character of the page for a NUL terminator.
This is debugfs so it's root only.
--- drivers/net/wireless/broadcom/b43/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43/debugfs.c +1 -1
@@ -561,7 +561,7 @@ static ssize_t b43_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; dev = file->private_data;if (!dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1473/1848 wifi: b43legacy: debugfs: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit f94595252b318a9ae3c01d78b3bcd33b01b1c082 ]
The "buf" buffer is PAGE_SIZE and allocated with kzalloc(). We store a string from the user in it and then pass it to sscanf() in the write functions such as tsf_write_file(). The buffer is only used to store a number so we never come close to filling up the whole PAGE_SIZE. Reserve the last character of the page for a NUL terminator.
This is debugfs so it's root only.
--- drivers/net/wireless/broadcom/b43legacy/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/b43legacy/debugfs.c +1 -1
@@ -263,7 +263,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; dev = file->private_data;if (!dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1474/1848 wifi: carl9170: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit ece30e1daf6a9c95d6f9d0518534a0b9c8c7fd42 ]
The "buf" buffer comes from the user. We use it to store a number or two so it doesn't need to be large. It gets passed to sscanf() in the write functions such as carl9170_debugfs_erp_write(). Ensure that buffer is NUL terminated.
This is debugfs so it's root only.
--- drivers/net/wireless/ath/carl9170/debug.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/carl9170/debug.c +3 -2
@@ -121,7 +121,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,if (!count)return 0 ; -if (count >PAGE_SIZE ) +if (count >=PAGE_SIZE )return -E2BIG ; ar = file->private_data;
@@ -134,7 +134,7 @@ static ssize_t carl9170_debugfs_write(struct file *file,if (!dfops->write)return -ENOSYS ; - buf =vmalloc (count); + buf =vmalloc (count +1 );if (!buf)return -ENOMEM ;
@@ -142,6 +142,7 @@ static ssize_t carl9170_debugfs_write(struct file *file, err = -EFAULT ; goto out_free; } + buf[count] ='\0' ;if (mutex_trylock (&ar->mutex) ==0 ) { err = -EAGAIN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1475/1848 dmaengine: ioat: disable relaxed ordering before registering the device
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit 10d34fbca6e09a6a18d64fa3ebaa3db9f27fc1a6 ]
ioat3_dma_probe() disabled PCIe relaxed ordering after calling dma_async_device_register(), so if an error occurs and the code jumps to err_disable_interrupts, the function returns with the device still registered in the core's dma_device_list while the caller frees the ioatdma_device struct, leaving a dangling registration that anything walking the device list can dereference after it's been freed.
Move the capability read/write ahead of dma_async_device_register() instead. Nothing after registration depends on relaxed ordering already being disabled, and nothing before it depends on the device being registered, so this is a plain reordering. It also means every remaining step after registration can't fail, so there's no need to ever have to unregister the device once registered.
--- drivers/dma/ioat/init.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/dma/ioat/init.c +9 -9
@@ -1168,15 +1168,6 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) ioat_chan->reg_base + IOAT_DCACTRL_OFFSET); } - err =dma_async_device_register (&ioat_dma->dma_dev); -if (err) - goto err_disable_interrupts; - -ioat_kobject_add (ioat_dma, &ioat_ktype); - -if (dca) - ioat_dma->dca =ioat_dca_init (pdev, ioat_dma->reg_base); -/* disable relaxed ordering */ err =pcie_capability_read_word (pdev,PCI_EXP_DEVCTL , &val16);if (err) {
@@ -1192,6 +1183,15 @@ static int ioat3_dma_probe(struct ioatdma_device *ioat_dma, int dca) goto err_disable_interrupts; } + err =dma_async_device_register (&ioat_dma->dma_dev); +if (err) + goto err_disable_interrupts; + +ioat_kobject_add (ioat_dma, &ioat_ktype); + +if (dca) + ioat_dma->dca =ioat_dca_init (pdev, ioat_dma->reg_base); +if (ioat_dma->cap &IOAT_CAP_DPS )writeb (ioat_pending_level +1 , ioat_dma->reg_base +IOAT_PREFETCH_LIMIT_OFFSET );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1476/1848 dmaengine: plx_dma: fix NULL pointer deref in plx_dma_isr()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Logan Gunthorpe <[email protected]>
[ Upstream commit f3017892457d8bb664ea4b912910dc254e2dd825 ]
plx_dma_create() registered the interrupt handler with request_irq() before initializing plxdev->bar. If the device raised an interrupt in that window, plx_dma_isr() would dereference the still-NULL bar.
Move the bar assignment ahead of request_irq() so everything the handler can touch is initialized before it can run.
--- drivers/dma/plx_dma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/dma/plx_dma.c +5 -5
@@ -505,17 +505,17 @@ static int plx_dma_create(struct pci_dev *pdev)if (!plxdev)return -ENOMEM ; - rc =request_irq (pci_irq_vector (pdev,0 ), plx_dma_isr,0 , -KBUILD_MODNAME , plxdev); -if (rc) - goto free_plx; -spin_lock_init (&plxdev->ring_lock);tasklet_setup (&plxdev->desc_task, plx_dma_desc_task);RCU_INIT_POINTER (plxdev->pdev, pdev); plxdev->bar =pcim_iomap_table (pdev)[0 ]; + rc =request_irq (pci_irq_vector (pdev,0 ), plx_dma_isr,0 , +KBUILD_MODNAME , plxdev); +if (rc) + goto free_plx; + dma = &plxdev->dma_dev; dma->chancnt =1 ;INIT_LIST_HEAD (&dma->channels);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/1848 NFS: filelayout: calculate dense stripe width in 64 bits
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 9ba13ef0e3ad033d3ddbaeb740b12d135a88363d ]
filelayout_get_dense_offset() calculates the stripe width from the stripe unit and count, where both values are provided by the server. Their product is stored on 32 bits, and can wrap to zero despite passing individual checks. For example, a 1 GiB stripe unit (0x40000000) and four stripes (4) cause the following div_u64() to raise a divide error during the first read through the dense layout.
Update u32 to u64 and use div64_u64() instead of div_u64(). stripe_unit is a u32 and stripe_count is limited to 4096, so the product cannot overflow a u64.
--- fs/nfs/filelayout/filelayout.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/nfs/filelayout/filelayout.c +3 -2
@@ -55,12 +55,13 @@ static loff_t filelayout_get_dense_offset(struct nfs4_filelayout_segment *flseg, loff_t offset) { -u32 stripe_width = flseg->stripe_unit * flseg->dsaddr->stripe_count; +u64 stripe_width = (u64 )flseg->stripe_unit * + flseg->dsaddr->stripe_count;u64 stripe_no;u32 rem; offset -= flseg->pattern_offset; - stripe_no =div_u64 (offset, stripe_width); + stripe_no =div64_u64 (offset, stripe_width);div_u64_rem (offset, flseg->stripe_unit, &rem);return stripe_no * flseg->stripe_unit + rem;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/1848 floppy: flush pending work before releasing resources on init failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 74c2e2eeb7e51cdeb5e3eceaf324cfcf8dcd0d32 ]
do_floppy_init() probes each FDC with user_reset_fdc(), which queues a redo_fd_request() work item on floppy_wq that may still be pending when the probe finishes. When no controller is found, the error path calls floppy_release_irq_and_dma() to free the IRQ and DMA channel, and only later destroys the workqueue. destroy_workqueue() drains the queued work last, so it can run after the IRQ and DMA are already gone:
floppy0: no floppy controllers found
work still pending
The flush used to be here. Commit 070ad7e793dc ("floppy: convert to delayed work and single-thread wq") renamed the label out_flush_work to out_release_dma and dropped it. Restore it so the work drains before the IRQ and DMA are released, as floppy_module_exit() already does.
--- drivers/block/floppy.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/block/floppy.c +2 -0
@@ -4798,6 +4798,8 @@ static int __init do_floppy_init(void) } } out_release_dma: +/* Drain the queued redo_fd_request() before releasing IRQ and DMA. */ +flush_workqueue (floppy_wq);if (atomic_read (&usage_count))floppy_release_irq_and_dma (); out_unreg_region:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/1848 floppy: avoid NULL deref in reset_interrupt when cont is cleared
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yang Xiuwei <[email protected]>
[ Upstream commit 7c82781039c03a3e47b70d3259f336adbb9d2692 ]
reset_fdc() arms do_floppy = reset_interrupt; the IRQ handler then queues that function via schedule_bh(). If unlock_fdc() or do_wakeup() clears cont before the work runs, reset_interrupt() dereferences a NULL cont and oopses.
Example crash excerpt:
[ 1070.468148] status=80 [ 1070.468152] fdc_busy=1 [ 1070.468158] cont= (null) [ 1070.468161] current_req= (null) [ 1070.468162] command_status=-1 [ 1070.468163] [ 1070.557051] floppy0: floppy timeout called [ 1070.557053] no cont in shutdown! [ 1070.557056] floppy0: floppy_shutdown: timeout handler died. [ 1074.419509] floppy0: FDC access conflict! [ 1074.419782] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 [ 1074.421969] PGD 0 P4D 0 [ 1074.422320] Oops: 0000 [#1] SMP NOPTI [ 1074.422648] CPU: 10 PID: 3269 Comm: kworker/u256:4 Kdump: loaded [ 1074.423830] Hardware name: inspur Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 [ 1074.424284] Workqueue: floppy floppy_work_workfn [floppy] [ 1074.424757] RIP: 0010:reset_interrupt+0x3a/0xa0 [floppy]
The same NULL deref has also been reported by syzbot on upstream.
Return early if cont is already NULL after result(). The hardware reset has completed; result() still drains the FDC. A later request can lock the FDC and reset again. This is a defensive fix for stale work, not a rewrite of the floppy continuation state machine.
--- drivers/block/floppy.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/block/floppy.c +3 -0
@@ -1785,6 +1785,9 @@ static void reset_interrupt(void) {debugt (__func__,"" );result (current_fdc);/* get the status ready for set_fdc */ +/* Stale work: unlock_fdc()/do_wakeup() may have cleared cont. */ +if (!cont) +return ;if (fdc_state[current_fdc].reset) {pr_info ("reset set in interrupt, calling %ps\n" , cont->error); cont->error ();/* a reset just after a reset. BAD! */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1480/1848 dmaengine: ste_dma40: Fix physical cyclic capability
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 11101a8e3e42273a5910a149f6324040b88f4747 ]
d40_dmaengine_init() configures dma_both for physical channels that can handle both slave and memcpy transfers. Physical DMA40 channel setup has supported cyclic LLIs since cyclic transfer support was added, but the DMA_CYCLIC capability is set on dma_slave a second time instead of dma_both.
Set DMA_CYCLIC on dma_both so d40_ops_init() installs device_prep_dma_cyclic and physical channels advertise cyclic support.
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -2886,7 +2886,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,dma_cap_zero (base->dma_both.cap_mask);dma_cap_set (DMA_SLAVE , base->dma_both.cap_mask);dma_cap_set (DMA_MEMCPY , base->dma_both.cap_mask); -dma_cap_set (DMA_CYCLIC , base->dma_slave.cap_mask); +dma_cap_set (DMA_CYCLIC , base->dma_both.cap_mask);d40_ops_init (base, &base->dma_both); err =dmaenginem_async_device_register (&base->dma_both);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1481/1848 dmaengine: ste_dma40: Fix failed start cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 8175ead5727173d4b96d1e830e696765d75ade71 ]
If d40_start() fails after a queued descriptor has been moved to the active list, d40_queue_start() currently returns NULL without unwinding the transfer state or clearing the channel busy flag.
Fix this pre-existing error path by completing the descriptor through the normal tasklet path, clearing the busy flag, balancing the runtime PM reference and returning an error pointer to distinguish the failure from the no-work case. Do not free the descriptor directly, since it has already been submitted and has a DMA cookie.
When starting the next queued transfer from the completion handler, put the completed descriptor on the done list first. This preserves FIFO completion order if the new transfer fails to start and prevents the completed cookie from moving backwards.
Use done-list membership rather than the cyclic flag to identify terminal descriptors in the tasklet. A cyclic descriptor that failed to start is then completed and removed instead of remaining permanently at the head of the done list.
--- drivers/dma/ste_dma40.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-)
drivers/dma/ste_dma40.c +17 -8
@@ -1510,8 +1510,15 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)/* Start dma job */ err =d40_start (d40c); -if (err) -return NULL ; +if (err) { +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); + d40c->pending_tx++; + d40c->busy = false; +pm_runtime_put_autosuspend (d40c->base->dev); +tasklet_schedule (&d40c->tasklet); +return ERR_PTR (err); + } }return d40d;
@@ -1555,15 +1562,15 @@ static void dma_tc_handle(struct d40_chan *d40c)return ; } +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); +if (d40_queue_start (d40c) ==NULL ) { d40c->busy = false;pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev); } - -d40_desc_remove (d40d); -d40_desc_done (d40c, d40d); } d40c->pending_tx++;
@@ -1577,20 +1584,22 @@ static void dma_tasklet(struct tasklet_struct *t)struct d40_desc *d40d;unsigned long flags;bool callback_active; +bool from_done;struct dmaengine_desc_callback cb;spin_lock_irqsave (&d40c->lock, flags);/* Get first entry from the done list */ d40d =d40_first_done (d40c); -if (d40d ==NULL ) { + from_done = !!d40d; +if (!from_done) {/* Check if we have reached here for cyclic job */ d40d =d40_first_active_get (d40c);if (d40d ==NULL || !d40d->cyclic) goto check_pending_tx; } -if (!d40d->cyclic) +if (from_done)dma_cookie_complete (&d40d->txd);/*
@@ -1606,7 +1615,7 @@ static void dma_tasklet(struct tasklet_struct *t) callback_active = !!(d40d->txd.flags &DMA_PREP_INTERRUPT );dmaengine_desc_get_callback (&d40d->txd, &cb); -if (!d40d->cyclic) { +if (from_done) {if (async_tx_test_ack (&d40d->txd)) {d40_desc_remove (d40d);d40_desc_free (d40c, d40d);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/1848 dmaengine: ste_dma40: Get LCPA SRAM from SRAM node
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 5a1a3b9c19ddeddc6b0c2ea1da7fbe6624c04c7e ]
Instead of passing the reserved SRAM as a "reg" field look for a phandle to the LCPA SRAM memory so we can use the proper SRAM device tree bindings for the SRAM.
Stable-dep-of: c6809b381e34 ("dmaengine: ste_dma40: Fix probe runtime PM disable")
--- drivers/dma/Kconfig | 1 + drivers/dma/ste_dma40.c | 47 +++++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 23 deletions(-)
drivers/dma/Kconfig +1 -0
@@ -523,6 +523,7 @@ config STE_DMA40 bool "ST-Ericsson DMA40 support" depends on ARCH_U8500 select DMA_ENGINE + select SRAM help Support for ST-Ericsson DMA40 controller
drivers/dma/ste_dma40.c +24 -23
85 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1483/1848 dmaengine: ste_dma40: Add dev helper variable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit fb85a8c51784f46b4ddd8bdad3c6bcacd0e5ad2b ]
The &pdev->dev device pointer is used so many times in the probe() and d40_hw_detect_init() functions that a local *dev variable makes the code way easier to read.
Stable-dep-of: c6809b381e34 ("dmaengine: ste_dma40: Fix probe runtime PM disable")
--- drivers/dma/ste_dma40.c | 50 +++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 24 deletions(-)
drivers/dma/ste_dma40.c +26 -24
@@ -3114,6 +3114,7 @@ static int __init d40_phy_res_init(struct d40_base *base)static struct d40_base *__init d40_hw_detect_init (struct platform_device *pdev) {struct stedma40_platform_data *plat_data =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev;struct clk *clk;void __iomem *virtbase;struct resource *res;
@@ -3127,15 +3128,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)u32 cid;u8 rev; - clk =clk_get (&pdev->dev,NULL ); + clk =clk_get (dev,NULL );if (IS_ERR (clk)) { -d40_err (&pdev->dev,"No matching clock found\n" ); +d40_err (dev,"No matching clock found\n" ); goto check_prepare_enabled; } clk_ret =clk_prepare_enable (clk);if (clk_ret) { -d40_err (&pdev->dev,"Failed to prepare/enable clock\n" ); +d40_err (dev,"Failed to prepare/enable clock\n" ); goto disable_unprepare; }
@@ -3161,11 +3162,11 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) & 255) << (i * 8);if (cid !=AMBA_CID ) { -d40_err (&pdev->dev,"Unknown hardware! No PrimeCell ID\n" ); +d40_err (dev,"Unknown hardware! No PrimeCell ID\n" ); goto unmap_io; }if (AMBA_MANF_BITS (pid) !=AMBA_VENDOR_ST ) { -d40_err (&pdev->dev,"Unknown designer! Got %x wanted %x\n" , +d40_err (dev,"Unknown designer! Got %x wanted %x\n" ,AMBA_MANF_BITS (pid),AMBA_VENDOR_ST ); goto unmap_io;
@@ -3181,7 +3182,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)*/ rev =AMBA_REV_BITS (pid);if (rev <2 ) { -d40_err (&pdev->dev,"hardware revision: %d is not supported" , rev); +d40_err (dev,"hardware revision: %d is not supported" , rev); goto unmap_io; }
@@ -3199,7 +3200,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ; -dev_info (&pdev->dev, +dev_info (dev,"hardware rev: %d @ %pa with %d physical and %d logical channels\n" , rev, &res->start, num_phy_chans, num_log_chans);
@@ -3219,7 +3220,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->phy_size =resource_size (res); base->virtbase = virtbase; base->plat_data = plat_data; - base->dev = &pdev->dev; + base->dev = dev; base->phy_chans = ((void *)base) +ALIGN (sizeof (struct d40_base ),4 ); base->log_chans = &base->phy_chans[num_phy_chans];
@@ -3515,7 +3516,8 @@ static int __init d40_of_probe(struct platform_device *pdev,static int __init d40_probe (struct platform_device *pdev) { -struct stedma40_platform_data *plat_data =dev_get_platdata (&pdev->dev); +struct device *dev = &pdev->dev; +struct stedma40_platform_data *plat_data =dev_get_platdata (dev);struct device_node *np = pdev->dev.of_node;struct device_node *np_lcpa;int ret = -ENOENT ;
@@ -3532,7 +3534,7 @@ static int __init d40_probe(struct platform_device *pdev) goto report_failure; } }else { -d40_err (&pdev->dev,"No pdata or Device Tree provided\n" ); +d40_err (dev,"No pdata or Device Tree provided\n" ); goto report_failure; } }
@@ -3551,24 +3553,24 @@ static int __init d40_probe(struct platform_device *pdev)/* Get IO for logical channel parameter address (LCPA) */ np_lcpa =of_parse_phandle (np,"sram" ,0 );if (!np_lcpa) { -dev_err (&pdev->dev,"no LCPA SRAM node\n" ); +dev_err (dev,"no LCPA SRAM node\n" ); goto report_failure; }/* This is no device so read the address directly from the node */ ret =of_address_to_resource (np_lcpa,0 , &res_lcpa);if (ret) { -dev_err (&pdev->dev,"no LCPA SRAM resource\n" ); +dev_err (dev,"no LCPA SRAM resource\n" ); goto report_failure; } base->lcpa_size =resource_size (&res_lcpa); base->phy_lcpa = res_lcpa.start; -dev_info (&pdev->dev,"found LCPA SRAM at 0x%08x, size 0x%08x\n" , +dev_info (dev,"found LCPA SRAM at 0x%08x, size 0x%08x\n" , (u32 )base->phy_lcpa, base->lcpa_size);/* We make use of ESRAM memory for this. */ val =readl (base->virtbase +D40_DREG_LCPA );if (base->phy_lcpa != val && val !=0 ) { -dev_warn (&pdev->dev, +dev_warn (dev,"[%s] Mismatch LCPA dma 0x%x, def %08x\n" , __func__, val, (u32 )base->phy_lcpa); }else
@@ -3577,7 +3579,7 @@ static int __init d40_probe(struct platform_device *pdev) base->lcpa_base =ioremap (base->phy_lcpa, base->lcpa_size);if (!base->lcpa_base) { ret = -ENOMEM ; -d40_err (&pdev->dev,"Failed to ioremap LCPA region\n" ); +d40_err (dev,"Failed to ioremap LCPA region\n" ); goto release_base; }/* If lcla has to be located in ESRAM we don't need to allocate */
@@ -3586,7 +3588,7 @@ static int __init d40_probe(struct platform_device *pdev) "lcla_esram");if (!res) { ret = -ENOENT ; -d40_err (&pdev->dev, +d40_err (dev,"No \"lcla_esram\" memory resource\n" ); goto destroy_cache; }
@@ -3594,7 +3596,7 @@ static int __init d40_probe(struct platform_device *pdev) resource_size(res));if (!base->lcla_pool.base) { ret = -ENOMEM ; -d40_err (&pdev->dev,"Failed to ioremap LCLA region\n" ); +d40_err (dev,"Failed to ioremap LCLA region\n" ); goto destroy_cache; }writel (res->start, base->virtbase +D40_DREG_LCLA );
@@ -3602,7 +3604,7 @@ static int __init d40_probe(struct platform_device *pdev) }else { ret =d40_lcla_allocate (base);if (ret) { -d40_err (&pdev->dev,"Failed to allocate LCLA area\n" ); +d40_err (dev,"Failed to allocate LCLA area\n" ); goto destroy_cache; } }
@@ -3617,7 +3619,7 @@ static int __init d40_probe(struct platform_device *pdev) ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base);if (ret) { -d40_err (&pdev->dev,"No IRQ defined\n" ); +d40_err (dev,"No IRQ defined\n" ); goto destroy_cache; }
@@ -3625,7 +3627,7 @@ static int __init d40_probe(struct platform_device *pdev) base->lcpa_regulator =regulator_get (base->dev,"lcla_esram" );if (IS_ERR (base->lcpa_regulator)) { -d40_err (&pdev->dev,"Failed to get lcpa_regulator\n" ); +d40_err (dev,"Failed to get lcpa_regulator\n" ); ret =PTR_ERR (base->lcpa_regulator); base->lcpa_regulator =NULL ; goto destroy_cache;
@@ -3633,7 +3635,7 @@ static int __init d40_probe(struct platform_device *pdev) ret =regulator_enable (base->lcpa_regulator);if (ret) { -d40_err (&pdev->dev, +d40_err (dev,"Failed to enable lcpa_regulator\n" );regulator_put (base->lcpa_regulator); base->lcpa_regulator =NULL ;
@@ -3656,7 +3658,7 @@ static int __init d40_probe(struct platform_device *pdev) ret =dma_set_max_seg_size (base->dev,STEDMA40_MAX_SEG_SIZE );if (ret) { -d40_err (&pdev->dev,"Failed to set dma max seg size\n" ); +d40_err (dev,"Failed to set dma max seg size\n" ); goto destroy_cache; }
@@ -3665,7 +3667,7 @@ static int __init d40_probe(struct platform_device *pdev)if (np) { ret =of_dma_controller_register (np, d40_xlate,NULL );if (ret) -dev_err (&pdev->dev, +dev_err (dev,"could not register of_dma_controller\n" ); }
@@ -3716,7 +3718,7 @@ static int __init d40_probe(struct platform_device *pdev)kfree (base->phy_res);kfree (base); report_failure: -d40_err (&pdev->dev,"probe failed\n" ); +d40_err (dev,"probe failed\n" );return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1484/1848 dmaengine: ste_dma40: Fix probe runtime PM disable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c6809b381e34f8966cc3d9e5d7d658775a408f83 ]
Some d40_probe() error paths jump to destroy_cache before runtime PM has been enabled for the DMA controller device. The label unconditionally calls pm_runtime_disable(), which increments disable_depth even though this probe attempt never enabled runtime PM.
Use devm_pm_runtime_set_active_enabled() to mark the controller active, enable runtime PM and register balanced cleanup for probe failure. This avoids both the disable-depth imbalance and ad-hoc probe state tracking.
The interrupt handler uses pm_runtime_get_if_active() and cannot acknowledge a pending interrupt while runtime PM is disabled. Request the IRQ only after enabling runtime PM so the handler cannot enter an unacknowledged interrupt loop during probe.
--- drivers/dma/ste_dma40.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/dma/ste_dma40.c +13 -10
@@ -3617,12 +3617,6 @@ static int __init d40_probe(struct platform_device *pdev) goto destroy_cache; } - ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base); -if (ret) { -d40_err (dev,"No IRQ defined\n" ); - goto destroy_cache; - } -if (base->plat_data->use_esram_lcla) { base->lcpa_regulator =regulator_get (base->dev,"lcla_esram" );
@@ -3647,10 +3641,20 @@ static int __init d40_probe(struct platform_device *pdev)pm_runtime_irq_safe (base->dev);pm_runtime_set_autosuspend_delay (base->dev,DMA40_AUTOSUSPEND_DELAY ); -pm_runtime_use_autosuspend (base->dev);pm_runtime_mark_last_busy (base->dev); -pm_runtime_set_active (base->dev); -pm_runtime_enable (base->dev); + + ret =devm_pm_runtime_set_active_enabled (base->dev); +if (ret) { +d40_err (dev,"Failed to enable runtime PM: %d\n" , ret); + goto destroy_cache; + } +pm_runtime_use_autosuspend (base->dev); + + ret =request_irq (base->irq, d40_handle_interrupt,0 ,D40_NAME , base); +if (ret) { +d40_err (dev,"No IRQ defined\n" ); + goto destroy_cache; + } ret =d40_dmaengine_init (base, num_reserved_chans);if (ret)
@@ -3710,7 +3714,6 @@ static int __init d40_probe(struct platform_device *pdev)regulator_disable (base->lcpa_regulator);regulator_put (base->lcpa_regulator); } -pm_runtime_disable (base->dev);kfree (base->lcla_pool.alloc_map);kfree (base->lookup_log_chans);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1485/1848 dmaengine: ste_dma40: Check runtime PM in IRQ
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 12787e3f2f93f3af59769b08ee4fcb044531120b ]
d40_handle_interrupt() reads DMA40 interrupt registers unconditionally. A spurious interrupt can arrive while the device is runtime suspended, after dma40_runtime_suspend() has disabled the GCC clock.
Avoid touching the registers unless the device is runtime active by taking a conditional runtime PM reference. Return IRQ_NONE when the device is suspended, and drop the reference after handling an active interrupt.
When CONFIG_PM is disabled, pm_runtime_get_if_active() returns -EINVAL even though the registers remain accessible. Keep handling interrupts in that configuration and only drop the runtime PM reference when one was acquired.
--- drivers/dma/ste_dma40.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/dma/ste_dma40.c +8 -0
@@ -1658,6 +1658,11 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)u32 *regs = base->regs_interrupt;struct d40_interrupt_lookup *il = base->gen_dmac.il;u32 il_size = base->gen_dmac.il_size; +int ret; + + ret =pm_runtime_get_if_active (base->dev); +if (IS_ENABLED (CONFIG_PM ) && ret <=0 ) +return IRQ_NONE ;spin_lock_irqsave (&base->interrupt_lock, flags);
@@ -1706,6 +1711,9 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)spin_unlock_irqrestore (&base->interrupt_lock, flags); +if (ret >0 ) +pm_runtime_put_autosuspend (base->dev); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1486/1848 dmaengine: ste_dma40: Remove redundant pm_runtime_mark_last_busy() calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit 01f2bcf06d7e0e3c4badd03c030cf634ca10a172 ]
pm_runtime_put_autosuspend(), pm_runtime_put_sync_autosuspend(), pm_runtime_autosuspend() and pm_request_autosuspend() now include a call to pm_runtime_mark_last_busy(). Remove the now-reduntant explicit call to pm_runtime_mark_last_busy().
Stable-dep-of: 55a35231b8ce ("dmaengine: ste_dma40: Handle runtime PM resume errors")
--- drivers/dma/ste_dma40.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/dma/ste_dma40.c +2 -12
@@ -1430,7 +1430,6 @@ static int d40_pause(struct dma_chan *chan) res =d40_channel_execute_command (d40c,D40_DMA_SUSPEND_REQ ); -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev);spin_unlock_irqrestore (&d40c->lock, flags);return res;
@@ -1457,7 +1456,6 @@ static int d40_resume(struct dma_chan *chan)if (d40_residue (d40c) ||d40_tx_is_linked (d40c)) res =d40_channel_execute_command (d40c,D40_DMA_RUN ); -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev);spin_unlock_irqrestore (&d40c->lock, flags);return res;
@@ -1569,7 +1567,6 @@ static void dma_tc_handle(struct d40_chan *d40c)if (d40_queue_start (d40c) ==NULL ) { d40c->busy = false; -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev); } }
@@ -2050,16 +2047,13 @@ static int d40_free_dma(struct d40_chan *d40c)else d40c->base->lookup_phy_chans[phy->num] =NULL ; -if (d40c->busy) { -pm_runtime_mark_last_busy (d40c->base->dev); +if (d40c->busy)pm_runtime_put_autosuspend (d40c->base->dev); - } d40c->busy = false; d40c->phy_chan =NULL ; d40c->configured = false; mark_last_busy: -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev);return res; }
@@ -2463,7 +2457,6 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)if (is_free_phy)d40_config_write (d40c); mark_last_busy: -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev);spin_unlock_irqrestore (&d40c->lock, flags);return err;
@@ -2615,12 +2608,9 @@ static int d40_terminate_all(struct dma_chan *chan)chan_err (d40c,"Failed to stop channel\n" );d40_term_all (d40c); -pm_runtime_mark_last_busy (d40c->base->dev);pm_runtime_put_autosuspend (d40c->base->dev); -if (d40c->busy) { -pm_runtime_mark_last_busy (d40c->base->dev); +if (d40c->busy)pm_runtime_put_autosuspend (d40c->base->dev); - } d40c->busy = false;spin_unlock_irqrestore (&d40c->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1487/1848 dmaengine: ste_dma40: Handle runtime PM resume errors
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 55a35231b8ced2250a7743ec350a9566d553780e ]
Several channel operations use pm_runtime_get_sync() and access DMA40 registers without checking whether runtime resume succeeded. If resume fails, the registers may be inaccessible. pm_runtime_get_sync() also increments the usage counter on failure, making error unwinding easy to unbalance.
Use pm_runtime_resume_and_get() and avoid register access when resume fails. Acquire the runtime PM reference before allocating a channel so failure needs no channel-allocation rollback.
If a queued transfer cannot be started because resume failed, retire all issued descriptors through the normal tasklet path. Since dma_async_issue_pending() cannot return an error, leaving them queued would make clients wait indefinitely for callbacks.
Termination and channel release must also clean up software state when the controller cannot resume. d40_term_all() only releases descriptor state and does not access DMA40 registers, so it remains unconditional.
Balance each transient runtime PM reference in its successful acquisition block, without bookkeeping flags. Release the outstanding busy reference and channel allocation state when freeing a channel. Skip only the hardware stop that requires register access.
--- drivers/dma/ste_dma40.c | 74 +++++++++++++++++++++++++++++------------ 1 file changed, 52 insertions(+), 22 deletions(-)
drivers/dma/ste_dma40.c +52 -22
@@ -1426,11 +1426,14 @@ static int d40_pause(struct dma_chan *chan)return 0 ;spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res <0 ) + goto unlock; res =d40_channel_execute_command (d40c,D40_DMA_SUSPEND_REQ );pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return res; }
@@ -1450,13 +1453,16 @@ static int d40_resume(struct dma_chan *chan)return 0 ;spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res <0 ) + goto unlock;/* If bytes left to transfer or linked tx resume job */ if (d40_residue (d40c) ||d40_tx_is_linked (d40c)) res =d40_channel_execute_command (d40c,D40_DMA_RUN );pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return res; }
@@ -1493,8 +1499,20 @@ static struct d40_desc *d40_queue_start(struct d40_chan *d40c)if (d40d !=NULL ) {if (!d40c->busy) { + err =pm_runtime_resume_and_get (d40c->base->dev); +if (err <0 ) { +chan_err (d40c,"Failed to resume DMA: %d\n" , + err); +do { +d40_desc_remove (d40d); +d40_desc_done (d40c, d40d); + d40c->pending_tx++; + d40d =d40_first_queued (d40c); + }while (d40d); +tasklet_schedule (&d40c->tasklet); +return ERR_PTR (err); + } d40c->busy = true; -pm_runtime_get_sync (d40c->base->dev); }/* Remove from queue */
@@ -2009,9 +2027,6 @@ static int d40_free_dma(struct d40_chan *d40c)struct d40_phy_res *phy = d40c->phy_chan;bool is_src; -/* Terminate all queued and active transfers */ -d40_term_all (d40c); -if (phy ==NULL ) {chan_err (d40c,"phy == null\n" );return -EINVAL ;
@@ -2033,11 +2048,18 @@ static int d40_free_dma(struct d40_chan *d40c)return -EINVAL ; } -pm_runtime_get_sync (d40c->base->dev); - res =d40_channel_execute_command (d40c,D40_DMA_STOP ); -if (res) { -chan_err (d40c,"stop failed\n" ); - goto mark_last_busy; +/* Release descriptor state; this does not access DMA40 registers. */ +d40_term_all (d40c); + + res =pm_runtime_resume_and_get (d40c->base->dev); +if (res >=0 ) { + res =d40_channel_execute_command (d40c,D40_DMA_STOP ); +if (res) +chan_err (d40c,"stop failed\n" ); + +pm_runtime_put_autosuspend (d40c->base->dev); +if (res) +return res; }d40_alloc_mask_free (phy, is_src,chan_is_logical (d40c) ? event :0 );
@@ -2053,8 +2075,6 @@ static int d40_free_dma(struct d40_chan *d40c) d40c->busy = false; d40c->phy_chan =NULL ; d40c->configured = false; - mark_last_busy: -pm_runtime_put_autosuspend (d40c->base->dev);return res; }
@@ -2414,10 +2434,14 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) err =d40_config_memcpy (d40c);if (err) {chan_err (d40c,"Failed to configure memcpy channel\n" ); - goto mark_last_busy; + goto unlock; } } + err =pm_runtime_resume_and_get (d40c->base->dev); +if (err <0 ) + goto unlock; + err =d40_allocate_channel (d40c, &is_free_phy);if (err) {chan_err (d40c,"Failed to allocate channel\n" );
@@ -2425,8 +2449,6 @@ static int d40_alloc_chan_resources(struct dma_chan *chan) goto mark_last_busy; } -pm_runtime_get_sync (d40c->base->dev); -d40_set_prio_realtime (d40c);if (chan_is_logical (d40c)) {
@@ -2458,6 +2480,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)d40_config_write (d40c); mark_last_busy:pm_runtime_put_autosuspend (d40c->base->dev); + unlock:spin_unlock_irqrestore (&d40c->lock, flags);return err; }
@@ -2602,19 +2625,26 @@ static int d40_terminate_all(struct dma_chan *chan)spin_lock_irqsave (&d40c->lock, flags); -pm_runtime_get_sync (d40c->base->dev); - ret =d40_channel_execute_command (d40c,D40_DMA_STOP ); -if (ret) -chan_err (d40c,"Failed to stop channel\n" ); + ret =pm_runtime_resume_and_get (d40c->base->dev); +if (ret >=0 ) { + ret =d40_channel_execute_command (d40c,D40_DMA_STOP ); +if (ret) +chan_err (d40c,"Failed to stop channel\n" ); + +pm_runtime_put_autosuspend (d40c->base->dev); + } +/* +* Always release software state, even when the controller cannot +* resume. d40_term_all() does not access DMA40 registers. +*/ d40_term_all (d40c); -pm_runtime_put_autosuspend (d40c->base->dev);if (d40c->busy)pm_runtime_put_autosuspend (d40c->base->dev); d40c->busy = false;spin_unlock_irqrestore (&d40c->lock, flags); -return 0 ; +return ret; } static int
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1488/1848 dmaengine: ste_dma40: Return IRQ_NONE when no interrupt is pending
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b96967644c524d34b2fdd2e58c31e7b36e3469e6 ]
d40_handle_interrupt() returns IRQ_HANDLED even when no terminal-count or error status bit is pending.
IRQ_NONE is not only used to identify a device on a shared interrupt. The generic IRQ core also counts it as unhandled for spurious IRQ detection. DMA40 does not request this IRQ with IRQF_SHARED, so interrupt sharing is not the purpose of this change.
If the line remains asserted without matching DMA40 status, returning IRQ_HANDLED hides the stuck interrupt and can leave the CPU servicing it indefinitely. Track whether any DMA40 status is pending and return IRQ_NONE when none is present, allowing the generic IRQ core to diagnose and eventually disable the faulty line.
DMA40 channels can be owned by other SoC cores. Their status means that the interrupt is real, but Linux must not acknowledge it. Treat foreign status as handled and leave its acknowledgment to the owning core, while acknowledging and dispatching only registered Linux channels.
--- drivers/dma/ste_dma40.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +8 -1
@@ -1663,6 +1663,7 @@ static void dma_tasklet(struct tasklet_struct *t)static irqreturn_t d40_handle_interrupt (int irq,void *data) { +irqreturn_t handled =IRQ_NONE ;int i;u32 idx;u32 row;
@@ -1697,6 +1698,12 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data) row = chan /BITS_PER_LONG ; idx = chan & (BITS_PER_LONG -1 ); +/* +* Status for a channel owned by another core still explains +* the interrupt, but only ACK Linux-owned channels below. +*/ + handled =IRQ_HANDLED ; +if (il[row].offset ==D40_PHY_CHAN ) d40c = base->lookup_phy_chans[idx];else
@@ -1729,7 +1736,7 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)if (ret >0 )pm_runtime_put_autosuspend (base->dev); -return IRQ_HANDLED ; +return handled; } static int d40_validate_conf(struct d40_chan *d40c,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/1848 dmaengine: ste_dma40: Remove platform data
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 42ae6f1695beed57958e7a2554e6d52dddc56e43 ]
The Ux500 is device tree-only since ages. Delete the platform data header and push it into or next to the driver instead.
Drop the non-DT probe path since this will not happen.
Stable-dep-of: 7ca608cf6b84 ("dmaengine: ste_dma40: Fix probe IRQ leak")
--- drivers/dma/ste_dma40.c | 56 ++++++---- .../dma/ste_dma40.h | 101 +----------------- drivers/dma/ste_dma40_ll.c | 3 +- 3 files changed, 41 insertions(+), 119 deletions(-) rename include/linux/platform_data/dma-ste-dma40.h => drivers/dma/ste_dma40.h (51%)
drivers/dma/ste_dma40.c +38 -18
@@ -23,11 +23,39 @@#include <linux/of_dma.h> #include <linux/amba/bus.h> #include <linux/regulator/consumer.h> -#include <linux/platform_data/dma-ste-dma40.h> #include "dmaengine.h" +#include "ste_dma40.h" #include "ste_dma40_ll.h" +/** +* struct stedma40_platform_data - Configuration struct for the dma device. +* +* @dev_tx: mapping between destination event line and io address +* @dev_rx: mapping between source event line and io address +* @disabled_channels: A vector, ending with -1, that marks physical channels +* that are for different reasons not available for the driver. +* @soft_lli_chans: A vector, that marks physical channels will use LLI by SW +* which avoids HW bug that exists in some versions of the controller. +* SoftLLI introduces relink overhead that could impact performace for +* certain use cases. +* @num_of_soft_lli_chans: The number of channels that needs to be configured +* to use SoftLLI. +* @use_esram_lcla: flag for mapping the lcla into esram region +* @num_of_memcpy_chans: The number of channels reserved for memcpy. +* @num_of_phy_chans: The number of physical channels implemented in HW. +* 0 means reading the number of channels from DMA HW but this is only valid +* for 'multiple of 4' channels, like 8. +*/ +struct stedma40_platform_data { +int disabled_channels[STEDMA40_MAX_PHYS ]; +int *soft_lli_chans; +int num_of_soft_lli_chans; +bool use_esram_lcla; +int num_of_memcpy_chans; +int num_of_phy_chans; +}; +#define D40_NAME "dma40"#define D40_PHY_CHAN -1
@@ -2308,7 +2336,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,return NULL ; } -bool stedma40_filter (struct dma_chan *chan,void *data) +static bool stedma40_filter (struct dma_chan *chan,void *data) {struct stedma40_chan_cfg *info = data; struct d40_chan *d40c =
@@ -2327,7 +2355,6 @@ bool stedma40_filter(struct dma_chan *chan, void *data)return err ==0 ; } -EXPORT_SYMBOL (stedma40_filter);static void __d40_set_prio_rt (struct d40_chan *d40c,int dev_type,bool src) {
@@ -3562,16 +3589,9 @@ static int __init d40_probe(struct platform_device *pdev)int num_reserved_chans;u32 val; -if (!plat_data) { -if (np) { -if (d40_of_probe (pdev, np)) { - ret = -ENOMEM ; - goto report_failure; - } - }else { -d40_err (dev,"No pdata or Device Tree provided\n" ); - goto report_failure; - } +if (d40_of_probe (pdev, np)) { + ret = -ENOMEM ; + goto report_failure; } base =d40_hw_detect_init (pdev);
@@ -3703,11 +3723,11 @@ static int __init d40_probe(struct platform_device *pdev)d40_hw_init (base); -if (np) { - ret =of_dma_controller_register (np, d40_xlate,NULL ); -if (ret) -dev_err (dev, -"could not register of_dma_controller\n" ); + ret =of_dma_controller_register (np, d40_xlate,NULL ); +if (ret) { +dev_err (dev, +"could not register of_dma_controller\n" ); + goto destroy_cache; }dev_info (base->dev,"initialized\n" );
drivers/dma/ste_dma40.h renamed from include/linux/platform_data/dma-ste-dma40.h +1 -100
112 lines not on this page · raw message
drivers/dma/ste_dma40_ll.c +2 -1
@@ -6,8 +6,9 @@*/ #include <linux/kernel.h> -#include <linux/platform_data/dma-ste-dma40.h> +#include <linux/dmaengine.h> +#include "ste_dma40.h" #include "ste_dma40_ll.h" static u8 d40_width_to_bits (enum dma_slave_buswidth width)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1490/1848 dmaengine: ste_dma40: Use managed resources
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 339f5041089a22646372d3ebdeec94c25e8d4e29 ]
This switches the DMA40 driver to use a bunch of managed resources and strip down the errorpath.
The result is pretty neat and makes the driver way more readable.
Stable-dep-of: 7ca608cf6b84 ("dmaengine: ste_dma40: Fix probe IRQ leak")
--- drivers/dma/ste_dma40.c | 180 ++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 119 deletions(-)
drivers/dma/ste_dma40.c +61 -119
@@ -554,8 +554,6 @@ struct d40_gen_dmac {* @virtbase: The virtual base address of the DMA's register. * @rev: silicon revision detected. * @clk: Pointer to the DMA clock structure. -* @phy_start: Physical memory start of the DMA registers. -* @phy_size: Size of the DMA register map. * @irq: The IRQ number. * @num_memcpy_chans: The number of channels used for memcpy (mem-to-mem * transfers).
@@ -599,8 +597,6 @@ struct d40_base {void __iomem *virtbase; u8 rev:4;struct clk *clk; -phys_addr_t phy_start; -resource_size_t phy_size;int irq;int num_memcpy_chans;int num_phy_chans;
@@ -3173,65 +3169,58 @@ static int __init d40_phy_res_init(struct d40_base *base)return num_phy_chans_avail; } +/* Called from the registered devm action */ +static void d40_drop_kmem_cache_action (void *d) +{ +struct kmem_cache *desc_slab = d; + +kmem_cache_destroy (desc_slab); +} +static struct d40_base *__init d40_hw_detect_init (struct platform_device *pdev) {struct stedma40_platform_data *plat_data =dev_get_platdata (&pdev->dev);struct device *dev = &pdev->dev;struct clk *clk;void __iomem *virtbase; -struct resource *res;struct d40_base *base;int num_log_chans;int num_phy_chans;int num_memcpy_chans; -int clk_ret = -EINVAL ;int i;u32 pid;u32 cid;u8 rev; +int ret; - clk =clk_get (dev,NULL ); -if (IS_ERR (clk)) { -d40_err (dev,"No matching clock found\n" ); - goto check_prepare_enabled; - } - - clk_ret =clk_prepare_enable (clk); -if (clk_ret) { -d40_err (dev,"Failed to prepare/enable clock\n" ); - goto disable_unprepare; - } + clk =devm_clk_get_enabled (dev,NULL ); +if (IS_ERR (clk)) +return NULL ;/* Get IO for DMAC base address */ - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"base" ); -if (!res) - goto disable_unprepare; - -if (request_mem_region (res->start,resource_size (res), -D40_NAME " I/O base" ) ==NULL ) - goto release_region; - - virtbase =ioremap (res->start,resource_size (res)); -if (!virtbase) - goto release_region; + virtbase =devm_platform_ioremap_resource_byname (pdev,"base" ); +if (IS_ERR (virtbase)) { +dev_err (dev,"No IO base defined\n" ); +return NULL ; + }/* This is just a regular AMBA PrimeCell ID actually */ for (pid =0 , i =0 ; i <4 ; i++) - pid |= (readl (virtbase +resource_size (res) -0x20 +4 * i) + pid |= (readl (virtbase +SZ_4K -0x20 +4 * i) &255 ) << (i *8 );for (cid =0 , i =0 ; i <4 ; i++) - cid |= (readl (virtbase +resource_size (res) -0x10 +4 * i) + cid |= (readl (virtbase +SZ_4K -0x10 +4 * i) &255 ) << (i *8 );if (cid !=AMBA_CID ) {d40_err (dev,"Unknown hardware! No PrimeCell ID\n" ); - goto unmap_io; +return NULL ; }if (AMBA_MANF_BITS (pid) !=AMBA_VENDOR_ST ) {d40_err (dev,"Unknown designer! Got %x wanted %x\n" ,AMBA_MANF_BITS (pid),AMBA_VENDOR_ST ); - goto unmap_io; +return NULL ; }/* * HW revision:
@@ -3245,7 +3234,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) rev =AMBA_REV_BITS (pid);if (rev <2 ) {d40_err (dev,"hardware revision: %d is not supported" , rev); - goto unmap_io; +return NULL ; }/* The number of physical channels on this HW */
@@ -3263,23 +3252,22 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ;dev_info (dev, -"hardware rev: %d @ %pa with %d physical and %d logical channels\n" , - rev, &res->start, num_phy_chans, num_log_chans); +"hardware rev: %d with %d physical and %d logical channels\n" , + rev, num_phy_chans, num_log_chans); - base =kzalloc (ALIGN (sizeof (struct d40_base ),4 ) + - (num_phy_chans + num_log_chans + num_memcpy_chans) * -sizeof (struct d40_chan ),GFP_KERNEL ); + base =devm_kzalloc (dev, +ALIGN (sizeof (struct d40_base ),4 ) + + (num_phy_chans + num_log_chans + num_memcpy_chans) * +sizeof (struct d40_chan ),GFP_KERNEL ); -if (base ==NULL ) - goto unmap_io; +if (!base) +return NULL ; base->rev = rev; base->clk = clk; base->num_memcpy_chans = num_memcpy_chans; base->num_phy_chans = num_phy_chans; base->num_log_chans = num_log_chans; - base->phy_start = res->start; - base->phy_size =resource_size (res); base->virtbase = virtbase; base->plat_data = plat_data; base->dev = dev;
@@ -3316,76 +3304,55 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->gen_dmac.init_reg_size =ARRAY_SIZE (dma_init_reg_v4a); } - base->phy_res =kcalloc (num_phy_chans, -sizeof (*base->phy_res), -GFP_KERNEL ); + base->phy_res =devm_kcalloc (dev, num_phy_chans, +sizeof (*base->phy_res), +GFP_KERNEL );if (!base->phy_res) - goto free_base; +return NULL ; - base->lookup_phy_chans =kcalloc (num_phy_chans, -sizeof (*base->lookup_phy_chans), -GFP_KERNEL ); + base->lookup_phy_chans =devm_kcalloc (dev, num_phy_chans, +sizeof (*base->lookup_phy_chans), +GFP_KERNEL );if (!base->lookup_phy_chans) - goto free_phy_res; +return NULL ; - base->lookup_log_chans =kcalloc (num_log_chans, -sizeof (*base->lookup_log_chans), -GFP_KERNEL ); + base->lookup_log_chans =devm_kcalloc (dev, num_log_chans, +sizeof (*base->lookup_log_chans), +GFP_KERNEL );if (!base->lookup_log_chans) - goto free_phy_chans; +return NULL ; - base->reg_val_backup_chan =kmalloc_array (base->num_phy_chans, + base->reg_val_backup_chan =devm_kmalloc_array (dev, base->num_phy_chans,sizeof (d40_backup_regs_chan),GFP_KERNEL );if (!base->reg_val_backup_chan) - goto free_log_chans; +return NULL ; - base->lcla_pool.alloc_map =kcalloc (num_phy_chans + base->lcla_pool.alloc_map =devm_kcalloc (dev, num_phy_chans *D40_LCLA_LINK_PER_EVENT_GRP ,sizeof (*base->lcla_pool.alloc_map),GFP_KERNEL );if (!base->lcla_pool.alloc_map) - goto free_backup_chan; +return NULL ; - base->regs_interrupt =kmalloc_array (base->gen_dmac.il_size, + base->regs_interrupt =devm_kmalloc_array (dev, base->gen_dmac.il_size,sizeof (*base->regs_interrupt),GFP_KERNEL );if (!base->regs_interrupt) - goto free_map; +return NULL ; base->desc_slab =kmem_cache_create (D40_NAME ,sizeof (struct d40_desc ),0 ,SLAB_HWCACHE_ALIGN ,NULL ); -if (base->desc_slab ==NULL ) - goto free_regs; +if (!base->desc_slab) +return NULL ; + ret =devm_add_action_or_reset (dev, d40_drop_kmem_cache_action, + base->desc_slab); +if (ret) +return NULL ;return base; - free_regs: -kfree (base->regs_interrupt); - free_map: -kfree (base->lcla_pool.alloc_map); - free_backup_chan: -kfree (base->reg_val_backup_chan); - free_log_chans: -kfree (base->lookup_log_chans); - free_phy_chans: -kfree (base->lookup_phy_chans); - free_phy_res: -kfree (base->phy_res); - free_base: -kfree (base); - unmap_io: -iounmap (virtbase); - release_region: -release_mem_region (res->start,resource_size (res)); - check_prepare_enabled: -if (!clk_ret) - disable_unprepare: -clk_disable_unprepare (clk); -if (!IS_ERR (clk)) -clk_put (clk); -return NULL ; }static void __init d40_hw_init (struct d40_base *base)
@@ -3631,11 +3598,11 @@ static int __init d40_probe(struct platform_device *pdev) }else writel (base->phy_lcpa, base->virtbase +D40_DREG_LCPA ); - base->lcpa_base =ioremap (base->phy_lcpa, base->lcpa_size); + base->lcpa_base =devm_ioremap (dev, base->phy_lcpa, base->lcpa_size);if (!base->lcpa_base) { ret = -ENOMEM ;d40_err (dev,"Failed to ioremap LCPA region\n" ); - goto release_base; + goto report_failure; }/* If lcla has to be located in ESRAM we don't need to allocate */ if (base->plat_data->use_esram_lcla) {
@@ -3645,14 +3612,14 @@ static int __init d40_probe(struct platform_device *pdev) ret = -ENOENT ;d40_err (dev,"No \"lcla_esram\" memory resource\n" ); - goto destroy_cache; + goto report_failure; } - base->lcla_pool.base =ioremap (res->start, -resource_size (res)); + base->lcla_pool.base =devm_ioremap (dev, res->start, +resource_size (res));if (!base->lcla_pool.base) { ret = -ENOMEM ;d40_err (dev,"Failed to ioremap LCLA region\n" ); - goto destroy_cache; + goto report_failure; }writel (res->start, base->virtbase +D40_DREG_LCLA );
@@ -3732,16 +3699,8 @@ static int __init d40_probe(struct platform_device *pdev)dev_info (base->dev,"initialized\n" );return 0 ; - destroy_cache: -kmem_cache_destroy (base->desc_slab); -if (base->virtbase) -iounmap (base->virtbase); - -if (base->lcla_pool.base && base->plat_data->use_esram_lcla) { -iounmap (base->lcla_pool.base); - base->lcla_pool.base =NULL ; - } + destroy_cache:if (base->lcla_pool.dma_addr) dma_unmap_single(base->dev, base->lcla_pool.dma_addr, SZ_1K * base->num_phy_chans,
@@ -3753,28 +3712,11 @@ static int __init d40_probe(struct platform_device *pdev)kfree (base->lcla_pool.base_unaligned); -if (base->lcpa_base) -iounmap (base->lcpa_base); - -release_base: -if (base->phy_start) -release_mem_region (base->phy_start, - base->phy_size); -if (base->clk) { -clk_disable_unprepare (base->clk); -clk_put (base->clk); - } -if (base->lcpa_regulator) {regulator_disable (base->lcpa_regulator);regulator_put (base->lcpa_regulator); } -kfree (base->lcla_pool.alloc_map); -kfree (base->lookup_log_chans); -kfree (base->lookup_phy_chans); -kfree (base->phy_res); -kfree (base); report_failure:d40_err (dev,"probe failed\n" );return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1491/1848 dmaengine: ste_dma40: Fix probe IRQ leak
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 7ca608cf6b842685bbbe131d4f7d638f7cdc2b5d ]
d40_probe() registers the hardware interrupt before several later probe steps that can fail. Those error paths jump to destroy_cache without freeing the IRQ, leaving the handler registered after probe resources have been released.
Route failures after a successful IRQ request through a dedicated cleanup label. Keep the request before DMAengine registration because that registration publishes channels to clients.
--- drivers/dma/ste_dma40.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/dma/ste_dma40.c +4 -2
@@ -3680,7 +3680,7 @@ static int __init d40_probe(struct platform_device *pdev) ret =d40_dmaengine_init (base, num_reserved_chans);if (ret) - goto destroy_cache; + goto release_irq; ret =dma_set_max_seg_size (base->dev,STEDMA40_MAX_SEG_SIZE );if (ret) {
@@ -3694,12 +3694,14 @@ static int __init d40_probe(struct platform_device *pdev)if (ret) {dev_err (dev,"could not register of_dma_controller\n" ); - goto destroy_cache; + goto release_irq; }dev_info (base->dev,"initialized\n" );return 0 ; + release_irq: +free_irq (base->irq, base); destroy_cache:if (base->lcla_pool.dma_addr) dma_unmap_single(base->dev, base->lcla_pool.dma_addr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1492/1848 dmaengine: ste_dma40: Fix LCLA allocation order
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 7d4dc355c574d414d2402ac481a2fc4ee51e2771 ]
d40_lcla_allocate() calculates the number of pages needed for LCLA, but passes that raw page count as the allocation order to __get_free_pages(). The same value is later passed to free_pages().
Store the allocation order with get_order() instead, and use a separate byte size for allocation diagnostics, fallback kmalloc() sizing and DMA mapping.
--- drivers/dma/ste_dma40.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
drivers/dma/ste_dma40.c +16 -17
@@ -413,8 +413,8 @@ struct d40_desc {* @dma_addr: DMA address, if mapped * @base_unaligned: The orignal kmalloc pointer, if kmalloc is used. * This pointer is only there for clean-up on error. -* @pages: The number of pages needed for all physical channels. -* Only used later for clean-up on error +* @alloc_order: Order used for the LCLA page allocation. +* Only used later for clean-up on error. * @lock: Lock to protect the content in this struct. * @alloc_map: big map over which LCLA entry is own by which job. */
@@ -422,7 +422,7 @@ struct d40_lcla_pool {void *base;dma_addr_t dma_addr;void *base_unaligned; -int pages; +unsigned int alloc_order;spinlock_t lock;struct d40_desc **alloc_map; };
@@ -3412,6 +3412,7 @@ static void __init d40_hw_init(struct d40_base *base)static int __init d40_lcla_allocate (struct d40_base *base) {struct d40_lcla_pool *pool = &base->lcla_pool; +size_t lcla_size =SZ_1K * base->num_phy_chans;unsigned long *page_list;int i, j;int ret;
@@ -3427,20 +3428,20 @@ static int __init d40_lcla_allocate(struct d40_base *base)if (!page_list)return -ENOMEM ; -/* Calculating how many pages that are required */ - base->lcla_pool.pages =SZ_1K * base->num_phy_chans /PAGE_SIZE ; + base->lcla_pool.alloc_order =get_order (lcla_size);for (i =0 ; i <MAX_LCLA_ALLOC_ATTEMPTS ; i++) { page_list[i] =__get_free_pages (GFP_KERNEL , - base->lcla_pool.pages); + base->lcla_pool.alloc_order);if (!page_list[i]) { -d40_err (base->dev,"Failed to allocate %d pages.\n" , - base->lcla_pool.pages); +d40_err (base->dev,"Failed to allocate %zu bytes.\n" , + lcla_size); ret = -ENOMEM ;for (j =0 ; j < i; j++) -free_pages (page_list[j], base->lcla_pool.pages); +free_pages (page_list[j], + base->lcla_pool.alloc_order); goto free_page_list; }
@@ -3450,7 +3451,7 @@ static int __init d40_lcla_allocate(struct d40_base *base) }for (j =0 ; j < i; j++) -free_pages (page_list[j], base->lcla_pool.pages); +free_pages (page_list[j], base->lcla_pool.alloc_order);if (i <MAX_LCLA_ALLOC_ATTEMPTS ) { base->lcla_pool.base = (void *)page_list[i];
@@ -3460,10 +3461,9 @@ static int __init d40_lcla_allocate(struct d40_base *base)* alignment, try with allocating a big buffer. */ dev_warn (base->dev, -"[%s] Failed to get %d pages @ 18 bit align.\n" , - __func__, base->lcla_pool.pages); - base->lcla_pool.base_unaligned =kmalloc (SZ_1K * - base->num_phy_chans + +"[%s] Failed to get %zu bytes @ 18 bit align.\n" , + __func__, lcla_size); + base->lcla_pool.base_unaligned =kmalloc (lcla_size +LCLA_ALIGNMENT ,GFP_KERNEL );if (!base->lcla_pool.base_unaligned) {
@@ -3475,8 +3475,7 @@ static int __init d40_lcla_allocate(struct d40_base *base) LCLA_ALIGNMENT); } - pool->dma_addr =dma_map_single (base->dev, pool->base, -SZ_1K * base->num_phy_chans, + pool->dma_addr =dma_map_single (base->dev, pool->base, lcla_size,DMA_TO_DEVICE );if (dma_mapping_error (base->dev, pool->dma_addr)) { pool->dma_addr =0 ;
@@ -3710,7 +3709,7 @@ static int __init d40_probe(struct platform_device *pdev)if (!base->lcla_pool.base_unaligned && base->lcla_pool.base)free_pages ((unsigned long )base->lcla_pool.base, - base->lcla_pool.pages); + base->lcla_pool.alloc_order);kfree (base->lcla_pool.base_unaligned);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1493/1848 dmaengine: ste_dma40: Fix probe LCLA free
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 750dfcdb7a406bdd52d604099a631bbe96ddda91 ]
When LCLA is placed in ESRAM, d40_probe() stores a devm_ioremap() address in lcla_pool.base and leaves base_unaligned unset. The destroy_cache error path can then pass the ioremap address to free_pages().
Only free lcla_pool.base with free_pages() when the driver allocated the LCLA pool from normal memory. The ESRAM mapping is devm-managed.
--- drivers/dma/ste_dma40.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dma/ste_dma40.c +2 -1
@@ -3707,7 +3707,8 @@ static int __init d40_probe(struct platform_device *pdev)SZ_1K * base->num_phy_chans, DMA_TO_DEVICE); -if (!base->lcla_pool.base_unaligned && base->lcla_pool.base) +if (!base->plat_data->use_esram_lcla && + !base->lcla_pool.base_unaligned && base->lcla_pool.base)free_pages ((unsigned long )base->lcla_pool.base, base->lcla_pool.alloc_order);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1494/1848 dmaengine: ste_dma40: Put the LCPA SRAM node
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9a3762b470421658214baeb6cce3eed7344bb435 ]
of_parse_phandle() takes a reference to the LCPA SRAM node, but d40_probe() does not release it after translating the node into a resource. This leaks the node reference for the lifetime of the system.
Put the node immediately after of_address_to_resource() so both the success and error paths release the reference.
--- drivers/dma/ste_dma40.c | 1 + 1 file changed, 1 insertion(+)
drivers/dma/ste_dma40.c +1 -0
@@ -3579,6 +3579,7 @@ static int __init d40_probe(struct platform_device *pdev) }/* This is no device so read the address directly from the node */ ret =of_address_to_resource (np_lcpa,0 , &res_lcpa); +of_node_put (np_lcpa);if (ret) {dev_err (dev,"no LCPA SRAM resource\n" ); goto report_failure;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1495/1848 dmaengine: stedma40: fix physical typo
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
[ Upstream commit c281cde7a456aa9a56ced9175a4dead94048d3ba ]
Fix misspelling of "physical".
Stable-dep-of: f2baf04a695d ("dmaengine: ste_dma40: Fix memcpy channel parsing")
--- drivers/dma/ste_dma40.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/ste_dma40.c +1 -1
@@ -107,7 +107,7 @@ static int dma40_memcpy_channels[] = { DB8500_DMA_MEMCPY_EV_5, }; -/* Default configuration for physcial memcpy */ +/* Default configuration for physical memcpy */ static const struct stedma40_chan_cfg dma40_memcpy_conf_phy = { .mode =STEDMA40_MODE_PHYSICAL , .dir =DMA_MEM_TO_MEM ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1496/1848 dmaengine: ste_dma40: Pass dev to OF function
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit e59d81e9173ae4b5037a81a08b1c5a6915b333e3 ]
The OF platform data population function only wants to use struct device *dev, so pass that instead.
This change makes the compiler realize that the local platform data variable is unused, so drop that too.
Stable-dep-of: f2baf04a695d ("dmaengine: ste_dma40: Fix memcpy channel parsing")
--- drivers/dma/ste_dma40.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/dma/ste_dma40.c +6 -7
@@ -3491,14 +3491,14 @@ static int __init d40_lcla_allocate(struct d40_base *base)return ret; } -static int __init d40_of_probe (struct platform_device *pdev, +static int __init d40_of_probe (struct device *dev,struct device_node *np) {struct stedma40_platform_data *pdata;int num_phy =0 , num_memcpy =0 , num_disabled =0 ;const __be32 *list; - pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); + pdata =devm_kzalloc (dev,sizeof (*pdata),GFP_KERNEL );if (!pdata)return -ENOMEM ;
@@ -3511,7 +3511,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_memcpy /=sizeof (*list);if (num_memcpy >D40_MEMCPY_MAX_CHANS || num_memcpy <=0 ) { -d40_err (&pdev->dev, +d40_err (dev,"Invalid number of memcpy channels specified (%d)\n" , num_memcpy);return -EINVAL ;
@@ -3526,7 +3526,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_disabled /=sizeof (*list);if (num_disabled >=STEDMA40_MAX_PHYS || num_disabled <0 ) { -d40_err (&pdev->dev, +d40_err (dev,"Invalid number of disabled channels specified (%d)\n" , num_disabled);return -EINVAL ;
@@ -3537,7 +3537,7 @@ static int __init d40_of_probe(struct platform_device *pdev, num_disabled); pdata->disabled_channels[num_disabled] =-1 ; - pdev->dev.platform_data = pdata; + dev->platform_data = pdata;return 0 ; }
@@ -3545,7 +3545,6 @@ static int __init d40_of_probe(struct platform_device *pdev,static int __init d40_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct stedma40_platform_data *plat_data =dev_get_platdata (dev);struct device_node *np = pdev->dev.of_node;struct device_node *np_lcpa;int ret = -ENOENT ;
@@ -3555,7 +3554,7 @@ static int __init d40_probe(struct platform_device *pdev)int num_reserved_chans;u32 val; -if (d40_of_probe (pdev, np)) { +if (d40_of_probe (dev, np)) { ret = -ENOMEM ; goto report_failure; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1497/1848 dmaengine: ste_dma40: turn d40_base phy_chans into a flexible array
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit cc4fea19daeb0460fe3569e0a2d523f427b2bac1 ]
Convert the separately-offset phy_chans pointer to a C99 flexible array member at the end of struct d40_base, and switch the allocation to struct_size(). The log_chans and memcpy_chans slots continue to live in the same allocation immediately after phy_chans, indexed via base->log_chans. This removes the hand-rolled pointer fixup that recomputed phy_chans from base + ALIGN(sizeof(struct d40_base), 4).
The ALIGN(sizeof(struct d40_base), 4) requirement is met implicitly by the C compiler when using a flexible array member. With struct d40_chan phy_chans[] as the last member, the C standard guarantees sizeof(struct d40_base) includes trailing padding to satisfy the alignment of the flexible array element type (struct d40_chan). Since struct d40_chan contains members like spinlock_t, pointers, and struct dma_chan — all with alignment ≥ 4 — the compiler ensures sizeof(struct d40_base) is already a multiple of _Alignof(struct d40_chan) >= 4. The struct_size() macro then computes sizeof(struct d40_base) + sizeof(struct d40_chan) * num_phy_chans, so phy_chans[0] lands at a properly aligned offset without needing the manual ALIGN.
Stable-dep-of: f2baf04a695d ("dmaengine: ste_dma40: Fix memcpy channel parsing")
--- drivers/dma/ste_dma40.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/dma/ste_dma40.c +8 -6
@@ -604,7 +604,6 @@ struct d40_base {struct dma_device dma_both;struct dma_device dma_slave;struct dma_device dma_memcpy; -struct d40_chan *phy_chans;struct d40_chan *log_chans;struct d40_chan **lookup_log_chans;struct d40_chan **lookup_phy_chans;
@@ -623,6 +622,7 @@ struct d40_base {u32 *regs_interrupt;u16 gcc_pwr_off_mask;struct d40_gen_dmac gen_dmac; +struct d40_chan phy_chans[]; };static struct device *chan2dev (struct d40_chan *d40c)
@@ -3184,6 +3184,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)struct clk *clk;void __iomem *virtbase;struct d40_base *base; +size_t alloc_size;int num_log_chans;int num_phy_chans;int num_memcpy_chans;
@@ -3243,22 +3244,24 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)else num_phy_chans =4 * (readl (virtbase +D40_DREG_ICFG ) &0x7 ) +4 ; + num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS ); +/* The number of channels used for memcpy */ if (plat_data->num_of_memcpy_chans) num_memcpy_chans = plat_data->num_of_memcpy_chans;else num_memcpy_chans =ARRAY_SIZE (dma40_memcpy_channels); + num_memcpy_chans =min (num_memcpy_chans,D40_MEMCPY_MAX_CHANS ); num_log_chans = num_phy_chans *D40_MAX_LOG_CHAN_PER_PHY ;dev_info (dev,"hardware rev: %d with %d physical and %d logical channels\n" , rev, num_phy_chans, num_log_chans); - base =devm_kzalloc (dev, -ALIGN (sizeof (struct d40_base ),4 ) + - (num_phy_chans + num_log_chans + num_memcpy_chans) * -sizeof (struct d40_chan ),GFP_KERNEL ); + alloc_size =struct_size (base, phy_chans, num_phy_chans); + alloc_size +=sizeof (*base->log_chans) * (num_log_chans + num_memcpy_chans); + base =devm_kzalloc (dev, alloc_size,GFP_KERNEL );if (!base)return NULL ;
@@ -3271,7 +3274,6 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->virtbase = virtbase; base->plat_data = plat_data; base->dev = dev; - base->phy_chans = ((void *)base) +ALIGN (sizeof (struct d40_base ),4 ); base->log_chans = &base->phy_chans[num_phy_chans];if (base->plat_data->num_of_phy_chans ==14 ) {
Signature · 1 line
2.53.0