Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp668050imu; Tue, 11 Dec 2018 05:47:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/V6Qc2UwQhWBiNiEAGuq7jHGslQj5zdjsR03afbeniYFxnkelYcNpmA9G7UjAqRU85CETTV X-Received: by 2002:a63:e615:: with SMTP id g21mr14867555pgh.290.1544536038617; Tue, 11 Dec 2018 05:47:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544536038; cv=none; d=google.com; s=arc-20160816; b=l1JZDLa1Uhdm1FYC14SS+ezuGxdZqHo36zgPDwfilvATJCoypdriavL98BbWXcvqwX uX4qqy3rH+8sXBMhuEmKWQGPdKH85TSNh3MemU4iVZ2QGWsaSPx/NI5kYUeGAQcehpvu u8ncYs78CfxgA3m0tr4+ZuXJoru6odfP45f3yMFF9bvzXWjvgPoEXyZ4gzpClfU7gdfa X05RbDxIIVNpFJsl2DN/RdJ6oM3zKmclPo6cQsXJGQ4K5eRZ3pBIXoad/d6EcR2Y/0CP 3PbwugJvntuwq/eV3/Mbiv+YyeZL3KMghgZAEPtt4Wf2egQxVeknRaYUL3dnevTocMNl QGPw== 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=ePk4ZUQ6H2b/e6K509wPKeu0ok3MaHBWKr0LUVg1bEY=; b=MxsUDvjagOKJga1quG28whjvCfP8RoJHB/QctCU2AvqXR+Y5PsOzsQSVQu4tgNqhJB afw/SPlIBn+1GpTrRJ5iCBPdyegQJ72HefRuBVTvPj2qeoFxN2tDeLUWH3+SbwqobhOz kNmk8CSEDmMhTq0E1IKya29YaRlI3Y0Md5u+aNXIIBFrspMsqdrle6Vf6cpwpKtCpEp7 HrmkOb/9ISb+nZ4zKwF6ph1Jr5tUmUQftSvUtAGlOChAsnRfqiNirdX5esG8LrvSPPiB yP4V4pwHphsTCIKVx4a0sThWPmpn59bmv9k/naBW46sp0KekttzwQrZil2lvlIp1WUVl Rmrw== 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 c2si12683425plb.152.2018.12.11.05.47.03; Tue, 11 Dec 2018 05:47:18 -0800 (PST) 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 S1726691AbeLKNo3 (ORCPT + 99 others); Tue, 11 Dec 2018 08:44:29 -0500 Received: from 8bytes.org ([81.169.241.247]:53236 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbeLKNns (ORCPT ); Tue, 11 Dec 2018 08:43:48 -0500 Received: by theia.8bytes.org (Postfix, from userid 1000) id A68D33AF; Tue, 11 Dec 2018 14:43:46 +0100 (CET) From: Joerg Roedel To: iommu@lists.linux-foundation.org Cc: Russell Currey , Sam Bobroff , oohall@gmail.com, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , Dan Williams , Vinod Koul , Joerg Roedel , jroedel@suse.de, Mathias Nyman , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, dmaengine@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function Date: Tue, 11 Dec 2018 14:43:38 +0100 Message-Id: <20181211134343.10664-2-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181211134343.10664-1-joro@8bytes.org> References: <20181211134343.10664-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 Some places in the kernel check the iommu_group pointer in 'struct device' in order to find ot whether a device is mapped by an IOMMU. This is not good way to make this check, as the pointer will be moved to 'struct dev_iommu_data'. This way to make the check is also not very readable. Introduce an explicit function to perform this check. Cc: Greg Kroah-Hartman Acked-by: Greg Kroah-Hartman Acked-by: Robin Murphy Signed-off-by: Joerg Roedel --- include/linux/device.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/device.h b/include/linux/device.h index 1b25c7a43f4c..6cb4640b6160 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1058,6 +1058,16 @@ static inline struct device *kobj_to_dev(struct kobject *kobj) return container_of(kobj, struct device, kobj); } +/** + * device_iommu_mapped - Returns true when the device DMA is translated + * by an IOMMU + * @dev: Device to perform the check on + */ +static inline bool device_iommu_mapped(struct device *dev) +{ + return (dev->iommu_group != NULL); +} + /* Get the wakeup routines, which depend on struct device */ #include -- 2.17.1