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: 798825 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 2B92E3F9EC for ; Fri, 24 May 2024 18:27:53 +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=1716575278; cv=none; b=LEzz9wMHxf2Tsu1LnSgOCLKCsnDfcROXlVMv8PYTefO/+Xg8IvpKhy2/9LhfSJVaqTJEh11tykh4UDMOzKOLNFWyCJjTwKYe2JPP7QUeey0WqJKQu2dLeN67PGkJlBNd7nhUFvM2KBzP/3HewrllW77xaTeG0qmk8kEz59sQzvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575278; c=relaxed/simple; bh=t6EOXzX5NBCieefJXhaqEj/EuhQeMzBIdGFGnmyqFc4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T/RdlTLPaxPgE+m008qFZpMVbdSAajV0hsh3QXN1WHJZCxEUlYisz4PYmM+gvraNCNAjXffVXjiTHafoaH/GPrKY62/T5YOos/2fdnZPOB/WUBQkwVniWDZ5amxVIjAyWtRL5IIfBRonu3nMzLZ2kKp9fwf92FUEJZJS+psqZIc= 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.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="tyumMzdp" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-42017f8de7aso68196345e9.1 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=CaUtg2MN2hypf5zFJlWusdHSbsi5m+t7Gjk2kPTr3wnTYiH6A7I1vRpsuLdBBXk/Dr HrgN6jlSFDh0hQCL2DZI5WQL/Ms5fKZTqjguV9LHCxPYjYlWHJVqP5Zm2bRnXrD0gh/z hPnSQKC9f+1DB9oyr+MarW/pjZGWxpMqmjV6CK4kWFHpom8gQLMAC4EFqM2uxBsc6Wf2 NjF/hEvmDnk3H7ZdfC6FHsmFUIPo7Kc6JlCPq0WLWvoLbxUkuOvzZxtshvVw2fRm3hLK bLW4rp2yzOYjq/fLfE3vLBrtjQ31iXCp0s+mX7tWAHkLP+3Yk+H1SppVTieMHshX1BgO NRlw== X-Forwarded-Encrypted: i=1; AJvYcCUkXdi5QXEM7WhQ0udl5kRjO+lyVmvIdPNYwXJ71BMxKnnMGCpPFWsh1VX4Si1ZcaLrsGVNbDyuvKn8l0EcGOQViJJ7n1aItSTn X-Gm-Message-State: AOJu0Yzdn/eOAxAXZviHBDH+TXPjVtTqSb4qQpPsNvViqQ5BmazXA0uF OGhBnC7o8cs5AzYU+434L6ppfqT9tHPhreeH61dz912WbSN0J7AoYENfX2G22p07Iww+s0o34tb vqsFvlpRZ0L1Zd4CbO9flMszuWijz/pEj 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-mmc@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: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: 798824 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 4A04D405D8 for ; Fri, 24 May 2024 18:27:55 +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=AnkDueoMx/wLY6Z5x7F/QUiv47uKep737YeWmBP15QDf6O0zFECZJhgUMg3Y2Wv72mCZOdkh/gvz3GgOw+zLmNjfp/NOyuU1lHqGqXe+YntgEWivqXbAsNpjtBfMNQdfNM3BPvhoSzMgSlsoocFvXwSz7GdgGg9o+Wu+IaCVENM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575279; c=relaxed/simple; bh=z+GE4dD4yPnc63WvqBNiPDl9b7TaZQb9Yc7IQzit1Hk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mbRpdS83RT6rREU+Za8xUp0HiPC9Uje1C3FvVkdHmK2hsvI0PTONEuOp+8e2c8u78FEadaYoY1nF5/G9huME7T8T2Gm9pU6qOpjAQpJLoFQDKIfGI1hOol/lV+x8Eg/4Dy98f/xB0CXJYXI2IUeOE9Rp7J8xMj9m9tIxbiPRd/I= 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.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="Dc9AYa0h" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-421087b6f3fso11219325e9.1 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=hWMcr7wP1mZwBsXz9qpG+zu43SrIlfqnNs8f45l6CIobG8VQteRC7iB8ogquiqee7h V2ctWyxOcwXYT/hsyYdVC5oVIDAFeoE5YJtEanwNfnOx+rFnnUTNE4463/vKWqo8DIG4 zSDpL92Ws8TaglYK8qoGTH0W04r4Ou7FOp5kwkyBzplbaHxkJhyx7CIMq7fkDaWeu0eM uVD28CgqUtXqqxFUdQfe8YifLmLp4COwBJsLHWlFG6aqyvN/Apgi1eC5KEh4bp5cFWAG HCIn2MnHhHmcFaZhzNqGKYAfqUze6btq2Y1aOo6dTy3p1JAGbFirZamOnP+KUpcWIHuW uPVg== X-Forwarded-Encrypted: i=1; AJvYcCWCxgOO4QAX3joLM8RoR1I45Ncb6YF2X+Vk5PJD4EM9ujmLk85myjiDVGgoKNw72rjI4AShIhGkEHx7Cr/0QTSkTHS20YHPZWaq X-Gm-Message-State: AOJu0YyIfM8tvvwSak1NGiTGPG180ChfMji6hLQLRSHXUtjszsDHb1L6 Hty4iOMWoE2WzSRS7z5hM7NIzXKOEJhBmDqWXYyZWIVq0wmCkw8BytE3bfMRA8D4N1/8YqPxQTM ssFZH6qCzZ2yPTNdfE0mU8mSXm4k8b+aV 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-mmc@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: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: 798823 Received: from mail-wr1-f98.google.com (mail-wr1-f98.google.com [209.85.221.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 90E9141755 for ; Fri, 24 May 2024 18:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.98 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; cv=none; b=ZPhLQXK5MrMb61NBq8sJgGQIFRTmyjxjnzghq2zfunfHXIR7mnPiaw0UcaAphb9M4dJ0fJ9xAtnNxMiImY10jXA85YkC2Rw8N+FaQi+tAyV9Ud7YG+GJmmvjFHG9iZGvetFOzn5U9EO7u8Ftqe3toKl7xlI7ha50FQTryvHpzZs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575281; c=relaxed/simple; bh=nfU4i7o8p143//pVAQIuLJreZUHivVRGYWOYdCfqYIA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qw5/SpWas7udHO2+p6xHCVeThaHeciV2igqreNYBbwf2QVWAi50tcC3aeZku+zzAxJ8g/ORJPGc9Vo/8J40i7hmM7LgMbV1RICQZllXRVEs15U5JBQHKjT6UVdo7t3Xw5fmrmzcv9jlwglz2Iv2KqZcu14ff2criT+Bal9tJKe8= 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.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="eZ6RhjaH" Received: by mail-wr1-f98.google.com with SMTP id ffacd0b85a97d-354f3f6c3b1so2553126f8f.2 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=radTJDVRnFoz8Xb0I8G0lJ1WxggmD2RuAK5FWGMPRY+6fiDEbfQ4+jLxeieLg311V1 YJtVzufY1qKVuGi3W0O0d6YQrv/A0f9x96r2C8AKwT3DQOTmZlP7yVIQ2aObEG7dAQif +52v3LWGpb7pMq9ZSGUbPBsQk5eIokLqTAWYvaFlfn5plnbuJAlr4BodHk4+IMeSIowy TfcUcoBnruEHmvTUiYtpbbkIOLTz26lDePmJya6biYc0iHDBJ4jyABAay5xvIFu7P2/j IkY4gALgHm6VudDWnuhOCMN7l17BhrdL5KAjjZ1hBS32sTdjD8BKLDe08fnG4nLr7iyx tkEw== X-Forwarded-Encrypted: i=1; AJvYcCU2w5KI8XCj86n8iTRMWJ1AOwGmCa6Ok8tHGXEQ7JNBgUuZhbOODE5PG0K/inE8Fw/Cs4AnUq5BLnEiYfnwS4lHXotGQuR3JdB6 X-Gm-Message-State: AOJu0YwATSDjj/ayng1PiowYZfk9jC/W1qG90A75zDpnStYhBM1QdWqL tI0j4cm9xZ08EBjYia0HRDHh05Jaj26xMD/eJfyMftwCDicOnyTdLrz/baBSuT9xTaTJBt2Tm6w MoypdA8/26A8R8FNy/VsIuTBC0I86Pqu2 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-mmc@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: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: 798822 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 47D8C3EA9B for ; Fri, 24 May 2024 18:27:59 +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=1716575283; cv=none; b=uxMsWdrD4DS4BQFvlZ6F0wjcePrsBb+rMDJSPuhuhODv5oBtq8c/S8kJEiiIApHxS9+ywzoOGZyxvwwHKqWcx6D3bOlxBtnX2fjZk/7oEWLynCp8qBIuPoHJReC8npyUoeA5kB0pqiL77Z7JIt96LInMsa3n1rNm4eswUXZKP5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575283; c=relaxed/simple; bh=5nrl5uVGiAQbueZrACpZq8a6cFbZpWvV3c8a8/I60FE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o82zp4B8I0G7svkYLzRpQdeXYM7gQnhaAWfLYgwO4u4SDbW6hQRWtWYrT8Npl30f7WSNd35msl44oXCegukFtdcIVt6CZN/Qq4k2JLzDV7VTZb+gC50oZ2pYvBCj+3jP94t2YFrpIsV8ztJwwEDF0fd4+WvNkYC2LZhazfvjAF4= 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.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="M65Q5Uek" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-42016c8daa7so67093605e9.2 for ; Fri, 24 May 2024 11:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=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=oOW1HYkhvW9LecbDRIoc3x7XkDlcsYzQc2eWBR3kRjgdbRr/elaJywgRoywkEGuTWO q9GKBsRkhch3i/ZTJnlgD/HG9yJ2WqcJL1mG1yhZimWXBum3nwHOIG0gRpteAOouJKKZ t6QGYuvNc29JvFmJiPrsnti3f8K1FS34lmPXohTpSZZ7mCgW09LcWK/+qTZdAxhI3Yz8 MDKmPUfSJ3RB+qEnXIn/65EXWTlJY9/lZJV53YQIJnrIPvdT9ZhKko6LQh8fhbLYqEz5 5Ri1+2jNRjzU1PGZnqiTD2vfVUUM5Ii0NRCPy2HTI9r1Gfelm9o3twu2FXNdS71Eo9j3 xbbQ== X-Forwarded-Encrypted: i=1; AJvYcCXbzE1171AkZm8MbM+TYiue/zERLubIZB44gw56Mqy+ERO80JiT+vrzaLPkPsDy3ewirpXWjc+039g/1Kr8vGD5ZqNWThBS/p2h X-Gm-Message-State: AOJu0YwvhCP4OoLiim8VxtlShjQgbCbqeizF5JIOO8wfQHmtfBCrXGv0 8lIDc+fnDqkqjnR3L9dWFfzKiPS8KEC6Kh6kTUYa6FPUuKr6Kzwrbpv4MreE1OazHLEd/RSyKVr 3VqN2yNHB/haCNj3XoJD8uShLsz56tOKD 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-mmc@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: 798820 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 6BC7E4F1E2 for ; Fri, 24 May 2024 18:28:00 +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=1716575286; cv=none; b=qyknIXF7avbqSQYK82nla6Uf27NKX0cNkb3Br1IqBd7Qh26Fk16SCoIF+r+7+3uf6hJ0S4wFKwZyQQ/iOsIG+tC5MZLZQhIqYIGjcEVSgEdU/ToxCP5A0eU3U6tBy937shGY+HWSepd3CJZPyqC4XyGCf4Sy3kGw9xQ0AhbhPdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575286; c=relaxed/simple; bh=NmaIHsHw8WolTjTf8xLqs7ZWhcp53cyRuvb7LqWTrw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tD9U36oqpVfHGdR02UFPi4R5mKuvAAEyb3r40EPAm7YwnM9B4kKFMZxC4YCo8tCiNZRCSMUrR0+Wmi4LkPtWUS8osolsCzb1CqlGeIYraJp/PmrGUDqB9t82LNLQq/SIcG11MEGL8X1IL/f5iBmDnp4o6xKPSLHIJp9ZwpGZjvM= 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-4200ee78f33so34494115e9.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=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=hDVs+25JrlbKgcZBhEiVuVZRiLq6AiGR1ZyWbgmmAINHi95KluSBJC7Jb4I2pHHRAd JlYDLk1+NAmynMxxJ81QPjkh2t1sh9z5rZ006CP1TXpFHJ3Dft8m+7My9yp4Wg6Y2uXL VpTfg3+YSmDBkkgP/1vSWzoYYLNwQPLviL29dliidsStvwJNICIps9rCQv/yO/hI6E08 SsA1JkRaDV3Z7Vvbu3IBUuVCvURNbn0VicOJ2JwGuHfxzlVmuZL6ik8Aw2lbG/qUbdnX ejwNABev+9UD3iZjLu2Gqpo08/iVMs2priIRc330mtrI3aWEgHbSMNTJ9hDJoGDBbgQD naCg== X-Forwarded-Encrypted: i=1; AJvYcCV4Z/oMW9QGFKF9w3oro61qOmDU64pBVHu1Yk7YWjapYcVzDSnQEBoQRN765op6X0ED+4bco3KzzPyj14PflSyPmDwDnpWg1mFE X-Gm-Message-State: AOJu0YzIpbQL83LLGi5U3/21HbfJEHvz8ZZg5l4gsfnHv7Vzofh0Qh4T juurz/Ir5weKc4jrsBeLhwnhbl/hHA9ACSZBh6f0bpvswtRZCrDxsqhP4KSPD4Ygh601UuVJlQ3 O2+rpRlM3tO19VHnpeMNBrzxoV3GrJ4MV 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-mmc@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: 798821 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 5CC0F4EB3D 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=1716575287; cv=none; b=L/xnJsrVwTQOEzU0rQIcRG2X5TvpoeT9nwF2Hx8o6YE5OrNa31dNcqfI1s5XYRT5R89NXy1AgJ2lirzoRgtP5cbSYPNmK/FW5PS65WNga0nTrTGoyorpLiW7PpNVYbNZXw+NAishCW3L/nrhmIumMPcMIZN+FOQmFoczKjlwtSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575287; c=relaxed/simple; bh=vAXHDE0/SqkQsUMGiVCRffAB088Mi79YDBrfTqisc/Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NJx/mev3JYO+l/eC4bSQpCVecpQOOLcvEpel+jm8WGs1L/wrejr9niU37ieJyp65ajsSi0brm1N7V3U8Qvy9ulZbTMdHA+IEsvsbBuqpup+706KS8Of/YWXwssBNNZK7izOXN14U37McIgpiyRZ+wkFX1bKZjj4DyvjBi3X/ws0= 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-4200ee78f34so32625635e9.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=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=gwUnNGHYkY+mBlIbPOtMsAr/dBW3bNL654CWDWhwWk9nFlwi7eqUEjff33aAnvEfEw tA/szKh7/5TbvEj5gJJTpRXpAl2CZOPR5qXS7MJVZLIdUS9y+7u3iHyzwMK+pfc/SrEJ nVDAy6F9EHzf7Ho4Vn89hFE+UZUnwzeG0etTYwdLPNWot3GrGJ6OAXn199yy0xK512Tu +UL00WgiudQe1kbO7YM3a9zRwpTKfMPmmwkKya8uSwOnuAy7GuBPgvpkY9ggsI6pFv5+ BIT+GWq3L7zfeyntoL+4NjySaQXA7KB0T1dMU6d/m/mBY8xonLf7ZEB4Y4OzfHMqYc10 yNcQ== X-Forwarded-Encrypted: i=1; AJvYcCUddPptjMuBTcCtxYx4uAi+zLjU/Ulphq9E9puauLfwZRCle0w5QCHeRt8ZZoFq3kfyloaMNilHSrickcR9Nj6AmJHmi/7yv6UE X-Gm-Message-State: AOJu0YxNPtvNrAaJJJMhCeX4e3KRwRor7lntd2UTJ+7odf5iyUio6BSE ncPouNVskXAUpmFP73MqH/p82tUumUv2rLlPK2mLMLuXjlR3uO/zSvAkdJhfEowptAYkjKTBr8l Pav+bare4IUC21ACR9v/pqB6Pg0NjWdkA 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-mmc@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: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: 798819 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 94E7241A88 for ; Fri, 24 May 2024 18:28:03 +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=1716575289; cv=none; b=CNeQlTdPjCD69dm12l3mYtP5Wu51Rm3H6rQycir4Or1vcuFtPHqnkfySy58rRD95WH2lwo6/eaQlgVtWzNxZ9XBgpeuoKtfrLlQe+/t/D51vARigx8OAJqtqZSAmekj3t0+ytZyBAUufSNokrb1/UgFw+W8efyiuVkebcL4uvXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575289; c=relaxed/simple; bh=WfcHrNiYZ1rUh5ZyFbpbA7wYQtF/ZVKkB0GXxiX6I+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ukXzCq+xBbq5NEjYhyWrMfd9MMLKNuRfdLwrxIbqsQQXyAOlFjgUQDK5M4oVUkeEV5smCyU6d6mcuo/3khsu9MRnNUa8dssNOh3pEqQuYSEIaOqCJmyt3hyZglus7NtkJzGlbd0xEpyoNAUwVG57cU8dKPJZMqUSsVLWRoEjLY8= 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.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="l0IgCMzK" Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-42108739ed8so13343795e9.0 for ; Fri, 24 May 2024 11:28:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=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=GxEQQ4aJwgjWo3XE+m6TjJMboGV51gczEIJ4NaunKNZbw0jEplEYR/nxjPsqGflEZD h5HVGUnkhf6inefCToH1PPlyt9oibTTaBE5FTTg+UIOUte5bBg8stclsWXZJrPsIKCnv OxoJhAuAtkThl4AoRY7MhT/zMGbnAM2idBV8fzGTsJBf4N2bay6PFGmjtbRW9Ylg/BTE aLzzT7gTppQVplS23jj1X1J5UOU3eVM2YwAlwv3xdHbnhSO1Cs3AlJEKa3yfiu6+KR00 PzMOOLlMUMG3lRT7QnoppzQlA1lgrws1RnkMze/4GIIuTV1jJDKHE/xnJFuXDoAJL5Cm jp7A== X-Forwarded-Encrypted: i=1; AJvYcCUE2jlSeRiUAevls2XyLogz7ANcHP8gB5xeKGNi5j6kSwapR2IRWA5bwUUGkFgHUQorPTke3gvitXt4pppx7sZmeWLMB33Q6hcH X-Gm-Message-State: AOJu0YyAnyGQFjQN5lxEdXkUZBc2aWGf9ODrsEx24t9jdgOHP9rbXsi3 dcpAwnnXHlKg7FvNasvKydLICWWegS68zwJCnUPOkcN/11o6g0sE697qVDsQdzBupyjFtxNYIjd dUv0X7UE2BFgrnaf7OYKIb1vca1s0BSef 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-mmc@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: 798818 Received: from mail-lf1-f100.google.com (mail-lf1-f100.google.com [209.85.167.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 7B42B59161 for ; Fri, 24 May 2024 18:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575290; cv=none; b=iaaXJaRggfMOpHiOx0Dq18/RFMKJ+X2WcYD2DC7BySWekTJu/yoixDqeW5E8COOk4wrrqqNJsdAash/GS1VAlu1zsYSN3IqxXvyU6F7+zMF2Ltxs4r1PKxhJaNq7ViLqRwYS+JIF4eG1TdTEBt8xXH8JZIVIR+N6Z/zlX/XWFaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575290; c=relaxed/simple; bh=txNXDmI+i52QByifcvV/37TC8rzKbXT7VxR03bSa2jU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KmF8Nmqw/1neciLU3e2T4k8VB2ooY5XIKSUT+ja96O55wJHsxOIOD4nxjzafBFbG/v8cFr7qAs0lCZI8HgThw292oYqWWDZNjoOdiHztdg834gfozsw1Sn3BwL2r66R/25BhrZC0HQjOE8r8wwpLSn9ybs86B65XIwfjWagp1dg= 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.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="DWX27F+F" Received: by mail-lf1-f100.google.com with SMTP id 2adb3069b0e04-51fcb7dc722so3283596e87.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=bNuZJvgtBLAnWbSUiXDwL7PVM02FY0ZlydddGGLhcbh6aYGy7OyG7Smm0Zh3tD4PqB W+oClrVOxrynPCdY0BBWqEXX528FIDREU6VhBKWByvT/qeykQzi9TdCbPacrbHZwXoal tFz3eOY6mov33IsbKSueGZv+eSAIiEMaUEZR++AQtLiDhZTNZvQrenSa+erHKZsQ5nRo RiIQj22rQBJkTY7ltHOUiKSmKvkt17XDZZe9ikxTgH6Wby83AcS15MIkM+/k7SR6YUvg MerM+9lRw6wPLK2qmCatpmdAHBReXoVhhojkVjfASCtGJ8CjxkzNlfFMYSbk+yqb+aP1 cPDA== X-Forwarded-Encrypted: i=1; AJvYcCXc/Dd4wFln0Ll1zvZw3zcgrx01fY/eyLYIFiGPSk/XlP3wT4ZtnX8tstZe3R+9eHnCn5i4cHxNV5GEByiVbYnH66usGpxEdC9W X-Gm-Message-State: AOJu0YwppkikeLa6FmEJvpXxDcAZK8/OaKdFgbMCjdNSsO3Ovk4xUduQ Do0O4NHvwh8xPReEVZHMgqEiuqC+Mh23Dg9X/EvCZo3CXx0VeFS8wjbKINhPDSijk5D5mPo0vNN CSR1FybTE8YBrn0Ohs8q5X53Qxm/FTQDc 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-mmc@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: 798817 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 5746059151 for ; Fri, 24 May 2024 18:28:05 +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=1716575290; cv=none; b=tPRbTQcnNmw4BBg3JjVhgqsIUMJdIU0RBGWIsz0je0c2dRQbCCNlt+HlFn3fq673uTLMz0IWidtPFqEF/s6CUX4E6jnYyWx4DcwtFeGyyE+CLwnbA+We7rTF/PcvnMf5BV/KKVsQ1Zal/4RPJt2HYBb4TSOUa+CqbVhpy/q94Jo= 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.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="Nmvhk/tz" Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-4202959b060so65838735e9.2 for ; Fri, 24 May 2024 11:28:05 -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=cELqXsbLb+6AgokbVSWK8KYjjuHJ4jed9yI2aIYbMH+ADNIuBaFPrduHc0kAUslVrV ho+eLB49FNoPmzTx11dNs9jiiGtSTTTYa+cpNz/Y/eOlyfTA/tfoy9UBbX5i418vN+mz PuVlo66yX21vDzZRgoLv8dpfihw5HjSx6FhqV5MBsqAECwWAXUsqDhhARDsA1iuMq4i/ xdYvrhHZOlVGEnOGYpAaMikY1uc4BJiD+EHNQ9YCjgSlcVuRy2Sjr1FEdR4xRGxn3+g1 mxcXYJ5nZvl+nKdrh2ZnTKA+/ZyHKnoHr8WKF9q+mDCShlcDrAAzzL+yjiwioQd8Noh4 weow== X-Forwarded-Encrypted: i=1; AJvYcCXFdeWi/P/lZcM9dn2XKSEVgw1YEa2oDvj7UFsvj+OlzAsB3gHaFKjysGoZyDufLxSif7NQoJEuBRfDgglBSpI5hvZGsQXler5W X-Gm-Message-State: AOJu0YyfTqxJZ6eqBvdfPvXuUevWz+ycmoBMhpNJD1rF9XOU6RnFvGiT UYzp9D7x0mmkaL8LEO+gwAC5Er1ntWs5jbH5Ae28Eru8MMnEVjLXj+TUXNSdonzlRnKPU/1GAn5 Nt555/RPiVH7Nf4RBbqOHCiS4K/Ohnsu3 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-mmc@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;