Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2559854rdb; Mon, 5 Feb 2024 10:06:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IFWBT052TnkCM4OxFK4ppa6g/zlv8DvIwJwJohAdL7WvYSln1WT+Zenc7BJihp9KFLc48XX X-Received: by 2002:a17:903:58d:b0:1d9:e2b:dba7 with SMTP id jv13-20020a170903058d00b001d90e2bdba7mr259104plb.5.1707156400853; Mon, 05 Feb 2024 10:06:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707156400; cv=pass; d=google.com; s=arc-20160816; b=t8v2KHcNxSVNTtGJ1nEik0qO+6WwpRV3cto4U49cUN1XK7SI0BLTuEWw2DVzRIokym 5oqD1/68kKnRrwqYMB2jLa2vaL78YH/XqipQwQ4KFwcUTmlkk+hQGrdqxPrYB9Y8jTFz zEPF4Y9PeRBhGvBfvWXknCsYM0iF0A41mgYhESiQPhq9NFkoYsAxN0uJl6Z/jMAfDTN4 qw/A3AuEgxTLid7e140NemL7YghZWVQtCv28p1touD+vV+f/9DZqMk1MVUiLvhMwsmPG X9f2rswX6JDALOsV5jlpkTyHbpJ4I1aUmRilw9zES9XLxXXn4TSw1y1N5HBZoHtw3uZd 6tcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=/mNbcI6o4a/zp5QixP/Sm798c5qJ/hSdvywAmnaenBk=; fh=aYQ2RcbQzLyWXMtr7EsX5L947V+/kToiNOFGhnDDPbY=; b=R9kpF0d7SqDdrccF7STHoajhQOXMXf+xStku/JqLAEw9GXkh6vVDib4ZX/QtbxVbS6 cPIjoaSa0WCR+gchYbbluQ4cRAwJ8lcUTUfU8Pu3CeMismKcmJPs2c/q28Tducjxlhx3 jUiTxCjDf2kG7IryPK6A1o1h4F/XG2XqNeS3nccZxzNNvMq4WoZqaMoR0iSMfsoM872V 9tDFVWOoTalW2j0YBhmmMABII4JUaX4hX4UKRI52hi5I6O3m9FTeaYTCMHLJ4+7guH2M TIOXQzuOuHXB44pX9Oj5pC5XfVQI8WskgyqhxLRP2iE5UtdJsE0Dh3v1RWjpA3ZMYexI mrOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-53158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCWdEATLtecj3t0Izal4AbFdm/RJhyPy9XyRY97PT7Hr2u6IkW3ErjU3MCpYNiuUq6JbNRCYAWLvmDSY4Y3BMeC2MPLCJwvBLXbRhJwWAg== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h9-20020a170902f2c900b001d9b09f23e5si176549plc.540.2024.02.05.10.06.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Feb 2024 10:06:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-53158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-53158-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-53158-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8DEA6B22225 for ; Mon, 5 Feb 2024 17:55:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09B2845952; Mon, 5 Feb 2024 17:55:17 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 138AD45BF8; Mon, 5 Feb 2024 17:55:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707155716; cv=none; b=XbXNJISwqB8Bsi6EnEvVBb95w4Qyl4UyhTuk+Wg4LRYZTqVg4GBUvr+7HmMq8hhvvaaDOwtZf7FjX6rEWzmOgzYumXwDLra95Xo0gxUEQlJ7vvCOJqJJ3Fi6SNw9w+l2CdEtMAHUUxPb0Knr47A3c9YUcXgJyaE8CDLbLNj5zGE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707155716; c=relaxed/simple; bh=eESW3XSM+ZIUv4q6feb/lSGwXUw4fd1vqphbOEDleeU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ICRaZN9dEU3Rww+vyRseuCRujW3RzmSeUaKR8KJurxoVBEVjB/X4iy2XRf+6RkqSdnib1H9X/w2btzPpEVQ1yRsLwE14n+JaYnDOx5kvFFyoQtucz/Ji9v/6aLgv9Da3XldUrzyEk4pQGS3rPldepC76O4HB2/6eV6DDOZYsm34= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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,