From patchwork Thu Aug 29 11:22:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 172575 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp2077411ily; Thu, 29 Aug 2019 04:22:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2Z6T8KU4KRaAONar5hDfWiA8Gi1ADa3xCDbF3mq8P0kWa+GBBUl3bO990AKZb/u8GSZhw X-Received: by 2002:aa7:9682:: with SMTP id f2mr10586573pfk.256.1567077762675; Thu, 29 Aug 2019 04:22:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567077762; cv=none; d=google.com; s=arc-20160816; b=j/Cul5DnSWccVaadpY4+ivOpyUowq/8UcyvjQukVz9LBqDTjguUEvv6nbLCf2MUBwk kLwKxpcKR+SA0nb9pH30YzN6VF4oQLVmc7rhIkoIhQJ2POCZzsKk8HzNOo+xGmgMPwmd yMSfRwln4O/DjkTEWDc1WFRQGoM/IgsZe4qdQXiESqNZqBsRl10cl/LceA34z+b/2m+R BW6KuzH5trELr8x+Tm1svQYXIebcyCe0oroiUFhqjZK+9axirjG668EgmmRpEYYsEbk+ REh88TqSLLhUFtSHtFE23UGk+s4pn1rCgbweMLHMen0sQvxED4xJ/b9RtyWdFrVAqq3e QjDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=358U2uqPbl6qXFC9SXmqT9U+KgkSDo6eJ4UtGlqT3Kw=; b=YdAOE294TrjeFeF1Nrm6Py1APbz18HLUwSVIc85wFx27Np7d7RSdqfhcNkt8XfUyGk DTTlnKq8TQ7Wu2ai41QPfMS2yVGxrv1wvg0i+C3z29OzFVYXS2X3+6cxgXlvlgzI/I1C 8J2CDgUSiWbl8izzOQgMTIfQMI2Ge2Az8QRdw/HSqGw/gPtSCK/eNyanzO6zV6NgYOzF aLyxZJWjft5Y18fZ3/xf2OGFxa7yxcu3ARxpL7UOIwApHLvLFIl06Yd+kaEcYDNJrhz6 ADGLhULIOgBdPCGSkgrmZPRfS7vRuPnRh4yja51BRzZiUTpL6hjzpOwvVgk4VgizJvIH xUAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=iDDG+wOV; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si1914652pjo.88.2019.08.29.04.22.42; Thu, 29 Aug 2019 04:22:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=iDDG+wOV; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726926AbfH2LWm (ORCPT + 5 others); Thu, 29 Aug 2019 07:22:42 -0400 Received: from conuserg-12.nifty.com ([210.131.2.79]:62421 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbfH2LWl (ORCPT ); Thu, 29 Aug 2019 07:22:41 -0400 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id x7TBMDjE007183; Thu, 29 Aug 2019 20:22:13 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com x7TBMDjE007183 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1567077734; bh=358U2uqPbl6qXFC9SXmqT9U+KgkSDo6eJ4UtGlqT3Kw=; h=From:To:Cc:Subject:Date:From; b=iDDG+wOVXM/+21lGdyYLTmVoNK3HTjUTLOSnC6ELrsr289u4SiLK5ziYZWGKrbpNO xnETFHkR+5UdmQwOcRXT3LDqWkL6WZRDuymXkgxhYJQqA/rlq9GUuwdxCAvkVlLMit JpSvTfHKUXTWK3s+55EOvYH2SW0PZd5yB882M7G1n5iLjYEA7tVcvbTgnEkR3ym3nt bQmjX2g6M82XGvnpNxEEWeTPHdffHKu/sanvCOw5IAH+3JQeNEgmeNf4Pf9U57layo DaUSaTEbNJ2HRNnYR+Pwqa/JOezFT/+i2zaDGH0GGYz/2jtCnQTusuQQlPLlgF2yiP D/1Zu32494mrQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mmc@vger.kernel.org, Adrian Hunter , Ulf Hansson Cc: Piotr Sroka , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v2] mmc: sdhci: use lower/upper_32_bits() macros for DMA addresses Date: Thu, 29 Aug 2019 20:22:06 +0900 Message-Id: <20190829112206.22213-1-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.17.1 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Currently, the DMA addresses are casted to (u64) for the upper 32bits to avoid "right shift count >= width of type" warning. 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 --- Changes in v2: - Another way to reduce linu wrapping drivers/mmc/host/sdhci.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) -- 2.17.1 Acked-by: Adrian Hunter 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));