From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Subject: Re: [PATCHv7 02/12] iommu/of: introduce a global iommu device list Date: Mon, 16 Dec 2013 11:32:47 -0700 Message-ID: <52AF474F.7080701@wwwdotorg.org> References: <1386835033-4701-1-git-send-email-hdoyu@nvidia.com> <1386835033-4701-3-git-send-email-hdoyu@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1386835033-4701-3-git-send-email-hdoyu-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Hiroshi Doyu , swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org, will.deacon-5wv7dgnIgG8@public.gmane.org, grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org Cc: mark.rutland-5wv7dgnIgG8@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, lorenzo.pieralisi-5wv7dgnIgG8@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, galak-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: devicetree@vger.kernel.org On 12/12/2013 12:57 AM, Hiroshi Doyu wrote: > This enables to find an populated IOMMU device via a device node. This > can be used to see if an dependee IOMMU is populated or not to keep > correct device population order. Client devices need to wait an IOMMU > to be populated. > > Suggested by Thierry Reding and copied his example code. > diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c > +static struct iommu *of_find_iommu_by_node(struct device_node *np) > +{ > + struct iommu *iommu; > + > + mutex_lock(&iommus_lock); > + list_for_each_entry(iommu, &iommus_list, list) { > + if (iommu->dev->of_node == np) { > + mutex_unlock(&iommus_lock); Now that the list is unlocked, the IOMMU could be removed from the list, and the driver unregistered. Should you do something like iommu_get(iommu); before the mutex_unlock() call, and call iommu_put() somewhere (i.e. in the next patch ...)?