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 06DF7C4828D for ; Mon, 5 Feb 2024 17:55:30 +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=nBQ2ynI7IZOn2BCB23xahDjGaCJ5bf9lL+Jqxu95pAQ=; b=Pkqq4HkpxlU/qa jMtmKIligDv6t4DLk7o/zWqxrzUEdZ6+shJsOXv64zLe8U9mxf7DFZvsuwOymZfr8T/pdQRQA1Os+ W4XZCMPwxYKMKO7+1R+QE18s8f3h0VWp0Y2No3pDgGl0JCPhjDWsXEMus5cLyPNuN0swgmBChJfxE TMCnzDs0JLSD03y1ogebZv8cs90/4r84joQD7f1t9LUBzq9oigA2nA67+MwVvu0Q2nX66vqkpnFyv tkhddcMX3MYGHO9AgL0uLwUX7sGK0es4vxKCSFJH/r+JJW65o2lCoN7ixin3qSN9FdlMv8/xlsD3l sPoCiQw0BUFtXvXsaBgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rX3Be-00000004G5f-4165; Mon, 05 Feb 2024 17:55:18 +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 1rX3Bc-00000004G57-04RO; Mon, 05 Feb 2024 17:55:17 +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 ADC1612FC; Mon, 5 Feb 2024 09:55:50 -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 25BB73F5A1; Mon, 5 Feb 2024 09:55:06 -0800 (PST) Message-ID: <1e71c153-e482-409c-b229-9b9c0662b67e@arm.com> Date: Mon, 5 Feb 2024 17:55:03 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 04/12] bcm2835-dma: Advertise the full DMA range 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 Cc: Maxime Ripard , Dom Cobley , Phil Elwell References: From: Robin Murphy In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_095516_192569_8C5BA54D X-CRM114-Status: GOOD ( 19.67 ) 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 > > Unless the DMA mask is set wider than 32 bits, DMA mapping will use a > bounce buffer. > > Signed-off-by: Phil Elwell > --- > drivers/dma/bcm2835-dma.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c > index 36bad198b655..237dcdb8d726 100644 > --- a/drivers/dma/bcm2835-dma.c > +++ b/drivers/dma/bcm2835-dma.c > @@ -39,6 +39,7 @@ > #define BCM2711_DMA_MEMCPY_CHAN 14 > > struct bcm2835_dma_cfg_data { > + u64 dma_mask; > u32 chan_40bit_mask; > }; > > @@ -308,10 +309,12 @@ DEFINE_SPINLOCK(memcpy_lock); > > static const struct bcm2835_dma_cfg_data bcm2835_dma_cfg = { > .chan_40bit_mask = 0, > + .dma_mask = DMA_BIT_MASK(32), > }; > > static const struct bcm2835_dma_cfg_data bcm2711_dma_cfg = { > .chan_40bit_mask = BIT(11) | BIT(12) | BIT(13) | BIT(14), > + .dma_mask = DMA_BIT_MASK(36), > }; > > static inline size_t bcm2835_dma_max_frame_length(struct bcm2835_chan *c) > @@ -1263,6 +1266,8 @@ static struct dma_chan *bcm2835_dma_xlate(struct of_phandle_args *spec, > > static int bcm2835_dma_probe(struct platform_device *pdev) > { > + const struct bcm2835_dma_cfg_data *cfg_data; > + const struct of_device_id *of_id; > struct bcm2835_dmadev *od; > struct resource *res; > void __iomem *base; > @@ -1272,13 +1277,20 @@ static int bcm2835_dma_probe(struct platform_device *pdev) > int irq_flags; > uint32_t chans_available; > char chan_name[BCM2835_DMA_CHAN_NAME_SIZE]; > - const struct of_device_id *of_id; > int chan_count, chan_start, chan_end; > > + of_id = of_match_node(bcm2835_dma_of_match, pdev->dev.of_node); > + if (!of_id) { > + dev_err(&pdev->dev, "Failed to match compatible string\n"); > + return -EINVAL; > + } > + > + cfg_data = of_id->data; We've had of_device_get_match_data() for nearly 9 years now, and even a generic device_get_match_data() for 6 ;) > + > if (!pdev->dev.dma_mask) > pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; [ Passing nit: that also really shouldn't be there, especially since cdfee5623290 ] > > - rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); > + rc = dma_set_mask_and_coherent(&pdev->dev, cfg_data->dma_mask); Wait, does chan_40bit_mask mean that you still have some channels which *can't* address this full mask? If so this can't work properly. You may well need to redesign a bit further to have a separate DMA device for each channel such they can each have different masks. Thanks, Robin. > if (rc) { > dev_err(&pdev->dev, "Unable to set DMA mask\n"); > return rc; > @@ -1342,7 +1354,7 @@ static int bcm2835_dma_probe(struct platform_device *pdev) > return -EINVAL; > } > > - od->cfg_data = of_id->data; > + od->cfg_data = cfg_data; > > /* Request DMA channel mask from device tree */ > if (of_property_read_u32(pdev->dev.of_node, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel