From mboxrd@z Thu Jan 1 00:00:00 1970 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 A1D0BCD5BB8 for ; Thu, 5 Sep 2024 19:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Owner; bh=Dlm9oaDqDC/Rilnx4WUYmKV0yTXLS962knwxaE0uSWA=; b=qmwDXX3LkAkHxy S8ksvay739mZ/WmG9OD/23fHvk4UV1veuswdg9T+U2TBF7Yz1Y8vEwAW++166c9sLidoltjEERTkM 8aSgWPP6vLvUorVWe551dUvUl14q2NpX+NgtQHZGpQYmyw831n/FE8025c7GWMDJOQ5eW42TCNeIO K5K/dZCL9uRogTspsuAVdYrhr3ExCOmTXL9tD8zOelC62kFXEkvduN5UO1ViXkoJmE+u5rNwxGaYe rGsSjD6i/B4Z0O6DIktq9Jl4rHJLkVO+Ru5Vc5S90ou7CRAo1WiPBj+VCIjDioaQz1ZkfjsQ5r3MT 2xT53EUKesbcCsq9oxJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smHzA-00000009a8X-2B4m; Thu, 05 Sep 2024 19:17:40 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smHyB-00000009ZyE-0gN5 for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 19:16:40 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D39B85C5D50; Thu, 5 Sep 2024 19:16:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AECA6C4CEC3; Thu, 5 Sep 2024 19:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725563798; bh=9aJfL5uL8bd3t0e3HtAXpLc2f4fAdbCybcOsaulLVvI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=eIu2kEiAZBqDaT7yHN6eG+IDuaPCPDqCMMCTivKgx4KBGiK1W6iCjULtgbp/1EsRK i9u1E+SCe35Cetssk7Oj4XzhXUZujCQD+ij33X/pN7AMVtU337D31+dFFjzUBuhsZg X7R3efIF5cWEhzhkKre+MoM9CuDTPyo+oHeZKWbdVDReEhqdxF+C9mZXrSdg6h+D4S mYv5S2fFApkEos/3C4F/IxawXbYsRg7KTb0quLzS62h4yKjvGKFtqRsEuEgtqBpLa0 tdNYw6xddpyYDLB1xVqKqduxtln8ISOtNbGrBTHY9AbUzpaDcifg68D4U0mLOvG1kq FNomTfczVE/Ww== Date: Thu, 5 Sep 2024 14:16:35 -0500 From: Bjorn Helgaas To: Jan Kiszka Cc: Nishanth Menon , Santosh Shilimkar , Vignesh Raghavendra , Tero Kristo , Rob Herring , Krzysztof Kozlowski , Conor Dooley , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org, Siddharth Vadapalli , Bao Cheng Su , Hua Qian Li , Diogo Ivo , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Bjorn Helgaas , Kishon Vijay Abraham I Subject: Re: [PATCH v4 4/7] PCI: keystone: Add supported for PVU-based DMA isolation on AM654 Message-ID: <20240905191635.GA395079@bhelgaas> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <35b5f0ff-50e7-42f9-8b66-b967476dd6c5@siemens.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_121639_358379_C498C721 X-CRM114-Status: GOOD ( 31.96 ) 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 On Thu, Sep 05, 2024 at 09:07:36PM +0200, Jan Kiszka wrote: > On 05.09.24 18:33, Bjorn Helgaas wrote: > > [+cc Kishon, just in case you have time/interest ;)] > > > > On Wed, Sep 04, 2024 at 12:00:13PM +0200, Jan Kiszka wrote: > >> From: Jan Kiszka > >> > >> The AM654 lacks an IOMMU, thus does not support isolating DMA requests > >> from untrusted PCI devices to selected memory regions this way. Use > >> static PVU-based protection instead. > >> > >> For this, we use the availability of restricted-dma-pool memory regions > >> as trigger and register those as valid DMA targets with the PVU. > > > > I guess the implication is that DMA *outside* the restricted-dma-pool > > just gets dropped, and the Requester would see Completion Timeouts or > > something for reads? > > I cannot tell what happens on the PCI bus in that case, maybe someone > from TI can help out. > > On the host side, the PVU will record an error and raise an interrupt > which will make the driver report that to the kernel log. That's quite > similar to what IOMMU drivers do on translation faults. The main thing is that the DMA doesn't complete, as you mentioned below. > > Since there's no explicit use of "restricted-dma-pool" elsewhere in > > this patch, I assume the setup above causes the controller to drop any > > DMA accesses outside that pool? I think a comment about how the > > controller behavior is being changed would be useful. Basically the > > same comment as for the commit log. > > Right, this is what will happen. Will add some comment. > > > Would there be any value in a dmesg note about a restriction being > > enforced? Seems like it's dependent on both CONFIG_TI_PVU and some DT > > properties, and since those are invisible in the log, maybe a note > > would help understand/debug any issues? > > This is what you will see when there are reserved region and PVU in > play: > > keystone-pcie 5600000.pcie: assigned reserved memory node restricted-dma@c0000000 > ti-pvu 30f80000.iommu: created TLB entry 0.2: 0xc0000000, psize 4 (0x02000000) > ti-pvu 30f80000.iommu: created TLB entry 0.3: 0xc2000000, psize 4 (0x02000000) > ... > ath9k 0000:01:00.0: assigned reserved memory node restricted-dma@c0000000 Looks reasonable and solves my concern. > >> + of_for_each_phandle(&it, err, pdev->dev.of_node, "memory-region", > >> + NULL, 0) { > >> + if (of_device_is_compatible(it.node, "restricted-dma-pool") && > >> + of_address_to_resource(it.node, 0, &phys) == 0) > >> + ti_pvu_remove_region(KS_PCI_VIRTID, &phys); > > > > I guess it's not important to undo the PCIE_VMAP_xP_CTRL_EN and > > related setup that was done by ks_init_restricted_dma()? > > > > Right, I didn't find a reason to do that. OK, as long as you considered it :) Bjorn