From patchwork Wed May 24 18:01:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 9746697 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D582460209 for ; Wed, 24 May 2017 17:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAE82289A1 for ; Wed, 24 May 2017 17:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF39C289BD; Wed, 24 May 2017 17:59:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34216289A1 for ; Wed, 24 May 2017 17:59:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4oRq9eQeTy7RlO01iE/sjKLLiAgK6AJB7HL6/qQojeo=; b=h3RhSgh0aORfeKEi0hueB8aUij E8qFpXaTlB7Cc0brmMIIz4V/bDRuZeF7mArbFipIn9zEsg+2WbQd/kGbPHg5Z6CObVdHTNjXgWhiO hm3vyrc8yVppx3kzAsrz75NCOgbbUqTY7J6k6uCc00/AsG7rt8dadkjG8I7bD0B4h733G8UhRViyz J20zdLkKcXsM5qSi4a+QqAGSBJT+VzYoViptEZY7llwefqJjJhQteMwtdeYkzBJbZ8Ct4S9qzpboe N05zKSd33TDCXd9B3GaAnQ9O8yI8pjygIjvHxmgUrTOZTALVy1V0a7WIBY3QhZ7L4DgL0Hq6IPe9S XZBKMGZQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDaYq-00084v-W8; Wed, 24 May 2017 17:59:05 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dDaYZ-0007bu-Fx for linux-arm-kernel@lists.infradead.org; Wed, 24 May 2017 17:58:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3F6C31682; Wed, 24 May 2017 10:58:30 -0700 (PDT) Received: from e106794-lin.cambridge.arm.com (e106794-lin.cambridge.arm.com [10.1.210.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 14DAC3F41F; Wed, 24 May 2017 10:58:26 -0700 (PDT) From: Jean-Philippe Brucker To: linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org Subject: [PATCH 3/7] iommu/of: Check ATS capability in root complex nodes Date: Wed, 24 May 2017 19:01:39 +0100 Message-Id: <20170524180143.19855-4-jean-philippe.brucker@arm.com> X-Mailer: git-send-email 2.12.1 In-Reply-To: <20170524180143.19855-1-jean-philippe.brucker@arm.com> References: <20170524180143.19855-1-jean-philippe.brucker@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170524_105847_887428_CEFC2C3B X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, lorenzo.pieralisi@arm.com, will.deacon@arm.com, joro@8bytes.org, thunder.leizhen@huawei.com, rjw@rjwysocki.net, okaya@codeaurora.org, robh+dt@kernel.org, hanjun.guo@linaro.org, sudeep.holla@arm.com, bhelgaas@google.com, tn@semihalf.com, sunil.kovvuri@gmail.com, robin.murphy@arm.com, lenb@kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The PCI root complex node in DT has a property indicating whether it supports ATS. Store this bit in the IOMMU fwspec when initializing a device, so it can be accessed later by an IOMMU driver. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/of_iommu.c | 8 ++++++++ include/linux/iommu.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index 9f44ee8ea1bc..3d8168e80634 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -147,6 +147,11 @@ static int __get_pci_rid(struct pci_dev *pdev, u16 alias, void *data) return iommu_spec->np == pdev->bus->dev.of_node; } +static bool of_pci_rc_supports_ats(struct device_node *rc_node) +{ + return of_property_read_bool(rc_node, "ats-supported"); +} + static const struct iommu_ops *of_pci_iommu_init(struct pci_dev *pdev, struct device_node *bridge_np) { @@ -175,6 +180,9 @@ static const struct iommu_ops ops = of_iommu_xlate(&pdev->dev, &iommu_spec); + if (!IS_ERR_OR_NULL(ops) && of_pci_rc_supports_ats(bridge_np)) + pdev->dev.iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_SUPPORTS_ATS; + of_node_put(iommu_spec.np); return ops; } diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 2cb54adc4a33..206821b9044c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -360,6 +360,7 @@ extern struct iommu_group *generic_device_group(struct device *dev); * @ops: ops for this device's IOMMU * @iommu_fwnode: firmware handle for this device's IOMMU * @iommu_priv: IOMMU driver private data for this device + * @flags: miscellaneous properties for this device * @num_ids: number of associated device IDs * @ids: IDs which this device may present to the IOMMU */ @@ -367,10 +368,13 @@ struct iommu_fwspec { const struct iommu_ops *ops; struct fwnode_handle *iommu_fwnode; void *iommu_priv; + u32 flags; unsigned int num_ids; u32 ids[1]; }; +#define IOMMU_FWSPEC_PCI_RC_SUPPORTS_ATS (1 << 0) + int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, const struct iommu_ops *ops); void iommu_fwspec_free(struct device *dev);