Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2744023ybk; Mon, 18 May 2020 06:58:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwl6J3lzK2kEmsyeLo81QiAOj1F6XedtmI/N9+fu01/Z6g9hIIvxh5bLooykDiavAbIGkG9 X-Received: by 2002:a05:6402:1849:: with SMTP id v9mr14238618edy.178.1589810339095; Mon, 18 May 2020 06:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589810339; cv=none; d=google.com; s=arc-20160816; b=rSIKV3QTdKDC/vZS3ltFXUcusEC9rY6M/h/MZ6tvP1MLtsHaSrAzveEo+NNdwtViAc EDyTcOg7a5Ld4xqQTPtkaaelcIA6KqpaSkjvQ1dMW9kftuip/o0E7PUzIeelx1i9W6x2 Q6hGj9lRcO9IKNQILK965GdYA1bCWWINVRWMHCCPAEaBAr0p+R1+w491SeyvsmyfdGTr Hr7yigetnnFhEP/a4OuO3uL4p2CVg+6Twcjn0rJ1n04kXonQXmGEA9pGHdx+I2hR03z4 ez/Gvtk9Ra52aeKr/4F3CQSnp5wWTb65nwl7ohcaLHJJ2zfRG8s7KoaTD7hxjb6sPVm6 vXnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=/meAKh5JqUDqkak4W8tLFXwXdMSHbW84LAkFqQWJvAI=; b=Q2yxvbctT1/m6udxRta7yiASysz3RK+F2oHQ0xcaZWI/cyW6iaq2TtTXtTgBC2GCxe FgmZP3/HBqenQY7JGdU1rAaICkRhPFmVwyDSJdp9ks4bdCKXkekOhZb9hNBl0JTgqgI7 Qlh8wxSXDzrWmv62PCUix/U+RsDgFm6gO9XTps/QtgKU5HzCQCeg8TbgwUXoBA8D/Svv 8i+w7DSvYz9Qsql34Gaq7fhTItxfBZcW01uMt+5vZ/ujPrsu349+0X48/gi8cdv01PPa EEx/MgRYf5+a8TQuKCifOaevnvMLQYqSL9laPbrh/6IzXKSzOrjny3BoBJSlPTnpl1qU 7aFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id r2si5362445edq.510.2020.05.18.06.58.35; Mon, 18 May 2020 06:58:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1727035AbgERNzF (ORCPT + 99 others); Mon, 18 May 2020 09:55:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbgERNzF (ORCPT ); Mon, 18 May 2020 09:55:05 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6279DC061A0C for ; Mon, 18 May 2020 06:55:05 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 10B08386; Mon, 18 May 2020 15:55:04 +0200 (CEST) Date: Mon, 18 May 2020 15:55:02 +0200 From: Joerg Roedel To: Yong Wu Cc: Joerg Roedel , Will Deacon , linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Robin Murphy , Marek Szyprowski Subject: Re: [PATCH v2 23/33] iommu/mediatek-v1 Convert to probe/release_device() call-backs Message-ID: <20200518135502.GE18353@8bytes.org> References: <20200414131542.25608-1-joro@8bytes.org> <20200414131542.25608-24-joro@8bytes.org> <1589528699.26119.9.camel@mhfsdcap03> <20200515100718.GS18353@8bytes.org> <1589784680.15083.19.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1589784680.15083.19.camel@mhfsdcap03> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, May 18, 2020 at 02:51:20PM +0800, Yong Wu wrote: > below is my local patch. split "dma_attach" to attach_device and > probe_finalize. About attach_device, Use the existed > __iommu_attach_group instead. Then rename from the "dma_attach" to > "probe_finalize" to do the probe_finalize job. And move it outside of > the mutex_unlock. > > I'm not sure if it is right. and of course I will test if you have any > other solution. Thanks. > > > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -1665,26 +1665,20 @@ static void probe_alloc_default_domain(struct > bus_type *bus, > > } > > -static int iommu_group_do_dma_attach(struct device *dev, void *data) > +static int iommu_group_do_probe_finalize(struct device *dev, void > *data) > { > struct iommu_domain *domain = data; > - const struct iommu_ops *ops; > - int ret; > - > - ret = __iommu_attach_device(domain, dev); > - > - ops = domain->ops; > + const struct iommu_ops *ops = domain->ops; > > - if (ret == 0 && ops->probe_finalize) > + if (ops->probe_finalize) > ops->probe_finalize(dev); > - > - return ret; > + return 0; > } > > -static int __iommu_group_dma_attach(struct iommu_group *group) > +static int iommu_group_probe_finalize(struct iommu_group *group) > { > return __iommu_group_for_each_dev(group, group->default_domain, > - iommu_group_do_dma_attach); > + iommu_group_do_probe_finalize); > } > > static int iommu_do_create_direct_mappings(struct device *dev, void > *data) > @@ -1731,12 +1725,14 @@ int bus_iommu_probe(struct bus_type *bus) > > iommu_group_create_direct_mappings(group); > > - ret = __iommu_group_dma_attach(group); > + ret = __iommu_attach_group(group->default_domain, group); > > mutex_unlock(&group->mutex); > > if (ret) > break; > + > + iommu_group_probe_finalize(group); > } > > return ret; > -- Yes, I think moving the probe_finalize call out of the group->mutex section is the right fix for this issue. Thanks for reporting it and working on a fix. Regards, Joerg