Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1242442 > unrolled thread

[RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

Started byNeil Armstrong <narmstrong@baylibre.com>
First post2015-10-08 16:50 +0200
Last post2015-10-14 13:00 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in  prepare_message Neil Armstrong <narmstrong@baylibre.com> - 2015-10-08 16:50 +0200
    Re: [RFC PATCH] spi: omap2-mcspi: disable other channels  CHCONF_FORCE in prepare_message Michael Welling <mwelling@ieee.org> - 2015-10-08 17:30 +0200
      Re: [RFC PATCH] spi: omap2-mcspi: disable other channels  CHCONF_FORCE in prepare_message Mark Brown <broonie@kernel.org> - 2015-10-09 13:40 +0200
        Re: [RFC PATCH] spi: omap2-mcspi: disable other channels  CHCONF_FORCE in prepare_message Michael Welling <mwelling@ieee.org> - 2015-10-09 16:30 +0200
          Re: [RFC PATCH] spi: omap2-mcspi: disable other channels  CHCONF_FORCE in prepare_message Mark Brown <broonie@kernel.org> - 2015-10-14 13:00 +0200

#1242442 — [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

FromNeil Armstrong <narmstrong@baylibre.com>
Date2015-10-08 16:50 +0200
Subject[RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message
Message-ID<qhkG5-6u9-7@gated-at.bofh.it>
Since the "Switch driver to use transfer_one" change, the cs_change
behavior has changed and a channel chip select can still be
asserted when changing channel from a previous last transfer in s
message having the cs_change attribute.

Since there is no sense having multiple chip select being asserted at the
same time, disable all the remaining forces chip selects in a the
prepare_message called right before a spi_transfer_one_message call.

This is also a bug fix found in the McSPI into a DM8168 SoC, hanging
all the other channels transfers when a CHCONF_FORCE is present.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/spi/spi-omap2-mcspi.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

This is a patch RFC following the bug report :
'McSPI hangs with cs_change after "Switch driver to use transfer_one" change'
http://permalink.gmane.org/gmane.linux.kernel/2056841

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 3d09e0b..db1b655 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1217,6 +1217,33 @@ out:
 	return status;
 }

+static int omap2_mcspi_prepare_message(struct spi_master *master,
+				       struct spi_message *msg)
+{
+	struct omap2_mcspi	*mcspi = spi_master_get_devdata(master);
+	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
+	struct omap2_mcspi_cs	*cs;
+
+	/* Only a single channel can have the FORCE bit enabled
+	 * in its chconf0 register.
+	 * Scan all channels and disable them.
+	 * A FORCE can remain from a last transfer having cs_change enabled
+	 */
+
+	/* Ignore message */
+	(void)msg;
+
+	list_for_each_entry(cs, &ctx->cs, node) {
+		if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) {
+			cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
+			writel_relaxed(cs->chconf0,
+					cs->base + OMAP2_MCSPI_CHCONF0);
+		}
+	}
+
+	return 0;
+}
+
 static int omap2_mcspi_transfer_one(struct spi_master *master,
 		struct spi_device *spi, struct spi_transfer *t)
 {
@@ -1344,6 +1371,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
 	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
 	master->setup = omap2_mcspi_setup;
 	master->auto_runtime_pm = true;
+	master->prepare_message = omap2_mcspi_prepare_message;
 	master->transfer_one = omap2_mcspi_transfer_one;
 	master->set_cs = omap2_mcspi_set_cs;
 	master->cleanup = omap2_mcspi_cleanup;
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1242521 — Re: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

FromMichael Welling <mwelling@ieee.org>
Date2015-10-08 17:30 +0200
SubjectRe: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message
Message-ID<qhliO-7tw-7@gated-at.bofh.it>
In reply to#1242442
On Thu, Oct 08, 2015 at 04:45:00PM +0200, Neil Armstrong wrote:
> Since the "Switch driver to use transfer_one" change, the cs_change
> behavior has changed and a channel chip select can still be
> asserted when changing channel from a previous last transfer in s
> message having the cs_change attribute.
> 
> Since there is no sense having multiple chip select being asserted at the
> same time, disable all the remaining forces chip selects in a the
> prepare_message called right before a spi_transfer_one_message call.
> 
> This is also a bug fix found in the McSPI into a DM8168 SoC, hanging
> all the other channels transfers when a CHCONF_FORCE is present.
> 
> Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
> ---
>  drivers/spi/spi-omap2-mcspi.c | 28 ++++++++++++++++++++++++++++
>  1 file changed, 28 insertions(+)
> 
> This is a patch RFC following the bug report :
> 'McSPI hangs with cs_change after "Switch driver to use transfer_one" change'
> http://permalink.gmane.org/gmane.linux.kernel/2056841
> 
> diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
> index 3d09e0b..db1b655 100644
> --- a/drivers/spi/spi-omap2-mcspi.c
> +++ b/drivers/spi/spi-omap2-mcspi.c
> @@ -1217,6 +1217,33 @@ out:
>  	return status;
>  }
> 
> +static int omap2_mcspi_prepare_message(struct spi_master *master,
> +				       struct spi_message *msg)
> +{
> +	struct omap2_mcspi	*mcspi = spi_master_get_devdata(master);
> +	struct omap2_mcspi_regs	*ctx = &mcspi->ctx;
> +	struct omap2_mcspi_cs	*cs;
> +
> +	/* Only a single channel can have the FORCE bit enabled
> +	 * in its chconf0 register.
> +	 * Scan all channels and disable them.
> +	 * A FORCE can remain from a last transfer having cs_change enabled
> +	 */
> +

What is the point of doing this void cast below?
Avoiding compiler warning perhaps?
Perhaps you can __maybe_unused for the variable instead?

> +	/* Ignore message */
> +	(void)msg;
> +
> +	list_for_each_entry(cs, &ctx->cs, node) {
> +		if ((cs->chconf0 & OMAP2_MCSPI_CHCONF_FORCE)) {
> +			cs->chconf0 &= ~OMAP2_MCSPI_CHCONF_FORCE;
> +			writel_relaxed(cs->chconf0,
> +					cs->base + OMAP2_MCSPI_CHCONF0);
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static int omap2_mcspi_transfer_one(struct spi_master *master,
>  		struct spi_device *spi, struct spi_transfer *t)
>  {
> @@ -1344,6 +1371,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
>  	master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
>  	master->setup = omap2_mcspi_setup;
>  	master->auto_runtime_pm = true;
> +	master->prepare_message = omap2_mcspi_prepare_message;
>  	master->transfer_one = omap2_mcspi_transfer_one;
>  	master->set_cs = omap2_mcspi_set_cs;
>  	master->cleanup = omap2_mcspi_cleanup;
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1243275 — Re: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

FromMark Brown <broonie@kernel.org>
Date2015-10-09 13:40 +0200
SubjectRe: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message
Message-ID<qhEbM-R9-15@gated-at.bofh.it>
In reply to#1242521

[Multipart message — attachments visible in raw view] — view raw

On Thu, Oct 08, 2015 at 10:21:05AM -0500, Michael Welling wrote:
> On Thu, Oct 08, 2015 at 04:45:00PM +0200, Neil Armstrong wrote:

> What is the point of doing this void cast below?
> Avoiding compiler warning perhaps?
> Perhaps you can __maybe_unused for the variable instead?

> > +	/* Ignore message */
> > +	(void)msg;

You shouldn't need it at all, but yes if there is a good reason to mark
something as unused the above annotation is better.

[toc] | [prev] | [next] | [standalone]


#1243411 — Re: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

FromMichael Welling <mwelling@ieee.org>
Date2015-10-09 16:30 +0200
SubjectRe: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message
Message-ID<qhGQi-4IM-1@gated-at.bofh.it>
In reply to#1243275
On Fri, Oct 09, 2015 at 12:38:10PM +0100, Mark Brown wrote:
> On Thu, Oct 08, 2015 at 10:21:05AM -0500, Michael Welling wrote:
> > On Thu, Oct 08, 2015 at 04:45:00PM +0200, Neil Armstrong wrote:
> 
> > What is the point of doing this void cast below?
> > Avoiding compiler warning perhaps?
> > Perhaps you can __maybe_unused for the variable instead?
> 
> > > +	/* Ignore message */
> > > +	(void)msg;
> 
> You shouldn't need it at all, but yes if there is a good reason to mark
> something as unused the above annotation is better.

Which one?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1246518 — Re: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message

FromMark Brown <broonie@kernel.org>
Date2015-10-14 13:00 +0200
SubjectRe: [RFC PATCH] spi: omap2-mcspi: disable other channels CHCONF_FORCE in prepare_message
Message-ID<qjrWO-4AF-21@gated-at.bofh.it>
In reply to#1243411

[Multipart message — attachments visible in raw view] — view raw

On Fri, Oct 09, 2015 at 09:24:51AM -0500, Michael Welling wrote:
> On Fri, Oct 09, 2015 at 12:38:10PM +0100, Mark Brown wrote:
> > On Thu, Oct 08, 2015 at 10:21:05AM -0500, Michael Welling wrote:
> > > On Thu, Oct 08, 2015 at 04:45:00PM +0200, Neil Armstrong wrote:

> > > What is the point of doing this void cast below?
> > > Avoiding compiler warning perhaps?
> > > Perhaps you can __maybe_unused for the variable instead?

> > > > +	/* Ignore message */
> > > > +	(void)msg;

> > You shouldn't need it at all, but yes if there is a good reason to mark
> > something as unused the above annotation is better.

> Which one?

__maybe_unused.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web