From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C94BFC433F5 for ; Thu, 27 Jan 2022 18:10:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244902AbiA0SKd (ORCPT ); Thu, 27 Jan 2022 13:10:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245102AbiA0SKG (ORCPT ); Thu, 27 Jan 2022 13:10:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D66C5C06175F; Thu, 27 Jan 2022 10:09:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7848C61998; Thu, 27 Jan 2022 18:09:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EF2EC340E4; Thu, 27 Jan 2022 18:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306976; bh=a2HwaX7gwQcBa/uKoUIkgkD1oBfKnidjfViQpYAN6u0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xX0AAibZXT2bymSXmCYGhTHipadhf7k1PXS94Y0ehIhNZclio9vF4q11korbl5T3U dDCJkor3ZLwbbUrYA5gUr1nl8a8Q5zZ9IVynIv/r8XGlPEctzZTJ3nPaG0xPL1vwaB GD2CdGYC70KxqSKebApZ0ybdQYBKiMbrpOg1zQDw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tvrtko Ursulin , Sushma Venkatesh Reddy , Daniel Vetter , Dave Airlie , Jon Bloomfield , Joonas Lahtinen , Jani Nikula , Linus Torvalds Subject: [PATCH 5.4 01/11] drm/i915: Flush TLBs before releasing backing store Date: Thu, 27 Jan 2022 19:09:02 +0100 Message-Id: <20220127180258.408413788@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tvrtko Ursulin commit 7938d61591d33394a21bdd7797a245b65428f44c upstream. We need to flush TLBs before releasing backing store otherwise userspace is able to encounter stale entries if a) it is not declaring access to certain buffers and b) it races with the backing store release from a such undeclared execution already executing on the GPU in parallel. The approach taken is to mark any buffer objects which were ever bound to the GPU and to trigger a serialized TLB flush when their backing store is released. Alternatively the flushing could be done on VMA unbind, at which point we would be able to ascertain whether there is potential a parallel GPU execution (which could race), but essentially it boils down to paying the cost of TLB flushes potentially needlessly at VMA unbind time (when the backing store is not known to be going away so not needed for safety), versus potentially needlessly at backing store relase time (since we at that point cannot tell whether there is anything executing on the GPU which uses that object). Thereforce simplicity of implementation has been chosen for now with scope to benchmark and refine later as required. Signed-off-by: Tvrtko Ursulin Reported-by: Sushma Venkatesh Reddy Reviewed-by: Daniel Vetter Acked-by: Dave Airlie Cc: Daniel Vetter Cc: Jon Bloomfield Cc: Joonas Lahtinen Cc: Jani Nikula Cc: stable@vger.kernel.org Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/gpu/drm/i915/gem/i915_gem_object_types.h | 3=20 drivers/gpu/drm/i915/gem/i915_gem_pages.c | 10 ++ drivers/gpu/drm/i915/gt/intel_gt.c | 99 ++++++++++++++++++= +++++ drivers/gpu/drm/i915/gt/intel_gt.h | 2=20 drivers/gpu/drm/i915/gt/intel_gt_types.h | 2=20 drivers/gpu/drm/i915/i915_reg.h | 11 ++ drivers/gpu/drm/i915/i915_vma.c | 4=20 7 files changed, 131 insertions(+) --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h @@ -118,6 +118,9 @@ struct drm_i915_gem_object { =20 I915_SELFTEST_DECLARE(struct list_head st_link); =20 + unsigned long flags; +#define I915_BO_WAS_BOUND_BIT 0 + /* * Is the object to be mapped as read-only to the GPU * Only honoured if hardware has relevant pte bit --- a/drivers/gpu/drm/i915/gem/i915_gem_pages.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_pages.c @@ -8,6 +8,8 @@ #include "i915_gem_object.h" #include "i915_scatterlist.h" =20 +#include "gt/intel_gt.h" + void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj, struct sg_table *pages, unsigned int sg_page_sizes) @@ -176,6 +178,14 @@ __i915_gem_object_unset_pages(struct drm __i915_gem_object_reset_page_iter(obj); obj->mm.page_sizes.phys =3D obj->mm.page_sizes.sg =3D 0; =20 + if (test_and_clear_bit(I915_BO_WAS_BOUND_BIT, &obj->flags)) { + struct drm_i915_private *i915 =3D to_i915(obj->base.dev); + intel_wakeref_t wakeref; + + with_intel_runtime_pm_if_in_use(&i915->runtime_pm, wakeref) + intel_gt_invalidate_tlbs(&i915->gt); + } + return pages; } =20 --- a/drivers/gpu/drm/i915/gt/intel_gt.c +++ b/drivers/gpu/drm/i915/gt/intel_gt.c @@ -15,6 +15,8 @@ void intel_gt_init_early(struct intel_gt =20 spin_lock_init(>->irq_lock); =20 + mutex_init(>->tlb_invalidate_lock); + INIT_LIST_HEAD(>->closed_vma); spin_lock_init(>->closed_lock); =20 @@ -266,3 +268,100 @@ void intel_gt_driver_late_release(struct intel_uc_driver_late_release(>->uc); intel_gt_fini_reset(gt); } + +struct reg_and_bit { + i915_reg_t reg; + u32 bit; +}; + +static struct reg_and_bit +get_reg_and_bit(const struct intel_engine_cs *engine, const bool gen8, + const i915_reg_t *regs, const unsigned int num) +{ + const unsigned int class =3D engine->class; + struct reg_and_bit rb =3D { }; + + if (WARN_ON_ONCE(class >=3D num || !regs[class].reg)) + return rb; + + rb.reg =3D regs[class]; + if (gen8 && class =3D=3D VIDEO_DECODE_CLASS) + rb.reg.reg +=3D 4 * engine->instance; /* GEN8_M2TCR */ + else + rb.bit =3D engine->instance; + + rb.bit =3D BIT(rb.bit); + + return rb; +} + +void intel_gt_invalidate_tlbs(struct intel_gt *gt) +{ + static const i915_reg_t gen8_regs[] =3D { + [RENDER_CLASS] =3D GEN8_RTCR, + [VIDEO_DECODE_CLASS] =3D GEN8_M1TCR, /* , GEN8_M2TCR */ + [VIDEO_ENHANCEMENT_CLASS] =3D GEN8_VTCR, + [COPY_ENGINE_CLASS] =3D GEN8_BTCR, + }; + static const i915_reg_t gen12_regs[] =3D { + [RENDER_CLASS] =3D GEN12_GFX_TLB_INV_CR, + [VIDEO_DECODE_CLASS] =3D GEN12_VD_TLB_INV_CR, + [VIDEO_ENHANCEMENT_CLASS] =3D GEN12_VE_TLB_INV_CR, + [COPY_ENGINE_CLASS] =3D GEN12_BLT_TLB_INV_CR, + }; + struct drm_i915_private *i915 =3D gt->i915; + struct intel_uncore *uncore =3D gt->uncore; + struct intel_engine_cs *engine; + enum intel_engine_id id; + const i915_reg_t *regs; + unsigned int num =3D 0; + + if (I915_SELFTEST_ONLY(gt->awake =3D=3D -ENODEV)) + return; + + if (INTEL_GEN(i915) =3D=3D 12) { + regs =3D gen12_regs; + num =3D ARRAY_SIZE(gen12_regs); + } else if (INTEL_GEN(i915) >=3D 8 && INTEL_GEN(i915) <=3D 11) { + regs =3D gen8_regs; + num =3D ARRAY_SIZE(gen8_regs); + } else if (INTEL_GEN(i915) < 8) { + return; + } + + if (WARN_ONCE(!num, "Platform does not implement TLB invalidation!")) + return; + + GEM_TRACE("\n"); + + assert_rpm_wakelock_held(&i915->runtime_pm); + + mutex_lock(>->tlb_invalidate_lock); + intel_uncore_forcewake_get(uncore, FORCEWAKE_ALL); + + for_each_engine(engine, gt, id) { + /* + * HW architecture suggest typical invalidation time at 40us, + * with pessimistic cases up to 100us and a recommendation to + * cap at 1ms. We go a bit higher just in case. + */ + const unsigned int timeout_us =3D 100; + const unsigned int timeout_ms =3D 4; + struct reg_and_bit rb; + + rb =3D get_reg_and_bit(engine, regs =3D=3D gen8_regs, regs, num); + if (!i915_mmio_reg_offset(rb.reg)) + continue; + + intel_uncore_write_fw(uncore, rb.reg, rb.bit); + if (__intel_wait_for_register_fw(uncore, + rb.reg, rb.bit, 0, + timeout_us, timeout_ms, + NULL)) + DRM_ERROR_RATELIMITED("%s TLB invalidation did not complete in %ums!\n", + engine->name, timeout_ms); + } + + intel_uncore_forcewake_put(uncore, FORCEWAKE_ALL); + mutex_unlock(>->tlb_invalidate_lock); +} --- a/drivers/gpu/drm/i915/gt/intel_gt.h +++ b/drivers/gpu/drm/i915/gt/intel_gt.h @@ -57,4 +57,6 @@ static inline bool intel_gt_is_wedged(st =20 void intel_gt_queue_hangcheck(struct intel_gt *gt); =20 +void intel_gt_invalidate_tlbs(struct intel_gt *gt); + #endif /* __INTEL_GT_H__ */ --- a/drivers/gpu/drm/i915/gt/intel_gt_types.h +++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h @@ -40,6 +40,8 @@ struct intel_gt { =20 struct intel_uc uc; =20 + struct mutex tlb_invalidate_lock; + struct intel_gt_timelines { spinlock_t lock; /* protects active_list */ struct list_head active_list; --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h @@ -2519,6 +2519,12 @@ static inline bool i915_mmio_reg_valid(i #define GAMT_CHKN_DISABLE_DYNAMIC_CREDIT_SHARING (1 << 28) #define GAMT_CHKN_DISABLE_I2M_CYCLE_ON_WR_PORT (1 << 24) =20 +#define GEN8_RTCR _MMIO(0x4260) +#define GEN8_M1TCR _MMIO(0x4264) +#define GEN8_M2TCR _MMIO(0x4268) +#define GEN8_BTCR _MMIO(0x426c) +#define GEN8_VTCR _MMIO(0x4270) + #if 0 #define PRB0_TAIL _MMIO(0x2030) #define PRB0_HEAD _MMIO(0x2034) @@ -2602,6 +2608,11 @@ static inline bool i915_mmio_reg_valid(i #define FAULT_VA_HIGH_BITS (0xf << 0) #define FAULT_GTT_SEL (1 << 4) =20 +#define GEN12_GFX_TLB_INV_CR _MMIO(0xced8) +#define GEN12_VD_TLB_INV_CR _MMIO(0xcedc) +#define GEN12_VE_TLB_INV_CR _MMIO(0xcee0) +#define GEN12_BLT_TLB_INV_CR _MMIO(0xcee4) + #define FPGA_DBG _MMIO(0x42300) #define FPGA_DBG_RM_NOCLAIM (1 << 31) =20 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -341,6 +341,10 @@ int i915_vma_bind(struct i915_vma *vma, return ret; =20 vma->flags |=3D bind_flags; + + if (vma->obj) + set_bit(I915_BO_WAS_BOUND_BIT, &vma->obj->flags); + return 0; } =20 From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27FB0C433FE for ; Thu, 27 Jan 2022 18:10:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238968AbiA0SKv (ORCPT ); Thu, 27 Jan 2022 13:10:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245168AbiA0SKH (ORCPT ); Thu, 27 Jan 2022 13:10:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C39BC06174A; Thu, 27 Jan 2022 10:09:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5C0DCB820C8; Thu, 27 Jan 2022 18:09:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF36EC340E4; Thu, 27 Jan 2022 18:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306986; bh=b4uTomHDQKQx/j+NssKkGR3OG4OXuN/5p8mTSEQXHZE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lCD1CNryJ8XpH2JjB0pECK8xE6tX3cr2ZshSLgIL8OiHTOuyhqKp0GHsxGyYIBFNZ P1jzRD5qep7z4oNmKOaB9hI8zF780aemy+m7egYLShPEre8QCnd793COJlXXo6Truv 13akkyodDxgNTDjdg3KU9oaK/dAeecwz/+XDhMMg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Morin , "Paul E. McKenney" Subject: [PATCH 5.4 02/11] rcu: Tighten rcu_advance_cbs_nowake() checks Date: Thu, 27 Jan 2022 19:09:03 +0100 Message-Id: <20220127180258.442604866@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Paul E. McKenney commit 614ddad17f22a22e035e2ea37a04815f50362017 upstream. Currently, rcu_advance_cbs_nowake() checks that a grace period is in progress, however, that grace period could end just after the check. This commit rechecks that a grace period is still in progress while holding the rcu_node structure's lock. The grace period cannot end while the current CPU's rcu_node structure's ->lock is held, thus avoiding false positives from the WARN_ON_ONCE(). As Daniel Vacek noted, it is not necessary for the rcu_node structure to have a CPU that has not yet passed through its quiescent state. Tested-by: Guillaume Morin Signed-off-by: Paul E. McKenney Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- kernel/rcu/tree.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -1358,10 +1358,11 @@ static void __maybe_unused rcu_advance_c struct rcu_data *rdp) { rcu_lockdep_assert_cblist_protected(rdp); - if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) || - !raw_spin_trylock_rcu_node(rnp)) + if (!rcu_seq_state(rcu_seq_current(&rnp->gp_seq)) || !raw_spin_trylock_rc= u_node(rnp)) return; - WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp)); + // The grace period cannot end while we hold the rcu_node lock. + if (rcu_seq_state(rcu_seq_current(&rnp->gp_seq))) + WARN_ON_ONCE(rcu_advance_cbs(rnp, rdp)); raw_spin_unlock_rcu_node(rnp); } =20 From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 704FDC43219 for ; Thu, 27 Jan 2022 18:10:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245050AbiA0SKP (ORCPT ); Thu, 27 Jan 2022 13:10:15 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:47058 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244940AbiA0SJu (ORCPT ); Thu, 27 Jan 2022 13:09:50 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0434161D00; Thu, 27 Jan 2022 18:09:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B77FEC340E4; Thu, 27 Jan 2022 18:09:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306989; bh=+FWXiszUeksTbgAqjRCIYjRqShTt5d5rJhmS/5F/rNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FrKpFSh+AGnymOLZzTh2CBc1xSVty2lgJltKkjOzvYEbsOnwP/6nf824XWrCL58P4 qPIj/WtSlXcdSOza144Hozvx8UMicpS2eNjXuY1CHBfPN88wUEWjNQ/9qItRRCZ6Vc 7BZwvHxg8y8+7uwpeaFlSJi0ucl+SXkWaB5sYq3Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Stefan Wahren , Nicolas Saenz Julienne , Linus Walleij , Florian Fainelli Subject: [PATCH 5.4 03/11] pinctrl: bcm2835: Drop unused define Date: Thu, 27 Jan 2022 19:09:04 +0100 Message-Id: <20220127180258.472150189@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Stefan Wahren commit be30d5de0a5a52c6ee2cc453a51301037ab94aa upstream There is no usage for this define, so drop it. Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1580148908-4863-2-git-send-email-stefan.wah= ren@i2se.com Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 3 --- 1 file changed, 3 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -40,9 +40,6 @@ #define BCM2835_NUM_BANKS 2 #define BCM2835_NUM_IRQS 3 =20 -#define BCM2835_PIN_BITMAP_SZ \ - DIV_ROUND_UP(BCM2835_NUM_GPIOS, sizeof(unsigned long) * 8) - /* GPIO register offsets */ #define GPFSEL0 0x0 /* Function Select */ #define GPSET0 0x1c /* Pin Output Set */ From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8649C4321E for ; Thu, 27 Jan 2022 18:10:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245201AbiA0SKR (ORCPT ); Thu, 27 Jan 2022 13:10:17 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:47100 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245140AbiA0SJx (ORCPT ); Thu, 27 Jan 2022 13:09:53 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F57961998; Thu, 27 Jan 2022 18:09:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 208AFC340E4; Thu, 27 Jan 2022 18:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306992; bh=adpN5MW8UdhQiTJHyDweGd8fKbVlDhWENtIBS7WECSE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gg2Hx1WrWT3r+XVCmN4wcRAx9AIUZ/+qP1FdcNE/mX/HXdgiLpDeHcUIeAx1kgRaH J+ArKTQCHL6x/DDXDAxgsdN/ghZt55DFD+XzawDT2yocph2jEgaJxT2kWKeNgfJjap phyfx7iDRIxqbMBQta7UcKEqohkMDNP/oebKoGh4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Stefan Wahren , Nicolas Saenz Julienne , Linus Walleij , Florian Fainelli Subject: [PATCH 5.4 04/11] pinctrl: bcm2835: Refactor platform data Date: Thu, 27 Jan 2022 19:09:05 +0100 Message-Id: <20220127180258.510828284@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Stefan Wahren commit 90bfaf028d61a6d523c685b63c2bcc94eebb8057 upstream This prepares the platform data to be easier to extend for more GPIOs. Except of this there is no functional change. Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1581166975-22949-3-git-send-email-stefan.wa= hren@i2se.com Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 57 ++++++++++++++++++++++++++---= ----- 1 file changed, 44 insertions(+), 13 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -82,6 +82,7 @@ struct bcm2835_pinctrl { =20 struct pinctrl_dev *pctl_dev; struct gpio_chip gpio_chip; + struct pinctrl_desc pctl_desc; struct pinctrl_gpio_range gpio_range; =20 raw_spinlock_t irq_lock[BCM2835_NUM_BANKS]; @@ -1051,7 +1052,7 @@ static const struct pinconf_ops bcm2711_ .pin_config_set =3D bcm2711_pinconf_set, }; =20 -static struct pinctrl_desc bcm2835_pinctrl_desc =3D { +static const struct pinctrl_desc bcm2835_pinctrl_desc =3D { .name =3D MODULE_NAME, .pins =3D bcm2835_gpio_pins, .npins =3D ARRAY_SIZE(bcm2835_gpio_pins), @@ -1061,19 +1062,47 @@ static struct pinctrl_desc bcm2835_pinct .owner =3D THIS_MODULE, }; =20 -static struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range =3D { +static const struct pinctrl_desc bcm2711_pinctrl_desc =3D { + .name =3D MODULE_NAME, + .pins =3D bcm2835_gpio_pins, + .npins =3D ARRAY_SIZE(bcm2835_gpio_pins), + .pctlops =3D &bcm2835_pctl_ops, + .pmxops =3D &bcm2835_pmx_ops, + .confops =3D &bcm2711_pinconf_ops, + .owner =3D THIS_MODULE, +}; + +static const struct pinctrl_gpio_range bcm2835_pinctrl_gpio_range =3D { .name =3D MODULE_NAME, .npins =3D BCM2835_NUM_GPIOS, }; =20 +struct bcm_plat_data { + const struct gpio_chip *gpio_chip; + const struct pinctrl_desc *pctl_desc; + const struct pinctrl_gpio_range *gpio_range; +}; + +static const struct bcm_plat_data bcm2835_plat_data =3D { + .gpio_chip =3D &bcm2835_gpio_chip, + .pctl_desc =3D &bcm2835_pinctrl_desc, + .gpio_range =3D &bcm2835_pinctrl_gpio_range, +}; + +static const struct bcm_plat_data bcm2711_plat_data =3D { + .gpio_chip =3D &bcm2835_gpio_chip, + .pctl_desc =3D &bcm2711_pinctrl_desc, + .gpio_range =3D &bcm2835_pinctrl_gpio_range, +}; + static const struct of_device_id bcm2835_pinctrl_match[] =3D { { .compatible =3D "brcm,bcm2835-gpio", - .data =3D &bcm2835_pinconf_ops, + .data =3D &bcm2835_plat_data, }, { .compatible =3D "brcm,bcm2711-gpio", - .data =3D &bcm2711_pinconf_ops, + .data =3D &bcm2711_plat_data, }, {} }; @@ -1082,6 +1111,7 @@ static int bcm2835_pinctrl_probe(struct { struct device *dev =3D &pdev->dev; struct device_node *np =3D dev->of_node; + const struct bcm_plat_data *pdata; struct bcm2835_pinctrl *pc; struct gpio_irq_chip *girq; struct resource iomem; @@ -1108,7 +1138,13 @@ static int bcm2835_pinctrl_probe(struct if (IS_ERR(pc->base)) return PTR_ERR(pc->base); =20 - pc->gpio_chip =3D bcm2835_gpio_chip; + match =3D of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node); + if (!match) + return -EINVAL; + + pdata =3D match->data; + + pc->gpio_chip =3D *pdata->gpio_chip; pc->gpio_chip.parent =3D dev; pc->gpio_chip.of_node =3D np; =20 @@ -1159,19 +1195,14 @@ static int bcm2835_pinctrl_probe(struct return err; } =20 - match =3D of_match_node(bcm2835_pinctrl_match, pdev->dev.of_node); - if (match) { - bcm2835_pinctrl_desc.confops =3D - (const struct pinconf_ops *)match->data; - } - - pc->pctl_dev =3D devm_pinctrl_register(dev, &bcm2835_pinctrl_desc, pc); + pc->pctl_desc =3D *pdata->pctl_desc; + pc->pctl_dev =3D devm_pinctrl_register(dev, &pc->pctl_desc, pc); if (IS_ERR(pc->pctl_dev)) { gpiochip_remove(&pc->gpio_chip); return PTR_ERR(pc->pctl_dev); } =20 - pc->gpio_range =3D bcm2835_pinctrl_gpio_range; + pc->gpio_range =3D *pdata->gpio_range; pc->gpio_range.base =3D pc->gpio_chip.base; pc->gpio_range.gc =3D &pc->gpio_chip; pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range); From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EB91C433EF for ; Thu, 27 Jan 2022 18:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245232AbiA0SKT (ORCPT ); Thu, 27 Jan 2022 13:10:19 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:58976 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245040AbiA0SJ6 (ORCPT ); Thu, 27 Jan 2022 13:09:58 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 23108B820C8; Thu, 27 Jan 2022 18:09:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D5A3C340EA; Thu, 27 Jan 2022 18:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306996; bh=ylg8kqnBPW7+lr+1ZYjjF8PMqVyBsduSyQYntsokWZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pKtfD2QZbEb7yzu3lhjnDwaoLwKFTTlLZWNqpefh5F544kSQX1O4me2HXQn1QQJIW 4iysrA5cRjt55/+ZN53T0ZNHRN/YfpjBKulw0mBXcJJu9T2eg99RS+3m3fYpdc4I0S 95Vd1/bP+ZXSYAvHHLiD/HzzCQoicjemTWhNKUok= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Stefan Wahren , Nicolas Saenz Julienne , Linus Walleij , Florian Fainelli Subject: [PATCH 5.4 05/11] pinctrl: bcm2835: Add support for all GPIOs on BCM2711 Date: Thu, 27 Jan 2022 19:09:06 +0100 Message-Id: <20220127180258.541081419@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Stefan Wahren commit b1d84a3d0a26c5844a22bc09a42704b9371208bb upstream The BCM2711 supports 58 GPIOs. So extend pinctrl and GPIOs accordingly. Signed-off-by: Stefan Wahren Link: https://lore.kernel.org/r/1581166975-22949-4-git-send-email-stefan.wa= hren@i2se.com Reviewed-by: Nicolas Saenz Julienne Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 54 ++++++++++++++++++++++++++---= ----- 1 file changed, 42 insertions(+), 12 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -37,6 +37,7 @@ =20 #define MODULE_NAME "pinctrl-bcm2835" #define BCM2835_NUM_GPIOS 54 +#define BCM2711_NUM_GPIOS 58 #define BCM2835_NUM_BANKS 2 #define BCM2835_NUM_IRQS 3 =20 @@ -78,7 +79,7 @@ struct bcm2835_pinctrl { =20 /* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS]; - unsigned int irq_type[BCM2835_NUM_GPIOS]; + unsigned int irq_type[BCM2711_NUM_GPIOS]; =20 struct pinctrl_dev *pctl_dev; struct gpio_chip gpio_chip; @@ -145,6 +146,10 @@ static struct pinctrl_pin_desc bcm2835_g BCM2835_GPIO_PIN(51), BCM2835_GPIO_PIN(52), BCM2835_GPIO_PIN(53), + BCM2835_GPIO_PIN(54), + BCM2835_GPIO_PIN(55), + BCM2835_GPIO_PIN(56), + BCM2835_GPIO_PIN(57), }; =20 /* one pin per group */ @@ -203,6 +208,10 @@ static const char * const bcm2835_gpio_g "gpio51", "gpio52", "gpio53", + "gpio54", + "gpio55", + "gpio56", + "gpio57", }; =20 enum bcm2835_fsel { @@ -353,6 +362,22 @@ static const struct gpio_chip bcm2835_gp .can_sleep =3D false, }; =20 +static const struct gpio_chip bcm2711_gpio_chip =3D { + .label =3D "pinctrl-bcm2711", + .owner =3D THIS_MODULE, + .request =3D gpiochip_generic_request, + .free =3D gpiochip_generic_free, + .direction_input =3D bcm2835_gpio_direction_input, + .direction_output =3D bcm2835_gpio_direction_output, + .get_direction =3D bcm2835_gpio_get_direction, + .get =3D bcm2835_gpio_get, + .set =3D bcm2835_gpio_set, + .set_config =3D gpiochip_generic_config, + .base =3D -1, + .ngpio =3D BCM2711_NUM_GPIOS, + .can_sleep =3D false, +}; + static void bcm2835_gpio_irq_handle_bank(struct bcm2835_pinctrl *pc, unsigned int bank, u32 mask) { @@ -399,7 +424,7 @@ static void bcm2835_gpio_irq_handler(str bcm2835_gpio_irq_handle_bank(pc, 0, 0xf0000000); bcm2835_gpio_irq_handle_bank(pc, 1, 0x00003fff); break; - case 2: /* IRQ2 covers GPIOs 46-53 */ + case 2: /* IRQ2 covers GPIOs 46-57 */ bcm2835_gpio_irq_handle_bank(pc, 1, 0x003fc000); break; } @@ -618,7 +643,7 @@ static struct irq_chip bcm2835_gpio_irq_ =20 static int bcm2835_pctl_get_groups_count(struct pinctrl_dev *pctldev) { - return ARRAY_SIZE(bcm2835_gpio_groups); + return BCM2835_NUM_GPIOS; } =20 static const char *bcm2835_pctl_get_group_name(struct pinctrl_dev *pctldev, @@ -776,7 +801,7 @@ static int bcm2835_pctl_dt_node_to_map(s err =3D of_property_read_u32_index(np, "brcm,pins", i, &pin); if (err) goto out; - if (pin >=3D ARRAY_SIZE(bcm2835_gpio_pins)) { + if (pin >=3D pc->pctl_desc.npins) { dev_err(pc->dev, "%pOF: invalid brcm,pins value %d\n", np, pin); err =3D -EINVAL; @@ -852,7 +877,7 @@ static int bcm2835_pmx_get_function_grou { /* every pin can do every function */ *groups =3D bcm2835_gpio_groups; - *num_groups =3D ARRAY_SIZE(bcm2835_gpio_groups); + *num_groups =3D BCM2835_NUM_GPIOS; =20 return 0; } @@ -1055,7 +1080,7 @@ static const struct pinconf_ops bcm2711_ static const struct pinctrl_desc bcm2835_pinctrl_desc =3D { .name =3D MODULE_NAME, .pins =3D bcm2835_gpio_pins, - .npins =3D ARRAY_SIZE(bcm2835_gpio_pins), + .npins =3D BCM2835_NUM_GPIOS, .pctlops =3D &bcm2835_pctl_ops, .pmxops =3D &bcm2835_pmx_ops, .confops =3D &bcm2835_pinconf_ops, @@ -1063,9 +1088,9 @@ static const struct pinctrl_desc bcm2835 }; =20 static const struct pinctrl_desc bcm2711_pinctrl_desc =3D { - .name =3D MODULE_NAME, + .name =3D "pinctrl-bcm2711", .pins =3D bcm2835_gpio_pins, - .npins =3D ARRAY_SIZE(bcm2835_gpio_pins), + .npins =3D BCM2711_NUM_GPIOS, .pctlops =3D &bcm2835_pctl_ops, .pmxops =3D &bcm2835_pmx_ops, .confops =3D &bcm2711_pinconf_ops, @@ -1077,6 +1102,11 @@ static const struct pinctrl_gpio_range b .npins =3D BCM2835_NUM_GPIOS, }; =20 +static const struct pinctrl_gpio_range bcm2711_pinctrl_gpio_range =3D { + .name =3D "pinctrl-bcm2711", + .npins =3D BCM2711_NUM_GPIOS, +}; + struct bcm_plat_data { const struct gpio_chip *gpio_chip; const struct pinctrl_desc *pctl_desc; @@ -1090,9 +1120,9 @@ static const struct bcm_plat_data bcm283 }; =20 static const struct bcm_plat_data bcm2711_plat_data =3D { - .gpio_chip =3D &bcm2835_gpio_chip, + .gpio_chip =3D &bcm2711_gpio_chip, .pctl_desc =3D &bcm2711_pinctrl_desc, - .gpio_range =3D &bcm2835_pinctrl_gpio_range, + .gpio_range =3D &bcm2711_pinctrl_gpio_range, }; =20 static const struct of_device_id bcm2835_pinctrl_match[] =3D { @@ -1118,8 +1148,8 @@ static int bcm2835_pinctrl_probe(struct int err, i; const struct of_device_id *match; =20 - BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) !=3D BCM2835_NUM_GPIOS); - BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) !=3D BCM2835_NUM_GPIOS); + BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) !=3D BCM2711_NUM_GPIOS); + BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) !=3D BCM2711_NUM_GPIOS); =20 pc =3D devm_kzalloc(dev, sizeof(*pc), GFP_KERNEL); if (!pc) From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66069C433FE for ; Thu, 27 Jan 2022 18:10:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245254AbiA0SKV (ORCPT ); Thu, 27 Jan 2022 13:10:21 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:58992 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233648AbiA0SKB (ORCPT ); Thu, 27 Jan 2022 13:10:01 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2D03AB820C9; Thu, 27 Jan 2022 18:10:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87826C340EA; Thu, 27 Jan 2022 18:09:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306998; bh=j9IbMF9BlPJ89kZFxrcZWmprUehq4dbxvd0eCOYC2bY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=w1AX0jNTac2iypKNWwHjo1OPwwRLO5/OFk2aFEoOEb7KbHIHt1M6uNqNDbGPJOz+R hWrDIeVsHMZJjd+Pu9nkzaNJ8zgI4P55IQmQ48Idi2JIqVHyvj4h1hcwTlGgm2GjAn Sll7GO7mRLtbgX7JqX1P24SGoRxZvmbtaQzdvLUU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Florian Fainelli , Linus Walleij Subject: [PATCH 5.4 06/11] pinctrl: bcm2835: Match BCM7211 compatible string Date: Thu, 27 Jan 2022 19:09:07 +0100 Message-Id: <20220127180258.573583252@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Fainelli commit 562c856f96d22ef1204b0a314bc52e85617199b4 upstream The BCM7211 SoC uses the same pinconf_ops as the ones defined for the BCM2711 SoC, match the compatible string and use the correct set of options. Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20200531001101.24945-4-f.fainelli@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1134,6 +1134,10 @@ static const struct of_device_id bcm2835 .compatible =3D "brcm,bcm2711-gpio", .data =3D &bcm2711_plat_data, }, + { + .compatible =3D "brcm,bcm7211-gpio", + .data =3D &bcm2711_plat_data, + }, {} }; =20 From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 98C61C433FE for ; Thu, 27 Jan 2022 18:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245264AbiA0SKX (ORCPT ); Thu, 27 Jan 2022 13:10:23 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:59020 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245085AbiA0SKE (ORCPT ); Thu, 27 Jan 2022 13:10:04 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 50779B820CC; Thu, 27 Jan 2022 18:10:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 702BCC340E8; Thu, 27 Jan 2022 18:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643307002; bh=2bxdWnwceU8BOUOonPuCbL7fbFSokb62/Dj5XS8WR2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jUsmr93fAC35Ge9hkzDw1VVWqXrPg3BnVEOUPZju53qpe2wVqIt6QTm7F6mH1JlX3 +/SaVR8unwhR89Dzm9qwCGsvjwaRJNJxFDd9is2aclhfyY/+Aica1YQK6d0eaZ5qIe lV3aeXKqKf+OtbMe4M5+Jaa4OyoNY+afv91P9yHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Florian Fainelli , Linus Walleij Subject: [PATCH 5.4 07/11] pinctrl: bcm2835: Add support for wake-up interrupts Date: Thu, 27 Jan 2022 19:09:08 +0100 Message-Id: <20220127180258.603077324@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Florian Fainelli commit 920fecc1aa4591da27ef9dcb338fc5da86b404d7 upstream Leverage the IRQCHIP_MASK_ON_SUSPEND flag in order to avoid having to specifically treat the GPIO interrupts during suspend and resume, and simply implement an irq_set_wake() callback that is responsible for enabling the parent wake-up interrupt as a wake-up interrupt. To avoid allocating unnecessary resources for other chips, the wake-up interrupts are only initialized if we have a brcm,bcm7211-gpio compatibility string. Signed-off-by: Florian Fainelli Link: https://lore.kernel.org/r/20200531001101.24945-5-f.fainelli@gmail.com Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 76 +++++++++++++++++++++++++++++= ++++- 1 file changed, 75 insertions(+), 1 deletion(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -76,6 +77,7 @@ struct bcm2835_pinctrl { struct device *dev; void __iomem *base; + int *wake_irq; =20 /* note: locking assumes each bank will have its own unsigned long */ unsigned long enabled_irq_map[BCM2835_NUM_BANKS]; @@ -432,6 +434,11 @@ static void bcm2835_gpio_irq_handler(str chained_irq_exit(host_chip, desc); } =20 +static irqreturn_t bcm2835_gpio_wake_irq_handler(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} + static inline void __bcm2835_gpio_irq_config(struct bcm2835_pinctrl *pc, unsigned reg, unsigned offset, bool enable) { @@ -631,6 +638,34 @@ static void bcm2835_gpio_irq_ack(struct bcm2835_gpio_set_bit(pc, GPEDS0, gpio); } =20 +static int bcm2835_gpio_irq_set_wake(struct irq_data *data, unsigned int o= n) +{ + struct gpio_chip *chip =3D irq_data_get_irq_chip_data(data); + struct bcm2835_pinctrl *pc =3D gpiochip_get_data(chip); + unsigned gpio =3D irqd_to_hwirq(data); + unsigned int irqgroup; + int ret =3D -EINVAL; + + if (!pc->wake_irq) + return ret; + + if (gpio <=3D 27) + irqgroup =3D 0; + else if (gpio >=3D 28 && gpio <=3D 45) + irqgroup =3D 1; + else if (gpio >=3D 46 && gpio <=3D 57) + irqgroup =3D 2; + else + return ret; + + if (on) + ret =3D enable_irq_wake(pc->wake_irq[irqgroup]); + else + ret =3D disable_irq_wake(pc->wake_irq[irqgroup]); + + return ret; +} + static struct irq_chip bcm2835_gpio_irq_chip =3D { .name =3D MODULE_NAME, .irq_enable =3D bcm2835_gpio_irq_enable, @@ -639,6 +674,8 @@ static struct irq_chip bcm2835_gpio_irq_ .irq_ack =3D bcm2835_gpio_irq_ack, .irq_mask =3D bcm2835_gpio_irq_disable, .irq_unmask =3D bcm2835_gpio_irq_enable, + .irq_set_wake =3D bcm2835_gpio_irq_set_wake, + .flags =3D IRQCHIP_MASK_ON_SUSPEND, }; =20 static int bcm2835_pctl_get_groups_count(struct pinctrl_dev *pctldev) @@ -1151,6 +1188,7 @@ static int bcm2835_pinctrl_probe(struct struct resource iomem; int err, i; const struct of_device_id *match; + int is_7211 =3D 0; =20 BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_pins) !=3D BCM2711_NUM_GPIOS); BUILD_BUG_ON(ARRAY_SIZE(bcm2835_gpio_groups) !=3D BCM2711_NUM_GPIOS); @@ -1177,6 +1215,7 @@ static int bcm2835_pinctrl_probe(struct return -EINVAL; =20 pdata =3D match->data; + is_7211 =3D of_device_is_compatible(np, "brcm,bcm7211-gpio"); =20 pc->gpio_chip =3D *pdata->gpio_chip; pc->gpio_chip.parent =3D dev; @@ -1211,6 +1250,15 @@ static int bcm2835_pinctrl_probe(struct GFP_KERNEL); if (!girq->parents) return -ENOMEM; + + if (is_7211) { + pc->wake_irq =3D devm_kcalloc(dev, BCM2835_NUM_IRQS, + sizeof(*pc->wake_irq), + GFP_KERNEL); + if (!pc->wake_irq) + return -ENOMEM; + } + /* * Use the same handler for all groups: this is necessary * since we use one gpiochip to cover all lines - the @@ -1218,8 +1266,34 @@ static int bcm2835_pinctrl_probe(struct * bank that was firing the IRQ and look up the per-group * and bank data. */ - for (i =3D 0; i < BCM2835_NUM_IRQS; i++) + for (i =3D 0; i < BCM2835_NUM_IRQS; i++) { + int len; + char *name; + girq->parents[i] =3D irq_of_parse_and_map(np, i); + if (!is_7211) + continue; + + /* Skip over the all banks interrupts */ + pc->wake_irq[i] =3D irq_of_parse_and_map(np, i + + BCM2835_NUM_IRQS + 1); + + len =3D strlen(dev_name(pc->dev)) + 16; + name =3D devm_kzalloc(pc->dev, len, GFP_KERNEL); + if (!name) + return -ENOMEM; + + snprintf(name, len, "%s:bank%d", dev_name(pc->dev), i); + + /* These are optional interrupts */ + err =3D devm_request_irq(dev, pc->wake_irq[i], + bcm2835_gpio_wake_irq_handler, + IRQF_SHARED, name, pc); + if (err) + dev_warn(dev, "unable to request wake IRQ %d\n", + pc->wake_irq[i]); + } + girq->default_type =3D IRQ_TYPE_NONE; girq->handler =3D handle_level_irq; =20 From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B5F2C433FE for ; Thu, 27 Jan 2022 18:11:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245460AbiA0SLG (ORCPT ); Thu, 27 Jan 2022 13:11:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234646AbiA0SKb (ORCPT ); Thu, 27 Jan 2022 13:10:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14958C061778; Thu, 27 Jan 2022 10:10:06 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A99E861CFD; Thu, 27 Jan 2022 18:10:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F140C340E4; Thu, 27 Jan 2022 18:10:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643307005; bh=usKZn3JXGLa2EgML8OfV/XgVxFI0449sBWOMZZdN+xQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYVmIGpYppJGdH83gAnb6XmhTTegkbaCzC6wjHatwgOQY+ZwVhdrYy2KBmUNo2fLs cae7iBbvteg7zQ46esk/gPfuEvt6haKjBIf1VM8LZhMl0CMREjUpX591zpwn7l8OIE iBWT5wFoaiDCA85FoM6F/h7GQyRfQTcfjrD/XOM4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Phil Elwell , Florian Fainelli , Linus Walleij Subject: [PATCH 5.4 08/11] pinctrl: bcm2835: Change init order for gpio hogs Date: Thu, 27 Jan 2022 19:09:09 +0100 Message-Id: <20220127180258.633464181@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Phil Elwell commit 266423e60ea1b953fcc0cd97f3dad85857e434d1 upstream ...and gpio-ranges pinctrl-bcm2835 is a combined pinctrl/gpio driver. Currently the gpio side is registered first, but this breaks gpio hogs (which are configured during gpiochip_add_data). Part of the hog initialisation is a call to pinctrl_gpio_request, and since the pinctrl driver hasn't yet been registered this results in an -EPROBE_DEFER from which it can never recover. Change the initialisation sequence to register the pinctrl driver first. This also solves a similar problem with the gpio-ranges property, which is required in order for released pins to be returned to inputs. Fixes: 73345a18d464b ("pinctrl: bcm2835: Pass irqchip when adding gpiochip") Signed-off-by: Phil Elwell Reviewed-by: Florian Fainelli Link: https://lore.kernel.org/r/20211206092237.4105895-2-phil@raspberrypi.c= om Signed-off-by: Linus Walleij Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/pinctrl/bcm/pinctrl-bcm2835.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c @@ -1241,6 +1241,18 @@ static int bcm2835_pinctrl_probe(struct raw_spin_lock_init(&pc->irq_lock[i]); } =20 + pc->pctl_desc =3D *pdata->pctl_desc; + pc->pctl_dev =3D devm_pinctrl_register(dev, &pc->pctl_desc, pc); + if (IS_ERR(pc->pctl_dev)) { + gpiochip_remove(&pc->gpio_chip); + return PTR_ERR(pc->pctl_dev); + } + + pc->gpio_range =3D *pdata->gpio_range; + pc->gpio_range.base =3D pc->gpio_chip.base; + pc->gpio_range.gc =3D &pc->gpio_chip; + pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range); + girq =3D &pc->gpio_chip.irq; girq->chip =3D &bcm2835_gpio_irq_chip; girq->parent_handler =3D bcm2835_gpio_irq_handler; @@ -1248,8 +1260,10 @@ static int bcm2835_pinctrl_probe(struct girq->parents =3D devm_kcalloc(dev, BCM2835_NUM_IRQS, sizeof(*girq->parents), GFP_KERNEL); - if (!girq->parents) + if (!girq->parents) { + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); return -ENOMEM; + } =20 if (is_7211) { pc->wake_irq =3D devm_kcalloc(dev, BCM2835_NUM_IRQS, @@ -1300,21 +1314,10 @@ static int bcm2835_pinctrl_probe(struct err =3D gpiochip_add_data(&pc->gpio_chip, pc); if (err) { dev_err(dev, "could not add GPIO chip\n"); + pinctrl_remove_gpio_range(pc->pctl_dev, &pc->gpio_range); return err; } =20 - pc->pctl_desc =3D *pdata->pctl_desc; - pc->pctl_dev =3D devm_pinctrl_register(dev, &pc->pctl_desc, pc); - if (IS_ERR(pc->pctl_dev)) { - gpiochip_remove(&pc->gpio_chip); - return PTR_ERR(pc->pctl_dev); - } - - pc->gpio_range =3D *pdata->gpio_range; - pc->gpio_range.base =3D pc->gpio_chip.base; - pc->gpio_range.gc =3D &pc->gpio_chip; - pinctrl_add_gpio_range(pc->pctl_dev, &pc->gpio_range); - return 0; } =20 From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AAFFCC433FE for ; Thu, 27 Jan 2022 18:10:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245054AbiA0SKq (ORCPT ); Thu, 27 Jan 2022 13:10:46 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:47406 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244907AbiA0SKJ (ORCPT ); Thu, 27 Jan 2022 13:10:09 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B7B7661CFD; Thu, 27 Jan 2022 18:10:08 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 83F8BC340E8; Thu, 27 Jan 2022 18:10:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643307008; bh=EFpcAwDpY+fz2EowNsF/nN0eEBu6yVeazj+LOb5Thsw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vgr4O2upQp31dSJL0JUoIDY5GHljGkINR3tZxX8f1cWEtWExVasP9VIy5ULG2Bgj3 zcy/juzXbCUiaTy+5NWHcgG220gzpMAUqHGSWzOhapbtPDwgxpOhmvaFsboMywDfyN eXb98HGG4Rx8LtwbLW9Rk24T9z9LcHy5xa9Z2oD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Stefan Wahren , Florian Fainelli , Jan Kiszka , Phil Elwell , Linus Walleij , Olof Johansson Subject: [PATCH 5.4 09/11] ARM: dts: gpio-ranges property is now required Date: Thu, 27 Jan 2022 19:09:10 +0100 Message-Id: <20220127180258.672040734@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Phil Elwell commit c8013355ead68dce152cf426686f8a5f80d88b40 upstream Since [1], added in 5.7, the absence of a gpio-ranges property has prevented GPIOs from being restored to inputs when released. Add those properties for BCM283x and BCM2711 devices. [1] commit 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges") Link: https://lore.kernel.org/r/20220104170247.956760-1-linus.walleij@linar= o.org Fixes: 2ab73c6d8323 ("gpio: Support GPIO controllers without pin-ranges") Fixes: 266423e60ea1 ("pinctrl: bcm2835: Change init order for gpio hogs") Reported-by: Stefan Wahren Reported-by: Florian Fainelli Reported-by: Jan Kiszka Signed-off-by: Phil Elwell Acked-by: Florian Fainelli Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/20211206092237.4105895-3-phil@raspberrypi.c= om Signed-off-by: Linus Walleij Acked-by: Florian Fainelli Signed-off-by: Olof Johansson [florian: Remove bcm2711.dtsi hunk which does not exist in 5.4] Signed-off-by: Florian Fainelli Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- arch/arm/boot/dts/bcm283x.dtsi | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm/boot/dts/bcm283x.dtsi +++ b/arch/arm/boot/dts/bcm283x.dtsi @@ -183,6 +183,7 @@ =20 interrupt-controller; #interrupt-cells =3D <2>; + gpio-ranges =3D <&gpio 0 0 54>; =20 /* Defines pin muxing groups according to * BCM2835-ARM-Peripherals.pdf page 102. From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 072C2C433F5 for ; Thu, 27 Jan 2022 18:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245194AbiA0SKk (ORCPT ); Thu, 27 Jan 2022 13:10:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245105AbiA0SKG (ORCPT ); Thu, 27 Jan 2022 13:10:06 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0031CC061760; Thu, 27 Jan 2022 10:09:40 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9138B61998; Thu, 27 Jan 2022 18:09:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9384BC340E4; Thu, 27 Jan 2022 18:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306980; bh=IpEbzjHNZ3M3wBS0pnjWiz3QqDtWe7Ld1IE2tNFTah4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=od8y59CoEhxhD+UffxsHg4VBT/q8wSjA18Y4twGudjJTYJXG0DKZ3HhHDs6UvolY+ UesGMgmdnlJOHRQWZ77oUFpJBbo9z8/sAHj/lXFDYeR1zXwJchS2JczEJrnPNNpgp5 MNcHVc2ppoE48sK5ysUwb+yHIUz4GuyUZw88vU3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tim Harvey , Haibo Chen , Adrian Hunter , Ulf Hansson , Andrey Zhizhikin Subject: [PATCH 5.4 10/11] mmc: sdhci-esdhc-imx: disable CMDQ support Date: Thu, 27 Jan 2022 19:09:11 +0100 Message-Id: <20220127180258.704235716@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tim Harvey commit adab993c25191b839b415781bdc7173a77315240 upstream. On IMX SoC's which support CMDQ the following can occur during high a high cpu load: mmc2: cqhci: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D CQHCI REGISTER DUMP =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D mmc2: cqhci: Caps: 0x0000310a | Version: 0x00000510 mmc2: cqhci: Config: 0x00001001 | Control: 0x00000000 mmc2: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006 mmc2: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000 mmc2: cqhci: TDL base: 0x8003f000 | TDL up32: 0x00000000 mmc2: cqhci: Doorbell: 0xbf01dfff | TCN: 0x00000000 mmc2: cqhci: Dev queue: 0x00000000 | Dev Pend: 0x08000000 mmc2: cqhci: Task clr: 0x00000000 | SSC1: 0x00011000 mmc2: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000800 mmc2: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000 mmc2: cqhci: Resp idx: 0x0000000d | Resp arg: 0x00000000 mmc2: sdhci: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SDHCI REGISTER DUMP =3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D mmc2: sdhci: Sys addr: 0x7c722000 | Version: 0x00000002 mmc2: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000020 mmc2: sdhci: Argument: 0x00018000 | Trn mode: 0x00000023 mmc2: sdhci: Present: 0x01f88008 | Host ctl: 0x00000030 mmc2: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 mmc2: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f mmc2: sdhci: Timeout: 0x0000008f | Int stat: 0x00000000 mmc2: sdhci: Int enab: 0x107f4000 | Sig enab: 0x107f4000 mmc2: sdhci: ACmd stat: 0x00000000 | Slot int: 0x00000502 mmc2: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 mmc2: sdhci: Cmd: 0x00000d1a | Max curr: 0x00ffffff mmc2: sdhci: Resp[0]: 0x00000000 | Resp[1]: 0xffc003ff mmc2: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d07f01 mmc2: sdhci: Host ctl2: 0x00000088 mmc2: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0xfe179020 mmc2: sdhci-esdhc-imx: =3D=3D=3D=3D=3D=3D=3D=3D=3D ESDHC IMX DEBUG STATUS D= UMP =3D=3D=3D=3D mmc2: sdhci-esdhc-imx: cmd debug status: 0x2120 mmc2: sdhci-esdhc-imx: data debug status: 0x2200 mmc2: sdhci-esdhc-imx: trans debug status: 0x2300 mmc2: sdhci-esdhc-imx: dma debug status: 0x2400 mmc2: sdhci-esdhc-imx: adma debug status: 0x2510 mmc2: sdhci-esdhc-imx: fifo debug status: 0x2680 mmc2: sdhci-esdhc-imx: async fifo debug status: 0x2750 mmc2: sdhci: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D For now, disable CMDQ support on the imx8qm/imx8qxp/imx8mm until the issue is found and resolved. Fixes: bb6e358169bf6 ("mmc: sdhci-esdhc-imx: add CMDQ support") Fixes: cde5e8e9ff146 ("mmc: sdhci-esdhc-imx: Add an new esdhc_soc_data for = i.MX8MM") Cc: stable@vger.kernel.org Signed-off-by: Tim Harvey Reviewed-by: Haibo Chen Acked-by: Adrian Hunter Link: https://lore.kernel.org/r/20211103165415.2016-1-tharvey@gateworks.com Signed-off-by: Ulf Hansson Signed-off-by: Andrey Zhizhikin Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- drivers/mmc/host/sdhci-esdhc-imx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/mmc/host/sdhci-esdhc-imx.c +++ b/drivers/mmc/host/sdhci-esdhc-imx.c @@ -218,8 +218,7 @@ static struct esdhc_soc_data usdhc_imx7u static struct esdhc_soc_data usdhc_imx8qxp_data =3D { .flags =3D ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200 - | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES - | ESDHC_FLAG_CQHCI, + | ESDHC_FLAG_HS400 | ESDHC_FLAG_HS400_ES, }; =20 struct pltfm_imx_data { From nobody Tue Jun 30 06:15:43 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C200DC4332F for ; Thu, 27 Jan 2022 18:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238332AbiA0SKx (ORCPT ); Thu, 27 Jan 2022 13:10:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245166AbiA0SKH (ORCPT ); Thu, 27 Jan 2022 13:10:07 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 922D9C061714; Thu, 27 Jan 2022 10:09:45 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 522CEB818E1; Thu, 27 Jan 2022 18:09:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 911CAC340E4; Thu, 27 Jan 2022 18:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643306983; bh=hnC+WHQSB5Y9GOv0QCFpDjFeMVtgDx2Tl+exIvMj6zU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XzcAQlxZCLoq1MSbmtAx3Y+uT6yCoEs9ND8/nRokwi5HFKFiY/SPQCukkeHChXk8K e0lLyx3E8pXCiAzLxjJz/zMLeAlfYeHGZkcmz/ogn4dDpgG5N3PeINSp4PaTZleEAJ sKpHo2n2TFZ72v2RMcQemJGwc8orSqeV8xnYmO1c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Torvalds , Jan Kara Subject: [PATCH 5.4 11/11] select: Fix indefinitely sleeping task in poll_schedule_timeout() Date: Thu, 27 Jan 2022 19:09:12 +0100 Message-Id: <20220127180258.742791870@linuxfoundation.org> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220127180258.362000607@linuxfoundation.org> References: <20220127180258.362000607@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Jan Kara commit 68514dacf2715d11b91ca50d88de047c086fea9c upstream. A task can end up indefinitely sleeping in do_select() -> poll_schedule_timeout() when the following race happens: TASK1 (thread1) TASK2 TASK1 (thread2) do_select() setup poll_wqueues table with 'fd' write data to 'fd' pollwake() table->triggered =3D 1 closes 'fd' thread1 is waiting for poll_schedule_timeout() - sees table->triggered table->triggered =3D 0 return -EINTR loop back in do_select() But at this point when TASK1 loops back, the fdget() in the setup of poll_wqueues fails. So now so we never find 'fd' is ready for reading and sleep in poll_schedule_timeout() indefinitely. Treat an fd that got closed as a fd on which some event happened. This makes sure cannot block indefinitely in do_select(). Another option would be to return -EBADF in this case but that has a potential of subtly breaking applications that excercise this behavior and it happens to work for them. So returning fd as active seems like a safer choice. Suggested-by: Linus Torvalds CC: stable@vger.kernel.org Signed-off-by: Jan Kara Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested-by: Florian Fainelli Tested-by: Guenter Roeck Tested-by: Linux Kernel Functional Testing Tested-by: Shuah Khan Tested-by: Sudip Mukherjee --- fs/select.c | 63 +++++++++++++++++++++++++++++++------------------------= ----- 1 file changed, 33 insertions(+), 30 deletions(-) --- a/fs/select.c +++ b/fs/select.c @@ -458,9 +458,11 @@ get_max: return max; } =20 -#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | EPOLLHUP | EPOLL= ERR) -#define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT | EPOLLERR) -#define POLLEX_SET (EPOLLPRI) +#define POLLIN_SET (EPOLLRDNORM | EPOLLRDBAND | EPOLLIN | EPOLLHUP | EPOLL= ERR |\ + EPOLLNVAL) +#define POLLOUT_SET (EPOLLWRBAND | EPOLLWRNORM | EPOLLOUT | EPOLLERR |\ + EPOLLNVAL) +#define POLLEX_SET (EPOLLPRI | EPOLLNVAL) =20 static inline void wait_key_set(poll_table *wait, unsigned long in, unsigned long out, unsigned long bit, @@ -527,6 +529,7 @@ static int do_select(int n, fd_set_bits break; if (!(bit & all_bits)) continue; + mask =3D EPOLLNVAL; f =3D fdget(i); if (f.file) { wait_key_set(wait, in, out, bit, @@ -534,34 +537,34 @@ static int do_select(int n, fd_set_bits mask =3D vfs_poll(f.file, wait); =20 fdput(f); - if ((mask & POLLIN_SET) && (in & bit)) { - res_in |=3D bit; - retval++; - wait->_qproc =3D NULL; - } - if ((mask & POLLOUT_SET) && (out & bit)) { - res_out |=3D bit; - retval++; - wait->_qproc =3D NULL; - } - if ((mask & POLLEX_SET) && (ex & bit)) { - res_ex |=3D bit; - retval++; - wait->_qproc =3D NULL; - } - /* got something, stop busy polling */ - if (retval) { - can_busy_loop =3D false; - busy_flag =3D 0; - - /* - * only remember a returned - * POLL_BUSY_LOOP if we asked for it - */ - } else if (busy_flag & mask) - can_busy_loop =3D true; - } + if ((mask & POLLIN_SET) && (in & bit)) { + res_in |=3D bit; + retval++; + wait->_qproc =3D NULL; + } + if ((mask & POLLOUT_SET) && (out & bit)) { + res_out |=3D bit; + retval++; + wait->_qproc =3D NULL; + } + if ((mask & POLLEX_SET) && (ex & bit)) { + res_ex |=3D bit; + retval++; + wait->_qproc =3D NULL; + } + /* got something, stop busy polling */ + if (retval) { + can_busy_loop =3D false; + busy_flag =3D 0; + + /* + * only remember a returned + * POLL_BUSY_LOOP if we asked for it + */ + } else if (busy_flag & mask) + can_busy_loop =3D true; + } if (res_in) *rinp =3D res_in;