From patchwork Mon Apr 29 11:39:38 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: 13646678 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 A52E6C4345F for ; Mon, 29 Apr 2024 11:43:24 +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=btRB0avc4mV494hv8XdGc2Y1GYoW2fvvsua5/RxBiIc=; b=B6HjDVveUrSY6s C2oLbPqJa9k5g/WGM/w/7OB3VpAIjen6kMH92gBXKvCy5HwHiNHx2uUqTeFIBJSidFWeI7rOvx2T4 Cl+ThADxLGrDQJXTBbLczDAneGzB1QRF9BceOyCVpBL+0m2maJEhatMRhUVXlikuXC7yhzFG+INIG MMIjXe0gxzf4FOzjFnkDSyRJh0XHQWVmhL6Q0KltSkr2zy2MNQNS7n6T9xSUed+p52/Wn7NpCpWZd tfQXABll2r24UfQFkw+8cYje9tDMAFp1yHjH65xRyP9+NY+zPPX3HdIyuPNNkeLpx//5Mure+ae2p K6eUrzfQRSlPQl49omkA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PPe-00000002V0o-3CfM; Mon, 29 Apr 2024 11:43:14 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1PPa-00000002Uza-3rUa for linux-arm-kernel@lists.infradead.org; Mon, 29 Apr 2024 11:43:13 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2dd6c160eaaso53280441fa.1 for ; Mon, 29 Apr 2024 04:43:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714390989; x=1714995789; 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=+iobJUdKPnLVIb4EdGa85F44GNjBoMRFbMt/Rt6vNcE=; b=gvtchyX+q36DkUmRNOq5vk7SU3WbTKHyjbhJvUJLRhq5OFPfRtpioFnGbX35xw5Eal gYGPzu9kceQouXGvX43bsriQOEBW2DWpzmlxmrgVFtJCePWAMsujEb1FFbQi33k71Yp6 ZBYqfdrvhX8odwppUjqO3DLBOzZnFb38+/dBbBW2xYV6HiEfhriaxJXSAPRsBFA2VPIp 3FilCvyPN75ER9Z19cGT3KuBWpmEDV3pC9k/6T9Q8yi98OK9PFh56tYILxRh4V0fM3EN y2uZMjYDNZYjUNaqpkJ0p2nA+z6xajslchEaCrQxCApnLVOeNTsuGA4oPfSyaZ0D9WwM 8qyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714390989; x=1714995789; 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=+iobJUdKPnLVIb4EdGa85F44GNjBoMRFbMt/Rt6vNcE=; b=SYZgVCTmPD70NLuxxVm+N9/KPx5XugYsQ8DC0PZkcgt85RZTAOZDPK53ep6NQCLMwR D67xyeewXcucLMohgtIOSQSHANGESKebfYuu9BTpOFFiZqe92Q9V9O+axXvv0HP7jYYv rhScwDtOstpj/NZxAn5ZIyqyblzr2isJo/GZvBQw0pXrS9ZqaOrYvAn56U53a5Qq9xhX BgQMvw2sF2CJaGkg8k6Elw+TNq9cUqA7aNHTG7xMDIVFJx8MS2DSz4sosnbMeNUwD2hy LsAzzLWdZhZtwKcjQlnrtGWa0W5o6O+nk5d60PmSLhnUynl0OuWwoURQ0VdB8QoHOJfF zxUw== X-Forwarded-Encrypted: i=1; AJvYcCVkbr1eGpKL6AozVEbUyU3GOi0rzhEg7hYcZOw2PyFSmmsepYdSOFyiRpWjszRM/gaTgSL5CpsJ/L9ukwacqlWbgCc07p1EBnbb1BfAkjymCxAjnME= X-Gm-Message-State: AOJu0YweJoJfJL5HGKc4M5AroOd6zN1vjkb5YmXJn8CuwwnHezGBvXYa omlwh/hsLd/2Ra2FADFnhLkOYhJ9n/fFF+ALtZb4lz4cGrsz73W5AkhrdDdrDkI= X-Google-Smtp-Source: AGHT+IEq/BVzW1OsfvO81EUURO73iK1PlTqRjZgwsgNcExdaG/QA6hqLUNgRw7WtOV6ZCZAJNddz7g== X-Received: by 2002:a05:651c:1a13:b0:2df:7d44:d784 with SMTP id by19-20020a05651c1a1300b002df7d44d784mr8398632ljb.3.1714390988764; Mon, 29 Apr 2024 04:43:08 -0700 (PDT) Received: from localhost.localdomain ([2.221.137.100]) by smtp.gmail.com with ESMTPSA id j28-20020a05600c1c1c00b0041bfb176a87sm7006611wms.27.2024.04.29.04.43.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 04:43:08 -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 Subject: [PATCH 2/3] iommu/of: Support ats-supported device-tree property Date: Mon, 29 Apr 2024 12:39:38 +0100 Message-ID: <20240429113938.192706-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240429113938.192706-2-jean-philippe@linaro.org> References: <20240429113938.192706-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-20240429_044310_983516_1929DDE9 X-CRM114-Status: GOOD ( 10.89 ) 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. Signed-off-by: Jean-Philippe Brucker Tested-by: Ketan Patil Reviewed-by: Jason Gunthorpe Reviewed-by: Liviu Dudau Reviewed-by: Robin Murphy Reviewed-by: Nicolin Chen --- 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); }