public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Linus Walleij <linus.walleij@linaro.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1 09/86] pinctrl: qcom: lpass-lpi: fix concurrent register updates
Date: Tue, 31 Oct 2023 18:00:34 +0100	[thread overview]
Message-ID: <20231031165918.907158629@linuxfoundation.org> (raw)
In-Reply-To: <20231031165918.608547597@linuxfoundation.org>

6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

[ Upstream commit c8befdc411e5fd1bf95a13e8744c8ca79b412bee ]

The Qualcomm LPASS LPI pin controller driver uses one lock for guarding
Read-Modify-Write code for slew rate registers.  However the pin
configuration and muxing registers have exactly the same RMW code but
are not protected.

Pin controller framework does not provide locking here, thus it is
possible to trigger simultaneous change of pin configuration registers
resulting in non-atomic changes.

Protect from concurrent access by re-using the same lock used to cover
the slew rate register.  Using the same lock instead of adding second
one will make more sense, once we add support for newer Qualcomm SoC,
where slew rate is configured in the same register as pin
configuration/muxing.

Fixes: 6e261d1090d6 ("pinctrl: qcom: Add sm8250 lpass lpi pinctrl driver")
Cc: stable@vger.kernel.org
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20231013145705.219954-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/pinctrl/qcom/pinctrl-lpass-lpi.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
index a55998ae29fa4..bfcc5c45b8fa5 100644
--- a/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
+++ b/drivers/pinctrl/qcom/pinctrl-lpass-lpi.c
@@ -24,7 +24,8 @@ struct lpi_pinctrl {
 	char __iomem *tlmm_base;
 	char __iomem *slew_base;
 	struct clk_bulk_data clks[MAX_LPI_NUM_CLKS];
-	struct mutex slew_access_lock;
+	/* Protects from concurrent register updates */
+	struct mutex lock;
 	const struct lpi_pinctrl_variant_data *data;
 };
 
@@ -94,9 +95,11 @@ static int lpi_gpio_set_mux(struct pinctrl_dev *pctldev, unsigned int function,
 	if (WARN_ON(i == g->nfuncs))
 		return -EINVAL;
 
+	mutex_lock(&pctrl->lock);
 	val = lpi_gpio_read(pctrl, pin, LPI_GPIO_CFG_REG);
 	u32p_replace_bits(&val, i, LPI_GPIO_FUNCTION_MASK);
 	lpi_gpio_write(pctrl, pin, LPI_GPIO_CFG_REG, val);
+	mutex_unlock(&pctrl->lock);
 
 	return 0;
 }
@@ -202,14 +205,14 @@ static int lpi_config_set(struct pinctrl_dev *pctldev, unsigned int group,
 			if (slew_offset == LPI_NO_SLEW)
 				break;
 
-			mutex_lock(&pctrl->slew_access_lock);
+			mutex_lock(&pctrl->lock);
 
 			sval = ioread32(pctrl->slew_base + LPI_SLEW_RATE_CTL_REG);
 			sval &= ~(LPI_SLEW_RATE_MASK << slew_offset);
 			sval |= arg << slew_offset;
 			iowrite32(sval, pctrl->slew_base + LPI_SLEW_RATE_CTL_REG);
 
-			mutex_unlock(&pctrl->slew_access_lock);
+			mutex_unlock(&pctrl->lock);
 			break;
 		default:
 			return -EINVAL;
@@ -225,6 +228,7 @@ static int lpi_config_set(struct pinctrl_dev *pctldev, unsigned int group,
 		lpi_gpio_write(pctrl, group, LPI_GPIO_VALUE_REG, val);
 	}
 
+	mutex_lock(&pctrl->lock);
 	val = lpi_gpio_read(pctrl, group, LPI_GPIO_CFG_REG);
 
 	u32p_replace_bits(&val, pullup, LPI_GPIO_PULL_MASK);
@@ -233,6 +237,7 @@ static int lpi_config_set(struct pinctrl_dev *pctldev, unsigned int group,
 	u32p_replace_bits(&val, output_enabled, LPI_GPIO_OE_MASK);
 
 	lpi_gpio_write(pctrl, group, LPI_GPIO_CFG_REG, val);
+	mutex_unlock(&pctrl->lock);
 
 	return 0;
 }
@@ -432,7 +437,7 @@ int lpi_pinctrl_probe(struct platform_device *pdev)
 	pctrl->chip.of_gpio_n_cells = 2;
 	pctrl->chip.can_sleep = false;
 
-	mutex_init(&pctrl->slew_access_lock);
+	mutex_init(&pctrl->lock);
 
 	pctrl->ctrl = devm_pinctrl_register(dev, &pctrl->desc, pctrl);
 	if (IS_ERR(pctrl->ctrl)) {
@@ -454,7 +459,7 @@ int lpi_pinctrl_probe(struct platform_device *pdev)
 	return 0;
 
 err_pinctrl:
-	mutex_destroy(&pctrl->slew_access_lock);
+	mutex_destroy(&pctrl->lock);
 	clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks);
 
 	return ret;
@@ -466,7 +471,7 @@ int lpi_pinctrl_remove(struct platform_device *pdev)
 	struct lpi_pinctrl *pctrl = platform_get_drvdata(pdev);
 	int i;
 
-	mutex_destroy(&pctrl->slew_access_lock);
+	mutex_destroy(&pctrl->lock);
 	clk_bulk_disable_unprepare(MAX_LPI_NUM_CLKS, pctrl->clks);
 
 	for (i = 0; i < pctrl->data->npins; i++)
-- 
2.42.0




  parent reply	other threads:[~2023-10-31 17:06 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 17:00 [PATCH 6.1 00/86] 6.1.61-rc1 review Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 01/86] KVM: x86/pmu: Truncate counter value to allowed width on write Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 02/86] mmc: core: Align to common busy polling behaviour for mmc ioctls Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 03/86] mmc: block: ioctl: do write error check for spi Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 04/86] mmc: core: Fix error propagation for some ioctl commands Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 05/86] ASoC: codecs: wcd938x: Convert to platform remove callback returning void Greg Kroah-Hartman
2023-10-31 17:11   ` Mark Brown
2023-10-31 17:44     ` Greg Kroah-Hartman
2023-10-31 17:49       ` Mark Brown
2023-10-31 20:41         ` Uwe Kleine-König
2023-11-01  6:23           ` Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 06/86] ASoC: codecs: wcd938x: Simplify with dev_err_probe Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 07/86] ASoC: codecs: wcd938x: fix regulator leaks on probe errors Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 08/86] ASoC: codecs: wcd938x: fix runtime PM imbalance on remove Greg Kroah-Hartman
2023-10-31 17:00 ` Greg Kroah-Hartman [this message]
2023-10-31 17:00 ` [PATCH 6.1 10/86] mcb: Return actual parsed size when reading chameleon table Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 11/86] mcb-lpc: Reallocate memory region to avoid memory overlapping Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 12/86] virtio_balloon: Fix endless deflation and inflation on arm64 Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 13/86] virtio-mmio: fix memory leak of vm_dev Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 14/86] virtio-crypto: handle config changed by work queue Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 15/86] virtio_pci: fix the common cfg map size Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 16/86] vsock/virtio: initialize the_virtio_vsock before using VQs Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 17/86] vhost: Allow null msg.size on VHOST_IOTLB_INVALIDATE Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 18/86] arm64: dts: rockchip: Add i2s0-2ch-bus-bclk-off pins to RK3399 Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 19/86] arm64: dts: rockchip: Fix i2s0 pin conflict on ROCK Pi 4 boards Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 20/86] mm: fix vm_brk_flags() to not bail out while holding lock Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 21/86] hugetlbfs: clear resv_map pointer if mmap fails Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 22/86] mm/page_alloc: correct start page when guard page debug is enabled Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 23/86] mm/migrate: fix do_pages_move for compat pointers Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 24/86] hugetlbfs: extend hugetlb_vma_lock to private VMAs Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 25/86] maple_tree: add GFP_KERNEL to allocations in mas_expected_entries() Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 26/86] nfsd: lock_rename() needs both directories to live on the same fs Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 27/86] drm/i915/pmu: Check if pmu is closed before stopping event Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 28/86] drm/amd: Disable ASPM for VI w/ all Intel systems Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 29/86] drm/dp_mst: Fix NULL deref in get_mst_branch_device_by_guid_helper() Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 30/86] ARM: OMAP: timer32K: fix all kernel-doc warnings Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 31/86] firmware/imx-dsp: Fix use_after_free in imx_dsp_setup_channels() Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 32/86] clk: ti: Fix missing omap4 mcbsp functional clock and aliases Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 33/86] clk: ti: Fix missing omap5 " Greg Kroah-Hartman
2023-10-31 17:00 ` [PATCH 6.1 34/86] r8169: fix the KCSAN reported data-race in rtl_tx() while reading tp->cur_tx Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 35/86] r8169: fix the KCSAN reported data-race in rtl_tx while reading TxDescArray[entry].opts1 Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 36/86] r8169: fix the KCSAN reported data race in rtl_rx while reading desc->opts1 Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 37/86] iavf: initialize waitqueues before starting watchdog_task Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 38/86] i40e: Fix I40E_FLAG_VF_VLAN_PRUNING value Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 39/86] treewide: Spelling fix in comment Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 40/86] igb: Fix potential memory leak in igb_add_ethtool_nfc_entry Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 41/86] neighbour: fix various data-races Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 42/86] igc: Fix ambiguity in the ethtool advertising Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 43/86] net: ethernet: adi: adin1110: Fix uninitialized variable Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 44/86] net: ieee802154: adf7242: Fix some potential buffer overflow in adf7242_stats_show() Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 45/86] net: usb: smsc95xx: Fix uninit-value access in smsc95xx_read_reg Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 46/86] r8152: Increase USB control msg timeout to 5000ms as per spec Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 47/86] r8152: Run the unload routine if we have errors during probe Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 48/86] r8152: Cancel hw_phy_work if we have an error in probe Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 49/86] r8152: Release firmware " Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 50/86] tcp: fix wrong RTO timeout when received SACK reneging Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 51/86] gtp: uapi: fix GTPA_MAX Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 52/86] gtp: fix fragmentation needed check with gso Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 53/86] i40e: Fix wrong check for I40E_TXR_FLAGS_WB_ON_ITR Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 54/86] drm/logicvc: Kconfig: select REGMAP and REGMAP_MMIO Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 55/86] iavf: in iavf_down, disable queues when removing the driver Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 56/86] scsi: sd: Introduce manage_shutdown device flag Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 57/86] blk-throttle: check for overflow in calculate_bytes_allowed Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 58/86] kasan: print the original fault addr when access invalid shadow Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 59/86] io_uring/fdinfo: lock SQ thread while retrieving thread cpu/pid Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 60/86] iio: afe: rescale: Accept only offset channels Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 61/86] iio: exynos-adc: request second interupt only when touchscreen mode is used Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 62/86] iio: adc: xilinx-xadc: Dont clobber preset voltage/temperature thresholds Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 63/86] iio: adc: xilinx-xadc: Correct temperature offset/scale for UltraScale Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 64/86] i2c: muxes: i2c-mux-pinctrl: Use of_get_i2c_adapter_by_node() Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 65/86] i2c: muxes: i2c-mux-gpmux: " Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 66/86] i2c: muxes: i2c-demux-pinctrl: " Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 67/86] i2c: stm32f7: Fix PEC handling in case of SMBUS transfers Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 68/86] i2c: aspeed: Fix i2c bus hang in slave read Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 69/86] tracing/kprobes: Fix the description of variable length arguments Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 70/86] misc: fastrpc: Reset metadata buffer to avoid incorrect free Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 71/86] misc: fastrpc: Free DMA handles for RPC calls with no arguments Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 72/86] misc: fastrpc: Clean buffers on remote invocation failures Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 73/86] misc: fastrpc: Unmap only if buffer is unmapped from DSP Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 74/86] nvmem: imx: correct nregs for i.MX6ULL Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 75/86] nvmem: imx: correct nregs for i.MX6SLL Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 76/86] nvmem: imx: correct nregs for i.MX6UL Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 77/86] x86/i8259: Skip probing when ACPI/MADT advertises PCAT compatibility Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 78/86] x86/cpu: Add model number for Intel Arrow Lake mobile processor Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 79/86] perf/core: Fix potential NULL deref Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 80/86] sparc32: fix a braino in fault handling in csum_and_copy_..._user() Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 81/86] clk: Sanitize possible_parent_show to Handle Return Value of of_clk_get_parent_name Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 82/86] platform/x86: Add s2idle quirk for more Lenovo laptops Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 83/86] ext4: add two helper functions extent_logical_end() and pa_logical_end() Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 84/86] ext4: fix BUG in ext4_mb_new_inode_pa() due to overflow Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 85/86] ext4: avoid overlapping preallocations " Greg Kroah-Hartman
2023-10-31 17:01 ` [PATCH 6.1 86/86] objtool/x86: add missing embedded_insn check Greg Kroah-Hartman
2023-10-31 19:37 ` [PATCH 6.1 00/86] 6.1.61-rc1 review Pavel Machek
2023-10-31 23:16 ` Florian Fainelli
2023-11-01  0:15 ` Shuah Khan
2023-11-01  2:39 ` Bagas Sanjaya
2023-11-01 10:08 ` Jon Hunter
2023-11-01 10:54 ` Ron Economos
2023-11-01 11:39 ` Ricardo B. Marliere
2023-11-01 13:30 ` Takeshi Ogasawara
2023-11-01 13:59 ` Naresh Kamboju
2023-11-01 14:57 ` Guenter Roeck
2023-11-01 18:53 ` Allen Pais

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231031165918.907158629@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox