lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPDyKFqrQF8nBfLOHNyqM_LfPx7XjRCHT_PVzDKb98qxVjdSGQ@mail.gmail.com>
Date:   Thu, 29 Aug 2019 15:34:08 +0200
From:   Ulf Hansson <ulf.hansson@...aro.org>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:     "linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Piotr Sroka <piotrs@...ence.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] mmc: sdhci: use lower/upper_32_bits() macros for DMA addresses

On Thu, 29 Aug 2019 at 13:22, Masahiro Yamada
<yamada.masahiro@...ionext.com> wrote:
>
> Currently, the DMA addresses are casted to (u64) for the upper 32bits
> to avoid "right shift count >= width of type" warning.
>
> <linux/kernel.h> provides macros to address this, and I like the macro
> names are self-documenting.
>
> I introduced a new helper, sdhci_set_adma_addr() to avoid the code
> duplication.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@...ionext.com>

Applied for next, thanks!

Kind regards
Uffe


> ---
>
> Changes in v2:
>   - Another way to reduce linu wrapping
>
>  drivers/mmc/host/sdhci.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 08cc0792c174..66c2cf89ee22 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -668,10 +668,10 @@ void sdhci_adma_write_desc(struct sdhci_host *host, void **desc,
>         /* 32-bit and 64-bit descriptors have these members in same position */
>         dma_desc->cmd = cpu_to_le16(cmd);
>         dma_desc->len = cpu_to_le16(len);
> -       dma_desc->addr_lo = cpu_to_le32((u32)addr);
> +       dma_desc->addr_lo = cpu_to_le32(lower_32_bits(addr));
>
>         if (host->flags & SDHCI_USE_64_BIT_DMA)
> -               dma_desc->addr_hi = cpu_to_le32((u64)addr >> 32);
> +               dma_desc->addr_hi = cpu_to_le32(upper_32_bits(addr));
>
>         *desc += host->desc_sz;
>  }
> @@ -816,6 +816,13 @@ static void sdhci_adma_table_post(struct sdhci_host *host,
>         }
>  }
>
> +static void sdhci_set_adma_addr(struct sdhci_host *host, dma_addr_t addr)
> +{
> +       sdhci_writel(host, lower_32_bits(addr), SDHCI_ADMA_ADDRESS);
> +       if (host->flags & SDHCI_USE_64_BIT_DMA)
> +               sdhci_writel(host, upper_32_bits(addr), SDHCI_ADMA_ADDRESS_HI);
> +}
> +
>  static dma_addr_t sdhci_sdma_address(struct sdhci_host *host)
>  {
>         if (host->bounce_buffer)
> @@ -826,13 +833,10 @@ static dma_addr_t sdhci_sdma_address(struct sdhci_host *host)
>
>  static void sdhci_set_sdma_addr(struct sdhci_host *host, dma_addr_t addr)
>  {
> -       if (host->v4_mode) {
> -               sdhci_writel(host, addr, SDHCI_ADMA_ADDRESS);
> -               if (host->flags & SDHCI_USE_64_BIT_DMA)
> -                       sdhci_writel(host, (u64)addr >> 32, SDHCI_ADMA_ADDRESS_HI);
> -       } else {
> +       if (host->v4_mode)
> +               sdhci_set_adma_addr(host, addr);
> +       else
>                 sdhci_writel(host, addr, SDHCI_DMA_ADDRESS);
> -       }
>  }
>
>  static unsigned int sdhci_target_timeout(struct sdhci_host *host,
> @@ -1095,12 +1099,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)
>                         host->flags &= ~SDHCI_REQ_USE_DMA;
>                 } else if (host->flags & SDHCI_USE_ADMA) {
>                         sdhci_adma_table_pre(host, data, sg_cnt);
> -
> -                       sdhci_writel(host, host->adma_addr, SDHCI_ADMA_ADDRESS);
> -                       if (host->flags & SDHCI_USE_64_BIT_DMA)
> -                               sdhci_writel(host,
> -                                            (u64)host->adma_addr >> 32,
> -                                            SDHCI_ADMA_ADDRESS_HI);
> +                       sdhci_set_adma_addr(host, host->adma_addr);
>                 } else {
>                         WARN_ON(sg_cnt != 1);
>                         sdhci_set_sdma_addr(host, sdhci_sdma_address(host));
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ