From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB093C48292 for ; Mon, 5 Feb 2024 18:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FMERbTnL1AVULruuA7J8QhNeDtb2FkBFJSkK5pfWA1M=; b=oVrj0y+L9L20h+ +kBRnhRJJoMilAdNGGd2b7TZNf2+VFacm9kr3BQwbBcv8fazQQmFyIdryiiwdRL+NiMz0MGlb8O/j Rb9iNEseyvMRCO9WJCl2j7H1pvNL01WOkA2V4bxH1ojRTkZ2MF4zEAq43pRwCHYMxDpiCzAqx9Pt9 jWH26mZQZfmRedqnHwaTQrWaXnW9gamQHC70iO6onBDXke9/80z285HI/A8wP1qcPnfCGGbUxw5LO SiMkqDoVf8ZLdCm35Sc6vfXNZ0A7tvvKp8ftkKBPfU/GTUwt8r85RNB76xrzrTRroW8+7asIAAJXv c15hS57IjarYULLRrqsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3K6-00000004IbV-3BHc; Mon, 05 Feb 2024 18:04:02 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3K3-00000004Ib3-2S6N; Mon, 05 Feb 2024 18:04:01 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1D0E212FC; Mon, 5 Feb 2024 10:04:39 -0800 (PST) Received: from [10.57.48.140] (unknown [10.57.48.140]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 651753F5A1; Mon, 5 Feb 2024 10:03:54 -0800 (PST) Message-ID: Date: Mon, 5 Feb 2024 18:03:53 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 05/12] bcm2835-dma: Derive slave DMA addresses correctly Content-Language: en-GB To: Andrea della Porta , Vinod Koul , Florian Fainelli , Ray Jui , Scott Branden , Broadcom internal kernel review list , dmaengine@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, "iommu@lists.linux.dev" Cc: Maxime Ripard , Dom Cobley , Phil Elwell References: <30da53ebdf43b712da790fd2ae0f0040f71762b8.1706948717.git.andrea.porta@suse.com> From: Robin Murphy In-Reply-To: <30da53ebdf43b712da790fd2ae0f0040f71762b8.1706948717.git.andrea.porta@suse.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_100359_765629_153131CE X-CRM114-Status: GOOD ( 22.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2024-02-04 6:59 am, Andrea della Porta wrote: > From: Phil Elwell > > Slave addresses for DMA are meant to be supplied as physical addresses > (contrary to what struct snd_dmaengine_dai_dma_data does). It is up to > the DMA controller driver to perform the translation based on its own > view of the world, as described in Device Tree. > > Now that the Pi Device Trees have the correct peripheral mappings, > replace the hacky address munging with phys_to_dma(). > > Signed-off-by: Phil Elwell > --- > drivers/dma/bcm2835-dma.c | 23 +++++------------------ > 1 file changed, 5 insertions(+), 18 deletions(-) > > diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c > index 237dcdb8d726..077812eda609 100644 > --- a/drivers/dma/bcm2835-dma.c > +++ b/drivers/dma/bcm2835-dma.c > @@ -18,6 +18,7 @@ > * Copyright 2012 Marvell International Ltd. > */ > #include > +#include Please read the comment at the top of that file; this driver is definitely not a DMA API implementation, and should not be including it. > #include > #include > #include > @@ -980,22 +981,12 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( > if (direction == DMA_DEV_TO_MEM) { > if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) > return NULL; > - src = c->cfg.src_addr; > - /* > - * One would think it ought to be possible to get the physical > - * to dma address mapping information from the dma-ranges DT > - * property, but I've not found a way yet that doesn't involve > - * open-coding the whole thing. > - */ > - if (c->is_40bit_channel) > - src |= 0x400000000ull; > + src = phys_to_dma(chan->device->dev, c->cfg.src_addr); FWIW I'd argue that abusing DMA API internals like this is even more hacky than bypassing it entirely. The appropriate public API for setting up the device end of a transfer is dma_map_resource(). Now, it *is* the case currently that the dma-direct implementation of that does not take dma_range_map into account, but that's already an open question: https://lore.kernel.org/linux-iommu/20220610080802.11147-1-Sergey.Semin@baikalelectronics.ru/ Thanks, Robin. > info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; > } else { > if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) > return NULL; > - dst = c->cfg.dst_addr; > - if (c->is_40bit_channel) > - dst |= 0x400000000ull; > + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr); > info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; > } > > @@ -1064,17 +1055,13 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( > if (direction == DMA_DEV_TO_MEM) { > if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) > return NULL; > - src = c->cfg.src_addr; > - if (c->is_40bit_channel) > - src |= 0x400000000ull; > + src = phys_to_dma(chan->device->dev, c->cfg.src_addr); > dst = buf_addr; > info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; > } else { > if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) > return NULL; > - dst = c->cfg.dst_addr; > - if (c->is_40bit_channel) > - dst |= 0x400000000ull; > + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr); > src = buf_addr; > info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel