Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752471AbeAQHil (ORCPT + 1 other); Wed, 17 Jan 2018 02:38:41 -0500 Received: from mail-vk0-f68.google.com ([209.85.213.68]:46998 "EHLO mail-vk0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752446AbeAQHik (ORCPT ); Wed, 17 Jan 2018 02:38:40 -0500 X-Google-Smtp-Source: ACJfBourMoFOgsqYZoZ2lyMoqtMkdRAK6n0gR4T3Ud37jYChpn+1lyPmVf6XsvCfki+YAHVlqkHZNw== MIME-Version: 1.0 In-Reply-To: <5A5EFAB2.7040001@rock-chips.com> References: <20180116132540.18939-1-jeffy.chen@rock-chips.com> <20180116132540.18939-13-jeffy.chen@rock-chips.com> <5A5EFAB2.7040001@rock-chips.com> From: Tomasz Figa Date: Wed, 17 Jan 2018 16:38:17 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 12/13] iommu/rockchip: Add runtime PM support To: JeffyChen Cc: linux-kernel@vger.kernel.org, Ricky Liang , Robin Murphy , simon xue , Heiko Stuebner , "open list:ARM/Rockchip SoC..." , open@263.net, "list@263.net:IOMMU DRIVERS , Joerg Roedel ," Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, Jan 17, 2018 at 4:26 PM, JeffyChen wrote: > Hi Tomasz, > > Thanks for your reply. > > On 01/17/2018 02:20 PM, Tomasz Figa wrote: >> >> On Tue, Jan 16, 2018 at 10:25 PM, Jeffy Chen >> [snip] >>> >>> +static int rk_iommu_startup(struct rk_iommu *iommu) >>> { >>> - struct rk_iommu *iommu; >>> + struct iommu_domain *domain = iommu->domain; >>> struct rk_iommu_domain *rk_domain = to_rk_domain(domain); >>> - unsigned long flags; >>> int ret, i; >>> >>> - /* >>> - * Allow 'virtual devices' (e.g., drm) to attach to domain. >>> - * Such a device does not belong to an iommu group. >>> - */ >>> - iommu = rk_iommu_from_dev(dev); >>> - if (!iommu) >>> - return 0; >>> - >>> - if (iommu->domain) >>> - rk_iommu_detach_device(iommu->domain, dev); >>> - >>> ret = rk_iommu_enable_clocks(iommu); >>> if (ret) >>> return ret; >>> >> >> Don't we need to check here (and in _shutdown() too) if we have a >> domain attached? > > hmmm, right, the startup might been called by resume, so should check > iommu->domain here. > > but the shutdown would be called at the end of detach or suspend, it could > be not attached or attached. If startup might be called by resume, without domain attached, what prevents shutdown from being called by suspend after that resume, still without domain attached? Is it guaranteed that if resume is called, someone will attach a domain before suspend is called? Best regards, Tomasz