All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Wan Zongshun <vincent.wan@amd.com>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
	"linux-mmc@vger.kernel.org" <linux-mmc@vger.kernel.org>,
	Wan Zongshun <mcuos.com@gmail.com>, Borislav Petkov <bp@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Huang Rui <ray.huang@amd.com>
Subject: Re: [PATCH 2/3] mmc: sdhci-pci: Add platform tuning callback for amd hs200 mode
Date: Tue, 22 Dec 2015 14:30:19 +0200	[thread overview]
Message-ID: <CAHp75VcwcVnTEQYNKm5WZevVQ4143OVG2krumTL53r+rsv+wgA@mail.gmail.com> (raw)
In-Reply-To: <1450802408-16354-2-git-send-email-vincent.wan@amd.com>

On Tue, Dec 22, 2015 at 6:40 PM, Wan Zongshun <vincent.wan@amd.com> wrote:
> From: Wan Zongshun <Vincent.Wan@amd.com>
>
> AMD hs200 mode tuning mode is not compatible with standard tuning process,
> so we need .platform_execute_tuning callback support in sdhci-pci-core.c,
> this patch is to do:
>
> 1. Add platform_execute_tuning callback in sdhci_pci_slot.
> 2. Implement sdhci_pci_ops.platform_execute_tuning function.
>
> Signed-off-by: Wan Zongshun <Vincent.Wan@amd.com>
> ---
> Hi Ulf,
>
> Though modifying sdhci_pci_ops to be not const that is easy to implement
> my requirement, I am not sure it is right to do this.
>
> So I just follow sdhci_pci_select_drive_strength style to add new callback:
> sdhci_pci_platform_execute_tuning.
>
> But I also met trouble in sdhci_execute_tuning of sdhci.c, I have to suppose
> only sdhci_pci_platform_execute_tuning is returning -EPERM(current code,
> my assumption is right), so that those vendor that has no
> slot->platform_execute_tuning could be skipped and go next standard
> tuning process.
>
> If you have better idea for my requirement, please correct me.
>
> Thanks!
> Wan Zongshun.
>
> ---
>  drivers/mmc/host/sdhci-pci-core.c | 23 +++++++++++++++++++++++
>  drivers/mmc/host/sdhci-pci.h      |  1 +
>  drivers/mmc/host/sdhci.c          |  3 ++-
>  3 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
> index 01c5723..e7b2bbe 100644
> --- a/drivers/mmc/host/sdhci-pci-core.c
> +++ b/drivers/mmc/host/sdhci-pci-core.c
> @@ -905,8 +905,19 @@ static int amd_probe(struct sdhci_pci_chip *chip)
>         return 0;
>  }
>
> +static int amd_probe_slot(struct sdhci_pci_slot *slot)
> +{
> +       struct sdhci_host *host = slot->host;
> +
> +       if (host->quirks2 & SDHCI_QUIRK2_CLEAR_TRANSFERMODE_REG_BEFORE_CMD)
> +               slot->platform_execute_tuning = amd_execute_tuning;
> +
> +       return 0;
> +}
> +
>  static const struct sdhci_pci_fixes sdhci_amd = {
>         .probe          = amd_probe,
> +       .probe_slot     = amd_probe_slot,
>  };
>
>  static const struct pci_device_id pci_ids[] = {
> @@ -1508,6 +1519,17 @@ static int sdhci_pci_select_drive_strength(struct sdhci_host *host,
>                                            card_drv, drv_type);
>  }
>
> +static int sdhci_pci_platform_execute_tuning(struct sdhci_host *host,
> +                                            u32 opcode)
> +{
> +       struct sdhci_pci_slot *slot = sdhci_priv(host);
> +
> +       if (!slot->platform_execute_tuning)
> +               return -EPERM;

Here you return an error code.

> +
> +       return slot->platform_execute_tuning(host, opcode);
> +}
> +
>  static const struct sdhci_ops sdhci_pci_ops = {
>         .set_clock      = sdhci_set_clock,
>         .enable_dma     = sdhci_pci_enable_dma,
> @@ -1516,6 +1538,7 @@ static const struct sdhci_ops sdhci_pci_ops = {
>         .set_uhs_signaling = sdhci_set_uhs_signaling,
>         .hw_reset               = sdhci_pci_hw_reset,
>         .select_drive_strength  = sdhci_pci_select_drive_strength,
> +       .platform_execute_tuning = sdhci_pci_platform_execute_tuning,
>  };
>
>  /*****************************************************************************\
> diff --git a/drivers/mmc/host/sdhci-pci.h b/drivers/mmc/host/sdhci-pci.h
> index d1a0b4d..48d98f1 100644
> --- a/drivers/mmc/host/sdhci-pci.h
> +++ b/drivers/mmc/host/sdhci-pci.h
> @@ -83,6 +83,7 @@ struct sdhci_pci_slot {
>                                      struct mmc_card *card,
>                                      unsigned int max_dtr, int host_drv,
>                                      int card_drv, int *drv_type);
> +       int (*platform_execute_tuning)(struct sdhci_host *host, u32 opcode);
>  };
>
>  struct sdhci_pci_chip {
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 2753b722d..2a5a6ce 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1937,7 +1937,8 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
>                 spin_unlock_irqrestore(&host->lock, flags);
>                 err = host->ops->platform_execute_tuning(host, opcode);
>                 sdhci_runtime_pm_put(host);
> -               return err;
> +               if (err != EPERM)

…and here you ignore it. Perhaps better to introduce various positive codes

#define AMD_TUNNING_DONE 0
#define AMD_TUNNING_NA 1


> +                       return err;
>         }
>
>         ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
> --
> 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/



-- 
With Best Regards,
Andy Shevchenko

  reply	other threads:[~2015-12-22 12:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-22 16:40 [PATCH 1/3] mmc: sdhci-pci: Add AMD HS200 mode tuning function Wan Zongshun
2015-12-22 16:40 ` Wan Zongshun
2015-12-22  9:52 ` Andy Shevchenko
2015-12-23  0:40   ` Wan ZongShun
2015-12-22 16:40 ` [PATCH 2/3] mmc: sdhci-pci: Add platform tuning callback for amd hs200 mode Wan Zongshun
2015-12-22 16:40   ` Wan Zongshun
2015-12-22 12:30   ` Andy Shevchenko [this message]
2015-12-23  0:18     ` Wan ZongShun
2016-01-12 14:34   ` Ulf Hansson
2016-01-15  1:38     ` Wan Zongshun
2016-01-15  7:26       ` Ulf Hansson
2015-12-22 16:40 ` [PATCH 3/3] mmc: sdhci-pci: enable AMD emmc " Wan Zongshun
2015-12-22 16:40   ` Wan Zongshun

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=CAHp75VcwcVnTEQYNKm5WZevVQ4143OVG2krumTL53r+rsv+wgA@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=bp@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=mcuos.com@gmail.com \
    --cc=ray.huang@amd.com \
    --cc=ulf.hansson@linaro.org \
    --cc=vincent.wan@amd.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 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.