linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: linux-mmc@vger.kernel.org,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Simon Horman <simon.horman@netronome.com>,
	Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
	linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ulf Hansson <ulf.hansson@linaro.org>
Subject: Re: [PATCH v2 17/22] mmc: tmio: move TMIO_MASK_{READOP,WRITEOP} handling to correct place
Date: Tue, 16 Jan 2018 09:01:01 +0100	[thread overview]
Message-ID: <20180116080101.264qbj5inn76abom@ninjato> (raw)
In-Reply-To: <1511540697-27387-18-git-send-email-yamada.masahiro@socionext.com>

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

On Sat, Nov 25, 2017 at 01:24:52AM +0900, Masahiro Yamada wrote:
> This driver was largely extended by Renesas, but actually used by
> several SoC vendors.  The current code does not work for UniPhier
> SoCs at least.

Do you insist on this paragraph? All people working on the code so far
tried hard to make it work on all devices they had access to. So far, I
can't recall one of the several SoC vendors contacting upstream to get
their support merged (until now, of course) or even to file bugs.
Because I can't guess unknown stuff, I'd prefer to skip this paragraph.

> The DMA mode for UniPhier SoCs failed with the following error message:
>   PIO IRQ in DMA mode!
> 
> For UniPhier SoCs, the TMIO_MASK_{READOP,WRITEOP} are asserted in the
> DMA mode as well.

Sure, that we need to fix! Note that both Renesas DMA drivers also
enable DATAEND and disable RXRDY | TXRQ on their own, too. So, probably
the same issue? And IIUC we can decide now to prepare the irqs like this
in tmio_core because all known DMA engines need it. Or we keep it that
DMA engines set up irqs themselves. More flexible but maybe
over-engineered?

> In fact, the code is very strange.

Yes.

> The TMIO_MASK_{READOP,WRITEOP} IRQs are set as follows:
> 
>     /* Unmask the IRQs we want to know about */
>     if (!_host->chan_rx)
>             irq_mask |= TMIO_MASK_READOP;
>     if (!_host->chan_tx)
>             irq_mask |= TMIO_MASK_WRITEOP;
> 
> At this point, _host->{chan_rx,chan_tx} are _always_ NULL because
> tmio_mmc_request_dma() is called after this code.  Consequently,
> TMIO_MASK_{READOP,WRITEOP} are set whether DMA is used or not.

Yes :( Bummer.

> tmio_mmc_cmd_irq() enables TMIO_MASK_{READOP,WRITEOP}, but never
> disables them.  This does not take care of a case where ->force_pio
> is set, but unset later.

force_pio gets disabled within the same request? I may be overlooking
something but I only see code paths where force_pio gets cleared and a
little later the request gets finished. Can you give me a pointer?

> After all, the correct place to handle those flags is just before
> starting the data transfer.

While I totally agree the code below can be improved for sure, I'd
prefer to keep the design pattern that irqs get disabled once they are
not actively used. Generally spoken, I think it makes sense to keep
regressions on old platforms low. Any chance this can be achieved?
Other than that, fixing/removing this irq_mask handling from probe() is
really good.

> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
> Changes in v2:
>   - Newly added
> 
>  drivers/mmc/host/tmio_mmc_core.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
> index 7d169ed..345e379 100644
> --- a/drivers/mmc/host/tmio_mmc_core.c
> +++ b/drivers/mmc/host/tmio_mmc_core.c
> @@ -621,15 +621,19 @@ static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host, unsigned int stat)
>  	 */
>  	if (host->data && (!cmd->error || cmd->error == -EILSEQ)) {
>  		if (host->data->flags & MMC_DATA_READ) {
> -			if (host->force_pio || !host->chan_rx)
> +			if (host->force_pio || !host->chan_rx) {
>  				tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_READOP);
> -			else
> +			} else {
> +				tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_READOP);
>  				tasklet_schedule(&host->dma_issue);
> +			}
>  		} else {
> -			if (host->force_pio || !host->chan_tx)
> +			if (host->force_pio || !host->chan_tx) {
>  				tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_WRITEOP);
> -			else
> +			} else {
> +				tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_WRITEOP);
>  				tasklet_schedule(&host->dma_issue);
> +			}
>  		}
>  	} else {
>  		schedule_work(&host->done);
> @@ -1285,12 +1289,6 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host,
>  	_host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK);
>  	tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
>  
> -	/* Unmask the IRQs we want to know about */
> -	if (!_host->chan_rx)
> -		irq_mask |= TMIO_MASK_READOP;
> -	if (!_host->chan_tx)
> -		irq_mask |= TMIO_MASK_WRITEOP;
> -
>  	_host->sdcard_irq_mask &= ~irq_mask;
>  
>  	if (_host->native_hotplug)
> -- 
> 2.7.4
> 

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

  reply	other threads:[~2018-01-16  8:01 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24 16:24 [PATCH v2 00/22] mmc: tmio: various fixes and cleanups Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 01/22] mmc: renesas_sdhi: consolidate DMAC CONFIG options Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 02/22] mmc: renesas_sdhi: remove wrong depends on to enable compile test Masahiro Yamada
2017-11-26  9:02   ` Geert Uytterhoeven
2017-12-04 15:25   ` Wolfram Sang
2017-12-05  4:16     ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 03/22] mmc: renesas_sdhi: remove eprobe jump label Masahiro Yamada
2017-12-04 15:02   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 04/22] mmc: tmio: set tmio_mmc_host to driver data Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 05/22] mmc: tmio: use devm_ioremap_resource() instead of devm_ioremap() Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 06/22] mmc: tmio: move mmc_host_ops to struct tmio_mmc_host from static data Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 07/22] mmc: tmio, renesas_sdhi: set mmc_host_ops hooks directly Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 08/22] mmc: tmio: move mmc_gpio_request_cd() before mmc_add_host() Masahiro Yamada
2017-12-04 15:14   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 09/22] mmc: tmio: use mmc_can_gpio_cd() instead of checking TMIO_MMC_USE_GPIO_CD Masahiro Yamada
2017-12-04 22:22   ` Wolfram Sang
2018-01-02 12:56   ` Wolfram Sang
2018-01-12  4:06     ` Masahiro Yamada
2018-01-12 14:29   ` Ulf Hansson
2017-11-24 16:24 ` [PATCH v2 10/22] mmc: tmio: support IP-builtin card detection logic Masahiro Yamada
2017-12-04 15:13   ` Wolfram Sang
2017-12-05 15:03     ` Masahiro Yamada
2017-12-05 15:28       ` Wolfram Sang
2018-01-02 12:58   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 11/22] mmc: renesas_sdhi: remove always false condition Masahiro Yamada
2017-12-04 15:04   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 12/22] mmc: tmio,renesas_sdhi: move struct tmio_mmc_dma to renesas_sdhi.h Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 13/22] mmc: tmio,renesas_sdhi: move Renesas-specific DMA data " Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 14/22] mmc: tmio,renesas_sdhi: move ssc_tappos " Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 15/22] mmc: tmio: change bus_shift to unsigned int Masahiro Yamada
2017-12-04 15:05   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 16/22] mmc: tmio: fix never-detected card insertion bug Masahiro Yamada
2018-01-02 13:15   ` Wolfram Sang
2018-01-02 17:13     ` Wolfram Sang
2018-01-05 15:58       ` Masahiro Yamada
2018-01-13 20:59         ` Wolfram Sang
2018-01-17 16:32           ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 17/22] mmc: tmio: move TMIO_MASK_{READOP,WRITEOP} handling to correct place Masahiro Yamada
2018-01-16  8:01   ` Wolfram Sang [this message]
2018-01-17 16:45     ` Masahiro Yamada
2017-11-24 16:24 ` [PATCH v2 18/22] mmc: tmio: remove useless TMIO_MASK_CMD handling in tmio_mmc_host_probe() Masahiro Yamada
2018-01-16  9:44   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 19/22] mmc: tmio: ioremap memory resource in tmio_mmc_host_alloc() Masahiro Yamada
2018-01-16  9:44   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 20/22] mmc: tmio: move clk_enable/disable out of tmio_mmc_host_probe() Masahiro Yamada
2018-01-16 22:42   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 21/22] mmc: tmio: move {tmio_}mmc_of_parse() to tmio_mmc_host_alloc() Masahiro Yamada
2018-01-16 22:42   ` Wolfram Sang
2017-11-24 16:24 ` [PATCH v2 22/22] mmc: tmio: remove dma_ops from tmio_mmc_host_probe() argument Masahiro Yamada
2018-01-16 22:43   ` Wolfram Sang
2017-11-27 17:13 ` [PATCH v2 00/22] mmc: tmio: various fixes and cleanups Wolfram Sang
2017-11-28  2:18   ` Masahiro Yamada
2017-12-15  9:18 ` Ulf Hansson
2017-12-15 10:08   ` Masahiro Yamada
2017-12-15 11:12     ` Wolfram Sang
2017-12-15 13:34       ` Ulf Hansson
2017-12-15 16:30         ` Wolfram Sang
2017-12-15 16:34           ` Ulf Hansson
2017-12-15 19:08             ` Wolfram Sang
2017-12-19  3:56   ` Masahiro Yamada
2017-12-19  7:54     ` Ulf Hansson

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=20180116080101.264qbj5inn76abom@ninjato \
    --to=wsa@the-dreams.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=simon.horman@netronome.com \
    --cc=ulf.hansson@linaro.org \
    --cc=wsa+renesas@sang-engineering.com \
    --cc=yamada.masahiro@socionext.com \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /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 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).