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: 13673536 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E88D3D966 for ; Fri, 24 May 2024 18:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575277; cv=none; b=cQ/b6gU6fIjpqbZhdHgXfMkmt5j978mp02X/Hioq/4TDl147J/rhZPKVf7IeFsYhCqIRktFLgvq/j1FPq91H/Squ6dYMbhhtTiBJG7Z35JUYQD86GQbeSPZ9HyttoPoeckrFppP6IT4LZ1Y8F59xRGFYrx0NFYf7w13HNTKv+ZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575277; c=relaxed/simple; bh=guK+qXaJ8AZoVR69jRMhph9+Ra3UDqbRnwvqmJc9gsI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FnpG4Mx23njlknzUiml9nJHblZ8H3PXAKF6Qah6ANCrYj03fvjrmASCwbngn+P+Kswc1fH/FZoRkvFyYxMFOIv9NdybBYVaZ60A0SIpA0GdFJEAnieRdNwD9ASI73w0f9X18MPvF53jzuQtBfvf120jCbJFno6hReNZsIn/sIJo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=RXXjQD6d; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="RXXjQD6d" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-42011507a54so20436635e9.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=vger.kernel.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=RXXjQD6dzwStvDqi+42tP00mk/CVTm2VB2sOJMazc+QH6UwOGZWlZkSHfslgQych+T I8TfXS5wDEd2vdmawaUMTmI/Ux1N9sHlZn+FneXjPVb35XSTGVT1M0pWEtMR4JOWkeZG MhOZLJvb8KKmbnvA5TTG/O3qAZRp7HGvTZMTgFQhG1eRlIpyhldAZvUHzttyDLJf0DFO 1M5a19di362OhlMryLr9Ck30vwnekJ5AP7GwPX0u5HgE/p1Skd3SitHMNA/Vcwq6iVyw CVpUpQnSARVOdJAPqyqrFn0ZFpO4uhRsmdUjNSqcmq40KoxFLw3v4VPucXK1j1YoP+nl lVNA== 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=cHP/lKjPU7PNBOx+H8b+LIfg0l7xa6reydZ9qX4wvqRwuDFtL7ORwffSU9pqE7jka7 Ggw5yw9HHSLRE4fsbt43wkRW6gafyDKsQenFmO6ajB1cV2DRS8WGKV7hWv7EylJSKviJ bNOG3hUWdwfU5/ntOfMIKqcamnF8R/dfA0tBaV5DvvOPsIV7Ym1f4CsBshS8T+fG6F9s cAIqcboyj5yjA1TD5CQ90euslMTABOg/nCyZFpmzjlcZi41+VN81N8Rl+yJkVwvjPzbr 6VQa5YrxeK3YGmkWrtPGWcm1z7/cE8YiLgxIxDx9gHz+41+1T7FU9REYkGBIv41TCeDD 45Yw== X-Forwarded-Encrypted: i=1; AJvYcCXW2B21p57aX8e4/7P5qAQ0Oi+oWxnBHA62jSw9KvgmUHEM8jzkkZuC8AcY/I/roxIfYR/J6u1o8HhYKog+8rZo9PEGBw0Shmxd X-Gm-Message-State: AOJu0YxSZ9W0Hm92iiv8W7c8bfD/8Fjc7qcIl5xUq2sSQdP+T4BFZfkF 9/jcAkTm67h6St5I1LF0sxlgGktZRCPmho7jzRDQDHF0On8tOR/o28eqafRcgTEI6CABccUnGVB zu6fyL4ML6W+SaY19qmltp8a0Mo3RKbcT 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673538 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F96F3D0AD for ; Fri, 24 May 2024 18:27:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575279; cv=none; b=ZyiNlK0LEGpb6WbTIkAFX/ALrpFrBouZM0mIC7WQ2p/2+yGeDLgARhyYxJbjXrfDwk1LxyZ0CaAIfGORhUjI/i1mb6Byrqr3bpx+MVzUrsEiXN2hZXmKCQIrxlxizZbyun7yREgkXDvxh6czzQBl4io9SZHIiSKWwe3HI2nPdMI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575279; c=relaxed/simple; bh=t6EOXzX5NBCieefJXhaqEj/EuhQeMzBIdGFGnmyqFc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sp5iIe1DAYfcs7t98t3CElPfs75nntmiqLypsWxQ96Qi2Mszpyyu5LDUp3g5+EGba4CjsRSPGVAXwhSR4vJbtK3mEyTh7DVmMaVYzVcAlEjuZAxbRYWX59tbbW2EE+XaYShKqExFY+pmUBojwpQTGKlB8775XX2BTgEk7d7SWLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=tyumMzdp; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="tyumMzdp" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-4200ee47de7so68153525e9.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=vger.kernel.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=tyumMzdp8FGH9YqbvdldjlPB0bjTiwCyYniuRFs67n7zZL41LXqMUi3apYcvJ/FTA5 M3kAX0WE4j8SDbpzjxwWCCKxbw1u57Nguq/v2FMPSS4uI6dtAxizOCGZ0eBMI+giPfLs QvApk0fZcExSdaNCsei0Em4f1G/bHa02obSiWQYxPJYf2OTrcqNngtG7fqN92qpSMWd4 qD7ebj+Y4Dpe1rZl9wjNyKqKRINFSoYAGtTAXt2pntSVMA26ch4aqH5QiFZPeqmkseQA K4fAR/cssGDV9rbvR/Vs87o/WpMpGCPjJua5UqgwybJZQDrXX7FDKs9zXG64mCd7eDD3 osvg== 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=G9gWptJHVAh5MCMn54Ekc7ULOASaG56qRtP7EAP2MV+GGeWqF4I3qf4cqq3rPMZoSX jPYjz0he79jv4EP2zN/v4v3Tgy9kJLl9ZSrrBYS3oWpbWjGszL0M6dVNVVIwLhp/4i4K o3EeVWT6YpcTGQ20l5Snx/IEfHyvGzIcs8qNjoLjlrA1vDkGKBAprP3PD0c5dTNiyPIS GPE7kWjDrMpFFfTtt4s6W9wU1aXKho/sZz6ax3kW/DL2YhKyI1vFa87CWXBX/apOE6rg xkPLdrQ12Hsev7o9Z1JHJD1f0y1CLUzPr47h+Qu8Yd+cFFEFs7RpUE5i0BtBSn/INZv/ UmCw== X-Forwarded-Encrypted: i=1; AJvYcCUaqzyuFEgv6yG7vyBAfvYuq5x/f0UAfmYiPIwv2Xygh00sXmX+WrQhBUheU4HHFf0cHD+K8TR3qCiahmVyupLjjhPbjGb8OeFV X-Gm-Message-State: AOJu0YxeDO1CMDDlUGhV8FZtu1mlLwUBOzjaDv87R5Ke2COG3IzdSDsF R23MAkXb2+9djexGcUIhmWonHIF9FMWv1FcOv6jc1cYybjROpQ2Wtok7MFeTlmoqq2Fln8dBWjl vwUFZ6AudmTIMFE5gcTsjbmWe1v/sTjQH 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673537 Received: from mail-wm1-f100.google.com (mail-wm1-f100.google.com [209.85.128.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8561F3FB01 for ; Fri, 24 May 2024 18:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575277; cv=none; b=gQXkpm35Ez3FnuTInupm7EOdkJtFKP5hEBRdz3VeIE6pcrMZ37590Xrp27mBPAUWYT3xtzVKZqPXALZ0AUl863acM//nGK16hRCIap94cI1tI3FqSBtiJFqzh0nk5S7VQgTdhn2weUDFvtHnkCYXJzUqgmwVZtQPh3twd9geqTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575277; c=relaxed/simple; bh=KzZ2/ILylgxy50sk/StCVlBR9s2jedRDn061bSZ6QRA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OxceezYc5DIUnZ9Z9DGCqoKdRchQexUPjm2x38j5MhcXH4PzycTFkXVxGoJjb/1WWDc9pjUcYGRm5x7jRuNyu4t5DhC2Yd3tO+lsEGwgnOWfIpHPeGezjHHdUxFOfp9KGQPL3QrwRulYZrW3wJON6cUCv8VFnB+HNnqM36gECvs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=TXjTMPjv; arc=none smtp.client-ip=209.85.128.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TXjTMPjv" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-4202c1d19d5so64558375e9.2 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=vger.kernel.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=TXjTMPjvEB/mpo5ZJFhiMaaLnozrvLslAQ+8QJMzQMCPL24NoORbh/iE+2u0VB2MfZ 1EfFvNlEv3pYHOX3PLnPH81gO8rl+M3C9pwpf76F3Ym4Cmroc3xhPvVpSak5XcrMHzHm D5mZhstvelzEAdDlKGhTP6mZHGx2SL2LLuA04oOSyJeQ+FQhAeR9LYDZn2a0FSVJcOeD W5NC7dvCF5W0HL2IU8T53zi9BLYm9nBfyYCdJDv1I0XaAJ2lJvQom18lNOpjx5B8xXTs qytn/30BOA7mU5yGUg/NF7guE60VaGTNLsr7ROhtnuCRWtpSC6DJpuLb4qAgg1xJpb67 HmOQ== 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=Z/W9qcuP4ZvjyVR7BbLuFdA6oD/E926sQHOCZWMwRT5l5+2KfmcILlxH+lv35zu9Zo 2g62b7prmvi9kqXfC9+ucIiQBKLB+llPPyCc7m2GxaWrPEbF7BRQoMsHa5GGgxw+wCJ2 Gt3IjtBeOJlOFRZzBvP6wn1/rROkc8wGuGdlSZEu75d2Mc+kR27VPmfhGctCexCNJKc6 tPgoNxkzUusIBSSxNHvlrAeMYtMocIMtJRFUUaUim9Lenmleh0e5BPXYYBsjejZ9hSuS 9QeiMv4/oPguieN+lsEst1JpTMsyeMYizny+X+dtlD/xygPbbYIPA/E1sBkxnhRq0z3b SQIA== X-Forwarded-Encrypted: i=1; AJvYcCVMSU0P+qyPqYiKWirq5nG1Jn7m/5v7sDNCjo7p+moJ1mMWGOGkqRIL9qfaeUwOlI5VrHnimHsuU1fOv34X6ZXoPi0MMsEjc+OG X-Gm-Message-State: AOJu0YyiupEP2EUvAjp4l0gFbEbeWPojOrex5SNhheweSckGEp2y9VGh xG/77gGaGvO5dLu2mmR9+xK5xL2cmQ5AYpeSOj/GFmOhiZCW2+w8yAfAtU8cT5YXw4cqSan+wCk YFv1CEldmMZtrG7yNqpqSj01iQKPcsUtg 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673540 Received: from mail-wm1-f100.google.com (mail-wm1-f100.google.com [209.85.128.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3406A3D387 for ; Fri, 24 May 2024 18:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575280; cv=none; b=HXGqCGWlN7BfBiXGrxl+Ao/SFPimLcuCCXa8XC8rkdJsI4SzTX8Ywf0Dzvv1vlFokBkm0Fr8jG+WOzp8LgmjamK/aTaH6FZmAOTU5ONptIMLW+R9nzl3xWI6oiL/v6XpxjCwHv4gmlBXAwx1lA1xJ6YFNjwh/3G0r/C9rCHMfFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575280; c=relaxed/simple; bh=z+GE4dD4yPnc63WvqBNiPDl9b7TaZQb9Yc7IQzit1Hk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SzfpDh5wi6DViZ3HMiW3AIotyOhbkcjwkBWqucko+bsfxgVuQ+q5vee/tUJ3OtOMeceJpBB+/4LJqNivBhvN5iwh39dOWP0OgGpGhpi1Yz1Ek9E4h2pLwpXMvn0FT8gkbpJ721CV86vsB/OSbHrEwLjDvBSgpUzpM7ON36fTkFM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=Dc9AYa0h; arc=none smtp.client-ip=209.85.128.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Dc9AYa0h" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-420180b59b7so32821345e9.0 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=vger.kernel.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=Dc9AYa0hTWZphKr9rgBXa49QYki0fCu6QHW7ASVWDHQXTla6c0OVa+PPCb+IvJrEyL 70Gyp66vyypP1RR+AoNJ/gUB1uhyth/NfABPlWvV0rv7fi0hlLbJDbdk1L8tKr6JY6B6 em471noo7L/LOOqzXobq9HYA0a1jnSuwtXj1GaoHEJxaT0SAYHQ6GaImeFeCYWi7b7sH cew7CfSNky8qR2K6lgR6Qj23DI2B/ybeEnswq6KDKxn0K+yu2ry7W0f1BQK26OEFFdGj Yc7fynQt/OpMGE/dmi+c6US8v71HJkzcL90qHHADUDyLTe5y0KOEe1uQqkw1u7Qwt6Pw hx2w== 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=wux32G7BES2rgKgV7xRLVCWLDZyk7ELRRUjxxEIpeMpjqGCf/mThXimpuvJa7KKbYh 61uKd1LQXo1vWCBDBZhEtXL5E2h0RvY7Re3pmbPntlLMSRn3FZqaRfv1MaldOLVQprsH aSGv6V6NkqmPlTjkaV5DB27PsZZ5+Q0f5OagYhPpXOVFhvwiSr433mwC/v5W51kr5zZ9 3XgYv+TFKP4A7JsScEhLNWOPGvCsUHeazwAuU/O1gDXgdzRAu/SNoHP5eJ1S4aEsd5RX nZ4qQAa+GTyA7HL1URxtgDT4ynOkOEd7gfXo4ae3Bo7IQDP/QnuQQKrgZeFuHH0LTzPh kCDA== X-Forwarded-Encrypted: i=1; AJvYcCW9fP+DPA3X8UhEFBQFNmigeIpQ5BGXA5QCWkGlfNcM2kxZxkXbXe+R+RIDzcMqAKTrwxbYdJ52mpRXlAIIXFavOujDLvtX+WiL X-Gm-Message-State: AOJu0YxKb1C7QES4ZaE644+tN3KhOc2oO5YGHv8D4fJSrN+ASc9LauxZ DCa26585kUsunpmwh/8tPmMUeljMK7Cv4MMl56YAT6xnlx2PHGlUzsbClov6qGGps5uAQMa8C+w VgvhTzIx0LYEO1eU7RnHVAvf8vXiSuB9l 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673539 Received: from mail-wm1-f98.google.com (mail-wm1-f98.google.com [209.85.128.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7D2340856 for ; Fri, 24 May 2024 18:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575279; cv=none; b=qgLs7ip1Wl8ap+qb1YlDziTi/sbXfZRZeQdQj/U4DlVntBq4Top5X5Fm4cpTOGDbzd2T033QR6QVZc2fjHzHVhTBu4lCYibZi0zVOErzC4RzyoSRbidl/uaVOTdxYHsbanXAPWBTcLpXkxxgOcPPC0ZdjX8mta5YK8AfRI7eBuQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575279; c=relaxed/simple; bh=uJR9uKYukjwMUHwhOo3zWcIKx8YU7Uzest2LYe4K6KI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P27c90uhbW2ysUK5+2WLjlmI9uWNaLqNdcaravnhtLP3yeuP7YvFhmKT4sMBI2QVuP96BReK6H0dAW48nn1AeWNxCD4yRZttWcfz4BG7X3hePy5U8d3skRqz3AeYKsSSV0JDSkcTVJPL3Dd6SZovDtFlEM9sPL6rme6QwKDRIpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=KelZL+Nx; arc=none smtp.client-ip=209.85.128.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="KelZL+Nx" Received: by mail-wm1-f98.google.com with SMTP id 5b1f17b1804b1-420180b5897so31804635e9.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=vger.kernel.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=KelZL+NxJWXtNt1p5TObgeYeTIYe/fqNpTUxhf8qeRC/yWBeBez5iBn6uXJBJ43U7u dtHcMZg/CAs7F9+mWArEWGUsKY3LxvGVx1eGZn/8ZJI1A4JAGB9uA01FbQGD2SXy9QA4 Q5EcuvMJf7PvDGqmeRg93i93r5+6ph5d9sBIay+B9DZuTKbRpdSt4OKv0OxyEkqi1Nr8 4EJdXAJ+4WW8HMyeuKOZR11SgP2T3g9mKEQTteb3+m25rsnjhrgQ5mIjdEs3w7PTJ2w9 md3vwFFld2ioevQ2Yx/dgbI2EhOdQjMZ2wyyFuYXGZD4aT3nJFHbWUoshbtItGK7lCku BR6g== 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=UXzwGabnaBLOrzJGWgX8s+NYBDFETu4eN1oq8ULA+wgT62my48E0TTGaE16bHHT9/f 7fa9mizNLnNQDgfh8VrwBjUfbvXWSK4iOq/hgBxEsepT6wF25+WbMgPVUSdhNvtUmlE5 8jHmPzit5zU5SE8K3+C+JeMlireO92+8GF3vMTmRxeMq0xIUI5DL24PiwJps+UGppQ/d H1jDriWa67CjujH8sKdIgzYaioBu7M0ldQogVxjWHy8fnC0g6RqTxXMvh9sUvOuTccuQ YgofycjzSKEPCR5qM73KHGseakY13FnsFi5c2cwDmnnfU/z3ohMevixwbavlDU3ynS6H pRAQ== X-Forwarded-Encrypted: i=1; AJvYcCW8854Yv/lgOclSDLHZSg50JSZ1bQ9lXkIO7nny/D9+LQET81fX2N7Ga5j+BPkiEQ+d2Rilu++ZwYho6VV46y0VuaA0NvfZJwEa X-Gm-Message-State: AOJu0YzYC1GpixXubYyXvlGdQeiSCWlKSrWkGklfLFzJXEgP0acngMdw hUsWcczhRb8cFaHWgrN8ROr5DoVi0TPUfC1/JREXfYejqWHLJr07pgR9OI5HU1SFBhGrHOKPh+J Vcqs6VnYEFH0PtNwDTcPuI/wFBxzgfNx4 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673543 Received: from mail-wr1-f100.google.com (mail-wr1-f100.google.com [209.85.221.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E79AF42058 for ; Fri, 24 May 2024 18:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575283; cv=none; b=K5NhWcotgYIPj4qfROwZQUrdnaU0u64/rR5R2RmuLSxpnLaQE8MR9x+CQPnCYpIzogi5xDqVLFuNyl3fMYLwo6fTJXKI6Fp8r6LL23+xzjgLHiXGXnO5VZFRQiQC0JChM9MQCmUjy8Mgye3mln0MvExJs+x2H3DrFt4pOaqqfLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575283; c=relaxed/simple; bh=nfU4i7o8p143//pVAQIuLJreZUHivVRGYWOYdCfqYIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tfuYzSERzNtS1QAUvo3mAnpl+Vo+S/yHVYqpKy2y1X2KfvnpxeqdkKMuUErNMxcHkVzU7bGkSxDhPqyAAzIpWjC+cpoiwo2z7AEF9izKrSmqNgUZsyR0RvlBonG/eh9UGV20Fk6pkGkqdBwmqz7qcCojxAUttO3t3uVwURM6DXg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=eZ6RhjaH; arc=none smtp.client-ip=209.85.221.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="eZ6RhjaH" Received: by mail-wr1-f100.google.com with SMTP id ffacd0b85a97d-354f14bd80cso2166806f8f.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=1716575274; x=1717180074; darn=vger.kernel.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=eZ6RhjaHWn7JAwBMH3CDTN9O3tUGAubZo3Q5rnemb2GnpUMXGD/J7rY/ho0nnrYRof fKYmq97Yai6JC7D/2b6suH3E+kY21hQr0DRSR4FnWZ76bWUmz3f+VMfdKdnRCd1qK/mo L9o2+IqFsf+9nRwq5s7lz3DpKsyaWJnpXl9rH1Zs+er9AFMTy7kwOhuDeb16qZAifCPj WAJGlvHghsGMY7fSWf5shWzjliTfD4uvH4Q15g9O5q//ZCvpFZ/i32ODtqcogCbT8Vvq JuhxQXUvIseKuZXb1pOpft7ohXUOW1Nn7NRCl5xkXtGQDJluYo0cCXHcXe3jsSqyllXy qfpQ== 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=Xtf95hAJExhImXmSMhyPEGq+/iNEs/2Yz74xB2EegCJFW3B2rfgwqajvFhdoioR2cJ b/eY6fiVQa5NRNeykQcdtoW+iPM/odi0qgV86/IaRNYQxRFe3dzP9dOOKf6JzOkaYX3B 0DhADGyi0ZcOIfuWfq+49UvDwJaiZY8Hr9fypoL0GMTrap2QdbTBIKHazpTmcTNnYRhb sb/Yr6wqmhuV+fDU4LAHgK76bsmDMW69DnX7k0Jw1NmBc/zwzM25gJ6LSJVMyZSHEH1v NuAxZ9MJAfkAbtA4ISTf0QKo3y4ZtbFJ227tru+4lSBbBqmNu4j9yAoHVj/z9YGlUNSg g/4w== X-Forwarded-Encrypted: i=1; AJvYcCWpUHOS2ilzJGzxJ6lmbXzVAjTVBQE1TTKlje28RyOSlcMmSKcYMggxeZEko9zIpfHfuVCLH/ElC0v4uG2rNTs0mGLLqgp2bZSE X-Gm-Message-State: AOJu0Yy2u4s0cKkLUhv+7KtPCCjrvU15MZ1gSRAqJQ9d2ZsAc4qFCmOe u9YgrbpufrpORV6EbynOl39mDo8+HJhJYMP7g8M+Yr95WmfJ+9CovUQW4NWvgS0lhunDqBG1t9P HHg7K7+WF8B7ChznHCROXmSnS+ep7BFvw 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673541 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2F3343AA3 for ; Fri, 24 May 2024 18:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; cv=none; b=DdR/3ap6RisjILhzKL6TzgAXMY7U/4YmH1PzleZPAyZktpmEMDkOU+bjzl6ZXg8ID9AN52/0sR3wQ0a8Oie3kbVg7HdNLvVmPgVLjGsfxIXeu3OacTq2Zn57qb+afOj3i5/OLS7eA+EnYmtxgq2owahaNB3y8P8o6qSAkTfcMB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; c=relaxed/simple; bh=q/vPvexOj8BorMyOQXoWhY2JPB5kWHRHIatWLRoYFL8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gBZM3S0qijQ1vPbAW2zd4RJENUb3hPQaUCVqh/fIWUgNGeA5FfrytGKpwpQ58GnEjoOOG59g8Lk2fUY8GOqpFCxbkTnXJ3OAUtlz6jb4BgzjKXf8Lpf0LwwBKonRzlEOJZf+RTQQ5Cp45D3YJojRhF4YKpUW2vApIzxz71fOvAU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=iEOZDZFP; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="iEOZDZFP" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-4202c1d19d5so64558905e9.2 for ; Fri, 24 May 2024 11:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; darn=vger.kernel.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=iEOZDZFPhCWfBwNhTss3azICVGcHfq3YdwuiFxHNXSYKe5RG62yeX2/HLJGcEETqE3 DeltBSFm60DNjff864htX9sXlwhdcSLoGQQjpTqFudGzUROcVjUNbSvcbRr3ngaREWKY wUFXYh5UrbK6mzaWMsDbSi2Ww01xc/j3vzRoQ/LijUsgKTjPyqm9MRzyFwdT6x1OlaAl dTxdTyduycLLrZt7J72H4iJR9EDsfvAUA/Ua9sHW8BgflLeHfOr4QwlI+E2fXZvc35cP OdD7q8PVTQb9RGjptftuRA9Iuq8N71mz9B64qtL7JnGaRd3atLxS0WlB1e7/BZJRjnLA QYqg== 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=h4PbGo72xJ5RdoPinGVIBO4e/9mlKXdTYv36aw7g3x24JxJH3tvMmn9uC3mw4vTvwh IgghxODrPaosgCG64MsqO8oOCyWtSYRqCPMVGLqjbWn7gdQAs+dZW8PnXwMnnBG3Qh37 WqiWA1BDQ2gmy2bE9+f4FBvr7R83sqXT5AUksr3DS7W3DHsKXTO++ZGvAH/Kpu9gx+oe NcCxHUQWcPl8AUiJKZv1DNTws05yGeemcrVbgs3thHYnfMc2j60FlrLeIZaLhfiN8Y34 oi/aBB6W2b7B2x4yvj+lnfSQ904KY07LavZztFx9GOPFZAnEqB+iU7w3hz9YBRO1A9EB 1a2Q== X-Forwarded-Encrypted: i=1; AJvYcCV0sBK+ENXcCwcXkJeFR2OrKwISdV4qxzTcr0MCClbNH+rQaOUtE5AMGRZ6enNoRYVRFrXo7gVqlFlshdAtObCl5vVcvODlaKWT X-Gm-Message-State: AOJu0YwKwQcO6qQt5J4Ncb9CMFDZalw2B0wrxqXcfR7hihVA0t+7Um6o XGGgSB7LEQXFG25eJJgad0FUsoWPoZwqogpN1EuoZWCNYD9P4BoRg8AtwSyFRpulyATXPPg8PXg cHutaqDVFYLQdR7355k/rLN1xMe8qFB+l 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673542 Received: from mail-wm1-f100.google.com (mail-wm1-f100.google.com [209.85.128.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE47640847 for ; Fri, 24 May 2024 18:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575282; cv=none; b=mlXTnDTT9cKecsK92EICRiK+xEkJvouBjxZizUZ6dUooLwaFfTWKMbnXqoVdOLUI3XAGg0Wenx9wQloTetwcW+KtX2BbkZAlF//G0Y0Zytj1dtAm5suVsfPwoXHm49HvU2vstlXn/exugd+Qa2o+7uDEUvXGofUgkA7qLHtVme0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575282; c=relaxed/simple; bh=CyDfQLvAvAnEQtfGBunWvar9mbFlVk8eB6mLlJLEUOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Mr9n8/xWm5JRoEzQ5GROAMfFaLlkCBGYhKygDmbGuUCPBZWo/ImyGNxMqraQZ5ESLvnPfoh+dCllRtfyAUTEXqQhWZLg4+7kVRL3KjyF3zhLGSVIhHFZIvHOqlr2fzw90u3MV2cbbB8DuwHFtD7DluZUd2KFGgBZod8Uc4t7P98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=EapH5Vzu; arc=none smtp.client-ip=209.85.128.100 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="EapH5Vzu" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so88861685e9.1 for ; Fri, 24 May 2024 11:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575275; x=1717180075; darn=vger.kernel.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=EapH5Vzu3Obz7Ahca2lTgBLMN9X9XWhFwgHYbmtbRXfH7GYK1sfGzsjTP8n0kR1XLu iVSiPvtLJhD/y2WKGVMcO/vSW3X2T+YdfgAKsmoWRrvUauSAk0AMFVm0Pw9I0xejzI3+ KnU/1V7gSLLv78YVq1d0C14qrNw/cnXB3dv1p1DbpH7UBv5iGhVkFlzvIoWQUIUHoo/6 ZuIosgYxpyFAGUtGxbIF7REEP92uvoPlP2a6t6Z3l6G6jqYgpHfMO3JRUAAADVSCjeNH 4ccZUzmKFtd7hVOL25cNAq+z435LauLEMx+xlT1nzZ0iJSsZJX+DAhGJgYqWOSvUBQg1 uoyA== 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=cMIM42Pfpi5mL9nQoyjTEFim3C7v/HZlXRvkLLxCTnHq22f8fa8VdHoeN28NdfrQGX SDGKrSvhs+FUcX4TtSMHMRL9E4aRDk9Wa5LG12iwVIkaVoVq57+EC7+6ltj8ZKTBJ4Zu 85oGexhhNNkga4QbBP6bLSBHZVGjUk4jNKNeA4VtMNjJSdZHW1O+G1K104yRaXawC8RZ A37MsFPjEOOcghrj3IS2GnyTm2uNNnHj4ZIv1Urx+vcpbmE0N+HmI0Rs3/gkymlG3vsb FUzwDAtlzj0KMfRe5nm9baAa/Ne04Y4BVvbzKf/dZGgZVeeOWLWoYzQvP6c5q38d1yB0 40Uw== X-Forwarded-Encrypted: i=1; AJvYcCXXALRGOekYOyBTkOptklTwWoQ0gDfNgZ5alKPOEML1V1h2YP0ioaKeppOvLNDvhcm2iXQFrEq6Fkpm+ohJ1X6YgzmjCfxlVVlz X-Gm-Message-State: AOJu0YzTdgTxjNbUlvzDm0I4+VHJClzr5S8+sfPB0K8cN0iCGGdxm28X 3uqy5c5f3DVvmyVrLvIB14Np0G/oNwd9u/jpB7iVwQE2qX80YmWEgdv50VZlphGoJwenCugnBXa v2rrOIe8mrYMSiYVDrz/y8CExiRiODL6E 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673545 Received: from mail-lj1-f227.google.com (mail-lj1-f227.google.com [209.85.208.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4115947F4A for ; Fri, 24 May 2024 18:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575284; cv=none; b=cHHUMk2X8Uj8ERp26lzvBHahtAZivjOIOKgJf5ZCIHkeAoABsiqDDTtOgOpUuXX5GzpwFPvGG7sQdNQeMW+RwcjGXDrz97vWfzEYz6cd2K6Wg3UggxNcAKYPykk94HhbUYGLX+SmkYUhQmglqxP6JxNcpvNYy2XYHp1GZ9a3eD4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575284; c=relaxed/simple; bh=HeQH+726CyNd6SDwiRedJyMRoX6cs3MUOfByWaM6V4s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kAeayTrkiZhY9wu046f61IzMde8VfVvA8HXSrDFEPBgKquhigbHx0ZLBSAKcUUXfS4N/NjzZf5pC4bvWOUnaXZualI8WeV96J6d2ZDK1pZ0VNl66RXL5oOd9Ql7k279RFCy4n8TV9EvloVeeAel/HxTaNNCai1zzxHcVbQj704k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=OnA3QUt5; arc=none smtp.client-ip=209.85.208.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OnA3QUt5" Received: by mail-lj1-f227.google.com with SMTP id 38308e7fff4ca-2e576057c2bso136105471fa.1 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=vger.kernel.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=OnA3QUt5z9UlqM+IzEmWliXQWN3Vih7wB/ZkTOLwpyO5zMFF1eG0xzF8cVkMtptg7U E7gm5r4ljsNTKp9a9y0mu2ieIbhfXnGqXaKXkGHy/ajn67eQPrp3NAEXoD1JA/LH+FkZ BGl15AKaR2Lwtswzi59KB61XRm/fOmKlXbNcsubDNI7OYA3AD8DI1OYsfaNqaRTkv6nk hpsKa3nN8GEvn1TR6M5mqRFTmFHVsE0kMYiY9+08IxJAiNLHW8LvvqEUSZyYrtxat9oG nb8ChHxsIlAdRQymUTID5X1imGJLXM2nL7WjmN5Y5FP9UZE7fSInfbCZvrYqeKYLR448 dhRQ== 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=RsqEuC52x90fJ4pCm7stBZ1E4mCnr6TPm0NOcQt8aJm4qP8pp2xf2rhSZYkyRRsvE8 f5BZct/rU1vPUtTAIkFDz6MdGXBm1rlALpyMZB4yTkOzE0hpVZxGfCBZDqJpysoQqtH2 tqo3i59hGj0eDeGsuCyvaFvEUVlTW1kQAAKJRIy2LE30vITSX2dG+/3UvY1RsoafdcWK 5p9+xtRvzipzq5b53VKbghl0ICIMraNuCZOUWqZeG751r/sYX8TqB0JXq/DKzmVwwbfn PSvDtnE8KfE6iXKkHJF8V9nNvF9V6FWsSDVQMNFpCTDwDhsdFj7Ql2UYOUhJXQDgb9H4 VW6w== X-Forwarded-Encrypted: i=1; AJvYcCXHVfM95Ume9fLpuN6epyWPsl88XgbtLIv2QgriNYdN/zu0qxE2Om3AFkOkkkon+hOnYmYS3OAmFroDz/sPlEmAOZXY1k/KPCr9 X-Gm-Message-State: AOJu0YwbpJKcbTx1ISsk8FurxVRs0NyRaRkAeO+v5qVtMC33BbQLoq3S gENIAhEPqzSBeYaQa92bDSwUschZZjq5oJd9p2BFcPiII9Cuf80b5jY3AaC5ztED7z99n00g45U Q6KlNjN0EhUZncKdWOHGak0t+t0m5dmjX 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673544 Received: from mail-wm1-f97.google.com (mail-wm1-f97.google.com [209.85.128.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AD693FB1B for ; Fri, 24 May 2024 18:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575285; cv=none; b=DPZ3/yYxopRFy0vzwIWZnXx0KqE2EU53MMfbsNsYYrE/KejBPKTOqgIo2aAOR3V5Yixun0KUt/uWmivUXLuo6yh4n9o27l7RA9Qcpe8eJ/SD9SV5wHRY6NMDdvB/RyrtxdLP8VQcWGcAN9rlLW6SzZf14Y/Fq89AnjqKqrn9XqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575285; c=relaxed/simple; bh=5nrl5uVGiAQbueZrACpZq8a6cFbZpWvV3c8a8/I60FE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nwL3jMqL38yMPMZMu/q/M3vVWFgC8ZC7WQtLAHxn90bt1hpzijvBCZdXhlLc/RruSNHV8bv6pLKylEbKTlFo1F1INAnqGk4D7pUZdR2LgffYMYW0F0O3Dx+8/lRoUmeSQz5+3/FVdwVf1ziQU/7SkMpiQJ+lw0Y+6xcmuFv33D8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=M65Q5Uek; arc=none smtp.client-ip=209.85.128.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="M65Q5Uek" Received: by mail-wm1-f97.google.com with SMTP id 5b1f17b1804b1-4200ee78e56so33901755e9.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=vger.kernel.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=M65Q5UekziG+lHvXQ/hI4nw4upU5bbNJVfgaHqEmGJLfmLg/wnt5OLrm1bsxi3HXHe hMi+LCte6mD6ONooYUmb9MJGl6n3IO0se3b14h68fuMTOAqkPm2JK3TWzOvNuHEVa8Md vNqC01pAGWD0D4ZY7ILTvYgxGTLmHYTdqM0IhIQwdzsEb5KbMbI0I/NQ7QIQaRlqERmf LNPrD7IrxfR6TeGLsMCnZfRaym/deOUkUAGgaKZvovawuN3PG3YHcKVtAWzw/TNDMOv/ 4VSeuFQ2ODyw0fdTrGMkIbOvFA2AsMEfAVghVKJwElD2ONrMLZVAmj+yW2wwG43+xpzg jhDQ== 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=Pxyx3IuAWE54AHHjdfzZJcyWJqlRdkywtk+2cZ9wN1sa3SM9QSlXfmnWv4d0vs8kDc WMfWp57fjsluDdAb2ZDASBc1doEyt0ab012JLY0ujX633e4of1AmpBuj1afzGRcBrccB JdwRfb9hk7JfAJdYVN4vetvr/c8N5Ry6/STCPEEpf0xiiN6MOoiweYoTNtqtcI2wGZrK Sl8jSZY3mnbHil0li/fm+dPHvg1XTLPlJe6qaU86lKlfVSOYhE4xz4ThF0RqKXsp8eJ+ 1CUms7+oRWJt4zl8t1DWrhBWJt94ICaRK/V07v+dJ3MO7UYXYcL67TbT+Y1HmkyJG7Cb WTXw== X-Forwarded-Encrypted: i=1; AJvYcCXVfcaiYgI9xiaoY1IDC47LDjNJ1eSmIA/OcnvJG/Qgupe0KiUiT4J2iDXnZzPny1/2fvna4Q3924iax6CwhP05fsBCsrXFh0p5 X-Gm-Message-State: AOJu0YwH/Nc0zNA+j//wG8jlMps917mZubIajVERYkdGVQcrCds4TB6N wWDFPYdh8A8Q0tQfihmmlZUFeFeMtXneToQUS+gkOYhC85N3PNBpnY6ZeY+GvIDYx6LABKWfeDI bdq4dBiWZ0Pl7dwgN3V8q/w3JFpmFTW8D 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673546 Received: from mail-wm1-f97.google.com (mail-wm1-f97.google.com [209.85.128.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADEF43D966 for ; Fri, 24 May 2024 18:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575284; cv=none; b=MTfomvmqoLQn6BWVWTNjpSls8yZT2N8xuFhtn8aKFPnB7OAugI0gHyYM9t9QMRyNuascFWhup7J0LCSZgyZuOHZtvxoXhKUs9Iq12aLBBMIhAXmwLbFv0g4kGAQdsP/4IlSw/k26UImN3Xnlc/s7hexaFqjkSjZRBd4DKM3Q60M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575284; c=relaxed/simple; bh=NmaIHsHw8WolTjTf8xLqs7ZWhcp53cyRuvb7LqWTrw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZEJf7VnxDUBGPdajQO5mJRj94/hPO+6LLQbN8pmYtvXG4MasfZViXnWkZGqgC6V1E3dA8kds9/U80O920YgmTOuuJXu1IDnqAPB6YOIQ6dzFdt7+TsZHoGuml3luyy86qjlQ6fsuznDCdgYCVinZSVFyoTLFf5NCf3YrV2Ki3g0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=Ivg2B1lz; arc=none smtp.client-ip=209.85.128.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Ivg2B1lz" Received: by mail-wm1-f97.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so6627315e9.0 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=vger.kernel.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=Ivg2B1lzQOB65xO+puBtgL2S6qry2wIhL0nqxKhV+9dRpAxgaz+rNB33Rp7eaU/30q ujRQZ3TSj225d69JMN4Swvp0d3Lxp10tMvXF4H6UkJaEog+PMqYolCEUco+su845XvmS C4tfYKO0kJ/NmphbySPRaPhhHCNEpBC3G2S4p3BWUrxkjbtGRtCNhxkcFYU9nuTYJmN5 sjfcP/k1lyWgNDulJJHmytqnqf0qP4zXn/eFGg3Fv0RCwnjLkcpqpLemBbujjT9mQfnQ 9KKDA2m88vM+cCVNx72wt7TWdJgglNT2o/vEaHYdyW0GeCUYRNTM1GqNj3xnkrpPPzgc Mabg== 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=gbfpPU+rqIZ/S7YgbWprmGzUpKhvAYT7ts3yMMucvsRtASXU+AunRuqQcZshDpMjP/ kKCF5E6jzD//HDpyXB2kLqD0qHkyOKNgjUO2pnwxWYNNyDcaNVYTqD0tWGGWlipo+syT qRO2YH8DTncInBROcJW/ZeO8Ep5CV8knCsooMZZs7en3ui9dI8bjztWOO7UAfzViHzD4 9Pr3xoVjpIpbgZ8OtSBZ0t8nON1ODEQui07I59iITr7iIwSwdjgm0TS4XVipJmcsZdvE ckKy+QHX3QxCvIithv/ADtKCiX7tYgAFYCx+5dsc4E090smgptC88YODWhWMnmJjthzu dANg== X-Forwarded-Encrypted: i=1; AJvYcCUQHxPLuezxsRyxL+nvgI+pgpoidrxEKDeYxkHGUUfX9X4pC3Y0i9ZgGnhTyAMnbl8ECoQHzpav+JYDyLbHfndHoJC7zr/8ZFNS X-Gm-Message-State: AOJu0Yw85OvHAc9qRUTbvByjr2v4lUowrrKVcMSVPuOjVg1OaNwg/8yL Sgz5fjW785Adnzt4yntYB0bxOvatGexV0fQHIcCR8SJdCagO1x9RymP+a+tBWQ7UpY3bRvx0Lnv qMlhmWNZGG4zAba6bHKA7FAP+vRAFNKDF 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673547 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A4E34EB4C for ; Fri, 24 May 2024 18:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575286; cv=none; b=lEsPanKqeWKyGa2FOppixN0WDK/T1HtDSoTjloiWKag4jsLXMaGOp/98oCojI/X8wWZTjTFjruzl608aIdN3Oh2ksaKdSEG3ALJ8P6F3U2Qs5L/B+fWv8Jod0rmzu17rExAEp84pT4JDi9x2SfDALFUkzMkAIO6ilHql9lngrfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575286; c=relaxed/simple; bh=vAXHDE0/SqkQsUMGiVCRffAB088Mi79YDBrfTqisc/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Cm5dEKsuDdhjE8j2yMXRdLyPvNe084RFpZrgAWH/BDClbdpOyOnr/2rMWvVb1fvIVGcEGP0qqkKpidn4+7I2R6G0mbMZsiyXkXc7bm5favSBIPJf43dJj492R8q6mogr6UNnS6/mYJPdf4qODNRpjVDbRfe0wGc7o1RBVTqA78c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=lfEYg52p; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lfEYg52p" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-4210c9d1df6so3469055e9.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=vger.kernel.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=lfEYg52pyu+DKsD80EA7rNZ2YDy7brFQQ1vMXAb1docWr7tuY1IgRRqSq5MT4QWp0P sgwiBC90cJ4/L6vugOJxWR0YJO+PP5niD7GiJpqWSLeyW20FOtsPtVk8CPck5MnCpKJh DeD1nf2R/CAuWqwhVsJtFCSHgNACajOGFjWIx30547WdOSe6frg6fMruNgUlfWwNuZMo nDffxv+b3+/z9TwG3h8mjVLJSpvQai77nfpxJEdD6RvTl1qoU0pxGe8fsFYo3LWfFPrL SGVs0gTCyCsT2qPPuxclMo3AEatxcJ7PWRRSSeWTi9g9tEkocdzYubTwdkoOmFkcDbxX Y2BQ== 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=wzDjcvjN7aZvM6mSun6rSaOwt1+HBDRTUFwU0ZvcqRVx8/3IFRSQWjWY44+WQJboUO 3xIziB/vnwt9TUIE/L625BhA2WzbXmLtH+Qj4DYwwkctlpnjSA+0WHuxASd97VsBk7T8 FF/xS1MgJWB6Vr/5QrgHR1zO04IPAZdsE5bNSBL2mmjhUPF77QiQrZF/LtWOj2Z/qUfG 5oEtXXuWVY+bLKgUskPg7PyTeRf2QB7ASxzyE0czybfiP2kKpoR5xLkXP4jv+cgg2ya1 dkIhgBXETQ4cF07mLMwu7WrSxb2NJgoQ9br2uLN8qRjU73Ap6iwYirXzP4wOwY/qZRX3 p0bw== X-Forwarded-Encrypted: i=1; AJvYcCWuR0hm50ksw31pGnsEzsnMRehGoaKzsKyL6f4Hc7wiPY01eyke5Cp6Xepbqr2VkvwrM1NEhL3d/2yH+cB/zee6CAPdz5WFz81A X-Gm-Message-State: AOJu0Yz8RpX0lDpmQlw+rMxpD9X720Wmw+ijYpunV18sfHsJwKlrSF/g 223Fdj3y6qnInbMqM4jBFnZUPGszpov4zDZNwuuoMJiWc92XBUsqKdgLQaKkLOxMfRRBUZq4e94 cSb5S+kZV3703ZN9l7rwuUvq/3BAKQkWh 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673551 Received: from mail-wr1-f97.google.com (mail-wr1-f97.google.com [209.85.221.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B65F3FE55 for ; Fri, 24 May 2024 18:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; cv=none; b=SJX+PD6MatbSOZyvty2W6UcmbxxPs/xzecfjB/jM+E99h1bnlxTm4l7vbHx0MYfRRvdS1qYzRBxZL/ft3+dKacOutSNq5n0xqcmfZx1f0HuPyYgek3/Mud2qipvAzwtkpDxSqfMm4izPN6+rnDfl+XgLwyPHBGcj9OtyWrydNYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; c=relaxed/simple; bh=F8/KqPuTA3STsdOrh0OGo7BppxoWY1fWB0fqUmwksXo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d+ZeQHgQq2KjU5pQuYfObODCvHaUST/D617c4cY+SyOV2GDUhL9uNkZvKduV77jo0EIER6Rkt6uJx5CFQB0pBFIX6U4GNOUrysi8gYeuJ7u2Kzpcb9mRYYYk4sP/56FdZKILxu5mUeOn/+IKtwbF+t2wozSBBC8CBhsraQrH/58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=HCrdbbkA; arc=none smtp.client-ip=209.85.221.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="HCrdbbkA" Received: by mail-wr1-f97.google.com with SMTP id ffacd0b85a97d-354dfe54738so2415477f8f.3 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=vger.kernel.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=HCrdbbkAjz1tSpFIwBraoBEQcqzzGcabQBgTv52KLoBobA2t/QS6RtuOifaiwI5G0J 5O0jn6BKDJmwgu+XfACyb31fSyKoNSNttHo9e+UkptKYOKE+iQlsELMZLZxGIWyP44o7 ybQu5ZYseUCLyGyGqnBZ8tFfUnoCpu7Ge1JXYbYiNCjHforIsRtz0sH4YvtpDI1bd/+E bk/PsZrvZ+YbBo4AhXwA7I7mYGfG55MxEhLau8u9cbPW3EWCDcIHk+FJDCFvqImozoCt bDD2Ep8dFJgT8wz1tv5J69punW6kzhkxd3zu7dYxF65boaHmmecBdTnJdUA8iKxuP19R tqtA== 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=FIMY2icrjEDW2eFOwgrBqSvSN0+fZQNnnjWcnhvfO+c93id3Qqzy6gY6dmeU6AxovK HEBXIIfIojtRkxz2ulxU0gRC2PEtqYNXCjSOI2asSbysg7CrBwVrxnSFCyu4spITuJjh omm6wj1WUCZNAytbNuI7pK07vdtsUgoYCOO5N7brlxAnJsjC1qe8uMljrkRQbF7z140A MXt0P8o9xpjX/VMYOiIz3VrknDpLPBReffss64nAV0tvefWfTtMGZbxkI6BiqiD/Y1pE M/UT/3Y/Ktjh0xReZYMJ2bE9Ls4wVAj/Vbjvb118kIZ4/OZkXoGyeD0BnFZrahNxTU4J /D/w== X-Forwarded-Encrypted: i=1; AJvYcCX4AmO6+JnaXBlB2mo7hYkMGHK1SrsuqY9o2FzUGiwpHQ8t0llCF/MA1lk06svUwAA6HeYj8fZ0+3R5u3J4CiEgJ2IBP2xmNg7s X-Gm-Message-State: AOJu0YwmFgDE0juEyPDLUrPtjBsXdtkh1CLAn4DZwgI/c3dmi8tsAhT1 yorkd+QpCACOymLhL6wUq4BEpsvCXNFOuiRnOmJuSd61v0CzHAUK5QXvaXG9v7wQWXji5A1zvnD UyobnhlkEjWMHDaLXJeUHy76aW8OsoPe1 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673550 Received: from mail-lj1-f228.google.com (mail-lj1-f228.google.com [209.85.208.228]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3027F41C6D for ; Fri, 24 May 2024 18:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.228 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; cv=none; b=puh66YM6Rs38ekeVIepcZ/IlhbceetpQNTzM+zAQ1TJD47MWpi9mscy84vVh6yMecEu1BXOi7wNtNZkq1j2t7SY8M44MEidtqX8sE6w3TMnLlwsTCT0RLpEoCMd/I+h+12Q3NfVrFShcJt+xkyjbYYVJCDN2qvlcCQ3Wgr5pO0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; c=relaxed/simple; bh=HegCCdIEY4pR36AZ8QiWEFIcmksLTJsNsXIyFUq7yl8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QNNaJVlkKWvauuRn8MHrKzpghYTGyyjOgrqLf4NKZfEqjjw3Q1kQpp7xJMEAwih2GUoz0GpwaNWGqoAsNWEkIBokihUdS0L2YYDzkc1Uu14JO75/QbJZblxAIb04lTuGHo+84Rihrl2eCfDIP9TSQ7EPr244unS+hG9oNtw6s5M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=pbw6huoW; arc=none smtp.client-ip=209.85.208.228 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pbw6huoW" Received: by mail-lj1-f228.google.com with SMTP id 38308e7fff4ca-2e964acff1aso888591fa.0 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=1716575279; x=1717180079; darn=vger.kernel.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=pbw6huoWpJHSkW6rnnTfQHXZo+T89snmADZc68eQy+0rB5V25z3dVo7uOfjJ0fDEEd zFOtb8HeB4NlGE20heQin92G9n1stH9HhEBMXEvJ++dDmD/nS4f1XuSN5zuaDgxKHLcH whvf3vUUxc2AL520bsjKTzHKcZFtnB95vKCUg6lpQzyO47SiNk82Rj9b0zZE9EcklSkO 1HK/YSTdz1Kwnxnn7wACrWjXXfVXdoUMyE7OlbAe9Vwe9vcTyNFnqlQ2+yVeytmpe6ku xIqExOH/FcBwmEOlQDaQzIBuDKrw4Gd6iuvvPp1lLfNK5yxju917WcONYsLkk3Chit2u z53A== 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=rQNuwtu8+nTw/Ifw67+29NwuM1inDcQ/HTLBC9yJDoCm+Xxt+hG7OmweosNwQn4kgn PzCOmQtntDVzbBDDApvR5PRN9f7C/z+ZTaOtTxfdrVjOCELvqcNuTU8NZOQZt4MOJHu3 G2FKhuINFPPcgSg7ozBlX3i0esgw3AumGyAYKOfL4Yqv3DGTMwIJFWPdkliplD9nmAlu lT6wWu+7Jkl+u1WBHTua/n58esEFbFx5MTs4+xUeIyfAFR9rgUsIowkMGIDLbDxOSr5E IeG2zVZidz8uTS1wn1zmL0F4p+HFiptEt/lDeWAIJGpm4ILlkeBQ2/jztS/ARRAIjyx+ 1ZEQ== X-Forwarded-Encrypted: i=1; AJvYcCXBRo26lagSNBlQ+/RUdnCg2p7HOzQfLAVkEknjXHOz3jr2DKaMkXFXgWVWy0UXb+m+LQ//k2rTNzWnrnZIuhwMG1YO9G1QEaZU X-Gm-Message-State: AOJu0YzU1qIXPaK0qUb91miN9huQGkYazGHs+shob9rxay/Dw7AuW/Fc uH5lJyDTnclUW2gSF1wjSCqNZGfc7VLiIavX2ia9yScZaaF5l++d4x083tEm2DqIYNSlVNPazp+ boSQRNsIKi5jCSXITXRbgzj5CFdY6qVWA 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673548 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6857B55C0A for ; Fri, 24 May 2024 18:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; cv=none; b=VRc5x5ri0T6VQQoNNvlp9eEq762UzSVTLVSOoHmtBDI5QZrlZC630Z7fDOhp/MaOYAnz3V50IMDYtFQW4P1clQOPq6ln6nhKPSK3l0DE/EMOvywII6Vo4IUlz4CEC5Z8AWEt7VzLiap3pTgeIsM/jt91uKWKIXV9LiZqk0D47TM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; c=relaxed/simple; bh=N3Kfi5rjJxhjSAGsgu3nLGQYoSBKamIirsVfmPZi9nY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RB+wVlx98Xkz9dSjNMZe4oOfEp6FQo/Gy51WU4rop8+QnUhsg9HriVthKSbqES/w+dT7w1NIRll+QAeOGlIHzTQ4vALVavtYBNxPrL03iH6DO/GQt2VXivM+W7sFHc6mw/2Eu7Gq09nl1HVCZLaeAxBC5HBNeFizpe4jXsR7oaE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=H8SvFKa9; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="H8SvFKa9" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-4210aa012e5so6627745e9.0 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=vger.kernel.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=H8SvFKa9kcI0I/S+GtybgKj6wteHMsd/mvWsk40hg9y3B5a7budMlqyQzjhI2tTyuc KS1R7UFxf0NRtU3gcoSd1Xk7xdRHs4khoOx4koY4eZU9PutbV04+vkjrh8hStrVcaHlg t7Y7FGGkUC6+hy4TOVMMMSVriHxTRMzyUfZJWiuWS95xvP6CCA5KvqTmZHtwc1K83yZ4 IVObWlnssFfrwYMea+b1gDqGMw9dmc7pXVMGzhz14ec3Jkwo4QG1OMl2sPf24xh9+KGG xWRJRUSfo8lhlUDrMtl6++T6y9gppJYBvtcN9D3913uLH4Ho+c2t1cRjYmcJfoFmrmcS EhtQ== 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=AzpwLLZne92gZJbjyhMjPY12Whlz7sS0AFvrN2iNFKamg5BPNIfYxEylnvhmMl3lFf k5HYyRyI8LRjSAxAlbiKxyS6qOFKAClqsIZvdzvIKXoAvtiJy6iKa4SCwI5Ek/vtW+lH GIobMW6plrKLsYIAF8qkmnZpAPMENYFEBpCyVzR1VcYmKEAjXzMme2icyNGh2udJqArM Rg8N+pWkyugbsu4StEmlS9Sv0a1HGqFVCQMBmm9F2pKZon9wIrwZ9sDrWzbHcOWLv043 MvA9MdXvFpbTTCxIRfX7kJRu/tEexN01CzzN8pFzYNH6ivFFJ70UaO2b3YskUP9GWM/m 32Zg== X-Forwarded-Encrypted: i=1; AJvYcCVrUC/+Ephco9pvqIzQtSPp9489HqXNbrwD6sxjGV10KI6ddQuwVWWSd4cB3wmWWEBQoZ7GB277CElgTvYMNxg4A81kulJZWiUI X-Gm-Message-State: AOJu0YxYRbXGP//QNHCBXJ7thtqLut9EsA7rCKSJr/yWy95HaNiqOE+j CPHxqXK9gUhFR1VlhEPUo1sKuKuBVMdpvTchViwzdh6Smu0G9dARwA5BnIL0Fc7Sl77YD4CGyVy BOpf+gTkSbmY4ydmypg8WfQQcEw49QlQY 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673549 Received: from mail-wm1-f98.google.com (mail-wm1-f98.google.com [209.85.128.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14D4E55C3B for ; Fri, 24 May 2024 18:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; cv=none; b=ooVKBc1FGhiyhW9EFGtRjMw7UipIEabWgYo+Cl5bE6Q5QQDgqHJ7sUz0grPnWIw9y4FkALoFtF6BOyis8lsK8/r1uV0TaO9ayfKFwdnGZbxHfGsdJxuVAmYm5eeo37hPMBSd01T9xKBJQqBVkkSY+MkawlxfDcpmAnDlMqmvang= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; c=relaxed/simple; bh=WfcHrNiYZ1rUh5ZyFbpbA7wYQtF/ZVKkB0GXxiX6I+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OxjO5iLhhvRXwIqfI14kp4fIED0zy1C30jZvJ+cSdb1SXCSYlWoJSSXBCQwZotnBE0iW+efFPX6I/Ffbn8wJC8g6C8wglZDHM5+Q5hTXfzG2eF3Po0l5Y4XbmGKyIbp6LYB7IRIN5FTU77KgvV/w4MX4qO9buPu96BtONb3nLFU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=l0IgCMzK; arc=none smtp.client-ip=209.85.128.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="l0IgCMzK" Received: by mail-wm1-f98.google.com with SMTP id 5b1f17b1804b1-4202ca70270so41003355e9.3 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=1716575281; x=1717180081; darn=vger.kernel.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=l0IgCMzKayqPSpiSaOfEjaUxi7Xb5gpOxwaSeJeBQW4L4hUjXABzfWycLEL/u5Dq7t gu7ojxEmvGT6eeV2pCKUlRGjiGIuh4uJktn1c51/v726sTlmuji08gdJGt3yYLevm/59 gqvcaQh2knAcmzejRhAtS0yk8M4cbOkqS9rFNVPBDc//B7E+b2eaTJTTBIg8SMFSkIA9 06hbrAC/6JviK3Np2dd+FTYCEl168sR2y7TgDVDc4Lc1Xd+GlfnTbQbcXeZR0ifxM9rv DD4QIDmwMRLiZE7rY3i8NkR2gyCcfPK9Dd97mbkP1SIfBlI1UxzBez5y8bRTMmj2FCEa W4Kg== 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=U0fkVyk6q1d4tTjNi28+nVqK2ri87Lnbs7bXh9cTiug=; b=N2khFJbnwrHJsV53rhYtYtPj7KDVnqgFve8NDxrkcqdXUV8R8/cSFw6tRf2eecUYkU UpMsL8g8DkRX2o+VzfpdxQUcF2N9EHiFEZ6YfUOL5CzWMHlnhzge8NqaClc/nID/tEbH +0O9tqIfT0EVR6cm454K1P8Cly57ayI33EyPcKmTXPvCiyM10d4BJpajMP4YMYbVENC4 DneiX+JNHeX2tsqvuhTdnLkTXYrrcmn23/x8xJFcI1GavHPAHOfxEogefpZj1RWBhspn sP8PspQdRlSnQOzeSuV/+fZ/szfaZ18AJjQusRNEY6ywcIw4xoGhUiCM/dVDn3/TunaT TrIg== X-Forwarded-Encrypted: i=1; AJvYcCU7hYnV3xnxZAZFSdCXfnpmJjd24ueB0rk0n8iTStKlUOm2HInyJh32jc4/LNdtG93JZcDYV46y+axN+H1GpjK6U4hu68d6AFpb X-Gm-Message-State: AOJu0YzVxBYFHIvF2Ptq+hTNQL6Km24IBhR42CWt0MwkC/jkLXT5t2vC VirJq77mFS3zkDAZlh2M65niwo+dyIi+ABRE/ZDlxPAN8iXTRVG7Tu+gVGDwrjeZcWpGGziByes rE/oovbueFXm+tH3ZpJZzkkYHChKi2sfO 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673552 Received: from mail-lf1-f97.google.com (mail-lf1-f97.google.com [209.85.167.97]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 575D859154 for ; Fri, 24 May 2024 18:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.97 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; cv=none; b=RU3PORpDPVQcJK2yl1FHPbgl1LgXRiMUMtE6pTb7h+tCmRmxY9q84HDuENCrS79OvbPaOSR5eKYVMadvMBD6Ge+IciZQyBdLAUFidxBaDuLiRZsFzqIJD6WSbVRsvrOBu1e2P0DCJVMIJTNQHohRof4qE640HjQ/617IAbwW8N0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; c=relaxed/simple; bh=txNXDmI+i52QByifcvV/37TC8rzKbXT7VxR03bSa2jU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bAsjp19r4x0HKfTqGGIoNUuA94paUYrI5OHsE1rIoElgO4hlHgDTEmuIgLm0DBSz4Q86FQtpM/eeIOGCum5fRAJKBdfAznFrwmqhuzJArU0RONiHVFjJ+xrVBStumxhm1fcy8kfXY2/LN42PU2cbc2t4NmJqVR6WcT0g3/5yZTk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=DWX27F+F; arc=none smtp.client-ip=209.85.167.97 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="DWX27F+F" Received: by mail-lf1-f97.google.com with SMTP id 2adb3069b0e04-5295dada905so922755e87.1 for ; Fri, 24 May 2024 11:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575281; x=1717180081; darn=vger.kernel.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=DWX27F+FYPicuIZa1Ly0zVJ2V8kTJl/XLQ777SJ1Hd1qUT4ovexKmYiFkuTvofQ7J2 BkdL6PrSmM/2M4+0AEBm6WtAf+eoXc0SFBwBXBkcG8Y1ZQCl6iGWLGIbqYbXzjuT5n5X bDq30nT6w4AqYWVxjcAgrKx6zC7K8rakbmR6EvgBOuxZ2Lqc5tV4I3E8vq68MZqPW13w WIiaP4uGAvfTe0bhZ2QiAAOocI6hJ6wWVgqDDKFhZYtchxmoolSWDQ8sthQTiLR09fOT xCbDAfDJPIuSco9HdJYMIdWvaOi1eKFuAql6/y5qFizcCoGINKIzcwwsWTryzdAtCEY/ 1PyA== 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=odI7uIibIOlJK147DDjgyoVWRwoo/594Zd7gWN+oLsf7Hh5es0Gfag/15QEgDnS5Ar h4TEtmR3Ak3d+DajLtKNxwpaUHGQ3XcCTVo7YXfvrxmBeopA8eHACPMSG59Hl61fSOMZ 9GepOlJ0H9/Mobp0RXmhVtXahpGU/V+CasVu9m7Bo7Dbol2KTr06C8MZ6wTocYPlus4X F0Nr3NdkF4Eigze2oPIARb5Lv2qCTfjte1VnOklulusHC2j9CHVix2xHoiKBFH8jWNRc iGjzMH5HWrxCvH1NX+m6S8fruOOvqZugNPv5OQVcgVxrfCDFVY6elB77Qv/506z/rLQJ PrOg== X-Forwarded-Encrypted: i=1; AJvYcCWJqeAxSExw2yTIB2lETIp3pS2JTjaOMOxyna8DjMYa4vpMLD53fcX3gx3nFFbICTHNAhH9p52rTJyvhgAfOTH/3/aDe3/vCoDP X-Gm-Message-State: AOJu0YyTssBT6ThGu1NlTbfgrjanNl1O4uQviEHzBSlsFccgMgQhVRLE kwywSbCVynw4OPAWfVfDU1drnAZbuH76u6/g4OzqkcPqyLMeqOZkL1ZbpbzHStq43iTnnfjXKpk rYjRgH6huAQVvXQNL0JeWjTIpOlqXyRSu 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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: 13673553 Received: from mail-wm1-f99.google.com (mail-wm1-f99.google.com [209.85.128.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44734642B for ; Fri, 24 May 2024 18:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.99 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575290; cv=none; b=cJ+Suu0JH5twhE/F2uX6V7Md8Rtw5ycn/SwXaeBaMPQFsOqPMO9mkqWVTY6rtT7u7Iy0iE/yaTCgMEJrUp0m4wGXdE1UA8mR1/ynE+H1SBLjiPjgP8IYFw0lumdgf8PvnLD6PJJDqeCJKc4JXOLN/pigwc4TRfYu1wzh0B7blAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575290; c=relaxed/simple; bh=+sLcs4QOO6S6PmRZbmAwV/bGLEFVH4urRpzSl6qADg8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=IUpj6IA2RzINEpQZtxE/7Wryd8POrL7CbmZ/+9DnyeXRq8fVmH72900EnH4eIVTDK9XCJrZwcFQQSsHnqAmuOjANeYH1iOtoa9KEW59yYCVHWFDWL8PUrNVdOmivkNY6HlqD31r4lDSzaD64+bRP5j/X0/K/6Z/Jp8mUSXyU5Ko= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com; spf=pass smtp.mailfrom=raspberrypi.com; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b=Nmvhk/tz; arc=none smtp.client-ip=209.85.128.99 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=raspberrypi.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Nmvhk/tz" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-42101a2ac2cso20613745e9.0 for ; Fri, 24 May 2024 11:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575282; x=1717180082; darn=vger.kernel.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=Nmvhk/tzDQSX2UDe/IHZGuA20HUeVV6mdgNpw8qWHuAqivewQ4FGD/71Up1vrHDP7T d5Hz36auZWV55kV9GaywU+sQMX/ovYLo3E8AAM4SxVNhI3uww0/PeLR8Yx6/P2ySdeEx rNUST7NDHLGTizRbRYTBHzA3weELXzU3RaRj5zzZEk5zOETsdINCPnVK3xSS7LoaZnv7 E4CCuOT3C4uBfUQMvedSmTxKoXzWW7l8YpCYfFJ9podFut3VqpIFBGZpLQL2xr2IA0ce ICWupmMAXOdQzNKhCom0S9F2cvqEFoFhoWHUXON6wLYmt31vIHC0rGblWvV1+Vg9yxPa Qy4g== 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=GecNTaMNk65uwZr0KiU4S7u53IDGdAmF1MNhYoreNcHm45KxmhIkodfG1CkOHaJ9Cf ZA7rECGrbHoJDXgMRFjWqjEVFxQpfQNDmjYbTpdeLNoPfajh4xq4ETqDWxU/F07XoaDA AewbkCxNknS3XspTtRLmPcwSgq2QklijoyzerFxo3WSmvsu07BtWbYAP6mnDRcoLe7jZ tZCQC3GZxNkHVne3CpSw6yF23xRppfKzsOBi3+5Zl/gBJCQ38KWB3DoWh4TpXnYMhd8F Bza7b/LYJ8RmVs/ICG2npUBchn9J34BnM9jPpDHWSAE8/LSJ41sbc7XyoUigS6nY/SJ3 Zv7w== X-Forwarded-Encrypted: i=1; AJvYcCXVocbeOCTQgE2rymfFnBpqGzIBrZSlTqh3oSzmDGdfc53COHRX3MSoC9u//F5ODxyCNWMl36HgS17/wfoz4Wu8RrOV8vSAdEj7 X-Gm-Message-State: AOJu0YxqQvdAPPmp46yD5YcG4kEV+OQNA+yjh7Uj78oGIR0BfghDwtyz 8MJ3dnnvxvjnb+CAhxwtlCjDTd9oOIJAFX5KCMJMikubtYb8mDb+IZCeAelBxdofjABGkX+hkEf C19FBQuyBNc1GjQkZid2DFpGAKwZRFaKC 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> Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;