linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode
@ 2021-07-04 23:06 Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 15/70] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:06 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Charles Keepax, Mark Brown, Sasha Levin, linux-spi

From: Charles Keepax <ckeepax@opensource.cirrus.com>

[ Upstream commit 0e793ba77c18382f08e440260fe72bc6fce2a3cb ]

Currently, the SPI core doesn't set the struct device fwnode pointer
when it creates a new SPI device. This means when the device is
registered the fwnode is NULL and the check in device_add which sets
the fwnode->dev pointer is skipped. This wasn't previously an issue,
however these two patches:

commit 4731210c09f5 ("gpiolib: Bind gpio_device to a driver to enable
fw_devlink=on by default")
commit ced2af419528 ("gpiolib: Don't probe gpio_device if it's not the
primary device")

Added some code to the GPIO core which relies on using that
fwnode->dev pointer to determine if a driver is bound to the fwnode
and if not bind a stub GPIO driver. This means the GPIO providers
behind SPI will get both the expected driver and this stub driver
causing the stub driver to fail if it attempts to request any pin
configuration. For example on my system:

madera-pinctrl madera-pinctrl: pin gpio5 already requested by madera-pinctrl; cannot claim for gpiochip3
madera-pinctrl madera-pinctrl: pin-4 (gpiochip3) status -22
madera-pinctrl madera-pinctrl: could not request pin 4 (gpio5) from group aif1  on device madera-pinctrl
gpio_stub_drv gpiochip3: Error applying setting, reverse things back
gpio_stub_drv: probe of gpiochip3 failed with error -22

The firmware node on the device created by the GPIO framework is set
through the of_node pointer hence things generally actually work,
however that fwnode->dev is never set, as the check was skipped at
device_add time. This fix appears to match how the I2C subsystem
handles the same situation.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210421101402.8468-1-ckeepax@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 0cf67de741e7..bd8b1f79dce2 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -2050,6 +2050,7 @@ of_register_spi_device(struct spi_controller *ctlr, struct device_node *nc)
 	/* Store a pointer to the node in the device structure */
 	of_node_get(nc);
 	spi->dev.of_node = nc;
+	spi->dev.fwnode = of_fwnode_handle(nc);
 
 	/* Register the new device */
 	rc = spi_add_device(spi);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 5.10 15/70] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf'
  2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
@ 2021-07-04 23:07 ` Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 16/70] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:07 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Jay Fang, Mark Brown, Sasha Levin, linux-spi

From: Jay Fang <f.fangjian@huawei.com>

[ Upstream commit 9e37a3ab0627011fb63875e9a93094b6fc8ddf48 ]

In function 'spi_test_run_iter': Value 'tx_buf' might be 'rx_buf'.

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1620629903-15493-5-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-loopback-test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
index df981e55c24c..89b91cdfb2a5 100644
--- a/drivers/spi/spi-loopback-test.c
+++ b/drivers/spi/spi-loopback-test.c
@@ -874,7 +874,7 @@ static int spi_test_run_iter(struct spi_device *spi,
 		test.transfers[i].len = len;
 		if (test.transfers[i].tx_buf)
 			test.transfers[i].tx_buf += tx_off;
-		if (test.transfers[i].tx_buf)
+		if (test.transfers[i].rx_buf)
 			test.transfers[i].rx_buf += rx_off;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 5.10 16/70] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages()
  2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 15/70] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
@ 2021-07-04 23:07 ` Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 17/70] spi: omap-100k: Fix the length judgment problem Sasha Levin
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:07 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Jay Fang, Mark Brown, Sasha Levin, linux-spi

From: Jay Fang <f.fangjian@huawei.com>

[ Upstream commit 026a1dc1af52742c5897e64a3431445371a71871 ]

pch_spi_set_tx() frees data->pkt_tx_buff on failure of kzalloc() for
data->pkt_rx_buff, but its caller, pch_spi_process_messages(), will
free data->pkt_tx_buff again. Set data->pkt_tx_buff to NULL after
kfree() to avoid double free.

Signed-off-by: Jay Fang <f.fangjian@huawei.com>
Link: https://lore.kernel.org/r/1620284888-65215-1-git-send-email-f.fangjian@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-topcliff-pch.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index b459e369079f..7fb020a1d66a 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -580,8 +580,10 @@ static void pch_spi_set_tx(struct pch_spi_data *data, int *bpw)
 	data->pkt_tx_buff = kzalloc(size, GFP_KERNEL);
 	if (data->pkt_tx_buff != NULL) {
 		data->pkt_rx_buff = kzalloc(size, GFP_KERNEL);
-		if (!data->pkt_rx_buff)
+		if (!data->pkt_rx_buff) {
 			kfree(data->pkt_tx_buff);
+			data->pkt_tx_buff = NULL;
+		}
 	}
 
 	if (!data->pkt_rx_buff) {
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 5.10 17/70] spi: omap-100k: Fix the length judgment problem
  2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 15/70] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 16/70] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
@ 2021-07-04 23:07 ` Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 48/70] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 49/70] spi: meson-spicc: fix memory leak in meson_spicc_probe Sasha Levin
  4 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:07 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Tian Tao, Mark Brown, Sasha Levin, linux-spi

From: Tian Tao <tiantao6@hisilicon.com>

[ Upstream commit e7a1a3abea373e41ba7dfe0fbc93cb79b6a3a529 ]

word_len should be checked in the omap1_spi100k_setup_transfer
function to see if it exceeds 32.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Link: https://lore.kernel.org/r/1619695248-39045-1-git-send-email-tiantao6@hisilicon.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-omap-100k.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-omap-100k.c b/drivers/spi/spi-omap-100k.c
index ccd817ee4917..0d0cd061d356 100644
--- a/drivers/spi/spi-omap-100k.c
+++ b/drivers/spi/spi-omap-100k.c
@@ -241,7 +241,7 @@ static int omap1_spi100k_setup_transfer(struct spi_device *spi,
 	else
 		word_len = spi->bits_per_word;
 
-	if (spi->bits_per_word > 32)
+	if (word_len > 32)
 		return -EINVAL;
 	cs->word_len = word_len;
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 5.10 48/70] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak.
  2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
                   ` (2 preceding siblings ...)
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 17/70] spi: omap-100k: Fix the length judgment problem Sasha Levin
@ 2021-07-04 23:07 ` Sasha Levin
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 49/70] spi: meson-spicc: fix memory leak in meson_spicc_probe Sasha Levin
  4 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:07 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: zpershuai, Neil Armstrong, Mark Brown, Sasha Levin, linux-spi,
	linux-arm-kernel, linux-amlogic

From: zpershuai <zpershuai@gmail.com>

[ Upstream commit 95730d5eb73170a6d225a9998c478be273598634 ]

In meson_spifc_probe function, when enable the device pclk clock is
error, it should use clk_disable_unprepare to release the core clock.

Signed-off-by: zpershuai <zpershuai@gmail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lore.kernel.org/r/1623562172-22056-1-git-send-email-zpershuai@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-meson-spicc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index ecba6b4a5d85..51aef2c6e966 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -725,7 +725,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	ret = clk_prepare_enable(spicc->pclk);
 	if (ret) {
 		dev_err(&pdev->dev, "pclk clock enable failed\n");
-		goto out_master;
+		goto out_core_clk;
 	}
 
 	device_reset_optional(&pdev->dev);
@@ -764,9 +764,11 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	return 0;
 
 out_clk:
-	clk_disable_unprepare(spicc->core);
 	clk_disable_unprepare(spicc->pclk);
 
+out_core_clk:
+	clk_disable_unprepare(spicc->core);
+
 out_master:
 	spi_master_put(master);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH AUTOSEL 5.10 49/70] spi: meson-spicc: fix memory leak in meson_spicc_probe
  2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
                   ` (3 preceding siblings ...)
  2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 48/70] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak Sasha Levin
@ 2021-07-04 23:07 ` Sasha Levin
  4 siblings, 0 replies; 6+ messages in thread
From: Sasha Levin @ 2021-07-04 23:07 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: zpershuai, Neil Armstrong, Mark Brown, Sasha Levin, linux-spi,
	linux-arm-kernel, linux-amlogic

From: zpershuai <zpershuai@gmail.com>

[ Upstream commit b2d501c13470409ee7613855b17e5e5ec4111e1c ]

when meson_spicc_clk_init returns failed, it should goto the
out_clk label.

Signed-off-by: zpershuai <zpershuai@gmail.com>
Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Link: https://lore.kernel.org/r/1623562156-21995-1-git-send-email-zpershuai@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/spi/spi-meson-spicc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-meson-spicc.c b/drivers/spi/spi-meson-spicc.c
index 51aef2c6e966..b2c4621db34d 100644
--- a/drivers/spi/spi-meson-spicc.c
+++ b/drivers/spi/spi-meson-spicc.c
@@ -752,7 +752,7 @@ static int meson_spicc_probe(struct platform_device *pdev)
 	ret = meson_spicc_clk_init(spicc);
 	if (ret) {
 		dev_err(&pdev->dev, "clock registration failed\n");
-		goto out_master;
+		goto out_clk;
 	}
 
 	ret = devm_spi_register_master(&pdev->dev, master);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-04 23:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 23:06 [PATCH AUTOSEL 5.10 01/70] spi: Make of_register_spi_device also set the fwnode Sasha Levin
2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 15/70] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 16/70] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 17/70] spi: omap-100k: Fix the length judgment problem Sasha Levin
2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 48/70] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak Sasha Levin
2021-07-04 23:07 ` [PATCH AUTOSEL 5.10 49/70] spi: meson-spicc: fix memory leak in meson_spicc_probe Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).