Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp751545imu; Tue, 11 Dec 2018 07:04:19 -0800 (PST) X-Google-Smtp-Source: AFSGD/VttSPHspyadAGw0AePC69lvW6E88OhnKMujSLuQ7uhClSAGkwh3Y46wKaV6jy60V+RQCYn X-Received: by 2002:a17:902:2a0a:: with SMTP id i10mr16020243plb.323.1544540659129; Tue, 11 Dec 2018 07:04:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544540659; cv=none; d=google.com; s=arc-20160816; b=eUFMwGUV4FWnmUVOhcFX4XNaEMLxhrpcqSR5xpGE+jmsZDJ/rJKftmSGbDKdu+zqQi Zv8T+5BXpq86d6kawjvkGB93QNY2W48OWMFhzBUwpvaRE9peFpKVv+acHohP7daVvg28 2oAlSyL0akfg7HFJVUoNNc7JVicfZC2qYCvHxosV6Og644smppX1k4h1bHw7cV3Po3/P ot7xWLPw3J0fNCUJt/3xVCRU+aGQxz7S40piVEO1Fqb8pkRQYjnHN2Nyk2LxrmT0A+3N wFRULwK4RE+se7FH0rjtrrSRqet1z2flmtDw61UOf+cokBlmG5WtuyOOkp1Hwy5FOYeH kRVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=1AO66jJhSY8/evsRYM/xVdgBN8qsSLYY7v4QBGE5+8g=; b=dN8+04+ZZBWwg1dKdfWU6wTyC5kkXY//oudED/w//IGtZxloEF4xobNKZzIGPeKXE6 YRmEgh54egRQLSEzeJZ6oL0pcd4SkdYFgsKP/dqLPGIUNBun/jIvrlS02V0tdX8RDN0i SiMwPstuhLkY0q4Y1as8bmAhi0z4VZqnSOyK3o/SEB4PL+9n57/lwNUePHmTTutEoFzT DvL20PnCI/WOLyvit3gbgcwU0dZ9PAY8Eai0xI9WC+WscQHiv1DGobj3AFm0GonsVOM2 Lqkm6hI0z9cq3NI1t2MtpIF+i1FYn5BgDi1GHfq1wXgX9Svmoo54XDXqNm7iHUp6RgYM K+qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=u5kN6xfN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i13si12137418pgj.199.2018.12.11.07.04.02; Tue, 11 Dec 2018 07:04:19 -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; dkim=pass header.i=@cogentembedded-com.20150623.gappssmtp.com header.s=20150623 header.b=u5kN6xfN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726614AbeLKO7i (ORCPT + 99 others); Tue, 11 Dec 2018 09:59:38 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:33594 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726417AbeLKO7h (ORCPT ); Tue, 11 Dec 2018 09:59:37 -0500 Received: by mail-lj1-f193.google.com with SMTP id v1-v6so13268983ljd.0 for ; Tue, 11 Dec 2018 06:59:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cogentembedded-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:organization:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=1AO66jJhSY8/evsRYM/xVdgBN8qsSLYY7v4QBGE5+8g=; b=u5kN6xfNUnAQzEN+auFhyI+Ou8JVB32aqhDqm1+HsMhKPYrTcfGlZceEboL07m4K88 ZiyzoJJAFK+LhoLf09KOOmxQQypTPk0R+mIAK/sYse0yQj9nmKdGo9Ty6tN9MQHWUwPq SbRleckMwpRpOo1v9RpFqZKMzcegGcTErfZNS/wgxG+C46Esf+k/sYUy6UZcR5XGPX/R q+2fDtHutFSnrPrFDpHyI0t/q3ze1e5CtZmgrdqvlWhApAWVFlMydtYv55fj97Ooi3dw MOimZqd8Qw9FL2uGYSUGKVnasodIacw1fELeQCuTl7+9G9cGMIyYsdinU//cju2U5C2E WYIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1AO66jJhSY8/evsRYM/xVdgBN8qsSLYY7v4QBGE5+8g=; b=KSEglMIoAMGoO02gShJKpFPFJhaXCNXXYqGx8P6nQR/G5q74oYzrGft6SjobjH9arr cF8suvX2uC8f+wFstgg32uJy9vnJwly1IJB9kwCZREeZ0L0g1Rt9mIx9wCk/aK/qWpTV XUSmluNkmuZBn5HauKi75aibBRJDYLB7YjAtOhDrpda5EzOKJgR5MCXUNCBpAPImpabD gAq+nm/IS3EWFP4eMKLqrEaB6+U303Q2246ihPWhu0JMfEJWScFfXLl7dCKzUma4t5+2 OSL8bmFaScQc9rcdWDFJmLma3SE3WS2X+ehK4QMZ1waC4h92gcxfZxm3sW6Q+K23Va7F fpGA== X-Gm-Message-State: AA+aEWa0RGlQ/NCCFApnwGbFuE0e697cBcSVUhaxWUBwTpEmjYpo9MKF WtWvLo/nYVLqfUSkQOnXtFIhTw== X-Received: by 2002:a2e:a289:: with SMTP id k9-v6mr9897024lja.24.1544540375561; Tue, 11 Dec 2018 06:59:35 -0800 (PST) Received: from wasted.cogentembedded.com ([31.173.85.248]) by smtp.gmail.com with ESMTPSA id b25sm2628573lfa.96.2018.12.11.06.59.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 06:59:34 -0800 (PST) Subject: Re: [PATCH 1/6] driver core: Introduce device_iommu_mapped() function To: Joerg Roedel , 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 , 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 References: <20181211134343.10664-1-joro@8bytes.org> <20181211134343.10664-2-joro@8bytes.org> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: Date: Tue, 11 Dec 2018 17:59:33 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20181211134343.10664-2-joro@8bytes.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-MW Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 12/11/2018 04:43 PM, Joerg Roedel wrote: > 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); You know that parens are unnecessary here, right? :-) > +} > + > /* Get the wakeup routines, which depend on struct device */ > #include > MBR, Sergei