mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 11/19] mci: sdhci: dove: fix pointer to u32 casts
Date: Mon, 12 Jun 2023 15:02:32 +0200	[thread overview]
Message-ID: <20230612130239.1087599-12-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230612130239.1087599-1-a.fatoum@pengutronix.de>

The dove SDHCI driver doesn't fully work on 64-bit, which
is ok as the SoC is ARMv7-only anways. We do want to be able to build
test the driver though, so replace straight casts of addr with
lower_32_bits(virt_to_phys(addr)), which has the same result, but makes
it clear that the upper 32 bit are truncated and silences the compiler
warnings.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mci/dove-sdhci.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/mci/dove-sdhci.c b/drivers/mci/dove-sdhci.c
index 9e6da6a81be1..5954058e6b30 100644
--- a/drivers/mci/dove-sdhci.c
+++ b/drivers/mci/dove-sdhci.c
@@ -87,9 +87,11 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 	if (data) {
 		num_bytes = data->blocks * data->blocksize;
 		if (data->flags & MMC_DATA_READ)
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->dest);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->dest)));
 		else
-			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS, (u32)data->src);
+			sdhci_write32(&host->sdhci, SDHCI_DMA_ADDRESS,
+				      lower_32_bits(virt_to_phys(data->src)));
 		sdhci_write16(&host->sdhci, SDHCI_BLOCK_SIZE, SDHCI_DMA_BOUNDARY_512K |
 				SDHCI_TRANSFER_BLOCK_SIZE(data->blocksize));
 		sdhci_write16(&host->sdhci, SDHCI_BLOCK_COUNT, data->blocks);
@@ -97,10 +99,12 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 
 		if (data->flags & MMC_DATA_WRITE)
-			dma_sync_single_for_device(host->mci.hw_dev, (unsigned long)data->src,
+			dma_sync_single_for_device(host->mci.hw_dev,
+						   lower_32_bits(virt_to_phys(data->src)),
 						    num_bytes, DMA_TO_DEVICE);
 		else
-			dma_sync_single_for_device(host->mci.hw_dev, (unsigned long)data->dest,
+			dma_sync_single_for_device(host->mci.hw_dev,
+						   lower_32_bits(virt_to_phys(data->dest)),
 						    num_bytes, DMA_FROM_DEVICE);
 	}
 
@@ -126,11 +130,13 @@ static int dove_sdhci_mci_send_cmd(struct mci_host *mci, struct mci_cmd *cmd,
 
 	if (data) {
 		if (data->flags & MMC_DATA_WRITE)
-			dma_sync_single_for_cpu(host->mci.hw_dev, (unsigned long)data->src,
+			dma_sync_single_for_cpu(host->mci.hw_dev,
+						lower_32_bits(virt_to_phys(data->src)),
 						num_bytes, DMA_TO_DEVICE);
 		else
-			dma_sync_single_for_cpu(host->mci.hw_dev, (unsigned long)data->dest,
-					 num_bytes, DMA_FROM_DEVICE);
+			dma_sync_single_for_cpu(host->mci.hw_dev,
+						lower_32_bits(virt_to_phys(data->dest)),
+						num_bytes, DMA_FROM_DEVICE);
 
 		ret = dove_sdhci_wait_for_done(host, SDHCI_INT_XFER_COMPLETE);
 		if (ret) {
-- 
2.39.2




  parent reply	other threads:[~2023-06-12 13:03 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 13:02 [PATCH 00/19] misc fixes building sandbox 64-bit allyesconfig Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 01/19] clk: always define clk_prepare_enable/disable Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 02/19] clk: define clk_get_parent stub Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 03/19] pci: disable building CONFIG_PCI when CONFIG_COMPILE_TEST Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 04/19] mci: tegra: fix base address constant to be hexadecimal Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 05/19] ata: ide-sff: fix warnings when compiling as 64-bit Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 06/19] video: bochs: remove dependency on PCI header in common part Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 07/19] commands: ubsan: hide pointer provenance used to trigger UB Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 08/19] test: self: printf: silence clang warnings Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 09/19] crypto: caam - fix pointer to u32 casts Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 10/19] crypto: imx-scc: fix u32 to pointer casts Ahmad Fatoum
2023-06-12 13:02 ` Ahmad Fatoum [this message]
2023-06-12 13:02 ` [PATCH 12/19] lib: make_directory: return -ENOMEM on allocation failure Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 13/19] include <linux/idr.h>: handle OOM gracefully inside idr_alloc_one Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 14/19] mci: tegra: use correct types for mmio and DMA address Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 15/19] mtd: spi-nor: cadence: fix types Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 16/19] video: simplefb-fixup: warn on framebuffers >= 4G Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 17/19] watchdog: imx28: use correct constant for computing timeout_max Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 18/19] firmware: mark firmware sections as having non-executable stack Ahmad Fatoum
2023-06-12 13:02 ` [PATCH 19/19] phy: stm32: usb: depend on COMMON_CLK Ahmad Fatoum
2023-06-13  7:49 ` [PATCH 00/19] misc fixes building sandbox 64-bit allyesconfig Sascha Hauer

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=20230612130239.1087599-12-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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