From patchwork Fri May 24 18:26:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Stevenson X-Patchwork-Id: 13673518 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 369D0C25B74 for ; Fri, 24 May 2024 18:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3EStZKw/X5OLHoKIdW5p+tj1pWe59SQXWaUZEYTexoI=; b=Wo6wMggN8Iz+5y d3RJpQBTe0+25nwqyDRkL4IyaY/0WimmiVUTeFsYqy4VHBTAIKpnSiEPDrr4EoYHoMy6dWs1mxzMU uo6Tobwt6/T3Q8Uk0StWI9wTA4DWDC2Buiaadqg45hZzAehclIYSF1xPwHrVSso1M2TbLHnfC8F4N NPUY1rF82Q/7CUAi3d2LOfh7CejpiImTvu8yjwvBzQQIRqf7l27eqE5iBBQB8U6xTpDPWAOK9aEy/ C/RLLcV+Wzih4f4iIUuCkc14sKfDi6OxZUpSf+jfpgSxS4SyWRE3msEYC6VUFVcIwNoBEGGeXxg15 0NkMNgZu9YbZUlU2WIIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZeK-00000009ZPC-47Or; Fri, 24 May 2024 18:28:16 +0000 Received: from mail-wm1-x364.google.com ([2a00:1450:4864:20::364]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sAZe2-00000009Z8D-38p6 for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2024 18:28:02 +0000 Received: by mail-wm1-x364.google.com with SMTP id 5b1f17b1804b1-42108822e3cso6206465e9.0 for ; Fri, 24 May 2024 11:27:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1716575272; x=1717180072; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BSFDj4ol3AWAL0GeTo1h24EE4RwMrFwKLsNkcBtWgJ8=; b=sthwL8uHA+dzoKf7NdMDz6nOarg0v70HHu/NH4bWNCK0FiWMFzF6YMDk6xbj1huhNF qYR7UfxtpOaYXQKho9gCM/YyvaSKimcuT5A/q7vcAFtQubuZqFafuE5jOoPN+g29klAL so6Z9coNxOvYHfuKn1kzHEFe1uI7w6PgfRGZa2SLzt4iR2Vqzd2DcC22Lgn4UCBteg31 W+BZ5xscJ2CFztu6gAZSxq4nr+y7/TNuQ5HZgxBDUAJ7Bjq2pZJQ7koELOCUQYivlX41 mjXb6kKTsLkmqyXnNxBY/LqYeDOmOZraE+sXM5C1uY3PTIa1yXY7z6ON3vrqgYvKDRjJ M5yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716575272; x=1717180072; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BSFDj4ol3AWAL0GeTo1h24EE4RwMrFwKLsNkcBtWgJ8=; b=UlM3dXbDaExuOPll/tXaeSqhkW4JdQJMI17HSHEVuj1gZwc6uO6Mc3hyGK3w3eNUdu 4b0lbNU1Hjtt+qQR1CY0bq/aU971PhP2CoxJlEHPDR95CScTfN1eiw3PxXjy54U9kmPC cSexjzgYV6T9PjVQcW8Tdh6ts9VJ33f8jDhif2fKlHKaE2C6R6kdy/HxviF+g2JNB0qA Y+oulvmaqfjYo5pOajq8No/pdCZEpsPSpxu8HvlnQgGOpxeuSI3Tal70IL8R1dbR4V6w Re3a4WvmmH4uVg3OB1GCT1FfLFaoaIyHE2fIm3bwd67rKjS18mUKwUfof+4wS7sRfJ8f Zl/w== X-Forwarded-Encrypted: i=1; AJvYcCWd3rU6FWChXCFIsD3c/4/4hnsXOh/+lyOJaSOk7Anjhtr8FaYBxQTPii0V8W2wNaX8WykMZ34C31jKRw0mQPdb1BsPE3R9IDUt/44VYJ1sMXNY/7Q= X-Gm-Message-State: AOJu0YyQ4Vi8lCDxz8rOSQPll08YGFqlEm9ZS02sYlHj/KL43hBixNtY rTMHTtq7Yl02lKrNEYJHHhXZn5NXScAnQjfLIw0zfdgeMS8iObK7hH/lHXwW7yz+bdAyOMZ5hSr EOXQXuQhKUTl5SVgF0FP8CoYazJLQgsBB X-Google-Smtp-Source: AGHT+IGoEzQFTvVJkKaznbn3tsRrsBHXrR2xRBfQSwJwq8OyKLj9sbB3e3hIegjaXdW0XFK+xVpzR1K4PrIS X-Received: by 2002:a05:600c:4695:b0:41a:4623:7ee9 with SMTP id 5b1f17b1804b1-421015b3ccemr57035725e9.10.1716575271904; Fri, 24 May 2024 11:27:51 -0700 (PDT) Received: from raspberrypi.com ([188.39.149.98]) by smtp-relay.gmail.com with ESMTPS id 5b1f17b1804b1-4210890571asm1226495e9.7.2024.05.24.11.27.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:27:51 -0700 (PDT) X-Relaying-Domain: raspberrypi.com From: Dave Stevenson To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Florian Fainelli , Broadcom internal kernel review list , Ray Jui , Scott Branden , Vinod Koul , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Ulf Hansson , Mark Brown , Christoph Hellwig , Marek Szyprowski , Robin Murphy , Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Vladimir Murzin , Phil Elwell , Stefan Wahren , Serge Semin Cc: devicetree@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-mmc@vger.kernel.org, linux-spi@vger.kernel.org, iommu@lists.linux.dev, linux-sound@vger.kernel.org, Dave Stevenson Subject: [PATCH 01/18] dma-direct: take dma-ranges/offsets into account in resource mapping Date: Fri, 24 May 2024 19:26:45 +0100 Message-Id: <20240524182702.1317935-2-dave.stevenson@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240524_112759_045408_FA899464 X-CRM114-Status: GOOD ( 15.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Serge Semin A basic device-specific linear memory mapping was introduced back in commit ("dma: Take into account dma_pfn_offset") as a single-valued offset preserved in the device.dma_pfn_offset field, which was initialized for instance by means of the "dma-ranges" DT property. Afterwards the functionality was extended to support more than one device-specific region defined in the device.dma_range_map list of maps. But all of these improvements concerned a single pointer, page or sg DMA-mapping methods, while the system resource mapping function turned to miss the corresponding modification. Thus the dma_direct_map_resource() method now just casts the CPU physical address to the device DMA address with no dma-ranges-based mapping taking into account, which is obviously wrong. Let's fix it by using the phys_to_dma_direct() method to get the device-specific bus address from the passed memory resource for the case of the directly mapped DMA. Fixes: 25f1e1887088 ("dma: Take into account dma_pfn_offset") Signed-off-by: Serge Semin Signed-off-by: Dave Stevenson --- kernel/dma/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 4d543b1e9d57..916a16959575 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -509,7 +509,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents, dma_addr_t dma_direct_map_resource(struct device *dev, phys_addr_t paddr, size_t size, enum dma_data_direction dir, unsigned long attrs) { - dma_addr_t dma_addr = paddr; + dma_addr_t dma_addr = phys_to_dma_direct(dev, paddr); if (unlikely(!dma_capable(dev, dma_addr, size, false))) { dev_err_once(dev,