Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752978AbeAQMrd (ORCPT + 1 other); Wed, 17 Jan 2018 07:47:33 -0500 Received: from regular1.263xmail.com ([211.150.99.141]:37309 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752662AbeAQMrc (ORCPT ); Wed, 17 Jan 2018 07:47:32 -0500 X-263anti-spam: KSV:0; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-RL-SENDER: jeffy.chen@rock-chips.com X-FST-TO: robin.murphy@arm.com X-SENDER-IP: 103.29.142.67 X-LOGIN-NAME: jeffy.chen@rock-chips.com X-UNIQUE-TAG: <95fb30cbc788eaa2ae622fb9a0feb7ab> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <5A5F45DA.5000104@rock-chips.com> Date: Wed, 17 Jan 2018 20:47:22 +0800 From: JeffyChen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:19.0) Gecko/20130126 Thunderbird/19.0 MIME-Version: 1.0 To: Robin Murphy , linux-kernel@vger.kernel.org CC: jcliang@chromium.org, xxm@rock-chips.com, tfiga@chromium.org, Heiko Stuebner , linux-rockchip@lists.infradead.org, iommu@lists.linux-foundation.org, Joerg Roedel , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 09/13] iommu/rockchip: Use iommu_group_get_for_dev() for add_device References: <20180116132540.18939-1-jeffy.chen@rock-chips.com> <20180116132540.18939-10-jeffy.chen@rock-chips.com> <4c1b2469-9a32-c6ca-522f-73143b0fa618@arm.com> In-Reply-To: <4c1b2469-9a32-c6ca-522f-73143b0fa618@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Robin, On 01/17/2018 08:31 PM, Robin Murphy wrote: > On 16/01/18 13:25, Jeffy Chen wrote: >> IOMMU drivers are supposed to call this function instead of manually >> creating a group in their .add_device callback. This behavior is not >> strictly required by ARM DMA mapping implementation, but ARM64 already >> relies on it. This patch fixes the rockchip-iommu driver to comply with >> this requirement. > > FWIW that's not 100% true: what arm64 relies on is the group having a > default DMA ops domain. Technically, you *could* open-code that in the > driver's group allocation, but obviously using the appropriate existing > API is nicer :) ok, will rewrite the commit message. > > [...] >> @@ -1182,6 +1164,29 @@ static void rk_iommu_remove_device(struct >> device *dev) >> iommu_group_remove_device(dev); >> } >> +static struct iommu_group *rk_iommu_device_group(struct device *dev) >> +{ >> + struct iommu_group *group; >> + int ret; >> + >> + group = iommu_group_get(dev); >> + if (!group) { > > This check is pointless - if dev->iommu_group were non-NULL you wouldn't > have been called in the first place. right, it's allocated in the probe. > > Robin.