All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-02-26 14:00 ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2021-02-26 14:00 UTC (permalink / raw)
  To: Mark Brown, Heiko Stuebner
  Cc: Pratyush Yadav, Arnd Bergmann, Nathan Chancellor,
	Nick Desaulniers, Emil Renner Berthing, Jon Lin, Johan Jonker,
	linux-spi, linux-arm-kernel, linux-rockchip, linux-kernel,
	clang-built-linux

From: Arnd Bergmann <arnd@arndb.de>

Building this file with clang leads to a an unreachable code path
causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Change the unreachable() into an error return that can be
handled if it ever happens, rather than silently crashing
the kernel.

Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use 'return' instead of 'BUG()'
---
 drivers/spi/spi-rockchip.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 936ef54e0903..0d75080da648 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
 	return 1;
 }
 
-static void rockchip_spi_config(struct rockchip_spi *rs,
+static int rockchip_spi_config(struct rockchip_spi *rs,
 		struct spi_device *spi, struct spi_transfer *xfer,
 		bool use_dma, bool slave_mode)
 {
@@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		dev_err(rs->dev, "unknown bits per word: %d\n",
+			xfer->bits_per_word);
+		return -EINVAL;
 	}
 
 	if (use_dma) {
@@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 	 */
 	writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
 			rs->regs + ROCKCHIP_SPI_BAUDR);
+
+	return 0;
 }
 
 static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
@@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
 		struct spi_transfer *xfer)
 {
 	struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
+	int ret;
 	bool use_dma;
 
 	WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
 
 	use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
 
-	rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	if (ret)
+		return ret;
 
 	if (use_dma)
 		return rockchip_spi_prepare_dma(rs, ctlr, xfer);
-- 
2.29.2


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

* [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-02-26 14:00 ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2021-02-26 14:00 UTC (permalink / raw)
  To: Mark Brown, Heiko Stuebner
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Jon Lin, Johan Jonker, Pratyush Yadav,
	linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

Building this file with clang leads to a an unreachable code path
causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Change the unreachable() into an error return that can be
handled if it ever happens, rather than silently crashing
the kernel.

Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use 'return' instead of 'BUG()'
---
 drivers/spi/spi-rockchip.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 936ef54e0903..0d75080da648 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
 	return 1;
 }
 
-static void rockchip_spi_config(struct rockchip_spi *rs,
+static int rockchip_spi_config(struct rockchip_spi *rs,
 		struct spi_device *spi, struct spi_transfer *xfer,
 		bool use_dma, bool slave_mode)
 {
@@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		dev_err(rs->dev, "unknown bits per word: %d\n",
+			xfer->bits_per_word);
+		return -EINVAL;
 	}
 
 	if (use_dma) {
@@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 	 */
 	writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
 			rs->regs + ROCKCHIP_SPI_BAUDR);
+
+	return 0;
 }
 
 static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
@@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
 		struct spi_transfer *xfer)
 {
 	struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
+	int ret;
 	bool use_dma;
 
 	WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
 
 	use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
 
-	rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	if (ret)
+		return ret;
 
 	if (use_dma)
 		return rockchip_spi_prepare_dma(rs, ctlr, xfer);
-- 
2.29.2


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-02-26 14:00 ` Arnd Bergmann
  0 siblings, 0 replies; 12+ messages in thread
From: Arnd Bergmann @ 2021-02-26 14:00 UTC (permalink / raw)
  To: Mark Brown, Heiko Stuebner
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Jon Lin, Johan Jonker, Pratyush Yadav,
	linux-arm-kernel

From: Arnd Bergmann <arnd@arndb.de>

Building this file with clang leads to a an unreachable code path
causing a warning from objtool:

drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame

Change the unreachable() into an error return that can be
handled if it ever happens, rather than silently crashing
the kernel.

Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use 'return' instead of 'BUG()'
---
 drivers/spi/spi-rockchip.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
index 936ef54e0903..0d75080da648 100644
--- a/drivers/spi/spi-rockchip.c
+++ b/drivers/spi/spi-rockchip.c
@@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
 	return 1;
 }
 
-static void rockchip_spi_config(struct rockchip_spi *rs,
+static int rockchip_spi_config(struct rockchip_spi *rs,
 		struct spi_device *spi, struct spi_transfer *xfer,
 		bool use_dma, bool slave_mode)
 {
@@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 		 * ctlr->bits_per_word_mask, so this shouldn't
 		 * happen
 		 */
-		unreachable();
+		dev_err(rs->dev, "unknown bits per word: %d\n",
+			xfer->bits_per_word);
+		return -EINVAL;
 	}
 
 	if (use_dma) {
@@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
 	 */
 	writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
 			rs->regs + ROCKCHIP_SPI_BAUDR);
+
+	return 0;
 }
 
 static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
@@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
 		struct spi_transfer *xfer)
 {
 	struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
+	int ret;
 	bool use_dma;
 
 	WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
@@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
 
 	use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
 
-	rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
+	if (ret)
+		return ret;
 
 	if (use_dma)
 		return rockchip_spi_prepare_dma(rs, ctlr, xfer);
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
  2021-02-26 14:00 ` Arnd Bergmann
  (?)
@ 2021-02-26 15:53   ` Pratyush Yadav
  -1 siblings, 0 replies; 12+ messages in thread
From: Pratyush Yadav @ 2021-02-26 15:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mark Brown, Heiko Stuebner, Arnd Bergmann, Nathan Chancellor,
	Nick Desaulniers, Emil Renner Berthing, Jon Lin, Johan Jonker,
	linux-spi, linux-arm-kernel, linux-rockchip, linux-kernel,
	clang-built-linux

On 26/02/21 03:00PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
> 
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Pratyush Yadav <p.yadav@ti.com>

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-02-26 15:53   ` Pratyush Yadav
  0 siblings, 0 replies; 12+ messages in thread
From: Pratyush Yadav @ 2021-02-26 15:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Heiko Stuebner, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Mark Brown, Jon Lin, Johan Jonker,
	linux-arm-kernel, Emil Renner Berthing

On 26/02/21 03:00PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
> 
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Pratyush Yadav <p.yadav@ti.com>

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-02-26 15:53   ` Pratyush Yadav
  0 siblings, 0 replies; 12+ messages in thread
From: Pratyush Yadav @ 2021-02-26 15:53 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Heiko Stuebner, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Mark Brown, Jon Lin, Johan Jonker,
	linux-arm-kernel, Emil Renner Berthing

On 26/02/21 03:00PM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
> 
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Acked-by: Pratyush Yadav <p.yadav@ti.com>

-- 
Regards,
Pratyush Yadav
Texas Instruments Inc.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
  2021-02-26 14:00 ` Arnd Bergmann
  (?)
@ 2021-03-01 17:15   ` Nick Desaulniers
  -1 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2021-03-01 17:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mark Brown, Heiko Stuebner, Pratyush Yadav, Arnd Bergmann,
	Nathan Chancellor, Emil Renner Berthing, Jon Lin, Johan Jonker,
	linux-spi, Linux ARM, linux-rockchip, LKML, clang-built-linux

On Fri, Feb 26, 2021 at 6:01 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
>
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
>
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
>
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for the v2!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
> v2: use 'return' instead of 'BUG()'
> ---
>  drivers/spi/spi-rockchip.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 936ef54e0903..0d75080da648 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
>         return 1;
>  }
>
> -static void rockchip_spi_config(struct rockchip_spi *rs,
> +static int rockchip_spi_config(struct rockchip_spi *rs,
>                 struct spi_device *spi, struct spi_transfer *xfer,
>                 bool use_dma, bool slave_mode)
>  {
> @@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>                  * ctlr->bits_per_word_mask, so this shouldn't
>                  * happen
>                  */
> -               unreachable();
> +               dev_err(rs->dev, "unknown bits per word: %d\n",
> +                       xfer->bits_per_word);
> +               return -EINVAL;
>         }
>
>         if (use_dma) {
> @@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>          */
>         writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
>                         rs->regs + ROCKCHIP_SPI_BAUDR);
> +
> +       return 0;
>  }
>
>  static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
> @@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
>                 struct spi_transfer *xfer)
>  {
>         struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
> +       int ret;
>         bool use_dma;
>
>         WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
> @@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
>
>         use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
>
> -       rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       if (ret)
> +               return ret;
>
>         if (use_dma)
>                 return rockchip_spi_prepare_dma(rs, ctlr, xfer);
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-03-01 17:15   ` Nick Desaulniers
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2021-03-01 17:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux, LKML,
	linux-spi, Nathan Chancellor, linux-rockchip, Mark Brown,
	Jon Lin, Johan Jonker, Pratyush Yadav, Linux ARM, Heiko Stuebner

On Fri, Feb 26, 2021 at 6:01 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
>
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
>
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
>
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for the v2!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
> v2: use 'return' instead of 'BUG()'
> ---
>  drivers/spi/spi-rockchip.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 936ef54e0903..0d75080da648 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
>         return 1;
>  }
>
> -static void rockchip_spi_config(struct rockchip_spi *rs,
> +static int rockchip_spi_config(struct rockchip_spi *rs,
>                 struct spi_device *spi, struct spi_transfer *xfer,
>                 bool use_dma, bool slave_mode)
>  {
> @@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>                  * ctlr->bits_per_word_mask, so this shouldn't
>                  * happen
>                  */
> -               unreachable();
> +               dev_err(rs->dev, "unknown bits per word: %d\n",
> +                       xfer->bits_per_word);
> +               return -EINVAL;
>         }
>
>         if (use_dma) {
> @@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>          */
>         writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
>                         rs->regs + ROCKCHIP_SPI_BAUDR);
> +
> +       return 0;
>  }
>
>  static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
> @@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
>                 struct spi_transfer *xfer)
>  {
>         struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
> +       int ret;
>         bool use_dma;
>
>         WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
> @@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
>
>         use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
>
> -       rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       if (ret)
> +               return ret;
>
>         if (use_dma)
>                 return rockchip_spi_prepare_dma(rs, ctlr, xfer);
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-03-01 17:15   ` Nick Desaulniers
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Desaulniers @ 2021-03-01 17:15 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux, LKML,
	linux-spi, Nathan Chancellor, linux-rockchip, Mark Brown,
	Jon Lin, Johan Jonker, Pratyush Yadav, Linux ARM, Heiko Stuebner

On Fri, Feb 26, 2021 at 6:01 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
>
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
>
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.
>
> Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks for the v2!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
> v2: use 'return' instead of 'BUG()'
> ---
>  drivers/spi/spi-rockchip.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> index 936ef54e0903..0d75080da648 100644
> --- a/drivers/spi/spi-rockchip.c
> +++ b/drivers/spi/spi-rockchip.c
> @@ -476,7 +476,7 @@ static int rockchip_spi_prepare_dma(struct rockchip_spi *rs,
>         return 1;
>  }
>
> -static void rockchip_spi_config(struct rockchip_spi *rs,
> +static int rockchip_spi_config(struct rockchip_spi *rs,
>                 struct spi_device *spi, struct spi_transfer *xfer,
>                 bool use_dma, bool slave_mode)
>  {
> @@ -521,7 +521,9 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>                  * ctlr->bits_per_word_mask, so this shouldn't
>                  * happen
>                  */
> -               unreachable();
> +               dev_err(rs->dev, "unknown bits per word: %d\n",
> +                       xfer->bits_per_word);
> +               return -EINVAL;
>         }
>
>         if (use_dma) {
> @@ -554,6 +556,8 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
>          */
>         writel_relaxed(2 * DIV_ROUND_UP(rs->freq, 2 * xfer->speed_hz),
>                         rs->regs + ROCKCHIP_SPI_BAUDR);
> +
> +       return 0;
>  }
>
>  static size_t rockchip_spi_max_transfer_size(struct spi_device *spi)
> @@ -577,6 +581,7 @@ static int rockchip_spi_transfer_one(
>                 struct spi_transfer *xfer)
>  {
>         struct rockchip_spi *rs = spi_controller_get_devdata(ctlr);
> +       int ret;
>         bool use_dma;
>
>         WARN_ON(readl_relaxed(rs->regs + ROCKCHIP_SPI_SSIENR) &&
> @@ -596,7 +601,9 @@ static int rockchip_spi_transfer_one(
>
>         use_dma = ctlr->can_dma ? ctlr->can_dma(ctlr, spi, xfer) : false;
>
> -       rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       ret = rockchip_spi_config(rs, spi, xfer, use_dma, ctlr->slave);
> +       if (ret)
> +               return ret;
>
>         if (use_dma)
>                 return rockchip_spi_prepare_dma(rs, ctlr, xfer);
> --
> 2.29.2
>


-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
  2021-02-26 14:00 ` Arnd Bergmann
  (?)
@ 2021-03-01 23:37   ` Mark Brown
  -1 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2021-03-01 23:37 UTC (permalink / raw)
  To: Heiko Stuebner, Arnd Bergmann
  Cc: linux-rockchip, Pratyush Yadav, Jon Lin, Nick Desaulniers,
	Johan Jonker, Nathan Chancellor, Emil Renner Berthing,
	linux-kernel, clang-built-linux, linux-spi, linux-arm-kernel,
	Arnd Bergmann

On Fri, 26 Feb 2021 15:00:48 +0100, Arnd Bergmann wrote:
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: rockchip: avoid objtool warning
      commit: d86e880f7a7c5b64a650146a1353f98750863f21

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-03-01 23:37   ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2021-03-01 23:37 UTC (permalink / raw)
  To: Heiko Stuebner, Arnd Bergmann
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Jon Lin, Johan Jonker, Pratyush Yadav,
	linux-arm-kernel

On Fri, 26 Feb 2021 15:00:48 +0100, Arnd Bergmann wrote:
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: rockchip: avoid objtool warning
      commit: d86e880f7a7c5b64a650146a1353f98750863f21

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

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

* Re: [PATCH] [v2] spi: rockchip: avoid objtool warning
@ 2021-03-01 23:37   ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2021-03-01 23:37 UTC (permalink / raw)
  To: Heiko Stuebner, Arnd Bergmann
  Cc: Emil Renner Berthing, Arnd Bergmann, clang-built-linux,
	Nick Desaulniers, linux-kernel, linux-spi, Nathan Chancellor,
	linux-rockchip, Jon Lin, Johan Jonker, Pratyush Yadav,
	linux-arm-kernel

On Fri, 26 Feb 2021 15:00:48 +0100, Arnd Bergmann wrote:
> Building this file with clang leads to a an unreachable code path
> causing a warning from objtool:
> 
> drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> 
> Change the unreachable() into an error return that can be
> handled if it ever happens, rather than silently crashing
> the kernel.

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: rockchip: avoid objtool warning
      commit: d86e880f7a7c5b64a650146a1353f98750863f21

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-03-02  7:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 14:00 [PATCH] [v2] spi: rockchip: avoid objtool warning Arnd Bergmann
2021-02-26 14:00 ` Arnd Bergmann
2021-02-26 14:00 ` Arnd Bergmann
2021-02-26 15:53 ` Pratyush Yadav
2021-02-26 15:53   ` Pratyush Yadav
2021-02-26 15:53   ` Pratyush Yadav
2021-03-01 17:15 ` Nick Desaulniers
2021-03-01 17:15   ` Nick Desaulniers
2021-03-01 17:15   ` Nick Desaulniers
2021-03-01 23:37 ` Mark Brown
2021-03-01 23:37   ` Mark Brown
2021-03-01 23:37   ` Mark Brown

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.