Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp735728lqb; Fri, 24 May 2024 11:28:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9F0+1+31HnFf7fP0CBur3XwuphfohNCBFth0qqfU5aE6MQcZWPuE+yaxxBzlXtLiTnuhH4c3WmDCy/xSE1AF0uUYqBnlxQYUZvA7bwA== X-Google-Smtp-Source: AGHT+IH+g46SOE7VyUyVFMb8X5DxZBbaQN49oX4cOJqxeKA1Daq6Z5CMpJeBRGD3TG3P6xttr/ko X-Received: by 2002:a50:9e81:0:b0:578:6484:24ff with SMTP id 4fb4d7f45d1cf-57864849320mr676675a12.6.1716575303468; Fri, 24 May 2024 11:28:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716575303; cv=pass; d=google.com; s=arc-20160816; b=rcqGLxwNnkhPtfolBI9DduacUzuXKo0N171xiwt6q837pUJNVc3UvBv4ngdhVBrTcV q39fexA3eJP3CDDcoMQ3IJv5cJLea6AwHPRCxjYL7OnNAOfV4xErib3oE5jkW4Is+A/8 6S4pKxrHmtYCf+FXhKZVive56H384AJ2LMWBjhrVwsv7t1KSDfWIe6jNrfY/23HAx2+i U+1kC7kNnBKlg5kegZ5PvSinJ0w+fd7eLejYBJuGMRWESW/k9PL4Qeks2wBuVf9KRe30 BT33A2Pl2T5W8Xq1d9GD9cMXxKsEXI1e4LPoBib4LU/iRDU3bTpg+39PN+OsrByxvVAg PvHw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=Xql1CWOkqvawpbosdHCKSvgqjnwNVKxpQqZxh7tM+T4=; fh=nVFdnTF2MuGVH7WsMRAc5RiehTQPElVAwWQuTE0Mz88=; b=Cmc3CEEzFl4DiXuq1nbQ7nv4IaDJhuDHcw//gANIEti+EOq1lEWmGfKjQF3XmlGxBu 4InQmlshcoLvsGbmYcKpokxL+fbCrSW0pUiKy/7DmLIPXC7RBLFoy1j5Qlp03pqqFK1n o+BxBMWhpY4Oe66jJ1kw2UliiIT1TK0FbbUXY1ZAZHAhrLBKmrqKEUzMdrS/2ds8bI/w xhXb3D+w70GUu/q8wZTECX4lrsGqFz1vUw8y0B8IQ0dwAcelgumV3xsCIeN+qvPAgZTy 5aZJHBmz+fwSRAufIe5v4LN3W36tWuXwYu3dAaEhzdgpvdvi+DB4PtI0S5HjvC8WoiZJ MFYw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=dxrqh2Dl; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-188995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188995-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-578599eb685si924816a12.196.2024.05.24.11.28.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:28:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=dxrqh2Dl; arc=pass (i=1 spf=pass spfdomain=raspberrypi.com dkim=pass dkdomain=raspberrypi.com dmarc=pass fromdomain=raspberrypi.com); spf=pass (google.com: domain of linux-kernel+bounces-188995-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188995-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0D1F41F2296F for ; Fri, 24 May 2024 18:28:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ADAE44A99C; Fri, 24 May 2024 18:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="dxrqh2Dl" 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 E2A923BBED for ; Fri, 24 May 2024 18:27:52 +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=1716575274; cv=none; b=tXELLLQScdPh5z5BaZtfy5HGbM3TDOrkgog1TAzWr+AtK1D4PSULpUrGQVGQoJM72eqxNLEu2u0+ybROAUcP5sPrX/PegdxSkGPZpjGh5F/QCNHxCfLbslbvSZ/efRDZUma2kwqdrvyvQg67YGwFeA22K2VcLOLKD1F9xvvRzMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716575274; c=relaxed/simple; bh=td/Vk7YkZYHrVt/nOdJ0BOQkIAcpR2c/B2eHAhBjQLk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=VWSsC22KdWhMWdbpg4ekWf6oiwedfavqXfBLfEDKa3xqEteG4GDcuY2GEtJ47mPsMK2uHAqVXMEy2cyZ7ondZYyuVmNBziSu0W1DfIvbFsAJqt/7yQWinZUae2gtU3Blm1sDrxSnEWTbEjR6yFByZt8byd+fotZ6jTn5GEdCrRI= 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=dxrqh2Dl; 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 Received: by mail-wm1-f99.google.com with SMTP id 5b1f17b1804b1-42108822e3cso6206375e9.0 for ; Fri, 24 May 2024 11:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575271; x=1717180071; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Xql1CWOkqvawpbosdHCKSvgqjnwNVKxpQqZxh7tM+T4=; b=dxrqh2DlxIVia43NACZLda+CTXfnSS7U4U3G5ZWpxu5FyGVH2d39QrQv0aqklsfeEr 9IWlHdJyqSA/pPsrsx19+OvL+pg9kWdnARtf/lNOaXC5EzhRx2u46d6fbSS2kgfp+B4n 2P+3I/kfASS6IlWSQyVu0/akO8qupmHF97J4G8s3b3lPBDcqj0BmMqoLMQcpDq+PisnA BAh4FhNuhj7gcDZh9V57WyF0bZXeKJLIQqJf8uPD4bci7Fp4QVVrO9gylpMYMon84cs5 VY8wYLrgrh4blrEh3cdnb3TFAePY1zWBoo15rfq9t2rpTwsM+j9XL1Lto+MXFkB1itAk WH2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575271; x=1717180071; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Xql1CWOkqvawpbosdHCKSvgqjnwNVKxpQqZxh7tM+T4=; b=Tq+nx8N2kAU61rerxFvpNpExyL4duFVWnVVM3IqAe6C0VpMKEnpwqUC4caGv+l906l PD7AV8/iqTjmFYzS2QoxYUpUetgOZwPy9ImByvtGL1ebBvKuLvKiKoLs8/7kyfrHtyqR DII1fnD2wdWh1FAY4ZjHGjNr0HeXg9F6g/RI8NJZQmWa3Z1rliYGXMPk4qYoSD+YkLEN IFzrXoaclnVBmnCnA3j9rH6MqFJBgyU9KXaTHNQpkVtmpx5rZ8nzI30tukM0ww+yBzaL ejy6C8riD6yyeT1wS0Ff73B0wIc2e6BVJlxaGYvI7P5OP1uK1WlSxXOXi5jpnCPICd+7 eoiQ== X-Forwarded-Encrypted: i=1; AJvYcCXjbW6wv8FEa20mIJmTWUqnX+2DSga11D/4jaCYxEOQir7bK4vzC7UOYg3GHgmloeczZeJIpIUaz/Hft4vfzMYOM/oAbyHVUcdjdSH3 X-Gm-Message-State: AOJu0YxJo6ZFlJIUc5Yv2c5q8k3LwflE03vxc+Z/5ix8uQjhrXeE8voL Sf0nuXdtG6DEs3YNP0p4Jnct9Ia9x6W/i5H/RYICl7/+ybhB08g2YzVMTj5evsbK8/0/EXftLd3 LVtAykE9KdVF3RpNwhZCP7hVuq5GULArI X-Received: by 2002:a05:6000:1753:b0:354:fce5:4cc3 with SMTP id ffacd0b85a97d-354fce54d2dmr4599736f8f.19.1716575271168; 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 ffacd0b85a97d-35579d7b436sm63138f8f.14.2024.05.24.11.27.50 (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 00/18] BCM2835 DMA mapping cleanups and fixes Date: Fri, 24 May 2024 19:26:44 +0100 Message-Id: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi All This series initially cleans up the BCM2835 DMA driver in preparation for supporting the 40bit version. It then fixes up the incorrect mapping behaviour we've had to date. The cleanups are based on Stefan Wahren's RFC [1], with a couple of minor bugs fixed, but stopping before actually adding the 40bit support. If we can sort the mapping issue, it avoids having to have workarounds in the 40bit support. The mapping issues were discussed in [2]. Up until this point all DMA users have been passing in dma addresses rather than CPU physical addresses, and the DMA driver has been using those directly rather than using dma_map_resource() to map them. The DT has also been missing some of the required mappings in "dma-ranges", but they have been present in "ranges". I've therefore duplicated the minimum amount of of_dma_get_range and translate_phys_to_dma to be able to use "ranges" as discussed in that thread. I'm assuming that sort of code is not desirable in the core code as it shouldn't be necessary, so keeping it contained within a driver is the better solution. When Andrea posted our downstream patches in [3], Robin Murphy stated that dma_map_resource is the correct API, but as it currently doesn't check the dma_range_map we need Sergey Semin's patch [4]. There seemed to be no follow up over the implications of it. I've therefore included it in the series at least for discussion. If it's not acceptable then I'm not sure of the route forward in fixing this mapping issue. I'm expecting there to be some discussion, but also acknowledge that merging this will need to be phased with the patches 1-13 needing to be merged before any of 14-17, and then 18 merged last to remove the workaround. I suspect that's the least of my worries though. I will apologise in advance if I don't respond immediately to comments - I'm out of the office for the next week, but do appreciate any feedback. Thanks Dave [1] https://lore.kernel.org/linux-arm-kernel/13ec386b-2305-27da-9765-8fa3ad71146c@i2se.com/T/ [2] https://lore.kernel.org/linux-arm-kernel/CAPY8ntBua=wPVUj+SM0WGcUL0fT56uEHo8YZUTMB8Z54X_aPRw@mail.gmail.com/T/ [3] https://lore.kernel.org/lkml/cover.1706948717.git.andrea.porta@suse.com/T/ [4] https://lore.kernel.org/linux-iommu/20220610080802.11147-1-Sergey.Semin@baikalelectronics.ru/ Dave Stevenson (7): ARM: dts: bcm283x: Update to use dma-channel-mask dmaengine: bcm2835: Add function to handle DMA mapping dmaengine: bcm2835: Add backwards compatible handling until clients updated dmaengine: bcm2835: Use dma_map_resource to map addresses dmaengine: bcm2835: Read ranges if dma-ranges aren't mapped arm: dt: Add dma-ranges to the bcm283x platforms dmaengine: bcm2835: Revert the workaround for DMA addresses Phil Elwell (4): mmc: bcm2835: Use phys addresses for slave DMA config spi: bcm2835: Use phys addresses for slave DMA config drm/vc4: Use phys addresses for slave DMA config ASoC: bcm2835-i2s: Use phys addresses for DAI DMA Serge Semin (1): dma-direct: take dma-ranges/offsets into account in resource mapping Stefan Wahren (6): dmaengine: bcm2835: Support common dma-channel-mask dmaengine: bcm2835: move CB info generation into separate function dmaengine: bcm2835: move CB final extra info generation into function dmaengine: bcm2835: make address increment platform independent dmaengine: bcm2385: drop info parameters dmaengine: bcm2835: pass dma_chan to generic functions arch/arm/boot/dts/broadcom/bcm2711.dtsi | 14 +- .../arm/boot/dts/broadcom/bcm2835-common.dtsi | 2 +- arch/arm/boot/dts/broadcom/bcm2835.dtsi | 3 +- arch/arm/boot/dts/broadcom/bcm2836.dtsi | 3 +- arch/arm/boot/dts/broadcom/bcm2837.dtsi | 3 +- drivers/dma/bcm2835-dma.c | 432 ++++++++++++++---- drivers/gpu/drm/vc4/vc4_hdmi.c | 15 +- drivers/mmc/host/bcm2835.c | 17 +- drivers/spi/spi-bcm2835.c | 23 +- kernel/dma/direct.c | 2 +- sound/soc/bcm/bcm2835-i2s.c | 18 +- 11 files changed, 383 insertions(+), 149 deletions(-) -- 2.34.1