Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp736072lqb; Fri, 24 May 2024 11:29:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVO9RXoX6kD2/uQoNsOggcN5eAclXxSKsn1wqO5wL4t/dtFGw0zxc2Ml7l2HcF6Kpjk54QGJrgCjrucar021hIJqJPxhi2LA0dze+e6FQ== X-Google-Smtp-Source: AGHT+IGQby93GkkJzXfsMVnxRExoVqLon/j94LKz+PJAY45fNxotyAgVu8uP7EbwV02nq3ysMnkn X-Received: by 2002:a17:902:f0cd:b0:1f3:f8c:5583 with SMTP id d9443c01a7336-1f4497dd04fmr26455605ad.52.1716575358529; Fri, 24 May 2024 11:29:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716575358; cv=pass; d=google.com; s=arc-20160816; b=Nza40zcfwPlaM6BxWmEnjjuseBnUctLi9fMt3VQcsjjmxIZDYfED8pBsc8G4Yj0Lo2 rUsX3st0XkEcg3P1DvkICtfas8yuFyhqAq6UGhhddNrGkfxC0u+hVwxkOAfLwIndhmzA xKeMjIWyzKhUYeShzfXgZlGRyXFizh6bRYVpUOFURecnnVIAPnEfxPuvOM27vHgE0TU7 oJX6o6BHeEVUKhJby0BbtYkQw+JSegl/B+cvw6PrQiBNJP7pF/yei21nVr4QJMoJi6lA jQX+U/8rawl96J0jSmzn7CEunUYtFtylR14CsGKaSSFXhh73jUXvuRZE4xm/ROR48k5n O9Pg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BSFDj4ol3AWAL0GeTo1h24EE4RwMrFwKLsNkcBtWgJ8=; fh=jBHEWWihEwagF5Xivt+r/KiBBfPSiZR46Ze4Ua+MbPk=; b=ndESm9of/nNSsPKR066c7i8x/nkqWiouldfRMOwheXc5hJNiOnALIEqdyXqVn0o+Vi uewB227L5LiHAOXlmd8EdBp0405z8Q3GY0tb5PxpNIDeACWk0aITB1QupqdUAdDlb4ty i+fKKV8sqCbA0PFK+J8MOnqZTzeY864Dgbn4+VONdDSUwpm0eM4Zd2b7xOD0LOvnaj86 ou0sc6//36pidP1AU4qJo/3mxoIQBeJmnZzHHAl0R2HNA14cYjBbpNahMoYQHEIkrwd7 YCVPot7WWNOOeLndV2qw1GLxUE2Xtjrh7kM+b3fRseheVyI1IqGyLKr/lodHaddJZUA7 8zQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=RXXjQD6d; 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-188997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188997-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=raspberrypi.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f44c9a0c9esi17630655ad.405.2024.05.24.11.29.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 11:29:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-188997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@raspberrypi.com header.s=google header.b=RXXjQD6d; 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-188997-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-188997-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B287F282DE2 for ; Fri, 24 May 2024 18:29:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 364D25BAFC; Fri, 24 May 2024 18:28:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="RXXjQD6d" 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 81B763D984 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=1716575277; cv=none; b=ei9IaJrIap7m8uJ3XSdWrUK9u8uufRPaSzyWj4AkNEnmKHVCpknuTzFa7EyJJbnL0PDg8Kz8KvGXgJDPWC2jghICi64sPfnn8taHvEtQhL67KodJS8buKFfRTASL7OiSlwKON9vN1duB2Td9+k55xh1A0vIZhKEqI55ML5C4X68= 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.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 Received: by mail-wm1-f100.google.com with SMTP id 5b1f17b1804b1-42102c51524so12460115e9.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=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=d0fOVUPB9+uy8KN587z3NZx1RiAFl28CypoaJitA4AFrwZ3sJpAb++e9Mpf/NFwGWB ExncjFQpd3UJrwPNOMi5AZPEckjoFNk3aDGC4hvwx3Ft8bw9qO7mkMGDSjA6OdVAh2xD WCzyg/tZ+IsHoFnWGvF8lRM00Wqw5ex3sjuFL08zE2WD7FIDLGz4/psLu641xeRpr81p o2ImLwXtNqlonPYvXaPJpN6x1qJ2cLG+lRApZVUFRv08UB2cTq6Gi37x+51OWukeYnMw fJOfVZ2C1/jl6fxu50mHD/6/RyHZNSBHgXp6cUDntVx6bdGefd4efaa6BC4aMhWcISuC VERA== X-Forwarded-Encrypted: i=1; AJvYcCWBKomcq9Eqn2+yEtaPJc24gkHnW0iU53hTwreVCkq6t5e2WtcjrE8+oV0Fvu4/toU8CfEWIr8FVdcsrCz+pvL5z6nKj5VmUglbWx2l X-Gm-Message-State: AOJu0YzTJzAVrIZjh96lzHUuG76whUIoJG3zx1hQam9C3Q2MmGBsu2Qk AGYWIQ+x6yYVzmSd35ecFiItJ+CAX4nVITeEny9mAETqw6bkhm50II3dsNesV77UNTlCNQPex3z 30flwtL0WPheoFZV5kEJ6ICFB7GIWZmPE 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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, -- 2.34.1