From patchwork Mon Dec 9 11:59:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 11279257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 68842139A for ; Mon, 9 Dec 2019 12:00:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 50BBE2077B for ; Mon, 9 Dec 2019 12:00:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50BBE2077B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11A0A6E431; Mon, 9 Dec 2019 12:00:16 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 452656E421; Mon, 9 Dec 2019 12:00:13 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id p17so14620258wmi.3; Mon, 09 Dec 2019 04:00:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WWB0gv0IKvrIB1DiP2k54lYzCkgCyMMzc45SZZG00Os=; b=ugNNhdVTT8sUvUEsPNwWnyoWikN+K5laBWRwqcWDPvEbqWZec+hUdf0IRJLifY0aTo NVmxE4Wghvzgn7SF1hgdwWmNy28535QnZyUYnAx4ReH83Y/Wqc6fWhzrILg7U974dG3T Ygpe3+s3y1dnGgU7JBd8+PYKxlQ3te138D1Cb2BSqcN+dmUwqu4b9fmHlj3lh6hhG4C9 1OfELeaF/YP4WH1K1DrANTascBgOqko0ci2lit830wC4gxVR8PGqtUtmMZLGaKtWxx86 izZEz1mAJP7ix1ldgIZIv72KRKCTuOOfuRTMQ4nJmi3KeNu6WMaBDmdFeCoq9KBcfIwx xSwA== X-Gm-Message-State: APjAAAW8WaIx2ZevgiEUSfaN/O402/bdvw9to+j32zjPkiTeUjFChmrV JSfa4UnMB8KgsjZ7jhaSzdk= X-Google-Smtp-Source: APXvYqxdw3QGqId0WWIJ8FkEPSj74gaCo0YXXuupNcHzm44v6wyffmecyZxNMEwCEOOhxRKKC/h/QA== X-Received: by 2002:a1c:4004:: with SMTP id n4mr23578319wma.153.1575892811780; Mon, 09 Dec 2019 04:00:11 -0800 (PST) Received: from localhost (pD9E518ED.dip0.t-ipconnect.de. [217.229.24.237]) by smtp.gmail.com with ESMTPSA id c1sm26876206wrs.24.2019.12.09.04.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 04:00:10 -0800 (PST) From: Thierry Reding To: Ben Skeggs Subject: [PATCH v3 2/9] iommu: Add dummy dev_iommu_fwspec_get() helper Date: Mon, 9 Dec 2019 12:59:58 +0100 Message-Id: <20191209120005.2254786-3-thierry.reding@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191209120005.2254786-1-thierry.reding@gmail.com> References: <20191209120005.2254786-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WWB0gv0IKvrIB1DiP2k54lYzCkgCyMMzc45SZZG00Os=; b=oGcGDPaluv2mBeTtJ/vs1cgoT3/Yi9JY24nblOBc3AC3qvNYxsD63sgL33QiKkU6iB X8TDy4+G7ji6c6xTws1R7ECRQt7lgV1pf4j0kS9Sdtz5iNsgheiBNdCA/nRwGfwdXbbG VJ2Z8LK5nmL5Bphivwd4iGrV+HeiLjG7MEfFj7IdaYnvClWNLXBojZUunFPnrqggkhRd BOrH0+SRbKFrZS2KpV8qqux1pjbwa4vD9QqOTI6WXkAtigiPhfnORPebg+m9T+4kaaQ7 YQhzF9WraavPVfSv6a7tq83qWbjQwA4IDb1jm1I0QMSVYBra1DulAO/gWPOt1+5Dec/Z RYrA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joerg Roedel , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Thierry Reding This dummy implementation is useful to avoid a dependency on the IOMMU_API Kconfig symbol in drivers that can optionally use the IOMMU API. In order to fully use this, also move the struct iommu_fwspec definition out of the IOMMU_API protected region. Acked-by: Joerg Roedel Signed-off-by: Thierry Reding --- Changes in v3: - remove duplicate struct iommu_fwspec definition include/linux/iommu.h | 48 +++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 216e919875ea..bb28453bb09c 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -190,6 +190,27 @@ struct iommu_sva_ops { iommu_mm_exit_handler_t mm_exit; }; +/** + * struct iommu_fwspec - per-device IOMMU instance data + * @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: IOMMU flags associated with this device + * @num_ids: number of associated device IDs + * @ids: IDs which this device may present to the IOMMU + */ +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]; +}; + +/* ATS is supported */ +#define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0) + #ifdef CONFIG_IOMMU_API /** @@ -565,27 +586,6 @@ extern struct iommu_group *generic_device_group(struct device *dev); /* FSL-MC device grouping function */ struct iommu_group *fsl_mc_device_group(struct device *dev); -/** - * struct iommu_fwspec - per-device IOMMU instance data - * @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: IOMMU flags associated with this device - * @num_ids: number of associated device IDs - * @ids: IDs which this device may present to the IOMMU - */ -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]; -}; - -/* ATS is supported */ -#define IOMMU_FWSPEC_PCI_RC_ATS (1 << 0) - /** * struct iommu_sva - handle to a device-mm bond */ @@ -634,7 +634,6 @@ int iommu_sva_get_pasid(struct iommu_sva *handle); struct iommu_ops {}; struct iommu_group {}; -struct iommu_fwspec {}; struct iommu_device {}; struct iommu_fault_param {}; struct iommu_iotlb_gather {}; @@ -980,6 +979,11 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode) return NULL; } +static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev) +{ + return NULL; +} + static inline bool iommu_dev_has_feature(struct device *dev, enum iommu_dev_features feat) {