Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2457450lqb; Mon, 27 May 2024 23:33:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDcr9zucjZAMawP+ul7rXo90q24zWfLJv9iI+NhB5YgzcVNn5Tn/iA6Vj00kVuQjBg/c3b7l8w9cANxi+Yg8IWeSfk1ZUgu0TCLK2xHw== X-Google-Smtp-Source: AGHT+IGN+yTTzEbnoLnUEwCfzFwaAY7Sr0fUigEdtF8E9EO87JZPm7h4pRhy0aZBb6hgyTuKzsFv X-Received: by 2002:a05:620a:2688:b0:792:9248:c2e9 with SMTP id af79cd13be357-794ab11f6e4mr1556316885a.48.1716878030158; Mon, 27 May 2024 23:33:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716878030; cv=pass; d=google.com; s=arc-20160816; b=mFlI14GgjBaEy+TRfCtZHjg4KzPFCNkiI+KPQe1FC0X8xTEWjoJrzCWaT14T6jUbGq w2yXivkgUGAPP+SFJKSR6R4egKyfLsYeMPHmMZLWdtclH++2NXsmxVmZ8FsRgE2NyKlQ RbEoGs8U2SsrZQapqa2lCkzOuewDy66ayc7jwAtp8XZ4KhTHACmp1C3sUuVgA/h8bRTn Em1kI4BNVnGfUX9OmeiS/eUwN9Bs0V8B5I+MU9rDdsS3lxm6q4lvTiXFYlKeUatWtvli ej0tEMUM1yvNHcRqPzDNaCg3VKoP+rDhzc2sDZoz0r6Hb3e3BVpTvxLq7vojUa7Ci2fB kmEg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=suUTGs1cDKLmd3aGTMOWSYFyWIHAlEdpely8xzgqUSk=; fh=o/Rp63KNdYABY9wkXLin6Jd08Ee2OSHzz0QvUfGEL3s=; b=elK//GurSVH3x4gQ+8KPzReivcQpRAVddlJCc+UhQm5TiBww4RHO9nVNc7l4IM2RIF WB+Y1+TBpZ6OK20JNF2h+fjnS2KmkYHkta7PwymINA6hs509e3+fDZwPrP3B00sXffaX ZbenClqS5OFs18Mvnet8GsNQK/aKWG3Y6gKr9y8Qm0FcnoTMPYgwrYqG4JU02GTlIlU3 zDH7xS0bzb93A6aJg/ulkagUExwvVm1EXpT98JsZuToTC1iVFLd7Rszux3cYuu8l/Q5b 1oFQrEJdLYTGaTQAjeAnTsitYD+UPEdFjhlX/WtGKr1OnGgivCsiJhSRh6Mym5zapEv9 aTOw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-191809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191809-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43fdbfc60b5si2963321cf.569.2024.05.27.23.33.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 23:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-191809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-191809-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-191809-linux.lists.archive=gmail.com@vger.kernel.org" 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id DCEB51C219EF for ; Tue, 28 May 2024 06:33:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5F8F6A33C; Tue, 28 May 2024 06:33:41 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEFDC22067; Tue, 28 May 2024 06:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716878021; cv=none; b=hkJmYjUA9QkzuNELrD/beU6OtOp88laWpLM71N7Ac+gYM2Bb02cY7D0HXhmGChEVdaaZI8pgnlZL8ATT9TU9zNcIG5eY6ww2crldEvS4BKv/DHCYeWdJm73Zi6IdrHpN3jgNab4cTZIp5wgU+wRpkoJIMBGj4xlKsq3PihlYzIM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716878021; c=relaxed/simple; bh=ldjbI0S/6R2kqmtohSnLqSpSiUjP7PyHc2GT7iFo/70=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=G7kY6VR0OnHy4UzdtzdRjJxtgIauAy/dj1jNaw2TTt51fw3eLPim4WXZw2o/C+0TP2r0+plRdWyfwXDscHaklgoSf191csT6xr+hR9VfcxjrbDpe3je3VdrWthFBewp5P8hSpYfPPiRc89B0cdmE3BJ74uWXJgdjPK1b9y4QJSA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id ED81868BEB; Tue, 28 May 2024 08:33:32 +0200 (CEST) Date: Tue, 28 May 2024 08:33:32 +0200 From: Christoph Hellwig To: Dave Stevenson Cc: 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 , 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 Subject: Re: [PATCH 01/18] dma-direct: take dma-ranges/offsets into account in resource mapping Message-ID: <20240528063332.GA30051@lst.de> References: <20240524182702.1317935-1-dave.stevenson@raspberrypi.com> <20240524182702.1317935-2-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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240524182702.1317935-2-dave.stevenson@raspberrypi.com> User-Agent: Mutt/1.5.17 (2007-11-01) On Fri, May 24, 2024 at 07:26:45PM +0100, Dave Stevenson wrote: > 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. My memory is getting a little bad, but as dma_direct_map_resource is mostly used for (non-PCIe) peer to peer transfers, any kind of mapping from the host address should be excluded. (dma_direct_map_resource in general is a horrible interface and I'd prefer everyone to switch to the map_sg based P2P support, but we have plenty of users for it unfortunately)