From patchwork Fri May 24 18:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673518 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 369D0C25B74 for ; Fri, 24 May 2024 18:28:26 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3EStZKw/X5OLHoKIdW5p+tj1pWe59SQXWaUZEYTexoI=; b=Wo6wMggN8Iz+5y d3RJpQBTe0+25nwqyDRkL4IyaY/0WimmiVUTeFsYqy4VHBTAIKpnSiEPDrr4EoYHoMy6dWs1mxzMU uo6Tobwt6/T3Q8Uk0StWI9wTA4DWDC2Buiaadqg45hZzAehclIYSF1xPwHrVSso1M2TbLHnfC8F4N NPUY1rF82Q/7CUAi3d2LOfh7CejpiImTvu8yjwvBzQQIRqf7l27eqE5iBBQB8U6xTpDPWAOK9aEy/ C/RLLcV+Wzih4f4iIUuCkc14sKfDi6OxZUpSf+jfpgSxS4SyWRE3msEYC6VUFVcIwNoBEGGeXxg15 0NkMNgZu9YbZUlU2WIIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeK-00000009ZPC-47Or; Fri, 24 May 2024 18:28:16 +0000 Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8D-38p6 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:02 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-42108822e3cso6206465e9.0 for ; Fri, 24 May 2024 11:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575272; x=1717180072; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BSFDj4ol3AWAL0GeTo1h24EE4RwMrFwKLsNkcBtWgJ8=; b=sthwL8uHA+dzoKf7NdMDz6nOarg0v70HHu/NH4bWNCK0FiWMFzF6YMDk6xbj1huhNF qYR7UfxtpOaYXQKho9gCM/YyvaSKimcuT5A/q7vcAFtQubuZqFafuE5jOoPN+g29klAL so6Z9coNxOvYHfuKn1kzHEFe1uI7w6PgfRGZa2SLzt4iR2Vqzd2DcC22Lgn4UCBteg31 W+BZ5xscJ2CFztu6gAZSxq4nr+y7/TNuQ5HZgxBDUAJ7Bjq2pZJQ7koELOCUQYivlX41 mjXb6kKTsLkmqyXnNxBY/LqYeDOmOZraE+sXM5C1uY3PTIa1yXY7z6ON3vrqgYvKDRjJ M5yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575272; x=1717180072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BSFDj4ol3AWAL0GeTo1h24EE4RwMrFwKLsNkcBtWgJ8=; b=UlM3dXbDaExuOPll/tXaeSqhkW4JdQJMI17HSHEVuj1gZwc6uO6Mc3hyGK3w3eNUdu 4b0lbNU1Hjtt+qQR1CY0bq/aU971PhP2CoxJlEHPDR95CScTfN1eiw3PxXjy54U9kmPC cSexjzgYV6T9PjVQcW8Tdh6ts9VJ33f8jDhif2fKlHKaE2C6R6kdy/HxviF+g2JNB0qA Y+oulvmaqfjYo5pOajq8No/pdCZEpsPSpxu8HvlnQgGOpxeuSI3Tal70IL8R1dbR4V6w Re3a4WvmmH4uVg3OB1GCT1FfLFaoaIyHE2fIm3bwd67rKjS18mUKwUfof+4wS7sRfJ8f Zl/w== X-Forwarded-Encrypted: i=1; AJvYcCWd3rU6FWChXCFIsD3c/4/4hnsXOh/+lyOJaSOk7Anjhtr8FaYBxQTPii0V8W2wNaX8WykMZ34C31jKRw0mQPdb1BsPE3R9IDUt/44VYJ1sMXNY/7Q= X-Gm-Message-State: AOJu0YyQ4Vi8lCDxz8rOSQPll08YGFqlEm9ZS02sYlHj/KL43hBixNtY rTMHTtq7Yl02lKrNEYJHHhXZn5NXScAnQjfLIw0zfdgeMS8iObK7hH/lHXwW7yz+bdAyOMZ5hSr EOXQXuQhKUTl5SVgF0FP8CoYazJLQgsBB X-Google-Smtp-Source: AGHT+IGoEzQFTvVJkKaznbn3tsRrsBHXrR2xRBfQSwJwq8OyKLj9sbB3e3hIegjaXdW0XFK+xVpzR1K4PrIS X-Received: by 2002:a05:600c:4695:b0:41a:4623:7ee9 with SMTP id 5b1f17b1804b1-421015b3ccemr57035725e9.10.1716575271904; Fri, 24 May 2024 11:27:51 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-4210890571asm1226495e9.7.2024.05.24.11.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:51 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 01/18] dma-direct: take dma-ranges/offsets into account in resource mapping Date: Fri, 24 May 2024 19:26:45 +0100 Message-Id: <20240524182702.1317935-2-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_045408_FA899464 X-CRM114-Status: GOOD ( 15.94 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Serge Semin A basic device-specific linear memory mapping was introduced back in commit ("dma: Take into account dma_pfn_offset") as a single-valued offset preserved in the device.dma_pfn_offset field, which was initialized for instance by means of the "dma-ranges" DT property. Afterwards the functionality was extended to support more than one device-specific region defined in the device.dma_range_map list of maps. But all of these improvements concerned a single pointer, page or sg DMA-mapping methods, while the system resource mapping function turned to miss the corresponding modification. Thus the dma_direct_map_resource() method now just casts the CPU physical address to the device DMA address with no dma-ranges-based mapping taking into account, which is obviously wrong. Let's fix it by using the phys_to_dma_direct() method to get the device-specific bus address from the passed memory resource for the case of the directly mapped DMA. Fixes: 25f1e1887088 ("dma: Take into account dma_pfn_offset") Signed-off-by: Serge Semin Signed-off-by: Dave Stevenson --- kernel/dma/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 4d543b1e9d57..916a16959575 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -509,7 +509,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr, size_t size, enum dma_data_direction dir, unsigned long attrs) { - dma_addr_t dma_addr = paddr; + dma_addr_t dma_addr = phys_to_dma_direct(dev, paddr); if (unlikely(!dma_capable(dev, dma_addr, size, false))) { dev_err_once(dev, From patchwork Fri May 24 18:26:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673521 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 E75BEC25B74 for ; Fri, 24 May 2024 18:29:07 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=f36s8HBEIsijXmQQmkAh5+FAvfP4LnpAy5PohhkQHSI=; b=gbKTdakxZKLNmv wTaN5qI0TYKeReB0hXSLk4qGaZho2OywVUejz6Tvd+ilZ0TuZtLMmb1i2bT6HBYSuD3blomvPRb4o Ttk4WlVn6Rx7IpOo91VUA8l1CSAlF8xeJVp684bRtHf6SCvU/yhuNsKrzoBkb/5rtuuuLmyVyhjzX xNGo41+t80NqQVAP/MES/xocSnZOGvzOcad9WB6aF9DvGJHBaFtKuuZFmw2DCN2usK62A4kY0U4w1 CYdepu/HqLbsfbhC6IBsVv73BJcde3wzb3UrMITv4/Xcvf8j/j3w7SNfXjzGA3PnOLKADe9YWke9r 1mqtysFBGggJi/TyAIug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZf0-00000009Zsq-1ChH; Fri, 24 May 2024 18:28:58 +0000 Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8J-38s5 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:06 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-4200ee47de7so68153495e9.2 for ; Fri, 24 May 2024 11:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575272; x=1717180072; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MmjLsXIH2Amncxc11ehW4fWxMk13TiDZ+O44YXe6Wgk=; b=GNgjj6VUAJ2I+m/ojttT/z3nOv+A2OhL2C813lC99HdjRP7yXkD/nMNnrJFsucs+sP SyRbAcBw3w6UZGF6uS/D/Ph/OFZ/74uBqUE7sAgeCUPcqOEJXOkj8vKOoGbgmMvoekFQ vkKsd9LxBpieM/2QpJmQH0j2mfS2m22KuC3SgEhAvRCaxjGez8K5/fSk1MS7oDzdpiwL EgTd05SEyx70fxS0nW1EHpdaTdk/dPp9nSlzFJ9bUY9ilWBuO752WwFc8Evr4LLC7Dwb BMtETMIzy93mKupFYKGrzBiHdDz+WTKdKPxz6Vs73x4z2G9o270o63RmYRzppZpT+P85 q1ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575272; x=1717180072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MmjLsXIH2Amncxc11ehW4fWxMk13TiDZ+O44YXe6Wgk=; b=oMJLpOZEhSfTULsMS/pVSC1m/FeQ5MgKLW9qPXBerCCGKOI/TzqA3qoSqJ2ftryHTY s9S2nVDQzCDDTZNUxuz6sBrxtlYi9GR48txE1Hh5Bx3oc2luNmHJstvUQ7TzrSFY+NYZ sh2sfDr19w0WyBmW37nTHctf073qe1lmE+v+V/U8smKlFw6mdAKTbJVU8DLf1zS9SYcc v2VRLHKnOjbEjscULjurAJhr2Qiiwd1usjb7jif6C17kACPiwXTNfIptGI1AGhPqXt1L ukIc6g9zw5DZDHio5wcReWSoBiK3z77b8SoqTB/9O1MnlbsC5a3bJxZDYHl60dpzPpcN Olbg== X-Forwarded-Encrypted: i=1; AJvYcCWdA77ODnfLIN1fYLfmmevfzH1sxKgIHVHNvm5/WiVuBNop5HvHQaxjAIAQ8gFRyIa0pcGs8KPCLznk1TCxSUSYXim7nI5J1cljhEiK8Yp50kJOzyY= X-Gm-Message-State: AOJu0YzZz+k/RDp+7g9ba7eu80VSDE3JhTKKrUpbPDXjYgUYJ871+dR1 mZzA9uZhXiWInWbXjJpL5zUnN67kobGFR7T7hmBkwdCnZAyvaZZRgX8f72+f+Kd1KNi2ciNvLh6 nbYhcPiDZJaFRlSCZgsg00jzvgVT3Me8v X-Google-Smtp-Source: AGHT+IGfOa5XBgeYIs/cH5TAMCHbRBfIruDizHffdZ+UPyoZ3jK796PR+KziATsAgtd+BnPEgr+Se5nRlYpt X-Received: by 2002:a05:600c:3114:b0:420:2cbe:7ee8 with SMTP id 5b1f17b1804b1-421089f1394mr28435685e9.6.1716575272442; Fri, 24 May 2024 11:27:52 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-3557a1cd354sm56646f8f.101.2024.05.24.11.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:52 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 02/18] dmaengine: bcm2835: Support common dma-channel-mask Date: Fri, 24 May 2024 19:26:46 +0100 Message-Id: <20240524182702.1317935-3-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112803_927607_0C144DF3 X-CRM114-Status: GOOD ( 16.41 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren Nowadays there is a generic property for dma-channel-mask in the DMA controller binding. So prefer this one instead of the old vendor specific one. Print a warning in case the old one is used. Btw use the result of of_property_read_u32() as return code in error case. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 9d74fe97452e..528c4593b45a 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -941,12 +941,19 @@ static int bcm2835_dma_probe(struct platform_device *pdev) } /* Request DMA channel mask from device tree */ - if (of_property_read_u32(pdev->dev.of_node, - "brcm,dma-channel-mask", - &chans_available)) { - dev_err(&pdev->dev, "Failed to get channel mask\n"); - rc = -EINVAL; - goto err_no_dma; + rc = of_property_read_u32(pdev->dev.of_node, "dma-channel-mask", + &chans_available); + + if (rc) { + /* Try deprecated property */ + if (of_property_read_u32(pdev->dev.of_node, + "brcm,dma-channel-mask", + &chans_available)) { + dev_err(&pdev->dev, "Failed to get channel mask\n"); + goto err_no_dma; + } + + dev_warn(&pdev->dev, "brcm,dma-channel-mask deprecated - please update DT\n"); } /* get irqs for each channel that we support */ From patchwork Fri May 24 18:26:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673516 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 75B57C25B74 for ; Fri, 24 May 2024 18:28:23 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F8rJZ1OVM3PPKqIHSXwJLjybinAsJ2KQdHEmM2bCGHs=; b=VjBdiIQ4EeEPc4 6mXvNOibib9tA2BfITDoOS4hCn2lh4HyIsCbIxqqMTeQLFWiUOUMN1MGqVHQ0hR0ea/2ec5h45iOq mCmRcLIZY8zkfe9OFrjbiVpNJAug2cr8KaecT7Ef+u1XWqjo1F8p/oRkKUPvQqGdJLQvbU5CGYtRo 9SWG8VqUut76cuURyuoLOBw75RCtoIexpgsByV2WK7xIWZPUIE8GWoO3UVvquEpvBCySWXXNaLQ4G NS0l6zkPfp0ZGIArDu6vag/NQm1+k/lyJOMaUTTQbp6VHL+9priEvhfhty//7QTBhUfu7qK4Qh/Uk CmYqFX1XloOQH1g7M5Nw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe6-00000009ZCv-3QSX; Fri, 24 May 2024 18:28:02 +0000 Received: from mail-wm1-x361.google.com ([2a00:1450:4864:20::361]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8L-30DF for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:00 +0000 Received: by mail-wm1-x361.google.com with SMTP id 5b1f17b1804b1-420180b58c5so32160285e9.3 for ; Fri, 24 May 2024 11:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575273; x=1717180073; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2MV7QZf2fhH+OEhBA38QGxT92fUaASU1Nxo1nxUSVd8=; b=Gcypq2bpnAwT4uVuYZaQqtcdxGQS6CYaiveRuwT77jK0vIg5JuClYknUiryODWyWts iAIiwe7jeXbVL3RpzzBY0gK6q4l7uGpD7/TxlMtwK9s9td3/RozwHRdfV5LOMlNHFDkD SVOP/tE++EE6VFaMSxYDBfNV9IepyNzTUZ22EG6Vgto5xiuTM4jDNVED3asU2rA73r69 5NVmDYQhUdVLS1XS9EHFPBfjmXmLgfwHPLhLYINDf7daccuhzYnDjhX1ZhWgkzmAUdM7 /c/ap525+9EraPY16d2jh/w449rNREMJ1URGO5mUXfiHr4qLjo200UYElDSHvuWFGmCB oOHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575273; x=1717180073; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2MV7QZf2fhH+OEhBA38QGxT92fUaASU1Nxo1nxUSVd8=; b=nKEFfnbe3/nmRIJIuevVYq9nPXywEzFaN1I72V5EWrGq4K3XrnwYjcA6Ekan6S+ub1 hhSTouYGy5yg+LrULmnlvn9xqZptKYtP/TYeR0usVXBulf7zLUrZ4v2z1Uiq68iKrqGC 0/w/+4adE3CHgqbkzma0vFyQgelAmyx9rnV0hpDAMdiYABnL7uLNgdRAe/olp/woV5/p jzC9o2DESu+PzP0aFhBPUpRPQ/pGm1x+oIUKlBuvDmyEhkelbxpPz2yhncSiKgkJ46wA FVzHs+wlseC+QUC/YXaDWD743VCOmviRsTdgqvXxlQvC/GLDcXZhIg9L/drYlu/T74M+ 5Qig== X-Forwarded-Encrypted: i=1; AJvYcCXPPivl875c0feyQUCkBR9U0raD9qZyb1fYdtpxah9W8/WOjO3E3nRgrdYdTdOhbigUtj6pNJJ7OVZQf0Xz38I7r6A2t7OxTWOqflnme15uT9EarGs= X-Gm-Message-State: AOJu0YxJIDOi6aG0OQynYDYfrhzGiPorLSjXWxIkOQJl1XyPIdTiq8Jk p5LeqmZ7BX5+nlTswRiaZjXxICrEQXL2TtrN/nud432ON4EUz4L7B4iaxMe7HDlyP+dpX0B6yRl U0mnfxPgdSn3g1uxSw7EbVEbZftxZIyqF X-Google-Smtp-Source: AGHT+IHWZ0JTRBQwe/XochchvTJaAoc7r7/ijNNUJ35CDCjZA7ALjlPQSMAk7tENe+DW/f85sGYNAcbTrrfr X-Received: by 2002:a05:600c:5799:b0:41b:f2ca:19cc with SMTP id 5b1f17b1804b1-421089f93b7mr26088945e9.34.1716575272958; Fri, 24 May 2024 11:27:52 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-4210891c6edsm1217615e9.20.2024.05.24.11.27.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:52 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 03/18] ARM: dts: bcm283x: Update to use dma-channel-mask Date: Fri, 24 May 2024 19:26:47 +0100 Message-Id: <20240524182702.1317935-4-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_044977_306A7EA0 X-CRM114-Status: GOOD ( 14.73 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now the driver looks for the common dma-channel-mask property rather than the vendor-specific brcm,dma-channel-mask, update the dt files to follow suit. Signed-off-by: Dave Stevenson Acked-by: Florian Fainelli --- arch/arm/boot/dts/broadcom/bcm2711.dtsi | 2 +- arch/arm/boot/dts/broadcom/bcm2835-common.dtsi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi index e4e42af21ef3..d64bf098b697 100644 --- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi @@ -103,7 +103,7 @@ dma: dma-controller@7e007000 { "dma9", "dma10"; #dma-cells = <1>; - brcm,dma-channel-mask = <0x07f5>; + dma-channel-mask = <0x07f5>; }; pm: watchdog@7e100000 { diff --git a/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi b/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi index 9261b67dbee1..3ba8db8eed0f 100644 --- a/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2835-common.dtsi @@ -46,7 +46,7 @@ dma: dma-controller@7e007000 { "dma14", "dma-shared-all"; #dma-cells = <1>; - brcm,dma-channel-mask = <0x7f35>; + dma-channel-mask = <0x7f35>; }; intc: interrupt-controller@7e00b200 { From patchwork Fri May 24 18:26:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673519 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 AB9F1C25B7D for ; Fri, 24 May 2024 18:28:28 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=6sWX9gpDdUK0D+mjJg/WpbL/lAd/1vaL3ZpK2bpLeQc=; b=titz0VbJvLHRuI yVtL12ajhSNth3ssyJAzcPIpRr7iqmqGumW33ac5wJ71ks/1x6oyeAUF5ff5MBqVj/VDmtvErHIzX iRQWCQFUxUmbktAtICW5WoNK0hfcBVWWzcEe1tRQ2eRw+pS66tpktsFcgMmx6frNdGdiVVHVazQ8E +p9J3vG4hx2yCUGQgHYeKRU6BXu3omXwIRoL7DkKi3XJCSH3i91gE8Hg/ujRFRI2UNUlhrb0SzGJ4 0J/oq9s1UV0haXGD6vEY7EH6HvOwiZmpbLT/ps85aKkfzb6LCd5P7LLi8qMuZkkmRJgNB4UNQW60A n1iwULEPMaIIKP3ttk8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeJ-00000009ZOV-3gsO; Fri, 24 May 2024 18:28:15 +0000 Received: from mail-wm1-x361.google.com ([2a00:1450:4864:20::361]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8P-3440 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:01 +0000 Received: by mail-wm1-x361.google.com with SMTP id 5b1f17b1804b1-4200ee78f34so32624885e9.3 for ; Fri, 24 May 2024 11:27:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575273; x=1717180073; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TKd9X1LOVt1ChaX4vRXT/Yfb21vDTf36hviq/MF6+cg=; b=Wo47nshlTkznIu8lrMDh+8rF0YLZ+2+4mTVytqotAk2gvAK2sxB5PYmOYSyi4lNF/C dx9bmRUepfuHfTnzm0cTndT0IVTxyUCo3zO8RjxlJJi1OJqMNSbV9/MER7KP/o3GKRxh 3MbU6YCcXnDEYh2K+KddFaIA1uEJ9JngV1RejFq4mme9IAxQv2FcllLJ6fIVJQ+ptMcu 3yWbx36d1xPZfuxqzb1fmJtoNQgb9CRSAnzDAqlRX6b3hAzONFrh4IKSzy0By7vxYpyQ sGHm9dnLyEPyF+JR45+VbfBFppO0dXogtOgMGXJBpbMBLuShaJxOtFi+PFMgk3X/fDkM ituw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575273; x=1717180073; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TKd9X1LOVt1ChaX4vRXT/Yfb21vDTf36hviq/MF6+cg=; b=wU17lHXYLnFcC9f0u/gIXYOJIcUQ9OpUj2W5DNBy0UErrgz+16NtmJ2AhnJqVr80I9 /+6C5U4ALziHc33AgotZaH6uoS2aLIaI+ipG6Mo5dU3520cDDvWc3Ipo4oJVR3c/EjLT JrQ3IOZflmbItAzJudBRWRNJ92nlAnQ6mG5K0MRwuqw7AdCuqvnGKXKjio7avBtHxjm7 Q3am7as4zjK9B0vEN2PbFFX20qGOOjE9hOTLWFtuaxc+kG8DgXzUe94uXlPUlgIKzgfE lmiXeTd2W5ky3fIncK8UbMdfqwbeA61W2VLU4sIke8D78VilgM9thW4RXqBsCuYcmi6o Vj3w== X-Forwarded-Encrypted: i=1; AJvYcCXjdaNQMV6Wa4+N7f6LAWcY9Ai/28NPNspSAb5NgNc8K34mDC3IgnGBobo4X/GOXMWyb0TFRz6FmgZO2gsg3670EPtEsLq37QqG/d33vxYjelcPU2A= X-Gm-Message-State: AOJu0YzjsUNZNjXI0yXX3naWp0h9624bFxaB8psF18FP2781T/RmuiNz qPgYy2wVbdk43vZUXNpy931n6TRQ75pi8DZX52EpnPgwKhoYH1D4lDskEQguK9N5iVcoa7YqFgc 44OlVIHkgzsGpge//MbBnykGJ7R5wBfFV X-Google-Smtp-Source: AGHT+IE1vodFu4VYv4ismPyHD4+ricu2iZqmWOTNKtTorabHI/piuhSxGYfbWmThDOKYJ4k1kIH/5D1hvWp9 X-Received: by 2002:a7b:c305:0:b0:41c:2313:d966 with SMTP id 5b1f17b1804b1-421089d3943mr28029795e9.1.1716575273524; Fri, 24 May 2024 11:27:53 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fb4c8fsm5347505e9.49.2024.05.24.11.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:53 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 04/18] dmaengine: bcm2835: move CB info generation into separate function Date: Fri, 24 May 2024 19:26:48 +0100 Message-Id: <20240524182702.1317935-5-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_005716_D310465E X-CRM114-Status: GOOD ( 17.53 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren Actually the generation of the Control Block info follows some simple rules. So handle this with a separate function to avoid open coding for every DMA operation. Another advantage is that we can easier introduce other platforms with different info bits. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 50 +++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 528c4593b45a..7cef7ff89575 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -201,6 +201,34 @@ static inline struct bcm2835_desc *to_bcm2835_dma_desc( return container_of(t, struct bcm2835_desc, vd.tx); } +static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool zero_page) +{ + u32 result; + + if (direction == DMA_MEM_TO_MEM) + return BCM2835_DMA_D_INC | BCM2835_DMA_S_INC; + + result = BCM2835_DMA_WAIT_RESP; + + /* Setup DREQ channel */ + if (c->dreq != 0) + result |= BCM2835_DMA_PER_MAP(c->dreq); + + if (direction == DMA_DEV_TO_MEM) { + result |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC; + } else { + result |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; + + /* non-lite channels can write zeroes w/o accessing memory */ + if (zero_page && !c->is_lite_channel) + result |= BCM2835_DMA_S_IGNORE; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -615,7 +643,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; - u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC; + u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -646,7 +674,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = BCM2835_DMA_WAIT_RESP; + u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); u32 extra = BCM2835_DMA_INT_EN; size_t frames; @@ -656,19 +684,14 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( return NULL; } - if (c->dreq != 0) - info |= BCM2835_DMA_PER_MAP(c->dreq); - if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; src = c->cfg.src_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; - info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; } /* count frames in sg list */ @@ -698,7 +721,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = BCM2835_DMA_WAIT_RESP; + u32 info = bcm2835_dma_prepare_cb_info(c, direction, + buf_addr == od->zero_page); u32 extra = 0; size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -729,26 +753,16 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( "%s: buffer_length (%zd) is not a multiple of period_len (%zd)\n", __func__, buf_len, period_len); - /* Setup DREQ channel */ - if (c->dreq != 0) - info |= BCM2835_DMA_PER_MAP(c->dreq); - if (direction == DMA_DEV_TO_MEM) { if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) return NULL; src = 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; src = buf_addr; - info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC; - - /* non-lite channels can write zeroes w/o accessing memory */ - if (buf_addr == od->zero_page && !c->is_lite_channel) - info |= BCM2835_DMA_S_IGNORE; } /* calculate number of frames */ From patchwork Fri May 24 18:26:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673532 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 D35BAC25B79 for ; Fri, 24 May 2024 18:30:42 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=uavjb5KmyXJ/361zZoVk9DhM3qrkxPefb+RkdzVrRd0=; b=dUtuJAN4t5uWY1 PwsUiES4flMYVNESjQXsuyrsrT+bvw4J9WYt1o+2/A0ZehcKA+qs625T/lQ1ot2aV9SasLaK+/wfO MFTrJqctUO2r1TcVIoQ3y57x/xsV0NHtkyRzJSZgmE/0vpGlQWHxfUer8/D4Qq3CF1kdvBm2Xn76h oJQjLANDqmALj0dyDGiL7DkHGUcs1lp6Wrueh7b+5cpD+MhQj5aBTd03YPBNeo9AX09xDQBsK+vh9 DCVPbT4qOPZFFxFAjdkP/eGr3Ul5PWF5UYbYv0lCBt38mVS732fx1bXRvZXAfDHauTQvy8GM8rjbZ B8JP1XjtihPF0C5pGIRQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgU-00000009at5-19rU; Fri, 24 May 2024 18:30:30 +0000 Received: from mail-wm1-x363.google.com ([2a00:1450:4864:20::363]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8T-39lx for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:09 +0000 Received: by mail-wm1-x363.google.com with SMTP id 5b1f17b1804b1-420180b5897so31804645e9.3 for ; Fri, 24 May 2024 11:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575274; x=1717180074; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iWDOi4FnuIg8+afcsNOQvw2Jh+B2uESuovEt5c+znUw=; b=oCCz9dJTHdxAWu1OiE+zHYd8/RLy1KzDf3/y/S594gYFKcwzy8eL0aHPoDgwUFSY+I RZUJNnWTB3Ucb59Ef5uT5TPO5lRgaqhE1rzAiSZbxww/H2AwZHOL9p3vWYNwcLEHzq1U L0RxTMx+FPj6k60AyAoOifAevBDAJXW6VxYhMvR9GxsGxtv6Z87oqlikkerxmdZ4H6h8 zBVd6YZN/QFpWR8nrQphicK4KEYmUaB0zixQa6iL7voR8LMlc2qBsnj/MUTDkD5mU7Pe Y2B49g90nyhSSNsfeDTSMZ+mmQTaKVfvsHamgvrH/ld69XFm9aiaRqhkFKn5rm2lN3UW sHww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575274; x=1717180074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iWDOi4FnuIg8+afcsNOQvw2Jh+B2uESuovEt5c+znUw=; b=MQKnNp7FPsiaLpGPSIwT9sG5JIHSaepgUAr0rkvCJtxhTJvY6iHQo3hrtDcm2Xp3GP dOPEuNBv5NzOqGkQXZQjI89iM3lF2Vmc9JTGsDMgbXFa9GrL9OF5THNSzlAuJZ7SH7wx JWvj4UgbUmh1h9hJH0v0/yvt4wEGtJVijbubXB+4mj38BPF91w5t1p7sbCs8r91bVMHX Svj4a/Zg5g7jsKl2VmnPBE1U0/O7eGifw0MIe484dLNENp40WUp/x4rdNv0AHtzPYL8H BtHQojIw7sWux+S1wIu5Y/2PrRzA9mVu7Bqkt0MC22acQbWYTRgd80R7MRE7VgBbZUa9 ckYA== X-Forwarded-Encrypted: i=1; AJvYcCXomWKo99c0tuqgeOB03tVs7hh49WVfvuPSJdvD23NQj5QT0R1DBfvdceaXNrCKn+lqqkcaTs9UFcYSTaZqPlyWmtt8UvYVZR9/W1ANAgq5MepDEds= X-Gm-Message-State: AOJu0YyQKtzQ8T9V4mrfstV8lcgNjuG8xNQBMZDgTMbEnc1DxjVz4iN0 7lQ/e37YoGasvUtk/d/pBN5Reb/0RM8HDHxIdcvGSSsju/BQyP/04ckM+R4KuWlNo8kRACnY06c C0HXIuZdUKtDjnzSPQZYLRW18AUd8m78+ X-Google-Smtp-Source: AGHT+IGIsyeooWRqeftH29E3jxJT2At/nTJ1Uu/BdgAMBJJVRNDQOp3tq7uahyaHfy6aSgJSk6q/Wsrk7a1Y X-Received: by 2002:a05:600c:314c:b0:41c:5eb:4f8f with SMTP id 5b1f17b1804b1-421089d7c33mr24729315e9.15.1716575273960; Fri, 24 May 2024 11:27:53 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100eeb86fsm5721785e9.4.2024.05.24.11.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:53 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 05/18] dmaengine: bcm2835: move CB final extra info generation into function Date: Fri, 24 May 2024 19:26:49 +0100 Message-Id: <20240524182702.1317935-6-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112804_090811_A75D7A52 X-CRM114-Status: GOOD ( 16.37 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren Similar to the info generation, generate the final extra info with a separate function. This is necessary to introduce other platforms with different info bits. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 7cef7ff89575..ef452ebb3c15 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -229,6 +229,29 @@ static u32 bcm2835_dma_prepare_cb_info(struct bcm2835_chan *c, return result; } +static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, + enum dma_transfer_direction direction, + bool cyclic, bool final, + unsigned long flags) +{ + u32 result = 0; + + if (cyclic) { + if (flags & DMA_PREP_INTERRUPT) + result |= BCM2835_DMA_INT_EN; + } else { + if (!final) + return 0; + + result |= BCM2835_DMA_INT_EN; + + if (direction == DMA_MEM_TO_MEM) + result |= BCM2835_DMA_WAIT_RESP; + } + + return result; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -644,7 +667,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); - u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP; + u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false, + true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -675,7 +699,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); - u32 extra = BCM2835_DMA_INT_EN; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -723,7 +747,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( dma_addr_t src, dst; u32 info = bcm2835_dma_prepare_cb_info(c, direction, buf_addr == od->zero_page); - u32 extra = 0; + u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -739,9 +763,7 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( return NULL; } - if (flags & DMA_PREP_INTERRUPT) - extra |= BCM2835_DMA_INT_EN; - else + if (!(flags & DMA_PREP_INTERRUPT)) period_len = buf_len; /* From patchwork Fri May 24 18:26:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673528 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 B11B0C25B74 for ; Fri, 24 May 2024 18:30:34 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DtSJwB+o3IrlWmOUlv3jlWEYTojij8PyYwa/0EUp6MM=; b=fq1c+o4ydJvPar ZKbmrtIWm8DaFJZHhJz15b/2CsyDvwxs/9pMlqM26FG9dj39Wa6NW7V3a+hi0U/7sMX/iGSbYrX3m FgT8fPK5NjtVBkTiBY5804QZGXcexOsktyh9hPnt5zsL+/27Tq1ryuN0ootv0+wZj8vPGPU4J9fOG T3JN4ia8SWaoIhIBo5emROEmoud5EdSI/BznNVuHP3absGS9tv4gnOVgr6v/XhRmKQX29u23nTV36 iaQSBFu8s9bIUVwDVWd74AOJiErys5pGKF5mTTUJ71y0m+4OKsKPnLxplemcqZcSeiprg9C0QOuZs NPszYSM7KEuQs+myL11A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgO-00000009apA-39ur; Fri, 24 May 2024 18:30:25 +0000 Received: from mail-wr1-x461.google.com ([2a00:1450:4864:20::461]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8V-393W for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:04 +0000 Received: by mail-wr1-x461.google.com with SMTP id ffacd0b85a97d-35507fc2600so1076457f8f.0 for ; Fri, 24 May 2024 11:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575274; x=1717180074; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2dAf5h5XwHiWp+dmoS6JsUC+O9MVsTne143uCle/zUc=; b=ZaMBgqYECL3PX8hdKw9RaxFPiwzRNHtOab4H2Jq9KRW63Kn5Tkf+Z2SIprSF0B2tIO H8h3LBZ0FZCawHKZ41t1zU6yGkLk7q63+GNezrq/CmKL0JV87jUvLUDC3Bnlg81ZqV2D 3S6wazEDxLhH2+IMJ02PCqRbzItI0dYyIywnhkEP9Ms1y5L6L4oqlefF21jtP00exQJ0 5DYjytHBf3rYTD4N9daeVfwF1AUmAA3bbmRugb6HZBTj39vjNKqmivWD4sSyrh5iY5ph PAhpvGQTp+o8G0gJ3cYGvZoV/QbTCEmHsZMyAJx1OIBby2QN2DYon1tUmViX/pxxKNk+ 27eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575274; x=1717180074; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2dAf5h5XwHiWp+dmoS6JsUC+O9MVsTne143uCle/zUc=; b=bz3yq76Gce3H1hEyxFGjXZaUw843FWCSNPyl+z6uA6CpEDw4mE/vMeb2B6CRrHdtrd Zoyhq+Yb5skawQz86XrxAPKYlAAsZzt0BfmKPOd9vnMibd45+GUl9NG8CQg/w6Eutyb3 ngjN1TAxRNhPzOOfHvQd0LNuYUQB5QizBXTweEFCVMtzF95XhiM+LNpRJq52+iIoCQK+ yg6M2R+s8daXYAnxUdNXCmPykJFscouIIxaF1IgIIluSKELgOCiPeEG8hR82XW2qKUbK jALSAqyY3RjLJ1o/EwEp84LNnynqGFg27NgtOUH1ziDFDY/OmjiX/n6E8WCQpllrjKE6 Avtg== X-Forwarded-Encrypted: i=1; AJvYcCWNLyqAX5d5GFfuZfedfGshZH4+7aBtb6aBkLHWnLQPErPpdxKuypiRXiTx/n7iTrKH0AB4+f3P1DnwXr6ygdtYw6liJZIT0OpZuZm4Dd+1RpsEkEE= X-Gm-Message-State: AOJu0Yxk0dBpFxcC3+dOel7aCKYENjF72/XLNn5mj4SR6c/RWuYRXj9O BbY1p+wRp6BSSp5t+kfDw7cfhtitOtLgj/8l1M7Lh1IcTipnfUAq1eiubzt8bGhqM0Ajbp9wpWB ElspDyoh803LhvMgR7R4ZxvK9fLdf5kqs X-Google-Smtp-Source: AGHT+IG7AwSKXGWwm3Jk0PS/jS/c6HEpbiqG3nmvQrlTW240Q10yveOxPP4at4VICqmuogqReFECxtmY3Gqc X-Received: by 2002:adf:f746:0:b0:34d:bab1:26eb with SMTP id ffacd0b85a97d-3552fe17476mr2052052f8f.68.1716575274538; Fri, 24 May 2024 11:27:54 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-35579d7c6bfsm65665f8f.22.2024.05.24.11.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:54 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 06/18] dmaengine: bcm2835: make address increment platform independent Date: Fri, 24 May 2024 19:26:50 +0100 Message-Id: <20240524182702.1317935-7-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_130398_308EDB0C X-CRM114-Status: GOOD ( 17.13 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren Actually the criteria to increment source & destination address doesn't based on platform specific bits. It's just the DMA transfer direction which is translated into the info bits. So introduce two new helper functions and get the rid of these platform specifics. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index ef452ebb3c15..d6c5a2762a46 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -252,6 +252,24 @@ static u32 bcm2835_dma_prepare_cb_extra(struct bcm2835_chan *c, return result; } +static inline bool need_src_incr(enum dma_transfer_direction direction) +{ + return direction != DMA_DEV_TO_MEM; +} + +static inline bool need_dst_incr(enum dma_transfer_direction direction) +{ + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + return true; + default: + break; + } + + return false; +} + static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) { size_t i; @@ -336,10 +354,8 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @cyclic: it is a cyclic transfer * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate - * @src: the src address to assign (if the S_INC bit is set - * in @info, then it gets incremented) - * @dst: the dst address to assign (if the D_INC bit is set - * in @info, then it gets incremented) + * @src: the src address to assign + * @dst: the dst address to assign * @buf_len: the full buffer length (may also be 0) * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer @@ -408,9 +424,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->cb_list[frame - 1].cb->next = cb_entry->paddr; /* update src and dst and length */ - if (src && (info & BCM2835_DMA_S_INC)) + if (src && need_src_incr(direction)) src += control_block->length; - if (dst && (info & BCM2835_DMA_D_INC)) + if (dst && need_dst_incr(direction)) dst += control_block->length; /* Length of total transfer */ From patchwork Fri May 24 18:26:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673530 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 50224C25B74 for ; Fri, 24 May 2024 18:30:38 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XOretuaqtN3tZVYgYXi7GfrVDRORLxo6uP3wjVVrBUM=; b=F7XiL2uPQw1XpJ TeOewhIzQuVA/0FPxLjqlibvZKFaDo3pfUW6cXVsCPqekvZX5pjl340hJhE6SJFEkxt8NhtkrL+uL 5GpI/KVSEPQtlaBK36GeRw8CK3W8TXBX0aEUQ+i99WinPm3AV0lA8aqMk1ZuDycYKfQzPEszxrjAZ skh95nCbh5hp7B2jaU/+3ZqOfk3+JQSdqdcyHhsC/flIQz1gypRitOElyyhe8g+20sZgoayGZU/kZ LGDVkfdGFW0Eax9kzBCZLY+vWtOqNfTWCIgv+iy/U3QYi7aVN3n5UZQCVVlSCl2CUTA85qbde7XB5 nBCjbnysDQOC3NZXkfKQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgQ-00000009aqC-2WTt; Fri, 24 May 2024 18:30:26 +0000 Received: from mail-wm1-x362.google.com ([2a00:1450:4864:20::362]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8X-37JR for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:04 +0000 Received: by mail-wm1-x362.google.com with SMTP id 5b1f17b1804b1-4202ca70318so64599675e9.1 for ; Fri, 24 May 2024 11:27:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=94Kgj4XNRFYduQRTRfIrQIcXqS9keoQhSCwvILhnmSs=; b=oJ9aTaKwVRJR+JL/pEB6ZDEwXq3Bqq7oRLAKSwqp5kUJ8NQ6rHuqL2plgOS4JvfCSr XEsrmo6r5kWfepXD3dprm6tO1hM0lqI4qmV3qSAphMPW0tm/L+1BRiJ54iwTVv9oKJCK iXT2dUUV5qlPJeQFe0uD+nX8XTWuKKQsW0kVcDUr0O7ipmof3CJ9jV/QcqR3uuNzgxzS ZLO3iBtZ6VsYKfQYlayssxq+QVqrjgIsUejxB3NhClFFsxqWhnTnc0J4cpn3YSyxUJ8X 1XeZxU9xa3D21q8zY6afPN178/NxKsq23KbtiQ2Yt17qtxmA8XAFgoh6yRuUTmS+Rnza XZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575275; x=1717180075; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=94Kgj4XNRFYduQRTRfIrQIcXqS9keoQhSCwvILhnmSs=; b=DyO9wyC7Y8QbwSUFSFWfv3uUxpeo96NkK5d+wwI9Q4vqwTm/6EVjZ/uGOEkPz07EsV /ZPZEWDUkC7jprv2K8rJqiekFAoql00ri7lgLKsHObfyZz4PDaIERQJA0PH+fkmYwHfr UIqnMLEl97KzUrxKO2VXvuCSmP1mlwIkHVmJBKzchZHMDXilWpoePrLL9BqnBDmHZpXO D/RAv+w14wEyt8XDXFCGQTvUgg4HfGp5GLO7qL73qwBgIbW0JUi0kAMpRRNoFoumamq3 8B4s3LgWV0VHuI5Je8nSUH3P9b/FuDaQ5khZKOQBUnIH/xQh2ozIafOWpcBIqXpenDkp hwUw== X-Forwarded-Encrypted: i=1; AJvYcCVl8TRorpX6nIXw5HLdGee76qvPuV4fu9J996XEmt2dAVWPkatVZM6bijbj0dvjB2DDCSvwl/MZuAhR/jaIxF6bRrSSqkkwcFrLhHcUu1Y0tQqs9n4= X-Gm-Message-State: AOJu0YyKjZzgCQqaEzGYm0gu33OmigvBazszQJWqG4h+P7GuQLzjyf36 6RF+rtqlro4oOUWz4xMwwWCYSmZVMtROu3bd5AEXe/tdkAdRlzgpUuziAccjBJW0zBLX320TdfK MDQM9e8N9U2tBVib5bHniYmlagozeetU7 X-Google-Smtp-Source: AGHT+IGesJtEvV+unRtxxlqVpvfAyXBqt4L3VhNP7OXMl0+5bcpxZXNW6Yligrt0JA2P+vgera6GBoU5TmNu X-Received: by 2002:a05:6000:248:b0:34d:b605:ec68 with SMTP id ffacd0b85a97d-35526c37d2emr2209418f8f.17.1716575275087; Fri, 24 May 2024 11:27:55 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-35579d7beacsm64758f8f.21.2024.05.24.11.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:55 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 07/18] dmaengine: bcm2385: drop info parameters Date: Fri, 24 May 2024 19:26:51 +0100 Message-Id: <20240524182702.1317935-8-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_083880_443BC5C8 X-CRM114-Status: GOOD ( 24.19 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren The parameters info and finalextrainfo are platform specific. So drop them by generating them within bcm2835_dma_create_cb_chain(). Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 83 +++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 43 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index d6c5a2762a46..e2f9c8692e6b 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -287,13 +287,11 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) container_of(vd, struct bcm2835_desc, vd)); } -static void bcm2835_dma_create_cb_set_length( - struct bcm2835_chan *chan, - struct bcm2835_dma_cb *control_block, - size_t len, - size_t period_len, - size_t *total_len, - u32 finalextrainfo) +static bool +bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, + struct bcm2835_dma_cb *control_block, + size_t len, size_t period_len, + size_t *total_len) { size_t max_len = bcm2835_dma_max_frame_length(chan); @@ -302,7 +300,7 @@ static void bcm2835_dma_create_cb_set_length( /* finished if we have no period_length */ if (!period_len) - return; + return false; /* * period_len means: that we need to generate @@ -316,7 +314,7 @@ static void bcm2835_dma_create_cb_set_length( if (*total_len + control_block->length < period_len) { /* update number of bytes in this period so far */ *total_len += control_block->length; - return; + return false; } /* calculate the length that remains to reach period_length */ @@ -325,8 +323,7 @@ static void bcm2835_dma_create_cb_set_length( /* reset total_length for next period */ *total_len = 0; - /* add extrainfo bits in info */ - control_block->info |= finalextrainfo; + return true; } static inline size_t bcm2835_dma_count_frames_for_sg( @@ -352,7 +349,6 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @chan: the @dma_chan for which we run this * @direction: the direction in which we transfer * @cyclic: it is a cyclic transfer - * @info: the default info bits to apply per controlblock * @frames: number of controlblocks to allocate * @src: the src address to assign * @dst: the dst address to assign @@ -360,22 +356,24 @@ static inline size_t bcm2835_dma_count_frames_for_sg( * @period_len: the period length when to apply @finalextrainfo * in addition to the last transfer * this will also break some control-blocks early - * @finalextrainfo: additional bits in last controlblock - * (or when period_len is reached in case of cyclic) * @gfp: the GFP flag to use for allocation + * @flags */ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( struct dma_chan *chan, enum dma_transfer_direction direction, - bool cyclic, u32 info, u32 finalextrainfo, size_t frames, - dma_addr_t src, dma_addr_t dst, size_t buf_len, - size_t period_len, gfp_t gfp) + bool cyclic, size_t frames, dma_addr_t src, dma_addr_t dst, + size_t buf_len, size_t period_len, gfp_t gfp, unsigned long flags) { + struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); size_t len = buf_len, total_len; size_t frame; struct bcm2835_desc *d; struct bcm2835_cb_entry *cb_entry; struct bcm2835_dma_cb *control_block; + u32 extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, + false, flags); + bool zero_page = false; if (!frames) return NULL; @@ -389,6 +387,14 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( d->dir = direction; d->cyclic = cyclic; + switch (direction) { + case DMA_MEM_TO_MEM: + case DMA_DEV_TO_MEM: + break; + default: + zero_page = src == od->zero_page; + } + /* * Iterate over all frames, create a control block * for each frame and link them together. @@ -402,7 +408,8 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* fill in the control block */ control_block = cb_entry->cb; - control_block->info = info; + control_block->info = bcm2835_dma_prepare_cb_info(c, direction, + zero_page); control_block->src = src; control_block->dst = dst; control_block->stride = 0; @@ -410,10 +417,12 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ - bcm2835_dma_create_cb_set_length( - c, control_block, - len, period_len, &total_len, - cyclic ? finalextrainfo : 0); + if (bcm2835_dma_create_cb_set_length(c, control_block, + len, period_len, + &total_len)) { + /* add extrainfo bits in info */ + control_block->info |= extrainfo; + } /* calculate new remaining length */ len -= control_block->length; @@ -434,7 +443,9 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( } /* the last frame requires extra flags */ - d->cb_list[d->frames - 1].cb->info |= finalextrainfo; + extrainfo = bcm2835_dma_prepare_cb_extra(c, direction, cyclic, true, + flags); + d->cb_list[d->frames - 1].cb->info |= extrainfo; /* detect a size missmatch */ if (buf_len && (d->size != buf_len)) @@ -682,9 +693,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( { struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; - u32 info = bcm2835_dma_prepare_cb_info(c, DMA_MEM_TO_MEM, false); - u32 extra = bcm2835_dma_prepare_cb_extra(c, DMA_MEM_TO_MEM, false, - true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -696,9 +704,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy( frames = bcm2835_dma_frames_for_length(len, max_len); /* allocate the CB chain - this also fills in the pointers */ - d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, - info, extra, frames, - src, dst, len, 0, GFP_KERNEL); + d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false, frames, + src, dst, len, 0, GFP_KERNEL, 0); if (!d) return NULL; @@ -714,8 +721,6 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src = 0, dst = 0; - u32 info = bcm2835_dma_prepare_cb_info(c, direction, false); - u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, false, true, 0); size_t frames; if (!is_slave_direction(direction)) { @@ -738,10 +743,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg( frames = bcm2835_dma_count_frames_for_sg(c, sgl, sg_len); /* allocate the CB chain */ - d = bcm2835_dma_create_cb_chain(chan, direction, false, - info, extra, - frames, src, dst, 0, 0, - GFP_NOWAIT); + d = bcm2835_dma_create_cb_chain(chan, direction, false, frames, src, + dst, 0, 0, GFP_NOWAIT, 0); if (!d) return NULL; @@ -757,13 +760,9 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( size_t period_len, enum dma_transfer_direction direction, unsigned long flags) { - struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; dma_addr_t src, dst; - u32 info = bcm2835_dma_prepare_cb_info(c, direction, - buf_addr == od->zero_page); - u32 extra = bcm2835_dma_prepare_cb_extra(c, direction, true, true, 0); size_t max_len = bcm2835_dma_max_frame_length(c); size_t frames; @@ -814,10 +813,8 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( * note that we need to use GFP_NOWAIT, as the ALSA i2s dmaengine * implementation calls prep_dma_cyclic with interrupts disabled. */ - d = bcm2835_dma_create_cb_chain(chan, direction, true, - info, extra, - frames, src, dst, buf_len, - period_len, GFP_NOWAIT); + d = bcm2835_dma_create_cb_chain(chan, direction, true, frames, src, dst, + buf_len, period_len, GFP_NOWAIT, flags); if (!d) return NULL; From patchwork Fri May 24 18:26:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673523 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 E0BECC41513 for ; Fri, 24 May 2024 18:29:28 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=eDDwS7j/E9qR5DC0pvfSgQvdRgqc49YmZGcR6i0Vork=; b=M0XoHz7LhpD7t4 loDUdbwziP/CTN6AkYVf9MerW5FRsvmVkrilenVvYwBl5E2vbhWsJJ/0fi0jN7gge5Q5Hj4ei21sJ /vMMy/Mtjja0oErPwTO201xa4nZJF0h8t4m7IgTP1t0W32bWwAtrVDLLl7ZwZYmZ5qN4Th0AVVq6P iWc9rKnHEcrjGzpTJgPQ8y0hIRspJx2dRsWt1o8ZIfF1mUGOg+goG+8HEfOYjNXJF/cwzDUl8N0nQ GweVIJp62Q8HRA1q6ddwa2RkzSSk0H9J6AmumitSHJZ9RO7vhVBwtBLbElB8xjvPvB9E6ZLOio0Zp DoZSgFyZeoStLLh2Omcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfJ-00000009a6K-2MRs; Fri, 24 May 2024 18:29:17 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeC-00000009ZI5-2LEe for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=IdpIFvpAOe+p4DJCyeDBQ+tGYJ 9nnqYyJBkThvMlEbNHhx63ocUpozZlMmEZI3qdpCX1kB2iQJgUOu3SVriZ1yqYOM2s+JqIsOsZsLv z6p/HpT0TGbvHm677wMAMt0FC8ioJag5570NLS+dHjowX1DYwi3tng4A1bgsPPlUw4hDeqq5oPf63 fjy3yx+Izl9Nze0C2rzcw0H9/f+Y4BSw22wTGXgxtCJ3WcCD4tdvWQjy6UbOdIMuVQVV8oh2+bDvZ MLqfUZ9oaD6Yg8EFW6zxiTGqeQvq3kevTYafNWegUjWjRh1HTf5xcy2/jXrMJpLHE6vdEpbESBKmn h5b8I8ng==; Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJ3-1OIH for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:06 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-4202ca70270so41001845e9.3 for ; Fri, 24 May 2024 11:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=fvKyswU+mMFqUAXu1VsSR4Oc0GMywL16RQqAK3WFeZLDFktBWdAgZI893dBBVJnTk5 8Gu4H9E+Ik2pCWszxM8PgYJx6BSp3xUQsYgmMoCV/CaNsNS0lH5R4Xgj0TDHdgqQ/41W wsMHgI0igcYr0hDGOwVO2aedgQ2imfKWMCa4SbS+eUdHwMeDdbrbween5Drs6spHplbm M6y1LfxzE66n9YLyglX27VxKjIXSw098CdEHfXKgMs20KFe/0RfOKDzGWcg9J3SicfeQ 98tccb0t4dWAcVSZMVz7yX9ZkPDS582/eAw/S77l28m5KY49BOV51WTvaRfDDsAlB9RW bf7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575275; x=1717180075; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wA8wcVcwFLmtvy2VP3x9io/V3+kH7xE00SpBiNM4hDU=; b=kkd6q0m5blSE8g4DAmhhduItaFaBnyRMwSXLmUpp3rdxHeZiTKoUsyrvsM4R4e7L6T pTjdbGZ2xfcOjD9bBAL5Ldax69J287ELxaW/ilF+QTlLFhEFho6Leev7utLV6RzG2axZ 79s8BpX5UGoUHfubyuABl/zF9x3Dqm+ehE9N+lDGbxZJGlFdIsRHTyjPMKq0UkzIO5ga kGIpnhyMBEV8zmVnz7JmmtfcBhrEaZ4NJYaKlmt+n/IMirE/B3W/wY44+mQVb63UitVu GMatT7jc7PBMKYUwbOUiC8OrAvmXWsbFcsIuHPzRnUMe/TPVbRqPHMVyGMMpRCrcNdMC fJRg== X-Forwarded-Encrypted: i=1; AJvYcCWUz/EK+n0Eo4RWMMkB3HqxWlGwe7UTiZp6fu8saBGik5uWOLX9+CFd+EW/Bgxxct7mOHpk+M75u2yM3IJ8MY3L+TUrLfv8PzzMEUUISVOBiphV7RQ= X-Gm-Message-State: AOJu0YxV1tgq10Hx7GGoJfhAsfg8JumZp3Uh7f2cT2SXp2VUMQ+cKpsx Uy4urIdkf9qUAdpyWgTQQw1cmblnKz8bGBgqPLkHj8JC+hvxEfVDeBw4QLpDyC8Ud9/chC0k9rv 1AxSJQKUeLZj+cfY3FBisN8hIsIRGuOXE X-Google-Smtp-Source: AGHT+IFDaLmabHJHQMgitln4OpgM8BEx4a9yXpbL9c/m5s+ybK8fzjM7KEITDWBXUomFqJVUNhNO7yZURk4G X-Received: by 2002:a05:600c:5746:b0:420:29dd:84f8 with SMTP id 5b1f17b1804b1-42108a99ba4mr30406535e9.32.1716575275682; Fri, 24 May 2024 11:27:55 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42108905a6dsm1244535e9.9.2024.05.24.11.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:55 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Stefan Wahren , Dave Stevenson Subject: [PATCH 08/18] dmaengine: bcm2835: pass dma_chan to generic functions Date: Fri, 24 May 2024 19:26:52 +0100 Message-Id: <20240524182702.1317935-9-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_282275_B93DC220 X-CRM114-Status: GOOD ( 19.05 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Stefan Wahren In preparation to support more platforms pass the dma_chan to the generic functions. This provides access to the DMA device and possible platform specific data. Signed-off-by: Stefan Wahren Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index e2f9c8692e6b..aefaa1f01d7f 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -288,12 +288,13 @@ static void bcm2835_dma_desc_free(struct virt_dma_desc *vd) } static bool -bcm2835_dma_create_cb_set_length(struct bcm2835_chan *chan, +bcm2835_dma_create_cb_set_length(struct dma_chan *chan, struct bcm2835_dma_cb *control_block, size_t len, size_t period_len, size_t *total_len) { - size_t max_len = bcm2835_dma_max_frame_length(chan); + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); + size_t max_len = bcm2835_dma_max_frame_length(c); /* set the length taking lite-channel limitations into account */ control_block->length = min_t(u32, len, max_len); @@ -417,7 +418,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain( /* set up length in control_block if requested */ if (buf_len) { /* calculate length honoring period_length */ - if (bcm2835_dma_create_cb_set_length(c, control_block, + if (bcm2835_dma_create_cb_set_length(chan, control_block, len, period_len, &total_len)) { /* add extrainfo bits in info */ @@ -485,8 +486,9 @@ static void bcm2835_dma_fill_cb_chain_with_sg( } } -static void bcm2835_dma_abort(struct bcm2835_chan *c) +static void bcm2835_dma_abort(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); void __iomem *chan_base = c->chan_base; long int timeout = 10000; @@ -513,8 +515,9 @@ static void bcm2835_dma_abort(struct bcm2835_chan *c) writel(BCM2835_DMA_RESET, chan_base + BCM2835_DMA_CS); } -static void bcm2835_dma_start_desc(struct bcm2835_chan *c) +static void bcm2835_dma_start_desc(struct dma_chan *chan) { + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct virt_dma_desc *vd = vchan_next_desc(&c->vc); struct bcm2835_desc *d; @@ -533,7 +536,8 @@ static void bcm2835_dma_start_desc(struct bcm2835_chan *c) static irqreturn_t bcm2835_dma_callback(int irq, void *data) { - struct bcm2835_chan *c = data; + struct dma_chan *chan = data; + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_desc *d; unsigned long flags; @@ -566,7 +570,7 @@ static irqreturn_t bcm2835_dma_callback(int irq, void *data) vchan_cyclic_callback(&d->vd); } else if (!readl(c->chan_base + BCM2835_DMA_ADDR)) { vchan_cookie_complete(&c->desc->vd); - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); } } @@ -594,7 +598,7 @@ static int bcm2835_dma_alloc_chan_resources(struct dma_chan *chan) } return request_irq(c->irq_number, bcm2835_dma_callback, - c->irq_flags, "DMA IRQ", c); + c->irq_flags, "DMA IRQ", chan); } static void bcm2835_dma_free_chan_resources(struct dma_chan *chan) @@ -682,7 +686,7 @@ static void bcm2835_dma_issue_pending(struct dma_chan *chan) spin_lock_irqsave(&c->vc.lock, flags); if (vchan_issue_pending(&c->vc) && !c->desc) - bcm2835_dma_start_desc(c); + bcm2835_dma_start_desc(chan); spin_unlock_irqrestore(&c->vc.lock, flags); } @@ -846,7 +850,7 @@ static int bcm2835_dma_terminate_all(struct dma_chan *chan) if (c->desc) { vchan_terminate_vdesc(&c->desc->vd); c->desc = NULL; - bcm2835_dma_abort(c); + bcm2835_dma_abort(chan); } vchan_get_all_descriptors(&c->vc, &head); From patchwork Fri May 24 18:26:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673527 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 C4B5EC25B79 for ; Fri, 24 May 2024 18:30:12 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WPMboe5ZcoVa3r8YT8lXr2/g4id591dtGl/x/FLuzDE=; b=0XaFwhqOEvtr8T NP3FJlcsd68ygsYxG9uyLT5MMjUUsCsXC1aKqttzHXbuZOGPxtQSMnLD7cEGRa9vYQpK5iszOGCg6 rLIzjvF4bKGNRAtcRj5dWAorm6g4Q12ryVegqvV+hpwckpxgwJBxPN5DGa1EG/IzuZEpNNS195RgX /2AAa47G6Sz7QUYnRSbTgSELgvbLP02ZZSRrlxVDb+bK9hKgFvS5b8UerUJKjOiXsWXeoJZynzweh gV82Wbn1QHjO2tcX9PhYR+PbbsthbnpdSN+U0hpRww6UkGWNE8BKix1plvh2EaUWCPCsTh2S0okA5 JzpiYW4t1obKriLIiYYA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZg1-00000009aa5-14uM; Fri, 24 May 2024 18:30:01 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeF-00000009ZJp-0fvk for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=k5/0PmDw861toPHKUvcW29ls0QVOfTRw5AjJ+CnPD2s=; b=Phhl5jJbQLlwU9SOhH/jP5pc1J cwdf5Z82En0KqHLAPY8GmztmJQtSmZC87Uc+INDImxEKOs1PVNp+exbb+ONCd4iI+PXkP0r8CV46x ATzLciqbL/Q3zp34q0+BDScJaYWgnQ2S9LNo20grLQ+R7lN/Uwjis6rT+WsgMqLgGeKQPzstP0vs2 Me8v4vDLunSU2Tq+r9zv0uUftuckAgdw22GVT2r3qSuqBqRYKGhkv4UpRWXYqRjo2qtW6CkhrERPx FYPCRO9Jgfw1DzYGVuJ5IFLW65cdReUoG6NdExECrv84DjKgO7/ivruETE4PNhvkapr+v+TaC2BIw CeZCbsHQ==; Received: from mail-lj1-x263.google.com ([2a00:1450:4864:20::263]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJ6-2RuC for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:09 +0000 Received: by mail-lj1-x263.google.com with SMTP id 38308e7fff4ca-2e6f51f9de4so107026771fa.3 for ; Fri, 24 May 2024 11:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575277; x=1717180077; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k5/0PmDw861toPHKUvcW29ls0QVOfTRw5AjJ+CnPD2s=; b=Dh6NQKltq7FpXHQmBpFEyZXRgz5Yg6aTm8tvHIX+OaPu99iN4qMaixQ0T9h7eJRJvb 2p1T/F0mt0piHiaU+St7kDfQeopS5e/WdyXt7EqdjdVgJCWX4SlLJ7rUAUXfhKNV8TJC 2eLnZhzOvsAfyE2AFJhSEIkSZV8+44n6LOr0NQHuiL0L468fco6rikvS81SlvXh8ZZGt D+jOTOnNSqr/92doZkKgyWx65abTSzdYozv8/6JcEnU6fLS9L9kV6QNtPe/OBmSs7fzx XJj/KTiIpk3d53JHKNVD3qsFZeZx+3BHnF/8CDILmXWnqox8ec9N1jyT3UPAnuctttZP dnmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575277; x=1717180077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=k5/0PmDw861toPHKUvcW29ls0QVOfTRw5AjJ+CnPD2s=; b=SWrgG4wqv/Cg6sry2wWG7vz0fYGjRaV+YG4JgqfriMhJWqRk9jOzkdFIkAg184cmsH MkYaa1zd+XyJEgbcrdTaqIKfziHwHKFCoOmtVAkuxVRyqksh6ZjplzjKfkUa3LvV8MYf brVYnsQX5SBL46+loje+Z3qqod7Sl0zYxir+HxmJnAIFDzTn/rpvpfOiVzFC+QxZgxda 9aFT6siXYr0PU+r7TM6ppSHit2T7dLwfTR05R8CvuIORYL6JkxMwri5C7BBrChbVPhby TwGZLSSYWbS+Y79vuC0rsY606yH6JPP0h0wNrFGpVhIMQUgRJaRe3dcn95ncrQjD8o+G dgBg== X-Forwarded-Encrypted: i=1; AJvYcCXUXWIquPwcrFGqhIi3+niFjC0Qu2ZQL3Bujc9utodwDUnvPlq23wfdKHjPIyqByiU4/swos047PLEut2Jtft0tEFLR16uZ75fuJxHtb9BvFzVJ5i8= X-Gm-Message-State: AOJu0Yy6NsrIMO19blM5LXEctZnkwIowggkcu9YJnEA7mPbk5AzXL7dP ein3q2zbRxgQIz2pK51fYUbYziQvp9ZNPUieiTlfW4zXdLYsd042t4ZupkyAy3SpfrZCviG+Bu8 760ekfuzHoEaMTha7jKZirk692VK1k39W X-Google-Smtp-Source: AGHT+IEHAWM6BIO0Edq+CWHOn6Y+ZIrJttwNlxlncG6HGF/KksFdkfl8n2+vvBn5hfO9zRO5ovw/15yBiAgP X-Received: by 2002:a05:651c:4d4:b0:2e9:61c7:cad3 with SMTP id 38308e7fff4ca-2e961c7cceemr12892461fa.25.1716575276717; Fri, 24 May 2024 11:27:56 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 38308e7fff4ca-2e95bcedd3dsm330901fa.19.2024.05.24.11.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:56 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 09/18] dmaengine: bcm2835: Add function to handle DMA mapping Date: Fri, 24 May 2024 19:26:53 +0100 Message-Id: <20240524182702.1317935-10-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_726018_1BC74387 X-CRM114-Status: GOOD ( 16.57 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The code handling DMA mapping is currently incorrect and needs a sequence of fixups. Move the mapping out into a separate function and structure to allow for those fixes to be applied more cleanly. Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 46 ++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index aefaa1f01d7f..ef1d95bae84e 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -65,6 +65,10 @@ struct bcm2835_cb_entry { dma_addr_t paddr; }; +struct bcm2835_dma_chan_map { + dma_addr_t addr; +}; + struct bcm2835_chan { struct virt_dma_chan vc; @@ -74,6 +78,7 @@ struct bcm2835_chan { int ch; struct bcm2835_desc *desc; struct dma_pool *cb_pool; + struct bcm2835_dma_chan_map map; void __iomem *chan_base; int irq_number; @@ -268,6 +273,19 @@ static inline bool need_dst_incr(enum dma_transfer_direction direction) } return false; +}; + +static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, + phys_addr_t dev_addr, + size_t dev_size, + enum dma_data_direction dev_dir) +{ + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); + struct bcm2835_dma_chan_map *map = &c->map; + + map->addr = dev_addr; + + return 0; } static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) @@ -734,13 +752,19 @@ 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) + if (bcm2835_dma_map_slave_addr(chan, c->cfg.src_addr, + c->cfg.src_addr_width, + DMA_TO_DEVICE)) return NULL; - src = c->cfg.src_addr; + + src = c->map.addr; } else { - if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) + if (bcm2835_dma_map_slave_addr(chan, c->cfg.dst_addr, + c->cfg.dst_addr_width, + DMA_FROM_DEVICE)) return NULL; - dst = c->cfg.dst_addr; + + dst = c->map.addr; } /* count frames in sg list */ @@ -795,14 +819,20 @@ static struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_cyclic( __func__, buf_len, period_len); if (direction == DMA_DEV_TO_MEM) { - if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) + if (bcm2835_dma_map_slave_addr(chan, c->cfg.src_addr, + c->cfg.src_addr_width, + DMA_TO_DEVICE)) return NULL; - src = c->cfg.src_addr; + + src = c->map.addr; dst = buf_addr; } else { - if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) + if (bcm2835_dma_map_slave_addr(chan, c->cfg.dst_addr, + c->cfg.dst_addr_width, + DMA_FROM_DEVICE)) return NULL; - dst = c->cfg.dst_addr; + + dst = c->map.addr; src = buf_addr; } From patchwork Fri May 24 18:26:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673522 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 D3A04C25B79 for ; Fri, 24 May 2024 18:29:25 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dpa9yJWTxVv5drBlP/U6Vfj7NYXJOgdTDzNLSBVoWms=; b=Xh6RAIXySkU0Qd np+Q+s+bTLJr3tT/w/Xkpz1Fh2nm34PRNGzJLd67DSbCvhSiEaw4RDfJVGkXIajwRaa9pfcgbyC00 Gv3YxKqk8SDzCm4gNzKFAIKZKSElm7qB+CUGpZJgd9X7RaPX3eOjF1QWDu1tD3pVQmbXG4BS9oGsh ucrfCzMCSHs8WDxqDdKzZQgcM+lL09Vx2FoBidk+p8VvhpUaD9z6O92Smz3YRN2djb6kOj9xLVQ2w 6byGKb7oZgvwDjPD+7XXkEb6dZEHCvNEx1AyHi0ZaSWymSsk5KtXhdFDQuQ5OWCr6Kn1dq771USyw RiGnTcRB/wosBayT8mYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfH-00000009a5S-3zdX; Fri, 24 May 2024 18:29:15 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeB-00000009ZGt-1cqe for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FsDDNY/QwJvf47dmHC7PRu5uL7JEaRYA48sLf9OqOOY=; b=S9iU/4pN0QHG8g7goJqZxTQpYg gbKO35wKY3oMzZJWHw/pecpdLQu3gEmHBS1TRkUkkiDy9xO+xrme8TXTF0gLCUWFxsU6tu7vKj5dX 6xCtjIYpz1J64pk3tUjePwr0UYTUrBeppezW0XvWUjzMJuLgPtfMDjM5ElyxAU/3ZLDwHViZLJE5e g+W05aTmvNoik6zf6zTyyjWLqXeNG4EmW9lRC7ag7zfJoadRjhYyVRP1rIlQXgPkPOCNbN5oj1bir kWlilsPjKlmicYcJTurJgL8G9SFyZKYhsjJcxnIi4gtw2QSC73tCKBl90G18Br+z1H315MUiqoThF ecdu3QVA==; Received: from mail-wm1-x361.google.com ([2a00:1450:4864:20::361]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJ4-177u for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:05 +0000 Received: by mail-wm1-x361.google.com with SMTP id 5b1f17b1804b1-4200ee78e56so33901735e9.3 for ; Fri, 24 May 2024 11:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575277; x=1717180077; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FsDDNY/QwJvf47dmHC7PRu5uL7JEaRYA48sLf9OqOOY=; b=dNUqCJRxwTTjz4NoOMorUeQWAU39+pNW9fYsd2X6o7YkZx/9xDeTX/i6zF9eJOuD7Z 3uBHeulIMkR4d2bwTncD7qcDRNN2PwY8f4PMTRIduWh8a7XoXMygTWIZN+9LGrPNR5EX 8gwapH3rxSa5vP5s7GVCXBD8vNfSaNkYQVuimfD/Tek9HxkEXLU2Pegf9gGqg78RPpBB Oieoby+tWd41PzU9e8DfGstpt9NmPxAjb97wql0AUgjUcBGhxmJKffWbaf1gu97z8rLn 08BQObggMrPy5CHTr/xputymeh7YBZZye0j6R6rLnW195tZxMauNPb/5kn1Ns8VycziR d2Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575277; x=1717180077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FsDDNY/QwJvf47dmHC7PRu5uL7JEaRYA48sLf9OqOOY=; b=umeEbgPVhpAZdkA/Cd1op01pYBsXzRJZEr9LpMaCfguaFTQ6OI0rCEqjq1L8cEo0B5 4zbKMUHnDUqBBS1EcyCTlnxPcfsxhcoVHiIQZ4SyzgL0itBT+9o27gS6khTMBJuNNtYc rHg1gUDgn3/sG7H+j1NOwT2KBSDLqHyYcXmcuCZaQtjNzZvftDxPkYYXOzadh7HIbOlS b+MAvukXsSkvc5SVC+Gud4mdtbGm9n/tMQxzmaVytv/rn9dUtQzLytq9lOw+QEIfxjLP FMuLkjmvwKctqdH58IvSsQvGtj0P6ew8/qqNPtNyY8c9LiyiEaJp4V5RYFDU/gJCehCJ pMhw== X-Forwarded-Encrypted: i=1; AJvYcCWTFqxyNVzUdVigkJwLEBbJhUt3p9bAosdF94f06lKv0QNowSoGILA3EX8QYsY+HWdgZtfDpSysVUZAgUmVVvv0lfFgF14Gn4KA0MgEx3uARVRmlt0= X-Gm-Message-State: AOJu0YzlH2QZrK9yJbvlMhjwIJnOWt04ulK+XDP0jJxvh2QtDE7cFw/K BDAMiKs3/cUiL93KYx9LqeuqkuIzt0UvpELdB7Mmu/U8FINtKizO2+SNDXEpEdPKH87zEyDktbp HuAeuhEzWWTiFC1zyd5h6ARyBP8Qo+3fa X-Google-Smtp-Source: AGHT+IEXHyAwczg+VXo+M67fY0mVhzt5oPk36AjtQ9lYPMdZoLz7U9U+HdeHdCJz5d472HFdCSVQwmE4fQK0 X-Received: by 2002:a05:600c:3106:b0:420:29dd:84d5 with SMTP id 5b1f17b1804b1-421089ebf63mr23274805e9.5.1716575277312; Fri, 24 May 2024 11:27:57 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-4210a964067sm979275e9.31.2024.05.24.11.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:57 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 10/18] dmaengine: bcm2835: Add backwards compatible handling until clients updated Date: Fri, 24 May 2024 19:26:54 +0100 Message-Id: <20240524182702.1317935-11-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_031797_9A25A94C X-CRM114-Status: GOOD ( 15.93 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org bcm2835-dma has been (incorrectly) expecting dma addresses to be passed in, not CPU physical addresses. In order to fix this up, add temporary handling of clients still passing in dma addresses until they are fixed up. This will be reverted once all clients have been fixed. Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index ef1d95bae84e..9531c0b82071 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -283,9 +283,23 @@ static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_dma_chan_map *map = &c->map; - map->addr = dev_addr; + if ((dev_addr & 0xfe000000ULL) == 0x7e000000ULL) { + /* + * Address is already in the 0x7e... peripherals range. + * Assume this is an old client that hasn't been updated to + * correctly pass a cpu phys_addr to the DMA subsystem. + */ + map->addr = dev_addr; - return 0; + return 0; + } + + /* + * This path will be updated to handle new clients, but currently should + * never be used. + */ + + return -EINVAL; } static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) From patchwork Fri May 24 18:26:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673529 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 6B242C25B7D for ; Fri, 24 May 2024 18:30:38 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=YJq/uKbUmmumYZQ2gjMp24YcTFx9cpiDQROYfZM1SXE=; b=nXJhJ9rToKjGLe BqMa8BCwxhv5j8twLDGWzN+KYppPiYU3xFdsSzT49MysCU2cCTwfGxBYq9FfI7rVfrMb8hHlbj/PD ybZx0k2F9FYsl40A+io5Sp5u2mzDEuh+tVzgkrnUHL1kI6VCko76ahNsEJCP4copXZSJM/op1CzRC zZ2vwrAhXzMu4aietry3Rujb/VePJOZcakBVBTY1e2TiPwAhAzHDl2RXvb/qyltIpEkmm0HNUIg42 PWspOQNi2SbFeoBHET02XTvXG5Pakgos43PmCWqGTkF/yeqg792KffDiFg8JydjGiS+WiluiGtD4I vytqsjiCJH8OKjlOJ8rQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgS-00000009asI-3nWj; Fri, 24 May 2024 18:30:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeA-00000009ZGE-2jca for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=HLyqz2osfPGnGJK1wbt1y32SqdJNw076C0yH+gVvyYs=; b=TmyuTe1Cinn05t5nU4DT4sPk2S 6wEPkHcw5Sr0k9CtxWypsH06WocH9W65aEeLyfomaCZXot/tHd8+U5JMheQVALUj1/VTSE1+gPaUy jNWeHIcBERVmzb/rBCo635eqjLw08L4ixnpwtJR2driJKzMZtSN+St+Uy00zY+e5TSj5/f4KMHLzM HGYYQOFyIGFZKH1gg2/TmU+V5+hdVelkhsyMs3BwL6vdHr2JOrBpYvvEtq2FXm7LEALd+MtKhcng6 qy7f8XRxVxjMY8OF9GhTCArO09Ub9aIZ79wOkpyPexnjusfAlQzPFI/uk8h8fArPVEk0NMD9UZ6ai jfT4kI5g==; Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJ7-27pU for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:05 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-4200ee78f33so34494085e9.3 for ; Fri, 24 May 2024 11:27:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575277; x=1717180077; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HLyqz2osfPGnGJK1wbt1y32SqdJNw076C0yH+gVvyYs=; b=qyYN1goDv7jKegkg0BnX8ql9LAqx3KYkP3BW1FY18GgbcZs40rDOMxY0ywiPCHZG0r 6Pz5JLNV5bScuda1waoonH6SNGZ8Wt/NRnlwuaBbPgauWIDzFWeQrWt/zjvRDbkJ9j9v V8hr+ULrsy6hXBSOwbX2TTJ5Nzrl6fgNhvY1LXcLjmfIBq00ihXI1N4d0InmAxKQ1RFQ 0Ln5uSYxeT4QOhwrCK8o4NfP6LnyV3NoTuqBhnS0Y2iaz3OO8s59ztOhJPBowaO2Gnro bVoHTTYyaKzb+H+82PjeY9gkyn0SdneJ9xDDeq5BVxKOjBoEai67pnvpJP4gD5lsNpIK EP1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575277; x=1717180077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HLyqz2osfPGnGJK1wbt1y32SqdJNw076C0yH+gVvyYs=; b=aKbsx5NPlPLt+Yj1Zed6RDt6FvzKBBeyVNp0V+4IdGhqamKWHQBQCLXHRFhFo3AAml 1U/OyFgR7BH/JavZLkmwZU29R013bDZYO/VqVCzD9ZiLkW3UdpV6wYg9eXSddDLOMzXd 1y6bw22ZAXUtU/maKvAHFYla6+7VlYnBiqm4OdfaFao1iJM7nR+c8MZPbdS/Y8bZ04BF uRdZe4VcdHUlWwS81J47UJPFgtwWNqJjafS/KD+5+ioD699n50jd0Hj1KFmkgSG7c1JV 6XNASci56rzP7MpVi14Uo8TIflZou8j2AWKUq4SYKZtKv0/htotYwBWsDTH9XTzkBXE+ vnEA== X-Forwarded-Encrypted: i=1; AJvYcCX6J5taTrvPU9S4Z8BzWojEaL2w2x3CjzwAIwj8KI7rt43uH+SA7pvKo1PgqK76fPVNYIPQfdM0Pje0wtouYUxg887iPXOaaDB7bSIgraCCbjo5Klo= X-Gm-Message-State: AOJu0Yw0L0uTQh/mFJmIQNWe91FUCnc5+w25eYgE0+z0x7J9McJPKOk0 PBEY0TUmlscPv4uYnQo6Rwkq8Hbf7pYCuNdvvVrIJOjsijLIeZSjeg8En+OfoQ6vXfKqzn5z/pe V7DNG1fj0x3I0/pYESvQN5vjGx/N9s7J6 X-Google-Smtp-Source: AGHT+IHZyoYiw+ZfDDIW+lJcq4U5OZo2v43Ubu3YaXBugY/8GE8OzbxogUWp09sQZEXs2xF6wDmcdkXhQP7U X-Received: by 2002:a05:600c:548f:b0:418:c1a3:8521 with SMTP id 5b1f17b1804b1-42108aa8866mr22319455e9.26.1716575277729; Fri, 24 May 2024 11:27:57 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fa9be9sm5432805e9.40.2024.05.24.11.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:57 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 11/18] dmaengine: bcm2835: Use dma_map_resource to map addresses Date: Fri, 24 May 2024 19:26:55 +0100 Message-Id: <20240524182702.1317935-12-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_003700_08C6E5B4 X-CRM114-Status: GOOD ( 16.42 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is a need to account for dma-ranges and iommus in the dma mapping process, and the public API for handling that is dma_map_resource. Add support for mapping addresses to the DMA driver. Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 46 ++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 9531c0b82071..e48008b06716 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -67,6 +67,10 @@ struct bcm2835_cb_entry { struct bcm2835_dma_chan_map { dma_addr_t addr; + enum dma_data_direction dir; + + phys_addr_t slave_addr; + unsigned int xfer_size; }; struct bcm2835_chan { @@ -294,12 +298,44 @@ static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, return 0; } - /* - * This path will be updated to handle new clients, but currently should - * never be used. - */ + if (dev_size != DMA_SLAVE_BUSWIDTH_4_BYTES) + return -EIO; + + /* Reuse current map if possible. */ + if (dev_addr == map->slave_addr && + dev_size == map->xfer_size && + dev_dir == map->dir) + return 0; + + /* Remove old mapping if present. */ + if (map->xfer_size) { + dev_dbg(chan->device->dev, "chan: unmap %zx@%pap to %pad dir: %s\n", + dev_size, &dev_addr, &map->addr, + dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" : "DMA_FROM_DEVICE"); + dma_unmap_resource(chan->device->dev, map->addr, + map->xfer_size, map->dir, 0); + } + map->xfer_size = 0; - return -EINVAL; + /* Create new slave address map. */ + map->addr = dma_map_resource(chan->device->dev, dev_addr, dev_size, + dev_dir, 0); + + if (dma_mapping_error(chan->device->dev, map->addr)) { + dev_err(chan->device->dev, "chan: failed to map %zx@%pap", + dev_size, &dev_addr); + return -EIO; + } + + dev_dbg(chan->device->dev, "chan: map %zx@%pap to %pad dir: %s\n", + dev_size, &dev_addr, &map->addr, + dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" : "DMA_FROM_DEVICE"); + + map->slave_addr = dev_addr; + map->xfer_size = dev_size; + map->dir = dev_dir; + + return 0; } static void bcm2835_dma_free_cb_chain(struct bcm2835_desc *desc) From patchwork Fri May 24 18:26:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673525 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 9CC18C25B74 for ; Fri, 24 May 2024 18:29:59 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sO1s4Va4yacZoewulPHXs9gustd9TIAXvfrbTSipJrY=; b=KOU6vzeFGE5Ave A2X8fgeq0jxBGXadeNft94afr3xdJBttarbd95p7KAOK4gvzBN+BD7h0miR2vKiFZqf4ULk4XGNC9 wtLzjV4koyAbDMjYtd1xGyG1Fhg14/F7oOTnrAZ/dFyRbwRmgDkftUfru3Vq6uOPiPbyFGS6IePY8 ab/eXhJbpPdrYRCTdB709tktdkeDwsLFHaHwQiB1zvkCjYhT5kEkhJwYHHe8QIfkgdw91dI9+EmwW tRmSAx/vSkcFV3jNk6WgZUEY/B42sp1H8WbfHP7bpVKqZp7x96V4dZge+dpTINdKbItT47W//sY7T 8bCRchj1SZ28jyWG0tOg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfp-00000009aS3-3noF; Fri, 24 May 2024 18:29:49 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeD-00000009ZIW-2Q5w for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LczGECRfXrurv9dI4g4iDY7uh7b4Krp6PtWjBnzvVYI=; b=J1DVSHhAuSKdKeyIuVGc/dS7c1 wnkB2ZdAB8vB6O2jLsL3/L5uFGLyo7PyuI65JFgZNSvVOIzcMRKK5SxQCLa4TR9wQWGe8E1cqGgTi 9MZPdvRZ52l1aY9AjPK1WyNJOGy9Q02p9TU2fCG5B2NmyO6HvxjF6kwpzSeyl/1td0gvAE9fWYH7N zqrfM3ILEsugAbKyA/pDUCGyVhYB/xFRXT4tFJKDXuz5sfaoO1kEN1Cx9XBCkbLx7VS3gMZLxKeis epQ0naoJ1UdOp/XTdzTUPpW9TajX8PPSyRGxQ83dN5/vHvcvEF3SfoKDMo6GMIQyUYCLIBNgMlHRj QUHoF0Rw==; Received: from mail-wm1-x363.google.com ([2a00:1450:4864:20::363]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJC-3QF3 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:07 +0000 Received: by mail-wm1-x363.google.com with SMTP id 5b1f17b1804b1-4210c9d1df6so3469065e9.2 for ; Fri, 24 May 2024 11:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575278; x=1717180078; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=LczGECRfXrurv9dI4g4iDY7uh7b4Krp6PtWjBnzvVYI=; b=mGXdSqBK59+RJv69gXB77pAeSjSEUHzmDcDE4pWokLazQRm+2nAc5DyBGAUqnt7Obu sMM9VxzCq437MNXOuzjT6hDE04XalQwtMXcQzv2i4e7PDjx0NkKKyyKoHEL+8R/ewfy4 Wq8QSS5qJjd+q8X/xlxJk+13FyPYgkKzP+04czLLK6BkdpPFpwiP5uTasY0hZYeYN5+t BaxNU4pmyMpoBzvCX8z+1JzkAOTUChcoNAY5Z0Cafctl9Grw6LiW3p/0Uq0O4Iol0TSE DHECNRBxqFeM0RLSbbxJGnYQ6A3KOjMmB/uy8jbQ+OuEZA+wPMglJKQ41UDLOmjLYMvl 0GyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575278; x=1717180078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LczGECRfXrurv9dI4g4iDY7uh7b4Krp6PtWjBnzvVYI=; b=kq0C06tCV5+1PdmTzeRFSBpE1oOZteQprxt7xjirkHLmCEOouzLBvZlMVVm693Eqie +fxsGzfkBWsj0PHyFF147cw7KC4/mXElnaup7gMw2Z8zk6EPgotu1HlkYmFe8NHISL9A 3Ej0t2i2sj+jd41yF6mU44+Ue2X23cuN8pKu2X9kGQpdYXnUIkz072L3e4O9URqgTfU1 mO4XbNVlDTBxHAoZ1U/jvuT6ldwclpY0QDcHATrTJd384oQDzBa7sLOWr9+A1VMd+ZJi LGk4wA6wQAW+yypnj4Y8aIkAk5aj4c0tfZZdlv7EMoYjFGSgQ8JdncylHZNnH41LtsrI Gt7A== X-Forwarded-Encrypted: i=1; AJvYcCV+mvncEq7X8rx/iVKbaExueRnQd7xHUFT9daNl3kfyRIEX7025atei5G6PPot6ru3WWxGdCTHyp8Hb6vg1JqAQODnHXPYGBSVtgqxzrXsY/bU0l5U= X-Gm-Message-State: AOJu0Yzl/dEE//v7Y33qa8razzFzSlp/QLfgTzSv65b2ewVo52eh4VXo gSpQFhbsAN0cdKnqLAPlgD5r4w2Gh+BY1LQ67cOYXKo1c2kP6DYo+SgAXfBuBRuXqrFYk1VxJqC Yl+qpg148r8O6UPCc4ocgejwHvXJ15rfE X-Google-Smtp-Source: AGHT+IFZwqy7hi4v9+jui3sDRfDYyIcnFYr2RUg4s5QWzy/T07+ZLpqeeBjaPUd6wfnyXf+trffGHFzZtrlM X-Received: by 2002:a05:600c:2948:b0:41f:ec3e:9797 with SMTP id 5b1f17b1804b1-421089de607mr27580345e9.16.1716575278201; Fri, 24 May 2024 11:27:58 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-35586b0b42fsm56761f8f.115.2024.05.24.11.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:58 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 12/18] dmaengine: bcm2835: Read ranges if dma-ranges aren't mapped Date: Fri, 24 May 2024 19:26:56 +0100 Message-Id: <20240524182702.1317935-13-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_663180_33B49E59 X-CRM114-Status: GOOD ( 25.22 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have a historical error in the DT files that don't define the dma-ranges fully, and DMA users have been passing in DMA addresses instead of CPU physical addresses. As DT is ABI, we have to be able to work with old DT but new kernel, which means handling this missing dma-range mapping somehow. The "ranges" property has always been defined correctly, so abuse that in the event that dma-ranges are missing. There appears to be no easy route to access "ranges", so duplicate the functions for handling "dma-ranges" here to keep the hack contained. Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 139 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 5 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index e48008b06716..06407691ef28 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,12 @@ #define BCM2835_DMA_MAX_DMA_CHAN_SUPPORTED 14 #define BCM2835_DMA_CHAN_NAME_SIZE 8 +struct bcm2835_bus_dma_region { + phys_addr_t cpu_start; + dma_addr_t dma_start; + u64 size; +}; + /** * struct bcm2835_dmadev - BCM2835 DMA controller * @ddev: DMA device @@ -48,6 +55,8 @@ struct bcm2835_dmadev { struct dma_device ddev; void __iomem *base; dma_addr_t zero_page; + bool ranges_initialised; + struct bcm2835_bus_dma_region *ranges_map; }; struct bcm2835_dma_cb { @@ -71,6 +80,7 @@ struct bcm2835_dma_chan_map { phys_addr_t slave_addr; unsigned int xfer_size; + bool ranges; }; struct bcm2835_chan { @@ -279,6 +289,114 @@ static inline bool need_dst_incr(enum dma_transfer_direction direction) return false; }; +static int bcm2835_dma_init_ranges(struct dma_chan *chan) +{ + struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); + struct device *dev = chan->device->dev; + struct device_node *node = of_node_get(dev->of_node); + const __be32 *ranges = NULL; + bool found_ranges = false; + struct of_range_parser parser; + struct of_range range; + struct bcm2835_bus_dma_region *r; + int len, num_ranges = 0; + int ret = 0; + + while (node) { + ranges = of_get_property(node, "ranges", &len); + + /* Ignore empty ranges, they imply no translation required */ + if (ranges && len > 0) + break; + + /* Once we find 'dma-ranges', then a missing one is an error */ + if (found_ranges && !ranges) { + ret = -ENODEV; + goto out; + } + found_ranges = true; + + node = of_get_next_parent(node); + } + + if (!node || !ranges) { + pr_debug("no ranges found for node(%pOF)\n", dev->of_node); + ret = -ENODEV; + goto out; + } + + of_pci_range_parser_init(&parser, node); + for_each_of_range(&parser, &range) { + if (range.cpu_addr == OF_BAD_ADDR) { + pr_err("translation of DMA address(%llx) to CPU address failed node(%pOF)\n", + range.bus_addr, node); + continue; + } + num_ranges++; + } + + if (!num_ranges) { + ret = -EINVAL; + goto out; + } + + r = kcalloc(num_ranges + 1, sizeof(*r), GFP_KERNEL); + if (!r) { + ret = -ENOMEM; + goto out; + } + + /* + * Record all info in the generic DMA ranges array for struct device, + * returning an error if we don't find any parsable ranges. + */ + od->ranges_map = r; + of_pci_range_parser_init(&parser, node); + for_each_of_range(&parser, &range) { + pr_debug("dma_addr(%llx) cpu_addr(%llx) size(%llx)\n", + range.bus_addr, range.cpu_addr, range.size); + if (range.cpu_addr == OF_BAD_ADDR) + continue; + r->cpu_start = range.cpu_addr; + r->dma_start = range.bus_addr; + r->size = range.size; + r++; + } +out: + of_node_put(node); + return ret; +} + +static dma_addr_t bcm2835_translate_phys_to_dma(struct bcm2835_dmadev *od, + phys_addr_t paddr) +{ + const struct bcm2835_bus_dma_region *m; + + for (m = od->ranges_map; m && m->size; m++) { + u64 offset = paddr - m->cpu_start; + + if (paddr >= m->cpu_start && offset < m->size) + return m->dma_start + offset; + } + + /* make sure dma_capable fails when no translation is available */ + return DMA_MAPPING_ERROR; +} + +static dma_addr_t +bcm2835_dma_map_using_range(struct dma_chan *chan, phys_addr_t phys_addr, + size_t size, enum dma_data_direction dir) +{ + struct bcm2835_dmadev *od = to_bcm2835_dma_dev(chan->device); + + if (!od->ranges_initialised) { + bcm2835_dma_init_ranges(chan); + od->ranges_initialised = true; + } + + return bcm2835_translate_phys_to_dma(od, phys_addr); +} + static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, phys_addr_t dev_addr, size_t dev_size, @@ -307,8 +425,11 @@ static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, dev_dir == map->dir) return 0; - /* Remove old mapping if present. */ - if (map->xfer_size) { + /* + * Remove old mapping if present and we haven't used our own "ranges" + * mapping (which has no unmap) + */ + if (map->xfer_size && !map->ranges) { dev_dbg(chan->device->dev, "chan: unmap %zx@%pap to %pad dir: %s\n", dev_size, &dev_addr, &map->addr, dev_dir == DMA_TO_DEVICE ? "DMA_TO_DEVICE" : "DMA_FROM_DEVICE"); @@ -322,9 +443,17 @@ static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, dev_dir, 0); if (dma_mapping_error(chan->device->dev, map->addr)) { - dev_err(chan->device->dev, "chan: failed to map %zx@%pap", - dev_size, &dev_addr); - return -EIO; + map->addr = bcm2835_dma_map_using_range(chan, dev_addr, dev_size, + dev_dir); + if (dma_mapping_error(chan->device->dev, map->addr)) { + dev_err(chan->device->dev, "chan: failed to map %zx@%pap", + dev_size, &dev_addr); + + return -EIO; + } + map->ranges = true; + } else { + map->ranges = false; } dev_dbg(chan->device->dev, "chan: map %zx@%pap to %pad dir: %s\n", From patchwork Fri May 24 18:26:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673531 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 9AC12C25B74 for ; Fri, 24 May 2024 18:30:41 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qaYoU4Osp2iHu3oZZOlRFkXCwYaRY6f0JzkF6mdkMwQ=; b=GH49gV+iYm5fnu pOJC+0EeMdxm3zQlFEmTOXOuF5BzU13LJenhl2Fg9zCX0PKG0tR9flmh47t636h0vuXnH5Bun8HL9 JbCv+a3c/Y35xcgcVd8LZ0RbewlcsLFfMUggjogfhk1neDz3xeQvxl950NDyuXJQgxu6w4u8mc7+W FzkptJc8wnh6tep/MPHcAM4hLX1j1D9Qm7CSarGUH1ayXJPI/3vdJcHPrAhKMjfhadiReLEJ/oEgR GxVOOITpdLw4YW5DNUAN52Z159sC+zkBTMWFYVdF82GeEKxpOetLDtl5itpclnkQOAls5UYBEVuDl ronabCes0RgDjOljqmfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgW-00000009auN-0kFH; Fri, 24 May 2024 18:30:32 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeD-00000009ZIh-1Ngq for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=M/tSxq6GA4AT2Mm+nWQe3L0M6c7/C4J7O/BV4BAy6ic=; b=lLgov/jXK0wieNkmt9aC1N4hRZ dYr2OUZBGW/MoQ7ahf9PcqMFZoM2+wtYtmZXUtnMcmTTj0qvpka259sj8716ofEEZlm4VdjaZq8Z+ 4gWz2D16ob/ZAM87JJWGhXoTFaaasR5NWt95IVy6OWInKIJFhzNH45HsV4nWdLaa1jD/TPFWBHGn3 ua27H/S5UQ0d2hjYgxmuZAcTrIglpMDcnbMiC0I9FgfNy/UV7yvTP3Kv2n/3LdRFLS56CzHaYs2j6 gqIY3CUtpJbL1LoBXamyflScgyb5rN0ge0+14z7z9R4u8JFwjl+izTTGOgGQYteInDxSvrkXPT40k vtHivACg==; Received: from mail-wr1-x462.google.com ([2a00:1450:4864:20::462]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe4-00000009vJF-2ijR for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:07 +0000 Received: by mail-wr1-x462.google.com with SMTP id ffacd0b85a97d-354f8a0cd08so2500072f8f.2 for ; Fri, 24 May 2024 11:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575278; x=1717180078; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M/tSxq6GA4AT2Mm+nWQe3L0M6c7/C4J7O/BV4BAy6ic=; b=PtG1M1RL17Fl4PtNESAgVxnvtqTtfraImndwP2OphmkOgHMW0hppczK3Y48WJtJUSi iEeaoOtkHUuYTI89v7jbte/Jp/D0dyYACVazIITaEtYZApIbtKoXBcj61rf7ACode+oZ E7hMi5pOxfz9hDWqH7X1IcowAwtVKBq870TGf4q6MCnt+o4bRQg2eiToGZ7BToUZeMSD hMQXn+aoevSUzB5rG9LAw1vuza0gliTNM733SK0EimHQddR+MGnBO7FWaEUvrNvz5S8Q 3vVklJmomvZ9n0uCOAUsG9aBJY9/k59t+9gsrKf38dPZH3U3FWzYj2OwQvSwD8oSSHq8 eKcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575278; x=1717180078; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M/tSxq6GA4AT2Mm+nWQe3L0M6c7/C4J7O/BV4BAy6ic=; b=HYQyOkAdr8ffa6Grfr6bt9QYZspGh3OjKxI9xqph44cZl5JhpTPE1kzz+gaPTV8uS2 hWZdQ0gTYWmoLtbGtESDmkL5SNfrtZDbD0IOH0AhuFINnlzs/mj1QEe4weQPSEGXFQO6 /aTjGDKi6RQAIFLQ+YO+wpbucPiHT8LH7V2sd/AWvz5iiCrMTFRe6OdpFoSTctrHmhcA FAmvigjmKK0g+UyXZu7oOAD3R0kAmu4BfjdAdUHiPUfgJjkUXcYaOyCu5US7Q73scVkq 6pKmPaqk5gHWDrOjrOwlJrGHXljjdXfxMiujeAhYSJkt6HERfwfKmsz6CYC9BzjWYsFv kYhQ== X-Forwarded-Encrypted: i=1; AJvYcCXBrBe9Msp6Q+EHYaEW5rWg+LSTv2ItRWaOorS5rGqy1gMCma3agpytzbSFcYU/KsFwL9AivouED0T5AMQtqHa1SdE/o9b2ZtGHkSP/vWHdWg6sROU= X-Gm-Message-State: AOJu0YxzEY9PfdcFZzkU1Vau4KpJvU1G4Zj9pUboRuxJ+9UGleLwwGQE hMzhL/N/e2YIKvL88TJ6BGjadlO+cBA2ij8t3BYfPx0cq8WzY6fe/cHuHE+d1lpt+nNzBgZiRx8 axgggphfcFg8UZ2tMh244SFD3ufdOf2It X-Google-Smtp-Source: AGHT+IGz+W6dkdCIXw0ZDp1B/MgrtzNbyRrO8ywWOE/qPAQsbvGxItyKlknvWBy72WuD1SEAMZ/Y6JavBjaB X-Received: by 2002:a05:6000:4597:b0:354:e775:19fd with SMTP id ffacd0b85a97d-355221819d2mr1987214f8f.26.1716575278649; Fri, 24 May 2024 11:27:58 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id ffacd0b85a97d-3557a1c67f0sm61533f8f.70.2024.05.24.11.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:58 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 13/18] arm: dt: Add dma-ranges to the bcm283x platforms Date: Fri, 24 May 2024 19:26:57 +0100 Message-Id: <20240524182702.1317935-14-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192801_709718_3BF42F78 X-CRM114-Status: GOOD ( 13.12 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In order to use the dma_map_resource for mappings, add the dma-ranges to the relevant DT files. Signed-off-by: Dave Stevenson Acked-by: Florian Fainelli --- arch/arm/boot/dts/broadcom/bcm2711.dtsi | 12 ++++++++++-- arch/arm/boot/dts/broadcom/bcm2835.dtsi | 3 ++- arch/arm/boot/dts/broadcom/bcm2836.dtsi | 3 ++- arch/arm/boot/dts/broadcom/bcm2837.dtsi | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/broadcom/bcm2711.dtsi b/arch/arm/boot/dts/broadcom/bcm2711.dtsi index d64bf098b697..d6f32d32b456 100644 --- a/arch/arm/boot/dts/broadcom/bcm2711.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2711.dtsi @@ -42,7 +42,8 @@ soc { <0x7c000000 0x0 0xfc000000 0x02000000>, <0x40000000 0x0 0xff800000 0x00800000>; /* Emulate a contiguous 30-bit address range for DMA */ - dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>; + dma-ranges = <0xc0000000 0x0 0x00000000 0x40000000>, + <0x7c000000 0x0 0xfc000000 0x03800000>; /* * This node is the provider for the enable-method for @@ -550,7 +551,14 @@ scb { #size-cells = <1>; ranges = <0x0 0x7c000000 0x0 0xfc000000 0x03800000>, - <0x6 0x00000000 0x6 0x00000000 0x40000000>; + <0x0 0x40000000 0x0 0xff800000 0x00800000>, + <0x6 0x00000000 0x6 0x00000000 0x40000000>, + <0x0 0x00000000 0x0 0x00000000 0xfc000000>; + dma-ranges = <0x4 0x7c000000 0x0 0xfc000000 0x03800000>, + <0x0 0x00000000 0x0 0x00000000 0x80000000>, + <0x0 0x80000000 0x0 0x80000000 0x80000000>, + <0x1 0x00000000 0x1 0x00000000 0x80000000>, + <0x1 0x80000000 0x1 0x80000000 0x80000000>; pcie0: pcie@7d500000 { compatible = "brcm,bcm2711-pcie"; diff --git a/arch/arm/boot/dts/broadcom/bcm2835.dtsi b/arch/arm/boot/dts/broadcom/bcm2835.dtsi index 15cb331febbb..480e12fd8a17 100644 --- a/arch/arm/boot/dts/broadcom/bcm2835.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2835.dtsi @@ -35,7 +35,8 @@ cpu@0 { soc { ranges = <0x7e000000 0x20000000 0x02000000>; - dma-ranges = <0x40000000 0x00000000 0x20000000>; + dma-ranges = <0x80000000 0x00000000 0x20000000>, + <0x7e000000 0x20000000 0x02000000>; }; arm-pmu { diff --git a/arch/arm/boot/dts/broadcom/bcm2836.dtsi b/arch/arm/boot/dts/broadcom/bcm2836.dtsi index 783fe624ba68..4ab7769c056a 100644 --- a/arch/arm/boot/dts/broadcom/bcm2836.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2836.dtsi @@ -8,7 +8,8 @@ / { soc { ranges = <0x7e000000 0x3f000000 0x1000000>, <0x40000000 0x40000000 0x00001000>; - dma-ranges = <0xc0000000 0x00000000 0x3f000000>; + dma-ranges = <0xc0000000 0x00000000 0x3f000000>, + <0x7e000000 0x3f000000 0x01000000>; local_intc: interrupt-controller@40000000 { compatible = "brcm,bcm2836-l1-intc"; diff --git a/arch/arm/boot/dts/broadcom/bcm2837.dtsi b/arch/arm/boot/dts/broadcom/bcm2837.dtsi index 84c08b46519d..d034d6a8caad 100644 --- a/arch/arm/boot/dts/broadcom/bcm2837.dtsi +++ b/arch/arm/boot/dts/broadcom/bcm2837.dtsi @@ -7,7 +7,8 @@ / { soc { ranges = <0x7e000000 0x3f000000 0x1000000>, <0x40000000 0x40000000 0x00001000>; - dma-ranges = <0xc0000000 0x00000000 0x3f000000>; + dma-ranges = <0xc0000000 0x00000000 0x3f000000>, + <0x7e000000 0x3f000000 0x01000000>; local_intc: local_intc@40000000 { compatible = "brcm,bcm2836-l1-intc"; From patchwork Fri May 24 18:26:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673534 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 69B36C25B74 for ; Fri, 24 May 2024 18:30:46 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=erHxXKs5T/dVngGQRUV+pTO5fFZq/fiMa7cyYNhIBeU=; b=LZ2Hdi3/wtIjFC 563nWZz14IyyuWiIsfRGhD7foDsAR9yK2uI2x+0khcg1ydhgoanrHNpb1GYdKYiiGfbrGiKssXJjk 8+JGfF8ViCbk5wXXUNlbB4PzvFb+yeNcmt9Ve/qKm79XOxqk00l/D3+NZOuNUHTLsVcfL5M8FNEie hefV6o1n2I7TU4OWvdv6BAkget+yTimGHk2YbJ/u8UWOWKymcUbHo7/l8FDUzNDNKSecsvnq9rSkM al1cCSn4ydHD1/fTzOhJiSAHjPvW7zhYjujlWu4Pj0EFamYtHt7C2SdA/+2eX9tw9iGZeCmGD6OzN hvgYAeGFUFXDlc6Mbtxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgb-00000009ay2-0zh8; Fri, 24 May 2024 18:30:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeG-00000009ZL5-1FUF for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=JtSsjB9R4+UVIqScRuc1I4bk33cfKERDT5iPQWCGPm4=; b=gKHVZToPhe8aBDBx7qAE0c0p3V Uz5LLUyBLfWcmiVFWmZR+zqZwoOooSQH0SXme1gyCFN9donZmJsIEVMjRSKUsIEVwgmuuGxaeYN/Z 5kezbO7lcryZMsMzXl9zG4Tfo8TghBiQOtUNIHqvLj9b01LFNZNPvYP8WSrlFMHXG6AI4c0N21Xn/ Gz6LWmmjQFTd3Y4eWE/BZkwC2jY6gdzDXE1/LWr3NJr24d/GKz3CAt+lbKy/99PEc9lcAsZJoSa8T 65mqaCa+NYfjR0XiKgJoaflIP77hBBxqmurnkhjPnznazbMbyYh2EhkoHNXTpUq4VUj8J6LG9me8n A3sOF0EA==; Received: from mail-lj1-x262.google.com ([2a00:1450:4864:20::262]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe6-00000009vJH-1zPm for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:10 +0000 Received: by mail-lj1-x262.google.com with SMTP id 38308e7fff4ca-2e964acff1aso888531fa.0 for ; Fri, 24 May 2024 11:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575279; x=1717180079; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JtSsjB9R4+UVIqScRuc1I4bk33cfKERDT5iPQWCGPm4=; b=V8t7GbauPw8yNb0ypdAhc6xRuWTN2qXhgaa48vjZrbSbRJciMbN4XrxjpIPLWe3GA9 Pe7Zm3pDkiIaZNcoQV7OBsUONVng13Z6lUS79SHKeyIrgK0hLLxalf337WdMAAC8BnGC XFDxihvlQI5mfFK2tfO0yq8suFOOKY02KLEsySc2ppshxB7kdC2ZvPOgR9CWsVP5gAjK vYNycop8b+f7/ekfhIcM3YQunfmHIw0UOr9/L5BhrW4snmNPiJHeh0r7n0SIPuAC060x u6EZLLy8/zBdXnQ/bOfkJdxncR9bOLYLCmiGYrTpAo1+g4diTDyvch7yXARLcnDY3LtT o+Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575279; x=1717180079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JtSsjB9R4+UVIqScRuc1I4bk33cfKERDT5iPQWCGPm4=; b=ZURdOPpB4zIisDkxcAtYCHl60GabxzunrwveygmER8zDCbYtBiIwJjTDZ/WRJ/PcUy W7PerGca9k1jlLkvO7C89pUQdGAdtaY7PRePjtSSyH++6+715NCtSVDAfXYsE+eWz0X9 UiqjJqBORJpMhBOkYJDIKrIEBB5rWGuUXKbjeNcgmMdZHdVuhr+CzrBIgHw+2x92VqMy xt4nlPhlm739nSyUMCpMVt9j6NY57aktKw7ici8f+6Y4Spo4axp36H4P1l8meMK0g/kC q6QK++hoW1P7/jAjSh/0Elxb8aKm7DPmqQSQBTetQgkweOlr2eQghZKmYn6r0OJaKP10 jXew== X-Forwarded-Encrypted: i=1; AJvYcCXhsXp8LBOKSeIj4MiZM8dzHXK5QrOgKLZOLB5rvyFUEXPIbxE0/muMoHsVtnXCsyxn9JWFZXhsrxRD3ywdZo801oJMGw5txgdAK+c6LDCuh0rmXWM= X-Gm-Message-State: AOJu0Yz2Zk5prwXMaK+6Hxpwefd5MG6KYd+uWXAvvQ6qIiwdeIr6Bk93 cTNZHls/efFxu/6+DSWFjCobXSarNyVJ8uBRDqQOM3+kqfQt7Y0chOq11mAXSByW+uXgAxh9Alg P6XckT7Be0duKN5xXIoEJNSSm7fAf7MQs X-Google-Smtp-Source: AGHT+IEUZDsi7SCR4IVByAOz4hmEEdc/AaRCJ/JoMT6C0FVxhy9anVd20JxEW5NHN8g2XEYbzyFyk0QQFB+O X-Received: by 2002:a2e:9c8f:0:b0:2e6:f59e:226f with SMTP id 38308e7fff4ca-2e95b0bce90mr19539971fa.5.1716575279453; Fri, 24 May 2024 11:27:59 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 38308e7fff4ca-2e95be01800sm348091fa.53.2024.05.24.11.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:59 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 14/18] mmc: bcm2835: Use phys addresses for slave DMA config Date: Fri, 24 May 2024 19:26:58 +0100 Message-Id: <20240524182702.1317935-15-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192804_172457_5E1EFAA4 X-CRM114-Status: GOOD ( 17.00 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Phil Elwell Contrary to what struct snd_dmaengine_dai_dma_data suggests, the configuration of addresses of DMA slave interfaces should be done in CPU physical addresses. Signed-off-by: Phil Elwell Signed-off-by: Dave Stevenson --- drivers/mmc/host/bcm2835.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c index 35d8fdea668b..746a60fac0f0 100644 --- a/drivers/mmc/host/bcm2835.c +++ b/drivers/mmc/host/bcm2835.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -1347,8 +1346,8 @@ static int bcm2835_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct clk *clk; struct bcm2835_host *host; + struct resource *iomem; struct mmc_host *mmc; - const __be32 *regaddr_p; int ret; dev_dbg(dev, "%s\n", __func__); @@ -1361,23 +1360,13 @@ static int bcm2835_probe(struct platform_device *pdev) host->pdev = pdev; spin_lock_init(&host->lock); - host->ioaddr = devm_platform_ioremap_resource(pdev, 0); + host->ioaddr = devm_platform_get_and_ioremap_resource(pdev, 0, &iomem); if (IS_ERR(host->ioaddr)) { ret = PTR_ERR(host->ioaddr); goto err; } - /* Parse OF address directly to get the physical address for - * DMA to our registers. - */ - regaddr_p = of_get_address(pdev->dev.of_node, 0, NULL, NULL); - if (!regaddr_p) { - dev_err(dev, "Can't get phys address\n"); - ret = -EINVAL; - goto err; - } - - host->phys_addr = be32_to_cpup(regaddr_p); + host->phys_addr = iomem->start; host->dma_chan = NULL; host->dma_desc = NULL; From patchwork Fri May 24 18:26:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673533 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 80258C25B79 for ; Fri, 24 May 2024 18:30:46 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=niGdAxzITfPdNsiqyrJnwmUcVTLeOVv83V/7sovdHkI=; b=csNJ9AFpP7Ssl1 bxlRrXlyhQgK/PQgy6MaEEVSqnIwrWc8pPKjjDScC9nA2Bo+EEBQQV6OywtLd5P6oaF3SXg0TAWW7 X6rpWNdp/h/uHOxXOmjiznH4LcFJYePjW81YkguM77tTQEQ9mHRPQYR/XzOLKeLG5cK/qERtWbi5W bHcvruW3C6aQbqId8OF7Kz41Lx5OvuZEzFsWMchojg5JmYwFVOLhby2/I2xgMcdCJmhjNAzfC45CZ gkH9uMGkCiazPLdwI904wact4NpiPV6COqAMWQmsz5GXYk0BxTi6jniftJ7T7RrtSJGf1yybcy12I e95+yroAoX57YoVOI+Pg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZgX-00000009avo-3n3L; Fri, 24 May 2024 18:30:33 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeF-00000009ZKM-0mim for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:11 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; b=N9IPDPYsOy3/TKnNqXyjbOi7FH QqTE52y2vI8F7t9RS4gLHQA9ofDgNvWL9XbUoawAZ1dI1T42XrE51qRh5butLxlEx2/VlU1F0xw7j j6l+Q3oQTVuAXPEpp87b4kuZE2WrwP03bckhg7JBbXnEu92H7adZ/hy6yxUH/izCdTMd/BccRDTE3 YhmIFjbRaBSIlDqrsjUv8Xwl+EhuSySbwXgnuSFddeMcp8VdQt9jn+4Y+Xh6KVtEg6Y9AqUzxBSBZ 63GBQ7ogdM1xJwbtIsadZKzTwEbtjqT6a9NbWutLwd03Nck8vEO2wbdm2FClVm1s+IoIeW2tBt4B3 AFn58XVQ==; Received: from mail-wm1-x361.google.com ([2a00:1450:4864:20::361]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe5-00000009vJx-3J0P for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:09 +0000 Received: by mail-wm1-x361.google.com with SMTP id 5b1f17b1804b1-42011507a57so70353245e9.1 for ; Fri, 24 May 2024 11:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575280; x=1717180080; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; b=HbRWp3kgZ2Vxh7s0OOlNFHITeruU4bQ8woUbhwTr1V97EHUGCzA+zt3ikhf6KZPrzM 6VDOVVrEMY80LtTpP7BEeGhIxDUGdJxOh50FFDpHrj7Xk6TGVGn6EiLp8lIGJm61Hqfh N4aR8I/IyB41iOWFHVcHVZore/IFdGnX8spqJYOirp2ECseiZp7ohRw6sjjmT1pyjs3d gqexrcb2F/17GyokqyyBa36GxAvxhE4fXcGjkf3xQmSFI8Glxc7DKqZxDzp9ErmBfXjv AxEZx2miMPyd37ZoQE00ge07fJKMHID7jeiBny+o5MC4iGJ4vabiKamS+Fopv1/iDKUg HL0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575280; x=1717180080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FGCf1ir0ewKxnfYL+8Y6zr0drR+R4O1jhqT1oluTBL8=; b=FcrsiobLSUoHWFD4iDU2NHmMU+rh9+5XR5a8cD/tcX3VTJCt4ZxasxAcZTqrxzbusU QoqBG71DR/3H4ZDVl/VGeW9v2C9uhEnXJMWO3FoTH3TykLz3SbAGY7nnoMAZImHWS3+p xi7gtCHNU8XpjGKyJm7j4PtYFwQN4ihS0GOQMCi8oar4Vpdk57yIzFBpZdGPNJkik6zt 2r0HhiPvrsxzL4dkNduJ4jJv1k7G2wVBa0ltmLwPNBOVflyCP2fkxqkm2PZqO+YEDWOx DRKet/bVyLMv5PeL1nYPn0b4WwlcwL7XQD+D6LE9UPlC7Dg1o+tGScP30GKcljz5/Ugl pC0w== X-Forwarded-Encrypted: i=1; AJvYcCVduGGd4bAhdIIk2jZqL2N+TinXKsp2aw4KjO3xbUAU7VJ9MvjPoI6xLBjX5JeqqIkoLXBYKkkpoQqz/LBsE80xJrExMP0ORnn7FfnKgDajLsIzclA= X-Gm-Message-State: AOJu0Yzw4Gf4UcrMPL0Nkkq6MvZCZYQFpRYXKov23DpscaMaLA4QU+tI sPIEr2ojSwsPLgXHfn3t72IHrlM1+XRcDEdeuNWCMNsGMXfDhcdSjTnnn7rX7EszYD67g1Pvvf1 qWqHLItJGPrBYK2ibLVmQ1MPIlmvgj2Xb X-Google-Smtp-Source: AGHT+IHAQFzXjWnTl+TwMEnEF3wypw9s7LeiM71e7MxN0zWKYR44rUnrOPV4U43jDFBiNTbbJuux8HJQ65dC X-Received: by 2002:a05:600c:1381:b0:41f:b0e7:f299 with SMTP id 5b1f17b1804b1-42108a59292mr20514315e9.9.1716575280074; Fri, 24 May 2024 11:28:00 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fa9eb7sm5393305e9.34.2024.05.24.11.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:00 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 15/18] spi: bcm2835: Use phys addresses for slave DMA config Date: Fri, 24 May 2024 19:26:59 +0100 Message-Id: <20240524182702.1317935-16-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192802_236051_387630DD X-CRM114-Status: GOOD ( 17.86 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Phil Elwell Contrary to what struct snd_dmaengine_dai_dma_data suggests, the configuration of addresses of DMA slave interfaces should be done in CPU physical addresses. Signed-off-by: Phil Elwell Signed-off-by: Dave Stevenson --- drivers/spi/spi-bcm2835.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c index e1b9b1235787..e8242e0c4246 100644 --- a/drivers/spi/spi-bcm2835.c +++ b/drivers/spi/spi-bcm2835.c @@ -119,6 +119,7 @@ MODULE_PARM_DESC(polling_limit_us, */ struct bcm2835_spi { void __iomem *regs; + phys_addr_t phys_addr; struct clk *clk; struct gpio_desc *cs_gpio; unsigned long clk_hz; @@ -891,19 +892,8 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, struct bcm2835_spi *bs) { struct dma_slave_config slave_config; - const __be32 *addr; - dma_addr_t dma_reg_base; int ret; - /* base address in dma-space */ - addr = of_get_address(ctlr->dev.of_node, 0, NULL, NULL); - if (!addr) { - dev_err(dev, "could not get DMA-register address - not using dma mode\n"); - /* Fall back to interrupt mode */ - return 0; - } - dma_reg_base = be32_to_cpup(addr); - /* get tx/rx dma */ ctlr->dma_tx = dma_request_chan(dev, "tx"); if (IS_ERR(ctlr->dma_tx)) { @@ -925,7 +915,7 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, * or, in case of an RX-only transfer, cyclically copies from the zero * page to the FIFO using a preallocated, reusable descriptor. */ - slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO); + slave_config.dst_addr = bs->phys_addr + BCM2835_SPI_FIFO; slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ret = dmaengine_slave_config(ctlr->dma_tx, &slave_config); @@ -964,9 +954,9 @@ static int bcm2835_dma_init(struct spi_controller *ctlr, struct device *dev, * RX FIFO or, in case of a TX-only transfer, cyclically writes a * precalculated value to the CS register to clear the RX FIFO. */ - slave_config.src_addr = (u32)(dma_reg_base + BCM2835_SPI_FIFO); + slave_config.src_addr = bs->phys_addr + BCM2835_SPI_FIFO; slave_config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; - slave_config.dst_addr = (u32)(dma_reg_base + BCM2835_SPI_CS); + slave_config.dst_addr = bs->phys_addr + BCM2835_SPI_CS; slave_config.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ret = dmaengine_slave_config(ctlr->dma_rx, &slave_config); @@ -1336,6 +1326,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) { struct spi_controller *ctlr; struct bcm2835_spi *bs; + struct resource *iomem; int err; ctlr = devm_spi_alloc_host(&pdev->dev, sizeof(*bs)); @@ -1359,10 +1350,12 @@ static int bcm2835_spi_probe(struct platform_device *pdev) bs = spi_controller_get_devdata(ctlr); bs->ctlr = ctlr; - bs->regs = devm_platform_ioremap_resource(pdev, 0); + bs->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &iomem); if (IS_ERR(bs->regs)) return PTR_ERR(bs->regs); + bs->phys_addr = iomem->start; + bs->clk = devm_clk_get_enabled(&pdev->dev, NULL); if (IS_ERR(bs->clk)) return dev_err_probe(&pdev->dev, PTR_ERR(bs->clk), From patchwork Fri May 24 18:27:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673524 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 D52C6C25B79 for ; Fri, 24 May 2024 18:29:28 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=8ykntCZzdTpuk04AS1Bl2wZoN6Szl8NCKY1S3dyoLD0=; b=p2IRr4PEkebidK iesHjpgh0bZq23CVyiqRh6cv/QQYP97uq5iMRJUvCBcmIdOj3KTCLeOJrPRnqu6B/YSsuDhQWqoR6 IBD1WQ8hzJEn1SIJxjsPuvDq4/rF5kILinmgv/MVbEGTc1xDxGq2DmBDVnUlEVq8TkxDFQ/FXZFf7 Hu0BIsTqnrpKih73bJO0HT9wW+hU5bISH17LHXdz5R9CVIyxmgYB4FcXry/ThVmKMMWObtftAnO0i rgJ62U7kgfxH2cJr7epFK4cwIU3vUnh+x5SkHrdDOgles4PGike2Hy+eSpgRVgnxHkKIdAxBdLBeE GVY3oayQg+890zzIYqjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfL-00000009a7u-2g5H; Fri, 24 May 2024 18:29:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeC-00000009ZHO-1FUt for linux-arm-kernel@bombadil.infradead.org; Fri, 24 May 2024 18:28:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=U0fkVyk6q1d4tTjNi28+nVqK2ri87Lnbs7bXh9cTiug=; b=qE4dc/54erSki8ew7K5umhJSVl WLSBUB+e5as6B2EuNw8uiQ3v7tJS1YFvq7GGSsdz/pQFVhXeRySNqf4zxHy/95v9RiLOSz1xX8c08 fnA9ZzLtRY2xExKdGefX6n9qFrY6gcqntekZwhbOSmp7jComlA01ckHrPt+HTER6fNnCT3QBzn1Pb aH5gVc3FF/w+im+PR57AfcquB0A1y7KRjgtW2+CdR74C423RKf+DAPCtDhcfaavZk9yTZBqj9UgPr 1MqiZyPQCR19bcBEDniO2OJKz3cnwVFpEZaCul6gUamA4rD4C00xc2+dgFPPHnUrsq9xOYvx5ww1p RypS3xKg==; Received: from mail-wm1-x362.google.com ([2a00:1450:4864:20::362]) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe8-00000002w4e-0Zz6 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:06 +0000 Received: by mail-wm1-x362.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so88863115e9.1 for ; Fri, 24 May 2024 11:28:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575280; x=1717180080; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U0fkVyk6q1d4tTjNi28+nVqK2ri87Lnbs7bXh9cTiug=; b=GLACGhbtRx5WnZTfh7i4URcHy2Jnwswmb+EGL3Q6zRy+TgbDJ6HFyzjS52cX1inc+b 6xCEbOK0LJ5d6pHiKL49xqf3mMNr0YqfzPFZRai5eWZl2/wVlXFNTGNkczzjahfiCAd8 tyhJRf0zxQlVK4uOy1eFrqBZOZJ4t4mv4eD2BxgVL8IlosO6rZqw9dDLfOwHwYdg5AuV Tj2X/dcXC61aywNGOpKnHpQUx6G2VfDvo50HvUarmEtTPEgNHEd2bX2P/YNvYHsUC76A kyzSWPtNKNhqw2mX4sxZnagK+4q5WU3ToYAvbBdkXzNoQvYbQxUWm4s3PQxxhZ+zhu3N 2aKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575280; x=1717180080; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U0fkVyk6q1d4tTjNi28+nVqK2ri87Lnbs7bXh9cTiug=; b=MzmvvW8NDVhT2T7fwlLo3n5VkufvLSc6Xtklg7rf3hcsUEd0p2dTat9WCG4+DJYn/F ZgJg+rajMdJBnPhpkYviCZc6iMIGaG17L0jnF66aI3N4ao4k48oIGnHoRigWyWUyzjoI H17H2dnhd9WnqoR4fJTQl3kfDEme5sy8ZpfKb4tuYbz5qvZLRTEimKBa8w9xCXLIdZrs NchMRYXEfpZyV1ZKL60uRIkbxnPgDa0eKIVmmzJX+IWKD/5+YiONuXkKF3wX0nHpCZSp Y5WUeECWUwOL4RKWYKL+cfdJLSvZLritWxvK6lViw/35iJ7t5ZDkGj5+T4yoMuYnaIpl hHlg== X-Forwarded-Encrypted: i=1; AJvYcCXJdXWrNzNIEuBmFGKNolRy1b9OCXJ/rnlel+oUQ1GGiqLBKyBddtTHA6+WHpo4QPUezTe9P6OIDvd3NTuPKY57zrOAPMCoTOFhEY92lf0HJ5UUDak= X-Gm-Message-State: AOJu0YzYKr2YobwI0KBa6uC3w8Qk34rWuqI2QmQBTw/EGj9dH928ejXp X/b/Q5mAiCZSsVgpGsVe5sZA3comzpItXoFmxYSRXMA9jz/0wSMrhbJ67N+YLs4j2J/gMNWHL8f JFtqp6EjZfgEeyFUgCKmmEWiMPjff5I3o X-Google-Smtp-Source: AGHT+IGBxnWkfl21ZWcAGGbY9pK5CCtvRZEInE2s9wbG2L53cMYgxcodxHXuIlPQ/f02qRVKa1ge9AFPlvFh X-Received: by 2002:a05:600c:3152:b0:421:757:4d3e with SMTP id 5b1f17b1804b1-42108a40f7emr33721035e9.16.1716575280608; Fri, 24 May 2024 11:28:00 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fb1394sm5457725e9.43.2024.05.24.11.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:00 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 16/18] drm/vc4: Use phys addresses for slave DMA config Date: Fri, 24 May 2024 19:27:00 +0100 Message-Id: <20240524182702.1317935-17-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_192804_382630_0963D95D X-CRM114-Status: GOOD ( 13.69 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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). Signed-off-by: Phil Elwell Signed-off-by: Dave Stevenson --- drivers/gpu/drm/vc4/vc4_hdmi.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index d30f8e8e8967..c2afd72bd96e 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -2696,7 +2696,7 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) struct snd_soc_card *card = &vc4_hdmi->audio.card; struct device *dev = &vc4_hdmi->pdev->dev; struct platform_device *codec_pdev; - const __be32 *addr; + struct resource *iomem; int index, len; int ret; @@ -2732,22 +2732,15 @@ static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi) } /* - * Get the physical address of VC4_HD_MAI_DATA. We need to retrieve - * the bus address specified in the DT, because the physical address - * (the one returned by platform_get_resource()) is not appropriate - * for DMA transfers. - * This VC/MMU should probably be exposed to avoid this kind of hacks. + * Get the physical address of VC4_HD_MAI_DATA. */ index = of_property_match_string(dev->of_node, "reg-names", "hd"); /* Before BCM2711, we don't have a named register range */ if (index < 0) index = 1; + iomem = platform_get_resource(vc4_hdmi->pdev, IORESOURCE_MEM, index); - addr = of_get_address(dev->of_node, index, NULL, NULL); - if (!addr) - return -EINVAL; - - vc4_hdmi->audio.dma_data.addr = be32_to_cpup(addr) + mai_data->offset; + vc4_hdmi->audio.dma_data.addr = iomem->start + mai_data->offset; vc4_hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; vc4_hdmi->audio.dma_data.maxburst = 2; From patchwork Fri May 24 18:27:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673526 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 A67D1C25B7D for ; Fri, 24 May 2024 18:30:00 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XEzc1aeyculmh+lsTRSYu/vMUDvnp/TmiXj227wVgNI=; b=Na126rR8Pkl/oW 3wEPOfREfikxyMNvPqaLcTAnKDK6kHdCk7AhZSHEARJ1Q3KEBK86zxVs+LotOngFJYLyZIKeuhH7b 55BDLD1EsmrXV2IeJ7qvc73dDsClNJpqCUvM5PCPKH4mVmbQbj3Gi9TyiFsPHGl37lKYvmtB4bsCW ObC8EA/83lVmIT1q1fzYXN3SClTUHFzDp/JV8rRZ42ulu2XnbG1p1ZXrfjl6d5wEMEiuGOaxwe//2 oqMtdofDS7BVLI1UidAJp/0LFKIbj3GoiYttGn1Rd5vWmWMhcW24jd/xXfaCDhqGBBtxIJkPprdLz R8CbyiWPz8/kCxArN5SA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZfn-00000009aQC-1sVQ; Fri, 24 May 2024 18:29:47 +0000 Received: from mail-lf1-x163.google.com ([2a00:1450:4864:20::163]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe8-00000009ZCr-2zLE for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:09 +0000 Received: by mail-lf1-x163.google.com with SMTP id 2adb3069b0e04-5295dada905so922756e87.1 for ; Fri, 24 May 2024 11:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575281; x=1717180081; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ILGqA7+HzXQqr0Ob8oymTx1wN+C0088/4KfGywkxvSc=; b=ByDYPPEid1+i5yrq8x0FRGWIbKuvLa6Hw2fFEtwKW1+UwM+604uFnU7W0Tf0hbHVUM wS9e1m+S2I9kASAQ40TwaBmOzni3uBXxGPipm7Q9bp124BC39RuJGBPlPzzDmSFDAq7O S7T32C9kl2WSyW86jXu56yJrNWjnYrkug22ppz4OU2/FdlPcXtyVQYWBceXxSo3zFoL/ j5d/tk8J70vvYQhWkRqn3VmsDRGYuGiW214f1FK3t0yK/uYtY/D4Z2WqvNnSo/Y2LI1n 3KK3trG19Gw1t+eVzUIiQQK+nDzg+PjawYm2grQ6n/Pw7G/01bptjE6qWz2dTlckOOOx tidg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575281; x=1717180081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ILGqA7+HzXQqr0Ob8oymTx1wN+C0088/4KfGywkxvSc=; b=h+UD0B5ubqjpWnS2bAxj01M/8fdF8U24WBOEjkbv1mr3A5g1nqp7PyNAziJMQfg/aC uz+0bs2NBwJu+cxlah5Pvb5wkBDPON+6cmXc3a8vf4yifZ1z08IDmNU2aibfXOiQnKGk Y7ulZlFk4teKEgDl1yXcArgVcApZAr5GUnhRai7DBNL7etawUJ6IzXmmkWNo8mbwz427 SdPI4kRRb2TTurA62hyNylnqPQHpV1Jr710kGDmMWW8Ziwyacj6JAJjDXTNWLbe3k34V QR85B8dAtFgcmxVt6G1WDnId0YxVFfYW18ewGUUBVZj7IMM5MUcvwTn92JG5bOL2BH+Q a7gA== X-Forwarded-Encrypted: i=1; AJvYcCUwsvqMGNDNcXsWAjf551SYujBLBZd10qlUlO4CDyDB9gtqcrBsO+B7CW8aFrCQiVlDmWecyroMUCvQtLWjx/pczUs2SvuoYr+Mvg5ADXuHUzXkJR4= X-Gm-Message-State: AOJu0YwF4vL46Ink7wflgPodqaIVriXFejVP8IuRQfyxqTMuKhP++Ztj BhZBR9FmNm7mwmf9FO7AUyL3cdqOH8+GV646Wwd3S+eXxgaEDVxk8hlYSeLsrWyvjkFgU8ogf/+ 52C+88T6FYR9MfbW8beH7SvD1w2pANdZG X-Google-Smtp-Source: AGHT+IF1+0vxRvmRUWINjGzopDgrgXSdoJO/81rJkJR0w/gJjv8782tLukyv6IUMN4Wu5q+/dPS8x/uZhNPk X-Received: by 2002:a05:6512:290:b0:51d:7d4a:517e with SMTP id 2adb3069b0e04-527ef210aa5mr1916182e87.9.1716575281453; Fri, 24 May 2024 11:28:01 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 38308e7fff4ca-2e95bcd2393sm339921fa.6.2024.05.24.11.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:01 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 17/18] ASoC: bcm2835-i2s: Use phys addresses for DAI DMA Date: Fri, 24 May 2024 19:27:01 +0100 Message-Id: <20240524182702.1317935-18-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112805_032745_669EBBC0 X-CRM114-Status: GOOD ( 15.57 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Phil Elwell Contrary to what struct snd_dmaengine_dai_dma_data suggests, the configuration of addresses of DMA slave interfaces should be done in CPU physical addresses. Signed-off-by: Phil Elwell Signed-off-by: Dave Stevenson --- sound/soc/bcm/bcm2835-i2s.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/sound/soc/bcm/bcm2835-i2s.c b/sound/soc/bcm/bcm2835-i2s.c index 9bda6499e66e..2d0fe53245f0 100644 --- a/sound/soc/bcm/bcm2835-i2s.c +++ b/sound/soc/bcm/bcm2835-i2s.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include @@ -830,8 +829,7 @@ static int bcm2835_i2s_probe(struct platform_device *pdev) struct bcm2835_i2s_dev *dev; int ret; void __iomem *base; - const __be32 *addr; - dma_addr_t dma_base; + struct resource *res; dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); @@ -846,7 +844,7 @@ static int bcm2835_i2s_probe(struct platform_device *pdev) "could not get clk\n"); /* Request ioarea */ - base = devm_platform_ioremap_resource(pdev, 0); + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); if (IS_ERR(base)) return PTR_ERR(base); @@ -855,19 +853,11 @@ static int bcm2835_i2s_probe(struct platform_device *pdev) if (IS_ERR(dev->i2s_regmap)) return PTR_ERR(dev->i2s_regmap); - /* Set the DMA address - we have to parse DT ourselves */ - addr = of_get_address(pdev->dev.of_node, 0, NULL, NULL); - if (!addr) { - dev_err(&pdev->dev, "could not get DMA-register address\n"); - return -EINVAL; - } - dma_base = be32_to_cpup(addr); - dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr = - dma_base + BCM2835_I2S_FIFO_A_REG; + res->start + BCM2835_I2S_FIFO_A_REG; dev->dma_data[SNDRV_PCM_STREAM_CAPTURE].addr = - dma_base + BCM2835_I2S_FIFO_A_REG; + res->start + BCM2835_I2S_FIFO_A_REG; /* Set the bus width */ dev->dma_data[SNDRV_PCM_STREAM_PLAYBACK].addr_width = From patchwork Fri May 24 18:27:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673520 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 CE5ABC25B79 for ; Fri, 24 May 2024 18:28:56 +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-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1qAYKUOOhe0a2yloCXaU3DdCdYq99sP9ajd9jr8UeBs=; b=PTAyt6AyK5V2Er vtWqxa685mGYab+mW2AAAvbX20wbHx/csQp6KRdamEh1rPdv82iCi+kNn3kkwEhg2DZIJskadrFk6 btMaWDURd1A8IfSkAtVTP/ILUyEL+u7S0hzJN3fRHdljPhLc9BQUhqwmMTLTSLA5WdUIonHU2pjcf v9yqyN9Ygwi0gSJ0Ahg1KSPoycsVzf+qPKBaRu/rMp7nsUpAXAQQbNyijDiQPTis9qJeb8VoVpPXI MF87ENYhXyhZwgK2dqD981F/iwm1k9dkcyyGVwl+o8DiNzNpaYdhH0x/UNxfwA06iy6xhZ2arhBjE Oro6mhKolrnC7y66Z5aA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeq-00000009Zm4-05pS; Fri, 24 May 2024 18:28:48 +0000 Received: from mail-wm1-x363.google.com ([2a00:1450:4864:20::363]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe7-00000009ZCz-1nQi for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:05 +0000 Received: by mail-wm1-x363.google.com with SMTP id 5b1f17b1804b1-42101a2ac2cso20613735e9.0 for ; Fri, 24 May 2024 11:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575282; x=1717180082; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gaJ2/2ZC9xmhH/6MleK2a1l8XHvCRgt0iv2l1bIIm7k=; b=U41MXQHbFLfK6D/xh6hLQoQdj3KQSCzLOKLZt5I8I14eH1oBw+DjNn+1G3ycV0Iqx2 10dwW6o7pESm+3xfhbuXB5Xup4LhpDeILwEPNwtmwIrSDfDdlAeAbthCMcd/1xCiqDnL y4QePZYzN9OkvQalxPqSXx//LaG5pA1DUsr0Sz+C5FXG6x/L5+BsWSwohO+1zhgrLGgU ENioc+UPZm0Z5UL4lwX7iFwh6GIfO1RgQH1zWKVTxHnJXltuXY9MxTr7+R0ngP1nSKhs +qeQ0zidRcClXbB+o3gaAd17zd3D/4j3qx+n1AJ4VKMOr61Gjbf2miZW3f9NeqFbc/MP HWug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575282; x=1717180082; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gaJ2/2ZC9xmhH/6MleK2a1l8XHvCRgt0iv2l1bIIm7k=; b=MIWXVaY1Ivq/o9vUiuz/hg/ytidNwpDJTQ1lQtaI6QeTxf2raI4w5+I4DvJp3M2juw lhvZBXNih0g6GkuyyfUDbSNgma3GcfjTaJT7Dj4WTLh+6qRnIw31AO6jM7nhU9TMZO1K 7ldzaRRnYf/mncU9pi5tUuGIjuW38tWJDKndbY8WUNd7NT8aj6+dr+FnRftncRwplS83 YZ+HJ0SgvqlZ4gIwZbFshVkuP5GIjYb55g2HUdmb3+uhT8Ot4UK2nAyYHv2sH1vJibW+ nkkJ8SHjJ7EMu45woLEBSy+6vo8/FpGzBxPX1M8TIwygOxDpD9KJgb67chpXs02xejDh N45w== X-Forwarded-Encrypted: i=1; AJvYcCUeTN3BUPwP+RZ64Rrriw7YGw2oLAAdJ4EW3mtze0hpclH1n++W7cW4ekvvwzBen8daxNm+UfTn4AlFr5JqfWHzsbD8WMEiVmEI1Gr/V10QU0ugBgo= X-Gm-Message-State: AOJu0YyhkuZfHpFvCiEi0MfqjnVnMwhqFQlRatU7xGUcZm4BX56m3cmG 9D7MdfuZxZrx9Y0oqJ2v/XpHYXNRHBGQnJ7LfQF/mrnYOAxkTu4uyTaNayUZiiNLxafGDgcxmh7 cEksMAz0yj2o5vEn9odBCkhtTppKyLcye X-Google-Smtp-Source: AGHT+IGW0tEBfx8ikBiBvNc7paeaC57bk88c6mQfl/2RM8CdfU5tVZ5vx+/JsN/a6nuR9BJ11cex+eTG9kUv X-Received: by 2002:a7b:cb8e:0:b0:420:2b5e:1808 with SMTP id 5b1f17b1804b1-421089d8182mr27055785e9.16.1716575282092; Fri, 24 May 2024 11:28:02 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-42100fbb0ffsm5433375e9.53.2024.05.24.11.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:02 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 18/18] dmaengine: bcm2835: Revert the workaround for DMA addresses Date: Fri, 24 May 2024 19:27:02 +0100 Message-Id: <20240524182702.1317935-19-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112803_637455_A4EE4A3C X-CRM114-Status: GOOD ( 13.97 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now that all DMA clients are passing in CPU addresses, drop the workaround that would accept those and not try mapping them. Signed-off-by: Dave Stevenson --- drivers/dma/bcm2835-dma.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c index 06407691ef28..181f2c291109 100644 --- a/drivers/dma/bcm2835-dma.c +++ b/drivers/dma/bcm2835-dma.c @@ -405,17 +405,6 @@ static int bcm2835_dma_map_slave_addr(struct dma_chan *chan, struct bcm2835_chan *c = to_bcm2835_dma_chan(chan); struct bcm2835_dma_chan_map *map = &c->map; - if ((dev_addr & 0xfe000000ULL) == 0x7e000000ULL) { - /* - * Address is already in the 0x7e... peripherals range. - * Assume this is an old client that hasn't been updated to - * correctly pass a cpu phys_addr to the DMA subsystem. - */ - map->addr = dev_addr; - - return 0; - } - if (dev_size != DMA_SLAVE_BUSWIDTH_4_BYTES) return -EIO;