5.15.226-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1628/2214 PCI: aardvark: Disable PHY on probe failures
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 28cc5bc5a6c6cffbe7ba27c0acbfbe06747fa173 ]
advk_pcie_setup_phy() initializes and powers on the PHY before the emulated bridge and IRQ domains are created. If any of those later initialization steps or pci_host_probe() fails, probe returns without powering off or exiting the PHY.
Replace the direct returns with staged cleanup labels. Remove IRQ domains in reverse order, release the emulated bridge allocation only after successful initialization, and disable the PHY on every failure after advk_pcie_setup_phy() succeeds. A setup_phy() failure still returns directly, so its partial internal cleanup is not repeated.
--- drivers/pci/controller/pci-aardvark.c | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-)
drivers/pci/controller/pci-aardvark.c +18 -13
@@ -1811,28 +1811,25 @@ static int advk_pcie_probe(struct platform_device *pdev) ret =advk_sw_pci_bridge_init (pcie);if (ret) {dev_err (dev,"Failed to register emulated root PCI bridge\n" ); -return ret; + goto err_disable_phy; } ret =advk_pcie_init_irq_domain (pcie);if (ret) {dev_err (dev,"Failed to initialize irq\n" ); -return ret; + goto err_cleanup_bridge; } ret =advk_pcie_init_msi_irq_domain (pcie);if (ret) {dev_err (dev,"Failed to initialize irq\n" ); -advk_pcie_remove_irq_domain (pcie); -return ret; + goto err_remove_irq_domain; } ret =advk_pcie_init_rp_irq_domain (pcie);if (ret) {dev_err (dev,"Failed to initialize irq\n" ); -advk_pcie_remove_msi_irq_domain (pcie); -advk_pcie_remove_irq_domain (pcie); -return ret; + goto err_remove_msi_irq_domain; } bridge->sysdata = pcie;
@@ -1840,14 +1837,22 @@ static int advk_pcie_probe(struct platform_device *pdev) bridge->map_irq = advk_pcie_map_irq; ret =pci_host_probe (bridge); -if (ret <0 ) { -advk_pcie_remove_rp_irq_domain (pcie); -advk_pcie_remove_msi_irq_domain (pcie); -advk_pcie_remove_irq_domain (pcie); -return ret; - } +if (ret <0 ) + goto err_remove_rp_irq_domain;return 0 ; + +err_remove_rp_irq_domain: +advk_pcie_remove_rp_irq_domain (pcie); +err_remove_msi_irq_domain: +advk_pcie_remove_msi_irq_domain (pcie); +err_remove_irq_domain: +advk_pcie_remove_irq_domain (pcie); +err_cleanup_bridge: +pci_bridge_emul_cleanup (&pcie->bridge); +err_disable_phy: +advk_pcie_disable_phy (pcie); +return ret; }static int advk_pcie_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1629/2214 iommu/vt-d: Fix IQE handling to cover all descriptors in submission range
In reply to Greg Kroah-Hartman5.15-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
@@ -1261,6 +1261,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;
@@ -1281,18 +1324,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 1630/2214 wifi: mac80211: Fix a race when expiring a mesh path
In reply to Greg Kroah-Hartman5.15-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 1631/2214 RDMA/hns: Pin CQ buffer writable to match device DMA write access
In reply to Greg Kroah-Hartman5.15-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
@@ -205,6 +205,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 + PAGE_SHIFT,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1632/2214 RDMA/mlx5: Set WQ event handler before firmware RQ insertion
In reply to Greg Kroah-Hartman5.15-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
@@ -5411,6 +5411,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;
@@ -5434,7 +5435,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 1633/2214 RDMA/mlx5: Set SRQ event handler before xarray insertion
In reply to Greg Kroah-Hartman5.15-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
@@ -281,6 +281,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) {
@@ -289,8 +290,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 1634/2214 RDMA/mlx5: Set RQ event handler for raw-packet QP
In reply to Greg Kroah-Hartman5.15-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
@@ -1568,6 +1568,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 1635/2214 RDMA/mlx5: Initialize QP/RQ/SQ resource refcount before publishing it
In reply to Greg Kroah-Hartman5.15-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
@@ -160,6 +160,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),
@@ -168,10 +172,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 1636/2214 ALSA: via82xx: use helper to activate DXS controls
In reply to Greg Kroah-Hartman5.15-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
@@ -1251,11 +1251,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 ; }
@@ -1342,10 +1338,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 1637/2214 drm/exynos/fimd: fix register offset type in fimd_trigger()
In reply to Greg Kroah-Hartman5.15-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
@@ -955,7 +955,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 1638/2214 iio: dac: ad5758: Reject out-of-range raw values
In reply to Greg Kroah-Hartman5.15-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 1639/2214 iio: dac: ad5758: Fix the offset calculation
In reply to Greg Kroah-Hartman5.15-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 1640/2214 ALSA: caiaq: Fix the Kore controller key map
In reply to Greg Kroah-Hartman5.15-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 1641/2214 spi: spi-rspi: Add support to deassert/assert reset line
In reply to Greg Kroah-Hartman5.15-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 1642/2214 spi: rspi: Get rid of unused struct rspi_plat_data
In reply to Greg Kroah-Hartman5.15-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 1643/2214 spi: rspi: Fix DMA mode when the DMA controller is built as a module
In reply to Greg Kroah-Hartman5.15-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 1644/2214 ASoC: mediatek: mt8192: fix APLL mux error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e8c263e0ef957fd8286e299b2be9266b902cec16 ]
Propagate errors from clock operations in the enable path and clean up previously enabled clocks when a later operation fails.
For the disable path, continue disabling all clocks even if a clock operation fails. Log the error without returning it, so the disable path can perform as much cleanup as possible.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 54 +++++++++++++--------- 1 file changed, 32 insertions(+), 22 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +32 -22
@@ -87,7 +87,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], ret); - goto EXIT; +return ret; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_TOP_APLL1_CK ]);
@@ -95,7 +95,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_TOP_APLL1_CK ], ret); - goto EXIT; + goto err_disable_mux_aud_1; }/* 180.6336 / 4 = 45.1584MHz */
@@ -103,7 +103,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], ret); - goto EXIT; + goto err_set_parent_mux_aud_1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_TOP_APLL1_D4 ]);
@@ -111,31 +111,36 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_TOP_APLL1_D4 ], ret); - goto EXIT; + goto err_disable_mux_aud_eng1; } }else { ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); } -EXIT: +return 0 ; + +err_disable_mux_aud_eng1: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); +err_set_parent_mux_aud_1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], + afe_priv->clk[CLK_CLK26M ]); +err_disable_mux_aud_1: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); +return ret; }
@@ -149,7 +154,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], ret); - goto EXIT; +return ret; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_TOP_APLL2_CK ]);
@@ -157,7 +162,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_TOP_APLL2_CK ], ret); - goto EXIT; + goto err_disable_mux_aud_2; }/* 196.608 / 4 = 49.152MHz */
@@ -165,7 +170,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], ret); - goto EXIT; + goto err_set_parent_mux_aud_2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_TOP_APLL2_D4 ]);
@@ -173,31 +178,36 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_TOP_APLL2_D4 ], ret); - goto EXIT; + goto err_disable_mux_aud_eng2; } }else { ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_CLK26M ]); -if (ret) { +if (ret)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; - }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); } -EXIT: +return 0 ; + +err_disable_mux_aud_eng2: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); +err_set_parent_mux_aud_2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], + afe_priv->clk[CLK_CLK26M ]); +err_disable_mux_aud_2: +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1645/2214 ASoC: mediatek: mt8192: fix AFE clock error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 7c54781e6e60681af8d0858148d613becb582328 ]
If a clock operation fails in mt8192_afe_enable_clock(), the function returns immediately via the EXIT label without disabling the clocks that were successfully enabled earlier in the sequence. This leaves unneeded clocks running and causes a resource leak.
Properly unwind clocks enabled before an error by jumping to appropriate cleanup labels on failure.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 28 +++++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +19 -9
@@ -222,21 +222,21 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUDIO ], ret); - goto EXIT; +return ret; } ret =clk_prepare_enable (afe_priv->clk[CLK_INFRA_AUDIO_26M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_AUDIO_26M ], ret); - goto EXIT; + goto err_disable_infra_sys_audio; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIO ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], ret); - goto EXIT; + goto err_disable_infra_audio_26m; } ret =clk_set_parent (afe_priv->clk[CLK_MUX_AUDIO ], afe_priv->clk[CLK_CLK26M ]);
@@ -244,14 +244,14 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; + goto err_disable_mux_audio; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIOINTBUS ], ret); - goto EXIT; + goto err_disable_mux_audio; } ret =mt8192_set_audio_int_bus_parent (afe,CLK_CLK26M );
@@ -259,7 +259,7 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIOINTBUS ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUDIO_H],
@@ -268,17 +268,27 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUDIO_H ], aud_clks[CLK_TOP_APLL2_CK ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } ret =clk_prepare_enable (afe_priv->clk[CLK_AFE ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_AFE ], ret); - goto EXIT; + goto err_disable_mux_audiointbus; } -EXIT: +return 0 ; + +err_disable_mux_audiointbus: +clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]); +err_disable_mux_audio: +clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIO ]); +err_disable_infra_audio_26m: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_AUDIO_26M ]); +err_disable_infra_sys_audio: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1646/2214 ASoC: mediatek: mt8192: fix error handling in APLL enable functions
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 88760524ca995acd229c30ec69ced7d883a90a72 ]
If a clock operation fails in mt8192_apll1_enable() or apll2_enable(), the functions return without checking the return value of mux settings or unwinding previously enabled clocks and MUX configurations.
Fix this by checking the return value of apll1_mux_setting() and apll2_mux_setting(), and adding proper unwind handling on failure.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +24 -8
@@ -312,20 +312,22 @@ int mt8192_apll1_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll1_mux_setting (afe, true); + ret =apll1_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL22M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL22M ], ret); - goto EXIT; + goto err_disable_mux_setting; } ret =clk_prepare_enable (afe_priv->clk[CLK_APLL1_TUNER ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL1_TUNER ], ret); - goto EXIT; + goto err_disable_apll22m; } regmap_update_bits(afe->regmap, AFE_APLL1_TUNER_CFG,
@@ -336,7 +338,13 @@ int mt8192_apll1_enable(struct mtk_base_afe *afe)AFE_22M_ON_MASK_SFT , 0x1 << AFE_22M_ON_SFT); -EXIT: +return 0 ; + +err_disable_apll22m: +clk_disable_unprepare (afe_priv->clk[CLK_APLL22M ]); +err_disable_mux_setting: +apll1_mux_setting (afe, false); +return ret; }
@@ -362,20 +370,22 @@ int mt8192_apll2_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll2_mux_setting (afe, true); + ret =apll2_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL24M ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL24M ], ret); - goto EXIT; + goto err_disable_mux_setting; } ret =clk_prepare_enable (afe_priv->clk[CLK_APLL2_TUNER ]);if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_APLL2_TUNER ], ret); - goto EXIT; + goto err_disable_apll24m; } regmap_update_bits(afe->regmap, AFE_APLL2_TUNER_CFG,
@@ -386,7 +396,13 @@ int mt8192_apll2_enable(struct mtk_base_afe *afe)AFE_24M_ON_MASK_SFT , 0x1 << AFE_24M_ON_SFT); -EXIT: +return 0 ; + +err_disable_apll24m: +clk_disable_unprepare (afe_priv->clk[CLK_APLL24M ]); +err_disable_mux_setting: +apll2_mux_setting (afe, false); +return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1647/2214 ASoC: mediatek: mt8192: fix MCK clock error handling
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 4a0ab266cb1594f8c6aef3c79726476ad99618c5 ]
If an error occurs after enabling 'm_sel_id' or 'div_clk_id' in mt8192_mck_enable(), the function returns directly without disabling the previously enabled clocks, leading to a resource leak.
Fix this by jumping to proper cleanup labels to unwind enabled clocks on failure paths.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +11 -3
@@ -623,7 +623,7 @@ int mt8192_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)dev_err (afe->dev,"%s(), clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[m_sel_id], aud_clks[apll_clk_id], ret); -return ret; + goto err_disable_m_sel; } }
@@ -632,17 +632,25 @@ int mt8192_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[div_clk_id], ret); -return ret; + goto err_disable_m_sel; } ret =clk_set_rate (afe_priv->clk[div_clk_id], rate);if (ret) {dev_err (afe->dev,"%s(), clk_set_rate %s, rate %d, fail %d\n" , __func__, aud_clks[div_clk_id], rate, ret); -return ret; + goto err_disable_div_clk; }return 0 ; + +err_disable_div_clk: +clk_disable_unprepare (afe_priv->clk[div_clk_id]); +err_disable_m_sel: +if (m_sel_id >=0 ) +clk_disable_unprepare (afe_priv->clk[m_sel_id]); + +return ret; }void mt8192_mck_disable (struct mtk_base_afe *afe,int mck_id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1648/2214 ASoC: mediatek: mt8192: switch to devm_clk_get_optional()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 6f4edfdce0099dc0c346c78c85f58a23d4ee646e ]
Switch from devm_clk_get() to devm_clk_get_optional() when requesting clocks, as optional clocks automatically return NULL when not present instead of requiring manual check and NULL assignment.
Additionally, handle clock errors properly using dev_err_probe() to propagate error codes (such as -EPROBE_DEFER) on failure instead of just printing a warning and continuing with NULL pointers.
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +4 -7
@@ -676,13 +676,10 @@ int mt8192_init_clock(struct mtk_base_afe *afe)return -ENOMEM ;for (i =0 ; i <CLK_NUM ; i++) { - afe_priv->clk[i] =devm_clk_get (afe->dev, aud_clks[i]); -if (IS_ERR (afe_priv->clk[i])) { -dev_warn (afe->dev,"%s devm_clk_get %s fail, ret %ld\n" , - __func__, - aud_clks[i],PTR_ERR (afe_priv->clk[i])); - afe_priv->clk[i] =NULL ; - } + afe_priv->clk[i] =devm_clk_get_optional (afe->dev, aud_clks[i]); +if (IS_ERR (afe_priv->clk[i])) +return dev_err_probe (afe->dev,PTR_ERR (afe_priv->clk[i]), +"failed to get clock %s\n" , aud_clks[i]); } afe_priv->apmixedsys = syscon_regmap_lookup_by_phandle(of_node,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1649/2214 ASoC: mediatek: mt8192: mt8192-afe-gpio: Use guard() for mutex locks
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 14edf39daefbf7aa689ea2bb8811a85c498e0ff6 ]
Convert the explicit mutex_lock()/mutex_unlock() pair to guard(mutex) to simplify the locking logic and automatically release the mutex on all exit paths.
This changes the mutex release point from immediately before dev_warn() to automatic cleanup at scope exit. However, the affected path only emits a warning and immediately returns -EINVAL, without any further processing.
Stable-dep-of: 411be3902fa8 ("ASoC: mediatek: mt8192: Propagate errors in mt8192_afe_gpio_request()")
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +1 -3
@@ -209,7 +209,7 @@ static int mt8192_afe_gpio_adda_ch34_ul(struct device *dev, bool enable)int mt8192_afe_gpio_request (struct device *dev,bool enable,int dai,int uplink) { -mutex_lock (&gpio_request_mutex); +guard (mutex)(&gpio_request_mutex);switch (dai) {case MT8192_DAI_ADDA :if (uplink)
@@ -297,11 +297,9 @@ int mt8192_afe_gpio_request(struct device *dev, bool enable, }break ;default : -mutex_unlock (&gpio_request_mutex);dev_warn (dev,"%s(), invalid dai %d\n" , __func__, dai);return -EINVAL ; } -mutex_unlock (&gpio_request_mutex);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1650/2214 ASoC: mediatek: mt8192: Propagate errors in mt8192_afe_gpio_request()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 411be3902fa8f879db6f2f55d0c15507efe09c92 ]
Currently, mt8192_afe_gpio_request() ignores the return values from mt8192_afe_gpio_select() and other helper functions. If configuring a GPIO state fails, the function still returns 0, hiding the failure from callers.
Fix this by capturing and returning the error codes properly.
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 74 +++++++++++---------- 1 file changed, 40 insertions(+), 34 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +40 -34
@@ -209,98 +209,104 @@ static int mt8192_afe_gpio_adda_ch34_ul(struct device *dev, bool enable)int mt8192_afe_gpio_request (struct device *dev,bool enable,int dai,int uplink) { +int ret; +guard (mutex)(&gpio_request_mutex);switch (dai) {case MT8192_DAI_ADDA :if (uplink) -mt8192_afe_gpio_adda_ul (dev, enable); + ret =mt8192_afe_gpio_adda_ul (dev, enable);else -mt8192_afe_gpio_adda_dl (dev, enable); + ret =mt8192_afe_gpio_adda_dl (dev, enable);break ;case MT8192_DAI_ADDA_CH34 :if (uplink) -mt8192_afe_gpio_adda_ch34_ul (dev, enable); + ret =mt8192_afe_gpio_adda_ch34_ul (dev, enable);else -mt8192_afe_gpio_adda_ch34_dl (dev, enable); + ret =mt8192_afe_gpio_adda_ch34_dl (dev, enable);break ;case MT8192_DAI_I2S_0 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S0_OFF );break ;case MT8192_DAI_I2S_1 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S1_OFF );break ;case MT8192_DAI_I2S_2 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S2_OFF );break ;case MT8192_DAI_I2S_3 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S3_OFF );break ;case MT8192_DAI_I2S_5 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S5_OFF );break ;case MT8192_DAI_I2S_6 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S6_OFF );break ;case MT8192_DAI_I2S_7 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S7_OFF );break ;case MT8192_DAI_I2S_8 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S8_OFF );break ;case MT8192_DAI_I2S_9 :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_I2S9_OFF );break ;case MT8192_DAI_TDM :if (enable) -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_ON );else -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_OFF ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_TDM_OFF );break ;case MT8192_DAI_VOW :if (enable) { -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_CLK_ON ); -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_DAT_ON ); + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_CLK_ON ); +if (ret) +break ; + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_DAT_ON ); }else { -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_CLK_OFF ); -mt8192_afe_gpio_select (dev, -MT8192_AFE_GPIO_VOW_DAT_OFF ); + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_CLK_OFF ); +if (ret) +break ; + ret =mt8192_afe_gpio_select (dev, +MT8192_AFE_GPIO_VOW_DAT_OFF ); }break ;default :dev_warn (dev,"%s(), invalid dai %d\n" , __func__, dai); -return -EINVAL ; + ret = -EINVAL ; } -return 0 ; +return ret; }EXPORT_SYMBOL (mt8192_afe_gpio_request);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1651/2214 ASoC: mediatek: mt8192: check return values in mt8192_afe_gpio_init()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 7cca184ad434436e8f4648f71756bab0c3593ed9 ]
Currently, mt8192_afe_gpio_init() ignores the return values of mt8192_afe_gpio_select() and mt8192_afe_gpio_request(). If configuring GPIO states or requesting GPIOs fails during initialization, the function still proceeds and returns 0, masking the initialization failure.
Fix this by checking and propagating the return values properly.
--- sound/soc/mediatek/mt8192/mt8192-afe-gpio.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-gpio.c +8 -4
@@ -152,13 +152,17 @@ int mt8192_afe_gpio_init(struct device *dev) } } -mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_CLK_MOSI_ON ); + ret =mt8192_afe_gpio_select (dev,MT8192_AFE_GPIO_CLK_MOSI_ON ); +if (ret) +return ret;/* gpio status init */ -mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret; + ret =mt8192_afe_gpio_request (dev, false,MT8192_DAI_ADDA ,1 ); -return 0 ; +return ret; }EXPORT_SYMBOL (mt8192_afe_gpio_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1652/2214 ASoC: mediatek: mt8192: Handle regcache_sync() failure in runtime resume
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d9e264741b041fc9dffc555bc1ab68708658cefd ]
Currently, the return value of regcache_sync() in mt8192_afe_runtime_resume() is ignored. If regcache_sync() fails, the function continues execution with clocks enabled and regcache out of sync.
Fix this by checking the return value of regcache_sync(). On failure, restore regcache to cache-only mode and disable the clocks enabled earlier in the function.
--- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +5 -1
@@ -2107,7 +2107,11 @@ static int mt8192_afe_runtime_resume(struct device *dev) goto skip_regmap;regcache_cache_only (afe->regmap, false); -regcache_sync (afe->regmap); + ret =regcache_sync (afe->regmap); +if (ret) { +regcache_cache_only (afe->regmap, true); +mt8192_afe_disable_clock (afe); + }/* enable audio sys DCM for power saving */ regmap_update_bits(afe_priv->infracfg,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1653/2214 ASoC: mediatek: mt8192: Propagate mt8192_afe_gpio_request() errors in ADDA DAI
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit eed9414a1b075e2df308e7222e3786981bd42b32 ]
Currently, DAPM event handlers in mt8192-dai-adda.c ignore the return value of mt8192_afe_gpio_request(). If GPIO configuration fails during PRE_PMU or POST_PMD events, the error is silently ignored.
Fix this by checking and propagating error codes from mt8192_afe_gpio_request() in all ADDA DAPM event handlers.
--- sound/soc/mediatek/mt8192/mt8192-dai-adda.c | 44 +++++++++++++++------ 1 file changed, 32 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-adda.c +32 -12
@@ -302,13 +302,16 @@ static int mtk_adda_ul_event(struct snd_soc_dapm_widget *w,struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt);struct mt8192_afe_private *afe_priv = afe->platform_priv;int mtkaif_dmic = afe_priv->mtkaif_dmic; +int ret;dev_info (afe->dev,"%s(), name %s, event 0x%x, mtkaif_dmic %d\n" , __func__, w->name, event, mtkaif_dmic);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); +if (ret) +return ret;/* update setting to dmic */ if (mtkaif_dmic) {
@@ -326,7 +329,9 @@ static int mtk_adda_ul_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); +if (ret) +return ret;break ;default :break ;
@@ -344,6 +349,7 @@ static int mtk_adda_ch34_ul_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int mtkaif_dmic = afe_priv->mtkaif_dmic_ch34;int mtkaif_adda6_only = afe_priv->mtkaif_adda6_only; +int ret; dev_info(afe->dev, "%s(), name %s, event 0x%x, mtkaif_dmic %d, mtkaif_adda6_only %d\n",
@@ -351,8 +357,10 @@ static int mtk_adda_ch34_ul_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , -1 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , +1 ); +if (ret) +return ret;/* update setting to dmic */ if (mtkaif_dmic) {
@@ -382,8 +390,10 @@ static int mtk_adda_ch34_ul_event(struct snd_soc_dapm_widget *w,case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , -1 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , +1 ); +if (ret) +return ret;/* reset dmic */ afe_priv->mtkaif_dmic_ch34 =0 ;
@@ -537,18 +547,23 @@ static int mtk_adda_dl_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;dev_info (afe->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); +if (ret) +return ret;break ;default :break ;
@@ -563,20 +578,25 @@ static int mtk_adda_ch34_dl_event(struct snd_soc_dapm_widget *w, {struct snd_soc_component *cmpnt =snd_soc_dapm_to_component (w->dapm);struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt); +int ret;dev_info (afe->dev,"%s(), name %s, event 0x%x\n" , __func__, w->name, event);switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , -0 ); + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 , +0 ); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :/* should delayed 1/fs(smallest is 8k) = 125us before afe off */ usleep_range (125 ,135 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , -0 ); + ret =mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 , +0 ); +if (ret) +return ret;break ;default :break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1654/2214 ASoC: mediatek: mt8192: Propagate errors in TDM DAI DAPM event handlers
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d0bc9613bc2d9e20a7e4f3e447cd9427c95d194a ]
Currently, DAPM event handlers in mt8192-dai-tdm.c ignore return values from mt8192_afe_gpio_request() and mt8192_mck_enable().
If GPIO configuration or master clock setup fails during DAPM events, the error is silently ignored.
Fix this by checking and propagating error codes properly in all TDM DAI DAPM event handlers.
--- sound/soc/mediatek/mt8192/mt8192-dai-tdm.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-tdm.c +13 -5
@@ -250,6 +250,7 @@ static int mtk_tdm_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -261,16 +262,17 @@ static int mtk_tdm_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_afe_gpio_request (afe->dev, true, tdm_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, true, tdm_priv->id,0 );break ;case SND_SOC_DAPM_POST_PMD : -mt8192_afe_gpio_request (afe->dev, false, tdm_priv->id,0 ); + ret =mt8192_afe_gpio_request (afe->dev, false, tdm_priv->id,0 );break ;default : + ret =0 ;break ; } -return 0 ; +return ret; } static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,
@@ -282,6 +284,7 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -293,7 +296,9 @@ static int mtk_tdm_bck_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); + ret =mt8192_mck_enable (afe, tdm_priv->bck_id, tdm_priv->bck_rate); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD :mt8192_mck_disable (afe, tdm_priv->bck_id);
@@ -314,6 +319,7 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,struct mt8192_afe_private *afe_priv = afe->platform_priv;int dai_id =get_tdm_id_by_name (w->name);struct mtk_afe_tdm_priv *tdm_priv = afe_priv->dai_priv[dai_id]; +int ret;if (!tdm_priv) {dev_warn (afe->dev,"%s(), tdm_priv == NULL" , __func__);
@@ -325,7 +331,9 @@ static int mtk_tdm_mck_en_event(struct snd_soc_dapm_widget *w,switch (event) {case SND_SOC_DAPM_PRE_PMU : -mt8192_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); + ret =mt8192_mck_enable (afe, tdm_priv->mclk_id, tdm_priv->mclk_rate); +if (ret) +return ret;break ;case SND_SOC_DAPM_POST_PMD : tdm_priv->mclk_rate =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1655/2214 ASoC: mt8192: Remove function name log messages
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nícolas F. R. A. Prado via Alsa-devel <[email protected]>
[ Upstream commit f147ca85d6ecaf65106d1650f3c2e8afacbc833f ]
There are some log messages in the mt8192 sound code that print the function name, presumably to aid in tracing. However this can also be achieved by ftrace and without spamming the console, so remove these messages.
Stable-dep-of: d6c8a0b5bf69 ("ASoC: mediatek: mt8192-mt6359: Fix error handling in MTKAIF calibration")
--- sound/soc/mediatek/mt8192/mt8192-afe-clk.c | 4 ---- sound/soc/mediatek/mt8192/mt8192-afe-pcm.c | 4 ---- sound/soc/mediatek/mt8192/mt8192-dai-tdm.c | 2 -- sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 2 -- 4 files changed, 12 deletions(-)
sound/soc/mediatek/mt8192/mt8192-afe-clk.c +0 -4
@@ -216,8 +216,6 @@ int mt8192_afe_enable_clock(struct mtk_base_afe *afe)struct mt8192_afe_private *afe_priv = afe->platform_priv;int ret; -dev_info (afe->dev,"%s()\n" , __func__); - ret =clk_prepare_enable (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]);if (ret) { dev_err(afe->dev, "%s clk_prepare_enable %s fail %d\n",
@@ -296,8 +294,6 @@ void mt8192_afe_disable_clock(struct mtk_base_afe *afe) {struct mt8192_afe_private *afe_priv = afe->platform_priv; -dev_info (afe->dev,"%s()\n" , __func__); -clk_disable_unprepare (afe_priv->clk[CLK_AFE ]);mt8192_set_audio_int_bus_parent (afe,CLK_CLK26M );clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]);
sound/soc/mediatek/mt8192/mt8192-afe-pcm.c +0 -4
@@ -2055,8 +2055,6 @@ static int mt8192_afe_runtime_suspend(struct device *dev)unsigned int value;int ret; -dev_info (afe->dev,"%s()\n" , __func__); -if (!afe->regmap || afe_priv->pm_runtime_bypass_reg_ctl) goto skip_regmap;
@@ -2097,8 +2095,6 @@ static int mt8192_afe_runtime_resume(struct device *dev)struct mt8192_afe_private *afe_priv = afe->platform_priv;int ret; -dev_info (afe->dev,"%s()\n" , __func__); - ret =mt8192_afe_enable_clock (afe);if (ret)return ret;
sound/soc/mediatek/mt8192/mt8192-dai-tdm.c +0 -2
@@ -762,8 +762,6 @@ int mt8192_dai_tdm_register(struct mtk_base_afe *afe)struct mtk_afe_tdm_priv *tdm_priv;struct mtk_base_afe_dai *dai; -dev_info (afe->dev,"%s()\n" , __func__); - dai =devm_kzalloc (afe->dev,sizeof (*dai),GFP_KERNEL );if (!dai)return -ENOMEM ;
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +0 -2
@@ -142,8 +142,6 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)int counter;int mtkaif_calib_ok; -dev_info (afe->dev,"%s(), start\n" , __func__); -pm_runtime_get_sync (afe->dev);mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 );mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1656/2214 ASoC: mediatek: mt8192-mt6359: Fix error handling in MTKAIF calibration
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d6c8a0b5bf696d89350e43bf554362de8929f801 ]
mt8192_mt6359_mtkaif_calibration() ignored the return values of pm_runtime_get_sync() and mt8192_afe_gpio_request(), which could leave PM runtime references or GPIO state unbalanced on failure.
Switch to pm_runtime_resume_and_get(), check each GPIO request, and unwind on error.
--- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +25 -12
@@ -141,12 +141,23 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)int chosen_phase_1, chosen_phase_2, chosen_phase_3;int counter;int mtkaif_calib_ok; +int ret =0 ; -pm_runtime_get_sync (afe->dev); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,1 ); -mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,0 ); + ret =pm_runtime_resume_and_get (afe->dev); +if (ret <0 ) +return ret; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,1 ); +if (ret) + goto err_pm_put; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA ,0 ); +if (ret) + goto err_disable_adda_1; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,1 ); +if (ret) + goto err_disable_adda_0; + ret =mt8192_afe_gpio_request (afe->dev, true,MT8192_DAI_ADDA_CH34 ,0 ); +if (ret) + goto err_disable_adda_ch34_1;mt6359_mtkaif_calibration_enable (cmpnt_codec);
@@ -267,10 +278,14 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd)mt6359_mtkaif_calibration_disable (cmpnt_codec); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); -mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,1 );mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,0 ); +err_disable_adda_ch34_1: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA_CH34 ,1 ); +err_disable_adda_0: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,0 ); +err_disable_adda_1: +mt8192_afe_gpio_request (afe->dev, false,MT8192_DAI_ADDA ,1 ); +err_pm_put:pm_runtime_put (afe->dev); dev_info(afe->dev, "%s(), mtkaif_chosen_phase[0/1/2]:%d/%d/%d\n",
@@ -279,7 +294,7 @@ static int mt8192_mt6359_mtkaif_calibration(struct snd_soc_pcm_runtime *rtd) afe_priv->mtkaif_chosen_phase[1 ], afe_priv->mtkaif_chosen_phase[2]); -return 0 ; +return ret; }static int mt8192_mt6359_init (struct snd_soc_pcm_runtime *rtd)
@@ -297,9 +312,7 @@ static int mt8192_mt6359_init(struct snd_soc_pcm_runtime *rtd) afe_priv->mtkaif_protocol =MTKAIF_PROTOCOL_2_CLK_P2 ;/* mtkaif calibration */ -mt8192_mt6359_mtkaif_calibration (rtd); - -return 0 ; +return mt8192_mt6359_mtkaif_calibration (rtd); }static int mt8192_rt5682_init (struct snd_soc_pcm_runtime *rtd)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1657/2214 soc: ti: k3-ringacc: Correct ring API kernel-doc
In reply to Greg Kroah-Hartman5.15-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
@@ -88,11 +88,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);
@@ -103,10 +102,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.
@@ -126,8 +123,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.
@@ -217,8 +215,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. */
@@ -242,7 +240,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 1658/2214 soc: ti: k3-ringacc: Fix DMA ring initialization kernel-doc
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 6c4e6e8f5cf95f7e0d4f04928a9ae70e20c73d4b ]
The heading for k3_ringacc_init_data repeats struct, so kernel-doc cannot match it to the declaration. Its three fields are also missing descriptions.
Use the structure name and describe the firmware handle, device ID, and total number of available rings used during DMA ring initialization.
--- include/linux/soc/ti/k3-ringacc.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/soc/ti/k3-ringacc.h +4 -1
@@ -254,7 +254,10 @@ u32 k3_ringacc_get_tisci_dev_id(struct k3_ring *ring);struct ti_sci_handle ;/** -* struct struct k3_ringacc_init_data - Initialization data for DMA rings +* struct k3_ringacc_init_data - Initialization data for DMA rings +* @tisci: TI SCI firmware handle +* @tisci_dev_id: TI SCI device ID of the DMA controller +* @num_rings: Total number of available rings */ struct k3_ringacc_init_data {const struct ti_sci_handle *tisci;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1659/2214 RDMA/mlx5: Restore mr->pi_mr after temporary stack-local assignment
In reply to Greg Kroah-Hartman5.15-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
@@ -1149,6 +1149,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 1660/2214 IB/isert: Dont share drop_cmd_list across concurrent connection teardowns
In reply to Greg Kroah-Hartman5.15-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
@@ -2589,7 +2589,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 1661/2214 PCI/IOV: Read VF config values that need not match PF
In reply to Greg Kroah-Hartman5.15-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
@@ -111,29 +111,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) {
@@ -269,8 +246,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
@@ -360,10 +360,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
@@ -1768,8 +1768,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;
@@ -1779,8 +1784,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
@@ -1794,7 +1799,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 1662/2214 swim: Fix FDEJECT ioctl for exclusive open
In reply to Greg Kroah-Hartman5.15-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
@@ -695,10 +695,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 1663/2214 swim3: Fix FDEJECT ioctl for exclusive open
In reply to Greg Kroah-Hartman5.15-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
@@ -886,7 +886,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 ;
@@ -897,10 +896,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 1664/2214 RDMA/bnxt_re: Fix integer overflow in send payload size computation
In reply to Greg Kroah-Hartman5.15-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;
@@ -2528,17 +2529,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)
@@ -2561,7 +2567,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);
@@ -2577,11 +2584,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 ;
@@ -2609,7 +2614,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);
@@ -2626,11 +2632,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 1665/2214 RDMA/bnxt_re: Detect wrong sge_len passed for inline
In reply to Greg Kroah-Hartman5.15-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
@@ -2512,8 +2512,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 1666/2214 RDMA/bnxt_re: Initialize wqe.flags in bnxt_re_post_srq_recv()
In reply to Greg Kroah-Hartman5.15-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
@@ -1763,6 +1763,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 1667/2214 RDMA/bnxt_re: Fix the PD and DPI table size
In reply to Greg Kroah-Hartman5.15-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 1668/2214 media: venus: Drop session events without an instance
In reply to Greg Kroah-Hartman5.15-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
@@ -190,6 +190,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 1669/2214 IB/mad: fix UAF and double-free in RMPP receive reassembly
In reply to Greg Kroah-Hartman5.15-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 1670/2214 clk: ti: adpll: unregister OF clock provider on remove
In reply to Greg Kroah-Hartman5.15-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
@@ -944,6 +944,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 1671/2214 clk: si5351: fail prepare when PLL reset times out
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit b6685c30d15cd7f28c40b2daaeacc00f21b2f12a ]
The clock prepare path requests a PLL reset when the platform data requires a deterministic output phase. The reset helper logs polling errors but returns no status, so prepare still enables the output and reports success when the reset did not complete.
Return the poll result to prepare, restore the output power-down bit on failure, and leave the output disabled. XTAL and CLKIN inputs continue to bypass PLL reset successfully.
The issue was found by our static-analysis tool.
--- drivers/clk/clk-si5351.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/clk/clk-si5351.c +16 -4
@@ -899,7 +899,7 @@ static int _si5351_clkout_set_disable_state(return 0 ; } -static void _si5351_clkout_reset_pll (struct si5351_driver_data *drvdata,int num) +static int _si5351_clkout_reset_pll (struct si5351_driver_data *drvdata,int num) {u8 val =si5351_reg_read (drvdata,SI5351_CLK0_CTRL + num); u8 mask = val & SI5351_CLK_PLL_SELECT ? SI5351_PLL_RESET_B :
@@ -910,7 +910,7 @@ static void _si5351_clkout_reset_pll(struct si5351_driver_data *drvdata, int numswitch (val &SI5351_CLK_INPUT_MASK ) {case SI5351_CLK_INPUT_XTAL :case SI5351_CLK_INPUT_CLKIN : -return ;/* pll not used, no need to reset */ +return 0 ;/* pll not used, no need to reset */ }si5351_reg_write (drvdata,SI5351_PLL_RESET , mask);
@@ -923,6 +923,8 @@ static void _si5351_clkout_reset_pll(struct si5351_driver_data *drvdata, int numdev_dbg (&drvdata->client->dev,"%s - %s: pll = %d\n" , __func__,clk_hw_get_name (&drvdata->clkout[num].hw), (val &SI5351_CLK_PLL_SELECT ) ?1 :0 ); + +return err; }static int si5351_clkout_prepare (struct clk_hw *hw)
@@ -939,8 +941,18 @@ static int si5351_clkout_prepare(struct clk_hw *hw)* Do a pll soft reset on the parent pll -- needed to get a * deterministic phase relationship between the output clocks. */ -if (pdata->clkout[hwdata->num].pll_reset) -_si5351_clkout_reset_pll (hwdata->drvdata, hwdata->num); +if (pdata->clkout[hwdata->num].pll_reset) { +int ret; + + ret =_si5351_clkout_reset_pll (hwdata->drvdata, hwdata->num); +if (ret) { +si5351_set_bits (hwdata->drvdata, +SI5351_CLK0_CTRL + hwdata->num, +SI5351_CLK_POWERDOWN , +SI5351_CLK_POWERDOWN ); +return ret; + } + }si5351_set_bits (hwdata->drvdata,SI5351_OUTPUT_ENABLE_CTRL , (1 << hwdata->num),0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1672/2214 RDMA/nldev: Fix NULL deref in dumps of objects abandoned by DRIVER_FAILURE
In reply to Greg Kroah-Hartman5.15-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
@@ -615,7 +615,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 ;
@@ -702,7 +703,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 1673/2214 RDMA/rtrs-clt: Reject invalid queue_depth from the peer
In reply to Greg Kroah-Hartman5.15-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
@@ -1847,6 +1847,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 (clt_path->queue_depth >0 && queue_depth != clt_path->queue_depth) {rtrs_err (clt,"Error: queue depth changed\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1674/2214 RDMA/mad: Reject receive completions shorter than GRH
In reply to Greg Kroah-Hartman5.15-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
@@ -2084,6 +2084,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 1675/2214 time: Prevent time64_to_tm() day truncation on 32-bit
In reply to Greg Kroah-Hartman5.15-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 1676/2214 RDMA/rtrs-clt: Dont WARN on unexpected info-response opcode
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quanye Yang <[email protected]>
[ Upstream commit 49c5691ad76f000e66c4f2635d5f196db5d038f9 ]
The info-response receive is posted for a SEND. The completion opcode comes from the peer, so RDMA WRITE with Immediate is a legal WC on that WQE even though it violates the RTRS handshake.
WARN_ON(wc->opcode != IB_WC_RECV) treats that peer-controlled field as an internal invariant and panics with panic_on_warn. Treat a non-SEND completion as a handshake failure: log it and keep the existing CONNECTING_ERR cleanup.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +6 -1
@@ -2494,7 +2494,12 @@ static void rtrs_clt_info_rsp_done(struct ib_cq *cq, struct ib_wc *wc) ib_wc_status_msg(wc->status)); goto out; } -WARN_ON (wc->opcode !=IB_WC_RECV ); +if (wc->opcode !=IB_WC_RECV ) { +rtrs_err (clt_path->clt, +"Path info response has unexpected opcode %d\n" , + wc->opcode); + goto out; + }if (wc->byte_len <sizeof (*msg)) { rtrs_err(clt_path->clt, "Path info response is malformed: size %d\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1677/2214 selftests/timers: clocksource-switch: Fix unchecked open()/read()
In reply to Greg Kroah-Hartman5.15-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 1678/2214 RDMA/rtrs-clt: Validate peer-supplied IO completion msg_id
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quanye Yang <[email protected]>
[ Upstream commit c1fcde82f7b68181553af7efb4410df04109a9a8 ]
process_io_rsp() indexes clt_path->reqs[] with the 19-bit msg_id taken from a WRITE_WITH_IMM immediate. That value is chosen by the peer. The only check was WARN_ON(msg_id >= queue_depth), which still lets a completion run after free_path_reqs() has set reqs to NULL, or against a slot whose FRWR is already gone. Either path dereferences req->mr and can GPF; KASAN reports a null-ptr-deref at offsetof(struct rtrs_clt_io_req, mr).
Treat a missing reqs array, an out-of-range msg_id, or a req without an MR as a protocol error and recover the connection.
--- drivers/infiniband/ulp/rtrs/rtrs-clt.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-)
drivers/infiniband/ulp/rtrs/rtrs-clt.c +16 -5
@@ -490,18 +490,22 @@ static int rtrs_post_send_rdma(struct rtrs_clt_con *con, imm, flags, wr, NULL); } -static void process_io_rsp (struct rtrs_clt_path *clt_path,u32 msg_id, +static bool process_io_rsp (struct rtrs_clt_path *clt_path,u32 msg_id,s16 errno,bool w_inval) {struct rtrs_clt_io_req *req; -if (WARN_ON (msg_id >= clt_path->queue_depth)) -return ; +if (!clt_path->reqs || msg_id >= clt_path->queue_depth) +return false; req = &clt_path->reqs[msg_id]; +if (!req->mr) +return false; +/* Drop need_inv if server responded with send with invalidation */ req->need_inv &= !w_inval;complete_rdma_req (req, errno, true, false); +return true; }static void rtrs_clt_recv_done (struct rtrs_clt_con *con,struct ib_wc *wc)
@@ -563,7 +567,8 @@ static void rtrs_clt_rkey_rsp_done(struct rtrs_clt_con *con, struct ib_wc *wc)if (WARN_ON (buf_id != msg_id)) goto out; clt_path->rbufs[buf_id].rkey =le32_to_cpu (msg->rkey); -process_io_rsp (clt_path, msg_id, err, w_inval); +if (!process_io_rsp (clt_path, msg_id, err, w_inval)) + goto out; }ib_dma_sync_single_for_device (clt_path->s.dev->ib_dev, iu->dma_addr, iu->size,DMA_FROM_DEVICE );
@@ -635,7 +640,13 @@ static void rtrs_clt_rdma_done(struct ib_cq *cq, struct ib_wc *wc) w_inval = (imm_type ==RTRS_IO_RSP_W_INV_IMM );rtrs_from_io_rsp_imm (imm_payload, &msg_id, &err); -process_io_rsp (clt_path, msg_id, err, w_inval); +if (!process_io_rsp (clt_path, msg_id, err, w_inval)) { +rtrs_err (clt_path->clt, +"Invalid IO rsp: msg_id %u queue_depth %zu\n" , + msg_id, clt_path->queue_depth); +rtrs_rdma_error_recovery (con); +return ; + } }else if (imm_type ==RTRS_HB_MSG_IMM ) {WARN_ON (con->c.cid);rtrs_send_hb_ack (&clt_path->s);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1679/2214 RDMA/siw: Fix length of first chunk in siw_try_1seg()
In reply to Greg Kroah-Hartman5.15-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_local (buffer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1680/2214 RDMA/hfi1: shut down the trap timer before unregistering
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit a1c9d476c2316685f85fffb6450ad88d01836357 ]
MAD processing arms a trap timer embedded in each hfi1_ibport. Device unregistration does not stop the timer, so its callback can run after the port and its containing hfi1_devdata have been released.
Shut down every port timer before unregistering the IB device. The shutdown form also prevents a concurrent path from rearming the timer.
--- drivers/infiniband/hw/hfi1/verbs.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/hw/hfi1/verbs.c +4 -0
@@ -1906,6 +1906,10 @@ int hfi1_register_ib_device(struct hfi1_devdata *dd)void hfi1_unregister_ib_device (struct hfi1_devdata *dd) {struct hfi1_ibdev *dev = &dd->verbs_dev; +int i; + +for (i =0 ; i < dd->num_pports; i++) +timer_shutdown_sync (&dd->pport[i].ibport_data.rvp.trap_timer);hfi1_verbs_unregister_sysfs (dd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1681/2214 RDMA/hfi1: quiesce SDMA asynchronous cleanup on exit
In reply to Greg Kroah-Hartman5.15-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
@@ -1583,6 +1583,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 1682/2214 kconfig: tests: Provide defconfig outfile for savedefconfig
In reply to Greg Kroah-Hartman5.15-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 1683/2214 RDMA/irdma: Do not move a fresh RoCE QP to ERROR on RESET
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nguyễn Văn Cao Nguyên <[email protected]>
[ Upstream commit 6de34bfb56ad8c24bf63b243b5f32b345d9cdd4d ]
irdma_modify_qp_roce() handles IB_QPS_RESET like IB_QPS_ERR and moves the QP to ERROR. On a QP that was never moved to INIT, this makes the following RESET->INIT fail with -EINVAL, while ibv_query_qp() still reports RESET.
RESET->RESET is a valid transition. The Mooncake transfer engine resets every new QP before INIT, so it cannot connect over an E810, while mlx5 accepts the same sequence:
ibv_create_qp(RC) -> RESET
ibv_modify_qp(RESET) -> 0
ibv_modify_qp(INIT, ...) -> -EINVAL
Skip the hardware modify when the QP has not been moved to INIT yet (iwarp_state is IRDMA_QP_STATE_INVALID), as there is nothing to flush. RESET after INIT still goes to ERROR.
--- drivers/infiniband/hw/irdma/verbs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/infiniband/hw/irdma/verbs.c +9 -1
@@ -1348,9 +1348,17 @@ int irdma_modify_qp_roce(struct ib_qp *ibqp, struct ib_qp_attr *attr, issue_modify_qp =1 ; iwqp->suspend_pending = true;break ; +case IB_QPS_RESET : +/* +* A QP that was never moved to INIT has nothing to +* flush, so skip the hardware modify. Moving it to +* ERROR would make the following INIT fail. +*/ +if (iwqp->iwarp_state ==IRDMA_QP_STATE_INVALID ) +break ; + fallthrough;case IB_QPS_SQE :case IB_QPS_ERR : -case IB_QPS_RESET :if (iwqp->iwarp_state ==IRDMA_QP_STATE_ERROR ) { iwqp->ibqp_state = attr->qp_state;spin_unlock_irqrestore (&iwqp->lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1684/2214 rtc: bd70528: properly enable wakeup
In reply to Greg Kroah-Hartman5.15-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>
@@ -318,6 +319,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 1685/2214 dt-bindings: vendor-prefixes: add Source Parts and Lctech names
In reply to Greg Kroah-Hartman5.15-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
@@ -649,6 +649,8 @@ patternProperties: description: Lantiq Semiconductor "^lattice,.*": description: Lattice Semiconductor + "^lctech,.*": + description: Shenzen LC Technology Co., Ltd. "^leadtek,.*": description: Shenzhen Leadtek Technology Co., Ltd. "^leeco,.*":
@@ -1132,6 +1134,8 @@ patternProperties: description: Solomon Systech Limited "^sony,.*": description: Sony Corporation + "^sourceparts,.*": + description: Source Parts Inc. "^spansion,.*": description: Spansion Inc. "^sparkfun,.*":
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1686/2214 dt-bindings: vendor-prefixes: add milkv/sophgo
In reply to Greg Kroah-Hartman5.15-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
@@ -763,6 +763,8 @@ patternProperties: description: MikroElektronika d.o.o. "^mikrotik,.*": description: MikroTik + "^milkv,.*": + description: MilkV Technology Co., Ltd "^miniand,.*": description: Miniand Tech "^minix,.*":
@@ -1134,6 +1136,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 1687/2214 dt-bindings: vendor-prefixes: Add Sophos
In reply to Greg Kroah-Hartman5.15-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
@@ -1138,6 +1138,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 1688/2214 x86/hibernate: Ignore page-zero RAM in E820 checksum
In reply to Greg Kroah-Hartman5.15-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 1689/2214 ARM: mvebu: fix Cortex-A9 errata selection for Armada 38x
In reply to Greg Kroah-Hartman5.15-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 1690/2214 drm/msm/mdp5: drop cursor pipe for msm8x76
In reply to Greg Kroah-Hartman5.15-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
@@ -706,15 +706,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 1691/2214 staging: sm750fb: free cmap on framebuffer release
In reply to Greg Kroah-Hartman5.15-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 1692/2214 OPP: Fix the return value in dev_pm_opp_get_of_node() kernel-doc
In reply to Greg Kroah-Hartman5.15-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
@@ -1348,7 +1348,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 1693/2214 rtc: ftrtc010: drop needless struct ftrtc010_rtc::rtc_dev member
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
[ Upstream commit a55d44807b63f171f8079d770c9d82fa87046cdd ]
The memory pointed to by the ::rtc_dev member is managed via devres, and no code in this driver uses it past _probe().
We can drop it from the structure and just use a local temporary variable, reducing runtime memory consumption by a few bytes.
Stable-dep-of: c60478875a44 ("rtc: ftrtc010: fix clock resource leak on probe failure")
--- drivers/rtc/rtc-ftrtc010.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/rtc/rtc-ftrtc010.c +8 -9
@@ -28,7 +28,6 @@ MODULE_LICENSE("GPL");MODULE_ALIAS ("platform:" DRV_NAME );struct ftrtc010_rtc { -struct rtc_device *rtc_dev;void __iomem *rtc_base;int rtc_irq;struct clk *pclk;
@@ -113,6 +112,7 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)struct ftrtc010_rtc *rtc;struct device *dev = &pdev->dev;struct resource *res; +struct rtc_device *rtc_dev;int ret; rtc =devm_kzalloc (&pdev->dev,sizeof (*rtc),GFP_KERNEL );
@@ -160,29 +160,28 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) goto err_disable_extclk; } - rtc->rtc_dev =devm_rtc_allocate_device (dev); -if (IS_ERR (rtc->rtc_dev)) { - ret =PTR_ERR (rtc->rtc_dev); + rtc_dev =devm_rtc_allocate_device (dev); +if (IS_ERR (rtc_dev)) { + ret =PTR_ERR (rtc_dev); goto err_disable_extclk; } - rtc->rtc_dev->ops = &ftrtc010_rtc_ops; + rtc_dev->ops = &ftrtc010_rtc_ops; sec =readl (rtc->rtc_base +FTRTC010_RTC_SECOND ); min =readl (rtc->rtc_base +FTRTC010_RTC_MINUTE ); hour =readl (rtc->rtc_base +FTRTC010_RTC_HOUR ); days =readl (rtc->rtc_base +FTRTC010_RTC_DAYS ); - rtc->rtc_dev->range_min = (u64 )days *86400 + hour *3600 + - min *60 + sec; - rtc->rtc_dev->range_max =U32_MAX + rtc->rtc_dev->range_min; + rtc_dev->range_min = (u64 )days *86400 + hour *3600 + min *60 + sec; + rtc_dev->range_max =U32_MAX + rtc_dev->range_min; ret =devm_request_irq (dev, rtc->rtc_irq, ftrtc010_rtc_interrupt,IRQF_SHARED , pdev->name, dev);if (unlikely (ret)) goto err_disable_extclk; -return devm_rtc_register_device (rtc->rtc_dev); +return devm_rtc_register_device (rtc_dev); err_disable_extclk:clk_disable_unprepare (rtc->extclk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1694/2214 rtc: ftrtc010: fix clock resource leak on probe failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liu Dalin <[email protected]>
[ Upstream commit c60478875a445dee1206aad6285c18cd8c91f7f2 ]
When devm_rtc_register_device() fails, ftrtc010_rtc_probe() returns the error directly without releasing clocks obtained via clk_prepare_enable(). This leaks both extclk and pclk resources, which may prevent subsequent probe attempts or module removal.
Capture the return value and jump to the error handling path to properly release clocks via clk_disable_unprepare().
Fixes smatch warnings:
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->extclk' from clk_prepare_enable() not released on lines: 183.
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
'rtc->pclk' from clk_prepare_enable() not released on lines: 183.
--- drivers/rtc/rtc-ftrtc010.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ftrtc010.c +5 -1
@@ -181,7 +181,11 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)if (unlikely (ret)) goto err_disable_extclk; -return devm_rtc_register_device (rtc_dev); + ret =devm_rtc_register_device (rtc_dev); +if (ret) + goto err_disable_extclk; + +return 0 ; err_disable_extclk:clk_disable_unprepare (rtc->extclk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1695/2214 ARM: vexpress: fix device_node refcount leak in vexpress_flags_set()
In reply to Greg Kroah-Hartman5.15-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 1696/2214 ARM: vexpress: fix device_node refcount leak in vexpress_smp_dt_prepare_cpus()
In reply to Greg Kroah-Hartman5.15-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 1697/2214 misc: enclosure: fix UAF on device_register() failure
In reply to Greg Kroah-Hartman5.15-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 1698/2214 pinctrl: mediatek: mt7629: fix the 2.4 GHz Wi-Fi pin mode array
In reply to Greg Kroah-Hartman5.15-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 1699/2214 drm/tegra: Fix syncobj_in wait return value check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 27836c46a3db5a7869a9f7e181136f0c4d8bc0d1 ]
dma_fence_wait_timeout() returns the remaining timeout in jiffies on success, zero on timeout, and a negative error code if interrupted. The return value was assigned to 'err' and checked as if it were an errno, the opposite of the correct logic.
Fix the code to use a properly typed variable and check each condition correctly.
--- drivers/gpu/drm/tegra/submit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/tegra/submit.c +8 -2
@@ -506,6 +506,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,if (args->syncobj_in) {struct dma_fence *fence; +long wait_err; err =drm_syncobj_find_fence (file, args->syncobj_in,0 ,0 , &fence);if (err) {
@@ -513,10 +514,15 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, goto unlock; } - err =dma_fence_wait_timeout (fence, true,msecs_to_jiffies (10000 )); + wait_err =dma_fence_wait_timeout (fence, true,msecs_to_jiffies (10000 ));dma_fence_put (fence); -if (err) { +if (wait_err ==0 ) {SUBMIT_ERR (context,"wait for syncobj_in timed out" ); + err = -ETIMEDOUT ; + goto unlock; + }else if (wait_err <0 ) { +/* In practice, -ERESTARTSYS */ + err = wait_err; goto unlock; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1700/2214 drm/tegra: Dont pass an ERR_PTR to drm_syncobj_replace_fence()
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 7fce3d34eddfff6361cb4de2c5b8789b88a552b6 ]
When host1x_fence_create() fails, avoid trying to attach the error pointer to the out syncobj.
--- drivers/gpu/drm/tegra/submit.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tegra/submit.c +1 -0
@@ -601,6 +601,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,if (IS_ERR (fence)) { err =PTR_ERR (fence);SUBMIT_ERR (context,"failed to create postfence: %d" , err); + goto put_job; }drm_syncobj_replace_fence (syncobj, fence);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1701/2214 drm/tegra: Drop reference on postfence
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikko Perttunen <[email protected]>
[ Upstream commit 5ba3dfe724448f308ad7b28ef8d4f41bca4896ae ]
drm_syncobj_replace_fence() calls dma_fence_get() on the parameter fence, so we need to drop ours. Add a call to dma_fence_put() to do that.
--- drivers/gpu/drm/tegra/submit.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/tegra/submit.c +1 -0
@@ -605,6 +605,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data, }drm_syncobj_replace_fence (syncobj, fence); +dma_fence_put (fence); } goto put_job;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1702/2214 nvdimm/pmem: Release gendisk on probe failure
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hemanth Selam <[email protected]>
[ Upstream commit 855a46681e0ba601952c346e5b62d867e51ecb23 ]
pmem_attach_disk() allocates the gendisk with blk_alloc_disk() and hands it to devres only once device_add_disk() has succeeded. Until that point the probe path owns the disk itself, which is why every failure after the allocation jumps to the out: label and puts it there.
The devm_init_badblocks() failure returns directly instead, so the disk allocated a few lines earlier is never released. Nothing releases it afterwards either: the devres action that would have done so has not been registered yet, so unbinding the namespace or destroying it does not reach the disk, and it stays allocated along with its queue and its bdev inode until the machine is rebooted.
devm_init_badblocks() only fails when a single page allocation fails, so reaching this at all needs memory exhaustion during namespace probe, and because device_add_disk() has not run there is nothing user visible left
behind: no device node, no sysfs entry, only the leaked memory.
Release the gendisk through the existing cleanup path on this failure.
--- drivers/nvdimm/pmem.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvdimm/pmem.c +4 -2
@@ -448,8 +448,10 @@ static int pmem_attach_disk(struct device *dev,nvdimm_namespace_disk_name (ndns, disk->disk_name);set_capacity (disk, (pmem->size - pmem->pfn_pad - pmem->data_offset) /512 ); -if (devm_init_badblocks (dev, &pmem->bb)) -return -ENOMEM ; +if (devm_init_badblocks (dev, &pmem->bb)) { + rc = -ENOMEM ; + goto out; + }nvdimm_badblocks_populate (nd_region, &pmem->bb, &bb_range); disk->bb = &pmem->bb;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1703/2214 crypto: atmel - handle authenc requests without plaintext
In reply to Greg Kroah-Hartman5.15-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
@@ -2029,6 +2029,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 1704/2214 crypto: tcrypt - add asynchronous speed test for SM3
In reply to Greg Kroah-Hartman5.15-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
@@ -2550,31 +2550,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 1705/2214 crypto: tcrypt - remove all multibuffer ahash tests
In reply to Greg Kroah-Hartman5.15-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) {
@@ -2553,36 +2359,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 1706/2214 crypto: tcrypt - Use pr_info/pr_err
In reply to Greg Kroah-Hartman5.15-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),
@@ -2827,7 +2827,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 1707/2214 crypto: tcrypt - Drop leading newlines from prints
In reply to Greg Kroah-Hartman5.15-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 ;
@@ -1326,7 +1326,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 1708/2214 crypto: tcrypt - Avoid reading req->base after submission
In reply to Greg Kroah-Hartman5.15-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); }
@@ -1219,16 +1237,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;
@@ -1236,10 +1254,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)
@@ -1251,9 +1269,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;
@@ -1261,10 +1280,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)
@@ -1277,10 +1296,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 ();
@@ -1302,8 +1321,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;
@@ -1316,7 +1335,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 );
@@ -1336,8 +1355,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 {
@@ -1404,11 +1424,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 1709/2214 hwrng: intel - return -ENOMEM when kmalloc_obj() fails
In reply to Greg Kroah-Hartman5.15-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 intel_rng_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 1710/2214 rtc: ftrtc010: fix integer overflow in time calculation
In reply to Greg Kroah-Hartman5.15-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
@@ -73,7 +73,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);
@@ -93,7 +93,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 1711/2214 hwrng: intel - return -ENOMEM when ioremap() fails
In reply to Greg Kroah-Hartman5.15-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 1712/2214 clocksource/drivers/dbx500-prcmu: Check timer register mapping
In reply to Greg Kroah-Hartman5.15-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 1713/2214 isofs: return long Joliet names whole
In reply to Greg Kroah-Hartman5.15-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 1714/2214 arm64: dts: amlogic: meson-sm1-odroid-hc4: mux the SPI NOR HOLD# and WP# pins
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit 0b825126590879812321cdab53786fcd906f7761 ]
The SPI NOR flash uses six lines, but nor_pins covers only four: data, clock and chip select. Nothing claims HOLD# (BOOT_3) and WP# (BOOT_7), so they keep the boot ROM setting. After a boot from SPI they are in the nor function and the flash works. After a boot from SD with the button under the board, they stay eMMC data lines pulled low, and spi-nor reports "unrecognized JEDEC id bytes: 00 00 00 00 00 00".
Add them as a separate group in meson-g12-common.dtsi rather than tonor_pins: whether HOLD# and WP# reach the SoC depends on the board. The HC4 has eMMC disabled and takes both groups.
Tested on ODROID-HC4: with BOOT_3 and BOOT_7 set back to eMMC with pull-down and spifc rebound, the flash fails as above without this patch and probes as a 16 MiB mtd0 with it.
--- arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi | 9 +++++++++ arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-g12-common.dtsi +9 -0
@@ -664,6 +664,15 @@ mux { }; }; + nor_hold_wp_pins: nor-hold-wp { + mux { + groups = "nor_hold", + "nor_wp"; + function = "nor"; + bias-disable; + }; + }; + pdm_din0_a_pins: pdm-din0-a { mux { groups = "pdm_din0_a";
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +1 -1
@@ -126,7 +126,7 @@ &sd_emmc_c { &spifc { status = "okay"; - pinctrl-0 = <&nor_pins>; + pinctrl-0 = <&nor_pins>, <&nor_hold_wp_pins>; pinctrl-names = "default"; spi-flash@0 {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1715/2214 arm64: dts: amlogic: meson-sm1-odroid-hc4: run the SPI NOR at 40 MHz
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Velkov <[email protected]>
[ Upstream commit b44e2be772f866985cafdf90355285069ea68495 ]
At 104 MHz, reads return corrupted data: bit 0 of the first byte of a transfer flips from 0 to 1 part of the time. The same byte read as the second byte of a transfer was correct in all 100 reads. One 4 KiB block read 200 times came back wrong 157 times. Writes are unaffected.
flashcp verifies while it writes, so a bootloader update erases blocks it should skip and can abort halfway, with the flash half written.
The Hardkernel vendor device tree for this board uses 40 MHz. At 40 MHz the same tests pass: 200 block reads with no mismatch, and 14 flashcp runs with no block erased.
Tested on ODROID-HC4 with an XT25F128B.
--- arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/amlogic/meson-sm1-odroid-hc4.dts +1 -1
@@ -134,7 +134,7 @@ spi-flash@0 { #size-cells = <1>; compatible = "jedec,spi-nor"; reg = <0>; - spi-max-frequency = <104000000>; + spi-max-frequency = <40000000>; }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1716/2214 soc/tegra: flowctrl: Release OF node reference on error
In reply to Greg Kroah-Hartman5.15-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 1717/2214 drm/msm/dp: dont report link training success after a reinit
In reply to Greg Kroah-Hartman5.15-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
@@ -1746,6 +1746,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 1718/2214 scsi: scsi_debug: Refuse a negative physblk_exp
In reply to Greg Kroah-Hartman5.15-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
@@ -6770,8 +6770,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 1719/2214 scsi: st: Restore changed drive settings after reset also for MTLOAD and MTRETEN
In reply to Greg Kroah-Hartman5.15-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
@@ -3503,6 +3503,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 (struct file *file,unsigned int cmd_in,unsigned long arg) {
@@ -3511,6 +3528,7 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)int 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;
@@ -3650,6 +3668,17 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)st_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; } }
@@ -3729,6 +3758,14 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg)if (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; }
@@ -3747,6 +3784,20 @@ static long st_ioctl(struct file *file, unsigned int cmd_in, unsigned long arg) 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 1720/2214 scsi: st: Record the tape position after a successful MTLOAD
In reply to Greg Kroah-Hartman5.15-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
@@ -2653,6 +2653,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 1721/2214 md: take reconfig_mutex when enabling PPL on an inactive array
In reply to Greg Kroah-Hartman5.15-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
@@ -5467,7 +5467,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 1722/2214 md/raid5: drain released_stripes before destroying the cache
In reply to Greg Kroah-Hartman5.15-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 1723/2214 dt-bindings: media: sun4i-a10-video-engine: Fix IOMMU count for H6
In reply to Greg Kroah-Hartman5.15-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
@@ -50,7 +50,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: maxItems: 1
@@ -77,6 +80,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 1724/2214 dt-bindings: power: supply: ab8500: Add AB8505 charger
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 80d28539c1f9baab72210501729d67e3d9daa4b8 ]
AB8500 and AB8505 expose different charger interrupt sets. Add a unique AB8505 charger compatible with the AB8500 compatible as its fallback. Use the variant-specific string to require the fourteen main and USB charger interrupts on AB8500 and the nine USB charger interrupts on AB8505.
Also clarify that autopower_cfg describes the AB8500 facility, since the corresponding AB8505 register bit is reserved.
--- .../supply/stericsson,ab8500-charger.yaml | 76 ++++++++++++++----- 1 file changed, 56 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/power/supply/stericsson,ab8500-charger.yaml +56 -20
@@ -10,12 +10,13 @@ title: AB8500 Charger maintainers: - Sebastian Reichel <[email protected]> -allOf: - - $ref: power-supply.yaml# - properties: compatible: - const: stericsson,ab8500-charger + oneOf: + - const: stericsson,ab8500-charger + - items: + - const: stericsson,ab8505-charger + - const: stericsson,ab8500-charger battery: $ref: /schemas/types.yaml#/definitions/phandle
@@ -26,27 +27,15 @@ properties: autopower_cfg: type: boolean - description: automatic poweron after powerloss + description: AB8500 automatic poweron after powerloss interrupts: + minItems: 9 maxItems: 14 interrupt-names: - items: - - const: MAIN_CH_UNPLUG_DET - - const: MAIN_CHARGE_PLUG_DET - - const: MAIN_EXT_CH_NOT_OK - - const: MAIN_CH_TH_PROT_R - - const: MAIN_CH_TH_PROT_F - - const: VBUS_DET_F - - const: VBUS_DET_R - - const: USB_LINK_STATUS - - const: USB_CH_TH_PROT_R - - const: USB_CH_TH_PROT_F - - const: USB_CHARGER_NOT_OKR - - const: VBUS_OVV - - const: CH_WD_EXP - - const: VBUS_CH_DROP_END + minItems: 9 + maxItems: 14 io-channels: minItems: 2
@@ -73,6 +62,53 @@ required: - io-channels - io-channel-names +allOf: + - $ref: power-supply.yaml# + - if: + properties: + compatible: + contains: + const: stericsson,ab8505-charger + then: + properties: + interrupts: + minItems: 9 + maxItems: 9 + + interrupt-names: + items: + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + else: + properties: + interrupts: + minItems: 14 + maxItems: 14 + + interrupt-names: + items: + - const: MAIN_CH_UNPLUG_DET + - const: MAIN_CHARGE_PLUG_DET + - const: MAIN_EXT_CH_NOT_OK + - const: MAIN_CH_TH_PROT_R + - const: MAIN_CH_TH_PROT_F + - const: VBUS_DET_F + - const: VBUS_DET_R + - const: USB_LINK_STATUS + - const: USB_CH_TH_PROT_R + - const: USB_CH_TH_PROT_F + - const: USB_CHARGER_NOT_OKR + - const: VBUS_OVV + - const: CH_WD_EXP + - const: VBUS_CH_DROP_END + additionalProperties: false examples:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1725/2214 .gitignore: drop Module.markers
In reply to Greg Kroah-Hartman5.15-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
@@ -62,7 +62,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 1726/2214 power: supply: ab8500_btemp: Fix event temperature reporting
In reply to Greg Kroah-Hartman5.15-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
@@ -750,39 +750,29 @@ static void ab8500_btemp_periodic(struct ab8500_btemp *di,*/ static 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 ; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1727/2214 power: supply: ab8500_charger: Respect AB8505 register layout
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit dcecf527632297011153f088573689a1ad1de790 ]
Several AB8505 charger fields differ from AB8500. Its long VBUS falling debounce is 300 ms rather than 100 ms, and its VBUS overvoltage selector has a different encoding programmed through OTP. Writing the AB8500 6.3 V value selects 9 V on AB8505.
AB8505 revision 3 also defines SwControlFallback as reserved, correcting older documentation which led the driver to support autopower there. Preserve the AB8505 overvoltage setting, wait for its documented debounce, and reject the unsupported autopower setting.
--- drivers/power/supply/ab8500_charger.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-)
drivers/power/supply/ab8500_charger.c +19 -8
@@ -52,7 +52,7 @@#define MAIN_CH_DET 0x01#define MAIN_CH_CV_ON 0x04#define USB_CH_CV_ON 0x08 -#define VBUS_DET_DBNC100 0x02 +#define VBUS_DET_DBNC_LONG 0x02#define VBUS_DET_DBNC1 0x01#define OTP_ENABLE_WD 0x01#define DROP_COUNT_RESET 0x01
@@ -356,6 +356,10 @@ static void ab8500_enable_disable_sw_fallback(struct ab8500_charger *di,u8 bit;int ret; +/* SwControlFallback is reserved and must remain clear on AB8505. */ +if (is_ab8505 (di->parent)) +return ; +dev_dbg (di->dev,"SW Fallback: %d\n" , fallback);if (is_ab8500 (di->parent)) {
@@ -660,12 +664,16 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)if (!probe) {/* -* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC100 +* AB8500 says VBUS_DET_DBNC1 & VBUS_DET_DBNC_LONG * when disconnecting ACA even though no * charger was connected. Try waiting a little -* longer than the 100 ms of VBUS_DET_DBNC100... +* longer than its 100 ms debounce. AB8505 uses +* a 300 ms falling debounce for the same bit. */ -msleep (110 ); +if (is_ab8505 (di->parent)) +msleep (310 ); +else +msleep (110 ); } ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER ,AB8500_CH_USBCH_STAT1_REG , &val);
@@ -676,7 +684,7 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)dev_dbg (di->dev,"%s AB8500_CH_USBCH_STAT1_REG %x\n" , __func__, val); -if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC100 )) +if ((val &VBUS_DET_DBNC1 ) && (val &VBUS_DET_DBNC_LONG )) result |=USB_PW_CONN ;return result;
@@ -3060,7 +3068,7 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) } } -if (is_ab8505_2p0 (di->parent)) +if (is_ab8505 (di->parent)) ret = abx500_mask_and_set_register_interruptible(di->dev, AB8500_CHARGER, AB8500_USBCH_CTRL2_REG,
@@ -3413,11 +3421,14 @@ static int ab8500_charger_probe(struct platform_device *pdev) di->bm = &ab8500_bm_data; - di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); -/* get parent data */ di->dev = dev; di->parent =dev_get_drvdata (pdev->dev.parent); + di->autopower_cfg =of_property_read_bool (np,"autopower_cfg" ); +if (di->autopower_cfg &&is_ab8505 (di->parent)) { +dev_warn (dev,"autopower is not supported on AB8505\n" ); + di->autopower_cfg = false; + }/* Get ADC channels */ di->adc_main_charger_v =devm_iio_channel_get (dev,"main_charger_v" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1728/2214 power: supply: ab8500_charger: Handle detection errors
In reply to Greg Kroah-Hartman5.15-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
@@ -3335,6 +3335,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))
@@ -3629,6 +3633,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 1729/2214 power: supply: ab8500_charger: Skip absent AB8505 main charger
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 52c8cdcc1146d86fae524a589d4512c8d59ea8b4 ]
AB8505 contains only the USB charger. It has no integrated main charger, main-charger status register, or main-charger interrupts.
Avoid reading the missing status register, requesting the five missing interrupts, or disabling an AC charger which was never enabled. This lets the driver bind using only the AB8505 USB charger resources.
--- drivers/power/supply/ab8500_charger.c | 32 ++++++++++++++++++--------- 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/power/supply/ab8500_charger.c +21 -11
@@ -649,16 +649,19 @@ static int ab8500_charger_detect_chargers(struct ab8500_charger *di, bool probe)int ret;u8 val; -/* Check for AC charger */ - ret =abx500_get_register_interruptible (di->dev,AB8500_CHARGER , -AB8500_CH_STATUS1_REG , &val); -if (ret <0 ) { -dev_err (di->dev,"%s ab8500 read failed\n" , __func__); -return ret; - } +/* AB8505 has no integrated main charger. */ +if (!is_ab8505 (di->parent)) { + ret =abx500_get_register_interruptible (di->dev, +AB8500_CHARGER , +AB8500_CH_STATUS1_REG , &val); +if (ret <0 ) { +dev_err (di->dev,"%s ab8500 read failed\n" , __func__); +return ret; + } -if (val &MAIN_CH_DET ) - result =AC_PW_CONN ; +if (val &MAIN_CH_DET ) + result =AC_PW_CONN ; + }/* Check for USB charger */
@@ -3372,7 +3375,8 @@ static void ab8500_charger_unbind(struct device *dev)int ret;/* Disable AC charging */ -ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 ); +if (di->ac_chg.enabled) +ab8500_charger_ac_en (&di->ac_chg, false,0 ,0 );/* Disable USB charging */ ab8500_charger_usb_en (&di->usb_chg, false,0 ,0 );
@@ -3603,7 +3607,13 @@ static int ab8500_charger_probe(struct platform_device *pdev) }/* Request interrupts */ -for (i =0 ; i <ARRAY_SIZE (ab8500_charger_irq); i++) { +/* The first five interrupts belong to the AB8500 main charger. */ +if (is_ab8505 (di->parent)) + i =5 ; +else + i =0 ; + +for (; i <ARRAY_SIZE (ab8500_charger_irq); i++) { irq =platform_get_irq_byname (pdev, ab8500_charger_irq[i].name);if (irq <0 )return irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1730/2214 power: supply: ab8500_charger: Recover inactive AB8505 charger
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 76bdf9d78245bb068207c23e9bf43d4b9bb201c3 ]
UsbChCtrl1.UsbChEna can remain set while UsbChStatus1.UsbChOn is clear. The existing recovery only checks the control bit, so it considers the charger enabled and leaves charging stopped.
The Samsung-GT-S7710-Skomer, Samsung-SGH-I407-Kyle, and Samsung-SGH-T599-Codina-TMO product trees are reference points for checking both bits and cycling the charger when they disagree.
Extend the USB charger check to detect this AB8505 state and enable the check in the charging algorithm for AB8505. Only cycle the charger when VBUS is debounced and no charger-not-OK, thermal, overvoltage, or watchdog fault accounts for the inactive hardware.
--- drivers/power/supply/ab8500_chargalg.c | 9 ++--- drivers/power/supply/ab8500_charger.c | 51 +++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 7 deletions(-)
drivers/power/supply/ab8500_chargalg.c +3 -6
@@ -1304,12 +1304,9 @@ static void ab8500_chargalg_algorithm(struct ab8500_chargalg *di) charger_status =ab8500_chargalg_check_charger_connection (di);ab8500_chargalg_check_current_step_status (di); -if (is_ab8500 (di->parent)) { - ret =ab8500_chargalg_check_charger_enable (di); -if (ret <0 ) -dev_err (di->dev,"Checking charger is enabled error" -": Returned Value %d\n" , ret); - } + ret =ab8500_chargalg_check_charger_enable (di); +if (ret <0 ) +dev_err (di->dev,"Checking charger enable failed: %d\n" , ret);/* * First check if we have a charger connected.
drivers/power/supply/ab8500_charger.c +50 -1
69 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1731/2214 power: supply: ab8500_fg: Avoid reserved AB8505 CCConf bit
In reply to Greg Kroah-Hartman5.15-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
@@ -453,6 +453,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
@@ -483,7 +493,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;
@@ -557,7 +567,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 1732/2214 ASoC: rt5682-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 9a98f7e955d35e0831fb179e88e98cf9bc0e001e ]
rt5682_sdw_remove() cancels jack_detect_work only when hw_init is true. rt5682_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack_detect_work may already have been queued by rt5682_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work object is initialized during probe, so cancel it unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt5682-sdw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/rt5682-sdw.c +1 -2
@@ -719,8 +719,7 @@ static int rt5682_sdw_remove(struct sdw_slave *slave) {struct rt5682_priv *rt5682 =dev_get_drvdata (&slave->dev); -if (rt5682->hw_init) -cancel_delayed_work_sync (&rt5682->jack_detect_work); +cancel_delayed_work_sync (&rt5682->jack_detect_work);if (rt5682->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1733/2214 ASoC: rt711-sdw: always cancel jack work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 4bf78e3d9e324f9f2e39feecedd4f70b05baeb16 ]
rt711_sdw_remove() cancels the jack and calibration work only when hw_init is true. rt711_update_status() clears hw_init when the SoundWire slave becomes unattached, but work may already have been queued by rt711_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdw.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
sound/soc/codecs/rt711-sdw.c +3 -5
@@ -465,11 +465,9 @@ static int rt711_sdw_remove(struct sdw_slave *slave) {struct rt711_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); -cancel_work_sync (&rt711->calibration_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work); +cancel_work_sync (&rt711->calibration_work);if (rt711->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1734/2214 ASoC: rt711-sdca: always cancel jack work on remove
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit ecc2fca6decefe27d8cf40a4c9815798eec24d30 ]
rt711_sdca_sdw_remove() cancels the jack work only when hw_init is true. rt711_sdca_update_status() clears hw_init when the SoundWire slave becomes unattached, but jack work may already have been queued by rt711_sdca_interrupt_callback() or the jack initialization path.
A remove after that status update can therefore skip the cancellation and leave delayed work pending after the codec private data has been freed.
The work objects are initialized during probe, so cancel them unconditionally instead of relying on the mutable hw_init state.
--- sound/soc/codecs/rt711-sdca-sdw.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/codecs/rt711-sdca-sdw.c +2 -4
@@ -365,10 +365,8 @@ static int rt711_sdca_sdw_remove(struct sdw_slave *slave) {struct rt711_sdca_priv *rt711 =dev_get_drvdata (&slave->dev); -if (rt711->hw_init) { -cancel_delayed_work_sync (&rt711->jack_detect_work); -cancel_delayed_work_sync (&rt711->jack_btn_check_work); - } +cancel_delayed_work_sync (&rt711->jack_detect_work); +cancel_delayed_work_sync (&rt711->jack_btn_check_work);if (rt711->first_hw_init)pm_runtime_disable (&slave->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1735/2214 arm64: dts: rockchip: Rename rk3328 HDMI audio card
In reply to Greg Kroah-Hartman5.15-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
@@ -176,7 +176,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 1736/2214 ARM: dts: AB8505: Enable charging options
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 1afc8a287fbd72b5380ed037ab19fdaf448755ef ]
These are not disabled on the AB8500 and after testing we see they work fine, so enable them on AB8505 too.
Stable-dep-of: ff1501cbb825 ("ARM: dts: ux500: Use AB8505 charger compatible")
--- arch/arm/boot/dts/ste-ab8505.dtsi | 4 ---- 1 file changed, 4 deletions(-)
arch/arm/boot/dts/ste-ab8505.dtsi +0 -4
@@ -98,7 +98,6 @@ ab8500_battery: ab8500_battery { }; ab8500_fg { - status = "disabled"; compatible = "stericsson,ab8500-fg"; interrupts = <24 IRQ_TYPE_LEVEL_HIGH>, <8 IRQ_TYPE_LEVEL_HIGH>,
@@ -116,7 +115,6 @@ ab8500_fg { }; ab8500_btemp { - status = "disabled"; compatible = "stericsson,ab8500-btemp"; interrupts = <20 IRQ_TYPE_LEVEL_HIGH>, <80 IRQ_TYPE_LEVEL_HIGH>,
@@ -136,7 +134,6 @@ ab8500_btemp { }; ab8500_charger { - status = "disabled"; compatible = "stericsson,ab8500-charger"; interrupts = <10 IRQ_TYPE_LEVEL_HIGH>, <11 IRQ_TYPE_LEVEL_HIGH>,
@@ -175,7 +172,6 @@ ab8500_charger { }; ab8500_chargalg { - status = "disabled"; compatible = "stericsson,ab8500-chargalg"; battery = <&ab8500_battery>; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1737/2214 ARM: dts: ux500: Use AB8505 charger compatible
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit ff1501cbb825de117267124ecb8898112b4051c5 ]
Identify the AB8505 charger using its variant-specific compatible and retain the AB8500 compatible as a fallback for the existing driver. This selects the AB8505 interrupt constraints from the binding.
The AB8505 interrupt table explicitly omits the five interrupt sources belonging to the AB8500 main charger. Remove these nonexistent interrupts from the AB8505 charger node, leaving its nine USB charger interrupts.
--- arch/arm/boot/dts/ste-ab8505.dtsi | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
arch/arm/boot/dts/ste-ab8505.dtsi +4 -13
@@ -134,13 +134,9 @@ ab8500_btemp { }; ab8500_charger { - compatible = "stericsson,ab8500-charger"; - interrupts = <10 IRQ_TYPE_LEVEL_HIGH>, - <11 IRQ_TYPE_LEVEL_HIGH>, - <0 IRQ_TYPE_LEVEL_HIGH>, - <107 IRQ_TYPE_LEVEL_HIGH>, - <106 IRQ_TYPE_LEVEL_HIGH>, - <14 IRQ_TYPE_LEVEL_HIGH>, + compatible = "stericsson,ab8505-charger", + "stericsson,ab8500-charger"; + interrupts = <14 IRQ_TYPE_LEVEL_HIGH>, <15 IRQ_TYPE_LEVEL_HIGH>, <79 IRQ_TYPE_LEVEL_HIGH>, <105 IRQ_TYPE_LEVEL_HIGH>,
@@ -149,12 +145,7 @@ ab8500_charger { <22 IRQ_TYPE_LEVEL_HIGH>, <21 IRQ_TYPE_LEVEL_HIGH>, <16 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "MAIN_CH_UNPLUG_DET", - "MAIN_CHARGE_PLUG_DET", - "MAIN_EXT_CH_NOT_OK", - "MAIN_CH_TH_PROT_R", - "MAIN_CH_TH_PROT_F", - "VBUS_DET_F", + interrupt-names = "VBUS_DET_F", "VBUS_DET_R", "USB_LINK_STATUS", "USB_CH_TH_PROT_R",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1738/2214 arm64: dts: rockchip: fix analog headphone output on rk3399-firefly
In reply to Greg Kroah-Hartman5.15-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
@@ -95,6 +95,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>;
@@ -131,8 +140,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>;
@@ -541,8 +553,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 1739/2214 arm64: dts: rockchip: disable unused i2s0 on rk3399-firefly
In reply to Greg Kroah-Hartman5.15-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
@@ -622,13 +622,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";
@@ -683,6 +679,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 1740/2214 ASoC: mt6359-accdet: manage private workqueues with devres
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 9a773d9d21fa909e8babbe11e93c811cf1a6d22d ]
The threaded jack-detect interrupts queue work on two private workqueues. Neither queue is destroyed on device removal, so queued callbacks can retain pointers to devm-allocated state after it is released. Probe error paths also leak the queues.
Create and initialize both workqueues before requesting interrupts, then add a managed cleanup action. Since the managed IRQs are acquired afterwards, devres releases and synchronizes them before draining and destroying the workqueues on both removal and probe failure.
--- sound/soc/codecs/mt6359-accdet.c | 50 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-)
sound/soc/codecs/mt6359-accdet.c +28 -22
@@ -923,6 +923,14 @@ int mt6359_accdet_enable_jack_detect(struct snd_soc_component *component, }EXPORT_SYMBOL_GPL (mt6359_accdet_enable_jack_detect); +static void mt6359_accdet_destroy_workqueues (void *data) +{ +struct mt6359_accdet *priv = data; + +destroy_workqueue (priv->jd_workqueue); +destroy_workqueue (priv->accdet_workqueue); +} +static int mt6359_accdet_probe (struct platform_device *pdev) {struct mt6359_accdet *priv;
@@ -964,6 +972,26 @@ static int mt6359_accdet_probe(struct platform_device *pdev) }mutex_init (&priv->res_lock); + priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); +INIT_WORK (&priv->accdet_work, mt6359_accdet_work); +if (!priv->accdet_workqueue) { +dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); +return -ENOMEM ; + } + + priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); +INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); +if (!priv->jd_workqueue) { +dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); +destroy_workqueue (priv->accdet_workqueue); +return -ENOMEM ; + } + + ret =devm_add_action_or_reset (&pdev->dev, + mt6359_accdet_destroy_workqueues, priv); +if (ret) +return ret; + priv->accdet_irq =platform_get_irq (pdev,0 );if (priv->accdet_irq >=0 ) { ret = devm_request_threaded_irq(&pdev->dev, priv->accdet_irq,
@@ -1009,22 +1037,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev) } } - priv->accdet_workqueue =create_singlethread_workqueue ("accdet" ); -INIT_WORK (&priv->accdet_work, mt6359_accdet_work); -if (!priv->accdet_workqueue) { -dev_err (&pdev->dev,"Failed to create accdet workqueue\n" ); - ret =-1 ; - goto err_accdet_wq; - } - - priv->jd_workqueue =create_singlethread_workqueue ("mt6359_accdet_jd" ); -INIT_WORK (&priv->jd_work, mt6359_accdet_jd_work); -if (!priv->jd_workqueue) { -dev_err (&pdev->dev,"Failed to create jack detect workqueue\n" ); - ret =-1 ; - goto err_eint_wq; - } -platform_set_drvdata (pdev, priv); ret = devm_snd_soc_register_component(&pdev->dev, &mt6359_accdet_soc_driver,
@@ -1043,12 +1055,6 @@ static int mt6359_accdet_probe(struct platform_device *pdev)mt6359_accdet_jack_report (priv);return 0 ; - -err_eint_wq: -destroy_workqueue (priv->accdet_workqueue); -err_accdet_wq: -dev_err (&pdev->dev,"%s error. now exit.!\n" , __func__); -return ret; }static struct platform_driver mt6359_accdet_driver = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1741/2214 cpufreq: sparc-us2e: fix frequency table index copy-paste error
In reply to Greg Kroah-Hartman5.15-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 1742/2214 cpufreq: sti: avoid NULL dereference in dev_err()
In reply to Greg Kroah-Hartman5.15-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
@@ -270,7 +270,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; }
@@ -288,7 +288,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 1743/2214 wifi: cfg80211: allow zero HE OBSS PD offsets
In reply to Greg Kroah-Hartman5.15-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
@@ -354,11 +354,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 1744/2214 wifi: b43: dont pass unterminated string to sscanf()
In reply to Greg Kroah-Hartman5.15-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 1745/2214 wifi: b43legacy: debugfs: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman5.15-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 1746/2214 wifi: carl9170: NUL terminate string in debugfs
In reply to Greg Kroah-Hartman5.15-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 1747/2214 dmaengine: ioat: disable relaxed ordering before registering the device
In reply to Greg Kroah-Hartman5.15-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 1748/2214 dmaengine: plx_dma: fix NULL pointer deref in plx_dma_isr()
In reply to Greg Kroah-Hartman5.15-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 1749/2214 NFS: filelayout: calculate dense stripe width in 64 bits
In reply to Greg Kroah-Hartman5.15-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 1750/2214 floppy: flush pending work before releasing resources on init failure
In reply to Greg Kroah-Hartman5.15-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
@@ -4735,6 +4735,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_driver:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1751/2214 floppy: avoid NULL deref in reset_interrupt when cont is cleared
In reply to Greg Kroah-Hartman5.15-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 1752/2214 dmaengine: ste_dma40: Fix physical cyclic capability
In reply to Greg Kroah-Hartman5.15-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
@@ -2885,7 +2885,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 1753/2214 dmaengine: ste_dma40: Fix failed start cleanup
In reply to Greg Kroah-Hartman5.15-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 1754/2214 dmaengine: ste_dma40: Get LCPA SRAM from SRAM node
In reply to Greg Kroah-Hartman5.15-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
@@ -554,6 +554,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 1755/2214 dmaengine: ste_dma40: Add dev helper variable
In reply to Greg Kroah-Hartman5.15-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
@@ -3113,6 +3113,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;
@@ -3126,15 +3127,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; }
@@ -3160,11 +3161,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;
@@ -3180,7 +3181,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; }
@@ -3198,7 +3199,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);
@@ -3218,7 +3219,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];
@@ -3514,7 +3515,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 ;
@@ -3531,7 +3533,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; } }
@@ -3550,24 +3552,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
@@ -3576,7 +3578,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 */
@@ -3585,7 +3587,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; }
@@ -3593,7 +3595,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 );
@@ -3601,7 +3603,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; } }
@@ -3616,7 +3618,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; }
@@ -3624,7 +3626,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;
@@ -3632,7 +3634,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 ;
@@ -3655,7 +3657,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; }
@@ -3664,7 +3666,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" ); }
@@ -3715,7 +3717,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 1756/2214 dmaengine: ste_dma40: Fix probe runtime PM disable
In reply to Greg Kroah-Hartman5.15-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
@@ -3616,12 +3616,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" );
@@ -3646,10 +3640,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)
@@ -3709,7 +3713,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 1757/2214 dmaengine: ste_dma40: Check runtime PM in IRQ
In reply to Greg Kroah-Hartman5.15-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
@@ -1657,6 +1657,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 (&base->interrupt_lock);
@@ -1705,6 +1710,9 @@ static irqreturn_t d40_handle_interrupt(int irq, void *data)spin_unlock (&base->interrupt_lock); +if (ret >0 ) +pm_runtime_put_autosuspend (base->dev); +return IRQ_HANDLED ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1758/2214 dmaengine: ste_dma40: Remove redundant pm_runtime_mark_last_busy() calls
In reply to Greg Kroah-Hartman5.15-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); } }
@@ -2049,16 +2046,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; }
@@ -2462,7 +2456,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;
@@ -2614,12 +2607,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 1759/2214 dmaengine: ste_dma40: Handle runtime PM resume errors
In reply to Greg Kroah-Hartman5.15-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 */
@@ -2008,9 +2026,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 ;
@@ -2032,11 +2047,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 );
@@ -2052,8 +2074,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; }
@@ -2413,10 +2433,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" );
@@ -2424,8 +2448,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)) {
@@ -2457,6 +2479,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; }
@@ -2601,19 +2624,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 1760/2214 dmaengine: ste_dma40: Return IRQ_NONE when no interrupt is pending
In reply to Greg Kroah-Hartman5.15-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;
@@ -1696,6 +1697,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
@@ -1728,7 +1735,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 1761/2214 dmaengine: ste_dma40: Use managed resources
In reply to Greg Kroah-Hartman5.15-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
@@ -526,8 +526,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).
@@ -571,8 +569,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;
@@ -3145,65 +3141,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:
@@ -3217,7 +3206,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 */
@@ -3235,23 +3224,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;
@@ -3288,76 +3276,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)
@@ -3610,11 +3577,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) {
@@ -3624,14 +3591,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 );
@@ -3711,16 +3678,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,
@@ -3732,28 +3691,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 1762/2214 dmaengine: ste_dma40: Fix LCLA allocation order
In reply to Greg Kroah-Hartman5.15-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
@@ -385,8 +385,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. */
@@ -394,7 +394,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; };
@@ -3384,6 +3384,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;
@@ -3399,20 +3400,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; }
@@ -3422,7 +3423,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];
@@ -3432,10 +3433,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) {
@@ -3447,8 +3447,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 ;
@@ -3687,7 +3686,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 1763/2214 dmaengine: ste_dma40: Fix probe LCLA free
In reply to Greg Kroah-Hartman5.15-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
@@ -3684,7 +3684,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 1764/2214 dmaengine: ste_dma40: Put the LCPA SRAM node
In reply to Greg Kroah-Hartman5.15-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
@@ -3558,6 +3558,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 1765/2214 dmaengine: ste_dma40: turn d40_base phy_chans into a flexible array
In reply to Greg Kroah-Hartman5.15-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
@@ -576,7 +576,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;
@@ -595,6 +594,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)
@@ -3156,6 +3156,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;
@@ -3215,22 +3216,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 ;
@@ -3243,7 +3246,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
Greg Kroah-Hartman
maintainerPATCH 1766/2214 dmaengine: ste_dma40: Validate disabled channel indexes
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit c96e9f056095825b5f8d4a11f4107fc174892f92 ]
d40_of_probe() checks how many entries disabled-channels contains, but not the channel numbers themselves. d40_phy_res_init() later uses every value as an index into base->phy_res, whose size is the number of channels found in this DMA40 instance. An out-of-range value can therefore write beyond the allocation.
Validate each disabled channel against the detected hardware channel count before allocating and initializing the channel resources.
--- drivers/dma/ste_dma40.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/ste_dma40.c +9 -0
@@ -3218,6 +3218,15 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) num_phy_chans =min (num_phy_chans,STEDMA40_MAX_PHYS ); +for (i =0 ; plat_data->disabled_channels[i] !=-1 ; i++) { +int chan = plat_data->disabled_channels[i]; + +if (chan <0 || chan >= num_phy_chans) { +dev_err (dev,"Invalid disabled channel %d\n" , chan); +return -EINVAL ; + } + } +/* The number of channels used for memcpy */ if (plat_data->num_of_memcpy_chans) num_memcpy_chans = plat_data->num_of_memcpy_chans;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1767/2214 dmaengine: ste_dma40: Validate DMA specifier length
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 9f1064ebe17cf3ab65ac6eb166398e02678aea33 ]
The DMA40 binding requires three cells, but d40_xlate() reads args[0], args[1], and args[2] without checking args_count. A malformed provider node can specify fewer cells, leaving some of these values uninitialized when the OF DMA core invokes the translation callback.
Reject specifiers that do not contain exactly three cells before reading the argument array.
--- drivers/dma/ste_dma40.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma/ste_dma40.c +3 -0
@@ -2384,6 +2384,9 @@ static struct dma_chan *d40_xlate(struct of_phandle_args *dma_spec,dma_cap_mask_t cap;u32 flags; +if (dma_spec->args_count !=3 ) +return NULL ; +memset (&cfg,0 ,sizeof (struct stedma40_chan_cfg ));dma_cap_zero (cap);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1768/2214 dmaengine: ste_dma40: Reject direction changes after allocation
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 77ebc64f40717b8501793b5f5ee717a141e62e8e ]
Logical channel allocation uses the configured direction to select the source or destination allocation mask, derive the logical channel number, and choose the LCPA location.
d40_set_runtime_config_write() nevertheless overwrites the configured direction when a transfer is prepared for the opposite direction. d40_free_dma() then clears the wrong allocation mask, leaking the original resource and potentially releasing one used by another client.
Reject directions that differ from the direction used during allocation and propagate runtime configuration errors to callers. Skip slave runtime configuration for memcpy transfers, which also use d40_prep_sg() but do not require it.
--- drivers/dma/ste_dma40.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-)
drivers/dma/ste_dma40.c +14 -15
@@ -2256,7 +2256,13 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,return NULL ; } -d40_set_runtime_config_write (dchan, &chan->slave_config, direction); +if (direction !=DMA_MEM_TO_MEM ) { + ret =d40_set_runtime_config_write (dchan, + &chan->slave_config, + direction); +if (ret) +return NULL ; + }spin_lock_irqsave (&chan->lock, flags);
@@ -2712,6 +2718,13 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,return -EINVAL ; } +if (direction != cfg->dir) { +chan_err (d40c, +"transfer direction %d differs from allocated direction %d\n" , + direction, cfg->dir); +return -EINVAL ; + } + src_addr_width = config->src_addr_width; src_maxburst = config->src_maxburst; dst_addr_width = config->dst_addr_width;
@@ -2720,13 +2733,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan,if (direction ==DMA_DEV_TO_MEM ) { config_addr = config->src_addr; -if (cfg->dir !=DMA_DEV_TO_MEM ) -dev_dbg (d40c->base->dev, -"channel was not configured for peripheral " -"to memory transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_DEV_TO_MEM ; -/* Configure the memory side */ if (dst_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) dst_addr_width = src_addr_width;
@@ -2736,13 +2742,6 @@ static int d40_set_runtime_config_write(struct dma_chan *chan, }else if (direction ==DMA_MEM_TO_DEV ) { config_addr = config->dst_addr; -if (cfg->dir !=DMA_MEM_TO_DEV ) -dev_dbg (d40c->base->dev, -"channel was not configured for memory " -"to peripheral transfer (%d) overriding\n" , - cfg->dir); - cfg->dir =DMA_MEM_TO_DEV ; -/* Configure the memory side */ if (src_addr_width ==DMA_SLAVE_BUSWIDTH_UNDEFINED ) src_addr_width = dst_addr_width;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1769/2214 dmaengine: ste_dma40: Fix logical channel bounds check
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit 57938e0c2a24f9f792fe9f611391ef6b58d1aa21 ]
d40_validate_conf() checks the raw dev_type against num_log_chans, but d40_allocate_channel() derives the lookup_log_chans index as either 2 * dev_type or 2 * dev_type + 1.
Validate the dev_type against the derived logical channel index limit so channel allocation cannot write past lookup_log_chans.
--- drivers/dma/ste_dma40.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/dma/ste_dma40.c +14 -3
@@ -1739,15 +1739,26 @@ static int d40_validate_conf(struct d40_chan *d40c, {int res =0 ;bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ; +bool invalid_dev_type = conf->dev_type <0 ;if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ; } -if ((is_log && conf->dev_type > d40c->base->num_log_chans) || - (!is_log && conf->dev_type > d40c->base->num_phy_chans) || - (conf->dev_type <0 )) { +if (!invalid_dev_type && is_log) { +int max_dev_type; + +if (conf->dir ==DMA_DEV_TO_MEM ) + max_dev_type =DIV_ROUND_UP (d40c->base->num_log_chans,2 ); +else + max_dev_type = d40c->base->num_log_chans /2 ; + + invalid_dev_type = conf->dev_type >= max_dev_type; + } + +if (invalid_dev_type || + (!is_log && conf->dev_type > d40c->base->num_phy_chans)) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1770/2214 dmaengine: ste_dma40: Fix event group bounds
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit e66a9dbe04c71249cfb2a544c9c25d1b3b761fba ]
The dev_type validation can allow values whose derived event group has no matching physical channel pair. d40_allocate_channel() then indexes phy_res with j + event_group * 2, and __d40_set_prio_rt() uses the same group to select priority and realtime registers.
The physical-mode validation also compares dev_type with the number of physical channels. However, dev_type identifies an event line: DB8500 has eight physical channels but 64 source and 64 destination event lines. The event group determines which physical channel pair can serve an event, so the physical channel count is not a valid dev_type limit.
Reject dev_type values outside the hardware event-group range, remove the incorrect physical channel count limit, and stop the physical-channel search before a partial final channel group can index past phy_res.
--- drivers/dma/ste_dma40.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/dma/ste_dma40.c +22 -4
@@ -49,6 +49,10 @@#define D40_LCLA_LINK_PER_EVENT_GRP 128#define D40_LCLA_END D40_LCLA_LINK_PER_EVENT_GRP +/* Number of event groups per hardware register layout */ +#define D40_EVENT_GROUPS_V4A 4 +#define D40_EVENT_GROUPS_V4B 5 +/* Max number of logical channels per physical channel */ #define D40_MAX_LOG_CHAN_PER_PHY 32
@@ -496,6 +500,7 @@ struct d40_chan {* @high_prio_clear: the high priority clear register * @interrupt_en: the interrupt enable register * @interrupt_clear: the interrupt clear register +* @num_event_groups: number of supported event groups * @il: the pointer to struct d40_interrupt_lookup * @il_size: the size of d40_interrupt_lookup array * @init_reg: the pointer to the struct d40_reg_val
@@ -510,6 +515,7 @@ struct d40_gen_dmac {u32 high_prio_clear;u32 interrupt_en;u32 interrupt_clear; +u32 num_event_groups;struct d40_interrupt_lookup *il;u32 il_size;struct d40_reg_val *init_reg;
@@ -1741,6 +1747,11 @@ static int d40_validate_conf(struct d40_chan *d40c,bool is_log = conf->mode ==STEDMA40_MODE_LOGICAL ;bool invalid_dev_type = conf->dev_type <0 ; +if (!invalid_dev_type && +D40_TYPE_TO_GROUP (conf->dev_type) >= + d40c->base->gen_dmac.num_event_groups) + invalid_dev_type = true; +if (!conf->dir) {chan_err (d40c,"Invalid direction.\n" ); res = -EINVAL ;
@@ -1757,8 +1768,7 @@ static int d40_validate_conf(struct d40_chan *d40c, invalid_dev_type = conf->dev_type >= max_dev_type; } -if (invalid_dev_type || - (!is_log && conf->dev_type > d40c->base->num_phy_chans)) { +if (invalid_dev_type) {chan_err (d40c,"Invalid device type (%d)\n" , conf->dev_type); res = -EINVAL ; }
@@ -1923,8 +1933,12 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) } } }else -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; + j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ; +for (i = phy_num; i < phy_num +2 ; i++) { if (d40_alloc_mask_set(&phys[i], is_src,
@@ -1944,8 +1958,10 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)return -EINVAL ;/* Find logical channel */ -for (j =0 ; j < d40c->base->num_phy_chans; j +=8 ) { +for (j =0 ; j < d40c->base->num_phy_chans; j +=D40_GROUP_SIZE ) {int phy_num = j + event_group *2 ; +if (phy_num +1 >= num_phy_chans) +break ;if (d40c->dma_cfg.use_fixed_channel) { i = d40c->dma_cfg.phy_channel;
@@ -3271,6 +3287,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->log_chans = &base->phy_chans[num_phy_chans];if (base->plat_data->num_of_phy_chans ==14 ) { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4B ; base->gen_dmac.backup = d40_backup_regs_v4b; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4B ; base->gen_dmac.interrupt_en =D40_DREG_CPCMIS ;
@@ -3284,6 +3301,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev) base->gen_dmac.init_reg = dma_init_reg_v4b; base->gen_dmac.init_reg_size =ARRAY_SIZE (dma_init_reg_v4b); }else { + base->gen_dmac.num_event_groups =D40_EVENT_GROUPS_V4A ;if (base->rev >=3 ) { base->gen_dmac.backup = d40_backup_regs_v4a; base->gen_dmac.backup_size =BACKUP_REGS_SZ_V4A ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1771/2214 dmaengine: ste_dma40: Fix V4B event group mapping
In reply to Greg Kroah-Hartman5.15-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit b36f8fce7314fed53563c60e683ff86deb8a51ae ]
DMA40 physical resources are connected in pairs to event groups. The mapping repeats after each complete set of groups.
D40_GROUP_SIZE and D40_PHYS_TO_GROUP() encode the four-group V4A layout. On V4B, which has five groups, resources 8 and 9 are consequently offered both to event groups 0 and 4. The GCC clock bookkeeping also treats these resources as group 0 instead of group 4.
Derive the physical-resource stride and reverse mapping from the variant-specific number of event groups. This preserves the V4A mapping and gives V4B a ten-resource stride: resources 8 and 9 belong only to group 4, while resources 10 and 11 repeat group 0.
--- drivers/dma/ste_dma40.c | 47 ++++++++++++++++++++++++++------------ drivers/dma/ste_dma40_ll.h | 2 -- 2 files changed, 33 insertions(+), 16 deletions(-)
drivers/dma/ste_dma40.c +33 -14
@@ -52,6 +52,7 @@/* Number of event groups per hardware register layout */ #define D40_EVENT_GROUPS_V4A 4#define D40_EVENT_GROUPS_V4B 5 +#define D40_PHYS_PER_EVENT_GROUP 2/* Max number of logical channels per physical channel */ #define D40_MAX_LOG_CHAN_PER_PHY 32
@@ -1885,6 +1886,12 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,return is_free; } +static int d40_phy_to_group (struct d40_base *base,int phy) +{ +return (phy /D40_PHYS_PER_EVENT_GROUP ) % + base->gen_dmac.num_event_groups; +} +static int d40_allocate_channel (struct d40_chan *d40c,bool *first_phy_user) {int dev_type = d40c->dma_cfg.dev_type;
@@ -1895,11 +1902,14 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)int j;int log_num;int num_phy_chans; +int phy_group_stride;bool is_src;bool is_log = d40c->dma_cfg.mode ==STEDMA40_MODE_LOGICAL ; phys = d40c->base->phy_res; num_phy_chans = d40c->base->num_phy_chans; + phy_group_stride =D40_PHYS_PER_EVENT_GROUP * + d40c->base->gen_dmac.num_event_groups;if (d40c->dma_cfg.dir ==DMA_DEV_TO_MEM ) { log_num =2 * dev_type;
@@ -1933,13 +1943,18 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user) } } }else -for (j =0 ; j < d40c->base->num_phy_chans; - j +=D40_GROUP_SIZE ) { -int phy_num = j + event_group *2 ; -if (phy_num +1 >= num_phy_chans) +for (j =0 ; j < num_phy_chans; + j += phy_group_stride) { +int phy_num = j + event_group * +D40_PHYS_PER_EVENT_GROUP ; + +if (phy_num +D40_PHYS_PER_EVENT_GROUP > + num_phy_chans)break ; -for (i = phy_num; i < phy_num +2 ; i++) { +for (i = phy_num; + i < phy_num +D40_PHYS_PER_EVENT_GROUP ; + i++) { if (d40_alloc_mask_set(&phys[i], is_src, 0,
@@ -1958,9 +1973,10 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)return -EINVAL ;/* Find logical channel */ -for (j =0 ; j < d40c->base->num_phy_chans; j +=D40_GROUP_SIZE ) { -int phy_num = j + event_group *2 ; -if (phy_num +1 >= num_phy_chans) +for (j =0 ; j < num_phy_chans; j += phy_group_stride) { +int phy_num = j + event_group *D40_PHYS_PER_EVENT_GROUP ; + +if (phy_num +D40_PHYS_PER_EVENT_GROUP > num_phy_chans)break ;if (d40c->dma_cfg.use_fixed_channel) {
@@ -1987,14 +2003,17 @@ static int d40_allocate_channel(struct d40_chan *d40c, bool *first_phy_user)* channels. */ if (is_src) { -for (i = phy_num; i < phy_num +2 ; i++) { +for (i = phy_num; + i < phy_num +D40_PHYS_PER_EVENT_GROUP ; + i++) {if (d40_alloc_mask_set (&phys[i], is_src, event_line, is_log, first_phy_user)) goto found_log; } }else { -for (i = phy_num +1 ; i >= phy_num; i--) { +for (i = phy_num +D40_PHYS_PER_EVENT_GROUP -1 ; + i >= phy_num; i--) {if (d40_alloc_mask_set (&phys[i], is_src, event_line, is_log, first_phy_user))
@@ -3105,9 +3124,9 @@ static int __init d40_phy_res_init(struct d40_base *base) base->phy_res[i].allocated_src =D40_ALLOC_PHY ; base->phy_res[i].allocated_dst =D40_ALLOC_PHY ; base->phy_res[i].reserved = true; - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (i), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, i),D40_DREG_GCC_SRC ); - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (i), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, i),D40_DREG_GCC_DST );
@@ -3127,9 +3146,9 @@ static int __init d40_phy_res_init(struct d40_base *base) base->phy_res[chan].allocated_src =D40_ALLOC_PHY ; base->phy_res[chan].allocated_dst =D40_ALLOC_PHY ; base->phy_res[chan].reserved = true; - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (chan), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, chan),D40_DREG_GCC_SRC ); - gcc |=D40_DREG_GCC_EVTGRP_ENA (D40_PHYS_TO_GROUP (chan), + gcc |=D40_DREG_GCC_EVTGRP_ENA (d40_phy_to_group (base, chan),D40_DREG_GCC_DST ); num_phy_chans_avail--; }
drivers/dma/ste_dma40_ll.h +0 -2
@@ -16,8 +16,6 @@#define D40_TYPE_TO_GROUP (type) (type / 16)#define D40_TYPE_TO_EVENT (type) (type % 16) -#define D40_GROUP_SIZE 8 -#define D40_PHYS_TO_GROUP (phys) ((phys & (D40_GROUP_SIZE - 1)) / 2)/* Most bits of the CFG register are the same in log as in phy mode */ #define D40_SREG_CFG_MST_POS 15
Signature · 1 line
2.53.0