diff mbox series

[net,13/13] can: kvaser_pciefd: Enable 64-bit DMA addressing

Message ID 20240829192947.1186760-14-mkl@pengutronix.de (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net,01/13] can: bcm: Remove proc entry when dev is unregistered. | expand

Checks

Context Check Description
netdev/series_format success Pull request is its own cover letter
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 3 maintainers not CCed: pabeni@redhat.com edumazet@google.com mailhol.vincent@wanadoo.fr
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-30--06-00 (tests: 714)

Commit Message

Marc Kleine-Budde Aug. 29, 2024, 7:20 p.m. UTC
From: Martin Jocic <martin.jocic@kvaser.com>

Enabling 64-bit addressing for DMA buffers will prevent issues
on some memory constrained platforms like e.g. Raspberry Pi 5,
where the driver won't load because it cannot allocate enough
continuous memory in the default 32-bit memory address range.

Signed-off-by: Martin Jocic <martin.jocic@kvaser.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/kvaser_pciefd.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Jakub Kicinski Aug. 30, 2024, 8:17 p.m. UTC | #1
On Thu, 29 Aug 2024 21:20:46 +0200 Marc Kleine-Budde wrote:
> +	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
> +		dma_set_mask_and_coherent(&pcie->pci->dev, DMA_BIT_MASK(64));

This IS_ENABLED() is quite unusual. The driver just advertises its
capability of using 64 addressing. If the platform doesn't support
64b DMA addressing and therefore dma_addr_t is narrower, everything
will still work. I could be wrong, but that's how I understand it.
Marc Kleine-Budde Aug. 30, 2024, 10:03 p.m. UTC | #2
On 30.08.2024 13:17:24, Jakub Kicinski wrote:
> On Thu, 29 Aug 2024 21:20:46 +0200 Marc Kleine-Budde wrote:
> > +	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
> > +		dma_set_mask_and_coherent(&pcie->pci->dev, DMA_BIT_MASK(64));
> 
> This IS_ENABLED() is quite unusual. The driver just advertises its
> capability of using 64 addressing. If the platform doesn't support
> 64b DMA addressing and therefore dma_addr_t is narrower, everything
> will still work. I could be wrong, but that's how I understand it.

Ditch this PR.

I have sent out a new PR without this patch; however, it contains an
additional patch that has since arrived.

regards,
Marc
diff mbox series

Patch

diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c
index a60d9efd5f8d..99fad592965a 100644
--- a/drivers/net/can/kvaser_pciefd.c
+++ b/drivers/net/can/kvaser_pciefd.c
@@ -1104,6 +1104,10 @@  static int kvaser_pciefd_setup_dma(struct kvaser_pciefd *pcie)
 
 	/* Disable the DMA */
 	iowrite32(0, KVASER_PCIEFD_SRB_ADDR(pcie) + KVASER_PCIEFD_SRB_CTRL_REG);
+
+	if (IS_ENABLED(CONFIG_ARCH_DMA_ADDR_T_64BIT))
+		dma_set_mask_and_coherent(&pcie->pci->dev, DMA_BIT_MASK(64));
+
 	for (i = 0; i < KVASER_PCIEFD_DMA_COUNT; i++) {
 		pcie->dma_data[i] = dmam_alloc_coherent(&pcie->pci->dev,
 							KVASER_PCIEFD_DMA_SIZE,