From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C7D9C18E5A for ; Tue, 10 Mar 2020 09:13:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ED58B2467F for ; Tue, 10 Mar 2020 09:13:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgCJJNT (ORCPT ); Tue, 10 Mar 2020 05:13:19 -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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C62A7C18E5B for ; Tue, 10 Mar 2020 09:12:45 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 9DF4B20674 for ; Tue, 10 Mar 2020 09:12:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DF4B20674 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 7183B2076F; Tue, 10 Mar 2020 09:12:45 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VJ5BLpr1VYMW; Tue, 10 Mar 2020 09:12:44 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 135A22044D; Tue, 10 Mar 2020 09:12:44 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CF301C1D8F; Tue, 10 Mar 2020 09:12:43 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id A1DA7C1D87; Tue, 10 Mar 2020 09:12:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 8D65B8832A; Tue, 10 Mar 2020 09:12:42 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GvY1epRxpBsG; Tue, 10 Mar 2020 09:12:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by hemlock.osuosl.org (Postfix) with ESMTPS id E1F8A886D0; Tue, 10 Mar 2020 09:12:41 +0000 (UTC) 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 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> Cc: Jean-Philippe Brucker , Will Deacon , linux-arm-msm@vger.kernel.org, Sudeep Holla , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Thierry Reding , linux-mediatek@lists.infradead.org, Andy Gross , Joerg Roedel , Hanjun Guo , Matthias Brugger , Bjorn Andersson , Sean Paul , Robin Murphy X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" 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 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D05BC10F27 for ; Tue, 10 Mar 2020 09:13:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 51F9424686 for ; Tue, 10 Mar 2020 09:13:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="OwUh8bg2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 51F9424686 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=8bytes.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org 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=w+njyRqFQjSOwsvlMpGfNivBO5WxChJ1BUklwvLukVs=; b=OwUh8bg2hl3/ifv+w+nHv1MeUr QWk95ZXtBbD+d92yuQP/6Fa6c6qokQ2fTe++x/kyw5LDuBKBLxFapVuwjoqSg31SECua8MY7/4LN3 +Qw8lDBqppqyVaDOSuw4AKSXK67GVL5rFDZoKW5VCS95wdrgFyfCDRXACFZNCd9KLdXop7SCsCeLS ChU4KGipazJ6if2gr2jhj6lr/7AiQgQ/QC36lQjsgOATDooN6yXIpacAAh8MDnZIfbkbULhIYewDn G8LXi0W9cF5TOQTawFIlxkHRKPf5sExBpn+vmhA2R0L+tUl5ywBsd3uGksCl7lGHx0wcB+AI73YVM 2fPB15Zw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jBawZ-0006Rw-QH; Tue, 10 Mar 2020 09:12:55 +0000 Received: from 8bytes.org ([81.169.241.247] helo=theia.8bytes.org) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jBawQ-0006Hq-Sk for linux-mediatek@lists.infradead.org; Tue, 10 Mar 2020 09:12:48 +0000 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200310_021247_084784_265C0AF3 X-CRM114-Status: GOOD ( 11.01 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , Lorenzo Pieralisi , Will Deacon , linux-arm-msm@vger.kernel.org, Joerg Roedel , Sudeep Holla , linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, Rob Clark , Thierry Reding , linux-mediatek@lists.infradead.org, Andy Gross , Joerg Roedel , Hanjun Guo , Matthias Brugger , Bjorn Andersson , Sean Paul , Robin Murphy MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.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 _______________________________________________ Linux-mediatek mailing list Linux-mediatek@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-mediatek From mboxrd@z Thu Jan 1 00:00:00 1970 From: 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> References: <20200310091229.29830-1-joro@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20200310091229.29830-1-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Sender: "iommu" To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Cc: Jean-Philippe Brucker , Will Deacon , linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Sudeep Holla , linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Thierry Reding , linux-mediatek-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Andy Gross , Joerg Roedel , Hanjun Guo , Matthias Brugger , Bjorn Andersson , Sean Paul , Robin Murphy List-Id: virtualization@lists.linuxfoundation.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