Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp773873lqt; Fri, 19 Apr 2024 09:59:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWi9M/mLSIuP6oIq8m++TgcpMHMC1ah2QmYxNef0VgNRtw3ckqM0sKVUZLxvXUFCBMrGTtvOT/3MuuqqDL4hKtTgYhyfs92+oIC8xcPvA== X-Google-Smtp-Source: AGHT+IFUMfju0o85MYAzRJb/jZIq58becVJft0ZnNT6Fdp/fgRAH+reiTMqAw9xLMZKCI4h64zlY X-Received: by 2002:a05:6a00:240f:b0:6ec:ffb7:7dc7 with SMTP id z15-20020a056a00240f00b006ecffb77dc7mr3255125pfh.26.1713545941668; Fri, 19 Apr 2024 09:59:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713545941; cv=pass; d=google.com; s=arc-20160816; b=iTrB50CSptmL+jmDgXWwemVfJMV4lPL9nkpMVZo5L4zZOKJLvTvnl+2UxiDR9n3hKD 0o0Aodw3mJ8na4zU7tjLo8weEFWQvfzKfd9iKgcynG+GHk9dw6l9XAVCiC5SSpOv33XR lucRwycu5qiBkt1yY+Jl4iacIr7dmP+oSeCLOyO2E6GesfzR0hwAkLajicG03JtILpSu QXNPcRuaQy4QSHvrmmruF0Z3U8/wyw/xH54j+wcBMCtVAHekeQCoAr8TZkzvSuEvPmHy vUxbNPrVIOKbuegeM/P8o0WUKLMtPKJQNM4acDqX7+KHOCw+GKRq4kGj508o8O4fW8Yn 4qXA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=aDlptG7u/9a+2OMMTuQ+1Z29NGjIonBJ4xiRNzP6JEQ=; fh=aRP+j2eI8HLZeRlPbVNPpUzWFpzi52Y0udFwaQsFbe0=; b=i09hxf4GAF3XuhSOUuV4DA25vuEovTr+YSO4L1HGn9j9Ni123S1OIQWjN7uEbQk4xI rLhsHPHH++qOYjY8k2bYDMzaLLeggyb2sFea96FNqXrgMDnnm/MhbqniAT9vDgYUm45w 0VAI9Y3FWvIetrpnKvrfzFOS9CN/PnuY2bwpMBvvp4W17Uwu65fFGxep/xIOAEG7CSfW JgndmHvvDUdXHHFJMhO0iX4p2USxHncOW9OCgJiwkSaS8Qe9Lz8UREVh4wV9fCRc7i3q MfmQzlAlRYaRWVQeorsmJ+VU5+vWKvjotmWpUMBpKaFCcm+XaggiUKWOjGVJrtoF+L8w pdIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151796-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p1-20020a63ab01000000b005b7160263f2si3390391pgf.154.2024.04.19.09.59.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 09:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-151796-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-151796-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-151796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B8BA62870CA for ; Fri, 19 Apr 2024 16:58:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 76E0213D27F; Fri, 19 Apr 2024 16:56:33 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 767B113B5BE; Fri, 19 Apr 2024 16:56:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713545792; cv=none; b=HgqIpKWndMMylTClnNSL8a95e8ymAWzoIDldqKKvoZzS8O4zdzE/2oei9zqLhry82nbFGtYuoesLYTkG9CTq4B1VPofvM2iYXWssU7awBLo5b4T2pqXEj+SwTIlo1G/9ULtKPuaUnnOFmkcnUVRaye5GtVe2X1MnbiAQkdS2h40= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713545792; c=relaxed/simple; bh=0yp/FZZMQc5hYIr1LfFNeb5WKTxy3Na7JljiqpLCQ/E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pl/CG6OWeiuwWRDJB4lL6uYgM7Nf5NHDOMdy6UBS39IBSbBVocWp+NMOmZYTR5BRMQPmv7RNRDiJYBV0NBhPBZvcMajhC+XmVRRlyS8Mfc/92S2xVnJrkE78mwB9+romJinId/WhUY74jCZ97SHIjiGWkekB9K3vFnHepT7n8cs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 414E5153B; Fri, 19 Apr 2024 09:56:59 -0700 (PDT) Received: from e121345-lin.cambridge.arm.com (e121345-lin.cambridge.arm.com [10.1.196.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C0BC63F792; Fri, 19 Apr 2024 09:56:28 -0700 (PDT) From: Robin Murphy To: Will Deacon , Joerg Roedel Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, devicetree@vger.kernel.org, Rob Herring , Saravana Kannan , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , Jean-Philippe Brucker Subject: [PATCH 4/4] iommu: Remove iommu_fwspec ops Date: Fri, 19 Apr 2024 17:56:02 +0100 Message-Id: <3b8cf1725b20beccf009f7589ab4ab41447721b3.1713523251.git.robin.murphy@arm.com> X-Mailer: git-send-email 2.39.2.101.g768bb238c484.dirty In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The ops in iommu_fwspec are only needed for the early configuration and probe process, and by now are easy enough to derive on-demand in those couple of places which need them, so remove the redundant stored copy. Signed-off-by: Robin Murphy --- drivers/iommu/iommu-priv.h | 5 +++++ drivers/iommu/iommu.c | 11 ++--------- drivers/iommu/of_iommu.c | 4 +++- include/linux/iommu.h | 2 -- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/iommu/iommu-priv.h b/drivers/iommu/iommu-priv.h index 078cafcf49b4..a34efed2884b 100644 --- a/drivers/iommu/iommu-priv.h +++ b/drivers/iommu/iommu-priv.h @@ -19,6 +19,11 @@ static inline const struct iommu_ops *dev_iommu_ops(struct device *dev) const struct iommu_ops *iommu_ops_from_fwnode(const struct fwnode_handle *fwnode); +static inline const struct iommu_ops *iommu_fwspec_ops(struct iommu_fwspec *fwspec) +{ + return iommu_ops_from_fwnode(fwspec ? fwspec->iommu_fwnode : NULL); +} + int iommu_group_replace_domain(struct iommu_group *group, struct iommu_domain *new_domain); diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 07a647e34c72..996e79dc582d 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -510,7 +510,6 @@ DEFINE_MUTEX(iommu_probe_device_lock); static int __iommu_probe_device(struct device *dev, struct list_head *group_list) { const struct iommu_ops *ops; - struct iommu_fwspec *fwspec; struct iommu_group *group; struct group_device *gdev; int ret; @@ -523,12 +522,7 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list * be present, and that any of their registered instances has suitable * ops for probing, and thus cheekily co-opt the same mechanism. */ - fwspec = dev_iommu_fwspec_get(dev); - if (fwspec && fwspec->ops) - ops = fwspec->ops; - else - ops = iommu_ops_from_fwnode(NULL); - + ops = iommu_fwspec_ops(dev_iommu_fwspec_get(dev)); if (!ops) return -ENODEV; /* @@ -2831,7 +2825,7 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode) return -EPROBE_DEFER; if (fwspec) - return ops == fwspec->ops ? 0 : -EINVAL; + return ops == iommu_fwspec_ops(fwspec) ? 0 : -EINVAL; if (!dev_iommu_get(dev)) return -ENOMEM; @@ -2843,7 +2837,6 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode) fwnode_handle_get(iommu_fwnode); fwspec->iommu_fwnode = iommu_fwnode; - fwspec->ops = ops; dev_iommu_fwspec_set(dev, fwspec); return 0; } diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index a5d6ff8e4e72..fde3053706c0 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c @@ -17,6 +17,8 @@ #include #include +#include "iommu-priv.h" + static int of_iommu_xlate(struct device *dev, struct of_phandle_args *iommu_spec) { @@ -32,7 +34,7 @@ static int of_iommu_xlate(struct device *dev, if (ret) return ret; - ops = dev_iommu_fwspec_get(dev)->ops; + ops = iommu_ops_from_fwnode(&iommu_spec->np->fwnode); if (!ops->of_xlate || !try_module_get(ops->owner)) return -ENODEV; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 0614b2736d66..ddfc2c9cdda4 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -965,7 +965,6 @@ extern struct iommu_group *generic_single_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 * @flags: IOMMU_FWSPEC_* flags * @num_ids: number of associated device IDs @@ -976,7 +975,6 @@ extern struct iommu_group *generic_single_device_group(struct device *dev); * consumers. */ struct iommu_fwspec { - const struct iommu_ops *ops; struct fwnode_handle *iommu_fwnode; u32 flags; unsigned int num_ids; -- 2.39.2.101.g768bb238c484.dirty