All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH for-4.9.y 0/5] Stable commits picked up from lede project
@ 2018-07-17  8:19 Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 1/5] mtd: m25p80: consider max message size in m25p80_read Amit Pundir
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable

Hi Greg,

For your consideration, stable commits picked up from lede source
tree https://git.lede-project.org/?p=source.git for 4.9.y.

Cherry-picked and build tested on Linux v4.9.112.

Regards,
Amit Pundir

Heiner Kallweit (1):
  mtd: m25p80: consider max message size in m25p80_read

Jonas Gorski (4):
  spi/bcm63xx: make spi subsystem aware of message size limits
  spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation
  bcm63xx_enet: correct clock usage
  bcm63xx_enet: do not write to random DMA channel on BCM6345

 drivers/mtd/devices/m25p80.c                 |  3 ++-
 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 34 ++++++++++++++++++++--------
 drivers/spi/spi-bcm63xx.c                    |  9 ++++++++
 3 files changed, 36 insertions(+), 10 deletions(-)

-- 
2.7.4

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

* [PATCH for-4.9.y 1/5] mtd: m25p80: consider max message size in m25p80_read
  2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
@ 2018-07-17  8:19 ` Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits Amit Pundir
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable; +Cc: Heiner Kallweit, Cyrille Pitchen

From: Heiner Kallweit <hkallweit1@gmail.com>

commit 9e276de6a367cde07c1a63522152985d4e5cca8b upstream.

Consider a message size limit when calculating the maximum amount
of data that can be read.

The message size limit has been introduced with 4.9, so cc it
to stable.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git

 drivers/mtd/devices/m25p80.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c
index 9cf7fcd28034..16a7df2a0246 100644
--- a/drivers/mtd/devices/m25p80.c
+++ b/drivers/mtd/devices/m25p80.c
@@ -172,7 +172,8 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,
 
 	t[1].rx_buf = buf;
 	t[1].rx_nbits = m25p80_rx_nbits(nor);
-	t[1].len = min(len, spi_max_transfer_size(spi));
+	t[1].len = min3(len, spi_max_transfer_size(spi),
+			spi_max_message_size(spi) - t[0].len);
 	spi_message_add_tail(&t[1], &m);
 
 	ret = spi_sync(spi, &m);
-- 
2.7.4

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

* [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits
  2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 1/5] mtd: m25p80: consider max message size in m25p80_read Amit Pundir
@ 2018-07-17  8:19 ` Amit Pundir
  2018-07-18 10:47   ` Mark Brown
  2018-07-17  8:19 ` [PATCH for-4.9.y 3/5] spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation Amit Pundir
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable; +Cc: Jonas Gorski, Mark Brown

From: Jonas Gorski <jonas.gorski@gmail.com>

commit 0135c03df914f0481c61f097c78d37cece84f330 upstream.

The bcm63xx SPI controller does not allow manual control of the CS
lines and will toggle it automatically before and after sending data,
so we are limited to messages that fit in the FIFO buffer. Since the CS
lines aren't available as GPIOs either, we will need to make slave
drivers aware of this limitation so they can handle them accordingly.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git

 drivers/spi/spi-bcm63xx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index fee747030ee6..caa733ec405c 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -428,6 +428,13 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+static size_t bcm63xx_spi_max_length(struct spi_device *dev)
+{
+	struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
+
+	return bs->fifo_size;
+}
+
 static const unsigned long bcm6348_spi_reg_offsets[] = {
 	[SPI_CMD]		= SPI_6348_CMD,
 	[SPI_INT_STATUS]	= SPI_6348_INT_STATUS,
@@ -541,6 +548,8 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	master->transfer_one_message = bcm63xx_spi_transfer_one;
 	master->mode_bits = MODEBITS;
 	master->bits_per_word_mask = SPI_BPW_MASK(8);
+	master->max_transfer_size = bcm63xx_spi_max_length;
+	master->max_message_size = bcm63xx_spi_max_length;
 	master->auto_runtime_pm = true;
 	bs->msg_type_shift = bs->reg_offsets[SPI_MSG_TYPE_SHIFT];
 	bs->msg_ctl_width = bs->reg_offsets[SPI_MSG_CTL_WIDTH];
-- 
2.7.4

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

* [PATCH for-4.9.y 3/5] spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation
  2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 1/5] mtd: m25p80: consider max message size in m25p80_read Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits Amit Pundir
@ 2018-07-17  8:19 ` Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 4/5] bcm63xx_enet: correct clock usage Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 5/5] bcm63xx_enet: do not write to random DMA channel on BCM6345 Amit Pundir
  4 siblings, 0 replies; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable; +Cc: Jonas Gorski, Mark Brown

From: Jonas Gorski <jonas.gorski@gmail.com>

commit ccd0657c33b2c3701c5b14725284b7e671d3fb93 upstream.

Fix compilation by renaming argument dev to spi as expected by the code.

Fixes the following error:

drivers/spi/spi-bcm63xx.c: In function ‘bcm63xx_spi_max_length’:
drivers/spi/spi-bcm63xx.c:434:50: error: ‘spi’ undeclared (first use in this function)
  struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
                                                  ^~~

Fixes: 0135c03df914 ("spi/bcm63xx: make spi subsystem aware of message size limits")
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git

 drivers/spi/spi-bcm63xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index caa733ec405c..7ee4b04a4a11 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -428,7 +428,7 @@ static irqreturn_t bcm63xx_spi_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static size_t bcm63xx_spi_max_length(struct spi_device *dev)
+static size_t bcm63xx_spi_max_length(struct spi_device *spi)
 {
 	struct bcm63xx_spi *bs = spi_master_get_devdata(spi->master);
 
-- 
2.7.4

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

* [PATCH for-4.9.y 4/5] bcm63xx_enet: correct clock usage
  2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
                   ` (2 preceding siblings ...)
  2018-07-17  8:19 ` [PATCH for-4.9.y 3/5] spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation Amit Pundir
@ 2018-07-17  8:19 ` Amit Pundir
  2018-07-17  8:19 ` [PATCH for-4.9.y 5/5] bcm63xx_enet: do not write to random DMA channel on BCM6345 Amit Pundir
  4 siblings, 0 replies; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable; +Cc: Jonas Gorski, David S . Miller

From: Jonas Gorski <jonas.gorski@gmail.com>

commit 9c86b846ce02f7e35d7234cf090b80553eba5389 upstream.

Check the return code of prepare_enable and change one last instance of
enable only to prepare_enable. Also properly disable and release the
clock in error paths and on remove for enetsw.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git

 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 31 +++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 08d91efceed0..3760a2be5dbc 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1790,7 +1790,9 @@ static int bcm_enet_probe(struct platform_device *pdev)
 		ret = PTR_ERR(priv->mac_clk);
 		goto out;
 	}
-	clk_prepare_enable(priv->mac_clk);
+	ret = clk_prepare_enable(priv->mac_clk);
+	if (ret)
+		goto out_put_clk_mac;
 
 	/* initialize default and fetch platform data */
 	priv->rx_ring_size = BCMENET_DEF_RX_DESC;
@@ -1822,9 +1824,11 @@ static int bcm_enet_probe(struct platform_device *pdev)
 		if (IS_ERR(priv->phy_clk)) {
 			ret = PTR_ERR(priv->phy_clk);
 			priv->phy_clk = NULL;
-			goto out_put_clk_mac;
+			goto out_disable_clk_mac;
 		}
-		clk_prepare_enable(priv->phy_clk);
+		ret = clk_prepare_enable(priv->phy_clk);
+		if (ret)
+			goto out_put_clk_phy;
 	}
 
 	/* do minimal hardware init to be able to probe mii bus */
@@ -1915,13 +1919,16 @@ static int bcm_enet_probe(struct platform_device *pdev)
 out_uninit_hw:
 	/* turn off mdc clock */
 	enet_writel(priv, 0, ENET_MIISC_REG);
-	if (priv->phy_clk) {
+	if (priv->phy_clk)
 		clk_disable_unprepare(priv->phy_clk);
+
+out_put_clk_phy:
+	if (priv->phy_clk)
 		clk_put(priv->phy_clk);
-	}
 
-out_put_clk_mac:
+out_disable_clk_mac:
 	clk_disable_unprepare(priv->mac_clk);
+out_put_clk_mac:
 	clk_put(priv->mac_clk);
 out:
 	free_netdev(dev);
@@ -2766,7 +2773,9 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 		ret = PTR_ERR(priv->mac_clk);
 		goto out_unmap;
 	}
-	clk_enable(priv->mac_clk);
+	ret = clk_prepare_enable(priv->mac_clk);
+	if (ret)
+		goto out_put_clk;
 
 	priv->rx_chan = 0;
 	priv->tx_chan = 1;
@@ -2787,7 +2796,7 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 
 	ret = register_netdev(dev);
 	if (ret)
-		goto out_put_clk;
+		goto out_disable_clk;
 
 	netif_carrier_off(dev);
 	platform_set_drvdata(pdev, dev);
@@ -2796,6 +2805,9 @@ static int bcm_enetsw_probe(struct platform_device *pdev)
 
 	return 0;
 
+out_disable_clk:
+	clk_disable_unprepare(priv->mac_clk);
+
 out_put_clk:
 	clk_put(priv->mac_clk);
 
@@ -2827,6 +2839,9 @@ static int bcm_enetsw_remove(struct platform_device *pdev)
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	release_mem_region(res->start, resource_size(res));
 
+	clk_disable_unprepare(priv->mac_clk);
+	clk_put(priv->mac_clk);
+
 	free_netdev(dev);
 	return 0;
 }
-- 
2.7.4

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

* [PATCH for-4.9.y 5/5] bcm63xx_enet: do not write to random DMA channel on BCM6345
  2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
                   ` (3 preceding siblings ...)
  2018-07-17  8:19 ` [PATCH for-4.9.y 4/5] bcm63xx_enet: correct clock usage Amit Pundir
@ 2018-07-17  8:19 ` Amit Pundir
  4 siblings, 0 replies; 9+ messages in thread
From: Amit Pundir @ 2018-07-17  8:19 UTC (permalink / raw)
  To: Greg KH, Stable; +Cc: Jonas Gorski, David S . Miller

From: Jonas Gorski <jonas.gorski@gmail.com>

commit d6213c1f2ad54a964b77471690264ed685718928 upstream.

The DMA controller regs actually point to DMA channel 0, so the write to
ENETDMA_CFG_REG will actually modify a random DMA channel.

Since DMA controller registers do not exist on BCM6345, guard the write
with the usual check for dma_has_sram.

Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
---
Cherry-picked from lede tree https://git.lede-project.org/?p=source.git

 drivers/net/ethernet/broadcom/bcm63xx_enet.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
index 3760a2be5dbc..c4078401b7de 100644
--- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c
+++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c
@@ -1063,7 +1063,8 @@ static int bcm_enet_open(struct net_device *dev)
 	val = enet_readl(priv, ENET_CTL_REG);
 	val |= ENET_CTL_ENABLE_MASK;
 	enet_writel(priv, val, ENET_CTL_REG);
-	enet_dma_writel(priv, ENETDMA_CFG_EN_MASK, ENETDMA_CFG_REG);
+	if (priv->dma_has_sram)
+		enet_dma_writel(priv, ENETDMA_CFG_EN_MASK, ENETDMA_CFG_REG);
 	enet_dmac_writel(priv, priv->dma_chan_en_mask,
 			 ENETDMAC_CHANCFG, priv->rx_chan);
 
-- 
2.7.4

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

* Re: [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits
  2018-07-17  8:19 ` [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits Amit Pundir
@ 2018-07-18 10:47   ` Mark Brown
  2018-07-18 10:55     ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Mark Brown @ 2018-07-18 10:47 UTC (permalink / raw)
  To: Amit Pundir; +Cc: Greg KH, Stable, Jonas Gorski

[-- Attachment #1: Type: text/plain, Size: 577 bytes --]

On Tue, Jul 17, 2018 at 01:49:15PM +0530, Amit Pundir wrote:
> From: Jonas Gorski <jonas.gorski@gmail.com>
> 
> commit 0135c03df914f0481c61f097c78d37cece84f330 upstream.
> 
> The bcm63xx SPI controller does not allow manual control of the CS
> lines and will toggle it automatically before and after sending data,
> so we are limited to messages that fit in the FIFO buffer. Since the CS
> lines aren't available as GPIOs either, we will need to make slave
> drivers aware of this limitation so they can handle them accordingly.

This seems a bit new featureish...

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits
  2018-07-18 10:47   ` Mark Brown
@ 2018-07-18 10:55     ` Greg KH
  2018-07-18 11:14       ` Mark Brown
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2018-07-18 10:55 UTC (permalink / raw)
  To: Mark Brown; +Cc: Amit Pundir, Stable, Jonas Gorski

On Wed, Jul 18, 2018 at 11:47:18AM +0100, Mark Brown wrote:
> On Tue, Jul 17, 2018 at 01:49:15PM +0530, Amit Pundir wrote:
> > From: Jonas Gorski <jonas.gorski@gmail.com>
> > 
> > commit 0135c03df914f0481c61f097c78d37cece84f330 upstream.
> > 
> > The bcm63xx SPI controller does not allow manual control of the CS
> > lines and will toggle it automatically before and after sending data,
> > so we are limited to messages that fit in the FIFO buffer. Since the CS
> > lines aren't available as GPIOs either, we will need to make slave
> > drivers aware of this limitation so they can handle them accordingly.
> 
> This seems a bit new featureish...

It is?  Reads like a bugfix to me to get crappy hardware to work
properly :)

Almost like a quirk addition.

Anyway, it's a 9 line patch that the users of the hardware require to
get it to work, is it a problem to add?

thanks,

greg k-h

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

* Re: [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits
  2018-07-18 10:55     ` Greg KH
@ 2018-07-18 11:14       ` Mark Brown
  0 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2018-07-18 11:14 UTC (permalink / raw)
  To: Greg KH; +Cc: Amit Pundir, Stable, Jonas Gorski

[-- Attachment #1: Type: text/plain, Size: 1182 bytes --]

On Wed, Jul 18, 2018 at 12:55:46PM +0200, Greg KH wrote:
> On Wed, Jul 18, 2018 at 11:47:18AM +0100, Mark Brown wrote:
> > On Tue, Jul 17, 2018 at 01:49:15PM +0530, Amit Pundir wrote:

> > > The bcm63xx SPI controller does not allow manual control of the CS
> > > lines and will toggle it automatically before and after sending data,
> > > so we are limited to messages that fit in the FIFO buffer. Since the CS
> > > lines aren't available as GPIOs either, we will need to make slave
> > > drivers aware of this limitation so they can handle them accordingly.

> > This seems a bit new featureish...

> It is?  Reads like a bugfix to me to get crappy hardware to work
> properly :)

> Almost like a quirk addition.

Yes, it is a quirk addition.

> Anyway, it's a 9 line patch that the users of the hardware require to
> get it to work, is it a problem to add?

It's one of these cases where if someone notices the change it's because
it causes the consumer driver to exercise code paths that they weren't
otherwise exercising (for a little used feature too).  If it were just
in the driver perhaps but the actual use of the change would be in other
code which makes it more risky.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, other threads:[~2018-07-18 11:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17  8:19 [PATCH for-4.9.y 0/5] Stable commits picked up from lede project Amit Pundir
2018-07-17  8:19 ` [PATCH for-4.9.y 1/5] mtd: m25p80: consider max message size in m25p80_read Amit Pundir
2018-07-17  8:19 ` [PATCH for-4.9.y 2/5] spi/bcm63xx: make spi subsystem aware of message size limits Amit Pundir
2018-07-18 10:47   ` Mark Brown
2018-07-18 10:55     ` Greg KH
2018-07-18 11:14       ` Mark Brown
2018-07-17  8:19 ` [PATCH for-4.9.y 3/5] spi/bcm63xx: fix typo in bcm63xx_spi_max_length breaking compilation Amit Pundir
2018-07-17  8:19 ` [PATCH for-4.9.y 4/5] bcm63xx_enet: correct clock usage Amit Pundir
2018-07-17  8:19 ` [PATCH for-4.9.y 5/5] bcm63xx_enet: do not write to random DMA channel on BCM6345 Amit Pundir

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.