From patchwork Fri Jun 7 10:54:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 13689688 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 0D9F2C27C53 for ; Fri, 7 Jun 2024 10:58:40 +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=3RMCRcpibiZHj3Dbqjgr2BGq0NDt3fP5DNMItlgn3q4=; b=qHFw9+nMH+akSN Tkb7DPW/iGouYZASYq6e0OwBcL8BhqNduwaaVYuwovO7UYYITqDO+cTGUzaUW/JQTl5k3OTA6khed lP/VVYHT0wu4TYxbgQE0Dgugf2NCit7B7aOlLVzcYV7gMbJXNVv9bXwCmVr6/JJqunf5aTszJNQRQ K3qL+0PowDgUbl3Jpfldwm87UMufGj+99EhUdDM7bpFKya8wewqXUc/e1NGsH4HPRNVkLkw6/54xh +arUpVlpXsfRLYYJYmP2q1k8VzO7hSv8mGe/XvMXHYbNPpDcqnYKuaChHHE+UcAcg+d1z0YFNs2iQ ZU/JbQy97qUMQhPeh/kQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFXIf-0000000DcY4-1abg; Fri, 07 Jun 2024 10:58:25 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sFXIZ-0000000DcU7-22Rt for linux-arm-kernel@lists.infradead.org; Fri, 07 Jun 2024 10:58:20 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-52bc335e49aso1840e87.3 for ; Fri, 07 Jun 2024 03:58:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1717757896; x=1718362696; 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=MDcq5k/0ttuhuW1s9eNFA8PIx5mHSgVIL61fKi53/Ns=; b=rj0b9AGovfma22D88YdsQeB+HfJAaRgjwzMIml5Vt1L7gi3oRvRNoZORlGS/iSLI8A 6yDAa2ixmXE6J4IX1gAUvsSW4wquXmMWOxMoPPMsGybCO+UoLjfFjLgcIRa/QcvKmNiv 1+QO6YKt6AyVW2VJjdHv7T6ADsmkxqCVZp3YDcmIc5WKTcKyH/GulfSMCdNwCp1B1OcY RN8qwZdtG8Ozipg1b4cBDXh8b3xsCdnpnbPn1qD/yWl1J/nEBEXGW8W5ajWLFRZQme9K QDF/UsVo9OLF4OnWS3orNRs6G0M4aNfEiGHJqBorF6ToUGPFdWpOX86US/x3atireWXK 4HVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717757896; x=1718362696; 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=MDcq5k/0ttuhuW1s9eNFA8PIx5mHSgVIL61fKi53/Ns=; b=b3nOuy1K+cQrC0Kh69JgGJUE0yIdRofJDOdatphgjRcphKHGeFRzXK/c2vFscBqnyO bINCJ9Dgac3QpRE4/He4duyafcuFJET6mQ4tpVIerajpTqJDM0diKclhCZw60PSaDlr9 6aRHrwMRjZFjI0W/ktQSgPLsA3mJ2eL8BtXyB+1rtfLRwzXmXM6kEAgmiipy6XVBFKGP C9Mntxz8ln/PEK6G95vBWlS1nt82hLlXc9P93K0MuyIMfNv7RRGnd80z1e1VuRIir+49 WmzVJ3bKXXOZzv+detksPNjIqYVI0cF4gXjbOYEvO1jR6llIhtJH56iIIy3TZ8DLVP12 r/Mg== X-Forwarded-Encrypted: i=1; AJvYcCXL/7MmcW06utyQDgOkW1vOiRGrR8pTEJ/6RQMNLgYUIoL4r6iYRCHnrp9TJW9HoYn00jtQOhON9LI2ypugBQaJOXxJyV+HEc+TqTJwGLLkk2nDj4Q= X-Gm-Message-State: AOJu0Yw4J7gThtz0doc+AMoQaQdp7yrM+p8URZDSWgjRey8L1Gmhwlnv D3kkTS+mLSB5TDdWHPVFIbdecOxrqARky94S+TjC64ff0LO0I55gGwj3WKHaYkE= X-Google-Smtp-Source: AGHT+IFKBOo5vF96Rp1eu8L7oXMzKFGJxvSnCqz7HcFftnGZ/GajF1ZZWz5V+BiNnKs89U3LBYWGnw== X-Received: by 2002:ac2:52b5:0:b0:52b:b173:7490 with SMTP id 2adb3069b0e04-52bb9fea373mr1207405e87.68.1717757894609; Fri, 07 Jun 2024 03:58:14 -0700 (PDT) Received: from localhost.localdomain ([2.221.137.100]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35ef5fd1c5fsm3739485f8f.113.2024.06.07.03.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 03:58:14 -0700 (PDT) From: Jean-Philippe Brucker To: will@kernel.org, lpieralisi@kernel.org, kw@linux.com, robh@kernel.org, bhelgaas@google.com, krzk+dt@kernel.org, conor+dt@kernel.org, liviu.dudau@arm.com, sudeep.holla@arm.com, joro@8bytes.org Cc: robin.murphy@arm.com, nicolinc@nvidia.com, ketanp@nvidia.com, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, Jean-Philippe Brucker , Jason Gunthorpe Subject: [PATCH v2 2/3] iommu/of: Support ats-supported device-tree property Date: Fri, 7 Jun 2024 11:54:15 +0100 Message-ID: <20240607105415.2501934-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240607105415.2501934-2-jean-philippe@linaro.org> References: <20240607105415.2501934-2-jean-philippe@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240607_035819_547073_E3BAC444 X-CRM114-Status: GOOD ( 11.00 ) 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 Device-tree declares whether a PCI root-complex supports ATS by setting the "ats-supported" property. Copy this flag into device fwspec to let IOMMU drivers quickly check if they can enable ATS for a device. Tested-by: Ketan Patil Reviewed-by: Jason Gunthorpe Reviewed-by: Liviu Dudau Reviewed-by: Robin Murphy Reviewed-by: Nicolin Chen Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/of_iommu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 3afe0b48a48db..082b94c2b3291 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -105,6 +105,14 @@ static int of_iommu_configure_device(struct device_node *master_np, of_iommu_configure_dev(master_np, dev); } +static void of_pci_check_device_ats(struct device *dev, struct device_node *np) +{ + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); + + if (fwspec && of_property_read_bool(np, "ats-supported")) + fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; +} + /* * Returns: * 0 on success, an iommu was configured @@ -147,6 +155,7 @@ int of_iommu_configure(struct device *dev, struct device_node *master_np, pci_request_acs(); err = pci_for_each_dma_alias(to_pci_dev(dev), of_pci_iommu_init, &info); + of_pci_check_device_ats(dev, master_np); } else { err = of_iommu_configure_device(master_np, dev, id); }