6.18.52-rc1 review
Greg Kroah-Hartman
maintainerPATCH 206/1518 crypto: keembay - Fix AEAD unregister count in error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit e264401ce4776a288524e5b87593d4d864147115 ]
register_aes_algs() registers the AEAD algorithms before registering the skcipher algorithms. If skcipher registration fails, the function unwinds the earlier AEAD registration with crypto_engine_unregister_aeads(), but it passes ARRAY_SIZE(algs), which is the skcipher table size.
Use ARRAY_SIZE(algs_aead) for the AEAD unwind path so the unregister helper iterates over the same table that was registered. Also clarify the nearby
comment: the crypto registration helpers clean up algorithms registered within the same call, while this function must still unwind earlier successful registration steps.
--- drivers/crypto/intel/keembay/keembay-ocs-aes-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/intel/keembay/keembay-ocs-aes-core.c +2 -2
@@ -1541,7 +1541,7 @@ static int register_aes_algs(struct ocs_aes_dev *aes_dev)/* * If any algorithm fails to register, all preceding algorithms that -* were successfully registered will be automatically unregistered. +* were registered in the same call are automatically unregistered. */ ret =crypto_engine_register_aeads (algs_aead,ARRAY_SIZE (algs_aead));if (ret)
@@ -1549,7 +1549,7 @@ static int register_aes_algs(struct ocs_aes_dev *aes_dev) ret =crypto_engine_register_skciphers (algs,ARRAY_SIZE (algs));if (ret) -crypto_engine_unregister_aeads (algs_aead,ARRAY_SIZE (algs)); +crypto_engine_unregister_aeads (algs_aead,ARRAY_SIZE (algs_aead));return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 207/1518 RDMA/irdma: Deduplicate the irdma_del_memlist logic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 097f50384e1877b7cf3ace12ff0d1beed19f2088 ]
Simplify/dedup the irdma_del_memlist logic in preparation for the QP/CQ/SRQ ring MR refcounting change that will follow in a subsequent commit.
Stable-dep-of: f67d8a08f60c ("RDMA/irdma: Add refcounting to user ring MRs")
--- drivers/infiniband/hw/irdma/verbs.c | 31 +++++++++++------------------ 1 file changed, 12 insertions(+), 19 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +12 -19
@@ -3868,35 +3868,28 @@ static void irdma_del_memlist(struct irdma_mr *iwmr, {struct irdma_pbl *iwpbl = &iwmr->iwpbl;unsigned long flags; +spinlock_t *lock;switch (iwmr->type) {case IRDMA_MEMREG_TYPE_CQ : -spin_lock_irqsave (&ucontext->cq_reg_mem_list_lock, flags); -if (iwpbl->on_list) { - iwpbl->on_list = false; -list_del (&iwpbl->list); - } -spin_unlock_irqrestore (&ucontext->cq_reg_mem_list_lock, flags); + lock = &ucontext->cq_reg_mem_list_lock;break ;case IRDMA_MEMREG_TYPE_QP : -spin_lock_irqsave (&ucontext->qp_reg_mem_list_lock, flags); -if (iwpbl->on_list) { - iwpbl->on_list = false; -list_del (&iwpbl->list); - } -spin_unlock_irqrestore (&ucontext->qp_reg_mem_list_lock, flags); + lock = &ucontext->qp_reg_mem_list_lock;break ;case IRDMA_MEMREG_TYPE_SRQ : -spin_lock_irqsave (&ucontext->srq_reg_mem_list_lock, flags); -if (iwpbl->on_list) { - iwpbl->on_list = false; -list_del (&iwpbl->list); - } -spin_unlock_irqrestore (&ucontext->srq_reg_mem_list_lock, flags); + lock = &ucontext->srq_reg_mem_list_lock;break ;default : -break ; +return ; + } + +spin_lock_irqsave (lock, flags); +if (iwpbl->on_list) { + iwpbl->on_list = false; +list_del (&iwpbl->list); } +spin_unlock_irqrestore (lock, flags); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 208/1518 RDMA/irdma: Add a refcount to track user ring MR associations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit a7d0a6b58256a77566e9088a99e1594bf35821ec ]
User QP/CQ/SRQ rings are registered with the normal reg_mr mechanism prior to creating the actual QP/CQ/SRQ object. In order to prevent userspace from deregistering these special MRs while the child object still exists, a refcount will be used.
This commit adds the refcount and logic to reject a dereg_mr with active references. Subsequent commits will add logic to bump this refcount when the user QP/CQ/SRQ objects are created.
Stable-dep-of: f67d8a08f60c ("RDMA/irdma: Add refcounting to user ring MRs")
--- drivers/infiniband/hw/irdma/verbs.c | 21 +++++++++++++++++---- drivers/infiniband/hw/irdma/verbs.h | 1 + 2 files changed, 18 insertions(+), 4 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +17 -4
@@ -3363,6 +3363,7 @@ static struct irdma_mr *irdma_alloc_iwmr(struct ib_umem *region,if (!iwmr)return ERR_PTR (-ENOMEM ); +refcount_set (&iwmr->user_ring_refs,1 ); iwpbl = &iwmr->iwpbl; iwpbl->iwmr = iwmr; iwmr->region = region;
@@ -3862,13 +3863,16 @@ static struct ib_mr *irdma_get_dma_mr(struct ib_pd *pd, int acc)* irdma_del_memlist - Deleting pbl list entries for CQ/QP * @iwmr: iwmr for IB's user page addresses * @ucontext: ptr to user context +* +* Return: True if the MR is currently in-use by a QP/CQ/SRQ ring. */ -static void irdma_del_memlist (struct irdma_mr *iwmr, +static bool irdma_del_memlist (struct irdma_mr *iwmr,struct irdma_ucontext *ucontext) {struct irdma_pbl *iwpbl = &iwmr->iwpbl;unsigned long flags;spinlock_t *lock; +bool in_use = false;switch (iwmr->type) {case IRDMA_MEMREG_TYPE_CQ :
@@ -3881,15 +3885,19 @@ static void irdma_del_memlist(struct irdma_mr *iwmr, lock = &ucontext->srq_reg_mem_list_lock;break ;default : -return ; +return false; }spin_lock_irqsave (lock, flags); -if (iwpbl->on_list) { +if (!refcount_dec_if_one (&iwmr->user_ring_refs)) { + in_use = true; + }else if (iwpbl->on_list) { iwpbl->on_list = false;list_del (&iwpbl->list); }spin_unlock_irqrestore (lock, flags); + +return in_use; }/**
@@ -3911,7 +3919,12 @@ static int irdma_dereg_mr(struct ib_mr *ib_mr, struct ib_udata *udata) ucontext =rdma_udata_to_drv_context (udata, struct irdma_ucontext, ibucontext); -irdma_del_memlist (iwmr, ucontext); + +/* Do not allow the MR to be unpinned if it is still +* backing a user ring. +*/ +if (irdma_del_memlist (iwmr, ucontext)) +return -EBUSY ; } goto done; }
drivers/infiniband/hw/irdma/verbs.h +1 -0
@@ -120,6 +120,7 @@ struct irdma_mr {u64 len;u64 pgaddrmem[IRDMA_MAX_SAVED_PHY_PGADDR ];struct irdma_pbl iwpbl; +refcount_t user_ring_refs; };struct irdma_srq {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 209/1518 RDMA/irdma: Add irdma_cq fields to track pbl allocations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit 971e99623ed7a0d75a719021cf4fd64e5f9e44e5 ]
These fields will be used in a subsequent commit which adds refcounting to user CQ MRs.
Stable-dep-of: f67d8a08f60c ("RDMA/irdma: Add refcounting to user ring MRs")
--- drivers/infiniband/hw/irdma/verbs.c | 25 +++++++++++++++---------- drivers/infiniband/hw/irdma/verbs.h | 2 ++ 2 files changed, 17 insertions(+), 10 deletions(-)
drivers/infiniband/hw/irdma/verbs.c +15 -10
@@ -2130,6 +2130,11 @@ static int irdma_resize_cq(struct ib_cq *ibcq, int entries, goto error;spin_lock_irqsave (&iwcq->lock, flags); +if (udata) +/* Only update if the resize was successful. Otherwise, HW is +* still pointing to the old PBL. +*/ + iwcq->iwpbl = iwpbl_buf;if (cq_buf) { cq_buf->kmem_buf = iwcq->kmem; cq_buf->hw = dev->hw;
@@ -2500,6 +2505,8 @@ static int irdma_create_cq(struct ib_cq *ibcq,INIT_LIST_HEAD (&iwcq->resize_list);INIT_LIST_HEAD (&iwcq->cmpl_generated); iwcq->cq_num = cq_num; + iwcq->iwpbl =NULL ; + iwcq->iwpbl_shadow =NULL ; info.dev = dev; ukinfo->cq_size =max (entries,4 ); ukinfo->cq_id = cq_num;
@@ -2518,8 +2525,6 @@ static int irdma_create_cq(struct ib_cq *ibcq,struct irdma_ucontext *ucontext;struct irdma_create_cq_req req = {};struct irdma_cq_mr *cqmr; -struct irdma_pbl *iwpbl; -struct irdma_pbl *iwpbl_shadow;struct irdma_cq_mr *cqmr_shadow; iwcq->user_mode = true;
@@ -2533,34 +2538,34 @@ static int irdma_create_cq(struct ib_cq *ibcq, }spin_lock_irqsave (&ucontext->cq_reg_mem_list_lock, flags); - iwpbl =irdma_get_pbl ((unsigned long )req.user_cq_buf, - &ucontext->cq_reg_mem_list); + iwcq->iwpbl =irdma_get_pbl ((unsigned long )req.user_cq_buf, + &ucontext->cq_reg_mem_list);spin_unlock_irqrestore (&ucontext->cq_reg_mem_list_lock, flags); -if (!iwpbl) { +if (!iwcq->iwpbl) { err_code = -EPROTO ; goto cq_free_rsrc; } - cqmr = &iwpbl->cq_mr; + cqmr = &iwcq->iwpbl->cq_mr;if (rf->sc_dev.hw_attrs.uk_attrs.feature_flags &IRDMA_FEATURE_CQ_RESIZE ) {spin_lock_irqsave (&ucontext->cq_reg_mem_list_lock, flags); - iwpbl_shadow =irdma_get_pbl ( + iwcq->iwpbl_shadow =irdma_get_pbl ( (unsigned long )req.user_shadow_area, &ucontext->cq_reg_mem_list);spin_unlock_irqrestore (&ucontext->cq_reg_mem_list_lock, flags); -if (!iwpbl_shadow) { +if (!iwcq->iwpbl_shadow) { err_code = -EPROTO ; goto cq_free_rsrc; } - cqmr_shadow = &iwpbl_shadow->cq_mr; + cqmr_shadow = &iwcq->iwpbl_shadow->cq_mr; info.shadow_area_pa = cqmr_shadow->cq_pbl.addr; }else { info.shadow_area_pa = cqmr->shadow; } -if (iwpbl->pbl_allocated) { +if (iwcq->iwpbl->pbl_allocated) { info.virtual_map = true; info.pbl_chunk_size =1 ; info.first_pm_pbl_idx = cqmr->cq_pbl.idx;
drivers/infiniband/hw/irdma/verbs.h +2 -0
@@ -153,6 +153,8 @@ struct irdma_cq {struct list_head resize_list;struct irdma_cq_poll_info cur_cqe;struct list_head cmpl_generated; +struct irdma_pbl *iwpbl; +struct irdma_pbl *iwpbl_shadow; };struct irdma_cmpl_gen {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 210/1518 RDMA/irdma: Add refcounting to user ring MRs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Moroni <[email protected]>
[ Upstream commit f67d8a08f60c9217df6d40da56422d2049f5e334 ]
Prevent userspace from deregistering the MRs that back QP/CQ/SRQ rings by bumping the MR's refcount upon association.
--- drivers/infiniband/hw/irdma/utils.c | 6 ++++ drivers/infiniband/hw/irdma/verbs.c | 45 +++++++++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-)
drivers/infiniband/hw/irdma/utils.c +6 -0
@@ -1169,6 +1169,12 @@ void irdma_free_qp_rsrc(struct irdma_qp *iwqp) iwqp->kqp.dma_mem.va =NULL ;kfree (iwqp->kqp.sq_wrid_mem);kfree (iwqp->kqp.rq_wrid_mem); + +if (iwqp->user_mode && iwqp->iwpbl) { +struct irdma_mr *iwmr = iwqp->iwpbl->iwmr; + +refcount_dec (&iwmr->user_ring_refs); + } }/**
drivers/infiniband/hw/irdma/verbs.c +43 -2
91 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 211/1518 arm64: dts: qcom: sm8750: wire UFS to ice instance
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuldeep Singh <[email protected]>
[ Upstream commit ac456227d22952b656ad291ebd2d3d3e498e3d95 ]
The Inline Crypto Engine (ICE) exists as a standalone DT node, but the UFS node lacks the required qcom,ice phandle reference.
Add the qcom,ice property to explicitly associate the UFS controller with its ICE instance.
--- arch/arm64/boot/dts/qcom/sm8750.dtsi | 1 + 1 file changed, 1 insertion(+)
arch/arm64/boot/dts/qcom/sm8750.dtsi +1 -0
@@ -3558,6 +3558,7 @@ &mc_virt SLAVE_EBI1 QCOM_ICC_TAG_ALWAYS>, phy-names = "ufsphy"; #reset-cells = <1>; + qcom,ice = <&ice>; status = "disabled";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 212/1518 nvme-apple: Use acquire/release for queue enabled state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit f61c934aa084b7440fec681be3f4b481eb5a8609 ]
apple_nvme_init_queue() initializes queue state and then marks the queue enabled. The interrupt and request paths check enabled before using that queue state.
The old wmb() after WRITE_ONCE(enabled, true) does not publish the earlier initialization before enabled becomes visible. Use a release store when enabling the queue and acquire loads when testing it.
Although the shutdown-side enabled accesses are not used for publishing queue initialization, use helpers for them as well for consistency.
--- drivers/nvme/host/apple.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/nvme/host/apple.c +23 -7
@@ -151,6 +151,23 @@ struct apple_nvme_queue {bool enabled; }; +static inline bool apple_nvme_queue_enabled (struct apple_nvme_queue *q) +{ +/* Pair with apple_nvme_enable_queue(). */ +return smp_load_acquire (&q->enabled); +} + +static inline void apple_nvme_enable_queue (struct apple_nvme_queue *q) +{ +/* Publish queue initialization before setting q->enabled. */ +smp_store_release (&q->enabled, true); +} + +static inline void apple_nvme_disable_queue (struct apple_nvme_queue *q) +{ +WRITE_ONCE (q->enabled, false); +} +/* * The apple_nvme_iod describes the data in an I/O. *
@@ -677,7 +694,7 @@ static bool apple_nvme_handle_cq(struct apple_nvme_queue *q, bool force)bool found;DEFINE_IO_COMP_BATCH (iob); -if (!READ_ONCE (q->enabled) && !force) +if (!apple_nvme_queue_enabled (q) && !force)return false; found =apple_nvme_poll_cq (q, &iob);
@@ -780,7 +797,7 @@ static blk_status_t apple_nvme_queue_rq(struct blk_mq_hw_ctx *hctx,* We should not need to do this, but we're still using this to * ensure we can drain requests on a dying queue. */ -if (unlikely (!READ_ONCE (q->enabled))) +if (unlikely (!apple_nvme_queue_enabled (q)))return BLK_STS_IOERR ;if (!nvme_check_ready (&anv->ctrl, req, true))
@@ -863,7 +880,7 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)nvme_quiesce_io_queues (&anv->ctrl);if (!dead) { -if (READ_ONCE (anv->ioq.enabled)) { +if (apple_nvme_queue_enabled (&anv->ioq)) {apple_nvme_remove_sq (anv);apple_nvme_remove_cq (anv); }
@@ -887,8 +904,8 @@ static void apple_nvme_disable(struct apple_nvme *anv, bool shutdown)nvme_disable_ctrl (&anv->ctrl, false); } -WRITE_ONCE (anv->ioq.enabled, false); -WRITE_ONCE (anv->adminq.enabled, false); +apple_nvme_disable_queue (&anv->ioq); +apple_nvme_disable_queue (&anv->adminq);mb ();/* ensure that nvme_queue_rq() sees that enabled is cleared */ nvme_quiesce_admin_queue (&anv->ctrl);
@@ -1016,8 +1033,7 @@ static void apple_nvme_init_queue(struct apple_nvme_queue *q)memset (q->tcbs,0 , anv->hw->max_queue_depth *sizeof (struct apple_nvmmu_tcb ));memset (q->cqes,0 , depth *sizeof (struct nvme_completion )); -WRITE_ONCE (q->enabled, true); -wmb ();/* ensure the first interrupt sees the initialization */ +apple_nvme_enable_queue (q); }static void apple_nvme_reset_work (struct work_struct *work)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 213/1518 nvmet-rdma: factor out response resource cleanup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shin'ichiro Kawasaki <[email protected]>
[ Upstream commit 90096175473f7c86e39c3f74f10343f965f5a05d ]
Move the RDMA read/write context teardown and the request SGL freeing out of nvmet_rdma_release_rsp() into a new helper function nvmet_rdma_free_rsp_resources().
This is a refactoring with no functional change, in preparation for the following patch that uses nvmet_rdma_free_rsp_resources().
Stable-dep-of: 0114dd303b37 ("nvmet-rdma: fix response resource leak on queue teardown")
--- drivers/nvme/target/rdma.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/nvme/target/rdma.c +10 -3
@@ -658,18 +658,25 @@ static void nvmet_rdma_rw_ctx_destroy(struct nvmet_rdma_rsp *rsp) req->sg, req->sg_cnt, nvmet_data_dir(req)); } -static void nvmet_rdma_release_rsp (struct nvmet_rdma_rsp *rsp) +static void nvmet_rdma_free_rsp_resources (struct nvmet_rdma_rsp *rsp) {struct nvmet_rdma_queue *queue = rsp->queue; -atomic_add (1 + rsp->n_rdma, &queue->sq_wr_avail); -if (rsp->n_rdma)nvmet_rdma_rw_ctx_destroy (rsp);if (rsp->req.sg < rsp->cmd->inline_sg || rsp->req.sg >= rsp->cmd->inline_sg + queue->dev->inline_page_count)nvmet_req_free_sgls (&rsp->req); +} + +static void nvmet_rdma_release_rsp (struct nvmet_rdma_rsp *rsp) +{ +struct nvmet_rdma_queue *queue = rsp->queue; + +atomic_add (1 + rsp->n_rdma, &queue->sq_wr_avail); + +nvmet_rdma_free_rsp_resources (rsp);if (unlikely (!list_empty_careful (&queue->rsp_wr_wait_list)))nvmet_rdma_process_wr_wait_list (queue);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 214/1518 nvmet-rdma: fix response resource leak on queue teardown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shin'ichiro Kawasaki <[email protected]>
[ Upstream commit 0114dd303b373522dea06053aabae34bdd33a7c4 ]
When an nvme target with rdma transport is removed while I/Os are in flight, a response can be posted but its send completion is never delivered before the connection is torn down. As a result nvmet_rdma_send_done() and nvmet_rdma_release_rsp() are never called for the response, and this leaks the allocated RDMA read/write context and request SGLs.
These leaks are recreated by running blktests nvme/061 with the rdma transport and the siw driver. Kernel kmemleak feature reports them as follows:
unreferenced object 0xffff88812bc490c0 (size 32):
comm "kworker/2:1H", pid 409, jiffies 4307744490
backtrace (crc 89afd339):
__kmalloc_noprof+0x5f9/0x890
sgl_alloc_order+0x7b/0x380
nvmet_req_alloc_sgls+0x290/0x4f0 [nvmet]
nvmet_rdma_map_sgl_keyed+0x241/0x12e0 [nvmet_rdma]
nvmet_rdma_handle_command+0x73e/0xb80 [nvmet_rdma]
__ib_process_cq+0x149/0x4c0 [ib_core]
ib_cq_poll_work+0x49/0x160 [ib_core]
process_one_work+0x8b2/0x1640
worker_thread+0x5fd/0xfe0
kthread+0x367/0x460
ret_from_fork+0x655/0x9d0
ret_from_fork_asm+0x1a/0x30 unreferenced object 0xffff88814bd05e80 (size 64):
comm "kworker/3:1H", pid 148, jiffies 4295195428
backtrace (crc e35510cb):
__kmalloc_noprof+0x5f9/0x890
rdma_rw_ctx_init+0x333/0x1fa0 [ib_core]
nvmet_rdma_map_sgl_keyed+0x5c8/0x12e0 [nvmet_rdma]
nvmet_rdma_handle_command+0x73e/0xb80 [nvmet_rdma]
__ib_process_cq+0x149/0x4c0 [ib_core]
ib_cq_poll_work+0x49/0x160 [ib_core]
process_one_work+0x8b2/0x1640
worker_thread+0x5fd/0xfe0
kthread+0x367/0x460
ret_from_fork+0x655/0x9d0
ret_from_fork_asm+0x1a/0x30To avoid the memory leaks, reclaim the memory of the in-flight responses when the queue QP is torn down. Call nvmet_rdma_free_rsp_resources() that frees up the RDMA read/write context and the request SGLs of such responses.
--- drivers/nvme/target/rdma.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
drivers/nvme/target/rdma.c +18 -0
@@ -1346,9 +1346,27 @@ static int nvmet_rdma_create_queue_ib(struct nvmet_rdma_queue *queue) goto out; } +static bool nvmet_rdma_reclaim_rsp (struct sbitmap *sb,unsigned int bitnr, +void *data) +{ +struct nvmet_rdma_queue *queue = data; + +nvmet_rdma_free_rsp_resources (&queue->rsps[bitnr]); + +return true; +} +static void nvmet_rdma_destroy_queue_ib (struct nvmet_rdma_queue *queue) {ib_drain_qp (queue->qp); + +/* +* Reclaim resources of a response that is still in-flight when the +* queue is being torn down. This happens when the connection was +* forcefully disconnected while an I/O is in flight. +*/ +sbitmap_for_each_set (&queue->rsp_tags, nvmet_rdma_reclaim_rsp, queue); +if (queue->cm_id)rdma_destroy_id (queue->cm_id);ib_destroy_qp (queue->qp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 215/1518 bus: ti-sysc: Fix /chosen node reference leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 6342de0aed216b6df460b492ddb532b3e0ed16f1 ]
sysc_init_stdout_path() gets the /chosen node with of_find_node_by_path() to read stdout-path. The function then overwrites the local node pointer with the stdout-path lookup result, or exits on error, without dropping the /chosen reference.
Keep the /chosen node in a separate variable and put it after the stdout-path value has been used for the lookup. The successful stdout node lookup remains referenced by the cached stdout_path pointer.
--- drivers/bus/ti-sysc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/bus/ti-sysc.c +8 -4
@@ -682,6 +682,7 @@ static struct device_node *stdout_path;static void sysc_init_stdout_path (struct sysc *ddata) { +struct device_node *chosen;struct device_node *np =NULL ;const char *uart;
@@ -691,15 +692,18 @@ static void sysc_init_stdout_path(struct sysc *ddata)if (stdout_path)return ; - np =of_find_node_by_path ("/chosen" ); -if (!np) + chosen =of_find_node_by_path ("/chosen" ); +if (!chosen) goto err; - uart =of_get_property (np,"stdout-path" ,NULL ); -if (!uart) + uart =of_get_property (chosen,"stdout-path" ,NULL ); +if (!uart) { +of_node_put (chosen); goto err; + } np =of_find_node_by_path (uart); +of_node_put (chosen);if (!np) goto err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 216/1518 PM: sleep: Fix off-by-one in wakelocks number limit check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haowen Tu <[email protected]>
[ Upstream commit 6058646587dded0ce0ba91bd5a6afbf14fe42055 ]
CONFIG_PM_WAKELOCKS_LIMIT is documented as the maximum number of user-space wakeup sources, but the limit check is performed before the counter is incremented and only rejects new wakeup sources when the current number is greater than the limit. This allows one extra wakeup source to be created.
Reject new wakeup sources once the counter has reached the limit.
--- kernel/power/wakelock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/power/wakelock.c +1 -1
@@ -63,7 +63,7 @@ static unsigned int number_of_wakelocks;static inline bool wakelocks_limit_exceeded (void ) { -return number_of_wakelocks >CONFIG_PM_WAKELOCKS_LIMIT ; +return number_of_wakelocks >=CONFIG_PM_WAKELOCKS_LIMIT ; }static inline void increment_wakelocks_number (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 217/1518 cgroup/cpuset: Make nr_deadline_tasks an atomic_t
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Waiman Long <[email protected]>
[ Upstream commit 95220e1f18f6321008f021abc7d6f581f64bcb82 ]
The nr_deadline_tasks variable in the cpuset structure was introduced by commit 6c24849f5515 ("sched/cpuset: Keep track of SCHED_DEADLINE task in cpusets"). It is reported by sashiko [1] that nr_deadline_tasks can currently be modified by inc_dl_tasks_cs() under rq->lock and by cpuset_attach() under cpuset_mutex. So if both updates happen simultaneously, the nr_deadline_tasks variable can be corrupted leading to incorrect operations down the road.
Fix that by changing its type to atomic_t so that nr_deadline_tasks are always atomically updated. This fix patch is a low hanging fruit. It can handle some of the races between a concurrent sched_setscheduler() and cpuset_can_attach()/cpuset_attach() calls, but not all of them like the other issue raised by sashiko [2]. This will be handled hopefully in a future follow up patch.
[1] https://sashiko.dev/#/patchset/20260626181923.133658-1-longman%40redhat.com
[2] https://sashiko.dev/#/patchset/20260630033344.352702-1-longman%40redhat.com
--- kernel/cgroup/cpuset-internal.h | 2 +- kernel/cgroup/cpuset.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-)
kernel/cgroup/cpuset-internal.h +1 -1
@@ -165,7 +165,7 @@ struct cpuset {* number of SCHED_DEADLINE tasks attached to this cpuset, so that we * know when to rebuild associated root domain bandwidth information. */ -int nr_deadline_tasks; +atomic_t nr_deadline_tasks;int nr_migrate_dl_tasks;u64 sum_migrate_dl_bw;
kernel/cgroup/cpuset.c +5 -5
@@ -145,14 +145,14 @@ void inc_dl_tasks_cs(struct task_struct *p) {struct cpuset *cs =task_cs (p); - cs->nr_deadline_tasks++; +atomic_inc (&cs->nr_deadline_tasks); }void dec_dl_tasks_cs (struct task_struct *p) {struct cpuset *cs =task_cs (p); - cs->nr_deadline_tasks--; +atomic_dec (&cs->nr_deadline_tasks); }static inline bool is_partition_valid (const struct cpuset *cs)
@@ -1033,7 +1033,7 @@ static void dl_update_tasks_root_domain(struct cpuset *cs)struct css_task_iter it;struct task_struct *task; -if (cs->nr_deadline_tasks ==0 ) +if (atomic_read (&cs->nr_deadline_tasks) ==0 )return ;css_task_iter_start (&cs->css,0 , &it);
@@ -3313,8 +3313,8 @@ static void cpuset_attach(struct cgroup_taskset *tset) cs->old_mems_allowed = cpuset_attach_nodemask_to;if (cs->nr_migrate_dl_tasks) { - cs->nr_deadline_tasks += cs->nr_migrate_dl_tasks; - oldcs->nr_deadline_tasks -= cs->nr_migrate_dl_tasks; +atomic_add (cs->nr_migrate_dl_tasks, &cs->nr_deadline_tasks); +atomic_sub (cs->nr_migrate_dl_tasks, &oldcs->nr_deadline_tasks);reset_migrate_dl_data (cs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 218/1518 arm64: dts: qcom: sc8280xp-blackrock: switch to uefi rtc offset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Glathe <[email protected]>
[ Upstream commit f52102fc9ccbbb3c4bc01a29f3194fe07f9602f5 ]
On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account.
On platforms where the offset is stored in a Qualcomm specific UEFI variable the variables are also accessed in a non-standard way, which means that the OS cannot assume that the variable service is available by the time the RTC driver probes.
Use the new 'qcom,uefi-rtc-info' property to indicate that the offset is stored in a UEFI variable so that the OS can determine whether to wait for it to become available.
[1]: https://lore.kernel.org/r/[email protected]
--- .../boot/dts/qcom/sc8280xp-microsoft-blackrock.dts | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
arch/arm64/boot/dts/qcom/sc8280xp-microsoft-blackrock.dts +1 -10
@@ -769,20 +769,11 @@ &pmk8280_pon_resin { }; &pmk8280_rtc { - nvmem-cells = <&rtc_offset>; - nvmem-cell-names = "offset"; + qcom,uefi-rtc-info; status = "okay"; }; -&pmk8280_sdam_6 { - status = "okay"; - - rtc_offset: rtc-offset@bc { - reg = <0xbc 0x4>; - }; -}; - &pmk8280_vadc { channel@144 { reg = <PM8350_ADC7_AMUX_THM1_100K_PU(1)>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 219/1518 arm64: dts: qcom: sm7225-fairphone-fp4: Fix address in fb node name
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit f6e65005fe55c3d09287851523de06367cbf0bc2 ]
'reg' is 0xa0000000 so the node name is missing a zero. Add it, so that the reg and address in the node name matches.
No functional impact.
--- arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sm7225-fairphone-fp4.dts +1 -1
@@ -48,7 +48,7 @@ chosen { stdout-path = "serial0:115200n8"; - framebuffer0: framebuffer@a000000 { + framebuffer0: framebuffer@a0000000 { compatible = "simple-framebuffer"; reg = <0 0xa0000000 0 (2340 * 1080 * 4)>; width = <1080>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 220/1518 arm64: dts: qcom: hamoa: Fix clocks for HSPHYs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 115894bc201b0cd1799d239875a1b40924f0ef7b ]
The tertiary controller's HSPHY has its own toggle in TCSR, while the primary one is wired directly to the XO clock. Fix that.
--- arch/arm64/boot/dts/qcom/hamoa.dtsi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/hamoa.dtsi +2 -2
@@ -2826,7 +2826,7 @@ usb_1_ss0_hsphy: phy@fd3000 { reg = <0 0x00fd3000 0 0x154>; #phy-cells = <0>; - clocks = <&tcsr TCSR_USB2_1_CLKREF_EN>; + clocks = <&rpmhcc RPMH_CXO_CLK>; clock-names = "ref"; resets = <&gcc GCC_QUSB2PHY_PRIM_BCR>;
@@ -2968,7 +2968,7 @@ usb_1_ss2_hsphy: phy@fde000 { reg = <0 0x00fde000 0 0x154>; #phy-cells = <0>; - clocks = <&tcsr TCSR_USB2_1_CLKREF_EN>; + clocks = <&tcsr TCSR_USB2_2_CLKREF_EN>; clock-names = "ref"; resets = <&gcc GCC_QUSB2PHY_TERT_BCR>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 221/1518 clk: qcom: gcc-glymur: Move EVA clocks to critical clock list
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Taniya Das <[email protected]>
[ Upstream commit 7399034fd78615ba826b864fca2e4572f13cf8e3 ]
The gcc_eva_ahb_clk and gcc_eva_xo_clk branch clocks should not be registered as standalone GCC branch clocks. Drop these clocks from the GCC clock list and instead add their CBCR registers to the GCC critical clocks list to ensure they remain enabled during early boot.
If these clocks are registered as normal branch clocks, they may be gated, which breaks access to the EVA clock controller during clock controller probe, thus leave them as critical clocks similar to other subsystem AHB and XO clocks.
--- drivers/clk/qcom/gcc-glymur.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-)
drivers/clk/qcom/gcc-glymur.c +2 -30
@@ -3671,21 +3671,6 @@ static struct clk_branch gcc_disp_hf_axi_clk = { }, }; -static struct clk_branch gcc_eva_ahb_clk = { - .halt_reg =0x9b004 , - .halt_check =BRANCH_HALT_VOTED , - .hwcg_reg =0x9b004 , - .hwcg_bit =1 , - .clkr = { - .enable_reg =0x9b004 , - .enable_mask =BIT (0 ), - .hw.init = &(const struct clk_init_data ) { - .name ="gcc_eva_ahb_clk" , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch gcc_eva_axi0_clk = { .halt_reg =0x9b008 , .halt_check =BRANCH_HALT_SKIP ,
@@ -3716,19 +3701,6 @@ static struct clk_branch gcc_eva_axi0c_clk = { }, }; -static struct clk_branch gcc_eva_xo_clk = { - .halt_reg =0x9b024 , - .halt_check =BRANCH_HALT , - .clkr = { - .enable_reg =0x9b024 , - .enable_mask =BIT (0 ), - .hw.init = &(const struct clk_init_data ) { - .name ="gcc_eva_xo_clk" , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch gcc_gp1_clk = { .halt_reg =0x64000 , .halt_check =BRANCH_HALT ,
@@ -7995,10 +7967,8 @@ static struct clk_regmap *gcc_glymur_clocks[] = { [GCC_CFG_NOC_USB_ANOC_AHB_CLK] = &gcc_cfg_noc_usb_anoc_ahb_clk.clkr, [GCC_CFG_NOC_USB_ANOC_SOUTH_AHB_CLK] = &gcc_cfg_noc_usb_anoc_south_ahb_clk.clkr, [GCC_DISP_HF_AXI_CLK] = &gcc_disp_hf_axi_clk.clkr, - [GCC_EVA_AHB_CLK] = &gcc_eva_ahb_clk.clkr, [GCC_EVA_AXI0_CLK] = &gcc_eva_axi0_clk.clkr, [GCC_EVA_AXI0C_CLK] = &gcc_eva_axi0c_clk.clkr, - [GCC_EVA_XO_CLK] = &gcc_eva_xo_clk.clkr, [GCC_GP1_CLK] = &gcc_gp1_clk.clkr, [GCC_GP1_CLK_SRC] = &gcc_gp1_clk_src.clkr, [GCC_GP2_CLK] = &gcc_gp2_clk.clkr,
@@ -8547,6 +8517,8 @@ static u32 gcc_glymur_critical_cbcrs[] = {0x71004 ,/* GCC_GPU_CFG_AHB_CLK */ 0x32004 ,/* GCC_VIDEO_AHB_CLK */ 0x32058 ,/* GCC_VIDEO_XO_CLK */ +0x9b004 ,/* GCC_EVA_AHB_CLK */ + 0x9b024, /* GCC_EVA_XO_CLK */ }; static const struct regmap_config gcc_glymur_regmap_config = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 222/1518 bus: qcom-ebi2: Simplify with scoped for each OF child loop
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit 9c252f3c8f390fae4ca09de36c9262a35ae88ace ]
Use scoped for-each loop when iterating over device nodes to make code a bit simpler.
Stable-dep-of: 64774dea5896 ("bus: qcom-ebi2: Fix clock leak on probe failure")
--- drivers/bus/qcom-ebi2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/bus/qcom-ebi2.c +2 -5
@@ -292,7 +292,6 @@ static void qcom_ebi2_setup_chipselect(struct device_node *np,static int qcom_ebi2_probe (struct platform_device *pdev) {struct device_node *np = pdev->dev.of_node; -struct device_node *child;struct device *dev = &pdev->dev;struct resource *res;void __iomem *ebi2_base;
@@ -348,15 +347,13 @@ static int qcom_ebi2_probe(struct platform_device *pdev)writel (val, ebi2_base);/* Walk over the child nodes and see what chipselects we use */ -for_each_available_child_of_node (np, child) { +for_each_available_child_of_node_scoped (np, child) {u32 csindex;/* Figure out the chipselect */ ret =of_property_read_u32 (child,"reg" , &csindex); -if (ret) { -of_node_put (child); +if (ret)return ret; - }if (csindex >5 ) { dev_err(dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 223/1518 bus: qcom-ebi2: Fix clock leak on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 64774dea58969194ea5c27fa639954e551a87024 ]
qcom_ebi2_probe() enables the EBI2X and EBI2 clocks before it walks child nodes and populates child devices. If reading a child node's reg property fails, or if of_platform_default_populate() fails, probe returns without disabling either clock.
Route those failure paths through the existing clock cleanup labels so a failed probe does not leave the clocks prepared and enabled.
--- drivers/bus/qcom-ebi2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/bus/qcom-ebi2.c +7 -3
@@ -353,7 +353,7 @@ static int qcom_ebi2_probe(struct platform_device *pdev)/* Figure out the chipselect */ ret =of_property_read_u32 (child,"reg" , &csindex);if (ret) -return ret; + goto err_disable_clk;if (csindex >5 ) { dev_err(dev,
@@ -372,8 +372,12 @@ static int qcom_ebi2_probe(struct platform_device *pdev) have_children = true; } -if (have_children) -return of_platform_default_populate (np,NULL , dev); +if (have_children) { + ret =of_platform_default_populate (np,NULL , dev); +if (ret) + goto err_disable_clk; + } +return 0 ; err_disable_clk:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 224/1518 wifi: mac80211_hwsim: avoid NULL skb in stop queue drain
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 158438cd6ad69d6dd7d871582c38baf22169fede ]
mac80211_hwsim_stop() drops any frames left in data->pending. The loop currently checks skb_queue_empty() and then dequeues separately.
That split is racy with TX status handling, which can remove a pending frame under the queue lock. If the last entry is removed after the empty check, skb_dequeue() returns NULL and the stop path passes that NULL skb to ieee80211_free_txskb().
Use skb_dequeue() as the loop condition instead. The dequeue result is the object that stop owns and frees, and a concurrent status completion that empties the queue simply makes the loop terminate.
--- drivers/net/wireless/virtual/mac80211_hwsim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/virtual/mac80211_hwsim.c +3 -2
@@ -2159,6 +2159,7 @@ static int mac80211_hwsim_start(struct ieee80211_hw *hw)static void mac80211_hwsim_stop (struct ieee80211_hw *hw,bool suspend) {struct mac80211_hwsim_data *data = hw->priv; +struct sk_buff *skb;int i; data->started = false;
@@ -2166,8 +2167,8 @@ static void mac80211_hwsim_stop(struct ieee80211_hw *hw, bool suspend)for (i =0 ; i <ARRAY_SIZE (data->link_data); i++)hrtimer_cancel (&data->link_data[i].beacon_timer); -while (!skb_queue_empty (&data->pending)) -ieee80211_free_txskb (hw,skb_dequeue (&data->pending)); +while ((skb =skb_dequeue (&data->pending))) +ieee80211_free_txskb (hw, skb);wiphy_dbg (hw->wiphy,"%s\n" , __func__); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 225/1518 staging: greybus: audio: correct sscanf() return value check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexander A. Klimov <[email protected]>
[ Upstream commit f883fa1a0a0212f63acb18c50e5f900301f3bb1e ]
manager_sysfs_add_store() passes 6 pointers to sscanf(), but required latter to return 7 which always failed the operation. I corrected it to 6.
--- drivers/staging/greybus/audio_manager_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/greybus/audio_manager_sysfs.c +1 -1
@@ -23,7 +23,7 @@ static ssize_t manager_sysfs_add_store(struct kobject *kobj, desc.name, &desc.vid, &desc.pid, &desc.intf_id, &desc.ip_devices, &desc.op_devices); -if (num !=7 ) +if (num !=6 )return -EINVAL ; num =gb_audio_manager_add (&desc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 226/1518 staging: sm750fb: gate dualview dataflow using g_dualview
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmet Sezgin Duran <[email protected]>
[ Upstream commit d352778979d2eed09e266ed0f3a5e3ccd3983940 ]
In sm750fb_setup and sm750fb_set_drv functions, the dualview related code is guarded by sm750_dev->fb_count > 1 condition. That value is updated only after each framebuffer is registered, while both guards are used before any increment.
Current flow:
lynxfb_pci_probe()
sm750fb_setup() // fb_count is 0
for each fb:
sm750fb_framebuffer_alloc()
lynxfb_set_fbinfo()
sm750fb_set_drv() // fb_count is 0 or 1
register_framebuffer()
sm750_dev->fb_count++; // fb_count is incrementedThus even if dualview=1 parameter is passed down to the driver, fb_count is never > 1 at either check, so dualview dataflows are not selected and crtc->vidmem_size is never halved.
Use g_dualview global variable instead of fb_count > 1 to correctly enable dualview capabilities.
--- drivers/staging/sm750fb/sm750.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/sm750fb/sm750.c +2 -2
@@ -603,7 +603,7 @@ static int sm750fb_set_drv(struct lynxfb_par *par) crtc = &par->crtc; crtc->vidmem_size = sm750_dev->vidmem_size; -if (sm750_dev->fb_count >1 ) +if (g_dualview) crtc->vidmem_size >>=1 ;/* setup crtc and output member */
@@ -968,7 +968,7 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src) NO_PARAM:if (sm750_dev->revid !=SM750LE_REVISION_ID ) { -if (sm750_dev->fb_count >1 ) { +if (g_dualview) {if (swap) sm750_dev->dataflow = sm750_dual_swap;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 227/1518 staging: sm750fb: Add missing Kconfig dependency
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rong Zhang <[email protected]>
[ Upstream commit da8fd33e7d6af4c069668c2d42234b969f706885 ]
The sm750 frame buffer driver depends on FB_IOMEM_FOPS, but its Kconfig somehow misses it.
Fix it by making FB_SM750 select FB_IOMEM_FOPS, as other frame buffer drivers do.
--- drivers/staging/sm750fb/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/staging/sm750fb/Kconfig +1 -0
@@ -6,6 +6,7 @@ config FB_SM750 select FB_CFB_FILLRECT select FB_CFB_COPYAREA select FB_CFB_IMAGEBLIT + select FB_IOMEM_FOPS help Frame buffer driver for the Silicon Motion SM750 chip with 2D acceleration and dual head support.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 228/1518 greybus: audio: bound the topology section sizes against the fetched size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bryam Vargas <[email protected]>
[ Upstream commit 33d8c7b794d2a30637c9d3fcb478f1d3222bef1e ]
gb_audio_gb_get_topology() fetches a topology blob of a module-supplied size, and gbaudio_tplg_parse_data() then walks it by adding the module-supplied size_dais, size_controls and size_widgets fields to form the control, widget and route section offsets. Those le32 sizes are never checked against the fetched blob, so a module reporting a small topology size but large section sizes makes the offsets point past the allocation, and parsing reads out of bounds.
Reject a topology whose section sizes do not fit within the fetched size before it is parsed.
--- drivers/staging/greybus/audio_gb.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/staging/greybus/audio_gb.c +13 -0
@@ -37,6 +37,19 @@ int gb_audio_gb_get_topology(struct gb_connection *connection,return ret; } +/* +* The size_* fields are supplied by the module and are used by +* gbaudio_tplg_parse_data() to compute offsets into the blob; make +* sure the sections fit within the fetched topology, so walking it +* cannot read out of bounds. +*/ +if ((u64 )le32_to_cpu (topo->size_dais) +le32_to_cpu (topo->size_controls) + +le32_to_cpu (topo->size_widgets) +le32_to_cpu (topo->size_routes) > + size -sizeof (*topo)) { +kfree (topo); +return -EINVAL ; + } + *topology = topo;return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 229/1518 staging: fbtft: Use sysfs_emit_at() to print to sysfs file
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 221192a784c25e28b489a7e75fabf59be4f63d57 ]
This scnprintf() uses the wrong limit. It should be "PAGE_SIZE - len" instead of just PAGE_SIZE. We're not going to hit the limit in real life since we are printing at most FBTFT_GAMMA_MAX_VALUES_TOTAL (128) u32 values, however, it's still worth fixing.
Use sysfs_emit_at() to fix this since this is a sysfs file.
--- drivers/staging/fbtft/fbtft-sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/fbtft/fbtft-sysfs.c +1 -1
@@ -98,7 +98,7 @@ sprintf_gamma(struct fbtft_par *par, u32 *curves, char *buf)mutex_lock (&par->gamma.lock);for (i =0 ; i < par->gamma.num_curves; i++) {for (j =0 ; j < par->gamma.num_values; j++) - len +=scnprintf (&buf[len],PAGE_SIZE , + len +=sysfs_emit_at (buf, len,"%04x " , curves[i * par->gamma.num_values + j]); buf[len -1 ] ='\n' ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/1518 staging: octeon: add missing tasklet_kill in cvm_oct_tx_shutdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayush Mukkanwar <[email protected]>
[ Upstream commit b9af44b0d20b2247c4eb0ea5cfca907d643eea50 ]
The TX cleanup tasklet can be scheduled by the watchdog IRQ handler to execute cvm_oct_tx_do_cleanup. There can be a pending tasklet in the queue which might run after the cvm_oct_remove() frees net_device structures, causing a use-after-free in cvm_oct_tx_do_cleanup() as it iterates cvm_oct_device[] which is an array of netdevice pointers. Add tasklet_kill() after free_irq() to ensure the tasklet is no longer scheduled or running before teardown proceeds.
--- drivers/staging/octeon/ethernet-tx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/octeon/ethernet-tx.c +2 -0
@@ -670,4 +670,6 @@ void cvm_oct_tx_shutdown(void) {/* Free the interrupt handler */ free_irq (OCTEON_IRQ_TIMER1 , cvm_oct_device); + +tasklet_kill (&cvm_oct_tx_cleanup_tasklet); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/1518 staging: octeon: fix free_irq dev_id mismatch in cvm_oct_rx_shutdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuvraj Singh Chauhan <[email protected]>
[ Upstream commit 41db5b76eeb4cc11a1097384caba7cfc659f7293 ]
In cvm_oct_rx_initialize(), request_irq() is called with &oct_rx_group[i].napi as the dev_id:
request_irq(oct_rx_group[i].irq, cvm_oct_do_interrupt, 0, "Ethernet", &oct_rx_group[i].napi);
However, cvm_oct_rx_shutdown() passes cvm_oct_device (an array of struct net_device pointers) as the dev_id to free_irq():
free_irq(oct_rx_group[i].irq, cvm_oct_device);
Since __free_irq() matches the action to remove by comparing dev_id pointers, the mismatched cookie means the IRQ handler is never found, triggering a WARN and leaving the IRQ line permanently allocated. This prevents proper driver cleanup on module removal.
Fix the mismatch by passing &oct_rx_group[i].napi as the dev_id to free_irq(), matching what was used during request_irq().
Stable-dep-of: c0a9a8586a63 ("staging: octeon: add missing napi_disable in cvm_oct_rx_shutdown")
--- drivers/staging/octeon/ethernet-rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/octeon/ethernet-rx.c +1 -1
@@ -535,7 +535,7 @@ void cvm_oct_rx_shutdown(void)cvmx_write_csr (CVMX_POW_WQ_INT_THRX (i),0 );/* Free the interrupt handler */ -free_irq (oct_rx_group[i].irq, cvm_oct_device); +free_irq (oct_rx_group[i].irq, &oct_rx_group[i].napi);netif_napi_del (&oct_rx_group[i].napi); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 232/1518 staging: octeon: ethernet-mem: replace pr_warn with dev_warn in free functions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayush Mukkanwar <[email protected]>
[ Upstream commit be5e8d5f61b31105e0ed7f51cd591653aea5054f ]
Add struct platform_device parameter to cvm_oct_free_hw_skbuff, cvm_oct_free_hw_memory and cvm_oct_mem_empty_fpa. Replace pr_warn calls with dev_warn, using &pdev->dev for device-aware logging.
Stable-dep-of: c0a9a8586a63 ("staging: octeon: add missing napi_disable in cvm_oct_rx_shutdown")
--- drivers/staging/octeon/ethernet-mem.c | 31 ++++++++++++++++----------- drivers/staging/octeon/ethernet-mem.h | 5 ++++- drivers/staging/octeon/ethernet.c | 6 +++--- 3 files changed, 25 insertions(+), 17 deletions(-)
drivers/staging/octeon/ethernet-mem.c +18 -13
@@ -5,6 +5,7 @@* Copyright (c) 2003-2010 Cavium Networks */ +#include <linux/platform_device.h> #include <linux/kernel.h> #include <linux/netdevice.h> #include <linux/slab.h>
@@ -40,11 +41,13 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements)/** * cvm_oct_free_hw_skbuff- free hardware pool skbuffs +* @pdev: Platform device for logging * @pool: Pool to allocate an skbuff for * @size: Size of the buffer needed for the pool * @elements: Number of buffers to allocate */ -static void cvm_oct_free_hw_skbuff (int pool,int size,int elements) +static void cvm_oct_free_hw_skbuff (struct platform_device *pdev, +int pool,int size,int elements) {char *memory;
@@ -59,11 +62,11 @@ static void cvm_oct_free_hw_skbuff(int pool, int size, int elements) }while (memory);if (elements <0 ) -pr_warn ("Freeing of pool %u had too many skbuffs (%d)\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u had too many skbuffs (%d)\n" , + pool, elements);else if (elements >0 ) -pr_warn ("Freeing of pool %u is missing %d skbuffs\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u is missing %d skbuffs\n" , + pool, elements); }/**
@@ -107,11 +110,13 @@ static int cvm_oct_fill_hw_memory(int pool, int size, int elements)/** * cvm_oct_free_hw_memory - Free memory allocated by cvm_oct_fill_hw_memory +* @pdev: Platform device for logging * @pool: FPA pool to free * @size: Size of each buffer in the pool * @elements: Number of buffers that should be in the pool */ -static void cvm_oct_free_hw_memory (int pool,int size,int elements) +static void cvm_oct_free_hw_memory (struct platform_device *pdev, +int pool,int size,int elements) {char *memory;char *fpa;
@@ -127,11 +132,11 @@ static void cvm_oct_free_hw_memory(int pool, int size, int elements) }while (fpa);if (elements <0 ) -pr_warn ("Freeing of pool %u had too many buffers (%d)\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u had too many buffers (%d)\n" , + pool, elements);else if (elements >0 ) -pr_warn ("Warning: Freeing of pool %u is missing %d buffers\n" , - pool, elements); +dev_warn (&pdev->dev,"Freeing of pool %u is missing %d buffers\n" , + pool, elements); }int cvm_oct_mem_fill_fpa (int pool,int size,int elements)
@@ -145,10 +150,10 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements)return freed; } -void cvm_oct_mem_empty_fpa (int pool,int size,int elements) +void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size,int elements) {if (pool ==CVMX_FPA_PACKET_POOL ) -cvm_oct_free_hw_skbuff (pool, size, elements); +cvm_oct_free_hw_skbuff (pdev, pool, size, elements);else -cvm_oct_free_hw_memory (pool, size, elements); +cvm_oct_free_hw_memory (pdev, pool, size, elements); }
drivers/staging/octeon/ethernet-mem.h +4 -1
@@ -6,4 +6,7 @@*/ int cvm_oct_mem_fill_fpa (int pool,int size,int elements); -void cvm_oct_mem_empty_fpa (int pool,int size,int elements); +struct platform_device ; + +void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size, +int elements);
drivers/staging/octeon/ethernet.c +3 -3
@@ -958,12 +958,12 @@ static void cvm_oct_remove(struct platform_device *pdev)cvmx_ipd_free_ptr ();/* Free the HW pools */ -cvm_oct_mem_empty_fpa (CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , num_packet_buffers); -cvm_oct_mem_empty_fpa (CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , num_packet_buffers);if (CVMX_FPA_OUTPUT_BUFFER_POOL !=CVMX_FPA_PACKET_POOL ) -cvm_oct_mem_empty_fpa (CVMX_FPA_OUTPUT_BUFFER_POOL , +cvm_oct_mem_empty_fpa (pdev,CVMX_FPA_OUTPUT_BUFFER_POOL ,CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE ,128 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 233/1518 staging: octeon: replace pr_warn with dev_warn in fill and rx paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayush Mukkanwar <[email protected]>
[ Upstream commit 2191a8dfd1f5a3091e9f388899beb137686c6532 ]
Add struct platform_device parameter to cvm_oct_fill_hw_memory, cvm_oct_mem_fill_fpa, cvm_oct_rx_refill_pool and cvm_oct_rx_initialize to support device-aware logging. Replace pr_warn with dev_warn using &pdev->dev.
To avoid passing these parameters through global state, introduce struct octeon_ethernet_platform to hold per-device state including the rx_refill_work and the oct_rx_group array. This ensures all receive group state and workers are correctly associated with the platform device.
Define struct oct_rx_group and struct octeon_ethernet_platform in octeon-ethernet.h so they are shared across compilation units.
Stable-dep-of: c0a9a8586a63 ("staging: octeon: add missing napi_disable in cvm_oct_rx_shutdown")
--- drivers/staging/octeon/ethernet-mem.c | 12 +++--- drivers/staging/octeon/ethernet-mem.h | 3 +- drivers/staging/octeon/ethernet-rx.c | 49 ++++++++++++------------ drivers/staging/octeon/ethernet-rx.h | 11 ++++-- drivers/staging/octeon/ethernet.c | 37 +++++++++++------- drivers/staging/octeon/octeon-ethernet.h | 14 +++++++ 6 files changed, 78 insertions(+), 48 deletions(-)
drivers/staging/octeon/ethernet-mem.c +7 -5
@@ -71,13 +71,15 @@ static void cvm_oct_free_hw_skbuff(struct platform_device *pdev,/** * cvm_oct_fill_hw_memory - fill a hardware pool with memory. +* @pdev: Platform device for logging * @pool: Pool to populate * @size: Size of each buffer in the pool * @elements: Number of buffers to allocate * * Returns the actual number of buffers allocated. */ -static int cvm_oct_fill_hw_memory (int pool,int size,int elements) +static int cvm_oct_fill_hw_memory (struct platform_device *pdev,int pool,int size, +int elements) {char *memory;char *fpa;
@@ -96,8 +98,8 @@ static int cvm_oct_fill_hw_memory(int pool, int size, int elements)*/ memory =kmalloc (size +256 ,GFP_ATOMIC );if (unlikely (!memory)) { -pr_warn ("Unable to allocate %u bytes for FPA pool %d\n" , - elements * size, pool); +dev_warn (&pdev->dev,"Unable to allocate %u bytes for FPA pool %d\n" , + elements * size, pool);break ; } fpa = (char *)(((unsigned long )memory +256 ) & ~0x7fUL );
@@ -139,14 +141,14 @@ static void cvm_oct_free_hw_memory(struct platform_device *pdev, pool, elements); } -int cvm_oct_mem_fill_fpa (int pool,int size,int elements) +int cvm_oct_mem_fill_fpa (struct platform_device *pdev,int pool,int size,int elements) {int freed;if (pool ==CVMX_FPA_PACKET_POOL ) freed =cvm_oct_fill_hw_skbuff (pool, size, elements);else - freed =cvm_oct_fill_hw_memory (pool, size, elements); + freed =cvm_oct_fill_hw_memory (pdev, pool, size, elements);return freed; }
drivers/staging/octeon/ethernet-mem.h +2 -1
@@ -5,8 +5,9 @@* Copyright (c) 2003-2007 Cavium Networks */ -int cvm_oct_mem_fill_fpa (int pool,int size,int elements);struct platform_device ; +int cvm_oct_mem_fill_fpa (struct platform_device *pdev,int pool,int size, +int elements);void cvm_oct_mem_empty_fpa (struct platform_device *pdev,int pool,int size,int elements);
drivers/staging/octeon/ethernet-rx.c +25 -24
125 lines not on this page · raw message
drivers/staging/octeon/ethernet-rx.h +7 -4
@@ -5,11 +5,14 @@* Copyright (c) 2003-2007 Cavium Networks */ +struct platform_device ; +void cvm_oct_poll_controller (struct net_device *dev); -void cvm_oct_rx_initialize (void ); -void cvm_oct_rx_shutdown (void ); +void cvm_oct_rx_initialize (struct platform_device *pdev); +void cvm_oct_rx_shutdown (struct platform_device *pdev); -static inline void cvm_oct_rx_refill_pool (int fill_threshold) +static inline void cvm_oct_rx_refill_pool (struct platform_device *pdev, +int fill_threshold) {int number_to_free;int num_freed;
@@ -20,7 +23,7 @@ static inline void cvm_oct_rx_refill_pool(int fill_threshold)if (number_to_free > fill_threshold) {cvmx_fau_atomic_add32 (FAU_NUM_PACKET_BUFFERS_TO_FREE , -number_to_free); - num_freed =cvm_oct_mem_fill_fpa (CVMX_FPA_PACKET_POOL , + num_freed =cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , number_to_free);if (num_freed != number_to_free) {
drivers/staging/octeon/ethernet.c +23 -14
@@ -104,11 +104,10 @@ struct net_device *cvm_oct_device[TOTAL_NUMBER_OF_PORTS];u64 cvm_oct_tx_poll_interval; -static void cvm_oct_rx_refill_worker (struct work_struct *work); -static DECLARE_DELAYED_WORK(cvm_oct_rx_refill_work, cvm_oct_rx_refill_worker); -static void cvm_oct_rx_refill_worker (struct work_struct *work) { +struct octeon_ethernet_platform *plat =container_of (work, + struct octeon_ethernet_platform, rx_refill_work.work);/* * FPA 0 may have been drained, try to refill it if we need * more than num_packet_buffers / 2, otherwise normal receive
@@ -116,10 +115,10 @@ static void cvm_oct_rx_refill_worker(struct work_struct *work)* could be received so cvm_oct_napi_poll would never be * invoked to do the refill. */ -cvm_oct_rx_refill_pool (num_packet_buffers /2 ); +cvm_oct_rx_refill_pool (plat->pdev, num_packet_buffers /2 );if (!atomic_read (&cvm_oct_poll_queue_stopping)) -schedule_delayed_work (&cvm_oct_rx_refill_work,HZ ); +schedule_delayed_work (&plat->rx_refill_work,HZ ); }static void cvm_oct_periodic_worker (struct work_struct *work)
@@ -138,16 +137,16 @@ static void cvm_oct_periodic_worker(struct work_struct *work)schedule_delayed_work (&priv->port_periodic_work,HZ ); } -static void cvm_oct_configure_common_hw (void ) +static void cvm_oct_configure_common_hw (struct platform_device *pdev) {/* Setup the FPA */ cvmx_fpa_enable (); -cvm_oct_mem_fill_fpa (CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_PACKET_POOL ,CVMX_FPA_PACKET_POOL_SIZE , num_packet_buffers); -cvm_oct_mem_fill_fpa (CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_WQE_POOL ,CVMX_FPA_WQE_POOL_SIZE , num_packet_buffers);if (CVMX_FPA_OUTPUT_BUFFER_POOL !=CVMX_FPA_PACKET_POOL ) -cvm_oct_mem_fill_fpa (CVMX_FPA_OUTPUT_BUFFER_POOL , +cvm_oct_mem_fill_fpa (pdev,CVMX_FPA_OUTPUT_BUFFER_POOL ,CVMX_FPA_OUTPUT_BUFFER_POOL_SIZE ,1024 );#ifdef __LITTLE_ENDIAN
@@ -678,6 +677,15 @@ static int cvm_oct_probe(struct platform_device *pdev)int qos;struct device_node *pip;int mtu_overhead =ETH_HLEN +ETH_FCS_LEN ; +struct octeon_ethernet_platform *plat; + + plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL ); +if (!plat) +return -ENOMEM ; + + plat->pdev = pdev; +INIT_DELAYED_WORK (&plat->rx_refill_work, cvm_oct_rx_refill_worker); +platform_set_drvdata (pdev, plat);#if IS_ENABLED (CONFIG_VLAN_8021Q ) mtu_overhead +=VLAN_HLEN ;
@@ -689,7 +697,7 @@ static int cvm_oct_probe(struct platform_device *pdev)return -EINVAL ; } -cvm_oct_configure_common_hw (); +cvm_oct_configure_common_hw (pdev);cvmx_helper_initialize_packet_io_global ();
@@ -912,28 +920,29 @@ static int cvm_oct_probe(struct platform_device *pdev) }cvm_oct_tx_initialize (); -cvm_oct_rx_initialize (); +cvm_oct_rx_initialize (pdev);/* * 150 uS: about 10 1500-byte packets at 1GE. */ cvm_oct_tx_poll_interval =150 * (octeon_get_clock_rate () /1000000 ); -schedule_delayed_work (&cvm_oct_rx_refill_work,HZ ); +schedule_delayed_work (&plat->rx_refill_work,HZ );return 0 ; }static void cvm_oct_remove (struct platform_device *pdev) { +struct octeon_ethernet_platform *plat =platform_get_drvdata (pdev);int port;cvmx_ipd_disable ();atomic_inc_return (&cvm_oct_poll_queue_stopping); -cancel_delayed_work_sync (&cvm_oct_rx_refill_work); +cancel_delayed_work_sync (&plat->rx_refill_work); -cvm_oct_rx_shutdown (); +cvm_oct_rx_shutdown (pdev);cvm_oct_tx_shutdown ();cvmx_pko_disable ();
drivers/staging/octeon/octeon-ethernet.h +14 -0
@@ -11,6 +11,7 @@#ifndef OCTEON_ETHERNET_H #define OCTEON_ETHERNET_H +#include <linux/netdevice.h> #include <linux/of.h> #include <linux/phy.h>
@@ -74,6 +75,19 @@ struct octeon_ethernet {struct device_node *of_node; }; +struct oct_rx_group { +int irq; +int group; +struct napi_struct napi; +struct platform_device *pdev; +}; + +struct octeon_ethernet_platform { +struct platform_device *pdev; +struct delayed_work rx_refill_work; +struct oct_rx_group rx_group[16 ]; +}; +int cvm_oct_free_work (void *work_queue_entry);int cvm_oct_rgmii_open (struct net_device *dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 234/1518 staging: octeon: add missing napi_disable in cvm_oct_rx_shutdown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ayush Mukkanwar <[email protected]>
[ Upstream commit c0a9a8586a63fda49e61a6b83360feac2a60d898 ]
cvm_oct_rx_shutdown calls free_irq and netif_napi_del without disabling the napi instance first. As the free_irq only waits for completion of hard interrupt handlers, the napi poll function could still be active. If cvm_oct_remove proceeds to free the plat structure (which holds the NAPI instances), the active poll function will access freed memory, resulting in a use-after-free crash.
--- drivers/staging/octeon/ethernet-rx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/staging/octeon/ethernet-rx.c +2 -0
@@ -535,6 +535,8 @@ void cvm_oct_rx_shutdown(struct platform_device *pdev)else cvmx_write_csr (CVMX_POW_WQ_INT_THRX (i),0 ); +napi_disable (&plat->rx_group[i].napi); +/* Free the interrupt handler */ free_irq (plat->rx_group[i].irq, &plat->rx_group[i].napi);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 235/1518 staging: rtl8723bs: fix mismatched free of HalData in rtw_sdio_if1_init()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dawei Feng <[email protected]>
[ Upstream commit 264676418b726baca7be49171e306b6aa05cceb0 ]
padapter->HalData is allocated via vzalloc(), but incorrectly freed using kfree() in the rtw_sdio_if1_init() error path. Using kfree() to release this vmalloc-backed buffer can lead to memory corruption.
Use rtw_hal_data_deinit() to pair the free correctly and free HalData with vfree().
The bug was first flagged by an experimental static analysis tool we are developing for kernel memory-management bugs. Manual inspection confirms that the issue is still present in current mainline.
An x86_64 allyesconfig build showed no new warnings. As we do not have suitable RTL8723BS SDIO hardware to test with, no runtime testing was able to be performed.
--- drivers/staging/rtl8723bs/os_dep/sdio_intf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/os_dep/sdio_intf.c +2 -2
@@ -307,8 +307,8 @@ static struct adapter *rtw_sdio_if1_init(struct dvobj_priv *dvobj, const struct status = _SUCCESS; free_hal_data: -if (status != _SUCCESS && padapter->HalData) -kfree (padapter->HalData); +if (status != _SUCCESS) +rtw_hal_data_deinit (padapter);if (status != _SUCCESS) {rtw_wdev_unregister (padapter->rtw_wdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 236/1518 ALSA: via82xx: Remove unreachable branch in snd_via686_pcm_pointer()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Evgenii Burenchev <[email protected]>
[ Upstream commit cd3447e1b6425efd1704ed07f1f245c842927eb0 ]
The condition
if (count && size < count)
can never evaluate to true.
The VIA DMA count register is masked with 0x00ffffff before use, while the DMA buffer size is limited to 0x00fffffe bytes. As a result, 'count' can never exceed 'size', making the condition permanently false.
This branch has therefore been unreachable since the driver was introduced. Remove the unreachable branch without changing runtime behavior.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- sound/pci/via82xx_modem.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-)
sound/pci/via82xx_modem.c +10 -16
@@ -575,24 +575,18 @@ static inline unsigned int calc_linear_pos(struct via82xx_modem *chip, viadev->bufsize2, viadev->idx_table[idx].offset, viadev->idx_table[idx].size, count);#endif -if (count && size < count) { +if (! count) +/* bogus count 0 on the DMA boundary? */ + res = viadev->idx_table[idx].offset; +else +/* count register returns full size +* when end of buffer is reached +*/ + res = viadev->idx_table[idx].offset + size; +if (check_invalid_pos (viadev, res)) {dev_dbg (chip->card->dev, -"invalid via82xx_cur_ptr, using last valid pointer\n" ); +"invalid via82xx_cur_ptr (2), using last valid pointer\n" ); res = viadev->lastpos; - }else { -if (! count) -/* bogus count 0 on the DMA boundary? */ - res = viadev->idx_table[idx].offset; -else -/* count register returns full size -* when end of buffer is reached -*/ - res = viadev->idx_table[idx].offset + size; -if (check_invalid_pos (viadev, res)) { -dev_dbg (chip->card->dev, -"invalid via82xx_cur_ptr (2), using last valid pointer\n" ); - res = viadev->lastpos; - } } } viadev->lastpos = res;/* remember the last position */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 237/1518 selftests/bpf: Fix memory leak in msg_alloc_iov error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Malaya Kumar Rout <[email protected]>
[ Upstream commit 0bebfaa39deadec21638f6fba553eae12627a26d ]
In msg_alloc_iov(), when calloc() fails for an individual iov_base allocation, the error path frees all previously allocated iov_base entries but fails to free the iov array itself that was allocated with calloc() at the beginning of the function. This results in a memory leak of the iov array.
Add free(iov) in the unwind_iov error path to ensure proper cleanup of all allocated memory.
--- tools/testing/selftests/bpf/test_sockmap.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/test_sockmap.c +1 -0
@@ -515,6 +515,7 @@ static int msg_alloc_iov(struct msghdr *msg, unwind_iov:for (i--; i >=0 ; i--)free (msg->msg_iov[i].iov_base); +free (iov);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 238/1518 selftests/bpf: Fix memory leak in msg_alloc_iov
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Feng Yang <[email protected]>
[ Upstream commit 602701718649936eb287bf6c7ecf870ec54c6f71 ]
In the msg_alloc_iov function, the iov pointer is only assigned to msg->msg_iov after all memory allocations complete successfully. Therefore, when a calloc failure triggers the unwind_iov cleanup branch, we should use the local variable iov instead of msg->msg_iov.
--- tools/testing/selftests/bpf/test_sockmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/test_sockmap.c +1 -1
@@ -514,7 +514,7 @@ static int msg_alloc_iov(struct msghdr *msg,return 0 ; unwind_iov:for (i--; i >=0 ; i--) -free (msg->msg_iov[i].iov_base); +free (iov[i].iov_base);free (iov);return -ENOMEM ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 239/1518 selftests/lsm: Fix memory leak in attr_lsm_count
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Yan <[email protected]>
[ Upstream commit 0cee720cfd51402cfcb14d96cb326a36c13b823a ]
The calloc-allocated buffer in attr_lsm_count() is never released on any exit path, including both the normal return path and the early return when read_sysfs_lsms fails, resulting in a heap memory leak.
Add free() for the buffer on all return branches to fix the leak.
--- tools/testing/selftests/lsm/common.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/lsm/common.c +3 -1
@@ -76,7 +76,7 @@ int attr_lsm_count(void)return 0 ;if (read_sysfs_lsms (names,sysconf (_SC_PAGESIZE))) -return 0 ; + goto out;if (strstr (names,"selinux" )) count++;
@@ -85,5 +85,7 @@ int attr_lsm_count(void)if (strstr (names,"apparmor" )) count++; +out: +free (names);return count; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 240/1518 irqchip/gic-v3-its: Fix memleak in its_probe_one()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 1efffab6fe336a5c4fd3c2886f255cd2f998e65f ]
Fix collection leak when its_init_domain() failed in its_probe_one().
--- drivers/irqchip/irq-gic-v3-its.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +3 -1
@@ -5322,7 +5322,7 @@ static int __init its_probe_one(struct its_node *its) err =its_init_domain (its);if (err) - goto out_free_tables; + goto out_free_collection;raw_spin_lock (&its_lock);list_add (&its->entry, &its_nodes);
@@ -5330,6 +5330,8 @@ static int __init its_probe_one(struct its_node *its)return 0 ; +out_free_collection: +kfree (its->collections); out_free_tables:its_free_tables (its); out_free_cmd:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 241/1518 irqchip/gic-v3-its: Fix its node leak in gic_acpi_parse_madt_its()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kemeng Shi <[email protected]>
[ Upstream commit 698a8648ca8051d34722b09b8a8088c741120ac3 ]
Fix its node leak when its_probe_one() failed ingic_acpi_parse_madt_its().
--- drivers/irqchip/irq-gic-v3-its.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/irqchip/irq-gic-v3-its.c +6 -2
@@ -5744,9 +5744,13 @@ static int __init gic_acpi_parse_madt_its(union acpi_subtable_headers *header, its->flags |=ITS_FLAGS_FORCE_NON_SHAREABLE ; err =its_probe_one (its); -if (!err) -return 0 ; +if (err) + goto probe_err; + +return 0 ; +probe_err: +its_node_destroy (its); node_err:iort_deregister_domain_token (its_entry->translation_id); dom_err:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 242/1518 selftests: timers: leap-a-day: Fix -w option and update usage comment
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiangshan Yi <[email protected]>
[ Upstream commit b4b66151a71445f3a71574136ddc82968c7b175e ]
Commit 98b74e1f3104 ("kselftests: timers: leap-a-day: Change default arguments to help test runs") replaced the -s option with -w and made "wait for the leap second" the non-default behaviour, but it only updated the switch/case handling. Two things were left inconsistent:
- The getopt() option string still lists 's' instead of 'w', so passing -w is rejected as an invalid option and the new behaviour cannot be selected at all.
- The file header comment still documents the removed -s option and an outdated default for -i.
Fix the getopt() string to accept 'w' (matching the existing case 'w':
handler) and update the header comment to describe -w, -t and the current -i default.
--- tools/testing/selftests/timers/leap-a-day.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
tools/testing/selftests/timers/leap-a-day.c +11 -8
@@ -9,16 +9,19 @@* kernel's leap-second behavior, as well as how well applications * handle the leap-second discontinuity. * -* Usage: leap-a-day [-s] [-i <num>] +* Usage: leap-a-day [-w] [-i <num>] [-t] * * Options: -* -s: Each iteration, set the date to 10 seconds before midnight GMT. -* This speeds up the number of leapsecond transitions tested, -* but because it calls settimeofday frequently, advancing the -* time by 24 hours every ~16 seconds, it may cause application -* disruption. +* -w: Only set the leap-second flag and wait for the leap second +* each iteration, instead of advancing the time. By default the +* date is set to 10 seconds before midnight GMT, which speeds up +* the number of leapsecond transitions tested, but because it +* calls settimeofday frequently, advancing the time by 24 hours +* every ~16 seconds, it may cause application disruption. * -* -i: Number of iterations to run (default: infinite) +* -i: Number of iterations to run (-1 = infinite, default: 10) +* +* -t: Print TAI time. * * Other notes: Disabling NTP prior to running this is advised, as the two * may conflict in their commands to the kernel.
@@ -186,7 +189,7 @@ int main(int argc, char **argv)int opt;/* Process arguments */ -while ((opt =getopt (argc, argv,"sti:" )) !=-1 ) { +while ((opt =getopt (argc, argv,"wti:" )) !=-1 ) {switch (opt) {case 'w' :printf ("Only setting leap-flag, not changing time. It could take up to a day for leap to trigger.\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 243/1518 clocksource: Unregister subsystem on device registration failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 3dee6537e728bd8137fda6eaf859f26e685943f7 ]
init_clocksource_sysfs() registers the clocksource subsystem before registering the clocksource device. If device_register() fails, the function returns the error while leaving the subsystem registered.
Unregister the clocksource subsystem on that failure path so the successful subsystem registration is unwound before returning.
--- kernel/time/clocksource.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/time/clocksource.c +6 -2
@@ -1482,8 +1482,12 @@ static int __init init_clocksource_sysfs(void) {int error =subsys_system_register (&clocksource_subsys,NULL ); -if (!error) - error =device_register (&device_clocksource); +if (error) +return error; + + error =device_register (&device_clocksource); +if (error) +bus_unregister (&clocksource_subsys);return error; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/1518 timekeeping: Unwind aux clock sysfs children on failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit f2eee7e31ccd4bc87d047d8670cc2ec39cf36647 ]
tk_aux_sysfs_init() creates one child kobject per auxiliary clock. If a later child or sysfs group creation fails, the current error path only puts the parent kobjects and leaves earlier children and groups behind.
Store the child kobjects during init and remove the successfully created groups and kobjects on failure.
--- kernel/time/timekeeping.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
kernel/time/timekeeping.c +15 -6
@@ -3065,7 +3065,9 @@ static const struct attribute_group aux_clock_enable_attr_group = {static int __init tk_aux_sysfs_init (void ) {struct kobject *auxo, *tko =kobject_create_and_add ("time" , kernel_kobj); +struct kobject *clks[MAX_AUX_CLOCKS ];int ret = -ENOMEM ; +int i;if (!tko)return ret;
@@ -3074,21 +3076,28 @@ static int __init tk_aux_sysfs_init(void)if (!auxo) goto err_clean; -for (int i =0 ; i <MAX_AUX_CLOCKS ; i++) { +for (i =0 ; i <MAX_AUX_CLOCKS ; i++) {char id[2 ] = { [0 ] ='0' + i, }; -struct kobject *clk =kobject_create_and_add (id, auxo); + clks[i] =kobject_create_and_add (id, auxo); -if (!clk) { +if (!clks[i]) { ret = -ENOMEM ; - goto err_clean; + goto err_clks; } - ret =sysfs_create_group (clk, &aux_clock_enable_attr_group); + ret =sysfs_create_group (clks[i], &aux_clock_enable_attr_group);if (ret) - goto err_clean; + goto err_clk; }return 0 ; +err_clk: +kobject_put (clks[i]); +err_clks: +while (--i >=0 ) { +sysfs_remove_group (clks[i], &aux_clock_enable_attr_group); +kobject_put (clks[i]); + } err_clean:kobject_put (auxo);kobject_put (tko);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 245/1518 timers/migration: Fix memory leak in tmigr_setup_groups() error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Malaya Kumar Rout <[email protected]>
[ Upstream commit eddfded4196542deda7cb2da3d7ebef83f7ccfa4 ]
When the WARN_ON_ONCE(i >= tmigr_hierarchy_levels) assertion triggers, the function returns -EINVAL without freeing the 'stack' memory allocated via kzalloc_objs() at the beginning of the function.
Add kfree(stack) before returning to prevent the memory leak.
--- kernel/time/timer_migration.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/time/timer_migration.c +3 -1
@@ -1667,8 +1667,10 @@ static int tmigr_setup_groups(unsigned int cpu, unsigned int node, }/* Assert single root without parent */ -if (WARN_ON_ONCE (i >= tmigr_hierarchy_levels)) +if (WARN_ON_ONCE (i >= tmigr_hierarchy_levels)) { +kfree (stack);return -EINVAL ; + }for (; i >= start_lvl; i--) { group = stack[i];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 246/1518 x86/tsx: Make tsx_ctrl_state static
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Petr Tesarik <[email protected]>
[ Upstream commit f018fca8f90bc383fefd97e3b2db03ea612ac789 ]
Move all definitions related to tsx_ctrl_state to tsx.c. They are never referenced outside this file.
No functional change.
Stable-dep-of: 06aba58e5849 ("time/namespace: Validate nanosecond field in proc_timens_set_offset()")
--- arch/x86/kernel/cpu/cpu.h | 9 --------- arch/x86/kernel/cpu/tsx.c | 9 ++++++++- 2 files changed, 8 insertions(+), 10 deletions(-)
arch/x86/kernel/cpu/cpu.h +0 -9
@@ -42,15 +42,6 @@ extern const struct cpu_dev *const __x86_cpu_dev_start[], *const __x86_cpu_dev_end[];#ifdef CONFIG_CPU_SUP_INTEL -enum tsx_ctrl_states { -TSX_CTRL_ENABLE , -TSX_CTRL_DISABLE , -TSX_CTRL_RTM_ALWAYS_ABORT , -TSX_CTRL_NOT_SUPPORTED , -}; - -extern __ro_after_init enum tsx_ctrl_states tsx_ctrl_state; -extern void __init tsx_init (void );void tsx_ap_init (void );void intel_unlock_cpuid_leafs (struct cpuinfo_x86 *c);
arch/x86/kernel/cpu/tsx.c +8 -1
@@ -19,7 +19,14 @@#undef pr_fmt#define pr_fmt (fmt) "tsx: " fmt -enum tsx_ctrl_states tsx_ctrl_state__ro_after_init =TSX_CTRL_NOT_SUPPORTED ; +enum tsx_ctrl_states { +TSX_CTRL_ENABLE , +TSX_CTRL_DISABLE , +TSX_CTRL_RTM_ALWAYS_ABORT , +TSX_CTRL_NOT_SUPPORTED , +}; + +static enum tsx_ctrl_states tsx_ctrl_state__ro_after_init =TSX_CTRL_NOT_SUPPORTED ;static void tsx_disable (void ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 247/1518 vdso/timens: Move functions to new file
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 5dc9cf835aba73c882348aa4f99be83b6e45ad9b ]
As a preparation of the untangling of time namespaces and the vDSO, move the glue functions between those subsystems into a new file.
While at it, switch the mutex lock and mmap_read_lock() in the vDSO namespace code to guard().
Stable-dep-of: 06aba58e5849 ("time/namespace: Validate nanosecond field in proc_timens_set_offset()")
--- MAINTAINERS | 2 + include/linux/time_namespace.h | 8 -- kernel/time/Makefile | 2 +- kernel/time/namespace.c | 124 +------------------------- kernel/time/namespace_internal.h | 13 +++ kernel/time/namespace_vdso.c | 146 +++++++++++++++++++++++++++++++ lib/vdso/datastore.c | 25 ------ 7 files changed, 166 insertions(+), 154 deletions(-) create mode 100644 kernel/time/namespace_internal.h create mode 100644 kernel/time/namespace_vdso.c
MAINTAINERS +2 -0
@@ -10533,6 +10533,7 @@ S: Maintained T: git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git timers/vdso F: include/asm-generic/vdso/vsyscall.h F: include/vdso/ +F: kernel/time/namespace_vdso.c F: kernel/time/vsyscall.c F: lib/vdso/ F: tools/testing/selftests/vDSO/
@@ -20502,6 +20503,7 @@ F: include/trace/events/timer* F: kernel/time/itimer.c F: kernel/time/posix-* F: kernel/time/namespace.c +F: kernel/time/namespace_vdso.c POWER MANAGEMENT CORE M: "Rafael J. Wysocki" <[email protected]>
include/linux/time_namespace.h +0 -8
@@ -38,8 +38,6 @@ static inline struct time_namespace *to_time_ns(struct ns_common *ns) return container_of(ns, struct time_namespace, ns); }void __init time_ns_init (void ); -extern int vdso_join_timens (struct task_struct *task, -struct time_namespace *ns);extern void timens_commit (struct task_struct *tsk,struct time_namespace *ns);static inline struct time_namespace *get_time_ns (struct time_namespace *ns)
@@ -117,12 +115,6 @@ static inline void __init time_ns_init(void) { } -static inline int vdso_join_timens (struct task_struct *task, -struct time_namespace *ns) -{ -return 0 ; -} -static inline void timens_commit (struct task_struct *tsk,struct time_namespace *ns) {
kernel/time/Makefile +1 -1
@@ -29,6 +29,6 @@ endif obj-$(CONFIG_GENERIC_GETTIMEOFDAY) += vsyscall.o obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o -obj-$(CONFIG_TIME_NS) += namespace.o +obj-$(CONFIG_TIME_NS) += namespace.o namespace_vdso.o obj-$(CONFIG_TEST_CLOCKSOURCE_WATCHDOG) += clocksource-wdtest.o obj-$(CONFIG_TIME_KUNIT_TEST) += time_test.o
kernel/time/namespace.c +4 -120
154 lines not on this page · raw message
kernel/time/namespace_internal.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TIME_NAMESPACE_INTERNAL_H +#define _TIME_NAMESPACE_INTERNAL_H + +#include <linux/mutex.h> + +/* +* Protects possibly multiple offsets writers racing each other +* and tasks entering the namespace. +*/ +extern struct mutex timens_offset_lock; + +#endif /* _TIME_NAMESPACE_INTERNAL_H */
kernel/time/namespace_vdso.c new file +146 -0
146 lines not on this page · raw message
lib/vdso/datastore.c +0 -25
@@ -103,28 +103,3 @@ struct vm_area_struct *vdso_install_vvar_mapping(struct mm_struct *mm, unsignedVM_PFNMAP |VM_SEALED_SYSMAP , &vdso_vvar_mapping); } - -#ifdef CONFIG_TIME_NS -/* -* The vvar page layout depends on whether a task belongs to the root or -* non-root time namespace. Whenever a task changes its namespace, the VVAR -* page tables are cleared and then they will be re-faulted with a -* corresponding layout. -* See also the comment near timens_setup_vdso_clock_data() for details. -*/ -int vdso_join_timens (struct task_struct *task,struct time_namespace *ns) -{ -struct mm_struct *mm = task->mm; -struct vm_area_struct *vma; -VMA_ITERATOR (vmi, mm,0 ); - -mmap_read_lock (mm); -for_each_vma (vmi, vma) { -if (vma_is_special_mapping (vma, &vdso_vvar_mapping)) -zap_vma_pages (vma); - } -mmap_read_unlock (mm); - -return 0 ; -} -#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 248/1518 timens: Remove dependency on the vDSO
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 1b6c89285d37114d7efe8ab04102a542581cd7da ]
Previously, missing time namespace support in the vDSO meant that time namespaces needed to be disabled globally. This was expressed in a hard dependency on the generic vDSO library. This also meant that architectures without any vDSO or only a stub vDSO could not enable time namespaces. Now that all architectures using a real vDSO are using the generic library, that dependency is not necessary anymore.
Remove the dependency and let all architectures enable time namespaces.
Stable-dep-of: 06aba58e5849 ("time/namespace: Validate nanosecond field in proc_timens_set_offset()")
--- include/linux/time_namespace.h | 28 ++++++++++++++++------------ init/Kconfig | 4 +++- kernel/time/Makefile | 3 ++- kernel/time/namespace.c | 8 ++++---- kernel/time/namespace_internal.h | 15 +++++++++++++++ kernel/time/namespace_vdso.c | 14 ++++++++++++++ 6 files changed, 54 insertions(+), 18 deletions(-)
include/linux/time_namespace.h +16 -12
@@ -25,7 +25,9 @@ struct time_namespace {struct ucounts *ucounts;struct ns_common ns;struct timens_offsets offsets; +#ifdef CONFIG_TIME_NS_VDSO struct page *vvar_page; +#endif /* If set prevents changing offsets after any task joined namespace. */ bool frozen_offsets; } __randomize_layout;
@@ -38,7 +40,6 @@ static inline struct time_namespace *to_time_ns(struct ns_common *ns) return container_of(ns, struct time_namespace, ns); }void __init time_ns_init (void ); -extern void timens_commit (struct task_struct *tsk,struct time_namespace *ns);static inline struct time_namespace *get_time_ns (struct time_namespace *ns) {
@@ -51,7 +52,6 @@ struct time_namespace *copy_time_ns(u64 flags, struct time_namespace *old_ns);void free_time_ns (struct time_namespace *ns);void timens_on_fork (struct nsproxy *nsproxy,struct task_struct *tsk); -struct page *find_timens_vvar_page (struct vm_area_struct *vma);static inline void put_time_ns (struct time_namespace *ns) {
@@ -115,11 +115,6 @@ static inline void __init time_ns_init(void) { } -static inline void timens_commit (struct task_struct *tsk, -struct time_namespace *ns) -{ -} -static inline struct time_namespace *get_time_ns (struct time_namespace *ns) {return NULL ;
@@ -146,11 +141,6 @@ static inline void timens_on_fork(struct nsproxy *nsproxy,return ; } -static inline struct page *find_timens_vvar_page (struct vm_area_struct *vma) -{ -return NULL ; -} -static inline void timens_add_monotonic (struct timespec64 *ts) { }static inline void timens_add_boottime (struct timespec64 *ts) { }
@@ -167,4 +157,18 @@ static inline ktime_t timens_ktime_to_host(clockid_t clockid, ktime_t tim) }#endif +#ifdef CONFIG_TIME_NS_VDSO +extern void timens_commit (struct task_struct *tsk,struct time_namespace *ns); +struct page *find_timens_vvar_page (struct vm_area_struct *vma); +#else /* !CONFIG_TIME_NS_VDSO */ +static inline void timens_commit (struct task_struct *tsk,struct time_namespace *ns) +{ +} + +static inline struct page *find_timens_vvar_page (struct vm_area_struct *vma) +{ +return NULL ; +} +#endif /* CONFIG_TIME_NS_VDSO */ +#endif /* _LINUX_TIMENS_H */
init/Kconfig +3 -1
@@ -1366,12 +1366,14 @@ config UTS_NS config TIME_NS bool "TIME namespace" - depends on GENERIC_GETTIMEOFDAY default y help In this namespace boottime and monotonic clocks can be set. The time will keep going with the same pace. +config TIME_NS_VDSO + def_bool TIME_NS && GENERIC_GETTIMEOFDAY + config IPC_NS bool "IPC namespace" depends on (SYSVIPC || POSIX_MQUEUE)
kernel/time/Makefile +2 -1
@@ -29,6 +29,7 @@ endif obj-$(CONFIG_GENERIC_GETTIMEOFDAY) += vsyscall.o obj-$(CONFIG_DEBUG_FS) += timekeeping_debug.o obj-$(CONFIG_TEST_UDELAY) += test_udelay.o -obj-$(CONFIG_TIME_NS) += namespace.o namespace_vdso.o +obj-$(CONFIG_TIME_NS) += namespace.o +obj-$(CONFIG_TIME_NS_VDSO) += namespace_vdso.o obj-$(CONFIG_TEST_CLOCKSOURCE_WATCHDOG) += clocksource-wdtest.o obj-$(CONFIG_TIME_KUNIT_TEST) += time_test.o
kernel/time/namespace.c +4 -4
@@ -93,8 +93,8 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,if (!ns) goto fail_dec; - ns->vvar_page =alloc_page (GFP_KERNEL_ACCOUNT | __GFP_ZERO); -if (!ns->vvar_page) + err =timens_vdso_alloc_vvar_page (ns); +if (err) goto fail_free; err =ns_common_init (ns);
@@ -109,7 +109,7 @@ static struct time_namespace *clone_time_ns(struct user_namespace *user_ns,return ns; fail_free_page: -__free_page (ns->vvar_page); +timens_vdso_free_vvar_page (ns); fail_free:kfree (ns); fail_dec:
@@ -146,7 +146,7 @@ void free_time_ns(struct time_namespace *ns)dec_time_namespaces (ns->ucounts);put_user_ns (ns->user_ns);ns_common_free (ns); -__free_page (ns->vvar_page); +timens_vdso_free_vvar_page (ns);/* Concurrent nstree traversal depends on a grace period. */ kfree_rcu (ns, ns.ns_rcu); }
kernel/time/namespace_internal.h +15 -0
@@ -4,10 +4,25 @@#include <linux/mutex.h> +struct time_namespace ; +/* * Protects possibly multiple offsets writers racing each other * and tasks entering the namespace. */ extern struct mutex timens_offset_lock; +#ifdef CONFIG_TIME_NS_VDSO +int timens_vdso_alloc_vvar_page (struct time_namespace *ns); +void timens_vdso_free_vvar_page (struct time_namespace *ns); +#else /* !CONFIG_TIME_NS_VDSO */ +static inline int timens_vdso_alloc_vvar_page (struct time_namespace *ns) +{ +return 0 ; +} +static inline void timens_vdso_free_vvar_page (struct time_namespace *ns) +{ +} +#endif /* CONFIG_TIME_NS_VDSO */ +#endif /* _TIME_NAMESPACE_INTERNAL_H */
kernel/time/namespace_vdso.c +14 -0
@@ -144,3 +144,17 @@ void timens_commit(struct task_struct *tsk, struct time_namespace *ns)timens_set_vvar_page (tsk, ns);vdso_join_timens (tsk, ns); } + +int timens_vdso_alloc_vvar_page (struct time_namespace *ns) +{ + ns->vvar_page =alloc_page (GFP_KERNEL_ACCOUNT | __GFP_ZERO); +if (!ns->vvar_page) +return -ENOMEM ; + +return 0 ; +} + +void timens_vdso_free_vvar_page (struct time_namespace *ns) +{ +__free_page (ns->vvar_page); +}
Signature · 1 line
2.53.0
Re: [PATCH 6.18 0248/1518] timens: Remove dependency on the vDSO
Hi Greg,
Quoted 1 line · Greg Kroah-Hartman
6.18-stable review patch. If anyone has any objections, please let me know.
I object.
This now lets SPARC enable time namespaces. But the SPARC vDSO can not handle those (yet, in v6.18). Userspace will read incorrect data from the vDSO inside a time namespace.
(...)
Quoted 1 line
Stable-dep-of:
06aba58e5849("time/namespace: Validate nanosecond field inproc_timens_set_offset()")
This does not look reasonable to me. The mentioned commit should be backportable as-is, without pulling in four additional patches.
If you want to keep this patch, at least drop the deletion of
"depends on GENERIC_GETTIMEOFDAY"
Thomas
(...)
Greg Kroah-Hartman
maintainerRe: [PATCH 6.18 0248/1518] timens: Remove dependency on the vDSO
Quoted 13 lines · Thomas Weißschuh
Hi Greg,
Quoted 1 line · Greg Kroah-Hartman
6.18-stable review patch. If anyone has any objections, please let me know.
I object.
This now lets SPARC enable time namespaces. But the SPARC vDSO can not handle those (yet, in v6.18). Userspace will read incorrect data from the vDSO inside a time namespace.
(...)
Quoted 8 lines
Quoted 1 line
Stable-dep-of:
06aba58e5849("time/namespace: Validate nanosecond field inproc_timens_set_offset()")This does not look reasonable to me. The mentioned commit should be backportable as-is, without pulling in four additional patches.
If you want to keep this patch, at least drop the deletion of
"depends on
GENERIC_GETTIMEOFDAY"
Now dropped, thanks for the review.
greg k-h
Greg Kroah-Hartman
maintainerPATCH 249/1518 timens: Add a __free() wrapper for put_time_ns()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit c2de5a5be4d60af5f928a2dd2b0f73e17358e346 ]
The wrapper will be used to simplify cleanups of 'struct time_namespace'.
Stable-dep-of: 06aba58e5849 ("time/namespace: Validate nanosecond field in proc_timens_set_offset()")
--- include/linux/time_namespace.h | 3 +++ 1 file changed, 3 insertions(+)
include/linux/time_namespace.h +3 -0
@@ -8,6 +8,7 @@#include <linux/ns_common.h> #include <linux/err.h> #include <linux/time64.h> +#include <linux/cleanup.h> struct user_namespace ;extern struct user_namespace init_user_ns;
@@ -171,4 +172,6 @@ static inline struct page *find_timens_vvar_page(struct vm_area_struct *vma) }#endif /* CONFIG_TIME_NS_VDSO */ +DEFINE_FREE(time_ns, struct time_namespace *, if (_T) put_time_ns(_T)) +#endif /* _LINUX_TIMENS_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 250/1518 timens: Simplify some calls to put_time_ns()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 3fa3aeb4a5cb19e372680ef8860a0381cd5409e9 ]
Use the new __free() based cleanup helpers to simplify some functions.
Stable-dep-of: 06aba58e5849 ("time/namespace: Validate nanosecond field in proc_timens_set_offset()")
--- kernel/time/namespace.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
kernel/time/namespace.c +11 -18
@@ -18,6 +18,7 @@#include <linux/cred.h> #include <linux/err.h> #include <linux/mm.h> +#include <linux/cleanup.h> #include "namespace_internal.h"
@@ -251,36 +252,33 @@ static void show_offset(struct seq_file *m, int clockid, struct timespec64 *ts)void proc_timens_show_offsets (struct task_struct *p,struct seq_file *m) { -struct ns_common *ns; -struct time_namespace *time_ns; + struct time_namespace *time_ns __free(time_ns) = NULL; +struct ns_common *ns =timens_for_children_get (p); - ns =timens_for_children_get (p);if (!ns)return ; + time_ns =to_time_ns (ns);show_offset (m,CLOCK_MONOTONIC , &time_ns->offsets.monotonic);show_offset (m,CLOCK_BOOTTIME , &time_ns->offsets.boottime); -put_time_ns (time_ns); }int proc_timens_set_offset (struct file *file,struct task_struct *p,struct proc_timens_offset *offsets,int noffsets) { -struct ns_common *ns; -struct time_namespace *time_ns; + struct time_namespace *time_ns __free(time_ns) = NULL; +struct ns_common *ns =timens_for_children_get (p);struct timespec64 tp;int i, err; - ns =timens_for_children_get (p);if (!ns)return -ESRCH ; + time_ns =to_time_ns (ns); -if (!file_ns_capable (file, time_ns->user_ns,CAP_SYS_TIME )) { -put_time_ns (time_ns); +if (!file_ns_capable (file, time_ns->user_ns,CAP_SYS_TIME ))return -EPERM ; - }for (i =0 ; i < noffsets; i++) {struct proc_timens_offset *off = &offsets[i];
@@ -293,15 +291,12 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,ktime_get_boottime_ts64 (&tp);break ;default : - err = -EINVAL ; - goto out; +return -EINVAL ; } - err = -ERANGE ; -if (off->val.tv_sec >KTIME_SEC_MAX || off->val.tv_sec < -KTIME_SEC_MAX ) - goto out; +return -ERANGE ; tp =timespec64_add (tp, off->val);/*
@@ -309,7 +304,7 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,* still unreachable. */ if (tp.tv_sec <0 || tp.tv_sec >KTIME_SEC_MAX /2 ) - goto out; +return -ERANGE ; }mutex_lock (&timens_offset_lock);
@@ -338,8 +333,6 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p, out_unlock:mutex_unlock (&timens_offset_lock); -out: -put_time_ns (time_ns);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 251/1518 time/namespace: Validate nanosecond field in proc_timens_set_offset()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Malaya Kumar Rout <[email protected]>
[ Upstream commit 06aba58e58492d2b8eae059274caed29025ea96e ]
The function validates tv_sec to be within [-KTIME_SEC_MAX, KTIME_SEC_MAX] but never validates that tv_nsec is within the valid range of [0, NSEC_PER_SEC-1] before using it in timespec64_add().
timespec64_add() expects both timespec64 structures to have normalized values with tv_nsec in the range [0, 999999999]. If off->val.tv_nsec contains invalid values (negative or >= NSEC_PER_SEC), it could lead to incorrect calculations or unexpected behavior.
Add validation to ensure tv_nsec is within the valid range before performing the addition.
--- kernel/time/namespace.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/time/namespace.c +4 -2
@@ -294,10 +294,12 @@ int proc_timens_set_offset(struct file *file, struct task_struct *p,return -EINVAL ; } -if (off->val.tv_sec >KTIME_SEC_MAX || - off->val.tv_sec < -KTIME_SEC_MAX ) +if (off->val.tv_sec >KTIME_SEC_MAX || off->val.tv_sec < -KTIME_SEC_MAX )return -ERANGE ; +if (off->val.tv_nsec <0 || off->val.tv_nsec >=NSEC_PER_SEC ) +return -EINVAL ; + tp =timespec64_add (tp, off->val);/* * KTIME_SEC_MAX is divided by 2 to be sure that KTIME_MAX is
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 252/1518 y2038: uapi: Use 64-bit __kernel_old_timespec::tv_nsec on x32
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 79ced850e549e8c86b772a79ea417a1425b5c04b ]
'struct __kernel_old_timespec' represents the 'native' time ABI of the kernel. On 32-bit systems it uses 32-bit fields and on 64-bit systems it uses 64-bit fields.
However the x86 x32 ABI uses the 64-bit time ABI natively. This is correctly handled for the 'tv_sec' fields, through the typedefs of '__kernel_old_time_t' -> '__kernel_long_t' -> 'long long'. The same treatment was missed for 'tv_nsec'.
In practice this might not make much of a difference as the value of 'tv_nsec' will always fit into 32 bits and the missing bits fall into the padding of the structure.
When introspecting the structure however, a difference can be observed.
Switch to 64-bit tv_nsec on x32. No other architectures or ABIs are affected.
While this could be interpreted as violating the POSIX requirement of 'timespec::tv_nsec' being 'long':
* __kernel_old_timespec is not actually the POSIX timespec type
* the requirement is gone in newer versions of POSIX
* this matches glibc
--- include/uapi/linux/time_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/time_types.h +1 -1
@@ -30,7 +30,7 @@ struct __kernel_old_timeval {struct __kernel_old_timespec {__kernel_old_time_t tv_sec;/* seconds */ -long tv_nsec;/* nanoseconds */ +__kernel_long_t tv_nsec;/* nanoseconds */ };struct __kernel_old_itimerval {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 253/1518 timekeeping: Account for monotonicity adjustment in ntp_error
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Woodhouse <[email protected]>
[ Upstream commit b7befd6d91207cf3f4cecd68fea0c212093906cf ]
timekeeping_apply_adjustment() modifies xtime_nsec to ensure monotonicity when mult changes:
xtime_nsec -= offset
This ensures that the time reported to userspace does not jump when the multiplier is adjusted from one tick to the next. However, the ntp_error accumulator which tracks the difference between intended and actual clock position was not being updated to reflect this additional discrepancy.
An earlier attempt at this compensation existed as:
ntp_error -= (interval - offset) << ntp_error_shift
but was removed in commit c2cda2a5bda9 ("timekeeping/ntp: Don't align NTP frequency adjustments to ticks") because it was a major source of NTP error. That's because (interval - offset) was wrong: the subtraction of "interval" prematurely accounted for the changed xtime_interval of the next tick, which would be correctly accounted in the next accumulation anyway — a double subtraction.
What is actually needed is just the "offset" part: ntp_error must be told that xtime_nsec moved by "offset" without a corresponding change in the intended position. For the normal ±1 mult dithering this is negligible (the adjustments cancel over time), but for larger mult changes — such as when an external reference clock sets a new frequency — the one-time uncompensated offset is significant.
Fix by adjusting ntp_error by the correct amount:
ntp_error += offset << ntp_error_shift
This keeps ntp_error consistent with the actual xtime_nsec position after the adjustment, and ensures the discrepancy is correctly smoothed away over time and the clock returns to where it should have been.
--- kernel/time/timekeeping.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/time/timekeeping.c +6 -0
@@ -2140,6 +2140,11 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk,* xtime_nsec_2 = xtime_nsec_1 - offset * Which simplifies to: * xtime_nsec -= offset +* +* When subtracting offset from xtime_nsec, the same amount +* (in appropriate units) has to be added to ntp_error, in +* order to correctly track the delta between the time +* reported in xtime_nsec, and the intended time. */ if ((mult_adj >0 ) && (tk->tkr_mono.mult + mult_adj < mult_adj)) {/* NTP adjustment caused clocksource mult overflow */
@@ -2150,6 +2155,7 @@ static __always_inline void timekeeping_apply_adjustment(struct timekeeper *tk, tk->tkr_mono.mult += mult_adj; tk->xtime_interval += interval; tk->tkr_mono.xtime_nsec -= offset; + tk->ntp_error += offset << tk->ntp_error_shift; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 254/1518 arm64: dts: qcom: Add #{address,size}-cells to Chromium-based /firmware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
[ Upstream commit 2a906f0b4f037b3fe5f790a48f88549a86288fdf ]
Chromium/Depthcharge bootloaders may dynamically add a few device nodes to a system's DTB under a /firmware node. A typical DT looks something like the following:
/ {
firmware {
ranges;
coreboot {
compatible = "coreboot";
reg = <...>;
...;
};
};
};Notably, the /firmware node has an empty 'ranges', but does not have address/size-cells.
Commit 6e5773d52f4a ("of/address: Fix WARN when attempting translating non-translatable addresses") started requiring #address-cells for a device's parent if we want to use the reg resource in a device node. This leads to errors like the following:
[ 7.763870] coreboot_table firmware:coreboot: probe with driver coreboot_table failed with error -22
Add appropriate #{address,size}-cells to work around the problem.
Note that Google has also patched the Depthcharge bootloader source to add {address,size}-cells [1], but bootloader updates are typically delivered only via Google OS updates. Not all users install Google software updates, and even if they do, Google may not produce updated binaries for all/older devices.
[1] https://lore.kernel.org/all/[email protected]/
https://crrev.com/c/6051580 ("coreboot: Insert #address-cells and #size-cells for firmware node")
--- arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi | 5 +++++ arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi | 5 +++++ 2 files changed, 10 insertions(+)
arch/arm64/boot/dts/qcom/sc7180-trogdor.dtsi +5 -0
@@ -98,6 +98,11 @@ chosen { stdout-path = "serial0:115200n8"; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + /* FIXED REGULATORS - parents above children */ /* This is the top level supply and variable voltage */
arch/arm64/boot/dts/qcom/sc7280-herobrine.dtsi +5 -0
@@ -25,6 +25,11 @@ chosen { stdout-path = "serial0:115200n8"; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + /* * FIXED REGULATORS *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 255/1518 clk: qcom: gdsc: propagate gdsc_check_status() errors from gdsc_poll_status
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herman van Hazendonk <[email protected]>
[ Upstream commit d69f0c2b8d292b4890c9f0fbe184dfc26c4de86c ]
gdsc_check_status() returns negative errno when the underlying regmap_read() fails -- e.g. when a parent regmap dies during system suspend, a CSR is removed by an HW debug tool, or the bus controller goes into protection. gdsc_poll_status() treats the result as a plain boolean ("is the GDSC in the requested state?"), so any negative error return is truncated to "true" and the poll exits with success even though the rail's real state is unknown:
do {
if (gdsc_check_status(sc, status))
return 0;
} while (ktime_us_delta(ktime_get(), start) < STATUS_POLL_TIMEOUT_US);
if (gdsc_check_status(sc, status))
return 0;
return -ETIMEDOUT;This silently misleads gdsc_toggle_logic() (which writes/un-writes SW_COLLAPSE on the strength of the poll succeeding) and the gdsc_init() sync path (which assumes the readback represents real silicon state).
Latch the return value, propagate negative errno immediately, and only treat a strictly-positive value as "reached the target state". Make the same change in the post-timeout final check so a regmap that comes back after the deadline does not silently degrade to -ETIMEDOUT.
--- drivers/clk/qcom/gdsc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/clk/qcom/gdsc.c +9 -2
@@ -103,14 +103,21 @@ static int gdsc_hwctrl(struct gdsc *sc, bool en)static int gdsc_poll_status (struct gdsc *sc,enum gdsc_status status) {ktime_t start; +int ret; start =ktime_get ();do { -if (gdsc_check_status (sc, status)) + ret =gdsc_check_status (sc, status); +if (ret <0 ) +return ret; +if (ret)return 0 ; }while (ktime_us_delta (ktime_get (), start) <STATUS_POLL_TIMEOUT_US ); -if (gdsc_check_status (sc, status)) + ret =gdsc_check_status (sc, status); +if (ret <0 ) +return ret; +if (ret)return 0 ;return -ETIMEDOUT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 256/1518 clk: qcom: gdsc: propagate gdsc_enable() failure for ALWAYS_ON domains
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herman van Hazendonk <[email protected]>
[ Upstream commit eea55fc694e132aacbe2cf4be7f345115e3d1801 ]
GENPD_FLAG_ALWAYS_ON requires the underlying domain to be on at genpd_init() time -- the framework will refuse to register the domain otherwise. When the cold readback in gdsc_init() finds an ALWAYS_ON GDSC powered down, the driver tries to bring it back up:
} else if (sc->flags & ALWAYS_ON) {
/* If ALWAYS_ON GDSCs are not ON, turn them ON */
gdsc_enable(&sc->pd);
on = true;
}but discards the return value: if gdsc_enable() fails (regmap write error, the long-form sequence's status poll times out, or the HW_CTRL hand-off errors) the code still sets on=true and falls through to pm_genpd_init(..., !on) -- which then registers the domain in the ON state and sets GENPD_FLAG_ALWAYS_ON, even though the silicon is actually off. Subsequent consumer probes will see genpd report "on" while accessing dead registers and hang or read garbage.
Catch the failure and surface it: returning the error from gdsc_init() makes the provider probe fail with the underlying errno, which propagates to consumers as -EPROBE_DEFER (or fatal if the hardware really is broken) rather than silently lying about the rail state.
--- drivers/clk/qcom/gdsc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/qcom/gdsc.c +3 -1
@@ -481,7 +481,9 @@ static int gdsc_init(struct gdsc *sc) }else if (sc->flags &ALWAYS_ON ) {/* If ALWAYS_ON GDSCs are not ON, turn them ON */ -gdsc_enable (&sc->pd); + ret =gdsc_enable (&sc->pd); +if (ret) +return ret; on = true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 257/1518 clk: qcom: gdsc: tear down per-domain genpds in gdsc_unregister()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herman van Hazendonk <[email protected]>
[ Upstream commit 86b23609d5e17a770d03037e53c6a443e742a6e6 ]
gdsc_unregister() removes the OF provider entry and tears down the parent/subdomain wiring, but never calls pm_genpd_remove() on the individual generic_pm_domain structures registered by gdsc_init():
void gdsc_unregister(struct gdsc_desc *desc)
{
struct device *dev = desc->dev;
size_t num = desc->num;
gdsc_pm_subdomain_remove(desc, num);
of_genpd_del_provider(dev->of_node);
}That leaves dangling entries on the global gpd_list. After a provider unbind/rebind cycle (deferred-probe replay during early boot, real module unload of a clk driver that owns GDSCs, or an OF-overlay tear- down) the next gdsc_init() will end up trying to re-register a name that is still in the list and pm_genpd_init() returns -EEXIST.
While we are here, flip the order so the consumer-facing OF provider entry is the first thing removed -- otherwise a fresh of_genpd_get_from_provider() call racing with the teardown could attach to a domain that is mid-removal.
Iterate the scs[] array and pm_genpd_remove() each registered domain after the subdomain links are torn down. The regulators stay devm- managed (devm_regulator_get_optional() in gdsc_register()), so the release happens automatically when the underlying device is unbound; just the genpd accounting needs to be undone explicitly.
--- drivers/clk/qcom/gdsc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/clk/qcom/gdsc.c +9 -1
@@ -645,10 +645,18 @@ int gdsc_register(struct gdsc_desc *desc,void gdsc_unregister (struct gdsc_desc *desc) {struct device *dev = desc->dev; +struct gdsc **scs = desc->scs;size_t num = desc->num; +int i; -gdsc_pm_subdomain_remove (desc, num);of_genpd_del_provider (dev->of_node); +gdsc_pm_subdomain_remove (desc, num); + +for (i =0 ; i < num; i++) { +if (!scs[i]) +continue ; +pm_genpd_remove (&scs[i]->pd); + } }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 258/1518 arm64: dts: qcom: sc8280xp-arcata: Fix top USB-C DP alt mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérôme de Bretagne <[email protected]>
[ Upstream commit 16065c4ec1e7ca595f4fa363dc2251c6bdf1f6b3 ]
The top USB-C port (usb0) didn't switch to DP alt mode, as reusing the same GPIO 101 as on the SC8280XP CRD or Lenovo ThinkPad X13s was not working on the Surface Pro 9 5G.
Investigation [1] by Jens on the Windows Dev Kit (WDK2023), the other sc8280xp-based "blackrock" model from Microsoft, found a reference to GPIO 100 in the DSDT in addition to 101. Switching to GPIO 100 fixed the issue on blackrock, as it does on arcata to enable external screen when using the left-side top USB-C port.
[1] https://lore.kernel.org/all/20250609-blackrock-usb0-mux-v1-1-7903c3b071e4@oldschoolsolutions.biz/
--- arch/arm64/boot/dts/qcom/sc8280xp-microsoft-arcata.dts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sc8280xp-microsoft-arcata.dts +2 -2
@@ -248,7 +248,7 @@ map1 { usb0-sbu-mux { compatible = "pericom,pi3usb102", "gpio-sbu-mux"; - enable-gpios = <&tlmm 101 GPIO_ACTIVE_LOW>; + enable-gpios = <&tlmm 100 GPIO_ACTIVE_LOW>; select-gpios = <&tlmm 164 GPIO_ACTIVE_HIGH>; pinctrl-0 = <&usb0_sbu_default>;
@@ -1002,7 +1002,7 @@ tx-pins { usb0_sbu_default: usb0-sbu-state { oe-n-pins { - pins = "gpio101"; + pins = "gpio100"; function = "gpio"; bias-disable; drive-strength = <16>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 259/1518 arm64: dts: qcom: sc8180x-primus: Rename regulator nodes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit ae51d9396f9318189e91578878409d8ada152edb ]
The nodes would be sorted correctly, if their names started with "regulator-" (which is the style used in the latest submissions). Touch that up.
Stable-dep-of: 80bf2eb87bfb ("arm64: dts: qcom: sc8180x-primus: Describe the display power net")
--- arch/arm64/boot/dts/qcom/sc8180x-primus.dts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/arm64/boot/dts/qcom/sc8180x-primus.dts +4 -4
@@ -165,7 +165,7 @@ reserved-region@9a500000 { }; }; - vreg_nvme_0p9: nvme-0p9-regulator { + vreg_nvme_0p9: regulator-nvme-0p9 { compatible = "regulator-fixed"; regulator-name = "vreg_nvme_0p9";
@@ -175,7 +175,7 @@ vreg_nvme_0p9: nvme-0p9-regulator { regulator-always-on; }; - vreg_nvme_3p3: nvme-3p3-regulator { + vreg_nvme_3p3: regulator-nvme-3p3 { compatible = "regulator-fixed"; regulator-name = "vreg_nvme_3p3";
@@ -188,7 +188,7 @@ vreg_nvme_3p3: nvme-3p3-regulator { regulator-always-on; }; - vdd_kb_tp_3v3: vdd-kb-tp-3v3-regulator { + vdd_kb_tp_3v3: regulator-vdd-kb-tp-3v3 { compatible = "regulator-fixed"; regulator-name = "vdd_kb_tp_3v3"; regulator-min-microvolt = <3300000>;
@@ -203,7 +203,7 @@ vdd_kb_tp_3v3: vdd-kb-tp-3v3-regulator { pinctrl-0 = <&kb_tp_3v3_en_active_state>; }; - vph_pwr: vph-pwr-regulator { + vph_pwr: regulator-vph-pwr { compatible = "regulator-fixed"; regulator-name = "vph_pwr"; regulator-min-microvolt = <3700000>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 260/1518 arm64: dts: qcom: sc8180x-primus: Describe the display power net
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 80bf2eb87bfbf1b7bc7b12228cbcc710b0a26275 ]
Describe and wire up the power supplies for the eDP panel and its backlight. Previously, this was only working because of settings inherited from the bootloader.
--- arch/arm64/boot/dts/qcom/sc8180x-primus.dts | 48 ++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/qcom/sc8180x-primus.dts +47 -1
@@ -27,9 +27,10 @@ backlight: backlight { compatible = "pwm-backlight"; pwms = <&pmc8180c_lpg 4 1000000>; enable-gpios = <&pmc8180c_gpios 8 GPIO_ACTIVE_HIGH>; + power-supply = <&vled_bl_pw>; - pinctrl-names = "default"; pinctrl-0 = <&bl_pwm_default>; + pinctrl-names = "default"; }; chosen {
@@ -165,6 +166,38 @@ reserved-region@9a500000 { }; }; + vled_bl_pw: regulator-vled-bl-pw { + compatible = "regulator-fixed"; + + regulator-name = "VLED_BL_PW"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&pmc8180_2_gpios 1 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&bl_pwr_en>; + pinctrl-names = "default"; + + regulator-boot-on; + }; + + vreg_lcm_3v3: regulator-edp-3p3 { + compatible = "regulator-fixed"; + + regulator-name = "VREG_LCM_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&tlmm 130 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&lcm_3v3_en>; + pinctrl-names = "default"; + + regulator-boot-on; + }; + vreg_nvme_0p9: regulator-nvme-0p9 { compatible = "regulator-fixed"; regulator-name = "vreg_nvme_0p9";
@@ -539,6 +572,7 @@ &mdss_edp { aux-bus { panel { compatible = "edp-panel"; + power-supply = <&vreg_lcm_3v3>; backlight = <&backlight>;
@@ -768,6 +802,12 @@ &wifi { }; /* PINCTRL */ +&pmc8180_2_gpios { + bl_pwr_en: bl-pwr-en-state { + pins = "gpio1"; + function = "normal"; + }; +}; &pmc8180c_gpios { bl_pwm_default: bl-pwm-default-state {
@@ -949,4 +989,10 @@ rx-pins { bias-pull-up; }; }; + + lcm_3v3_en: lcm-3v3-en-state { + pins = "gpio130"; + function = "gpio"; + bias-disable; + }; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 261/1518 arm64: dts: qcom: sc8180x-lenovo-flex-5g: Rename regulator nodes
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit 0b1c6d2a65fc41aa0d5f6617dd04043384678d61 ]
Align with the contemporary way of naming regulator nodes (regulator- prefix) in preparation for adding more of them.
Reorder the renamed entries to match the expectations of the DT coding style doc.
Stable-dep-of: d5f5c089858f ("arm64: dts: qcom: sc8180x-lenovo-flex-5g: Describe the display power net")
--- .../boot/dts/qcom/sc8180x-lenovo-flex-5g.dts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
arch/arm64/boot/dts/qcom/sc8180x-lenovo-flex-5g.dts +8 -8
@@ -162,14 +162,7 @@ cdsp_mem: cdsp-region@98900000 { }; }; - vph_pwr: vph-pwr-regulator { - compatible = "regulator-fixed"; - regulator-name = "vph_pwr"; - regulator-min-microvolt = <3700000>; - regulator-max-microvolt = <3700000>; - }; - - vreg_s4a_1p8: pm8150-s4-regulator { + vreg_s4a_1p8: regulator-pm8150-s4 { compatible = "regulator-fixed"; regulator-name = "vreg_s4a_1p8";
@@ -182,6 +175,13 @@ vreg_s4a_1p8: pm8150-s4-regulator { vin-supply = <&vph_pwr>; }; + vph_pwr: regulator-vph-pwr { + compatible = "regulator-fixed"; + regulator-name = "vph_pwr"; + regulator-min-microvolt = <3700000>; + regulator-max-microvolt = <3700000>; + }; + usbprim-sbu-mux { compatible = "pericom,pi3usb102", "gpio-sbu-mux";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 262/1518 arm64: dts: qcom: sc8180x-lenovo-flex-5g: Describe the display power net
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konrad Dybcio <[email protected]>
[ Upstream commit d5f5c089858f7accd1e4574c0c09d811e90eb51f ]
Describe and wire up the power supplies for the eDP panel and its backlight. Previously, this was only working because of settings inherited from the bootloader.
--- .../boot/dts/qcom/sc8180x-lenovo-flex-5g.dts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+)
arch/arm64/boot/dts/qcom/sc8180x-lenovo-flex-5g.dts +47 -0
@@ -26,6 +26,7 @@ backlight: backlight { compatible = "pwm-backlight"; pwms = <&pmc8180c_lpg 4 1000000>; enable-gpios = <&pmc8180c_gpios 8 GPIO_ACTIVE_HIGH>; + power-supply = <&vled_bl_pw>; pinctrl-0 = <&bl_pwm_default>; pinctrl-names = "default";
@@ -162,6 +163,38 @@ cdsp_mem: cdsp-region@98900000 { }; }; + vled_bl_pw: regulator-vled-bl-pw { + compatible = "regulator-fixed"; + + regulator-name = "VLED_BL_PW"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&pmc8180_2_gpios 1 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&bl_pwr_en>; + pinctrl-names = "default"; + + regulator-boot-on; + }; + + vreg_lcm_3v3: regulator-edp-3p3 { + compatible = "regulator-fixed"; + + regulator-name = "VREG_LCM_3V3"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + + gpio = <&tlmm 130 GPIO_ACTIVE_HIGH>; + enable-active-high; + + pinctrl-0 = <&lcm_3v3_en>; + pinctrl-names = "default"; + + regulator-boot-on; + }; + vreg_s4a_1p8: regulator-pm8150-s4 { compatible = "regulator-fixed"; regulator-name = "vreg_s4a_1p8";
@@ -444,6 +477,7 @@ &mdss_edp { aux-bus { panel { compatible = "edp-panel"; + power-supply = <&vreg_lcm_3v3>; no-hpd; backlight = <&backlight>;
@@ -478,6 +512,13 @@ &pcie3_phy { status = "okay"; }; +&pmc8180_2_gpios { + bl_pwr_en: bl-pwr-en-state { + pins = "gpio1"; + function = "normal"; + }; +}; + &pmc8180_pwrkey { status = "okay"; };
@@ -771,6 +812,12 @@ ts_int_default: ts-int-default-state { drive-strength = <2>; }; + lcm_3v3_en: lcm-3v3-en-state { + pins = "gpio130"; + function = "gpio"; + bias-disable; + }; + usbprim_sbu_default: usbprim-sbu-state { oe-n-pins { pins = "gpio152";
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 263/1518 clk: qcom: gcc-qcs8300: Use retention for PCIe power domains
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
[ Upstream commit 11b170abe4d324cac0d15a410282d1ec2b6bafa0 ]
As the PCIe host controller driver does not yet support dealing with the loss of state during suspend, use retention for relevant GDSCs.
Fix the PCIe link not surviving upon resume, and GDSC error:
gcc_pcie_0_gdsc status stuck at 'off'
--- drivers/clk/qcom/gcc-qcs8300.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-qcs8300.c +2 -2
@@ -3268,7 +3268,7 @@ static struct gdsc gcc_pcie_0_gdsc = { .pd = { .name = "gcc_pcie_0_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = VOTABLE | RETAIN_FF_ENABLE | POLL_CFG_GDSCR, };
@@ -3282,7 +3282,7 @@ static struct gdsc gcc_pcie_1_gdsc = { .pd = { .name = "gcc_pcie_1_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = VOTABLE | RETAIN_FF_ENABLE | POLL_CFG_GDSCR, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 264/1518 clk: qcom: gcc-qcs8300: Use retention for USB power domains
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Loic Poulain <[email protected]>
[ Upstream commit d8638610e0c9ebab2800b7ad6c2c2a3737090da9 ]
The USB subsystem does not expect to lose its state on suspend:
xhci-hcd xhci-hcd.1.auto: xHC error in resume, USBSTS 0x401, Reinit usb usb1: root hub lost power or was reset
To maintain state during suspend, the relevant GDSCs need to stay in retention mode, like they do on other similar SoCs. Change the mode to PWRSTS_RET_ON to fix.
--- drivers/clk/qcom/gcc-qcs8300.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/qcom/gcc-qcs8300.c +2 -2
@@ -3306,7 +3306,7 @@ static struct gdsc gcc_usb20_prim_gdsc = { .pd = { .name = "gcc_usb20_prim_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR, };
@@ -3318,7 +3318,7 @@ static struct gdsc gcc_usb30_prim_gdsc = { .pd = { .name = "gcc_usb30_prim_gdsc", }, - .pwrsts = PWRSTS_OFF_ON, + .pwrsts = PWRSTS_RET_ON, .flags = RETAIN_FF_ENABLE | POLL_CFG_GDSCR, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 265/1518 perf data convert json: Fix trace_seq memory leak in process_sample_event()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit dcb87c88952046ef43cb5ba3a5b95eb29c362a16 ]
Unlike the in-kernel trace_seq which uses a statically allocated buffer, the userspace traceevent library's trace_seq uses a dynamically allocated one. Therefore, every trace_seq_init() call must be paired with a trace_seq_destroy(), otherwise it produces a memory leak.
In process_sample_event(), a trace_seq is initialized for each field when formatting tracepoint raw_data, but the matching trace_seq_destroy() is never called, leaking memory for every field of every sample processed.
Add the missing trace_seq_destroy() after using the trace_seq buffer to properly free the allocated memory.
Detected with Valgrind on a perf.data file with 2,729 tracepoint samples:
Before: definitely lost: 55,537,664 bytes in 13,559 blocks
After: definitely lost: 0 bytes in 0 blocks
--- tools/perf/util/data-convert-json.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/data-convert-json.c +1 -0
@@ -242,6 +242,7 @@ static int process_sample_event(const struct perf_tool *tool,trace_seq_init (&s);tep_print_field (&s, sample->raw_data, fields[i]);output_json_key_string (out, true,3 , fields[i]->name, s.buffer); +trace_seq_destroy (&s); i++; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/1518 staging: media: ipu7: fix pm_runtime refcount leak in ipu7_init_fw_code_region_by_sys()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
[ Upstream commit 843644e1c3347670498d247d7cd20dff1569181c ]
ipu7_init_fw_code_region_by_sys() calls pm_runtime_get_sync() before accessing the firmware code region. If resuming the device fails, pm_runtime_get_sync() leaves the runtime PM usage count incremented, but the error path returns without dropping the reference.
Use pm_runtime_resume_and_get() instead, which balances the usage count automatically on failure and avoids the leak.
The ipu6 driver uses pm_runtime_resume_and_get() in the equivalent location.
--- drivers/staging/media/ipu7/ipu7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7.c +1 -1
@@ -2343,7 +2343,7 @@ static int ipu7_init_fw_code_region_by_sys(struct ipu7_bus_device *sys,return ret; } - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret <0 ) {dev_err (dev,"Failed to get runtime PM\n" );return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/1518 staging: media: ipu7: fix pm_runtime refcount leak in ipu7_resume()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vidhu Sarwal <[email protected]>
[ Upstream commit b298b80814dd0fc3cb1c8c0e0082fc14fdb5fecf ]
ipu7_resume() calls pm_runtime_get_sync() before resuming the device. If the runtime PM resume fails, the usage count remains incremented, but the error path returns without dropping the reference.
Use pm_runtime_resume_and_get() instead, which balances the usage count on failure and avoids the leak. Keep returning 0 on error, as resume callbacks should not propagate failures to the PM core, matching the behaviour of the ipu6 driver.
--- drivers/staging/media/ipu7/ipu7.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/media/ipu7/ipu7.c +1 -1
@@ -2702,7 +2702,7 @@ static int ipu7_resume(struct device *dev)if (ret)dev_err (dev,"IPC reset protocol failed!\n" ); - ret =pm_runtime_get_sync (&isp->psys->auxdev.dev); + ret =pm_runtime_resume_and_get (&isp->psys->auxdev.dev);if (ret <0 ) {dev_err (dev,"Failed to get runtime PM\n" );return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/1518 thermal/drivers/rcar: Fix error checking in probe()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit dd04ad1cdabcad51e34b74b4e91b9aeb7180d05d ]
This code accidentally calls thermal_zone_device_enable() before checking whether thermal_zone_device_register_with_trips() failed. Move the call until later to avoid an error pointer dereference of "priv->zone".
The driver works differently depending on if we are using OF thermal or not. We use thermal_add_hwmon_sysfs() if we are using OF thermal and call thermal_zone_device_enable() if not. We can share same error check for if either of these fail.
Moving the thermal_zone_device_enable() call is a bit cleaner as well. The original code used a three step process to cleanup:
1. Call thermal_zone_device_unregister() to cleanup.
2. Set priv->zone to an error pointer to preserve the error code.
3. Set priv->zone to NULL to avoid a second call to thermal_zone_device_unregister() in the rcar_thermal_remove() function.
Now we can just do a direct goto error_unregister and rcar_thermal_remove() handles the cleanup properly.
--- drivers/thermal/renesas/rcar_thermal.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-)
drivers/thermal/renesas/rcar_thermal.c +5 -10
@@ -492,12 +492,6 @@ static int rcar_thermal_probe(struct platform_device *pdev)"rcar_thermal" , trips,ARRAY_SIZE (trips), priv, &rcar_thermal_zone_ops,NULL ,0 , idle); - - ret =thermal_zone_device_enable (priv->zone); -if (ret) { -thermal_zone_device_unregister (priv->zone); - priv->zone =ERR_PTR (ret); - } }if (IS_ERR (priv->zone)) {dev_err (dev,"can't register thermal zone\n" );
@@ -506,11 +500,12 @@ static int rcar_thermal_probe(struct platform_device *pdev) goto error_unregister; } -if (chip->use_of_thermal) { +if (chip->use_of_thermal) ret =thermal_add_hwmon_sysfs (priv->zone); -if (ret) - goto error_unregister; - } +else + ret =thermal_zone_device_enable (priv->zone); +if (ret) + goto error_unregister;rcar_thermal_irq_enable (priv);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/1518 usb: typec: ucsi: unregister debugfs entries on teardown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit eed73a65ab609b79d53de88cccc34b36dfe753c4 ]
ucsi_register() creates per-instance debugfs entries, but ucsi_unregister() keeps them around until ucsi_destroy().
Drivers like ucsi_glink that unregister/register the same UCSI instance across remoteproc restart then try to create an already existing debugfs directory and log:
debugfs: 'pmic_glink.ucsi.0' already exists in 'ucsi'
Unregister debugfs entries as part of ucsi_unregister(), and clear ucsi->debugfs after freeing it so repeated unregister paths remain safe.
--- drivers/usb/typec/ucsi/debugfs.c | 1 + drivers/usb/typec/ucsi/ucsi.c | 2 ++ 2 files changed, 3 insertions(+)
drivers/usb/typec/ucsi/debugfs.c +1 -0
@@ -129,6 +129,7 @@ void ucsi_debugfs_unregister(struct ucsi *ucsi)debugfs_remove_recursive (ucsi->debugfs->dentry);kfree (ucsi->debugfs); + ucsi->debugfs =NULL ; }void ucsi_debugfs_init (void )
drivers/usb/typec/ucsi/ucsi.c +2 -0
@@ -2275,6 +2275,8 @@ void ucsi_unregister(struct ucsi *ucsi)cancel_delayed_work_sync (&ucsi->work);cancel_work_sync (&ucsi->resume_work); +ucsi_debugfs_unregister (ucsi); +/* Disable notifications */ ucsi->ops->async_control (ucsi, cmd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/1518 usb: gadget: r8a66597: avoid double free of ep0_req in probe error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xu <[email protected]>
[ Upstream commit 41d541e3718db01668a4cd29815ee4b3b55f76d2 ]
If usb_add_gadget_udc() fails, r8a66597_probe() jumps to err_add_udc and frees ep0_req, then falls through to clean_up2 where ep0_req is freed again when it is non-NULL.
Remove the redundant free from err_add_udc and keep the cleanup in clean_up2 so the request is released exactly once.
Issue found using a prototype static analysis tool and confirmed by code review.
--- drivers/usb/gadget/udc/r8a66597-udc.c | 1 - 1 file changed, 1 deletion(-)
drivers/usb/gadget/udc/r8a66597-udc.c +0 -1
@@ -1951,7 +1951,6 @@ static int r8a66597_probe(struct platform_device *pdev)return 0 ; err_add_udc: -r8a66597_free_request (&r8a66597->ep[0 ].ep, r8a66597->ep0_req); clean_up2:if (r8a66597->pdata->on_chip)clk_disable_unprepare (r8a66597->clk);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/1518 udf: Mark LVID buffer as uptodate before marking it dirty
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandr Nogikh <[email protected]>
[ Upstream commit fb0601134c7e51728bd098abc6909315de1e5d86 ]
When an I/O error occurs while writing the Logical Volume Integrity Descriptor (LVID) buffer to the block device, the block layer's completion handler (end_buffer_write_sync()) clears the BH_Uptodate flag on the buffer. However, the buffer still contains valid LVID data in memory. If the filesystem is subsequently remounted read-write or synced, udf_open_lvid() or udf_sync_fs() will modify the LVID buffer and call mark_buffer_dirty(). This triggers a spurious WARN_ON_ONCE(!buffer_uptodate(bh)) warning in mark_buffer_dirty() because the buffer is not marked uptodate, even though its in-memory contents are valid and are about to be overwritten.
To prevent this spurious warning, unconditionally set the BH_Uptodate flag before calling mark_buffer_dirty() in udf_open_lvid() and udf_sync_fs(). This acknowledges that the in-memory buffer is valid and matches the workaround previously applied to udf_close_lvid() in commit 853a0c25baf9 ("udf: Mark LVID buffer as uptodate before marking it dirty"). Extending this workaround ensures consistent behavior across all LVID updates.
Buffer I/O error on dev loop0, logical block 128, lost sync page write
------------[ cut here ]------------ !buffer_uptodate(bh) WARNING: fs/buffer.c:1087 at mark_buffer_dirty+0x299/0x410 fs/buffer.c:1087 ... Call Trace: <TASK> udf_open_lvid+0x369/0x5b0 fs/udf/super.c:2078 udf_reconfigure+0x336/0x540 fs/udf/super.c:679 reconfigure_super+0x232/0x8f0 fs/super.c:1080 vfs_cmd_reconfigure fs/fsopen.c:268 [inline] vfs_fsconfig_locked+0x171/0x320 fs/fsopen.c:297 __do_sys_fsconfig fs/fsopen.c:463 [inline] __se_sys_fsconfig+0x6b9/0x810 fs/fsopen.c:350 do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94 </TASK>
--- fs/udf/super.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-)
fs/udf/super.c +14 -9
@@ -2048,6 +2048,17 @@ static int udf_load_vrs(struct super_block *sb, struct udf_options *uopt,return 0 ; } +static void udf_mark_buffer_dirty (struct buffer_head *bh) +{ +/* +* We set buffer uptodate unconditionally here to avoid spurious +* warnings from mark_buffer_dirty() when previous EIO has marked +* the buffer as !uptodate +*/ +set_buffer_uptodate (bh); +mark_buffer_dirty (bh); +} +static void udf_finalize_lvid (struct logicalVolIntegrityDesc *lvid) {struct timespec64 ts;
@@ -2083,7 +2094,7 @@ static void udf_open_lvid(struct super_block *sb)UDF_SET_FLAG (sb,UDF_FLAG_INCONSISTENT );udf_finalize_lvid (lvid); -mark_buffer_dirty (bh); +udf_mark_buffer_dirty (bh); sbi->s_lvid_dirty =0 ;mutex_unlock (&sbi->s_alloc_mutex);/* Make opening of filesystem visible on the media immediately */
@@ -2116,14 +2127,8 @@ static void udf_close_lvid(struct super_block *sb)if (!UDF_QUERY_FLAG (sb,UDF_FLAG_INCONSISTENT )) lvid->integrityType =cpu_to_le32 (LVID_INTEGRITY_TYPE_CLOSE ); -/* -* We set buffer uptodate unconditionally here to avoid spurious -* warnings from mark_buffer_dirty() when previous EIO has marked -* the buffer as !uptodate -*/ -set_buffer_uptodate (bh);udf_finalize_lvid (lvid); -mark_buffer_dirty (bh); +udf_mark_buffer_dirty (bh); sbi->s_lvid_dirty =0 ;mutex_unlock (&sbi->s_alloc_mutex);/* Make closing of filesystem visible on the media immediately */
@@ -2405,7 +2410,7 @@ static int udf_sync_fs(struct super_block *sb, int wait)* Blockdevice will be synced later so we don't have to submit * the buffer for IO */ -mark_buffer_dirty (bh); +udf_mark_buffer_dirty (bh); sbi->s_lvid_dirty =0 ; }mutex_unlock (&sbi->s_alloc_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/1518 bpftool: Check EVP_Digest when computing excl_prog_hash
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 576bcaa1f5c208af0f590c9622247da87b49c05f ]
bpftool_prog_sign() ignores the return value of EVP_Digest(). If the digest computation fails (context allocation failure, or a digest fetch failure under OpenSSL), EVP_Digest() returns 0 and leaves the output buffer untouched, but the function still reports success.
--- tools/bpf/bpftool/sign.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/bpf/bpftool/sign.c +5 -2
@@ -175,8 +175,11 @@ int bpftool_prog_sign(struct bpf_load_and_run_opts *opts) goto cleanup; } -EVP_Digest (opts->insns, opts->insns_sz, opts->excl_prog_hash, - &opts->excl_prog_hash_sz,EVP_sha256 (),NULL ); +if (EVP_Digest (opts->insns, opts->insns_sz, opts->excl_prog_hash, + &opts->excl_prog_hash_sz,EVP_sha256 (),NULL ) !=1 ) { + err = -EIO ; + goto cleanup; + } bd_out =BIO_new (BIO_s_mem ());if (!bd_out) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/1518 perf vendor events amd: Reintroduce deprecated Zen 5 core events
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sandipan Das <[email protected]>
[ Upstream commit eda39f98bbc5ce8b7b0be10193d2de38ed59da6c ]
Maintain backward compatibility by reintroducing the events that were previously removed by commit 047979af3bf6 ("perf vendor events amd:
Update Zen 5 core events"). Also set the deprecated flag and update the descriptions to point users to the correct alternative.
--- .../arch/x86/amdzen5/floating-point.json | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+)
tools/perf/pmu-events/arch/x86/amdzen5/floating-point.json +42 -0
@@ -383,6 +383,13 @@ "BriefDescription": "Retired MMX integer VNNI ops.", "UMask": "0x0c" }, + { + "EventName": "sse_avx_ops_retired.mmx_pack", + "EventCode": "0x0b", + "BriefDescription": "This event is deprecated. Refer to new event sse_avx_ops_retired.mmx_vnni", + "Deprecated": "1", + "UMask": "0x0c" + }, { "EventName": "sse_avx_ops_retired.mmx_logical", "EventCode": "0x0b",
@@ -449,6 +456,13 @@ "BriefDescription": "Retired SSE and AVX integer convert or pack ops.", "UMask": "0x80" }, + { + "EventName": "sse_avx_ops_retired.sse_avx_clm", + "EventCode": "0x0b", + "BriefDescription": "This event is deprecated. Refer to new event sse_avx_ops_retired.sse_avx_cvt", + "Deprecated": "1", + "UMask": "0x80" + }, { "EventName": "sse_avx_ops_retired.sse_avx_shift", "EventCode": "0x0b",
@@ -473,6 +487,13 @@ "BriefDescription": "Retired SSE and AVX integer VNNI ops.", "UMask": "0xc0" }, + { + "EventName": "sse_avx_ops_retired.sse_avx_pack", + "EventCode": "0x0b", + "BriefDescription": "This event is deprecated. Refer to new event sse_avx_ops_retired.sse_avx_vnni", + "Deprecated": "1", + "UMask": "0xc0" + }, { "EventName": "sse_avx_ops_retired.sse_avx_logical", "EventCode": "0x0b",
@@ -731,6 +752,13 @@ "BriefDescription": "Retired 128-bit packed integer convert or pack ops.", "UMask": "0x08" }, + { + "EventName": "packed_int_op_type.int128_clm", + "EventCode": "0x0d", + "BriefDescription": "This event is deprecated. Refer to new event packed_int_op_type.int128_cvt", + "Deprecated": "1", + "UMask": "0x08" + }, { "EventName": "packed_int_op_type.int128_shift", "EventCode": "0x0d",
@@ -755,6 +783,13 @@ "BriefDescription": "Retired 128-bit packed integer VNNI ops.", "UMask": "0x0c" }, + { + "EventName": "packed_int_op_type.int128_pack", + "EventCode": "0x0d", + "BriefDescription": "This event is deprecated. Refer to new event packed_int_op_type.int128_vnni", + "Deprecated": "1", + "UMask": "0x0c" + }, { "EventName": "packed_int_op_type.int128_logical", "EventCode": "0x0d",
@@ -845,6 +880,13 @@ "BriefDescription": "Retired 256-bit packed integer VNNI ops.", "UMask": "0xc0" }, + { + "EventName": "packed_int_op_type.int256_pack", + "EventCode": "0x0d", + "BriefDescription": "This event is deprecated. Refer to new event packed_int_op_type.int256_vnni", + "Deprecated": "1", + "UMask": "0xc0" + }, { "EventName": "packed_int_op_type.int256_logical", "EventCode": "0x0d",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/1518 perf dso: Fix kallsyms DSO detection with fallback logic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tanushree Shah <[email protected]>
[ Upstream commit 8c5f60344b07f839267c0c835962e2206143be85 ]
The current kallsyms detection in dso__is_kallsyms() uses the dso_binary_type enum which fixes the issue of kallsyms being cached in the build-id cache for out-of-tree modules.
However, during build-id injection in perf record/inject, dso_binary_type has not been explicitly set yet,so dso__binary_type() returns DSO_BINARY_TYPE__NOT_FOUND instead of DSO_BINARY_TYPE__KALLSYMS for the kernel DSO. The current check then fails to identify it as kallsyms, causing build-id symlinks to not be created in ~/.debug/.build-id/ and perf archive to fail with "Cannot stat" errors.
Steps to reproduce the issue:
1. rm -rf ~/.debug/.build-id
2. perf record sleep 1
3. perf archive
Fix by falling back to matching long_name against the known kallsyms strings explicitly when binary_type is not yet set
(== DSO_BINARY_TYPE__NOT_FOUND). Use strcmp() for exact matching of fixed names and strict validation for guest kallsyms with embedded PID to prevent path traversal attacks.
--- tools/perf/util/dso.h | 57 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-)
tools/perf/util/dso.h +56 -1
@@ -9,6 +9,7 @@#include <stdbool.h> #include <stdio.h> #include <linux/bitops.h> +#include <string.h> #include "build-id.h" #include "debuginfo.h" #include "mutex.h"
@@ -20,6 +21,40 @@ struct perf_env;#define DSO__NAME_KALLSYMS "[kernel.kallsyms]"#define DSO__NAME_KCORE "[kernel.kcore]" +#define DSO__NAME_GUEST_KALLSYMS "[guest.kernel.kallsyms]" +#define DSO__NAME_GUEST_KALLSYMS_PID_PREFIX "[guest.kernel.kallsyms." + +/* +* Validate names of the form "[guest.kernel.kallsyms.<pid>]", where +* <pid> is the PID of the guest VM and varies per guest, so it +* cannot be matched with strcmp() against a fixed string. +* +* Every character after the fixed prefix must be a decimal digit, +* with ']' immediately terminating the digit run and nothing +* following it. This rules out '/', "..", or any other character +* being smuggled into the name. +*/ +static inline bool is_guest_kallsyms_pid_name (const char *name) +{ +const size_t prefix_len =sizeof (DSO__NAME_GUEST_KALLSYMS_PID_PREFIX ) -1 ; +size_t digits; + +if (strncmp (name,DSO__NAME_GUEST_KALLSYMS_PID_PREFIX , prefix_len) !=0 ) +return false; + + digits =strspn (name + prefix_len,"0123456789" ); +if (digits ==0 ) +return false; + +/* ']' must terminate the digit run, with nothing trailing it */ +if (name[prefix_len + digits] !=']' ) +return false; + +if (name[prefix_len + digits +1 ] !='\0' ) +return false; + +return true; +}/** * enum dso_binary_type - The kind of DSO generally associated with a memory
@@ -894,8 +929,28 @@ static inline bool dso__is_kcore(const struct dso *dso)static inline bool dso__is_kallsyms (const struct dso *dso) {enum dso_binary_type bt =dso__binary_type (dso); +const char *name; + +if (bt ==DSO_BINARY_TYPE__KALLSYMS || bt ==DSO_BINARY_TYPE__GUEST_KALLSYMS ) +return true; + +if (bt !=DSO_BINARY_TYPE__NOT_FOUND ) +return false; + +if (!dso__kernel (dso)) +return false; + + name =dso__long_name (dso); +if (!name) +return false; + +if (!strcmp (name,DSO__NAME_KALLSYMS )) +return true; + +if (!strcmp (name,DSO__NAME_GUEST_KALLSYMS )) +return true; -return bt ==DSO_BINARY_TYPE__KALLSYMS || bt ==DSO_BINARY_TYPE__GUEST_KALLSYMS ; +return is_guest_kallsyms_pid_name (name); }bool dso__is_object_file (const struct dso *dso);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/1518 bpf: Fix vmlinux BTF prep race in bpf_get_btf_vmlinux
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 92863e678070f57c17c868e4bfa2441a5c61ad2b ]
bpf_get_btf_vmlinux() lazily parses the vmlinux BTF under the bpf_verifier_lock, but publishes the result through a plain store and re-checks it through a plain lockless load. Nothing orders the stores initializing the struct btf inside btf_parse_vmlinux() against the store publishing the pointer: On a weakly ordered arch, a concurrent first-time caller taking the lockless fast path could in principle observe the pointer before the parsed contents are visible. The mutex_unlock() does not help such a reader given it only synchronizes with a later acquisition of the same lock. Thus, publish the pointer with smp_store_release() and read it on the fast path with smp_load_acquire().
Acquire semantics are needed rather than a dependency-ordered READ_ONCE(): btf_parse_vmlinux() also populates globals outside the returned object (e.g. bpf_ctx_convert.t). An address dependency would only order accesses performed through the pointer and not cover other globals.
--- kernel/bpf/verifier.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
kernel/bpf/verifier.c +16 -4
@@ -24406,13 +24406,25 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)struct btf *bpf_get_btf_vmlinux (void ) { -if (!btf_vmlinux &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF )) { +/* Pairs with the smp_store_release() on the parse path below. */ +struct btf *btf =smp_load_acquire (&btf_vmlinux); + +if (!btf &&IS_ENABLED (CONFIG_DEBUG_INFO_BTF )) {mutex_lock (&bpf_verifier_lock); -if (!btf_vmlinux) - btf_vmlinux =btf_parse_vmlinux (); + btf = btf_vmlinux; +if (!btf) { + btf =btf_parse_vmlinux (); +/* +* Order the parsed BTF contents and the globals the +* parse populated (e.g. bpf_ctx_convert.t) before +* the pointer publication. Pairs with the acquire +* on the lockless fast path above. +*/ +smp_store_release (&btf_vmlinux, btf); + }mutex_unlock (&bpf_verifier_lock); } -return btf_vmlinux; +return btf; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/1518 efi: fix stale reference to efi_recover_from_page_fault()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 718ee46ba4d95d28d50d3f6437afbbe2be531175 ]
efi_recover_from_page_fault() was renamed to efi_crash_gracefully_on_page_fault(), but the comment above enum efi_rts_ids was not updated. Use the current name.
--- include/linux/efi.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/efi.h +2 -2
@@ -1228,8 +1228,8 @@ efi_call_acpi_prm_handler(efi_status_t (__efiapi *handler_addr)(u64, void *),/* * efi_runtime_service() function identifiers. -* "NONE" is used by efi_recover_from_page_fault() to check if the page -* fault happened while executing an efi runtime service. +* "NONE" is used by efi_crash_gracefully_on_page_fault() to check if the +* page fault happened while executing an efi runtime service. */ enum efi_rts_ids {EFI_NONE ,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/1518 bpf: Fix use-after-free on mm_struct in bpf_find_vma()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanghyun Park <[email protected]>
[ Upstream commit 47b079e2117a2ee52e21f8b72935900c702fc0b5 ]
bpf_find_vma() reads task->mm and calls mmap_read_trylock(mm) without holding a reference on the mm. On a foreign task, a concurrent exit_mm() can free the mm_struct between the lockless read and the trylock, resulting in a use-after-free. mm_struct is not SLAB_TYPESAFE_BY_RCU.
For the current task, task->mm is stable. For a foreign task, pin the mm under task->alloc_lock and release it with mmput_async(), mirroring commit d8e27d2d22b6 ("bpf: fix mm lifecycle in open-coded task_vma iterator"). Use spin_trylock() instead of get_task_mm() so BPF context does not block on alloc_lock. Reject irqs-disabled contexts and !CONFIG_MMU on the foreign-task path because dropping the mm reference is not safe there.
Race:
CPU0 (BPF program) CPU1 (exiting task)
============================ ==========================
bpf_find_vma(foreign_task):
mm = task->mm
exit_mm():
task->mm = NULL
mmput(mm) -> frees mm_struct
mmap_read_trylock(mm)
// UAF on mm--- kernel/bpf/task_iter.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-)
kernel/bpf/task_iter.c +33 -3
@@ -756,6 +756,7 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,struct mmap_unlock_irq_work *work =NULL ;struct vm_area_struct *vma;bool irq_work_busy = false; +bool __maybe_unused mmput_needed = false;struct mm_struct *mm;int ret = -ENOENT ;
@@ -765,14 +766,38 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start,if (!task)return -ENOENT ; - mm = task->mm; +if (task == current) { + mm = task->mm; + }else { +/* +* Foreign task: pin task->mm against a concurrent exit_mm(). +* Use trylock on alloc_lock instead of get_task_mm()'s +* blocking task_lock() to avoid deadlocking the target task. +*/ +if (!IS_ENABLED (CONFIG_MMU )) +return -EOPNOTSUPP ; +if (irqs_disabled ()) +return -EBUSY ; +if (!spin_trylock (&task->alloc_lock)) +return -EBUSY ; + mm = task->mm; +if (mm && !(task->flags &PF_KTHREAD )) { +mmget (mm); + mmput_needed = true; + }else { + mm =NULL ; + } +spin_unlock (&task->alloc_lock); + }if (!mm)return -ENOENT ; irq_work_busy =bpf_mmap_unlock_get_irq_work (&work); -if (irq_work_busy || !mmap_read_trylock (mm)) -return -EBUSY ; +if (irq_work_busy || !mmap_read_trylock (mm)) { + ret = -EBUSY ; + goto out; + } vma =find_vma (mm, start);
@@ -782,6 +807,11 @@ BPF_CALL_5(bpf_find_vma, struct task_struct *, task, u64, start, ret =0 ; }bpf_mmap_unlock_mm (work, mm); +out: +#ifdef CONFIG_MMU +if (mmput_needed) +mmput_async (mm); +#endif return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/1518 bus: mhi: ep: Fix device refcount leak in the error path of MHI device creation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 6f12862600bb70e599a614d706a095ea5f8f9858 ]
mhi_ep_create_device() takes one device reference for the UL channel and another for the DL channel after allocating the transfer device. These references are normally released by mhi_ep_destroy_device() before the device itself is removed.
If dev_set_name() or device_add() fails, the error path currently drops only one reference. The remaining channel references keep the device from being released and leave the channels associated with a device that was never registered.
Route both failures through a common unwind path that drops the DL channel reference, the UL channel reference, and the initial reference from device_initialize().
--- drivers/bus/mhi/ep/main.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/bus/mhi/ep/main.c +10 -5
@@ -1340,14 +1340,19 @@ static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id) ret =dev_set_name (&mhi_dev->dev,"%s_%s" ,dev_name (&mhi_cntrl->mhi_dev->dev), mhi_dev->name); -if (ret) { -put_device (&mhi_dev->dev); -return ret; - } +if (ret) + goto err_put_channels; ret =device_add (&mhi_dev->dev);if (ret) -put_device (&mhi_dev->dev); + goto err_put_channels; + +return 0 ; + +err_put_channels: +put_device (&mhi_dev->dev);/* DL channel reference */ +put_device (&mhi_dev->dev);/* UL channel reference */ +put_device (&mhi_dev->dev);/* device_initialize() reference */ return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 279/1518 iommu/mediatek-v1: Fix off-by-one in MT2701_LARB_NR_MAX
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Akari Tsuyukusa <[email protected]>
[ Upstream commit aebaa93f3da1572877579c2e15ebf27be2dcc7fb ]
The mt2701_m4u_in_larb[] array contains 4 (for LARB0 to LARB3) elements, meaning mt2701_m4u_to_larb() can legitimately return 3. The current check if (larbid >= MT2701_LARB_NR_MAX) incorrectly rejects valid LARB3 with -EINVAL.
Fix this off-by-one error by updating MT2701_LARB_NR_MAX to 4.
Note that this does not cause immediate issues with the current mt2701.dtsi and mt7623n.dtsi because it only defines 3 LARBs:
mediatek,larbs = <&larb0 &larb1 &larb2>;
Thus, larbid never reaches 3 in the existing upstream device tree.
--- drivers/iommu/mtk_iommu_v1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/mtk_iommu_v1.c +1 -1
@@ -88,7 +88,7 @@ struct dma_iommu_mapping {/* MTK generation one iommu HW only support 4K size mapping */ #define MT2701_IOMMU_PAGE_SHIFT 12#define MT2701_IOMMU_PAGE_SIZE (1UL << MT2701_IOMMU_PAGE_SHIFT) -#define MT2701_LARB_NR_MAX 3 +#define MT2701_LARB_NR_MAX 4/* * MTK m4u support 4GB iova address space, and only support 4K page
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/1518 bpf: Fix security_bpf_map_create error handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 36ffa86c42f91c8a57071e024afc4ffb51a8958f ]
Commit 5816bf4273ed ("lsm,selinux: Add LSM blob support for BPF objects") made the LSM hook wrappers for BPF object creation clean up the LSM state internally upon denial, e.g. security_bpf_map_create() internally calls security_bpf_map_free() when the bpf_map_create hook returns an error. map_create() however still routes a denial to its free_map_sec label, which invokes security_bpf_map_free() a second time, so the bpf_map_free hook fires twice for a single denied map.
In-tree LSMs are unaffected in practice since the blob kfree() inside security_bpf_map_free() is NULL-safe and idempotent and none of them implement bpf_map_free, but a BPF LSM program attached to that hook observes double invocations. Route the denial to free_map instead.
--- kernel/bpf/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/syscall.c +1 -1
@@ -1593,7 +1593,7 @@ static int map_create(union bpf_attr *attr, bpfptr_t uattr) err =security_bpf_map_create (map, attr, token, uattr.is_kernel);if (err) - goto free_map_sec; + goto free_map; err =bpf_map_alloc_id (map);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/1518 iommu/msm: Return -ENOMEM on memory allocation failure in probe
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Zapolskiy <[email protected]>
[ Upstream commit b0d50c9016c4c2959dfa61bf9549cf98f9aa19cd ]
If dynamic memory allocation in driver's probe function execution fails, it should be reported to the driver's framework with -ENOMEM error code.
--- drivers/iommu/msm_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/msm_iommu.c +1 -1
@@ -719,7 +719,7 @@ static int msm_iommu_probe(struct platform_device *pdev) iommu =devm_kzalloc (&pdev->dev,sizeof (*iommu),GFP_KERNEL );if (!iommu) -return -ENODEV ; +return -ENOMEM ; iommu->dev = &pdev->dev;INIT_LIST_HEAD (&iommu->ctx_list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/1518 iommu/amd: Prevent SB IOAPIC from overriding IVRS validation errors
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Wang <[email protected]>
[ Upstream commit 854056480f9217568e3ab5edd81a9347a173ea79 ]
The check_ioapic_information() function validates IOAPICs against the IVRS table to safely disable Interrupt Remapping (IR) if the BIOS provides a broken topology.
Currently, the validation loop contains a bug: If an unmapped secondary IOAPIC is encountered, 'ret' is set to false. But if the Southbridge (SB) IOAPIC is enumerated after it in the MADT, the loop overwrites 'ret' to true.
This bypasses the validation failure and leaves IR enabled. When devices attached to the unmapped secondary IOAPIC fire interrupts, the IOMMU drops them due to the missing Requestor ID, leading to localized device hangs.
Fix this by initializing 'ret' to true and only toggling it to false upon encountering a validation error, ensuring failures are never erased.
--- drivers/iommu/amd/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iommu/amd/init.c +2 -2
@@ -3103,7 +3103,7 @@ static bool __init check_ioapic_information(void)int idx; has_sb_ioapic = false; - ret = false; + ret = true;/* * If we have map overrides on the kernel command line the
@@ -3123,7 +3123,6 @@ static bool __init check_ioapic_information(void) ret = false; }else if (devid ==IOAPIC_SB_DEVID ) { has_sb_ioapic = true; - ret = true; } }
@@ -3137,6 +3136,7 @@ static bool __init check_ioapic_information(void)* device id for the IOAPIC in the system. */ pr_err ("%s: No southbridge IOAPIC found\n" , fw_bug); + ret = false; }if (!ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/1518 iommu/amd: Add support for Hygon family 18h model 4h IOAPIC
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fu Hao <[email protected]>
[ Upstream commit 5beda8cadb1f072140e58b1edb7604444a42d955 ]
The SB IOAPIC is on the device 0xb from Hygon family 18h model 4h.
Stable-dep-of: 04fee302fac7 ("iommu/amd: Fix false positive in SB IOAPIC IVRS validation")
--- drivers/iommu/amd/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/iommu/amd/init.c +9 -1
@@ -3096,6 +3096,9 @@ static void __init free_iommu_resources(void)/* SB IOAPIC is always on this device in AMD systems */ #define IOAPIC_SB_DEVID ((0x00 << 8) | PCI_DEVFN(0x14, 0)) +/* SB IOAPIC for Hygon family 18h model 4h is on the device 0xb */ +#define IOAPIC_SB_DEVID_FAM18H_M4H ((0x00 << 8) | PCI_DEVFN(0xb, 0)) +static bool __init check_ioapic_information (void ) {const char *fw_bug =FW_BUG ;
@@ -3121,7 +3124,12 @@ static bool __init check_ioapic_information(void)pr_err ("%s: IOAPIC[%d] not in IVRS table\n" , fw_bug, id); ret = false; - }else if (devid ==IOAPIC_SB_DEVID ) { + }else if (devid ==IOAPIC_SB_DEVID || + (boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON && + boot_cpu_data.x86 ==0x18 && + boot_cpu_data.x86_model >=0x4 && + boot_cpu_data.x86_model <=0xf && + devid ==IOAPIC_SB_DEVID_FAM18H_M4H )) { has_sb_ioapic = true; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/1518 iommu/amd: Fix false positive in SB IOAPIC IVRS validation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Wang <[email protected]>
[ Upstream commit 04fee302fac762a242ff1ad6810cff90c2a350ba ]
The check_ioapic_information() function is designed to prevent boot hangs by ensuring the Southbridge (SB) IOAPIC is properly mapped in the IVRS table before enabling Interrupt Remapping.
Currently, this check passes if *any* enumerated IOAPIC matches the expected SB IOAPIC device ID. If a buggy BIOS incorrectly assigns the SB IOAPIC's device ID to a secondary IOAPIC in the IVRS, while scrambling the true SB IOAPIC's mapping, the check hits a false positive and succeeds.
This erroneously enables Interrupt Remapping. Consequently, the IOMMU blocks unmapped interrupts from the actual SB IOAPIC, dropping the system timer and leading to a silent kernel boot hang.
Tighten the validation to verify the device ID specifically against the SB IOAPIC by matching their APIC IDs first. This prevents the validation check from being bypassed via device ID aliasing.
--- drivers/iommu/amd/init.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
drivers/iommu/amd/init.c +28 -4
@@ -3099,11 +3099,25 @@ static void __init free_iommu_resources(void)/* SB IOAPIC for Hygon family 18h model 4h is on the device 0xb */ #define IOAPIC_SB_DEVID_FAM18H_M4H ((0x00 << 8) | PCI_DEVFN(0xb, 0)) +/* +* The Southbridge IOAPIC is assigned a GSI Base of 0 (handling interrupts +* 0 through 23). +*/ +static int __init get_sb_ioapic_id (void ) +{ +int idx =mp_find_ioapic (0 ); + +if (idx <0 ) +return -ENODEV ; + +return mpc_ioapic_id (idx); +} +static bool __init check_ioapic_information (void ) {const char *fw_bug =FW_BUG ;bool ret, has_sb_ioapic; -int idx; +int idx, sb_apicid; has_sb_ioapic = false; ret = true;
@@ -3116,6 +3130,16 @@ static bool __init check_ioapic_information(void)if (cmdline_maps) fw_bug ="" ; + sb_apicid =get_sb_ioapic_id (); +if (sb_apicid <0 ) { +/* +* Lack of SB IOAPIC registration is not a firmware bug, +* e.g. kernel booted with noapic or noacpi. +*/ + fw_bug ="" ; + goto out; + } +for (idx =0 ; idx < nr_ioapics; idx++) {int devid, id =mpc_ioapic_id (idx);
@@ -3124,16 +3148,16 @@ static bool __init check_ioapic_information(void)pr_err ("%s: IOAPIC[%d] not in IVRS table\n" , fw_bug, id); ret = false; - }else if (devid ==IOAPIC_SB_DEVID || + }else if (id == sb_apicid && (devid ==IOAPIC_SB_DEVID || (boot_cpu_data.x86_vendor ==X86_VENDOR_HYGON && boot_cpu_data.x86 ==0x18 && boot_cpu_data.x86_model >=0x4 && boot_cpu_data.x86_model <=0xf && - devid ==IOAPIC_SB_DEVID_FAM18H_M4H )) { + devid ==IOAPIC_SB_DEVID_FAM18H_M4H ))) { has_sb_ioapic = true; } } - +out:if (!has_sb_ioapic) {/* * We expect the SB IOAPIC to be listed in the IVRS
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/1518 leds: pca9532: Fix inverted GPIO output polarity
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cosmo Chou <[email protected]>
[ Upstream commit 65a38a28a0b04af19a5e1fbf3869051412eeac96 ]
The pca9532_gpio_set_value() function incorrectly mapped the requested value to PCA9532_ON and PCA9532_OFF, inverting the GPIO output polarity. A requested logical high (val=1) incorrectly enabled the LED output driver, which on this open-drain device pulls the pin low, while a requested logical low (val=0) released the pin.
Correct the mapping so that val=1 yields PCA9532_OFF (pin released / high-impedance) and val=0 yields PCA9532_ON (pin driven low).
pca9532_gpio_direction_input() is also updated to pass val=1 to pca9532_gpio_set_value() to align with the corrected polarity mapping, ensuring the pin remains not driven when configured as an input.
--- drivers/leds/leds-pca9532.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/leds/leds-pca9532.c +3 -3
@@ -325,9 +325,9 @@ static int pca9532_gpio_set_value(struct gpio_chip *gc, unsigned int offset,struct pca9532_led *led = &data->leds[offset];if (val) - led->state =PCA9532_ON ; -else led->state =PCA9532_OFF ; +else + led->state =PCA9532_ON ;pca9532_setled (led);
@@ -347,7 +347,7 @@ static int pca9532_gpio_get_value(struct gpio_chip *gc, unsigned offset)static int pca9532_gpio_direction_input (struct gpio_chip *gc,unsigned offset) {/* To use as input ensure pin is not driven */ -pca9532_gpio_set_value (gc, offset,0 ); +pca9532_gpio_set_value (gc, offset,1 );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/1518 leds: st1202: Stop pattern sequence before reprogramming
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit 9c019a8cb95d820e0bd03e75cfbad2c5b13941b7 ]
The LED1202 datasheet (section 4.8) states that modifications to the Pattern Sequence Repetition register (PAT_REP) and pattern duration registers are only applied after the sequence has completed or been stopped. When the device is running in infinite loop mode (PAT_REP = 0xFF) the sequence never completes on its own, so these writes are silently ignored by the hardware.
Neither pattern_clear() nor pattern_set() stop the running sequence before modifying pattern registers, causing any subsequent pattern reprogramming to have no effect when the previous pattern was set to infinite repeat.
Fix this by clearing PATS in the Configuration register before touching any pattern registers in both functions, ensuring the hardware accepts the new values immediately.
Note that the LED1202 has a single global pattern sequencer shared by all channels: PATS, PATSR, the duration registers, and PAT_REP are chip-wide. Stopping the sequencer in pattern_clear() therefore halts any pattern running on other channels. This is an inherent hardware constraint; pattern_set() restarts the sequencer when a new pattern is programmed.
--- drivers/leds/leds-st1202.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/leds/leds-st1202.c +8 -0
@@ -201,6 +201,10 @@ static int st1202_led_pattern_clear(struct led_classdev *ldev)guard (mutex)(&chip->lock); + ret =st1202_write_reg (chip,ST1202_CONFIG_REG ,ST1202_CONFIG_REG_SHFT ); +if (ret !=0 ) +return ret; +for (int patt =0 ; patt <ST1202_MAX_PATTERNS ; patt++) { ret =st1202_pwm_pattern_write (chip, led->led_num, patt,LED_OFF );if (ret !=0 )
@@ -227,6 +231,10 @@ static int st1202_led_pattern_set(struct led_classdev *ldev,guard (mutex)(&chip->lock); + ret =st1202_write_reg (chip,ST1202_CONFIG_REG ,ST1202_CONFIG_REG_SHFT ); +if (ret !=0 ) +return ret; +for (int patt =0 ; patt < len; patt++) {if (pattern[patt].delta_t <ST1202_MILLIS_PATTERN_DUR_MIN || pattern[patt].delta_t >ST1202_MILLIS_PATTERN_DUR_MAX )
Signature · 1 line
2.53.0
Re: [PATCH 6.18 0286/1518] leds: st1202: Stop pattern sequence before reprogramming
Quoted 9 lines · Greg Kroah-Hartman
6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit
9c019a8cb95d820e0bd03e75cfbad2c5b13941b7]
Please note that this patch was part of the following series:
The testing I carried out on real hardware included the complete series, including upstream commit fd2529ba8fb44cd4b56f1069363b949644b42cec, "leds: st1202: Validate pattern input before stopping the sequence".
That patch did not carry a Fixes: tag, as I considered it an improvement rather than a fix in its own right.
I do not anticipate any issues with the series being applied without that commit, but I have not tested that configuration. I therefore wanted to make you aware of this, in case you consider it advisable to backport fd2529ba8f as well.
The same applies to all of the following proposed backports, including this one. I am not going to respond to each individually, to avoid unnecessary mailing list traffic:
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
https://lore.kernel.org/stable/[email protected]/T/#u
Signature · 1 line
Manuel Fombuena
Sasha Levin
maintainerRe: [PATCH 6.18 0286/1518] leds: st1202: Stop pattern sequence before reprogramming
Quoted 3 lines
The testing I carried out on real hardware included the complete series, including upstream commit
fd2529ba8fb44cd4b56f1069363b949644b42cec, "leds: st1202: Validate pattern input before stopping the sequence".
Thanks for pointing it out, that is worth having. Queued for 7.2 and 6.18, so the series matches what you tested.
Signature · 2 lines
Thanks, Sasha
Greg Kroah-Hartman
maintainerPATCH 287/1518 leds: st1202: Fix pattern duration prescaler and pattern_clear skip marker
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit d32f8bdc2b417a3013e1316a54a0b314f973bbc1 ]
The PATy_DUR register encodes duration as N × 22.2 ms, with register value 0 reserved as a pattern skip indicator (§7.10). The driver incorrectly subtracted 1 from the register value:
value / ST1202_MILLIS_PATTERN_DUR_MIN - 1
This caused two problems:
- All programmed durations were off by one step (~22 ms too short).
- Writing the minimum duration (22 ms) produced register value 0, silently skipping the pattern step instead of setting a 22 ms duration.
The maximum duration constant was also wrong at 5660 ms. The 8-bit register saturates at 255, giving a maximum of 5610 ms (22 ms × 255). Values above 5653 ms were already producing a uint8_t overflow and writing 0 to the hardware.
Fix the formula by removing the erroneous subtraction, and derive the maximum from the register width so the relationship is explicit. Update the documentation to reflect the correct maximum.
This exposes a secondary issue: pattern_clear() was calling st1202_duration_pattern_write() with ST1202_MILLIS_PATTERN_DUR_MIN to reset unused slots, accidentally relying on the broken formula to produce register value 0. With the corrected formula, the same call writes 0x01 (22 ms), leaving unused slots as valid 22 ms zero-PWM steps and making the LED appear off for 7 × 22 ms out of every cycle.
Write 0 directly to the duration registers in pattern_clear() so unused slots are always explicitly marked as skip, independently of the conversion formula.
--- Documentation/leds/leds-st1202.rst | 2 +- drivers/leds/leds-st1202.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
Documentation/leds/leds-st1202.rst +1 -1
@@ -17,7 +17,7 @@ To be compatible with the hardware pattern format, maximum 8 tuples of brightness (PWM) and duration must be written to hw_pattern. - Min pattern duration: 22 ms -- Max pattern duration: 5660 ms +- Max pattern duration: 5610 ms The format of the hardware pattern values should be: "brightness duration brightness duration ..."
drivers/leds/leds-st1202.c +3 -3
@@ -32,7 +32,7 @@#define ST1202_ILED_REG0 0x09#define ST1202_MAX_LEDS 12#define ST1202_MAX_PATTERNS 8 -#define ST1202_MILLIS_PATTERN_DUR_MAX 5660 +#define ST1202_MILLIS_PATTERN_DUR_MAX (ST1202_MILLIS_PATTERN_DUR_MIN * U8_MAX)#define ST1202_MILLIS_PATTERN_DUR_MIN 22#define ST1202_PATTERN_DUR 0x16#define ST1202_PATTERN_PWM 0x1E
@@ -86,7 +86,7 @@ static int st1202_write_reg(struct st1202_chip *chip, int reg, uint8_t val)static uint8_t st1202_prescalar_to_miliseconds (unsigned int value) { -return value /ST1202_MILLIS_PATTERN_DUR_MIN -1 ; +return value /ST1202_MILLIS_PATTERN_DUR_MIN ; } static int st1202_pwm_pattern_write(struct st1202_chip *chip, int led_num,
@@ -210,7 +210,7 @@ static int st1202_led_pattern_clear(struct led_classdev *ldev)if (ret !=0 )return ret; - ret =st1202_duration_pattern_write (chip, patt,ST1202_MILLIS_PATTERN_DUR_MIN ); + ret =st1202_write_reg (chip,ST1202_PATTERN_DUR + patt,0 );if (ret !=0 )return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/1518 leds: st1202: Fix spurious pattern sequence start in setup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit dcc31246aaf0d330a3ba9a725f56c33e6d634caa ]
st1202_setup() writes PATS and PATSR to the Configuration register as its final step, which starts the hardware pattern sequencer during device probe before any patterns have been programmed. This causes the device to run a sequence with whatever values happen to be in the pattern registers at the time.
Remove the write. The device reset at the start of setup restores all registers to their power-on defaults, leaving PATS and PATSR cleared.
--- drivers/leds/leds-st1202.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/leds/leds-st1202.c +0 -5
@@ -331,11 +331,6 @@ static int st1202_setup(struct st1202_chip *chip)if (ret <0 )return ret; - ret =st1202_write_reg (chip,ST1202_CONFIG_REG , -ST1202_CONFIG_REG_PATS |ST1202_CONFIG_REG_PATSR ); -if (ret <0 ) -return ret; -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/1518 leds: st1202: Set all pattern PWM slots to full after clearing pattern
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit d2ca0e2b6d6430f9c60bb2e0ee0b2b3dc4e5d86a ]
pattern_clear() sets all PWM registers for the channel to LED_OFF (0). In static mode (PATS=0), the LED output is ILED x Pattern0_PWM / 4095; with Pattern0 at zero the LED remains dark regardless of the ILED value.
The LED1202 has a single global sequencer shared across all channels. If another channel starts the sequencer after this one has been cleared, the cleared channel runs through all 8 steps at zero duty cycle and stays dark regardless of ILED.
Set all 8 PWM slots to ST1202_PATTERN_PWM_FULL so that ILED alone controls the channel brightness in both static and sequencer modes.
Stable-dep-of: 7cbe470366bd ("leds: st1202: Fix brightness having no effect while pattern mode is active")
--- drivers/leds/leds-st1202.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/leds/leds-st1202.c +2 -1
@@ -36,6 +36,7 @@#define ST1202_MILLIS_PATTERN_DUR_MIN 22#define ST1202_PATTERN_DUR 0x16#define ST1202_PATTERN_PWM 0x1E +#define ST1202_PATTERN_PWM_FULL 0x0FFF#define ST1202_PATTERN_REP 0x15struct st1202_led {
@@ -206,7 +207,7 @@ static int st1202_led_pattern_clear(struct led_classdev *ldev)return ret;for (int patt =0 ; patt <ST1202_MAX_PATTERNS ; patt++) { - ret =st1202_pwm_pattern_write (chip, led->led_num, patt,LED_OFF ); + ret =st1202_pwm_pattern_write (chip, led->led_num, patt,ST1202_PATTERN_PWM_FULL );if (ret !=0 )return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/1518 leds: st1202: Fix brightness having no effect while pattern mode is active
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit 7cbe470366bdd43c7e8114fb2c4d74fa69093121 ]
Once a hardware pattern is running (PATS=1), writing to the brightness sysfs attribute only updates the ILED register. The visible output is ILED x Pattern_PWM / 4095, so the change has little effect and the LED never returns to steady static operation as the user expects.
The LED1202 has a single global sequencer shared across all channels. Stopping it in brightness_set() to force static mode would halt running patterns on all other active LEDs.
Instead, set all 8 PWM slots for the channel to ST1202_PATTERN_PWM_FULL before writing ILED. With every step at full duty cycle, the output is ILED x FULL / 4095 = ILED regardless of the sequencer state, without disturbing other channels.
This also enables basic LED operation without the pattern trigger: with the trigger set to none, the brightness sysfs attribute fully controls the LED as a simple on/off device.
--- drivers/leds/leds-st1202.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/leds/leds-st1202.c +2 -0
@@ -137,6 +137,8 @@ static void st1202_brightness_set(struct led_classdev *led_cdev,guard (mutex)(&chip->lock); +for (int patt =0 ; patt <ST1202_MAX_PATTERNS ; patt++) +st1202_pwm_pattern_write (chip, led->led_num, patt,ST1202_PATTERN_PWM_FULL );st1202_write_reg (chip,ST1202_ILED_REG0 + led->led_num, value); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/1518 leds: st1202: Disable channel when brightness is set to zero
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit 0767335233a8cbab00bbe260a4e4bd380c7677fd ]
When brightness_set() is called with LED_OFF, only the ILED register is zeroed; the channel enable bit is left set from probe time. A hardware channel enabled with ILED=0 still draws a small residual current, causing a dim glow even when the LED is supposed to be off.
Fix this by splitting st1202_channel_set() into a lockless inner function __st1202_channel_set() and a locking wrapper, then calling the inner function from brightness_set() while it already holds the mutex. The channel is now disabled when value is zero and re-enabled when non-zero, in the same lock region as the ILED write.
--- drivers/leds/leds-st1202.c | 68 ++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 29 deletions(-)
drivers/leds/leds-st1202.c +39 -29
@@ -129,39 +129,11 @@ static int st1202_duration_pattern_write(struct st1202_chip *chip, int pattern, st1202_prescalar_to_miliseconds(value)); } -static void st1202_brightness_set (struct led_classdev *led_cdev, -enum led_brightness value) -{ -struct st1202_led *led =cdev_to_st1202_led (led_cdev); -struct st1202_chip *chip = led->chip; - -guard (mutex)(&chip->lock); - -for (int patt =0 ; patt <ST1202_MAX_PATTERNS ; patt++) -st1202_pwm_pattern_write (chip, led->led_num, patt,ST1202_PATTERN_PWM_FULL ); -st1202_write_reg (chip,ST1202_ILED_REG0 + led->led_num, value); -} - -static enum led_brightness st1202_brightness_get (struct led_classdev *led_cdev) -{ -struct st1202_led *led =cdev_to_st1202_led (led_cdev); -struct st1202_chip *chip = led->chip; -u8 value =0 ; - -guard (mutex)(&chip->lock); - -st1202_read_reg (chip,ST1202_ILED_REG0 + led->led_num, &value); - -return value; -} - -static int st1202_channel_set (struct st1202_chip *chip,int led_num,bool active) +static int __st1202_channel_set (struct st1202_chip *chip,int led_num,bool active) {u8 chan_low, chan_high;int ret; -guard (mutex)(&chip->lock); -if (led_num <=7 ) { ret =st1202_read_reg (chip,ST1202_CHAN_ENABLE_LOW , &chan_low);if (ret <0 )
@@ -189,6 +161,40 @@ static int st1202_channel_set(struct st1202_chip *chip, int led_num, bool activereturn 0 ; } +static int st1202_channel_set (struct st1202_chip *chip,int led_num,bool active) +{ +guard (mutex)(&chip->lock); + +return __st1202_channel_set (chip, led_num, active); +} + +static void st1202_brightness_set (struct led_classdev *led_cdev, +enum led_brightness value) +{ +struct st1202_led *led =cdev_to_st1202_led (led_cdev); +struct st1202_chip *chip = led->chip; + +guard (mutex)(&chip->lock); + +for (int patt =0 ; patt <ST1202_MAX_PATTERNS ; patt++) +st1202_pwm_pattern_write (chip, led->led_num, patt,ST1202_PATTERN_PWM_FULL ); +st1202_write_reg (chip,ST1202_ILED_REG0 + led->led_num, value); +__st1202_channel_set (chip, led->led_num, !!value); +} + +static enum led_brightness st1202_brightness_get (struct led_classdev *led_cdev) +{ +struct st1202_led *led =cdev_to_st1202_led (led_cdev); +struct st1202_chip *chip = led->chip; +u8 value =0 ; + +guard (mutex)(&chip->lock); + +st1202_read_reg (chip,ST1202_ILED_REG0 + led->led_num, &value); + +return value; +} +static int st1202_led_set (struct led_classdev *ldev,enum led_brightness value) {struct st1202_led *led =cdev_to_st1202_led (ldev);
@@ -256,6 +262,10 @@ static int st1202_led_pattern_set(struct led_classdev *ldev,if (ret !=0 )return ret; + ret =__st1202_channel_set (chip, led->led_num, true); +if (ret !=0 ) +return ret; + ret =st1202_write_reg (chip,ST1202_CONFIG_REG , (ST1202_CONFIG_REG_PATSR |ST1202_CONFIG_REG_PATS |ST1202_CONFIG_REG_SHFT ));if (ret !=0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/1518 leds: st1202: Validate LED reg property against channel count
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manuel Fombuena <[email protected]>
[ Upstream commit cf197514bdfd3877f42b5dce1efd40b7b686547e ]
The reg property from the device tree is used directly as an array index into chip->leds[] without bounds checking. A value >= ST1202_MAX_LEDS would cause an out-of-bounds write during probe.
--- drivers/leds/leds-st1202.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/leds/leds-st1202.c +7 -1
@@ -278,13 +278,19 @@ static int st1202_dt_init(struct st1202_chip *chip) {struct device *dev = &chip->client->dev;struct st1202_led *led; -int err, reg; +int err; +u32 reg;for_each_available_child_of_node_scoped (dev_of_node (dev), child) { err =of_property_read_u32 (child,"reg" , ®);if (err)return dev_err_probe (dev, err,"Invalid register\n" ); +if (reg >=ST1202_MAX_LEDS ) +return dev_err_probe (dev, -EINVAL , +"LED reg %u out of range [0, %d]\n" , + reg,ST1202_MAX_LEDS -1 ); + led = &chip->leds[reg]; led->is_active = true; led->fwnode =of_fwnode_handle (child);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/1518 printk: Introduce console_flush_one_record
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Murray <[email protected]>
[ Upstream commit 741ea7aa95dd9ac77f861e7d0961d8d231ac8448 ]
console_flush_all prints all remaining records to all usable consoles whilst its caller holds console_lock. This can result in large waiting times for those waiting for console_lock especially where there is a large volume of records or where the console is slow (e.g. serial).
Let's extract the parts of this function which print a single record into a new function named console_flush_one_record. This can later be used for functions that will release and reacquire console_lock between records.
This commit should not change existing functionality.
Stable-dep-of: 36630cafbeed ("printk: Fix possible console use-after-free")
--- kernel/printk/printk.c | 158 ++++++++++++++++++++++++++--------------- 1 file changed, 99 insertions(+), 59 deletions(-)
kernel/printk/printk.c +99 -59
@@ -3155,6 +3155,99 @@ static inline void printk_kthreads_check_locked(void) { }#endif /* CONFIG_PRINTK */ + +/* +* Print out one record for each console. +* +* @do_cond_resched is set by the caller. It can be true only in schedulable +* context. +* +* @next_seq is set to the sequence number after the last available record. +* The value is valid only when there is at least one usable console and all +* usable consoles were flushed. +* +* @handover will be set to true if a printk waiter has taken over the +* console_lock, in which case the caller is no longer holding the +* console_lock. Otherwise it is set to false. +* +* @any_usable will be set to true if there are any usable consoles. +* +* Returns true when there was at least one usable console and a record was +* flushed. A returned false indicates there were no records to flush for any +* of the consoles. It may also indicate that there were no usable consoles, +* the context has been lost or there is a panic suitation. Regardless the +* reason, the caller should assume it is not useful to immediately try again. +* +* Requires the console_lock. +*/ +static bool console_flush_one_record (bool do_cond_resched,u64 *next_seq,bool *handover, +bool *any_usable) +{ +struct console_flush_type ft; +bool any_progress = false; +struct console *con; +int cookie; + +printk_get_console_flush_type (&ft); + + cookie =console_srcu_read_lock (); +for_each_console_srcu (con) { +short flags =console_srcu_read_flags (con); +u64 printk_seq; +bool progress; + +/* +* console_flush_one_record() is only responsible for +* nbcon consoles when the nbcon consoles cannot print via +* their atomic or threaded flushing. +*/ +if ((flags &CON_NBCON ) && (ft.nbcon_atomic || ft.nbcon_offload)) +continue ; + +if (!console_is_usable (con, flags, !do_cond_resched)) +continue ; + *any_usable = true; + +if (flags &CON_NBCON ) { + progress =nbcon_legacy_emit_next_record (con, handover, cookie, + !do_cond_resched); + printk_seq =nbcon_seq_read (con); + }else { + progress =console_emit_next_record (con, handover, cookie); + printk_seq = con->seq; + } + +/* +* If a handover has occurred, the SRCU read lock +* is already released. +*/ +if (*handover) +return false; + +/* Track the next of the highest seq flushed. */ +if (printk_seq > *next_seq) + *next_seq = printk_seq; + +if (!progress) +continue ; + any_progress = true; + +/* Allow panic_cpu to take over the consoles safely. */ +if (panic_on_other_cpu ()) + goto abandon; + +if (do_cond_resched) +cond_resched (); + } +console_srcu_read_unlock (cookie); + +return any_progress; + +abandon: +console_srcu_read_unlock (cookie); +return false; +} +/* * Print out all remaining records to all consoles. *
@@ -3180,77 +3273,24 @@ static inline void printk_kthreads_check_locked(void) { }*/ static bool console_flush_all (bool do_cond_resched,u64 *next_seq,bool *handover) { -struct console_flush_type ft;bool any_usable = false; -struct console *con;bool any_progress; -int cookie; *next_seq =0 ; *handover = false;do { - any_progress = false; + any_progress =console_flush_one_record (do_cond_resched, next_seq, handover, + &any_usable); -printk_get_console_flush_type (&ft); - - cookie =console_srcu_read_lock (); -for_each_console_srcu (con) { -short flags =console_srcu_read_flags (con); -u64 printk_seq; -bool progress; +if (*handover) +return false; -/* -* console_flush_all() is only responsible for nbcon -* consoles when the nbcon consoles cannot print via -* their atomic or threaded flushing. -*/ -if ((flags &CON_NBCON ) && (ft.nbcon_atomic || ft.nbcon_offload)) -continue ; - -if (!console_is_usable (con, flags, !do_cond_resched)) -continue ; - any_usable = true; - -if (flags &CON_NBCON ) { - progress =nbcon_legacy_emit_next_record (con, handover, cookie, - !do_cond_resched); - printk_seq =nbcon_seq_read (con); - }else { - progress =console_emit_next_record (con, handover, cookie); - printk_seq = con->seq; - } - -/* -* If a handover has occurred, the SRCU read lock -* is already released. -*/ -if (*handover) -return false; - -/* Track the next of the highest seq flushed. */ -if (printk_seq > *next_seq) - *next_seq = printk_seq; - -if (!progress) -continue ; - any_progress = true; - -/* Allow panic_cpu to take over the consoles safely. */ -if (panic_on_other_cpu ()) - goto abandon; - -if (do_cond_resched) -cond_resched (); - } -console_srcu_read_unlock (cookie); +if (panic_on_other_cpu ()) +return false; }while (any_progress);return any_usable; - -abandon: -console_srcu_read_unlock (cookie); -return false; }static void __console_flush_and_unlock (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/1518 printk: Fix possible console use-after-free
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 36630cafbeede0b64c370edb2f7b4094327ee1e0 ]
When emitting a record via legacy printing, it is possible that a handover to another legacy printing context occurs. When a context has performed a handover, the console SRCU read lock is released and the pointer to the console struct might now be invalid. Therefore, after calling nbcon_legacy_emit_next_record() or console_emit_next_record(), it is necessary to check if a handover occurred _before_ further @con usage.
Sashiko pointed out that console_flush_one_record() was not doing this.
In console_flush_one_record(), after emitting a record, move the further usage of @con after the handover check.
--- kernel/printk/printk.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
kernel/printk/printk.c +9 -2
@@ -3211,10 +3211,8 @@ static bool console_flush_one_record(bool do_cond_resched, u64 *next_seq, bool *if (flags &CON_NBCON ) { progress =nbcon_legacy_emit_next_record (con, handover, cookie, !do_cond_resched); - printk_seq =nbcon_seq_read (con); }else { progress =console_emit_next_record (con, handover, cookie); - printk_seq = con->seq; }/*
@@ -3224,6 +3222,15 @@ static bool console_flush_one_record(bool do_cond_resched, u64 *next_seq, bool *if (*handover)return false; +/* +* @con can be used here now that it is certain that this +* context is still holding the SRCU read lock. +*/ +if (flags &CON_NBCON ) + printk_seq =nbcon_seq_read (con); +else + printk_seq = con->seq; +/* Track the next of the highest seq flushed. */ if (printk_seq > *next_seq) *next_seq = printk_seq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/1518 ACPI: RISC-V: Fix riscv_acpi_irq_get_dep() loop termination
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Pieralisi <[email protected]>
[ Upstream commit 64ae310bffa477cd11029c818bec489f4b8a845e ]
In riscv_acpi_add_irq_dep() the main loop condition would currently stop the loop if an interrupt descriptor contains an interrupt for which the respective GSI handle is NULL, which is not correct because subsequent interrupts in the interrupt descriptor might still have a GSI dependency that must not be skipped.
Rework riscv_acpi_add_irq_dep() and the riscv_acpi_irq_get_dep() call chain to fix it - by not forcing the loop to stop in order to guarantee dependency detection for all the interrupt entries in the CRS descriptor.
--- drivers/acpi/riscv/irq.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/acpi/riscv/irq.c +6 -4
@@ -299,6 +299,7 @@ static acpi_status riscv_acpi_irq_get_parent(struct acpi_resource *ares, void *creturn AE_OK ; ctx->handle =riscv_acpi_get_gsi_handle (eirq->interrupts[ctx->index]); + ctx->rc =0 ;return AE_CTRL_TERMINATE ; }
@@ -314,10 +315,8 @@ static int riscv_acpi_irq_get_dep(acpi_handle handle, unsigned int index, acpi_hacpi_walk_resources (handle,METHOD_NAME__CRS , riscv_acpi_irq_get_parent, &ctx); *gsi_handle = ctx.handle; -if (*gsi_handle) -return 1 ; -return 0 ; +return ctx.rc; }static u32 riscv_acpi_add_prt_dep (acpi_handle handle)
@@ -379,8 +378,11 @@ static u32 riscv_acpi_add_irq_dep(acpi_handle handle)int i;for (i =0 ; -riscv_acpi_irq_get_dep (handle, i, &gsi_handle); + !riscv_acpi_irq_get_dep (handle, i, &gsi_handle); i++) { +if (!gsi_handle) +continue ; + dep_devices.count =1 ; dep_devices.handles =kcalloc (1 ,sizeof (*dep_devices.handles),GFP_KERNEL );if (!dep_devices.handles) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/1518 ACPI: RISC-V: Check acpi_get_handle() status in riscv_acpi_add_prt_dep()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Pieralisi <[email protected]>
[ Upstream commit 20435bda13f1219891ed0ce41207e320a916ff9c ]
In riscv_acpi_add_prt_dep(), the acpi_get_handle() call can fail which would leave link_handle uninitialized.
Fix it by checking the acpi_get_handle() return status and skip the entry if it fails.
--- drivers/acpi/riscv/irq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/riscv/irq.c +3 -1
@@ -339,7 +339,9 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) entry = buffer.pointer;while (entry && (entry->length >0 )) {if (entry->source[0 ]) { -acpi_get_handle (handle, entry->source, &link_handle); + status =acpi_get_handle (handle, entry->source, &link_handle); +if (ACPI_FAILURE (status)) +continue ; dep_devices.count =1 ; dep_devices.handles =kcalloc (1 ,sizeof (*dep_devices.handles),GFP_KERNEL );if (!dep_devices.handles) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/1518 ACPI: RISC-V: Fix riscv_acpi_add_prt_dep() loop handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Pieralisi <[email protected]>
[ Upstream commit 3a56321d0aceee2a0bd80d23366401c131ff8350 ]
The loop in riscv_acpi_add_prt_dep() includes error conditions that are handled in a dubious - if not outright wrong - way, by continuining the loop (which skips and misses the entry pointer update to point to the next entry).
Rewrite the loop as a for loop (that handles the continuation correctly) and wrap the condition and update statements using helper functions to make it cleaner.
--- drivers/acpi/riscv/irq.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
drivers/acpi/riscv/irq.c +15 -4
@@ -319,6 +319,20 @@ static int riscv_acpi_irq_get_dep(acpi_handle handle, unsigned int index, acpi_hreturn ctx.rc; } +static bool acpi_prt_entry_valid (void *prt_entry) +{ +struct acpi_pci_routing_table *entry = prt_entry; + +return entry && entry->length >0 ; +} + +static void *acpi_prt_next_entry (void *prt_entry) +{ +struct acpi_pci_routing_table *entry = prt_entry; + +return prt_entry + entry->length; +} +static u32 riscv_acpi_add_prt_dep (acpi_handle handle) {struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER ,NULL };
@@ -337,7 +351,7 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) } entry = buffer.pointer; -while (entry && (entry->length >0 )) { +for (;acpi_prt_entry_valid (entry); entry =acpi_prt_next_entry (entry)) {if (entry->source[0 ]) { status =acpi_get_handle (handle, entry->source, &link_handle);if (ACPI_FAILURE (status))
@@ -363,9 +377,6 @@ static u32 riscv_acpi_add_prt_dep(acpi_handle handle) dep_devices.handles[0 ] = gsi_handle; count +=acpi_scan_add_dep (handle, &dep_devices); } - - entry = (struct acpi_pci_routing_table *) - ((unsigned long )entry + entry->length); }kfree (buffer.pointer);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/1518 platform/x86: dell-privacy: Fix race condition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Armin Wolf <[email protected]>
[ Upstream commit ca9338dbc64759b30741b12017c050b33c94dfa2 ]
Accessing priv->features_present needs to happen with the list mutex being held, otherwise priv can be freed at any moment.
--- drivers/platform/x86/dell/dell-wmi-privacy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/dell/dell-wmi-privacy.c +2 -2
@@ -69,11 +69,11 @@ bool dell_privacy_has_mic_mute(void) {struct privacy_wmi_data *priv; -mutex_lock (&list_mutex); +guard (mutex)(&list_mutex); + priv =list_first_entry_or_null (&wmi_list, struct privacy_wmi_data, list); -mutex_unlock (&list_mutex);return priv && (priv->features_present &BIT (DELL_PRIVACY_TYPE_AUDIO )); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/1518 platform/x86: dell-wmi-base: Fix resource leak on module load failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Armin Wolf <[email protected]>
[ Upstream commit 072841e02cf9c00a7e8a9c567a14239e02ca47ad ]
We need to properly clean up the SMBIOS request and the privacy driver when the module load fails.
--- drivers/platform/x86/dell/dell-wmi-base.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/platform/x86/dell/dell-wmi-base.c +15 -2
@@ -851,9 +851,22 @@ static int __init dell_wmi_init(void) err =dell_privacy_register_driver ();if (err) -return err; + goto out_smbios; -return wmi_driver_register (&dell_wmi_driver); + err =wmi_driver_register (&dell_wmi_driver); +if (err) + goto out_privacy; + +return 0 ; + +out_privacy: +dell_privacy_unregister_driver (); + +out_smbios: +if (wmi_requires_smbios_request) +dell_wmi_events_set_enabled (false); + +return err; }late_initcall (dell_wmi_init);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/1518 platform/x86: lg-laptop: Drop debug-only ACPI notify handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit c12fe0b2c12195e0d1c56e0f670a6bd792b0567e ]
To facilitate subsequent conversion of the driver to using struct platform_driver instead of struct acpi_driver, drop the debug-only notify handler method from the driver.
No intentional functional impact beyond debug.
Stable-dep-of: 3e91964aa74a ("platform/x86: lg-laptop: Fix LED resource handling")
--- drivers/platform/x86/lg-laptop.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/platform/x86/lg-laptop.c +0 -6
@@ -269,11 +269,6 @@ static void wmi_input_setup(void) } } -static void acpi_notify (struct acpi_device *device,u32 event) -{ -acpi_handle_debug (device->handle,"notify: %d\n" , event); -} -static ssize_t fan_mode_store (struct device *dev,struct device_attribute *attr,const char *buffer,size_t count)
@@ -886,7 +881,6 @@ static struct acpi_driver acpi_driver = { .ops = { .add = acpi_add, .remove = acpi_remove, - .notify = acpi_notify, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/1518 platform/x86: lg-laptop: Convert ACPI driver to a platform one
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 2d9cb20610f75ca48c1cac064aede90196787507 ]
In all cases in which a struct acpi_driver is used for binding a driver to an ACPI device object, a corresponding platform device is created by the ACPI core and that device is regarded as a proper representation of underlying hardware. Accordingly, a struct platform_driver should be used by driver code to bind to that device. There are multiple reasons why drivers should not bind directly to ACPI device objects [1].
Overall, it is better to bind drivers to platform devices than to their ACPI companions, so convert the LG Gram ACPI features and hotkeys driver from an ACPI driver to a platform one.
While this is not expected to alter functionality, it changes sysfs layout and so it will be visible to user space.
Stable-dep-of: 3e91964aa74a ("platform/x86: lg-laptop: Fix LED resource handling")
--- drivers/platform/x86/lg-laptop.c | 45 +++++++++----------------------- 1 file changed, 13 insertions(+), 32 deletions(-)
drivers/platform/x86/lg-laptop.c +13 -32
@@ -748,8 +748,9 @@ static void lg_laptop_remove_address_space_handler(void *data) &lg_laptop_address_space_handler); } -static int acpi_add (struct acpi_device *device) +static int acpi_probe (struct platform_device *pdev) { +struct acpi_device *device =ACPI_COMPANION (&pdev->dev);struct platform_device_info pdev_info = { .fwnode =acpi_fwnode_handle (device), .name =PLATFORM_NAME ,
@@ -765,11 +766,11 @@ static int acpi_add(struct acpi_device *device) status =acpi_install_address_space_handler (device->handle,LG_ADDRESS_SPACE_ID , &lg_laptop_address_space_handler, -NULL , &device->dev); +NULL , &pdev->dev);if (ACPI_FAILURE (status))return -ENODEV ; - ret =devm_add_action_or_reset (&device->dev, lg_laptop_remove_address_space_handler, + ret =devm_add_action_or_reset (&pdev->dev, lg_laptop_remove_address_space_handler, device);if (ret <0 )return ret;
@@ -854,7 +855,7 @@ static int acpi_add(struct acpi_device *device)return ret; } -static void acpi_remove (struct acpi_device *device) +static void acpi_remove (struct platform_device *pdev) {sysfs_remove_group (&pf_device->dev.kobj, &dev_attribute_group);
@@ -874,33 +875,13 @@ static const struct acpi_device_id device_ids[] = { };MODULE_DEVICE_TABLE (acpi, device_ids); -static struct acpi_driver acpi_driver = { - .name ="LG Gram Laptop Support" , - .class ="lg-laptop" , - .ids = device_ids, - .ops = { - .add = acpi_add, - .remove = acpi_remove, - }, +static struct platform_driver acpi_driver = { + .probe = acpi_probe, + .remove = acpi_remove, + .driver = { + .name ="LG Gram Laptop Support" , + .acpi_match_table = device_ids, + }, }; -static int __init acpi_init (void ) -{ -int result; - - result =acpi_bus_register_driver (&acpi_driver); -if (result <0 ) { -pr_debug ("Error registering driver\n" ); -return -ENODEV ; - } - -return 0 ; -} - -static void __exit acpi_exit(void) -{ -acpi_bus_unregister_driver (&acpi_driver); -} - -module_init (acpi_init); -module_exit (acpi_exit); +module_platform_driver (acpi_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/1518 platform/x86: lg-laptop: Fix LED resource handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Armin Wolf <[email protected]>
[ Upstream commit 3e91964aa74ab261aa15d9d96318eded2fd9d22a ]
The event notification callback might access kbd_backlight even when it was not successfully registered with the LED subsystem. The same happens inside acpi_remove(), where the LED devices are unregistered unconditionally.
Fix this by tracking the availability of the kbd_backlight LED device and use devm_led_classdev_register() to let devres take care of unregistering the LED devices during removal. For this the parent device of the LED devices is changed to the native platform device.
--- drivers/platform/x86/lg-laptop.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/platform/x86/lg-laptop.c +14 -7
@@ -98,6 +98,7 @@ static u32 inited;#define INIT_SPARSE_KEYMAP 0x80static int battery_limit_use_wmbb; +static bool kbd_backlight_available;static struct led_classdev kbd_backlight;static enum led_brightness get_kbd_backlight_level (struct device *dev);
@@ -212,6 +213,7 @@ static union acpi_object *lg_wmbb(struct device *dev, u32 method_id, u32 arg1, ustatic void wmi_notify (union acpi_object *obj,void *context) {long data = (long )context; +unsigned int brightness;pr_debug ("event guid %li\n" , data);if (!obj)
@@ -222,8 +224,11 @@ static void wmi_notify(union acpi_object *obj, void *context)struct key_entry *key;if (eventcode ==0x10000000 ) { -led_classdev_notify_brightness_hw_changed ( - &kbd_backlight,get_kbd_backlight_level (kbd_backlight.dev->parent)); +if (kbd_backlight_available) { + brightness =get_kbd_backlight_level (kbd_backlight.dev->parent); +led_classdev_notify_brightness_hw_changed (&kbd_backlight, + brightness); + } }else { key =sparse_keymap_entry_from_scancode ( wmi_input_dev, eventcode);
@@ -840,8 +845,13 @@ static int acpi_probe(struct platform_device *pdev) goto out_platform_device;/* LEDs are optional */ -led_classdev_register (&pf_device->dev, &kbd_backlight); -led_classdev_register (&pf_device->dev, &tpad_led); + ret =devm_led_classdev_register (&pdev->dev, &kbd_backlight); +if (ret <0 ) + kbd_backlight_available = false; +else + kbd_backlight_available = true; + +devm_led_classdev_register (&pdev->dev, &tpad_led);wmi_input_setup ();battery_hook_register (&battery_hook);
@@ -859,9 +869,6 @@ static void acpi_remove(struct platform_device *pdev) {sysfs_remove_group (&pf_device->dev.kobj, &dev_attribute_group); -led_classdev_unregister (&tpad_led); -led_classdev_unregister (&kbd_backlight); -battery_hook_unregister (&battery_hook);wmi_input_destroy ();platform_device_unregister (pf_device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/1518 remoteproc: qcom_q6v5_adsp: Fix reference leak for device node
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 8c952807c2cebd5e9e9b37146c9383229794c129 ]
When calling of_parse_phandle_with_args(), the caller is responsible to call of_node_put() to release the reference of device node. In adsp_map_carveout, it does not release the reference.
--- drivers/remoteproc/qcom_q6v5_adsp.c | 1 + 1 file changed, 1 insertion(+)
drivers/remoteproc/qcom_q6v5_adsp.c +1 -0
@@ -355,6 +355,7 @@ static int adsp_map_carveout(struct rproc *rproc)return ret; sid = args.args[0 ] &SID_MASK_DEFAULT ; +of_node_put (args.np);/* Add SID configuration for ADSP Firmware to SMMU */ iova = adsp->mem_phys | (sid <<32 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/1518 hwspinlock: propagate errno when registering single lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit e088ffa9a00eaaaf90da74763e774ca160969c26 ]
hwspin_lock_register_single() always returns 0 despite checking the result from radix_tree_insert(). Propagate the errno to make sanity checks in callers of this function actually meaningful.
--- drivers/hwspinlock/hwspinlock_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwspinlock/hwspinlock_core.c +1 -1
@@ -472,7 +472,7 @@ static int hwspin_lock_register_single(struct hwspinlock *hwlock, int id) out:mutex_unlock (&hwspinlock_tree_lock); -return 0 ; +return ret; }static struct hwspinlock *hwspin_lock_unregister_single (unsigned int id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/1518 selftests/sched_ext: Fix bpf_link leak on early return in prog_run
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Liang Luo <[email protected]>
[ Upstream commit e655c1f1bd14804f398df7da029c4a7e3f9ccd7f ]
In prog_run's run(), the bpf_link is attached early but only destroyed on the success path. The three SCX_EQ assertions between attach and destroy expand to a direct 'return SCX_TEST_FAIL', so if any of them triggers, bpf_link__destroy() is never reached and the BPF scheduler stays loaded. All subsequent tests then fail to attach because SCX is not in the DISABLED state.
Convert those assertions to explicit checks that jump to a unified 'out' label which always runs the cleanup, matching the pattern used in cyclic_kick_wait.c.
--- tools/testing/selftests/sched_ext/prog_run.c | 34 +++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-)
tools/testing/selftests/sched_ext/prog_run.c +26 -8
@@ -28,7 +28,8 @@ static enum scx_test_status setup(void **ctx)static enum scx_test_status run (void *ctx) {struct prog_run *skel = ctx; -struct bpf_link *link; +struct bpf_link *link =NULL ; +enum scx_test_status status =SCX_TEST_PASS ;int prog_fd, err =0 ; prog_fd =bpf_program__fd (skel->progs.prog_run_syscall);
@@ -42,23 +43,40 @@ static enum scx_test_status run(void *ctx) link =bpf_map__attach_struct_ops (skel->maps.prog_run_ops);if (!link) {SCX_ERR ("Failed to attach scheduler" ); -close (prog_fd); -return SCX_TEST_FAIL ; + status =SCX_TEST_FAIL ; + goto out; } err =bpf_prog_test_run_opts (prog_fd, &topts); -SCX_EQ (err,0 ); +if (err) { +SCX_ERR ("BPF_PROG_RUN failed (%d)" , err); + status =SCX_TEST_FAIL ; + goto out; + }/* Assumes uei.kind is written last */ while (skel->data->uei.kind ==EXIT_KIND (SCX_EXIT_NONE ))sched_yield (); -SCX_EQ (skel->data->uei.kind,EXIT_KIND (SCX_EXIT_UNREG_BPF )); -SCX_EQ (skel->data->uei.exit_code,0xdeadbeef ); +if (skel->data->uei.kind !=EXIT_KIND (SCX_EXIT_UNREG_BPF )) { +SCX_ERR ("Unexpected exit kind: %llu" , + (unsigned long long )skel->data->uei.kind); + status =SCX_TEST_FAIL ; + goto out; + } +if (skel->data->uei.exit_code !=0xdeadbeef ) { +SCX_ERR ("Unexpected exit code: %lld" , + (long long )skel->data->uei.exit_code); + status =SCX_TEST_FAIL ; + goto out; + } + +out:close (prog_fd); -bpf_link__destroy (link); +if (link) +bpf_link__destroy (link); -return SCX_TEST_PASS ; +return status; }static void cleanup (void *ctx)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/1518 perf capstone: Fix kernel map reference count leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tengda Wu <[email protected]>
[ Upstream commit d3c9fca531e2465f3a8f585965f3d10e1a6595ff ]
In print_capstone_detail(), maps__find() is used to locate the kernel map. This function increments the reference count of the found map object. However, the current implementation fails to call map__put() after the map is no longer needed, leading to a reference count leak.
Fix this by adding a map__put(map) call to properly release the reference after use.
--- tools/perf/util/capstone.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/perf/util/capstone.c +9 -4
@@ -156,6 +156,7 @@ static void print_capstone_detail(cs_insn *insn, char *buf, size_t len,for (i =0 ; i < insn->detail->x86.op_count; i++) {cs_x86_op *op = &insn->detail->x86.operands[i];u64 orig_addr; +struct map *found_map =NULL ;if (op->type !=X86_OP_MEM )continue ;
@@ -171,19 +172,22 @@ static void print_capstone_detail(cs_insn *insn, char *buf, size_t len,if (dso__kernel (map__dso (map))) {/* * The kernel maps can be split into sections, let's -* find the map first and the search the symbol. +* find the map first and then search the symbol. */ - map =maps__find (map__kmaps (map), addr); -if (map ==NULL ) + found_map =maps__find (map__kmaps (map), addr); +if (found_map ==NULL )continue ; + map = found_map; }/* convert it to map-relative address for search */ addr =map__map_ip (map, addr); sym =map__find_symbol (map, addr); -if (sym ==NULL ) +if (sym ==NULL ) { +map__put (found_map);continue ; + }if (addr == sym->start) { scnprintf(buf, len, "\t# %"PRIx64" <%s>",
@@ -192,6 +196,7 @@ static void print_capstone_detail(cs_insn *insn, char *buf, size_t len,scnprintf (buf, len,"\t# %" PRIx64" <%s+%#" PRIx64">" , orig_addr, sym->name, addr - sym->start); } +map__put (found_map);break ; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/1518 spi: qcom-geni: Fix missing error check on pm_runtime_get_sync()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Praveen Talari <[email protected]>
[ Upstream commit d8e9ea989acb54508477e4a8c9d9eaf8217e0081 ]
spi_geni_init() calls pm_runtime_get_sync() to power up the device before accessing hardware registers, but never checks the return value. If the runtime resume fails, the function silently proceeds to read and write hardware registers on a device that may not be powered up, leading to register access faults.
Fix this by replacing pm_runtime_get_sync() with the PM_RUNTIME_ACQUIRE_IF_ENABLED() macro and checking the result via PM_RUNTIME_ACQUIRE_ERR(), propagating any error back to the caller immediately before any hardware access occurs.
Since the macro handles its own cleanup on failure, the out_pm label and the corresponding pm_runtime_put() call are no longer needed. Replace all goto out_pm paths with direct return ret statements and remove the label entirely.
--- drivers/spi/spi-geni-qcom.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/spi/spi-geni-qcom.c +10 -7
@@ -657,25 +657,30 @@ static int spi_geni_init(struct spi_geni_master *mas)u32 spi_tx_cfg, fifo_disable;int ret = -ENXIO ; -pm_runtime_get_sync (mas->dev); +PM_RUNTIME_ACQUIRE_IF_ENABLED (mas->dev, pm); + ret =PM_RUNTIME_ACQUIRE_ERR (&pm); +if (ret <0 ) { +dev_err (mas->dev,"Failed to resume and get %d\n" , ret); +return ret; + } proto =geni_se_read_proto (se);if (spi->target) {if (proto !=GENI_SE_SPI_SLAVE ) {dev_err (mas->dev,"Invalid proto %d\n" , proto); - goto out_pm; +return ret; }spi_slv_setup (mas); }else if (proto ==GENI_SE_INVALID_PROTO ) { ret =geni_load_se_firmware (se,GENI_SE_SPI );if (ret) {dev_err (mas->dev,"spi master firmware load failed ret: %d\n" , ret); - goto out_pm; +return ret; } }else if (proto !=GENI_SE_SPI ) {dev_err (mas->dev,"Invalid proto %d\n" , proto); - goto out_pm; +return ret; } mas->tx_fifo_depth =geni_se_get_tx_fifo_depth (se);
@@ -708,7 +713,7 @@ static int spi_geni_init(struct spi_geni_master *mas)dev_dbg (mas->dev,"Using GPI DMA mode for SPI\n" );break ; }else if (ret == -EPROBE_DEFER ) { - goto out_pm; +return ret; }/* * in case of failure to get gpi dma channel, we can still do the
@@ -737,8 +742,6 @@ static int spi_geni_init(struct spi_geni_master *mas)writel (spi_tx_cfg, se->base +SE_SPI_TRANS_CFG ); } -out_pm: -pm_runtime_put (mas->dev);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/1518 serial: core: Add dedicated uart_port field for console flow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 9c7eb1c9c3e3bfecb556fc8fa1b68939385444de ]
Currently the UPF_CONS_FLOW bit in the uart_port.flags field is used by serial console drivers to identify if a user has configured flow control on the console. Usually this policy is setup during early boot, but can be changed at runtime.
The bits in uart_port.flags are either hardware and driver properties that are initialized before usage or are properties that can be changed via the tty layer.
The UPF_CONS_FLOW bit is an exception because it is a console-only policy that can change at runtime and its setting and usage have nothing to do with the tty layer. This actually causes a problem for its usage because uart_port.flags is synchronized by a related tty_port.mutex, but a console has no relation to a tty (other than sharing the port).
This is probably why console flow control is not properly available for most serial drivers. And it is hindering being able to provide a proper implementation. Commit d01f4d181c92 ("serial: core: Privatize tty->hw_stopped") addressed a similar issue to deal with software assisted CTS flow state tracking.
Add a new uart_port boolean field "cons_flow" to store the user configuration for console flow control. Add getter/setter wrappers to allow for adding more policies later and/or locking constraint validation.
Mark UPF_CONS_FLOW as deprecated.
Stable-dep-of: d338ab1d9060 ("serial: 8250: Clear CON_PRINTBUFFER on port re-registration")
--- include/linux/serial_core.h | 12 ++++++++++++ 1 file changed, 12 insertions(+)
include/linux/serial_core.h +12 -0
@@ -533,6 +533,7 @@ struct uart_port {#define UPF_HARD_FLOW ((__force upf_t) (UPF_AUTO_CTS | UPF_AUTO_RTS))/* Port has hardware-assisted s/w flow control */ #define UPF_SOFT_FLOW ((__force upf_t) BIT_ULL(22)) +/* Deprecated: use uart_set_cons_flow_enabled()/uart_cons_flow_enabled() instead. */ #define UPF_CONS_FLOW ((__force upf_t) BIT_ULL(23))#define UPF_SHARE_IRQ ((__force upf_t) BIT_ULL(24))#define UPF_EXAR_EFR ((__force upf_t) BIT_ULL(25))
@@ -567,6 +568,7 @@ struct uart_port {#define UPSTAT_SYNC_FIFO ((__force upstat_t) (1 << 5))bool hw_stopped;/* sw-assisted CTS flow state */ +bool cons_flow;/* user specified console flow control */ unsigned int mctrl;/* current modem ctrl settings */ unsigned int frame_time;/* frame timing in ns */ unsigned int type;/* port type */
@@ -1163,6 +1165,16 @@ static inline bool uart_softcts_mode(struct uart_port *uport)return ((uport->status & mask) ==UPSTAT_CTS_ENABLE ); } +static inline void uart_set_cons_flow_enabled (struct uart_port *uport,bool enabled) +{ + uport->cons_flow = enabled; +} + +static inline bool uart_cons_flow_enabled (const struct uart_port *uport) +{ +return uport->cons_flow; +} +/* * The following are helper functions for the low level drivers. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/1518 serial: Replace driver usage of UPF_CONS_FLOW
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit bf558715d91cfa28f283de7105a879a92da31fb7 ]
Rather than using the UPF_CONS_FLOW bit of uart_port.flags to track the user configuration of console flow control, use the newly added uart_port.cons_flow (via its getter/setter functions).
A coccinelle script was used to perform the search/replace.
Note1: The sh-sci driver is blindly copying platform data configuration
flags to uart_port.flags. Thus UPF_CONS_FLOW could get set for uart_port.flags. A follow-up commit will address this.
Note2: The samsung_tty driver is using UPF_CONS_FLOW as a platform data
configuration flag. However, the driver explicitly checks for this configuration flag and thus setting UPF_CONS_FLOW in uart_port.flags is avoided.
Stable-dep-of: d338ab1d9060 ("serial: 8250: Clear CON_PRINTBUFFER on port re-registration")
--- drivers/tty/serial/8250/8250_port.c | 4 ++-- drivers/tty/serial/bcm63xx_uart.c | 2 +- drivers/tty/serial/omap-serial.c | 2 +- drivers/tty/serial/pch_uart.c | 2 +- drivers/tty/serial/pxa.c | 2 +- drivers/tty/serial/samsung_tty.c | 8 ++++---- drivers/tty/serial/serial_txx9.c | 4 ++-- drivers/tty/serial/sunsu.c | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-)
drivers/tty/serial/8250/8250_port.c +2 -2
@@ -1991,7 +1991,7 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits)wait_for_lsr (up, bits);/* Wait up to 1s for flow control if necessary */ -if (up->port.flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (&up->port)) {for (tmout =1000000 ; tmout; tmout--) {unsigned int msr =serial_in (up,UART_MSR ); up->msr_saved_flags |= msr &MSR_SAVE_FLAGS ;
@@ -3354,7 +3354,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,* it regardless of the CTS state. Therefore, only use fifo * if we don't use control flow. */ - !(up->port.flags &UPF_CONS_FLOW ); + !uart_cons_flow_enabled (&up->port);if (likely (use_fifo))serial8250_console_fifo_write (up, s, count);
drivers/tty/serial/bcm63xx_uart.c +1 -1
@@ -675,7 +675,7 @@ static void wait_for_xmitr(struct uart_port *port) }/* Wait up to 1s for flow control if necessary */ -if (port->flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (port)) { tmout =1000000 ;while (--tmout) {unsigned int val;
drivers/tty/serial/omap-serial.c +1 -1
@@ -1092,7 +1092,7 @@ static void __maybe_unused wait_for_xmitr(struct uart_omap_port *up) }while (!uart_lsr_tx_empty (status));/* Wait up to 1s for flow control if necessary */ -if (up->port.flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (&up->port)) {for (tmout =1000000 ; tmout; tmout--) {unsigned int msr =serial_in (up,UART_MSR );
drivers/tty/serial/pch_uart.c +1 -1
@@ -1451,7 +1451,7 @@ static void wait_for_xmitr(struct eg20t_port *up, int bits) }/* Wait up to 1s for flow control if necessary */ -if (up->port.flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (&up->port)) {unsigned int tmout;for (tmout =1000000 ; tmout; tmout--) {unsigned int msr =ioread8 (up->membase +UART_MSR );
drivers/tty/serial/pxa.c +1 -1
@@ -573,7 +573,7 @@ static void wait_for_xmitr(struct uart_pxa_port *up) }while (!uart_lsr_tx_empty (status));/* Wait up to 1s for flow control if necessary */ -if (up->port.flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (&up->port)) { tmout =1000000 ;while (--tmout && ((serial_in (up,UART_MSR ) &UART_MSR_CTS ) ==0 ))
drivers/tty/serial/samsung_tty.c +4 -4
@@ -311,7 +311,7 @@ static void s3c24xx_serial_stop_tx(struct uart_port *port) ourport->tx_enabled =0 ; ourport->tx_in_progress =0 ; -if (port->flags &UPF_CONS_FLOW ) +if (uart_cons_flow_enabled (port))s3c24xx_serial_rx_enable (port); ourport->tx_mode =0 ;
@@ -485,7 +485,7 @@ static void s3c24xx_serial_start_tx(struct uart_port *port)struct tty_port *tport = &port->state->port;if (!ourport->tx_enabled) { -if (port->flags &UPF_CONS_FLOW ) +if (uart_cons_flow_enabled (port))s3c24xx_serial_rx_disable (port); ourport->tx_enabled =1 ;
@@ -773,7 +773,7 @@ static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport) uerstat =rd_regl (port,S3C2410_UERSTAT ); ch =rd_reg (port,S3C2410_URXH ); -if (port->flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (port)) {bool txe =s3c24xx_serial_txempty_nofifo (port);if (ourport->rx_enabled) {
@@ -1828,7 +1828,7 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,if (cfg->uart_flags &UPF_CONS_FLOW ) {dev_dbg (port->dev,"enabling flow control\n" ); - port->flags |=UPF_CONS_FLOW ; +uart_set_cons_flow_enabled (port, true); }/* sort our the physical and virtual addresses for each UART */
drivers/tty/serial/serial_txx9.c +2 -2
@@ -422,7 +422,7 @@ static void wait_for_xmitr(struct uart_port *up)udelay (1 );/* Wait up to 1s for flow control if necessary */ -if (up->flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (up)) { tmout =1000000 ;while (--tmout && (sio_in (up,TXX9_SICISR ) &TXX9_SICISR_CTSS ))
@@ -857,7 +857,7 @@ serial_txx9_console_write(struct console *co, const char *s, unsigned int count)* Disable flow-control if enabled (and unnecessary) */ flcr =sio_in (up,TXX9_SIFLCR ); -if (!(up->flags &UPF_CONS_FLOW ) && (flcr &TXX9_SIFLCR_TES )) +if (!uart_cons_flow_enabled (up) && (flcr &TXX9_SIFLCR_TES ))sio_out (up,TXX9_SIFLCR , flcr & ~TXX9_SIFLCR_TES );uart_console_write (up, s, count, serial_txx9_console_putchar);
drivers/tty/serial/sunsu.c +1 -1
@@ -1245,7 +1245,7 @@ static void wait_for_xmitr(struct uart_sunsu_port *up) }while (!uart_lsr_tx_empty (status));/* Wait up to 1s for flow control if necessary */ -if (up->port.flags &UPF_CONS_FLOW ) { +if (uart_cons_flow_enabled (&up->port)) { tmout =1000000 ;while (--tmout && ((serial_in (up,UART_MSR ) &UART_MSR_CTS ) ==0 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/1518 serial: 8250: Set cons_flow on port registration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit f69ec492244d54068f08c20f90979274d8ac3655 ]
Since console flow control policy is no longer part of uart_port.flags, explicitly set the policy for the port.
Stable-dep-of: d338ab1d9060 ("serial: 8250: Clear CON_PRINTBUFFER on port re-registration")
--- drivers/tty/serial/8250/8250_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/8250/8250_core.c +2 -0
@@ -742,6 +742,8 @@ int serial8250_register_8250_port(const struct uart_8250_port *up) uart->lsr_save_mask = up->lsr_save_mask; uart->dma = up->dma; +uart_set_cons_flow_enabled (&uart->port,uart_cons_flow_enabled (&up->port)); +/* Take tx_loadsz from fifosize if it wasn't set separately */ if (uart->port.fifosize && !uart->tx_loadsz) uart->tx_loadsz = uart->port.fifosize;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/1518 serial: 8250: Add support for console flow control
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
[ Upstream commit 5e6dfb87b191f34b1bb7cfb4d668665e5b70687b ]
The kernel documentation specifies that the console option 'r' can be used to enable hardware flow control for console writes. The 8250 driver does include code for hardware flow control on the console if cons_flow is set, but there is no code path that actually sets this. However, that is not the only issue. The problems are:
1. Specifying the console option 'r' does not lead to cons_flow being set.
2. Even if cons_flow would be set, serial8250_register_8250_port() clears it.
3. When the console option 'r' is specified, uart_set_options() attempts to initialize the port for CRTSCTS. However, afterwards it does not set the UPSTAT_CTS_ENABLE status bit and therefore on boot, uart_cts_enabled() is always false. This policy bit is important for console drivers as a criteria if they may poll CTS.
4. Even though uart_set_options() attempts to initialize the port for CRTSCTS, the 8250 set_termios() callback does not enable the RTS signal (TIOCM_RTS) and thus the hardware is not properly initialized for CTS polling.
5. Even if modem control was properly setup for CTS polling (TIOCM_RTS), uart_configure_port() clears TIOCM_RTS, thus breaking CTS polling.
6. wait_for_xmitr() and serial8250_console_write() use cons_flow to decide if CTS polling should occur. However, the condition should also include a check that it is not in RS485 mode and CRTSCTS is actually enabled in the hardware.
Address all these issues as conservatively as possible by gating them behind checks focussed on the user specifying console hardware flow control support and the hardware being configured for CTS polling at the time of the write to the UART.
Since checking the UPSTAT_CTS_ENABLE status bit is a part of the new condition gate, these changes also support runtime termios updates to disable/enable CRTSCTS.
Stable-dep-of: d338ab1d9060 ("serial: 8250: Clear CON_PRINTBUFFER on port re-registration")
--- drivers/tty/serial/8250/8250_core.c | 6 +++++- drivers/tty/serial/8250/8250_port.c | 13 +++++++++++-- drivers/tty/serial/serial_core.c | 21 ++++++++++++++++++++- include/linux/serial_core.h | 8 ++++++++ 4 files changed, 44 insertions(+), 4 deletions(-)
drivers/tty/serial/8250/8250_core.c +5 -1
@@ -689,6 +689,7 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)int serial8250_register_8250_port (const struct uart_8250_port *up) {struct uart_8250_port *uart; +bool cons_flow;int ret;if (up->port.uartclk ==0 )
@@ -712,6 +713,9 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)if (uart->port.type ==PORT_8250_CIR )return -ENODEV ; +/* Preserve specified console flow control. */ + cons_flow =uart_cons_flow_enabled (&uart->port); +if (uart->port.dev)uart_remove_one_port (&serial8250_reg, &uart->port);
@@ -742,7 +746,7 @@ int serial8250_register_8250_port(const struct uart_8250_port *up) uart->lsr_save_mask = up->lsr_save_mask; uart->dma = up->dma; -uart_set_cons_flow_enabled (&uart->port,uart_cons_flow_enabled (&up->port)); +uart_set_cons_flow_enabled (&uart->port,uart_cons_flow_enabled (&up->port) | cons_flow);/* Take tx_loadsz from fifosize if it wasn't set separately */ if (uart->port.fifosize && !uart->tx_loadsz)
drivers/tty/serial/8250/8250_port.c +11 -2
@@ -1991,7 +1991,7 @@ static void wait_for_xmitr(struct uart_8250_port *up, int bits)wait_for_lsr (up, bits);/* Wait up to 1s for flow control if necessary */ -if (uart_cons_flow_enabled (&up->port)) { +if (uart_console_hwflow_active (&up->port)) {for (tmout =1000000 ; tmout; tmout--) {unsigned int msr =serial_in (up,UART_MSR ); up->msr_saved_flags |= msr &MSR_SAVE_FLAGS ;
@@ -2785,6 +2785,12 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,serial8250_set_efr (port, termios);serial8250_set_divisor (port, baud, quot, frac);serial8250_set_fcr (port, termios); +/* Consoles manually poll CTS for hardware flow control. */ +if (uart_console (port) && + !(port->rs485.flags &SER_RS485_ENABLED ) + && termios->c_cflag &CRTSCTS ) { + port->mctrl |=TIOCM_RTS ; + }serial8250_set_mctrl (port, port->mctrl); }
@@ -3354,7 +3360,7 @@ void serial8250_console_write(struct uart_8250_port *up, const char *s,* it regardless of the CTS state. Therefore, only use fifo * if we don't use control flow. */ - !uart_cons_flow_enabled (&up->port); + !uart_console_hwflow_active (&up->port);if (likely (use_fifo))serial8250_console_fifo_write (up, s, count);
@@ -3424,6 +3430,9 @@ int serial8250_console_setup(struct uart_port *port, char *options, bool probe)if (ret)return ret; +/* Track user-specified console flow control. */ +uart_set_cons_flow_enabled (port, flow =='r' ); +if (port->dev)pm_runtime_get_sync (port->dev);
drivers/tty/serial/serial_core.c +20 -1
@@ -2263,6 +2263,18 @@ uart_set_options(struct uart_port *port, struct console *co, port->mctrl |=TIOCM_DTR ; port->ops->set_termios (port, &termios, &dummy); + +/* +* If console hardware flow control was specified and is supported, +* the related policy UPSTAT_CTS_ENABLE must be set to allow console +* drivers to identify if CTS should be used for polling. +*/ +if (flow =='r' && (termios.c_cflag &CRTSCTS )) { +/* Synchronize @status RMW update against the console. */ +guard (uart_port_lock_irqsave)(port); + port->status |=UPSTAT_CTS_ENABLE ; + } +/* * Allow the setting of the UART parameters with a NULL console * too:
@@ -2569,7 +2581,14 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,* We probably don't need a spinlock around this, but */ scoped_guard(uart_port_lock_irqsave, port) { - port->mctrl &=TIOCM_DTR ; +unsigned int mask =TIOCM_DTR ; + +/* Console hardware flow control polls CTS. */ +if (uart_console_hwflow_active (port)) + mask |=TIOCM_RTS ; + + port->mctrl &= mask; +if (!(port->rs485.flags &SER_RS485_ENABLED )) port->ops->set_mctrl (port, port->mctrl); }
include/linux/serial_core.h +8 -0
@@ -1175,6 +1175,14 @@ static inline bool uart_cons_flow_enabled(const struct uart_port *uport)return uport->cons_flow; } +static inline bool uart_console_hwflow_active (struct uart_port *uport) +{ +return uart_console (uport) && + !(uport->rs485.flags &SER_RS485_ENABLED ) && +uart_cons_flow_enabled (uport) && +uart_cts_enabled (uport); +} +/* * The following are helper functions for the low level drivers. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/1518 serial: 8250: Clear CON_PRINTBUFFER on port re-registration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fushuai Wang <[email protected]>
[ Upstream commit d338ab1d90603f875c4f7ed223406535378173a5 ]
When two PnP devices map to the same physical port, the serial8250 driver removes and re-registers the console structure for the same port.
During re-registration, the console structure still has CON_PRINTBUFFER set from the initial registration, which causes console_init_seq() to set console->seq to syslog_seq. This results in re-printing the entire system log buffer, which may lead to RCU stall on slow serial consoles.
Clear CON_PRINTBUFFER when re-registering a port to prevent duplicate log printing.
--- drivers/tty/serial/8250/8250_core.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_core.c +5 -1
@@ -716,8 +716,12 @@ int serial8250_register_8250_port(const struct uart_8250_port *up)/* Preserve specified console flow control. */ cons_flow =uart_cons_flow_enabled (&uart->port); -if (uart->port.dev) +if (uart->port.dev) { +if (uart_console (&uart->port)) + uart->port.cons->flags &= ~CON_PRINTBUFFER ; +uart_remove_one_port (&serial8250_reg, &uart->port); + } uart->port.ctrl_id = up->port.ctrl_id; uart->port.port_id = up->port.port_id;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/1518 serial: ma35d1: Fix OF node reference leaks in console init
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 8dfea56f350b3dc826f35711802ad6ae8fae0748 ]
ma35d1serial_console_init_port() stores matching UART device nodes in ma35d1serial_uart_nodes[] with an extra of_node_get() so that console setup can later read the "reg" property. However, the stored references are never released after console setup has finished using them.
Drop the stored node reference after ma35d1serial_console_setup() reads the "reg" property, and clear the array slot to avoid leaving a stale pointer behind. Also release the iterator reference before breaking out of for_each_matching_node(), since the normal iterator advance will not run in that path.
--- drivers/tty/serial/ma35d1_serial.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/tty/serial/ma35d1_serial.c +10 -2
@@ -608,8 +608,14 @@ static int __init ma35d1serial_console_setup(struct console *co, char *options)if (!np || !p)return -ENODEV ; -if (of_property_read_u32_array (np,"reg" , val32,ARRAY_SIZE (val32)) !=0 ) +if (of_property_read_u32_array (np,"reg" , val32,ARRAY_SIZE (val32)) !=0 ) { +of_node_put (np); + ma35d1serial_uart_nodes[co->index] =NULL ;return -EINVAL ; + } + +of_node_put (np); + ma35d1serial_uart_nodes[co->index] =NULL ; p->port.iobase = val32[1 ]; p->port.membase =ioremap (p->port.iobase,MA35_UART_REG_SIZE );
@@ -648,8 +654,10 @@ static void ma35d1serial_console_init_port(void)of_node_get (np); ma35d1serial_uart_nodes[i] = np; i++; -if (i ==MA35_UART_NR ) +if (i ==MA35_UART_NR ) { +of_node_put (np);break ; + } } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/1518 serial: qcom-geni: do not advance stale DMA completions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 7ea38c49e7178960926657863299face6dc0e1b0 ]
The qcom GENI serial DMA TX completion path advances the transmit fifo by the number of bytes recorded in port->tx_remaining.
If uart_flush_buffer() runs after the hardware has completed a DMA transfer but before the DMA completion interrupt has been handled, the serial core resets the transmit fifo while port->tx_remaining still describes the old DMA transfer.
A previous fix avoided advancing an empty fifo by checking that the fifo length is at least tx_remaining. That still does not distinguish the old DMA payload from new bytes written after the flush. If userspace writes new data before the stale DMA completion interrupt is handled, the fifo can again contain at least tx_remaining bytes and the stale completion can advance and discard those new bytes.
Mark an in-flight DMA transfer stale when the transmit fifo is flushed. The later completion still unprepares the original DMA mapping using the saved length, but it no longer advances the transmit fifo.
--- drivers/tty/serial/qcom_geni_serial.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/tty/serial/qcom_geni_serial.c +9 -1
@@ -136,6 +136,7 @@ struct qcom_geni_serial_port {unsigned int tx_remaining;unsigned int tx_queued; +bool tx_dma_stale;int wakeup_irq;bool rx_tx_swap;bool cts_rts_swap;
@@ -688,6 +689,7 @@ static void qcom_geni_serial_start_tx_dma(struct uart_port *uport) } port->tx_remaining = xmit_size; + port->tx_dma_stale = false; }static void qcom_geni_serial_start_tx_fifo (struct uart_port *uport)
@@ -1020,6 +1022,7 @@ static void qcom_geni_serial_handle_tx_dma(struct uart_port *uport)struct qcom_geni_serial_port *port =to_dev_port (uport);struct tty_port *tport = &uport->state->port;unsigned int fifo_len =kfifo_len (&tport->xmit_fifo); +bool tx_dma_stale = port->tx_dma_stale;/* * Only advance the kfifo if it still contains the bytes that were
@@ -1030,12 +1033,13 @@ static void qcom_geni_serial_handle_tx_dma(struct uart_port *uport)* kfifo->in, making kfifo_len() wrap to UART_XMIT_SIZE - tx_remaining * and triggering a spurious large DMA transfer of stale data. */ -if (fifo_len >= port->tx_remaining) +if (!tx_dma_stale && fifo_len >= port->tx_remaining)uart_xmit_advance (uport, port->tx_remaining);geni_se_tx_dma_unprep (&port->se, port->tx_dma_addr, port->tx_remaining); port->tx_dma_addr =0 ; port->tx_remaining =0 ; + port->tx_dma_stale = false;if (!kfifo_is_empty (&tport->xmit_fifo))qcom_geni_serial_start_tx_dma (uport);
@@ -1173,6 +1177,10 @@ static void qcom_geni_serial_shutdown(struct uart_port *uport)static void qcom_geni_serial_flush_buffer_fifo (struct uart_port *uport) { +struct qcom_geni_serial_port *port =to_dev_port (uport); + +if (port->tx_dma_addr) + port->tx_dma_stale = true;qcom_geni_serial_cancel_tx_cmd (uport); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/1518 usb: gadget: f_fs: Fix fence cleanup in ffs_dmabuf_transfer() error paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
[ Upstream commit 621707dc67c9846fd876d7579ec951d92aa033f1 ]
The error paths for endpoint-disabled (ESHUTDOWN) and request-allocation failure (ENOMEM) in ffs_dmabuf_transfer() jump to err_fence_put which calls dma_fence_put() on the fence. However, at that point the fence has only been kmalloc'd — dma_fence_init() has not been called yet, so the refcount and the fence ops are uninitialized. Calling dma_fence_put() on such an object leads to undefined behavior.
Use kfree() instead, since the fence is just a plain allocation at this stage, and rename the label to err_fence_free to reflect the actual cleanup action.
--- drivers/usb/gadget/function/f_fs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/usb/gadget/function/f_fs.c +4 -4
@@ -1683,13 +1683,13 @@ static int ffs_dmabuf_transfer(struct file *file,/* In the meantime, endpoint got disabled or changed. */ if (epfile->ep != ep) { ret = -ESHUTDOWN ; - goto err_fence_put; + goto err_fence_free; } usb_req =usb_ep_alloc_request (ep->ep,GFP_ATOMIC );if (!usb_req) { ret = -ENOMEM ; - goto err_fence_put; + goto err_fence_free; }/*
@@ -1738,9 +1738,9 @@ static int ffs_dmabuf_transfer(struct file *file,return ret; -err_fence_put: +err_fence_free:spin_unlock_irq (&epfile->ffs->eps_lock); -dma_fence_put (&fence->base); +kfree (fence); err_resv_unlock:dma_resv_unlock (dmabuf->resv); err_attachment_put:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/1518 usb: gadget: configfs: fix out-of-bounds read of qw_sign
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit f63edb54d8f738f9c21e2068c777ae1c097df6b7 ]
os_desc_qw_sign_show() passes OS_STRING_QW_SIGN_LEN as the input length to utf16s_to_utf8s(), but that argument counts UTF-16 code units while OS_STRING_QW_SIGN_LEN (14) is the byte size of qw_sign[]. The array holds only OS_STRING_QW_SIGN_LEN / 2 (7) code units, so the conversion reads up to 7 units (14 bytes) past the end of qw_sign[] into the following members of struct gadget_info when the stored signature fills the array without a NUL terminator, exposing those bytes through the configfs attribute.
The store path halves the count for its input bound but passes the full byte count as the utf8s_to_utf16s() output limit; use the destination code-unit count in both directions.
--- drivers/usb/gadget/configfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/gadget/configfs.c +2 -2
@@ -1177,7 +1177,7 @@ static ssize_t os_desc_qw_sign_show(struct config_item *item, char *page)struct gadget_info *gi =os_desc_item_to_gadget_info (item);int res; - res =utf16s_to_utf8s ((wchar_t *) gi->qw_sign,OS_STRING_QW_SIGN_LEN , + res =utf16s_to_utf8s ((wchar_t *) gi->qw_sign,OS_STRING_QW_SIGN_LEN /2 ,UTF16_LITTLE_ENDIAN , page,PAGE_SIZE -1 ); page[res++] ='\n' ;
@@ -1199,7 +1199,7 @@ static ssize_t os_desc_qw_sign_store(struct config_item *item, const char *page,mutex_lock (&gi->lock); res =utf8s_to_utf16s (page, l,UTF16_LITTLE_ENDIAN , (wchar_t *) gi->qw_sign, -OS_STRING_QW_SIGN_LEN ); +OS_STRING_QW_SIGN_LEN /2 );if (res >0 ) res = len;mutex_unlock (&gi->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/1518 usb: ljca: bound bank_num in ljca_enumerate_gpio()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maoyi Xie <[email protected]>
[ Upstream commit dd9483726d0f16c1a56879c3edb65128259a4e2b ]
ljca_enumerate_gpio() reads desc->bank_num from the device and loops valid_pin[i] = get_unaligned_le32(...) for i < bank_num. valid_pin[] holds only LJCA_MAX_GPIO_NUM / 32 = 2 entries.
Two checks run before the loop. The reply length must match struct_size(desc, bank_desc, bank_num). The product pins_per_bank * bank_num must not exceed LJCA_MAX_GPIO_NUM. Neither one bounds bank_num against the size of valid_pin[]. The reply is capped at LJCA_MAX_PAYLOAD_SIZE (60) bytes, so the struct_size check limits bank_num to 9. A device that reports bank_num 9 with pins_per_bank 7 still passes both checks. gpio_num is 63 and the reply is 56 bytes. The loop then writes nine u32 into the two entry array and overruns valid_pin[] on the stack.
A broken or malicious LJCA device can therefore overflow the stack. Reject a bank_num that does not fit valid_pin[].
--- drivers/usb/misc/usb-ljca.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/misc/usb-ljca.c +3 -0
@@ -585,6 +585,9 @@ static int ljca_enumerate_gpio(struct ljca_adapter *adap)if (gpio_num >LJCA_MAX_GPIO_NUM )return -EINVAL ; +if (desc->bank_num >ARRAY_SIZE (valid_pin)) +return -EINVAL ; +/* construct platform data */ gpio_info =kzalloc (sizeof *gpio_info,GFP_KERNEL );if (!gpio_info)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/1518 usb: gadget: aspeed_udc: check endpoint DMA allocation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 97cee53a94be3bd4fd8fbed6071bd2f32dad1ab1 ]
ast_udc_probe() allocates a coherent DMA buffer used as the backing store for endpoint buffers. ast_udc_init_ep() derives per-endpoint buffer pointers from udc->ep0_buf, so a failed allocation is dereferenced during probe.
Check the allocation before endpoint setup. The existing probe error path called ast_udc_remove(), which unregisters the gadget unconditionally and is not safe before usb_add_gadget_udc() succeeds. Add a local cleanup helper for probe failures so pre-registration failures only unwind the resources that were actually initialized.
This was found by a local static analysis checker for unchecked allocator returns while scanning Linux 6.16. The change was checked by applying it to current mainline and by running checkpatch. I do not have access to Aspeed UDC hardware, so no runtime testing was performed.
--- drivers/usb/gadget/udc/aspeed_udc.c | 50 ++++++++++++++++++----------- 1 file changed, 32 insertions(+), 18 deletions(-)
drivers/usb/gadget/udc/aspeed_udc.c +32 -18
@@ -1434,25 +1434,12 @@ static void ast_udc_init_hw(struct ast_udc_dev *udc)ast_udc_write (udc,0 ,AST_UDC_EP0_CTRL ); } -static void ast_udc_remove (struct platform_device *pdev) +static void ast_udc_cleanup (struct platform_device *pdev) {struct ast_udc_dev *udc =platform_get_drvdata (pdev);unsigned long flags;u32 ctrl; -usb_del_gadget_udc (&udc->gadget); -if (udc->driver) { -/* -* This is broken as only some cleanup is skipped, *udev is -* freed and the register mapping goes away. Any further usage -* probably crashes. Also the device is unbound, so the skipped -* cleanup is never catched up later. -*/ -dev_alert (&pdev->dev, -"Driver is busy and still going away. Fasten your seat belts!\n" ); -return ; - } -spin_lock_irqsave (&udc->lock, flags);/* Disable upstream port connection */
@@ -1472,6 +1459,26 @@ static void ast_udc_remove(struct platform_device *pdev) udc->ep0_buf =NULL ; } +static void ast_udc_remove (struct platform_device *pdev) +{ +struct ast_udc_dev *udc =platform_get_drvdata (pdev); + +usb_del_gadget_udc (&udc->gadget); +if (udc->driver) { +/* +* This is broken as only some cleanup is skipped, *udev is +* freed and the register mapping goes away. Any further usage +* probably crashes. Also the device is unbound, so the skipped +* cleanup is never catched up later. +*/ +dev_alert (&pdev->dev, +"Driver is busy and still going away. Fasten your seat belts!\n" ); +return ; + } + +ast_udc_cleanup (pdev); +} +static int ast_udc_probe (struct platform_device *pdev) {enum usb_device_speed max_speed;
@@ -1524,6 +1531,12 @@ static int ast_udc_probe(struct platform_device *pdev)AST_UDC_NUM_ENDPOINTS , &udc->ep0_buf_dma, GFP_KERNEL); +if (!udc->ep0_buf) { +clk_disable_unprepare (udc->clk); + rc = -ENOMEM ; + goto err; + } + udc->gadget.speed =USB_SPEED_UNKNOWN ; udc->gadget.max_speed =USB_SPEED_HIGH ; udc->creq = udc->reg +AST_UDC_SETUP0 ;
@@ -1553,20 +1566,20 @@ static int ast_udc_probe(struct platform_device *pdev) udc->irq =platform_get_irq (pdev,0 );if (udc->irq <0 ) { rc = udc->irq; - goto err; + goto err_cleanup; } rc =devm_request_irq (&pdev->dev, udc->irq, ast_udc_isr,0 ,KBUILD_MODNAME , udc);if (rc) {dev_err (&pdev->dev,"Failed to request interrupt\n" ); - goto err; + goto err_cleanup; } rc =usb_add_gadget_udc (&pdev->dev, &udc->gadget);if (rc) {dev_err (&pdev->dev,"Failed to add gadget udc\n" ); - goto err; + goto err_cleanup; } dev_info(&pdev->dev, "Initialized udc in USB%s mode\n",
@@ -1574,9 +1587,10 @@ static int ast_udc_probe(struct platform_device *pdev)return 0 ; +err_cleanup: +ast_udc_cleanup (pdev); err:dev_err (&pdev->dev,"Failed to udc probe, rc:0x%x\n" , rc); -ast_udc_remove (pdev);return rc; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/1518 usb: fix UAF when probe runs concurrent to dyn ID removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gary Guo <[email protected]>
[ Upstream commit ef8154d8b52d60338c1fd8d793cd8e891c604c14 ]
Dynamic IDs are only guaranteed to be valid when usb_dynids_lock is held, as remove_id_store can free the node. Thus, make a copy in usb_probe_interface. Clarify the documentation that the id parameter is only valid during the probe.
USB serial has the same pattern, but it does not need fixing as the IDs cannot be removed via sysfs.
--- drivers/usb/core/driver.c | 12 ++++++++---- include/linux/usb.h | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-)
drivers/usb/core/driver.c +8 -4
@@ -228,14 +228,16 @@ static void usb_free_dynids(struct usb_driver *usb_drv) }static const struct usb_device_id *usb_match_dynamic_id (struct usb_interface *intf, -const struct usb_driver *drv) +const struct usb_driver *drv, +struct usb_device_id *id_copy) {struct usb_dynid *dynid;guard (mutex)(&usb_dynids_lock);list_for_each_entry (dynid, &drv->dynids.list, node) {if (usb_match_one_id (intf, &dynid->id)) { -return &dynid->id; + *id_copy = dynid->id; +return id_copy; } }return NULL ;
@@ -321,6 +323,7 @@ static int usb_probe_interface(struct device *dev)struct usb_interface *intf =to_usb_interface (dev);struct usb_device *udev =interface_to_usbdev (intf);const struct usb_device_id *id; +struct usb_device_id id_copy;int error = -ENODEV ;int lpm_disable_error = -ENODEV ;
@@ -340,7 +343,7 @@ static int usb_probe_interface(struct device *dev)return error; } - id =usb_match_dynamic_id (intf, driver); + id =usb_match_dynamic_id (intf, driver, &id_copy);if (!id) id =usb_match_id (intf, driver->id_table);if (!id)
@@ -892,6 +895,7 @@ static int usb_device_match(struct device *dev, const struct device_driver *drv)struct usb_interface *intf;const struct usb_driver *usb_drv;const struct usb_device_id *id; +struct usb_device_id id_copy;/* device drivers never match interfaces */ if (is_usb_device_driver (drv))
@@ -904,7 +908,7 @@ static int usb_device_match(struct device *dev, const struct device_driver *drv)if (id)return 1 ; - id =usb_match_dynamic_id (intf, usb_drv); + id =usb_match_dynamic_id (intf, usb_drv, &id_copy);if (id)return 1 ; }
include/linux/usb.h +2 -1
@@ -1185,7 +1185,8 @@ extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf);* interface. It may also use usb_set_interface() to specify the * appropriate altsetting. If unwilling to manage the interface, * return -ENODEV, if genuine IO errors occurred, an appropriate -* negative errno value. +* negative errno value. The usb_device_id parameter is only valid during +* probe. * @disconnect: Called when the interface is no longer accessible, usually * because its device has been (or is being) disconnected or the * driver module is being unloaded.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/1518 platform/mellanox: mlxbf-pmc: Check ACPI_COMPANION() against NULL
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit c38cce70adef874c2a7b5132c14d6c221401deff ]
Every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), so platform drivers that rely on the existence of a device's ACPI companion object need to verify its presence.
mlxbf_pmc_probe() passes the result of ACPI_COMPANION() to acpi_device_hid(), which dereferences it, so force-binding the driver to a device without an ACPI companion leads to a NULL pointer dereference.
Accordingly, add a requisite ACPI_COMPANION() check against NULL to the mlxbf-pmc driver and return -ENODEV when the companion is missing.
--- drivers/platform/mellanox/mlxbf-pmc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/platform/mellanox/mlxbf-pmc.c +8 -2
@@ -2262,13 +2262,19 @@ static int mlxbf_pmc_map_counters(struct device *dev)static int mlxbf_pmc_probe (struct platform_device *pdev) { -struct acpi_device *acpi_dev =ACPI_COMPANION (&pdev->dev); -const char *hid =acpi_device_hid (acpi_dev);struct device *dev = &pdev->dev; +struct acpi_device *acpi_dev;struct arm_smccc_res res; +const char *hid;guid_t guid;int ret; + acpi_dev =ACPI_COMPANION (&pdev->dev); +if (!acpi_dev) +return -ENODEV ; + + hid =acpi_device_hid (acpi_dev); +/* Ensure we have the UUID we expect for this service. */ arm_smccc_smc (MLXBF_PMC_SIP_SVC_UID ,0 ,0 ,0 ,0 ,0 ,0 ,0 , &res);guid_parse (mlxbf_pmc_svc_uuid_str, &guid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/1518 platform/surface: acpi-notify: Check ACPI companion before use
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 2b3a5dabe89e330413af403246b648c1890f368f ]
Since every platform driver can be forced to match a device that doesn't match its list of device IDs because of device_match_driver_override(), platform drivers that rely on the existence of a device's ACPI companion object should verify its presence.
san_probe() dereferences the result of ACPI_COMPANION() when installing the GSBUS address space handler, so force-binding the driver to a device without an ACPI companion leads to a NULL pointer dereference. The dereference was introduced when the probe function was switched from ACPI_HANDLE() to ACPI_COMPANION().
Check the ACPI companion against NULL and return -ENODEV when it is missing, like commit e4865a56d013 ("ACPI: driver: Check ACPI_COMPANION() against NULL during probe") does for the core ACPI platform drivers.
--- drivers/platform/surface/surface_acpi_notify.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/platform/surface/surface_acpi_notify.c +5 -1
@@ -777,12 +777,16 @@ static int san_consumer_links_setup(struct platform_device *pdev)static int san_probe (struct platform_device *pdev) { -struct acpi_device *san =ACPI_COMPANION (&pdev->dev);struct ssam_controller *ctrl; +struct acpi_device *san;struct san_data *data;acpi_status astatus;int status; + san =ACPI_COMPANION (&pdev->dev); +if (!san) +return -ENODEV ; + ctrl =ssam_client_bind (&pdev->dev);if (IS_ERR (ctrl))return PTR_ERR (ctrl) == -ENODEV ? -EPROBE_DEFER :PTR_ERR (ctrl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/1518 usb: mtu3: allow system suspend during active gadget connection
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fei Shao <[email protected]>
[ Upstream commit e69027c25361b6044c7928715667586cc5469063 ]
When operating in gadget mode connected to a USB host, system suspend fails with -EBUSY because active peripheral connections block suspend entry.
Fix this by restricting the -EBUSY check to runtime autosuspend (PMSG_IS_AUTO). For system suspend (!PMSG_IS_AUTO), perform soft disconnect to disconnect from the bus and allow MAC sleep.
--- drivers/usb/mtu3/mtu3_core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/usb/mtu3/mtu3_core.c +10 -1
@@ -1037,9 +1037,14 @@ int ssusb_gadget_suspend(struct ssusb_mtk *ssusb, pm_message_t msg)if (!mtu->gadget_driver)return 0 ; -if (mtu->connected) +/* Prevent runtime suspend when active connection exists */ +if (mtu->connected &&PMSG_IS_AUTO (msg))return -EBUSY ; +/* Perform soft disconnect for system suspend */ +if (mtu->softconnect && !PMSG_IS_AUTO (msg)) +mtu3_dev_on_off (mtu,0 ); +mtu3_dev_suspend (mtu);synchronize_irq (mtu->irq);
@@ -1055,5 +1060,9 @@ int ssusb_gadget_resume(struct ssusb_mtk *ssusb, pm_message_t msg)mtu3_dev_resume (mtu); +/* Restore soft connect for system resume */ +if (mtu->softconnect && !PMSG_IS_AUTO (msg)) +mtu3_dev_on_off (mtu,1 ); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/1518 usb: renesas_usbhs: Fix power-off ordering on unbind
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Biju Das <[email protected]>
[ Upstream commit 589b9e6f96be6bd8dd0d45fda8e948c31dc2fe94 ]
Move the usbhsc_power_ctrl() call to before hardware_exit() and reset_control_assert() in usbhs_remove(), so the PHY is powered off while priv->phy is still valid, rather than after hardware_exit() has already cleared it.
--- drivers/usb/renesas_usbhs/common.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/renesas_usbhs/common.c +3 -3
@@ -813,9 +813,6 @@ static void usbhs_remove(struct platform_device *pdev)flush_delayed_work (&priv->notify_hotplug_work); -usbhs_platform_call (priv, hardware_exit, pdev); -reset_control_assert (priv->rsts); -/* * Explicitly free the IRQ to ensure the interrupt handler is * disabled and synchronized before freeing resources.
@@ -832,6 +829,9 @@ static void usbhs_remove(struct platform_device *pdev)if (!usbhs_get_dparam (priv, runtime_pwctrl))usbhsc_power_ctrl (priv,0 ); +usbhs_platform_call (priv, hardware_exit, pdev); +reset_control_assert (priv->rsts); +usbhsc_clk_put (priv);pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/1518 usb: ucsi: huawei_gaokun: support mode switching
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengyu Luo <[email protected]>
[ Upstream commit 1c2b66a7d7257d2652aa41f9a860ecb96dde27dd ]
The USB PHY (QMP Combo PHY) is always initialized in USB3+DP mode. In the past, there was no MUX, and it was unnecessary to set it, since MSM only supported 2-lane DP. But now, MST and 4-lane DP support has been added to MSM, and a MUX has been added to the PHY. To support 4-lane DP and mode switching for gaokun, get the MUX and set it.
Stable-dep-of: 2c5659a7064e ("usb: typec: ucsi: gaokun: unwind notifier on UCSI register failure")
--- drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 55 +++++++++++++++------ 1 file changed, 41 insertions(+), 14 deletions(-)
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c +41 -14
@@ -18,6 +18,7 @@#include <linux/usb/pd_vdo.h> #include <linux/usb/typec_altmode.h> #include <linux/usb/typec_dp.h> +#include <linux/usb/typec_mux.h> #include <linux/workqueue_types.h> #include "ucsi.h"
@@ -82,6 +83,8 @@ struct gaokun_ucsi_port {struct gaokun_ucsi *ucsi;struct auxiliary_device *bridge; +struct typec_mux *typec_mux; +int idx;enum gaokun_ucsi_ccx ccx;enum gaokun_ucsi_mux mux;
@@ -226,19 +229,18 @@ static void gaokun_ucsi_port_update(struct gaokun_ucsi_port *port, port->hpd_state =FIELD_GET (GAOKUN_HPD_STATE_MASK , ddi); port->hpd_irq =FIELD_GET (GAOKUN_HPD_IRQ_MASK , ddi); -/* Mode and SVID are unused; keeping them to make things clearer */ switch (port->mode) {case USBC_DPAM_PAN_C :case USBC_DPAM_PAN_C_REVERSE : - port->mode =DP_PIN_ASSIGN_C ;/* correct it for usb later */ + port->mode =TYPEC_DP_STATE_C ;/* correct it for usb later */ break ;case USBC_DPAM_PAN_D :case USBC_DPAM_PAN_D_REVERSE : - port->mode =DP_PIN_ASSIGN_D ; + port->mode =TYPEC_DP_STATE_D ;break ;case USBC_DPAM_PAN_E :case USBC_DPAM_PAN_E_REVERSE : - port->mode =DP_PIN_ASSIGN_E ; + port->mode =TYPEC_DP_STATE_E ;break ;case USBC_DPAM_PAN_NONE : port->mode =TYPEC_STATE_SAFE ;
@@ -287,18 +289,32 @@ static int gaokun_ucsi_refresh(struct gaokun_ucsi *uec)return idx; } -static void gaokun_ucsi_handle_altmode (struct gaokun_ucsi_port *port) +static void gaokun_ucsi_handle_usb_mode (struct gaokun_ucsi_port *port) {struct gaokun_ucsi *uec = port->ucsi; -int idx = port->idx; - -if (idx >= uec->ucsi->cap.num_connectors) { +struct typec_mux_state state = {}; +struct typec_altmode dp_alt = {}; +int idx = port->idx, ret; + +/* +* For every typec port on this platform, the only mode-switch is +* controlled by its qmp combo phy which consumes svid and mode only. +*/ + dp_alt.svid = port->svid; + state.mode = port->mode; + state.alt = &dp_alt; + +if (idx >= uec->num_ports) {dev_warn (uec->dev,"altmode port out of range: %d\n" , idx);return ; } + ret =typec_mux_set (port->typec_mux, &state); +if (ret) +dev_err (uec->dev,"failed to set mux %d\n" , ret); +/* UCSI callback .connector_status() have set orientation */ -if (port->bridge) +if (port->bridge && port->svid ==USB_TYPEC_DP_SID ) drm_aux_hpd_bridge_notify(&port->bridge->dev, port->hpd_state ? connector_status_connected :
@@ -307,7 +323,7 @@ static void gaokun_ucsi_handle_altmode(struct gaokun_ucsi_port *port)gaokun_ec_ucsi_pan_ack (uec->ec, port->idx); } -static void gaokun_ucsi_altmode_notify_ind (struct gaokun_ucsi *uec) +static void gaokun_ucsi_usb_notify_ind (struct gaokun_ucsi *uec) {int idx;
@@ -320,7 +336,7 @@ static void gaokun_ucsi_altmode_notify_ind(struct gaokun_ucsi *uec)if (idx ==GAOKUN_UCSI_NO_PORT_UPDATE )gaokun_ec_ucsi_pan_ack (uec->ec, idx);/* ack directly if no update */ else -gaokun_ucsi_handle_altmode (&uec->ports[idx]); +gaokun_ucsi_handle_usb_mode (&uec->ports[idx]); }/*
@@ -352,7 +368,7 @@ static void gaokun_ucsi_handle_no_usb_event(struct gaokun_ucsi *uec, int idx) port = &uec->ports[idx];if (!wait_for_completion_timeout (&port->usb_ack,2 *HZ )) {dev_warn (uec->dev,"No USB EVENT, triggered by UCSI EVENT" ); -gaokun_ucsi_altmode_notify_ind (uec); +gaokun_ucsi_usb_notify_ind (uec); } }
@@ -366,7 +382,7 @@ static int gaokun_ucsi_notify(struct notifier_block *nb,switch (action) {case EC_EVENT_USB :gaokun_ucsi_complete_usb_ack (uec); -gaokun_ucsi_altmode_notify_ind (uec); +gaokun_ucsi_usb_notify_ind (uec);return NOTIFY_OK ;case EC_EVENT_UCSI :
@@ -429,8 +445,15 @@ static int gaokun_ucsi_ports_init(struct gaokun_ucsi *uec)fwnode_handle_put (fwnode);return PTR_ERR (ucsi_port->bridge); } - } + ucsi_port->typec_mux =fwnode_typec_mux_get (fwnode); +if (IS_ERR (ucsi_port->typec_mux)) { +fwnode_handle_put (fwnode); +return dev_err_probe (dev,PTR_ERR (ucsi_port->typec_mux), +"failed to acquire mode-switch for port: %d\n" , + port); + } + }for (i =0 ; i < num_ports; i++) {if (!uec->ports[i].bridge)continue ;
@@ -502,10 +525,14 @@ static int gaokun_ucsi_probe(struct auxiliary_device *adev,static void gaokun_ucsi_remove (struct auxiliary_device *adev) {struct gaokun_ucsi *uec =auxiliary_get_drvdata (adev); +int i;disable_delayed_work_sync (&uec->work);gaokun_ec_unregister_notify (uec->ec, &uec->nb);ucsi_unregister (uec->ucsi); +for (i =0 ; i < uec->num_ports; ++i) +typec_mux_put (uec->ports[i].typec_mux); +ucsi_destroy (uec->ucsi); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/1518 usb: typec: ucsi: gaokun: unwind notifier on UCSI register failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 2c5659a7064e7c4c0c51eb9356bcf6726a85773b ]
gaokun_ucsi_register_worker() registers the EC notifier before calling ucsi_register(). If ucsi_register() fails, the worker currently only logs the error and leaves the notifier registered. Later EC events can then call into an unpublished UCSI instance.
The remove path also unconditionally unregisters both the EC notifier and the UCSI device even if the delayed worker failed before both publication steps completed.
Unregister the notifier immediately when ucsi_register() fails, and track only the fully published state. The remove path then tears down the pair only if both publication steps completed.
--- drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/usb/typec/ucsi/ucsi_huawei_gaokun.c +12 -3
@@ -103,6 +103,7 @@ struct gaokun_ucsi {struct notifier_block nb;u16 version;u8 num_ports; +bool registered; };/* -------------------------------------------------------------------------- */
@@ -482,8 +483,13 @@ static void gaokun_ucsi_register_worker(struct work_struct *work) } ret =ucsi_register (ucsi); -if (ret) +if (ret) {dev_err_probe (ucsi->dev, ret,"ucsi register failed\n" ); +gaokun_ec_unregister_notify (uec->ec, &uec->nb); +return ; + } + + uec->registered = true; } static int gaokun_ucsi_probe(struct auxiliary_device *adev,
@@ -528,8 +534,11 @@ static void gaokun_ucsi_remove(struct auxiliary_device *adev)int i;disable_delayed_work_sync (&uec->work); -gaokun_ec_unregister_notify (uec->ec, &uec->nb); -ucsi_unregister (uec->ucsi); +if (uec->registered) { +gaokun_ec_unregister_notify (uec->ec, &uec->nb); +ucsi_unregister (uec->ucsi); + } +for (i =0 ; i < uec->num_ports; ++i)typec_mux_put (uec->ports[i].typec_mux);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/1518 drm/panel: samsung-s6d16d0: Power off on prepare failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laxman Acharya Padhya <[email protected]>
[ Upstream commit a9f950adfe2147318d75e7a6eab5e814851802ac ]
If enabling tearing mode or exiting sleep mode fails after the regulator is enabled, s6d16d0_prepare() returns without asserting reset or disabling the supply. Since the DRM panel core leaves the panel unprepared, a later unprepare call skips the driver callback and the supply remains enabled.
Assert reset and disable the supply before returning the DSI command error.
--- drivers/gpu/drm/panel/panel-samsung-s6d16d0.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c +8 -2
@@ -89,16 +89,22 @@ static int s6d16d0_prepare(struct drm_panel *panel) MIPI_DSI_DCS_TEAR_MODE_VBLANK);if (ret) {dev_err (s6->dev,"failed to enable vblank TE (%d)\n" , ret); -return ret; + goto err_power_off; }/* Exit sleep mode and power on */ ret =mipi_dsi_dcs_exit_sleep_mode (dsi);if (ret) {dev_err (s6->dev,"failed to exit sleep mode (%d)\n" , ret); -return ret; + goto err_power_off; }return 0 ; + +err_power_off: +gpiod_set_value_cansleep (s6->reset_gpio,1 ); +regulator_disable (s6->supply); + +return ret; }static int s6d16d0_enable (struct drm_panel *panel)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/1518 perf metricgroup: Fix metric expression copy leaks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yu Peng <[email protected]>
[ Upstream commit ef3af1df4f3372bd8ad47619452a283048b3bc8d ]
metricgroup__copy_metric_events() allocates a new metric expression and duplicates metric_name before linking the expression into the destination metric event.
Free new_expr when strdup() fails, and free the duplicated metric_name on the later error paths.
--- tools/perf/util/metricgroup.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
tools/perf/util/metricgroup.c +6 -1
@@ -1614,8 +1614,10 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, new_expr->metric_expr = old_expr->metric_expr; new_expr->metric_threshold = old_expr->metric_threshold; new_expr->metric_name =strdup (old_expr->metric_name); -if (!new_expr->metric_name) +if (!new_expr->metric_name) { +free (new_expr);return -ENOMEM ; + } new_expr->metric_unit = old_expr->metric_unit; new_expr->runtime = old_expr->runtime;
@@ -1627,6 +1629,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, alloc_size =sizeof (*new_expr->metric_refs); new_expr->metric_refs =calloc (nr +1 , alloc_size);if (!new_expr->metric_refs) { +zfree (&new_expr->metric_name);free (new_expr);return -ENOMEM ; }
@@ -1643,6 +1646,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, alloc_size =sizeof (*new_expr->metric_events); new_expr->metric_events =calloc (nr +1 , alloc_size);if (!new_expr->metric_events) { +zfree (&new_expr->metric_name);zfree (&new_expr->metric_refs);free (new_expr);return -ENOMEM ;
@@ -1653,6 +1657,7 @@ int metricgroup__copy_metric_events(struct evlist *evlist, struct cgroup *cgrp, evsel = old_expr->metric_events[idx]; evsel =evlist__find_evsel (evlist, evsel->core.idx);if (evsel ==NULL ) { +zfree (&new_expr->metric_name);zfree (&new_expr->metric_events);zfree (&new_expr->metric_refs);free (new_expr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/1518 soc: qcom: rpmh-rsc: manage PM notifiers with devres
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 75e918aa876440d8ad559a11d6ab87bddb1ed79a ]
rpmh_rsc_probe() registers CPU PM or genpd notifiers before populating child devices. If child population fails, the CPU PM notifier path is not unwound and the genpd path needs open-coded cleanup.
Use devm_pm_runtime_enable() for the genpd path and devm_add_action_or_reset() for both notifier registrations. This makes probe failure and driver detach use the same cleanup model while keeping devm_of_platform_populate() responsible for child devices.
--- drivers/soc/qcom/rpmh-rsc.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-)
drivers/soc/qcom/rpmh-rsc.c +26 -11
@@ -944,17 +944,30 @@ static int rpmh_rsc_pd_callback(struct notifier_block *nfb,return NOTIFY_OK ; } +static void rpmh_rsc_pd_detach (void *data) +{ +dev_pm_genpd_remove_notifier (data); +} +static int rpmh_rsc_pd_attach (struct rsc_drv *drv,struct device *dev) {int ret; -pm_runtime_enable (dev); + ret =devm_pm_runtime_enable (dev); +if (ret) +return ret; + drv->genpd_nb.notifier_call = rpmh_rsc_pd_callback; ret =dev_pm_genpd_add_notifier (dev, &drv->genpd_nb);if (ret) -pm_runtime_disable (dev); +return ret; -return ret; +return devm_add_action_or_reset (dev, rpmh_rsc_pd_detach, dev); +} + +static void rpmh_rsc_cpu_pm_unregister (void *data) +{ +cpu_pm_unregister_notifier (data); }static int rpmh_probe_tcs_config (struct platform_device *pdev,struct rsc_drv *drv)
@@ -1107,7 +1120,15 @@ static int rpmh_rsc_probe(struct platform_device *pdev)return ret; }else { drv->rsc_pm.notifier_call = rpmh_rsc_cpu_pm_callback; -cpu_pm_register_notifier (&drv->rsc_pm); + ret =cpu_pm_register_notifier (&drv->rsc_pm); +if (ret) +return ret; + + ret =devm_add_action_or_reset (&pdev->dev, + rpmh_rsc_cpu_pm_unregister, + &drv->rsc_pm); +if (ret) +return ret; } }
@@ -1122,13 +1143,7 @@ static int rpmh_rsc_probe(struct platform_device *pdev)dev_set_drvdata (&pdev->dev, drv); drv->dev = &pdev->dev; - ret =devm_of_platform_populate (&pdev->dev); -if (ret && pdev->dev.pm_domain) { -dev_pm_genpd_remove_notifier (&pdev->dev); -pm_runtime_disable (&pdev->dev); - } - -return ret; +return devm_of_platform_populate (&pdev->dev); }static const struct of_device_id rpmh_drv_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/1518 bus: qcom-ebi2: use managed resources for clocks and children
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit d19a46f7ed8eb54fea61e0eaf7db53ff7babb03c ]
qcom_ebi2_probe() enables the EBI2 clocks manually and populates child devices manually. Several later failure paths can then return without disabling the clocks or without relying on the driver core to undo child population.
Use devm_clk_get_enabled() for both clocks and devm_of_platform_populate() for children. This lets the driver core unwind the resources automatically and removes the hand-written error labels.
--- drivers/bus/qcom-ebi2.c | 50 +++++++++-------------------------------- 1 file changed, 11 insertions(+), 39 deletions(-)
drivers/bus/qcom-ebi2.c +11 -39
@@ -302,41 +302,23 @@ static int qcom_ebi2_probe(struct platform_device *pdev)u32 val;int ret; - ebi2xclk =devm_clk_get (dev,"ebi2x" ); + ebi2xclk =devm_clk_get_enabled (dev,"ebi2x" );if (IS_ERR (ebi2xclk))return PTR_ERR (ebi2xclk); - ret =clk_prepare_enable (ebi2xclk); -if (ret) { -dev_err (dev,"could not enable EBI2X clk (%d)\n" , ret); -return ret; - } - - ebi2clk =devm_clk_get (dev,"ebi2" ); -if (IS_ERR (ebi2clk)) { - ret =PTR_ERR (ebi2clk); - goto err_disable_2x_clk; - } - - ret =clk_prepare_enable (ebi2clk); -if (ret) { -dev_err (dev,"could not enable EBI2 clk\n" ); - goto err_disable_2x_clk; - } + ebi2clk =devm_clk_get_enabled (dev,"ebi2" ); +if (IS_ERR (ebi2clk)) +return PTR_ERR (ebi2clk); res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); ebi2_base =devm_ioremap_resource (dev, res); -if (IS_ERR (ebi2_base)) { - ret =PTR_ERR (ebi2_base); - goto err_disable_clk; - } +if (IS_ERR (ebi2_base)) +return PTR_ERR (ebi2_base); res =platform_get_resource (pdev,IORESOURCE_MEM ,1 ); ebi2_xmem =devm_ioremap_resource (dev, res); -if (IS_ERR (ebi2_xmem)) { - ret =PTR_ERR (ebi2_xmem); - goto err_disable_clk; - } +if (IS_ERR (ebi2_xmem)) +return PTR_ERR (ebi2_xmem);/* Allegedly this turns the power save mode off */ writel (0UL , ebi2_xmem +EBI2_XMEM_CFG );
@@ -353,7 +335,7 @@ static int qcom_ebi2_probe(struct platform_device *pdev)/* Figure out the chipselect */ ret =of_property_read_u32 (child,"reg" , &csindex);if (ret) - goto err_disable_clk; +return ret;if (csindex >5 ) { dev_err(dev,
@@ -372,20 +354,10 @@ static int qcom_ebi2_probe(struct platform_device *pdev) have_children = true; } -if (have_children) { - ret =of_platform_default_populate (np,NULL , dev); -if (ret) - goto err_disable_clk; - } +if (have_children) +return devm_of_platform_populate (dev);return 0 ; - -err_disable_clk: -clk_disable_unprepare (ebi2clk); -err_disable_2x_clk: -clk_disable_unprepare (ebi2xclk); - -return ret; }static const struct of_device_id qcom_ebi2_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/1518 clk: qcom: camcc-sc8280xp: unregister CAMCC_GDSC_CLK
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Masney <[email protected]>
[ Upstream commit 499b4cb6710f9a351d8b57a2132f9b4389d8464a ]
With the introduction of sync_state support in the clk and pmdomain subsystems, the following warning happens when the unused clocks are shutdown in camcc-sc8280xp:
[ 15.408367] titan_top_gdsc status stuck at 'on'
[ 15.408429] WARNING: drivers/clk/qcom/gdsc.c:178 at gdsc_toggle_logic+0x14c/0x160, CPU#2: kworker/u32:1/14
[ 15.408462] Modules linked in: bnep vfat fat ath11k_pci(+) ath11k mac80211 cfg80211 mhi libarc4 snd_soc_wcd938x snd_soc_wcd938x_sdw snd_soc_wcd_classh hci_uart snd_soc_wcd_common
snd_soc_sc8280xp soundwire_qcom snd_soc_wcd_mbhc snd_soc_qcom_sdw slimbus snd_soc_qcom_common regmap_sdw btqca btrtl qcom_camss soundwire_bus btbcm btintel snd_soc_sdca snd_soc_lpass_wsa_macro
bluetooth snd_soc_lpass_tx_macro snd_soc_lpass_va_macro snd_soc_lpass_rx_macro snd_soc_hdmi_codec snd_soc_lpass_macro_common videobuf2_dma_sg ov5675 v4l2_fwnode videobuf2_memops
qcom_spmi_adc5 snd_soc_core qcom_spmi_adc_tm5 videobuf2_v4l2 snd_seq snd_seq_device videobuf2_common v4l2_async qcom_vadc_common qcom_spmi_temp_alarm pm8941_pwrkey industrialio videodev
snd_compress rfkill ac97_bus snd_pcm_dmaengine qcom_tsens mc qcom_edac snd_pcm pci_pwrctrl_pwrseq qcom_cpufreq_hw snd_timer snd qcomtee soundcore tee leds_gpio joydev binfmt_misc zram
lz4hc_compress governor_simpleondemand panel_edp msm xhci_plat_hcd nvme nvme_core dwc3 qcom_pm8008_regulator
[ 15.408688] ucsi_glink nvme_keyring nvme_auth pmic_glink_altmode udc_core typec_ucsi aux_hpd_bridge qcom_battmgr ulpi ubwc_config socinfo ocmem drm_gpuvm qcom_q6v5_pas drm_exec
qcom_pil_info leds_qcom_lpg gpu_sched led_class_multicolor rtc_pm8xxx qcom_pbs qcom_common drm_display_helper qcom_pon qcom_glink_smem qcom_glink ghash_ce pwrseq_qcom_wcn gpio_sbu_mux
qcom_stats phy_qcom_qmp_combo qcom_q6v5 gf128mul cec dispcc_sc8280xp phy_qcom_edp camcc_sc8280xp i2c_qcom_cci qcom_sysmon drm_dp_aux_bus mdt_loader aux_bridge qcom_pm8008 i2c_hid_of_elan
dwc3_qcom_legacy llcc_qcom icc_bwmon gpi typec qcom_refgen_regulator phy_qcom_qmp_usb nvmem_qfprom qcom_ipcc phy_qcom_snps_femto_v2 gpucc_sc8280xp pinctrl_sc8280xp_lpass_lpi qcom_hwspinlock
pinctrl_lpass_lpi lpasscc_sc8280xp qrtr qcom_aoss pmic_glink pdr_interface phy_qcom_qmp_pcie qcom_smd qcom_pdr_msg icc_osm_l3 qcom_wdt qmi_helpers qcom_rng smp2p rpmsg_core gpio_keys pwm_bl
smem hid_multitouch fuse i2c_dev
[ 15.408928] CPU: 2 UID: 0 PID: 14 Comm: kworker/u32:1 Not tainted 7.1.0+ #2 PREEMPT(lazy)
[ 15.408937] Hardware name: LENOVO 21BX0016US/21BX0016US, BIOS N3HET88W (1.60 ) 03/14/2024
[ 15.408942] Workqueue: pm pm_runtime_work
[ 15.408959] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[ 15.408967] pc : gdsc_toggle_logic+0x14c/0x160
[ 15.408978] lr : gdsc_toggle_logic+0x14c/0x160
[ 15.408987] sp : ffff8000800f3b40
[ 15.408991] x29: ffff8000800f3b40 x28: 0000000000000000 x27: 0000000000000000
[ 15.409003] x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
[ 15.409014] x23: 0000000000000000 x22: 0000000000000001 x21: ffffa33f298fca88
[ 15.409024] x20: 0000000000000000 x19: ffffa33f298fc5b0 x18: 00cd15db75dacefd
[ 15.409035] x17: 000000040044ffff x16: ffffa33f3b1a3d88 x15: 726f776b80000002
[ 15.409045] x14: ffffffffffffffff x13: 0000000000000028 x12: 0101010101010101
[ 15.409056] x11: 7f7f7f7f7f7f7f7f x10: fefeff3039313274 x9 : ffffa33f3a5edafc
[ 15.409067] x8 : ffff8000800f3780 x7 : 0000000000000001 x6 : 0000000000000001
[ 15.409078] x5 : ffff000bf3ca1288 x4 : 0000000000000000 x3 : ffff5cccb6a3f000
[ 15.409088] x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000080ae0000
[ 15.409098] Call trace:
[ 15.409103] gdsc_toggle_logic+0x14c/0x160 (P)
[ 15.409115] gdsc_disable+0x4c/0x190
[ 15.409126] _genpd_power_off+0xa0/0x1a8
[ 15.409137] genpd_power_off.part.0+0x180/0x2a0
[ 15.409149] genpd_runtime_suspend+0x218/0x310
[ 15.409155] __rpm_callback+0x50/0x1f8
[ 15.409166] rpm_callback+0x7c/0x90
[ 15.409175] rpm_suspend+0xe8/0x690
[ 15.409185] pm_runtime_work+0xd0/0xe0
[ 15.409195] process_one_work+0x18c/0x518
[ 15.409208] worker_thread+0x190/0x320
[ 15.409218] kthread+0x110/0x130
[ 15.409227] ret_from_fork+0x10/0x20This clock is force enabled to be on in the probe, and registered with the Common Clk Framework, resulting in them being toggled off after unused clocks are shutdown. This clock is required for the GDSC transitions.
Similar to the fix in commit b60521eff227 ("clk: qcom: gcc-x1e80100:
Unregister GCC_GPU_CFG_AHB_CLK/GCC_DISP_XO_CLK"), let's just unregister this clock.
--- drivers/clk/qcom/camcc-sc8280xp.c | 19 ------------------- 1 file changed, 19 deletions(-)
drivers/clk/qcom/camcc-sc8280xp.c +0 -19
@@ -1754,24 +1754,6 @@ static struct clk_branch camcc_csiphy3_clk = { }, }; -static struct clk_branch camcc_gdsc_clk = { - .halt_reg =0xc1e4 , - .halt_check =BRANCH_HALT , - .clkr = { - .enable_reg =0xc1e4 , - .enable_mask =BIT (0 ), - .hw.init = &(struct clk_init_data ){ - .name ="camcc_gdsc_clk" , - .parent_hws = (const struct clk_hw *[]){ - &camcc_xo_clk_src.clkr.hw, - }, - .num_parents =1 , - .flags =CLK_SET_RATE_PARENT , - .ops = &clk_branch2_ops, - }, - }, -}; -static struct clk_branch camcc_icp_ahb_clk = { .halt_reg =0xc0d8 , .halt_check =BRANCH_HALT ,
@@ -2840,7 +2822,6 @@ static struct clk_regmap *camcc_sc8280xp_clocks[] = { [CAMCC_CSIPHY2_CLK] = &camcc_csiphy2_clk.clkr, [CAMCC_CSIPHY3_CLK] = &camcc_csiphy3_clk.clkr, [CAMCC_FAST_AHB_CLK_SRC] = &camcc_fast_ahb_clk_src.clkr, - [CAMCC_GDSC_CLK] = &camcc_gdsc_clk.clkr, [CAMCC_ICP_AHB_CLK] = &camcc_icp_ahb_clk.clkr, [CAMCC_ICP_CLK] = &camcc_icp_clk.clkr, [CAMCC_ICP_CLK_SRC] = &camcc_icp_clk_src.clkr,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/1518 tools/sched_ext: Strip compatibility macros for cgroup and dispatch APIs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 111a79800aeda615797f20b3a00ef116edce9e03 ]
Enough time has passed since the introduction of scx_bpf_task_cgroup() and the scx_bpf_dispatch* -> scx_bpf_dsq* kfunc renaming. Strip the compatibility macros.
Stable-dep-of: 8740156ad33b ("bpf: Require a BPF cpumask for bpf_cpumask_populate()")
--- tools/sched_ext/include/scx/compat.bpf.h | 108 +---------------------- tools/sched_ext/scx_flatcg.bpf.c | 10 +-- tools/sched_ext/scx_qmap.bpf.c | 14 ++- 3 files changed, 12 insertions(+), 120 deletions(-)
tools/sched_ext/include/scx/compat.bpf.h +2 -106
@@ -15,121 +15,17 @@ __ret; \ }) -/* v6.12: 819513666966 ("sched_ext: Add cgroup support") */ -#define __COMPAT_scx_bpf_task_cgroup (p) \ - (bpf_ksym_exists(scx_bpf_task_cgroup) ? \ - scx_bpf_task_cgroup((p)) : NULL) -/* -* v6.13: The verb `dispatch` was too overloaded and confusing. kfuncs are -* renamed to unload the verb. -* -* Build error is triggered if old names are used. New binaries work with both -* new and old names. The compat macros will be removed on v6.15 release. +* v6.15: 950ad93df2fc ("bpf: add kfunc for populating cpumask bits") * -* scx_bpf_dispatch_from_dsq() and friends were added during v6.12 by -* 4c30f5ce4f7a ("sched_ext: Implement scx_bpf_dispatch[_vtime]_from_dsq()"). -* Preserve __COMPAT macros until v6.15. +* Compat macro will be dropped on v6.19 release. */ -void scx_bpf_dispatch___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 enq_flags) __ksym __weak; -void scx_bpf_dispatch_vtime___compat(struct task_struct *p, u64 dsq_id, u64 slice, u64 vtime, u64 enq_flags) __ksym __weak; -bool scx_bpf_consume___compat(u64 dsq_id) __ksym __weak; -void scx_bpf_dispatch_from_dsq_set_slice___compat(struct bpf_iter_scx_dsq *it__iter, u64 slice) __ksym __weak; -void scx_bpf_dispatch_from_dsq_set_vtime___compat(struct bpf_iter_scx_dsq *it__iter, u64 vtime) __ksym __weak; -bool scx_bpf_dispatch_from_dsq___compat(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; -bool scx_bpf_dispatch_vtime_from_dsq___compat(struct bpf_iter_scx_dsq *it__iter, struct task_struct *p, u64 dsq_id, u64 enq_flags) __ksym __weak; int bpf_cpumask_populate(struct cpumask *dst, void *src, size_t src__sz) __ksym __weak; -#define scx_bpf_dsq_insert (p, dsq_id, slice, enq_flags) \ - (bpf_ksym_exists(scx_bpf_dsq_insert) ? \ - scx_bpf_dsq_insert((p), (dsq_id), (slice), (enq_flags)) : \ - scx_bpf_dispatch___compat((p), (dsq_id), (slice), (enq_flags))) - -#define scx_bpf_dsq_insert_vtime (p, dsq_id, slice, vtime, enq_flags) \ - (bpf_ksym_exists(scx_bpf_dsq_insert_vtime) ? \ - scx_bpf_dsq_insert_vtime((p), (dsq_id), (slice), (vtime), (enq_flags)) : \ - scx_bpf_dispatch_vtime___compat((p), (dsq_id), (slice), (vtime), (enq_flags))) - -#define scx_bpf_dsq_move_to_local (dsq_id) \ - (bpf_ksym_exists(scx_bpf_dsq_move_to_local) ? \ - scx_bpf_dsq_move_to_local((dsq_id)) : \ - scx_bpf_consume___compat((dsq_id))) - -#define __COMPAT_scx_bpf_dsq_move_set_slice (it__iter, slice) \ - (bpf_ksym_exists(scx_bpf_dsq_move_set_slice) ? \ - scx_bpf_dsq_move_set_slice((it__iter), (slice)) : \ - (bpf_ksym_exists(scx_bpf_dispatch_from_dsq_set_slice___compat) ? \ - scx_bpf_dispatch_from_dsq_set_slice___compat((it__iter), (slice)) : \ - (void)0)) - -#define __COMPAT_scx_bpf_dsq_move_set_vtime (it__iter, vtime) \ - (bpf_ksym_exists(scx_bpf_dsq_move_set_vtime) ? \ - scx_bpf_dsq_move_set_vtime((it__iter), (vtime)) : \ - (bpf_ksym_exists(scx_bpf_dispatch_from_dsq_set_vtime___compat) ? \ - scx_bpf_dispatch_from_dsq_set_vtime___compat((it__iter), (vtime)) : \ - (void) 0)) - -#define __COMPAT_scx_bpf_dsq_move (it__iter, p, dsq_id, enq_flags) \ - (bpf_ksym_exists(scx_bpf_dsq_move) ? \ - scx_bpf_dsq_move((it__iter), (p), (dsq_id), (enq_flags)) : \ - (bpf_ksym_exists(scx_bpf_dispatch_from_dsq___compat) ? \ - scx_bpf_dispatch_from_dsq___compat((it__iter), (p), (dsq_id), (enq_flags)) : \ - false)) - -#define __COMPAT_scx_bpf_dsq_move_vtime (it__iter, p, dsq_id, enq_flags) \ - (bpf_ksym_exists(scx_bpf_dsq_move_vtime) ? \ - scx_bpf_dsq_move_vtime((it__iter), (p), (dsq_id), (enq_flags)) : \ - (bpf_ksym_exists(scx_bpf_dispatch_vtime_from_dsq___compat) ? \ - scx_bpf_dispatch_vtime_from_dsq___compat((it__iter), (p), (dsq_id), (enq_flags)) : \ - false)) -#define __COMPAT_bpf_cpumask_populate (cpumask, src, size__sz) \ (bpf_ksym_exists(bpf_cpumask_populate) ? \ (bpf_cpumask_populate(cpumask, src, size__sz)) : -EOPNOTSUPP) -#define scx_bpf_dispatch (p, dsq_id, slice, enq_flags) \ - _Static_assert(false, "scx_bpf_dispatch() renamed to scx_bpf_dsq_insert()") - -#define scx_bpf_dispatch_vtime (p, dsq_id, slice, vtime, enq_flags) \ - _Static_assert(false, "scx_bpf_dispatch_vtime() renamed to scx_bpf_dsq_insert_vtime()") - -#define scx_bpf_consume (dsq_id) ({ \ - _Static_assert(false, "scx_bpf_consume() renamed to scx_bpf_dsq_move_to_local()"); \ - false; \ -}) - -#define scx_bpf_dispatch_from_dsq_set_slice (it__iter, slice) \ - _Static_assert(false, "scx_bpf_dispatch_from_dsq_set_slice() renamed to scx_bpf_dsq_move_set_slice()") - -#define scx_bpf_dispatch_from_dsq_set_vtime (it__iter, vtime) \ - _Static_assert(false, "scx_bpf_dispatch_from_dsq_set_vtime() renamed to scx_bpf_dsq_move_set_vtime()") - -#define scx_bpf_dispatch_from_dsq (it__iter, p, dsq_id, enq_flags) ({ \ - _Static_assert(false, "scx_bpf_dispatch_from_dsq() renamed to scx_bpf_dsq_move()"); \ - false; \ -}) - -#define scx_bpf_dispatch_vtime_from_dsq (it__iter, p, dsq_id, enq_flags) ({ \ - _Static_assert(false, "scx_bpf_dispatch_vtime_from_dsq() renamed to scx_bpf_dsq_move_vtime()"); \ - false; \ -}) - -#define __COMPAT_scx_bpf_dispatch_from_dsq_set_slice (it__iter, slice) \ - _Static_assert(false, "__COMPAT_scx_bpf_dispatch_from_dsq_set_slice() renamed to __COMPAT_scx_bpf_dsq_move_set_slice()") - -#define __COMPAT_scx_bpf_dispatch_from_dsq_set_vtime (it__iter, vtime) \ - _Static_assert(false, "__COMPAT_scx_bpf_dispatch_from_dsq_set_vtime() renamed to __COMPAT_scx_bpf_dsq_move_set_vtime()") - -#define __COMPAT_scx_bpf_dispatch_from_dsq (it__iter, p, dsq_id, enq_flags) ({ \ - _Static_assert(false, "__COMPAT_scx_bpf_dispatch_from_dsq() renamed to __COMPAT_scx_bpf_dsq_move()"); \ - false; \ -}) - -#define __COMPAT_scx_bpf_dispatch_vtime_from_dsq (it__iter, p, dsq_id, enq_flags) ({ \ - _Static_assert(false, "__COMPAT_scx_bpf_dispatch_vtime_from_dsq() renamed to __COMPAT_scx_bpf_dsq_move_vtime()"); \ - false; \ -}) -/** * __COMPAT_is_enq_cpu_selected - Test if SCX_ENQ_CPU_SELECTED is on * in a compatible way. We will preserve this __COMPAT helper until v6.16.
tools/sched_ext/scx_flatcg.bpf.c +5 -5
@@ -382,7 +382,7 @@ void BPF_STRUCT_OPS(fcg_enqueue, struct task_struct *p, u64 enq_flags)return ; } - cgrp =__COMPAT_scx_bpf_task_cgroup (p); + cgrp =scx_bpf_task_cgroup (p); cgc =find_cgrp_ctx (cgrp);if (!cgc) goto out_release;
@@ -508,7 +508,7 @@ void BPF_STRUCT_OPS(fcg_runnable, struct task_struct *p, u64 enq_flags) {struct cgroup *cgrp; - cgrp =__COMPAT_scx_bpf_task_cgroup (p); + cgrp =scx_bpf_task_cgroup (p);update_active_weight_sums (cgrp, true);bpf_cgroup_release (cgrp); }
@@ -521,7 +521,7 @@ void BPF_STRUCT_OPS(fcg_running, struct task_struct *p)if (fifo_sched)return ; - cgrp =__COMPAT_scx_bpf_task_cgroup (p); + cgrp =scx_bpf_task_cgroup (p); cgc =find_cgrp_ctx (cgrp);if (cgc) {/*
@@ -564,7 +564,7 @@ void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable)if (!taskc->bypassed_at)return ; - cgrp =__COMPAT_scx_bpf_task_cgroup (p); + cgrp =scx_bpf_task_cgroup (p); cgc =find_cgrp_ctx (cgrp);if (cgc) { __sync_fetch_and_add(&cgc->cvtime_delta,
@@ -579,7 +579,7 @@ void BPF_STRUCT_OPS(fcg_quiescent, struct task_struct *p, u64 deq_flags) {struct cgroup *cgrp; - cgrp =__COMPAT_scx_bpf_task_cgroup (p); + cgrp =scx_bpf_task_cgroup (p);update_active_weight_sums (cgrp, false);bpf_cgroup_release (cgrp); }
tools/sched_ext/scx_qmap.bpf.c +5 -9
@@ -320,12 +320,9 @@ static bool dispatch_highpri(bool from_timer)if (tctx->highpri) {/* exercise the set_*() and vtime interface too */ -__COMPAT_scx_bpf_dsq_move_set_slice ( -BPF_FOR_EACH_ITER , slice_ns *2 ); -__COMPAT_scx_bpf_dsq_move_set_vtime ( -BPF_FOR_EACH_ITER , highpri_seq++); -__COMPAT_scx_bpf_dsq_move_vtime ( -BPF_FOR_EACH_ITER , p,HIGHPRI_DSQ ,0 ); +scx_bpf_dsq_move_set_slice (BPF_FOR_EACH_ITER , slice_ns *2 ); +scx_bpf_dsq_move_set_vtime (BPF_FOR_EACH_ITER , highpri_seq++); +scx_bpf_dsq_move_vtime (BPF_FOR_EACH_ITER , p,HIGHPRI_DSQ ,0 ); } }
@@ -342,9 +339,8 @@ static bool dispatch_highpri(bool from_timer)else cpu =scx_bpf_pick_any_cpu (p->cpus_ptr,0 ); -if (__COMPAT_scx_bpf_dsq_move (BPF_FOR_EACH_ITER , p, -SCX_DSQ_LOCAL_ON | cpu, -SCX_ENQ_PREEMPT )) { +if (scx_bpf_dsq_move (BPF_FOR_EACH_ITER , p,SCX_DSQ_LOCAL_ON | cpu, +SCX_ENQ_PREEMPT )) {if (cpu == this_cpu) { dispatched = true;__sync_fetch_and_add (&nr_expedited_local,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/1518 bpf: Require a BPF cpumask for bpf_cpumask_populate()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Dudar <[email protected]>
[ Upstream commit 8740156ad33be5071b588b594c55f279457f667c ]
bpf_cpumask_populate() writes to its destination with bitmap_copy(), but the destination is typed as struct cpumask *. That allows the verifier to accept borrowed cpumask pointers returned by read-only kfuncs, such as scx_bpf_get_online_cpumask(), as a writable destination.
Make the destination a struct bpf_cpumask * so populate follows the same ownership rule as the other mutating cpumask kfuncs. Query kfuncs continue to accept const struct cpumask * inputs.
--- kernel/bpf/cpumask.c | 6 +++--- tools/sched_ext/include/scx/compat.bpf.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
kernel/bpf/cpumask.c +3 -3
@@ -449,12 +449,12 @@ __bpf_kfunc u32 bpf_cpumask_weight(const struct cpumask *cpumask)* @src__sz: Length of the BPF memory region in bytes. * * Return: -* * 0 if the struct cpumask * instance was populated successfully. +* * 0 if the struct bpf_cpumask * instance was populated successfully. * * -EACCES if the memory region is too small to populate the cpumask. * * -EINVAL if the memory region is not aligned to the size of a long * and the architecture does not support efficient unaligned accesses. */ -__bpf_kfunc int bpf_cpumask_populate(struct cpumask *cpumask, void *src, size_t src__sz) +__bpf_kfunc int bpf_cpumask_populate(struct bpf_cpumask *cpumask, void *src, size_t src__sz) {unsigned long source = (unsigned long )src;
@@ -467,7 +467,7 @@ __bpf_kfunc int bpf_cpumask_populate(struct cpumask *cpumask, void *src, size_t !IS_ALIGNED(source, sizeof(long)))return -EINVAL ; -bitmap_copy (cpumask_bits (cpumask), src, nr_cpu_ids); +bitmap_copy (cpumask_bits (&cpumask->cpumask), src, nr_cpu_ids);return 0 ; }
tools/sched_ext/include/scx/compat.bpf.h +1 -1
@@ -20,7 +20,7 @@* * Compat macro will be dropped on v6.19 release. */ -int bpf_cpumask_populate(struct cpumask *dst, void *src, size_t src__sz) __ksym __weak; +int bpf_cpumask_populate(struct bpf_cpumask *dst, void *src, size_t src__sz) __ksym __weak;#define __COMPAT_bpf_cpumask_populate (cpumask, src, size__sz) \ (bpf_ksym_exists(bpf_cpumask_populate) ? \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/1518 wifi: rtw89: pci: add to read PCI configuration space from common code
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping-Ke Shih <[email protected]>
[ Upstream commit dae8d7d63b740d8f5972b8438b139a6488e0f9fa ]
Normally only access PCI device in pci.c. However for debug purpose, a set of registers predefined in firmware element including PCI configuration space should be read for diagnosis.
Stable-dep-of: 9bf6bd6ed5ac ("wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready")
--- drivers/net/wireless/realtek/rtw89/core.h | 13 +++++++++++++ drivers/net/wireless/realtek/rtw89/mac.h | 2 -- drivers/net/wireless/realtek/rtw89/pci.c | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-)
drivers/net/wireless/realtek/rtw89/core.h +13 -0
@@ -38,6 +38,8 @@ extern const struct ieee80211_ops rtw89_ops;#define RFREG_MASK 0xfffff#define INV_RF_DATA 0xffffffff#define BYPASS_CR_DATA 0xbabecafe +#define RTW89_R32_EA 0xEAEAEAEA +#define RTW89_R32_DEAD 0xDEADBEEF#define RTW89_TRACK_WORK_PERIOD round_jiffies_relative(HZ * 2)#define RTW89_TRACK_PS_WORK_PERIOD msecs_to_jiffies(100)
@@ -3652,6 +3654,8 @@ struct rtw89_hci_ops {void (*write16)(struct rtw89_dev *rtwdev,u32 addr,u16 data);void (*write32)(struct rtw89_dev *rtwdev,u32 addr,u32 data); +u32 (*read32_pci_cfg)(struct rtw89_dev *rtwdev,u32 addr); +int (*mac_pre_init)(struct rtw89_dev *rtwdev);int (*mac_pre_deinit)(struct rtw89_dev *rtwdev);int (*mac_post_init)(struct rtw89_dev *rtwdev);
@@ -6626,6 +6630,15 @@ rtw89_write_rf(struct rtw89_dev *rtwdev, enum rtw89_rf_path rf_path,mutex_unlock (&rtwdev->rf_mutex); } +static inline u32 rtw89_read32_pci_cfg (struct rtw89_dev *rtwdev,u32 addr) +{ +if (rtwdev->hci.type !=RTW89_HCI_TYPE_PCIE || + !rtwdev->hci.ops->read32_pci_cfg) +return RTW89_R32_EA ; + +return rtwdev->hci.ops->read32_pci_cfg (rtwdev, addr); +} +static inline struct ieee80211_txq *rtw89_txq_to_txq (struct rtw89_txq *rtwtxq) {void *p = rtwtxq;
drivers/net/wireless/realtek/rtw89/mac.h +0 -2
@@ -574,8 +574,6 @@ enum rtw89_mac_bf_rrsc_rate {RTW89_MAC_BF_RRSC_MAX =32 }; -#define RTW89_R32_EA 0xEAEAEAEA -#define RTW89_R32_DEAD 0xDEADBEEF#define MAC_REG_POOL_COUNT 10#define ACCESS_CMAC (_addr) \ ({typeof(_addr) __addr = (_addr); \
drivers/net/wireless/realtek/rtw89/pci.c +16 -0
@@ -2071,6 +2071,20 @@ static void rtw89_pci_ops_write32(struct rtw89_dev *rtwdev, u32 addr, u32 data)writel (data, rtwpci->mmap + addr); } +static u32 rtw89_pci_ops_read32_pci_cfg (struct rtw89_dev *rtwdev,u32 addr) +{ +struct rtw89_pci *rtwpci = (struct rtw89_pci *)rtwdev->priv; +struct pci_dev *pdev = rtwpci->pdev; +u32 value; +int ret; + + ret =pci_read_config_dword (pdev, addr, &value); +if (ret) +return RTW89_R32_EA ; + +return value; +} +static void rtw89_pci_ctrl_dma_trx (struct rtw89_dev *rtwdev,bool enable) {const struct rtw89_pci_info *info = rtwdev->pci_info;
@@ -4691,6 +4705,8 @@ static const struct rtw89_hci_ops rtw89_pci_ops = { .write16 = rtw89_pci_ops_write16, .write32 = rtw89_pci_ops_write32, + .read32_pci_cfg = rtw89_pci_ops_read32_pci_cfg, + .mac_pre_init = rtw89_pci_ops_mac_pre_init, .mac_pre_deinit = rtw89_pci_ops_mac_pre_deinit, .mac_post_init = rtw89_pci_ops_mac_post_init,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/1518 wifi: rtw89: fw: parse firmware element of DIAG_MAC
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping-Ke Shih <[email protected]>
[ Upstream commit de19cc7def5a9c646264a1e7a2a183a3baad112f ]
The firmware element ID 28 is a set of rules to diagnose if MAC get abnormal. The latter patch will use these rules via debugfs to know the status.
The element contains rules with their textual messages shown as below:
+------------------------------------+ | | | +-----------+ | | | rule_size |-------|----------+ +----------------+-----------+-------+ -- | | rule[0] | \ | | rule[1] | | <---+ | : | / +------------------------------------+ -- | msg[0] msg[1] | each msg has variable length | msg[2] msg[3] ... | (with address align 2) | ... | +------------------------------------+
Stable-dep-of: 9bf6bd6ed5ac ("wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready")
--- drivers/net/wireless/realtek/rtw89/core.h | 1 + drivers/net/wireless/realtek/rtw89/fw.c | 15 +++++++++++++++ drivers/net/wireless/realtek/rtw89/fw.h | 6 ++++++ 3 files changed, 22 insertions(+)
drivers/net/wireless/realtek/rtw89/core.h +1 -0
@@ -4705,6 +4705,7 @@ struct rtw89_fw_elm_info {struct rtw89_phy_rfk_log_fmt *rfk_log_fmt;const struct rtw89_regd_data *regd;const struct rtw89_fw_element_hdr *afe; +const struct rtw89_fw_element_hdr *diag_mac; };enum rtw89_fw_mss_dev_type {
drivers/net/wireless/realtek/rtw89/fw.c +15 -0
@@ -1299,6 +1299,18 @@ int rtw89_build_afe_pwr_seq_from_elm(struct rtw89_dev *rtwdev,return 0 ; } +static +int rtw89_recognize_diag_mac_from_elm (struct rtw89_dev *rtwdev, +const struct rtw89_fw_element_hdr *elm, +const union rtw89_fw_element_arg arg) +{ +struct rtw89_fw_elm_info *elm_info = &rtwdev->fw.elm_info; + + elm_info->diag_mac = elm; + +return 0 ; +} +static const struct rtw89_fw_element_handler __fw_element_handlers[] = { [RTW89_FW_ELEMENT_ID_BBMCU0 ] = {__rtw89_fw_recognize_from_elm, { .fw_type =RTW89_FW_BBMCU0 },NULL },
@@ -1387,6 +1399,9 @@ static const struct rtw89_fw_element_handler __fw_element_handlers[] = { [RTW89_FW_ELEMENT_ID_AFE_PWR_SEQ ] = { rtw89_build_afe_pwr_seq_from_elm, {},"AFE" , }, + [RTW89_FW_ELEMENT_ID_DIAG_MAC ] = { + rtw89_recognize_diag_mac_from_elm, {},NULL , + }, };int rtw89_fw_recognize_elements (struct rtw89_dev *rtwdev)
drivers/net/wireless/realtek/rtw89/fw.h +6 -0
@@ -3989,6 +3989,7 @@ enum rtw89_fw_element_id {RTW89_FW_ELEMENT_ID_TXPWR_DA_LMT_RU_5GHZ =25 ,RTW89_FW_ELEMENT_ID_TXPWR_DA_LMT_RU_6GHZ =26 ,RTW89_FW_ELEMENT_ID_AFE_PWR_SEQ =27 , +RTW89_FW_ELEMENT_ID_DIAG_MAC =28 , RTW89_FW_ELEMENT_ID_NUM, };
@@ -4166,6 +4167,11 @@ struct rtw89_fw_element_hdr {__le32 val; }__packed infos[]; }__packed afe; +struct { +__le32 rule_size; +u8 rsvd[4 ]; +u8 rules_and_msgs[]; + } __packed diag_mac;struct __rtw89_fw_txpwr_element txpwr;struct __rtw89_fw_regd_element regd; }__packed u;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/1518 wifi: rtw89: debug: add parser to diagnose along DIAG_MAC fw element
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping-Ke Shih <[email protected]>
[ Upstream commit 7bf433c6767ffe2ad5b7ac8680c6e93e7d0be3e4 ]
The rules to diagnose MAC have a common header, and a cmd field is used to know the exact command and its format. The rules with the same tuple of fields {sheet, seq} can be seen as a set of compound rules, which treat it as positive rule if just one of the rules is positive.
Take EQUALV rules as example, if value of {addr, mask} is equal to predefined value as field val, a rule is positive. Fields addr_name_offset and msg_offset are offsets related to textual messages for human readable.
Format of common rule header (8 bytes)
+-------+-----+--------+-----------+-----+---------+ | sheet | cmd | seq[2] | io / band | len | rsvd[2] | +-------+-----+--------+-----------+-----+---------+
Format of rule command is EQUALV (equal value) (24 bytes):
+------+------------------+------+-----+------------+---------+ | addr | addr_name_offset | mask | val | msg_offset | rsvd[4] | +------+------------------+------+-----+------------+---------+
Format of message:
+-----+----------+ | len | string[] | +-----+----------+
An example of output:
Plain(Ignore)/Rules/Positive: 115(4)/86/81
Where, Plain is total rules written in firmware element.
Ignore is the ignored rules, such as USB IO, but current is PCIE. Rules is number of set of compound rules.
Positive is number of positive Rules.
Stable-dep-of: 9bf6bd6ed5ac ("wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready")
--- drivers/net/wireless/realtek/rtw89/debug.c | 299 +++++++++++++++++++++ 1 file changed, 299 insertions(+)
drivers/net/wireless/realtek/rtw89/debug.c +299 -0
@@ -87,6 +87,7 @@ struct rtw89_debugfs {struct rtw89_debugfs_priv disable_dm;struct rtw89_debugfs_priv mlo_mode;struct rtw89_debugfs_priv beacon_info; +struct rtw89_debugfs_priv diag_mac; };struct rtw89_debugfs_iter_data {
@@ -4361,6 +4362,302 @@ rtw89_debug_priv_mlo_mode_set(struct rtw89_dev *rtwdev,return count; } +enum __diag_mac_cmd { + __CMD_EQUALV, + __CMD_EQUALO, + __CMD_NEQUALV, + __CMD_NEQUALO, + __CMD_SETEQUALV, + __CMD_SETEQUALO, + __CMD_CMPWCR, + __CMD_CMPWWD, + __CMD_NEQ_CMPWCR, + __CMD_NEQ_CMPWWD, + __CMD_INCREMENT, + __CMD_MESSAGE, +}; + +enum __diag_mac_io { + __IO_NORMAL, + __IO_NORMAL_PCIE, + __IO_NORMAL_USB, + __IO_NORMAL_SDIO, + __IO_PCIE_CFG, + __IO_SDIO_CCCR, +}; + +struct __diag_mac_rule_header { +u8 sheet; +u8 cmd; +u8 seq_major; +u8 seq_minor; +u8 io_band; +#define __DIAG_MAC_IO GENMASK(3, 0) +#define __DIAG_MAC_N_BAND BIT(4) +#define __DIAG_MAC_HAS_BAND BIT(5) +u8 len;/* include header. Unit: 4 bytes */ +u8 rsvd[2 ]; +} __packed; + +struct __diag_mac_rule_equal { +struct __diag_mac_rule_header header; +__le32 addr; +__le32 addr_name_offset; +__le32 mask; +__le32 val; +__le32 msg_offset; +u8 rsvd[4 ]; +} __packed; + +struct __diag_mac_rule_increment { +struct __diag_mac_rule_header header; +__le32 addr; +__le32 addr_name_offset; +__le32 mask; +__le16 sel; +__le16 delay; +__le32 msg_offset; +u8 rsvd[4 ]; +} __packed; + +struct __diag_mac_msg_buf { +__le16 len; +char string[]; +} __packed; + +static ssize_t rtw89_mac_diag_do_equalv (struct rtw89_dev *rtwdev, +char *buf,size_t bufsz, +const struct __diag_mac_rule_equal *r, +const void *msg_start, +u64 *positive_bmp) +{ +const struct __diag_mac_msg_buf *name = msg_start + +le32_to_cpu (r->addr_name_offset); +const struct __diag_mac_msg_buf *msg = msg_start + +le32_to_cpu (r->msg_offset); +bool want_eq = r->header.cmd == __CMD_EQUALV; +char *p = buf, *end = buf + bufsz; +bool equal = false; +u32 val; + + *positive_bmp <<=1 ; + +if (u8_get_bits (r->header.io_band, __DIAG_MAC_IO) == __IO_PCIE_CFG) + val =rtw89_read32_pci_cfg (rtwdev,le32_to_cpu (r->addr)); +else + val =rtw89_read32 (rtwdev,le32_to_cpu (r->addr)); + +if ((val &le32_to_cpu (r->mask)) ==le32_to_cpu (r->val)) + equal = true; + +if (want_eq == equal) { + *positive_bmp |=BIT (0 ); +return p - buf; + } + + p +=scnprintf (p, end - p,"sheet: %d, cmd: %d, Reg: %.*s => %x, %.*s\n" , + r->header.sheet, r->header.cmd,le16_to_cpu (name->len), + name->string, val,le16_to_cpu (msg->len), msg->string); + +return p - buf; +} + +static ssize_t rtw89_mac_diag_do_increment (struct rtw89_dev *rtwdev, +char *buf,size_t bufsz, +const struct __diag_mac_rule_increment *r, +const void *msg_start, +u64 *positive_bmp) +{ +const struct __diag_mac_msg_buf *name = msg_start + +le32_to_cpu (r->addr_name_offset); +const struct __diag_mac_msg_buf *msg = msg_start + +le32_to_cpu (r->msg_offset); +char *p = buf, *end = buf + bufsz; +u32 addr =le32_to_cpu (r->addr); +u32 mask =le32_to_cpu (r->mask); +u16 sel =le16_to_cpu (r->sel); +u32 val1, val2; + + *positive_bmp <<=1 ; + +rtw89_write32 (rtwdev, addr, sel); + +if (u8_get_bits (r->header.io_band, __DIAG_MAC_IO) == __IO_PCIE_CFG) + val1 =rtw89_read32_pci_cfg (rtwdev, addr); +else + val1 =rtw89_read32 (rtwdev, addr); + +mdelay (le16_to_cpu (r->delay)); + +if (u8_get_bits (r->header.io_band, __DIAG_MAC_IO) == __IO_PCIE_CFG) + val2 =rtw89_read32_pci_cfg (rtwdev, addr); +else + val2 =rtw89_read32 (rtwdev, addr); + +if ((val2 & mask) > (val1 & mask)) { + *positive_bmp |=BIT (0 ); +return p - buf; + } + + p +=scnprintf (p, end - p,"sheet: %d, cmd: %d, Reg: %.*s [%d]=> %x, %.*s\n" , + r->header.sheet, r->header.cmd,le16_to_cpu (name->len), + name->string,le16_to_cpu (r->sel), val1, +le16_to_cpu (msg->len), msg->string); + +return p - buf; +} + +static bool rtw89_mac_diag_match_hci (struct rtw89_dev *rtwdev, +const struct __diag_mac_rule_header *rh) +{ +switch (u8_get_bits (rh->io_band, __DIAG_MAC_IO)) { +case __IO_NORMAL: +default : +return true; +case __IO_NORMAL_PCIE: +case __IO_PCIE_CFG: +if (rtwdev->hci.type ==RTW89_HCI_TYPE_PCIE ) +return true; +break ; +case __IO_NORMAL_USB: +if (rtwdev->hci.type ==RTW89_HCI_TYPE_USB ) +return true; +break ; +case __IO_NORMAL_SDIO: +case __IO_SDIO_CCCR: +if (rtwdev->hci.type ==RTW89_HCI_TYPE_SDIO ) +return true; +break ; + } + +return false; +} + +static bool rtw89_mac_diag_match_band (struct rtw89_dev *rtwdev, +const struct __diag_mac_rule_header *rh) +{ +u8 active_bands; +bool has_band; +u8 band; + + has_band =u8_get_bits (rh->io_band, __DIAG_MAC_HAS_BAND); +if (!has_band) +return true; + + band =u8_get_bits (rh->io_band, __DIAG_MAC_N_BAND); + active_bands =rtw89_get_active_phy_bitmap (rtwdev); + +if (active_bands &BIT (band)) +return true; + +return false; +} + +static ssize_t rtw89_mac_diag_iter_all (struct rtw89_dev *rtwdev, +char *buf,size_t bufsz) +{ +const struct rtw89_fw_element_hdr *elm = rtwdev->fw.elm_info.diag_mac; +u32 n_plains =0 , n_rules =0 , n_positive =0 , n_ignore =0 ; +char *p = buf, *end = buf + bufsz, *p_rewind; +const void *rule, *rule_end; +u32 elm_size, rule_size; +const void *msg_start; +u64 positive_bmp =0 ; +u8 prev_sheet =0 ; +u8 prev_seq =0 ; +int limit; + +if (!elm) { + p +=scnprintf (p, end - p,"No diag_mac entry\n" ); + goto out; + } + + rule_size =le32_to_cpu (elm->u.diag_mac.rule_size); + elm_size =le32_to_cpu (elm->size); + +if (ALIGN (rule_size,16 ) > elm_size) { + p +=scnprintf (p, end - p,"rule size (%u) exceed elm_size (%u)\n" , +ALIGN (rule_size,16 ), elm_size); + goto out; + } + + rule = &elm->u.diag_mac.rules_and_msgs[0 ]; + rule_end = &elm->u.diag_mac.rules_and_msgs[rule_size]; + msg_start = &elm->u.diag_mac.rules_and_msgs[ALIGN (rule_size,16 )]; + +for (limit =0 ; limit <5000 && rule < rule_end; limit++) { +const struct __diag_mac_rule_header *rh = rule; +u8 sheet = rh->sheet; +u8 seq = rh->seq_major; + +if (!rtw89_mac_diag_match_hci (rtwdev, rh) || + !rtw89_mac_diag_match_band (rtwdev, rh)) { + n_ignore++; + goto next; + } + +if (!seq || prev_sheet != sheet || prev_seq != seq) { +if (positive_bmp) { + n_positive++; +/* +* discard output for negative results if one in +* a sequence set is positive. +*/ +if (p_rewind) + p = p_rewind; + } + p_rewind = seq ? p :NULL ; + positive_bmp =0 ; + n_rules++; + } + +switch (rh->cmd) { +case __CMD_EQUALV: +case __CMD_NEQUALV: + p +=rtw89_mac_diag_do_equalv (rtwdev, p, end - p, rule, + msg_start, &positive_bmp); +break ; +case __CMD_INCREMENT: + p +=rtw89_mac_diag_do_increment (rtwdev, p, end - p, rule, + msg_start, &positive_bmp); +break ; +default : + p +=scnprintf (p, end - p,"unknown rule cmd %u\n" , rh->cmd); +break ; + } + +next: + n_plains++; + rule += rh->len *4 ; + prev_seq = seq; + prev_sheet = sheet; + } + +if (positive_bmp) { + n_positive++; +if (p_rewind) + p = p_rewind; + } + + p +=scnprintf (p, end - p,"\nPlain(Ignore)/Rules/Positive: %u(%u)/%u/%u\n" , + n_plains, n_ignore, n_rules, n_positive); + +out: +return p - buf; +} + +static ssize_t +rtw89_debug_priv_diag_mac_get (struct rtw89_dev *rtwdev, +struct rtw89_debugfs_priv *debugfs_priv, +char *buf,size_t bufsz) +{ +lockdep_assert_wiphy (rtwdev->hw->wiphy); + +rtw89_leave_lps (rtwdev); + +return rtw89_mac_diag_iter_all (rtwdev, buf, bufsz); +} + static ssize_t rtw89_debug_priv_beacon_info_get(struct rtw89_dev *rtwdev, struct rtw89_debugfs_priv *debugfs_priv,
@@ -4478,6 +4775,7 @@ static const struct rtw89_debugfs rtw89_debugfs_templ = { .disable_dm = rtw89_debug_priv_set_and_get(disable_dm, RWLOCK), .mlo_mode = rtw89_debug_priv_set_and_get(mlo_mode, RWLOCK), .beacon_info = rtw89_debug_priv_get(beacon_info), + .diag_mac = rtw89_debug_priv_get(diag_mac, RSIZE_16K, RLOCK), };#define rtw89_debugfs_add (name, mode, fopname, parent) \
@@ -4524,6 +4822,7 @@ void rtw89_debugfs_add_sec1(struct rtw89_dev *rtwdev, struct dentry *debugfs_toprtw89_debugfs_add_rw (disable_dm);rtw89_debugfs_add_rw (mlo_mode);rtw89_debugfs_add_r (beacon_info); +rtw89_debugfs_add_r (diag_mac); }void rtw89_debugfs_init (struct rtw89_dev *rtwdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/1518 wifi: rtw89: mlo: rearrange MLSR link decision flow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Chung Chen <[email protected]>
[ Upstream commit 7284f5be5d298c901be1fc9fda6a2476f5ffdbaf ]
The original MLSR link decision refers to RSSI, but it should be based on the premise of an existing link. Otherwise, make a link decision to select a new link from any available band.
Stable-dep-of: 9bf6bd6ed5ac ("wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready")
--- drivers/net/wireless/realtek/rtw89/core.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +7 -7
@@ -4270,13 +4270,19 @@ static void rtw89_core_mlsr_link_decision(struct rtw89_dev *rtwdev, {unsigned int sel_link_id =IEEE80211_MLD_MAX_NUM_LINKS ;struct ieee80211_vif *vif =rtwvif_to_vif (rtwvif); +u8 decided_bands =BIT (RTW89_BAND_NUM ) -1 ;struct rtw89_vif_link *rtwvif_link;const struct rtw89_chan *chan;unsigned long usable_links;unsigned int link_id; -u8 decided_bands;u8 rssi; + usable_links =ieee80211_vif_usable_links (vif); + + rtwvif_link =rtw89_get_designated_link (rtwvif); +if (unlikely (!rtwvif_link)) + goto select; + rssi =ewma_rssi_read (&rtwdev->phystat.bcn_rssi);if (unlikely (!rssi))return ;
@@ -4288,12 +4294,6 @@ static void rtw89_core_mlsr_link_decision(struct rtw89_dev *rtwdev,else return ; - usable_links =ieee80211_vif_usable_links (vif); - - rtwvif_link =rtw89_get_designated_link (rtwvif); -if (unlikely (!rtwvif_link)) - goto select; - chan =rtw89_chan_get (rtwdev, rtwvif_link->chanctx_idx);if (decided_bands &BIT (chan->band_type))return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/1518 wifi: rtw89: phy: support per PHY RX statistics
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuan-Chung Chen <[email protected]>
[ Upstream commit 09d369c66373de8708e442a30460ced17f254915 ]
Previously, RX statistics such as beacon RSSI and packet counters were shared across all PHYs. To support MLO, extend the statistics to be maintained per PHY.
Update the debugfs output for phy_info and beacon_info to include a "[PHY X]" label for better clarity.
The output of phy_info:
TP TX: 0 [0] Mbps (lv: 0), RX: 0 [0] Mbps (lv: 0) Avg packet length: TX=0, RX=120
TF: 0
[PHY 0]
Beacon: 19 (-45 dBm)
RX count:
Legacy: [0, 0, 0, 0]
...
EHT 2SS: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]The output of beacon_info:
[PHY 0]
Beacon: 20
raw rssi: 131
hw rate: 4
length: 437
[Beacon info]
interval: 100
dtim: 1
Stable-dep-of: 9bf6bd6ed5ac ("wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready")
--- drivers/net/wireless/realtek/rtw89/core.c | 26 ++++-- drivers/net/wireless/realtek/rtw89/core.h | 6 +- drivers/net/wireless/realtek/rtw89/debug.c | 88 ++++++++++++------- drivers/net/wireless/realtek/rtw89/fw.c | 6 +- drivers/net/wireless/realtek/rtw89/phy.c | 17 ++-- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 5 +- 6 files changed, 97 insertions(+), 51 deletions(-)
drivers/net/wireless/realtek/rtw89/core.c +17 -9
@@ -2499,12 +2499,14 @@ static u16 rtw89_bcn_get_histogram_bound(struct rtw89_dev *rtwdev, u8 target) }static u16 rtw89_bcn_get_rx_time (struct rtw89_dev *rtwdev, -const struct rtw89_chan *chan) +struct rtw89_vif_link *rtwvif_link) {#define RTW89_SYMBOL_TIME_2GHZ 192#define RTW89_SYMBOL_TIME_5GHZ 20#define RTW89_SYMBOL_TIME_6GHZ 20 -struct rtw89_pkt_stat *pkt_stat = &rtwdev->phystat.cur_pkt_stat; +const struct rtw89_chan *chan =rtw89_chan_get (rtwdev, rtwvif_link->chanctx_idx); +struct rtw89_bb_ctx *bb =rtw89_get_bb_ctx (rtwdev, rtwvif_link->phy_idx); +struct rtw89_pkt_stat *pkt_stat = &bb->cur_pkt_stat;u16 bitrate, val;if (!rtw89_legacy_rate_to_bitrate (rtwdev, pkt_stat->beacon_rate, &bitrate))
@@ -2535,15 +2537,15 @@ static void rtw89_bcn_calc_timeout(struct rtw89_dev *rtwdev,#define RTW89_BCN_TRACK_EXTEND_TIMEOUT 5#define RTW89_BCN_TRACK_COVERAGE_TH 0/* unit: TU */ #define RTW89_BCN_TRACK_STRONG_RSSI 80 -const struct rtw89_chan *chan =rtw89_chan_get (rtwdev, rtwvif_link->chanctx_idx); -struct rtw89_pkt_stat *pkt_stat = &rtwdev->phystat.cur_pkt_stat; +struct rtw89_bb_ctx *bb =rtw89_get_bb_ctx (rtwdev, rtwvif_link->phy_idx);struct rtw89_beacon_stat *bcn_stat = &rtwdev->phystat.bcn_stat;struct rtw89_beacon_track_info *bcn_track = &rtwdev->bcn_track; +struct rtw89_pkt_stat *pkt_stat = &bb->cur_pkt_stat;struct rtw89_beacon_dist *bcn_dist = &bcn_stat->bcn_dist;u16 outlier_high_bcn_th = bcn_track->outlier_high_bcn_th;u16 outlier_low_bcn_th = bcn_track->outlier_low_bcn_th; -u8 rssi =ewma_rssi_read (&rtwdev->phystat.bcn_rssi);u16 target_bcn_th = bcn_track->target_bcn_th; +u8 rssi =ewma_rssi_read (&bb->bcn_rssi);u16 low_bcn_th = bcn_track->low_bcn_th;u16 med_bcn_th = bcn_track->med_bcn_th;u16 beacon_int = bcn_track->beacon_int;
@@ -2589,7 +2591,7 @@ static void rtw89_bcn_calc_timeout(struct rtw89_dev *rtwdev, bcn_timeout = bcn_stat->drift[target_bcn_th]; out: - bcn_track->bcn_timeout = bcn_timeout +rtw89_bcn_get_rx_time (rtwdev, chan); + bcn_track->bcn_timeout = bcn_timeout +rtw89_bcn_get_rx_time (rtwdev, rtwvif_link); } static void rtw89_bcn_update_timeout(struct rtw89_dev *rtwdev,
@@ -2733,7 +2735,6 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac,struct rtw89_vif_rx_stats_iter_data *iter_data = data;struct rtw89_dev *rtwdev = iter_data->rtwdev;struct rtw89_vif *rtwvif =vif_to_rtwvif (vif); -struct rtw89_pkt_stat *pkt_stat = &rtwdev->phystat.cur_pkt_stat;struct rtw89_rx_desc_info *desc_info = iter_data->desc_info;struct sk_buff *skb = iter_data->skb;struct ieee80211_rx_status *rx_status =IEEE80211_SKB_RXCB (skb);
@@ -2743,6 +2744,8 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac,struct ieee80211_bss_conf *bss_conf;struct rtw89_vif_link *rtwvif_link;const u8 *bssid = iter_data->bssid; +struct rtw89_pkt_stat *pkt_stat; +struct rtw89_bb_ctx *bb;const u8 *target_bssid; if (rtwdev->scanning &&
@@ -2776,6 +2779,9 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac, rx_status->link_id = rtwvif_link->link_id; } + bb =rtw89_get_bb_ctx (rtwdev, rtwvif_link->phy_idx); + pkt_stat = &bb->cur_pkt_stat; +if (ieee80211_is_beacon (hdr->frame_control)) {if (vif->type ==NL80211_IFTYPE_STATION && !test_bit (RTW89_FLAG_WOWLAN , rtwdev->flags)) {
@@ -2784,7 +2790,7 @@ static void rtw89_vif_rx_stats_iter(void *data, u8 *mac, }if (phy_ppdu) { -ewma_rssi_add (&rtwdev->phystat.bcn_rssi, phy_ppdu->rssi_avg); +ewma_rssi_add (&bb->bcn_rssi, phy_ppdu->rssi_avg);if (!test_bit (RTW89_FLAG_LOW_POWER_MODE , rtwdev->flags)) rtwvif_link->bcn_bw_idx = phy_ppdu->bw_idx; }
@@ -4274,6 +4280,7 @@ static void rtw89_core_mlsr_link_decision(struct rtw89_dev *rtwdev,struct rtw89_vif_link *rtwvif_link;const struct rtw89_chan *chan;unsigned long usable_links; +struct rtw89_bb_ctx *bb;unsigned int link_id;u8 rssi;
@@ -4283,7 +4290,8 @@ static void rtw89_core_mlsr_link_decision(struct rtw89_dev *rtwdev,if (unlikely (!rtwvif_link)) goto select; - rssi =ewma_rssi_read (&rtwdev->phystat.bcn_rssi); + bb =rtw89_get_bb_ctx (rtwdev, rtwvif_link->phy_idx); + rssi =ewma_rssi_read (&bb->bcn_rssi);if (unlikely (!rssi))return ;
drivers/net/wireless/realtek/rtw89/core.h +3 -3
@@ -5136,9 +5136,6 @@ DECLARE_EWMA(thermal, 4, 4);struct rtw89_phy_stat {struct ewma_thermal avg_thermal[RF_PATH_MAX ];u8 last_thermal_max; -struct ewma_rssi bcn_rssi; -struct rtw89_pkt_stat cur_pkt_stat; -struct rtw89_pkt_stat last_pkt_stat;struct rtw89_beacon_stat bcn_stat; };
@@ -6063,6 +6060,9 @@ struct rtw89_dev {struct rtw89_dig_info dig;struct rtw89_phy_ch_info ch_info;struct rtw89_edcca_bak edcca_bak; +struct ewma_rssi bcn_rssi; +struct rtw89_pkt_stat cur_pkt_stat; +struct rtw89_pkt_stat last_pkt_stat; } bbs[RTW89_PHY_NUM ];struct wiphy_delayed_work track_work;
drivers/net/wireless/realtek/rtw89/debug.c +58 -30
131 lines not on this page · raw message
drivers/net/wireless/realtek/rtw89/fw.c +5 -1
@@ -3008,14 +3008,15 @@ int rtw89_fw_h2c_lps_ml_cmn_info(struct rtw89_dev *rtwdev, struct rtw89_vif *rtwvif) {const struct rtw89_phy_bb_gain_info_be *gain = &rtwdev->bb_gain.be; -struct rtw89_pkt_stat *pkt_stat = &rtwdev->phystat.cur_pkt_stat;static const u8 bcn_bw_ofst[] = {0 ,0 ,0 ,3 ,6 ,9 ,0 ,12 };const struct rtw89_chip_info *chip = rtwdev->chip;struct rtw89_efuse *efuse = &rtwdev->efuse;struct rtw89_h2c_lps_ml_cmn_info *h2c;struct rtw89_vif_link *rtwvif_link; +struct rtw89_pkt_stat *pkt_stat;const struct rtw89_chan *chan;u8 bw_idx =RTW89_BB_BW_20_40 ; +struct rtw89_bb_ctx *bb;u32 len =sizeof (*h2c);unsigned int link_id;struct sk_buff *skb;
@@ -3046,11 +3047,14 @@ int rtw89_fw_h2c_lps_ml_cmn_info(struct rtw89_dev *rtwdev, path = rtwvif_link->phy_idx ==RTW89_PHY_1 ?RF_PATH_B :RF_PATH_A ; chan =rtw89_chan_get (rtwdev, rtwvif_link->chanctx_idx); gain_band =rtw89_subband_to_gain_band_be (chan->subband_type); + bb =rtw89_get_bb_ctx (rtwdev, rtwvif_link->phy_idx); h2c->central_ch[rtwvif_link->phy_idx] = chan->channel; h2c->pri_ch[rtwvif_link->phy_idx] = chan->primary_channel; h2c->band[rtwvif_link->phy_idx] = chan->band_type; h2c->bw[rtwvif_link->phy_idx] = chan->band_width; + + pkt_stat = &bb->cur_pkt_stat;if (pkt_stat->beacon_rate <RTW89_HW_RATE_OFDM6 ) h2c->bcn_rate_type[rtwvif_link->phy_idx] =0x1 ;else
drivers/net/wireless/realtek/rtw89/phy.c +11 -6
@@ -5392,6 +5392,7 @@ static void rtw89_phy_stat_rssi_update(struct rtw89_dev *rtwdev)static void rtw89_phy_stat_init (struct rtw89_dev *rtwdev) {struct rtw89_phy_stat *phystat = &rtwdev->phystat; +struct rtw89_bb_ctx *bb;int i;for (i =0 ; i < rtwdev->chip->rf_path_num; i++)
@@ -5399,24 +5400,28 @@ static void rtw89_phy_stat_init(struct rtw89_dev *rtwdev)rtw89_phy_stat_thermal_update (rtwdev); -memset (&phystat->cur_pkt_stat,0 ,sizeof (phystat->cur_pkt_stat)); -memset (&phystat->last_pkt_stat,0 ,sizeof (phystat->last_pkt_stat)); +rtw89_for_each_capab_bb (rtwdev, bb) { +memset (&bb->cur_pkt_stat,0 ,sizeof (bb->cur_pkt_stat)); +memset (&bb->last_pkt_stat,0 ,sizeof (bb->last_pkt_stat)); -ewma_rssi_init (&phystat->bcn_rssi); +ewma_rssi_init (&bb->bcn_rssi); + } rtwdev->hal.thermal_prot_lv =0 ; }void rtw89_phy_stat_track (struct rtw89_dev *rtwdev) { -struct rtw89_phy_stat *phystat = &rtwdev->phystat; +struct rtw89_bb_ctx *bb;rtw89_phy_stat_thermal_update (rtwdev);rtw89_phy_thermal_protect (rtwdev);rtw89_phy_stat_rssi_update (rtwdev); - phystat->last_pkt_stat = phystat->cur_pkt_stat; -memset (&phystat->cur_pkt_stat,0 ,sizeof (phystat->cur_pkt_stat)); +rtw89_for_each_active_bb (rtwdev, bb) { + bb->last_pkt_stat = bb->cur_pkt_stat; +memset (&bb->cur_pkt_stat,0 ,sizeof (bb->cur_pkt_stat)); + } } static u16 rtw89_phy_ccx_us_to_idx(struct rtw89_dev *rtwdev,
drivers/net/wireless/realtek/rtw89/rtw8852a.c +3 -2
@@ -2107,13 +2107,14 @@ static void rtw8852a_query_ppdu(struct rtw89_dev *rtwdev,struct rtw89_rx_phy_ppdu *phy_ppdu, struct ieee80211_rx_status *status) { - u8 path; + struct rtw89_bb_ctx *bb = rtw89_get_bb_ctx(rtwdev, phy_ppdu->phy_idx);u8 *rx_power = phy_ppdu->rssi; +u8 path;u8 raw;if (!status->signal) {if (phy_ppdu->to_self) - raw =ewma_rssi_read (&rtwdev->phystat.bcn_rssi); + raw =ewma_rssi_read (&bb->bcn_rssi);else raw =max (rx_power[RF_PATH_A ], rx_power[RF_PATH_B ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/1518 wifi: rtw89: 8852a: fix RSSI report when average beacon RSSI is not ready
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chih-Kang Chang <[email protected]>
[ Upstream commit 9bf6bd6ed5accb57544d04ded911a2ef1642d48f ]
8852A uses the average beacon RSSI to smooth the RSSI. However, before the average beacon RSSI is available, the RSSI should use the PPDU status RSSI of the received packet to avoid reporting the RSSI as -110 dBm.
--- drivers/net/wireless/realtek/rtw89/rtw8852a.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw89/rtw8852a.c +1 -1
@@ -2113,7 +2113,7 @@ static void rtw8852a_query_ppdu(struct rtw89_dev *rtwdev,u8 raw;if (!status->signal) { -if (phy_ppdu->to_self) +if (phy_ppdu->to_self &&ewma_rssi_read (&bb->bcn_rssi)) raw =ewma_rssi_read (&bb->bcn_rssi);else raw =max (rx_power[RF_PATH_A ], rx_power[RF_PATH_B ]);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/1518 iio: accel: dmard09: Implement IIO_CHAN_INFO_SCALE
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mert Seftali <[email protected]>
[ Upstream commit aa58ecc73466d0cb8c418de98e2225490bf600e3 ]
Reading the in_accel_scale attribute on the DMARD09 has always returned -EINVAL: the channels advertise scale via info_mask_shared_by_type so the IIO core exposes the attribute, but dmard09_read_raw() only handles IIO_CHAN_INFO_RAW, so a SCALE read falls through to 'default: return -EINVAL':
$ cat .../iio:deviceX/in_accel_scale
cat: in_accel_scale: Invalid argumentleaving userspace with raw counts it cannot convert to m/s^2.
The driver was written from a vendor source [1] without a datasheet, and the scale was declared but never implemented. The vendor source carries the sensitivity: its conversion is
acc = raw * GRAVITY_EARTH_1000 / sensitivity (then / 1000 -> m/s^2)
with sensitivity = 32 and GRAVITY_EARTH_1000 = 9807 ("about (9.80665)*1000"), i.e. 32 counts correspond to 1 g.
That sensitivity applies to the value this driver already reports as raw:
the vendor reduces each 16-bit sample to a signed 9-bit value, and the preparation in dmard09_read_raw() yields the same value. It is
self-consistent: 256 counts / 32 = 8 g full scale, matching the +/-8g range.
Implement the scale derived from that sensitivity using standard gravity:
scale = 9.80665 / 32 = 0.3064578125 m/s^2 per LSB
--- drivers/iio/accel/dmard09.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/iio/accel/dmard09.c +7 -0
@@ -8,6 +8,7 @@#include <linux/unaligned.h> #include <linux/module.h> #include <linux/i2c.h> +#include <linux/units.h> #include <linux/iio/iio.h> #define DMARD09_DRV_NAME "dmard09"
@@ -79,6 +80,12 @@ static int dmard09_read_raw(struct iio_dev *indio_dev, *val = accel;return IIO_VAL_INT ; +case IIO_CHAN_INFO_SCALE : + *val =0 ; +/* 1 g / 32 LSB, in m/s^2 */ + *val2 =IIO_G_TO_M_S_2 (NANO /32 ); + +return IIO_VAL_INT_PLUS_NANO ;default :return -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/1518 RDMA/core: Wait for RCU callbacks before unloading ib_core
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 7d75592114d1664623c8cf191a12b38052c04483 ]
put_gid_ndev() is queued with call_rcu() and implemented in ib_core. Stopping the workqueues does not drain callbacks already queued, so RCU could invoke it after the module code has been unloaded.
synchronize_rcu() does not wait for callbacks. Wait for them after all producers have stopped.
--- drivers/infiniband/core/device.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/core/device.c +1 -0
@@ -3169,6 +3169,7 @@ static void __exit ib_core_cleanup(void)/* Make sure that any pending umem accounting work is done. */ destroy_workqueue (ib_wq);destroy_workqueue (ib_unreg_wq); +rcu_barrier ();WARN_ON (!xa_empty (&clients));WARN_ON (!xa_empty (&devices)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/1518 RDMA/mlx5: Drain RCU callbacks during module teardown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit e37cdd75f8d61c1123d324ae5667ac3da562290e ]
devx_free_subscription() can remain queued after the last DevX event file drops its module reference or an auxiliary driver detaches its devices. mlx5_ib can then unload before the callback runs.
Registration error unwind has the same risk because driver registration can attach existing devices before failing. Wait after all drivers have stopped.
--- drivers/infiniband/hw/mlx5/main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -5225,6 +5225,7 @@ static int __init mlx5_ib_init(void) dd_err:mlx5r_rep_cleanup (); rep_err: +rcu_barrier ();mlx5_ib_qp_event_cleanup (); qp_event_err:destroy_workqueue (mlx5_ib_event_wq);
@@ -5238,6 +5239,7 @@ static void __exit mlx5_ib_cleanup(void)auxiliary_driver_unregister (&mlx5r_driver);auxiliary_driver_unregister (&mlx5r_mp_driver);mlx5r_rep_cleanup (); +rcu_barrier ();mlx5_ib_qp_event_cleanup ();destroy_workqueue (mlx5_ib_event_wq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/1518 RDMA/ipoib: Drain RCU callbacks during module teardown
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 31b7c700670830a0e8a4cdcd451c88a13cc5dc48 ]
IPoIB reclamation completions can be signaled from inside an RCU callback. Teardown can wake before the callback returns and unload ib_ipoib while its code is still executing.
Client registration failure can also remove already-added devices and queue callbacks. Wait after client and workqueue teardown.
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +2 -0
@@ -2755,6 +2755,7 @@ static int __init ipoib_init_module(void) err_sa:ib_sa_unregister_client (&ipoib_sa_client);destroy_workqueue (ipoib_workqueue); +rcu_barrier (); err_fs:ipoib_unregister_debugfs ();
@@ -2772,6 +2773,7 @@ static void __exit ipoib_cleanup_module(void)ib_sa_unregister_client (&ipoib_sa_client);ipoib_unregister_debugfs ();destroy_workqueue (ipoib_workqueue); +rcu_barrier (); }module_init (ipoib_init_module);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/1518 RDMA/rxe: Avoid reprocessing the current packet after the QP enters the error state
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Allison Henderson <[email protected]>
[ Upstream commit 15ae32c4a3551c4c9da457370bdfdd65d171e512 ]
When do_complete() finds the QP in the error state it returns RESPST_CHK_RESOURCE. Before commit 49dc9c1f0c7e ("RDMA/rxe: Cleanup reset state handling in rxe_resp.c") this was the flush loop:check_resource() had an error-state branch that fetched each remaining recv WQE and completed it with IB_WC_WR_FLUSH_ERR, without touching the current packet. That commit removed the error-state branch from check_resource() (draining is now done at rxe_receiver() entry) but kept the do_complete() error-state return.
As a result, when a QP moves to the error state while a packet is being completed - e.g. an rdma_cm disconnect racing with receive processing - the responder state machine loops back into the request processing chain with the already-completed packet still in hand:check_resource() fetches a fresh recv WQE, execute()/send_data_in() copies the same packet payload again, do_complete() posts another IB_WC_SUCCESS CQE (qp->resp.status is still 0), and control returns to the error-state check. The loop re-executes the same packet once per posted recv WQE (observed: ~1000 duplicate IB_WC_SUCCESS completions of one SEND, one per ~8us, matching the RQ occupancy) until the RQ is exhausted, after which qp->resp.wqe is NULL and send_data_in() dereferences it:
BUG: kernel NULL pointer dereference, address: 0000000000000014 Workqueue: rxe_wq do_work RIP: copy_data+0x29/0x1f0 Call Trace: send_data_in+0x25/0x50 rxe_receiver+0xf36/0x1dd0
The duplicate completions are indistinguishable from real receives to the ULP. During an rds stress test, the message was accepted as new and delivered the same datagram to user space hundreds of times, corrupting the stream; any ULP that relies on RC exactly-once delivery is affected.
A live packet reaching the error-state check in do_complete() has been executed and completed exactly once and must be consumed, not re-processed. Return RESPST_CLEANUP for it (dequeue and free); keep returning RESPST_CHK_RESOURCE for the pkt == NULL case.
--- drivers/infiniband/sw/rxe/rxe_resp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/infiniband/sw/rxe/rxe_resp.c +8 -1
@@ -1203,7 +1203,14 @@ static enum resp_states do_complete(struct rxe_qp *qp,spin_lock_irqsave (&qp->state_lock, flags);if (unlikely (qp_state (qp) ==IB_QPS_ERR )) {spin_unlock_irqrestore (&qp->state_lock, flags); -return RESPST_CHK_RESOURCE ; +/* The packet was executed and completed before the QP +* moved to ERROR; it must be consumed exactly once. +* Re-entering the request chain with the stale packet +* would copy it into every remaining recv WQE as a new +* completion. Remaining WQEs are flushed by the drain +* path at rxe_receiver() entry. +*/ +return pkt ?RESPST_CLEANUP :RESPST_CHK_RESOURCE ; }spin_unlock_irqrestore (&qp->state_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/1518 drm/msm/dp: add missing drm_edid_connector_update() before add_modes on cached EDID
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Glathe <[email protected]>
[ Upstream commit b7088d58dccfba87fe8dd2ab7c493ee1d9d09277 ]
After the refactor to struct drm_edid, the fast path in msm_dp_panel_get_modes() that already held a cached EDID called drm_edid_connector_add_modes() directly without first calling drm_edid_connector_update().
The new API requires the update step to associate the EDID with the connector. Add the missing call. This restores correct behaviour for the cached-EDID path.
Patchwork: https://patchwork.freedesktop.org/patch/731125/
--- drivers/gpu/drm/msm/dp/dp_panel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dp/dp_panel.c +3 -1
@@ -254,8 +254,10 @@ int msm_dp_panel_get_modes(struct msm_dp_panel *msm_dp_panel,return -EINVAL ; } -if (msm_dp_panel->drm_edid) +if (msm_dp_panel->drm_edid) { +drm_edid_connector_update (connector, msm_dp_panel->drm_edid);return drm_edid_connector_add_modes (connector); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/1518 Revert "drm/msm: dsi: fix PLL init in bonded mode"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 44784327815b2a1ad8bb56b9236770cb538c7c27 ]
Commit 93c97bc8d85d ("drm/msm: dsi: fix PLL init in bonded mode") fixed one of the issues with the DSI bonded mode, but broke non-bonded usecase for DSI as reported by Mohit Dsor. Clock divider is being programmed incorrectly, resultin in the wrong display mode being selected. Revert the offending commit, letting Neil to work on a better fix.
Patchwork: https://patchwork.freedesktop.org/patch/739459/
--- drivers/gpu/drm/msm/dsi/phy/dsi_phy.h | 1 + drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy.h +1 -0
@@ -109,6 +109,7 @@ struct msm_dsi_phy {struct msm_dsi_dphy_timing timing;const struct msm_dsi_phy_cfg *cfg;void *tuning_cfg; +void *pll_data;enum msm_dsi_phy_usecase usecase;bool regulator_ldo_mode;
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +16 -2
@@ -426,8 +426,11 @@ static void dsi_pll_enable_pll_bias(struct dsi_pll_7nm *pll)u32 data;spin_lock_irqsave (&pll->pll_enable_lock, flags); - pll->pll_enable_cnt++; -WARN_ON (pll->pll_enable_cnt ==INT_MAX ); +if (pll->pll_enable_cnt++) { +spin_unlock_irqrestore (&pll->pll_enable_lock, flags); +WARN_ON (pll->pll_enable_cnt ==INT_MAX ); +return ; + } data =readl (pll->phy->base + REG_DSI_7nm_PHY_CMN_CTRL_0); data |= DSI_7nm_PHY_CMN_CTRL_0_PLL_SHUTDOWNB;
@@ -873,6 +876,7 @@ static int dsi_pll_7nm_init(struct msm_dsi_phy *phy)spin_lock_init (&pll_7nm->pll_enable_lock); pll_7nm->phy = phy; + phy->pll_data = pll_7nm; ret =pll_7nm_register (pll_7nm, phy->provided_clocks->hws);if (ret) {
@@ -961,8 +965,10 @@ static int dsi_7nm_phy_enable(struct msm_dsi_phy *phy,u32 const delay_us =5 ;u32 const timeout_us =1000 ;struct msm_dsi_dphy_timing *timing = &phy->timing; +struct dsi_pll_7nm *pll = phy->pll_data;void __iomem *base = phy->base;bool less_than_1500_mhz; +unsigned long flags;u32 vreg_ctrl_0, vreg_ctrl_1, lane_ctrl0;u32 glbl_pemph_ctrl_0;u32 glbl_str_swi_cal_sel_ctrl, glbl_hstx_str_ctrl_0;
@@ -1084,10 +1090,13 @@ static int dsi_7nm_phy_enable(struct msm_dsi_phy *phy, glbl_rescode_bot_ctrl =0x3c ; } +spin_lock_irqsave (&pll->pll_enable_lock, flags); + pll->pll_enable_cnt =1 ;/* de-assert digital and pll power down */ data = DSI_7nm_PHY_CMN_CTRL_0_DIGTOP_PWRDN_B | DSI_7nm_PHY_CMN_CTRL_0_PLL_SHUTDOWNB;writel (data, base + REG_DSI_7nm_PHY_CMN_CTRL_0); +spin_unlock_irqrestore (&pll->pll_enable_lock, flags);/* Assert PLL core reset */ writel (0x00 , base + REG_DSI_7nm_PHY_CMN_PLL_CNTRL);
@@ -1200,7 +1209,9 @@ static bool dsi_7nm_set_continuous_clock(struct msm_dsi_phy *phy, bool enable)static void dsi_7nm_phy_disable (struct msm_dsi_phy *phy) { +struct dsi_pll_7nm *pll = phy->pll_data;void __iomem *base = phy->base; +unsigned long flags;u32 data;DBG ("" );
@@ -1227,8 +1238,11 @@ static void dsi_7nm_phy_disable(struct msm_dsi_phy *phy)writel (data, base + REG_DSI_7nm_PHY_CMN_CTRL_0);writel (0 , base + REG_DSI_7nm_PHY_CMN_LANE_CTRL0); +spin_lock_irqsave (&pll->pll_enable_lock, flags); + pll->pll_enable_cnt =0 ;/* Turn off all PHY blocks */ writel (0x00 , base + REG_DSI_7nm_PHY_CMN_CTRL_0); +spin_unlock_irqrestore (&pll->pll_enable_lock, flags);/* make sure phy is turned off */ wmb ();
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/1518 crypto: ccp - Fix memory leak in SEV INIT_EX path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Atish Patra <[email protected]>
[ Upstream commit c8e53ada20d352b0f1bdc3e58405a9edab897a2e ]
allocated pages in _init_ext_path are never freed and sev_init_ex_buffer is left pointing at the leaked memory in case of any failures during the function..
Fix by adding an error path that frees the pages and clears sev_init_ex_buffer. Make sure we only free the memory if the failure happens before the conversion. Otherwise, we may end up trying to free up converted pages in case of reclaim failure. rmp_mark_pages_firmware failures should be rare enough to avoid more code complexity to track down which pages were reclaimed/leaked vs which are not.
--- drivers/crypto/ccp/sev-dev.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/crypto/ccp/sev-dev.c +14 -3
@@ -1514,7 +1514,7 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)if (sev_init_ex_buffer)return 0 ; - page =alloc_pages (GFP_KERNEL ,get_order (NV_LENGTH )); + page =alloc_pages (GFP_KERNEL | __GFP_ZERO,get_order (NV_LENGTH ));if (!page) {dev_err (sev->dev,"SEV: INIT_EX NV memory allocation failed\n" );return -ENOMEM ;
@@ -1524,7 +1524,7 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev) rc =sev_read_init_ex_file ();if (rc) -return rc; + goto err_free;/* If SEV-SNP is initialized, transition to firmware page. */ if (sev->snp_initialized) {
@@ -1533,11 +1533,22 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev) npages =1UL <<get_order (NV_LENGTH );if (rmp_mark_pages_firmware (__pa (sev_init_ex_buffer), npages, false)) {dev_err (sev->dev,"SEV: INIT_EX NV memory page state change failed.\n" ); -return -ENOMEM ; + rc = -ENOMEM ; +/* +* Pages can be in an inconsistent state, don't release them back to the +* system. +*/ + goto err_reset; } }return 0 ; + +err_free: +__free_pages (page,get_order (NV_LENGTH )); +err_reset: + sev_init_ex_buffer =NULL ; +return rc; }static int __sev_platform_init_locked (int *error)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/1518 hwrng: ks-sa - Fix runtime PM cleanup on registration failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuho Choi <[email protected]>
[ Upstream commit 1c17b601fafb09c9ec074fd097737d20eafe7d63 ]
ks_sa_rng_probe() enables runtime PM and resumes the device before registering the hwrng. If devm_hwrng_register() fails, probe returns without dropping the runtime PM usage count or disabling runtime PM.
Unwind the runtime PM state on the registration failure path, matching the cleanup done by remove().
--- drivers/char/hw_random/ks-sa-rng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/char/hw_random/ks-sa-rng.c +8 -1
@@ -242,7 +242,14 @@ static int ks_sa_rng_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"Failed to enable SA power-domain\n" ); } -return devm_hwrng_register (&pdev->dev, &ks_sa_rng->rng); + ret =devm_hwrng_register (dev, &ks_sa_rng->rng); +if (ret) { +pm_runtime_put_sync (dev); +pm_runtime_disable (dev); +return ret; + } + +return 0 ; }static void ks_sa_rng_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0