From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C9F1C433E2 for ; Sat, 29 Aug 2020 15:33:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3540C20791 for ; Sat, 29 Aug 2020 15:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598715222; bh=eRIQ3RsS8QokfA8Kzvr1LjY4Cf5uyuC9QpA4TQetVy0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-ID:From; b=WCrtUC+IF1MtGiqAaJCm+9WZ2loIwJ5kDvXZ7YSZS6HsxF2I44NhZZWzttmHFEY/8 mw7EIFiDKGAhxI/xTQnT2KsQGxNo35azG3LGcRniCgGLOoQYsH/ZdA2tWmKHSpapSW eQGMc6KFHH65uhicFOEsaQlRLn/nhMTCka9ZRADE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728303AbgH2Pdk (ORCPT ); Sat, 29 Aug 2020 11:33:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:47378 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728196AbgH2Pdk (ORCPT ); Sat, 29 Aug 2020 11:33:40 -0400 Received: from archlinux (cpc149474-cmbg20-2-0-cust94.5-4.cable.virginm.net [82.4.196.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4C0FC20791; Sat, 29 Aug 2020 15:33:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598715219; bh=eRIQ3RsS8QokfA8Kzvr1LjY4Cf5uyuC9QpA4TQetVy0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kA7bgoAX66sTvWabu8HGdci4RWthUM4T2ggmCMDHB/Y1LFAy44HMfRnxybnfp2sST J8xxkos9h/aATTZ8bkeG9SFHwsg2LGoWhXNA/LOHem90uIzENe4IiWdkZYTtczIsov BFwS4Ukr6GgC/DAE0SLebIHo+J4CB2SV//NGmNSg= Date: Sat, 29 Aug 2020 16:33:35 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: Krzysztof Kozlowski , Alexandru Ardelean , linux-iio , LKML , kgene@kernel.org, Sergiu Cuciurean Subject: Re: [PATCH] iio: adc: exynos_adc: Replace indio_dev->mlock with own device lock Message-ID: <20200829163335.3a9c420c@archlinux> In-Reply-To: References: <20200826132203.236748-1-alexandru.ardelean@analog.com> <20200827065625.GB17964@kozik-lap> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org On Thu, 27 Aug 2020 11:53:44 +0300 Alexandru Ardelean wrote: > On Thu, Aug 27, 2020 at 9:57 AM Krzysztof Kozlowski wrote: > > > > On Wed, Aug 26, 2020 at 04:22:03PM +0300, Alexandru Ardelean wrote: > > > From: Sergiu Cuciurean > > > > > > As part of the general cleanup of indio_dev->mlock, this change replaces > > > it with a local lock, to protect potential concurrent access to the > > > completion callback during a conversion. > > > > I don't know the bigger picture (and no links here for general cleanup) > > but I assume it is part of wider work and that mlock is unwanted. In > > such case: > > > > Reviewed-by: Krzysztof Kozlowski > > > > If it is part of some bigger work, please put a link to lore.kernel.org > > under separators ---, so everyone can get the context. > > Will keep that in mind. > I am not sure if there is a lore.kernel.org link that's easy to find > for a discussion on this topic, maybe I can describe it here and use > the link [from this later]. > > This was something that popped up during reviews we got from Jonathan > [or others], saying "please don't use indio_dev->mlock, that is an IIO > framework lock, and an IIO driver should not use it". Shortest one is the docs for that lock say don't use it directly in a driver :) https://elixir.bootlin.com/linux/latest/source/include/linux/iio/iio.h#L495 > Reasons include [and some may be repeated a bit]: > - this could cause a deadlock if the IIO framework holds this lock and > an IIO driver also tries to get a hold of this lock > - similar to the previous point, this mlock is taken by > iio_device_claim_direct_mode() and released by > iio_device_release_direct_mode() ; which means that mlock aims to > become more of an IIO framework lock, than a general usage lock; > - this wasn't policed/reviewed intensely in the older driver [a few > years ago], but has become a point in recent reviews; > - if we want to develop/enhance the IIO framework, some elements like > this need to be taken care of, as more drivers get added and more > complexity gets added; One side note here is we want to make all this [INTERN] state in struct iio_dev opaque to drivers. It'll take a while as the boundary gets crossed in various drivers. > - there is an element of fairness [obviously], where someone writing a > new IIO driver, takes an older one as example, and gets hit on the > review; the person feels they did a good job in mimicking the old > driver; their feeling is correct; the IIO framework should provide > good references and/or cleanup existing drivers; > - same as the previous point, we don't want to keep telling people > writing new IIO drivers [and starting out with IIO] to "not use mlock > [because it was copied from an old driver]"; it's more/needless review > work Good explanation. Thanks, Jonathan > > > > > > > > Best regards, > > Krzysztof > > > > > > > > Signed-off-by: Sergiu Cuciurean > > > Signed-off-by: Alexandru Ardelean > > > --- > > > drivers/iio/adc/exynos_adc.c | 12 ++++++++---- > > > 1 file changed, 8 insertions(+), 4 deletions(-) > > >