From patchwork Tue Dec 11 13:43:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 10723813 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DEC691E for ; Tue, 11 Dec 2018 13:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F58429562 for ; Tue, 11 Dec 2018 13:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 837C72ACB1; Tue, 11 Dec 2018 13:44:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C9F52AC96 for ; Tue, 11 Dec 2018 13:44:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbeLKNo2 (ORCPT ); Tue, 11 Dec 2018 08:44:28 -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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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