All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Mark Brown <broonie@kernel.org>, Magnus Damm <magnus.damm@gmail.com>
Cc: Takashi Yoshii <takasi-y@ops.dti.ne.jp>,
	linux-spi <linux-spi@vger.kernel.org>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Subject: Re: [PATCH 08/10] spi: sh-msiof: Move clock management to (un)prepare_message()
Date: Mon, 24 Feb 2014 09:48:26 +0000	[thread overview]
Message-ID: <CAMuHMdWF5BnPPFoWPqASQjc+9GCYZQEVcWRZaLNFzdz0rAt0_A@mail.gmail.com> (raw)
In-Reply-To: <20140222032700.GX25940@sirena.org.uk>

Hi Mark, Magnus,

On Sat, Feb 22, 2014 at 4:27 AM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 20, 2014 at 03:43:07PM +0100, Geert Uytterhoeven wrote:
>
>> +     if (!test_and_set_bit(0, &p->flags)) {
>> +             pm_runtime_get_sync(&p->pdev->dev);
>> +             clk_enable(p->clk);
>> +     }
>
> That test_and_set_bit() is a bit odd - what's going on there, perhaps a
> comment is in order?  I'd also like to see return value checks, though

My first guess was to support multiple CS, but you can't have multiple
active SPI slaves at the same time.

Perhaps it's because the bitbang core may call the .chipselect() callback
multiple times with is_on = BITBANG_CS_ACTIVE, and obviously the
clock should be enabled/disabled only once?
The current code doesn't seem to do that, but perhaps it was different when
the sh-msiof driver was written?

Ah, there's also the initial .chipselect(..., BITBANG_CS_INACTIVE) call
in spi_bitbang_setup(), which should not disable the clock.
But it should still call sh_msiof_spi_set_pin_regs() and set the optional
GPIO CS. Which is no longer done after my series. I'll fix that.

Magnus, do you remember the rationale for the test_and_set_bit()?

Anyway, it seems safe to remove it, as .(un)prepare_message() is
guaranteed to be called in matching pairs.

> the original didn't have them so it's not a blocker, and ideally that
> should be clk_prepare_enable().  I guess the clock stuff could even be
> moved inside the runtime PM callbacks?  Again not a blocker if the
> existing code doesn't have things but it'd be nice to do.
>
> There's also auto_runtime_pm in the SPI core which will do the runtime
> PM for you if you can do it unconditionally.

As you mention yourself, all of this code existed before. It just got moved,
to make the conversion to the SPI core message handling easier.
If you don't mind, I'd like to defer these, and tackle runtime PM later.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Mark Brown <broonie@kernel.org>, Magnus Damm <magnus.damm@gmail.com>
Cc: Takashi Yoshii <takasi-y@ops.dti.ne.jp>,
	linux-spi <linux-spi@vger.kernel.org>,
	Linux-sh list <linux-sh@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Geert Uytterhoeven <geert+renesas@linux-m68k.org>
Subject: Re: [PATCH 08/10] spi: sh-msiof: Move clock management to (un)prepare_message()
Date: Mon, 24 Feb 2014 10:48:26 +0100	[thread overview]
Message-ID: <CAMuHMdWF5BnPPFoWPqASQjc+9GCYZQEVcWRZaLNFzdz0rAt0_A@mail.gmail.com> (raw)
In-Reply-To: <20140222032700.GX25940@sirena.org.uk>

Hi Mark, Magnus,

On Sat, Feb 22, 2014 at 4:27 AM, Mark Brown <broonie@kernel.org> wrote:
> On Thu, Feb 20, 2014 at 03:43:07PM +0100, Geert Uytterhoeven wrote:
>
>> +     if (!test_and_set_bit(0, &p->flags)) {
>> +             pm_runtime_get_sync(&p->pdev->dev);
>> +             clk_enable(p->clk);
>> +     }
>
> That test_and_set_bit() is a bit odd - what's going on there, perhaps a
> comment is in order?  I'd also like to see return value checks, though

My first guess was to support multiple CS, but you can't have multiple
active SPI slaves at the same time.

Perhaps it's because the bitbang core may call the .chipselect() callback
multiple times with is_on == BITBANG_CS_ACTIVE, and obviously the
clock should be enabled/disabled only once?
The current code doesn't seem to do that, but perhaps it was different when
the sh-msiof driver was written?

Ah, there's also the initial .chipselect(..., BITBANG_CS_INACTIVE) call
in spi_bitbang_setup(), which should not disable the clock.
But it should still call sh_msiof_spi_set_pin_regs() and set the optional
GPIO CS. Which is no longer done after my series. I'll fix that.

Magnus, do you remember the rationale for the test_and_set_bit()?

Anyway, it seems safe to remove it, as .(un)prepare_message() is
guaranteed to be called in matching pairs.

> the original didn't have them so it's not a blocker, and ideally that
> should be clk_prepare_enable().  I guess the clock stuff could even be
> moved inside the runtime PM callbacks?  Again not a blocker if the
> existing code doesn't have things but it'd be nice to do.
>
> There's also auto_runtime_pm in the SPI core which will do the runtime
> PM for you if you can do it unconditionally.

As you mention yourself, all of this code existed before. It just got moved,
to make the conversion to the SPI core message handling easier.
If you don't mind, I'd like to defer these, and tackle runtime PM later.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

  reply	other threads:[~2014-02-24  9:48 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20 14:42 [PATCH 00/10] spi: sh-msiof: Add support for R-Car H2 and M2 Geert Uytterhoeven
2014-02-20 14:42 ` Geert Uytterhoeven
2014-02-20 14:42 ` Geert Uytterhoeven
2014-02-20 14:43 ` [PATCH 01/10] spi: sh-msiof: Fix SPI bus population from DT Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-22  3:10   ` Mark Brown
2014-02-22  3:10     ` Mark Brown
2014-02-20 14:43 ` [PATCH 02/10] spi: sh-msiof: Typo in comment s/tx/rx/ Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-22  3:10   ` Mark Brown
2014-02-22  3:10     ` Mark Brown
2014-02-20 14:43 ` [PATCH 03/10] spi: sh-msiof: Change hz from unsigned long to u32 Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-22  3:11   ` Mark Brown
2014-02-22  3:11     ` Mark Brown
     [not found] ` <1392907389-21798-1-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-02-20 14:43   ` [PATCH 04/10] spi: sh-msiof: Add more register documentation Geert Uytterhoeven
2014-02-20 14:43     ` Geert Uytterhoeven
2014-02-20 14:43     ` Geert Uytterhoeven
2014-02-22  3:11     ` Mark Brown
2014-02-22  3:11       ` Mark Brown
2014-02-20 14:43   ` [PATCH 09/10] spi: sh-msiof: Convert to let spi core validate xfer->bits_per_word Geert Uytterhoeven
2014-02-20 14:43     ` Geert Uytterhoeven
2014-02-20 14:43     ` Geert Uytterhoeven
2014-02-20 14:43 ` [PATCH 05/10] spi: sh-msiof: Use the core cs_gpio field, and make it optional Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-22  3:12   ` Mark Brown
2014-02-22  3:12     ` Mark Brown
2014-02-20 14:43 ` [PATCH 06/10] spi: sh-msiof: Improve binding documentation Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-20 14:43 ` [PATCH 07/10] spi: sh-msiof: Add support for R-Car H2 and M2 Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
     [not found]   ` <1392907389-21798-8-git-send-email-geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org>
2014-02-20 15:41     ` Magnus Damm
2014-02-20 15:41       ` Magnus Damm
2014-02-20 15:41       ` Magnus Damm
2014-02-20 16:13       ` Geert Uytterhoeven
2014-02-20 16:13         ` Geert Uytterhoeven
     [not found]         ` <CAMuHMdUByWPcYM8M_m5NVM4QP5cQE_tOLGQg=2fTNF7gqkUhig-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-02-22  3:14           ` Mark Brown
2014-02-22  3:14             ` Mark Brown
2014-02-22  3:14             ` Mark Brown
2014-02-24  2:45         ` Magnus Damm
2014-02-24  2:45           ` Magnus Damm
2014-02-24  7:39           ` Geert Uytterhoeven
2014-02-24  7:39             ` Geert Uytterhoeven
2014-02-24  8:09             ` Magnus Damm
2014-02-24  8:09               ` Magnus Damm
2014-02-20 14:43 ` [PATCH 08/10] spi: sh-msiof: Move clock management to (un)prepare_message() Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven
2014-02-22  3:27   ` Mark Brown
2014-02-22  3:27     ` Mark Brown
2014-02-24  9:48     ` Geert Uytterhoeven [this message]
2014-02-24  9:48       ` Geert Uytterhoeven
2014-02-24 13:07       ` Mark Brown
2014-02-24 13:07         ` Mark Brown
2014-02-25  1:43       ` Magnus Damm
2014-02-25  1:43         ` Magnus Damm
2014-02-20 14:43 ` [PATCH 10/10] spi: sh-msiof: Use core message handling instead of spi-bitbang Geert Uytterhoeven
2014-02-20 14:43   ` Geert Uytterhoeven

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=CAMuHMdWF5BnPPFoWPqASQjc+9GCYZQEVcWRZaLNFzdz0rAt0_A@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=broonie@kernel.org \
    --cc=geert+renesas@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=takasi-y@ops.dti.ne.jp \
    /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 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.