Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp469626ybh; Tue, 10 Mar 2020 02:14:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuWN53qfqkTYhXoTJKxW8evu+PdUFJfAChP0vhW/j8qcx5pK5KPIWVwye5EcNmmJuKXww/N X-Received: by 2002:a54:4085:: with SMTP id i5mr421501oii.17.1583831663909; Tue, 10 Mar 2020 02:14:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583831663; cv=none; d=google.com; s=arc-20160816; b=04fo5KO+GqZZ/6FvyisanJ+U3SamMEM/J31kAQg1PSFagod6JxXQhTe70kF8ox9NnQ hT6UQ7cacZHqCpzRUA0JSKetsiYDUrQcFeYYwfmdLyy0/bOr5sCxGmjo/RTEmEcJcrp5 2eUk7juaFhIloArjx124Gfee4kfj+8IuihPqdH6A2zWXa7TVGjAouMIEPFC3jPoy4spl /bQsj/LrDAdTQsbbR6I2AKBsM4RVMUl0Ux82Halr4RNCxTr/UPK8jFYc6c8DCNAobypB ukMS4OE4tNqlsDi6epP7HKs7ZIfnYclgHOKI4mAcU86j8ZOd6paFJxIACyRkVqKNf5vA NeAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=JMwpNACL7X1vlxHSlzyOcwG7wAX3vUVnzEiH/+LAEeQ=; b=WrLD9GPm4wtqk2gR+g6YtuluQgNILDn8duK6sQ1dzVE/hExd5q0e6dDqW/wRIqlCUz oiXaiIXpE+amdHw0+yLVaKbJ+IOSe7LKttm71K1rFUVR8tVGCDZJOnqRFz9kVALWPVA+ IcUaNe6dHIqXlI978LgWq25BQK3gvAUhvZlsTA4+kwRWQPhzQABOgXqjLwxIxshAsNij EDxVNk9l4XwdChHsWY1wudRSS8A1+wpoDyUXdXKIrizTaaBZ5FlyN5nmBaqaTZtq071A PtF9N59C1E3kzmADdoLSZI/VSQ1/98IJh9zfc0nVVsLjYvWzzHW30WqmF+WK/ULC20Fd Fv6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14si4753275otp.243.2020.03.10.02.14.10; Tue, 10 Mar 2020 02:14:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726861AbgCJJNV (ORCPT + 99 others); Tue, 10 Mar 2020 05:13:21 -0400 Received: from 8bytes.org ([81.169.241.247]:50500 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbgCJJMg (ORCPT ); Tue, 10 Mar 2020 05:12:36 -0400 Received: by theia.8bytes.org (Postfix, from userid 1000) id CD11C768; Tue, 10 Mar 2020 10:12:32 +0100 (CET) From: Joerg Roedel To: iommu@lists.linux-foundation.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, virtualization@lists.linux-foundation.org, Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Rob Clark , Sean Paul , Will Deacon , Robin Murphy , Joerg Roedel , Matthias Brugger , Thierry Reding , Jean-Philippe Brucker , Andy Gross , Bjorn Andersson , Joerg Roedel Subject: [PATCH 06/15] iommu: Move iommu_fwspec to struct dev_iommu Date: Tue, 10 Mar 2020 10:12:20 +0100 Message-Id: <20200310091229.29830-7-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200310091229.29830-1-joro@8bytes.org> References: <20200310091229.29830-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Move the iommu_fwspec pointer in struct device into struct dev_iommu. This is a step in the effort to reduce the iommu related pointers in struct device to one. Tested-by: Will Deacon # arm-smmu Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 3 +++ include/linux/device.h | 1 - include/linux/iommu.h | 12 ++++++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index beac2ef063dd..826a67ba247f 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -2405,6 +2405,9 @@ int iommu_fwspec_init(struct device *dev, struct fwnode_handle *iommu_fwnode, if (fwspec) return ops == fwspec->ops ? 0 : -EINVAL; + if (!dev_iommu_get(dev)) + return -ENOMEM; + fwspec = kzalloc(sizeof(*fwspec), GFP_KERNEL); if (!fwspec) return -ENOMEM; diff --git a/include/linux/device.h b/include/linux/device.h index 405a8f11bec1..ca29c39a6480 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -613,7 +613,6 @@ struct device { void (*release)(struct device *dev); struct iommu_group *iommu_group; - struct iommu_fwspec *iommu_fwspec; struct dev_iommu *iommu; bool offline_disabled:1; diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 1c9fa5c1174b..f5edc21a644d 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -368,14 +368,15 @@ struct iommu_fault_param { * struct dev_iommu - Collection of per-device IOMMU data * * @fault_param: IOMMU detected device fault reporting data + * @fwspec: IOMMU fwspec data * * TODO: migrate other per device data pointers under iommu_dev_data, e.g. * struct iommu_group *iommu_group; - * struct iommu_fwspec *iommu_fwspec; */ struct dev_iommu { struct mutex lock; - struct iommu_fault_param *fault_param; + struct iommu_fault_param *fault_param; + struct iommu_fwspec *fwspec; }; int iommu_device_register(struct iommu_device *iommu); @@ -614,13 +615,16 @@ const struct iommu_ops *iommu_ops_from_fwnode(struct fwnode_handle *fwnode); static inline struct iommu_fwspec *dev_iommu_fwspec_get(struct device *dev) { - return dev->iommu_fwspec; + if (dev->iommu) + return dev->iommu->fwspec; + else + return NULL; } static inline void dev_iommu_fwspec_set(struct device *dev, struct iommu_fwspec *fwspec) { - dev->iommu_fwspec = fwspec; + dev->iommu->fwspec = fwspec; } int iommu_probe_device(struct device *dev); -- 2.17.1