Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1950765pxa; Sat, 29 Aug 2020 08:47:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPcZAi2bGXPbq7Bj5lZpnw+eW7ztGnKckbFYppbyYWghrasCCH40aZBYHkwUintsOqdGaG X-Received: by 2002:a17:906:7715:: with SMTP id q21mr3984217ejm.251.1598716048295; Sat, 29 Aug 2020 08:47:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598716048; cv=none; d=google.com; s=arc-20160816; b=YWgCt9gOlYz/3xn78qTpblUBfPrYo7ywnW4bC2LZ7xF5BRs941AQ24IFXMSC5WtR7z xSvMk06Y7jxNf963l6m1a+B8xC1/HMxqeJusSYM4dt4Rlu1+fzLpva/fwDRjNMpl7D4h 3GxxKLHWoaX0hu580lGOI2bHkTSHsM8X98wWYmsuTMQizFRAKnyTr1jB0A/dwX3fm7Pl FDmZSs64tOMGkufg5lTGhc1ZF/krDIxJm+OcCsYvOz0sU2FSD4MEc22/8IKDI7SjrRDI 7N2U9403Ywj18E9YYNLYkEqLxiAuiruJXQm3O1632d+LM8xPOrfzugVqD+I6mG2hFAba jjnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=gZwSMWU4IIZ/SYiQ/z3cDp9G6Hv0CA5exT6EFnSvycU=; b=pdplRlozrAf7Ltl4Gwv/pIeylOLMeDUXykLRnlWX6J65OnI7AiMI02QghiCc2xCNcH H4iPnEq/7lEO+VC3l5SZuj/n8nTReRhNSzC0OOaJKJ3DyD6sYI+4IecqyBPg0xgKAqIw urD9+3i+CyyVPomFkZn5KssgTB8RHrW1lOfEloVxQrxoD5Oe2112cKHGSzKs1dVu6MnU JobmN9x6rhXKNzxDrKex5oA6Ip1+i8l20JpRNE152DWJrkM8mofO4ZxKeh4m4rrTv30K l0dOI3xML/gEu+ZUL4j4CqxKSE1jLqdffn3FDhbVDafICmIGGpHpO5Ml1keQNVutH07R aCRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xFkSuODy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b6si2057818ejb.68.2020.08.29.08.47.04; Sat, 29 Aug 2020 08:47:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=xFkSuODy; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728351AbgH2PqY (ORCPT + 99 others); Sat, 29 Aug 2020 11:46:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:51950 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728196AbgH2PqT (ORCPT ); Sat, 29 Aug 2020 11:46:19 -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 A981A20707; Sat, 29 Aug 2020 15:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598715978; bh=AheSshfe92OtbNQk0Y5YnL36d07LMk/Bwp5WrwRwW/8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=xFkSuODyEMu7scime7X76raA4n6sWN3AdwLpRB0qK1Rdc0IWkRyClkmKnRUBUriNg lwdIHHz47eCBAdC6YfYGpV5GhU/XPHYoq88pMjRcI5qz5WzE0g/JSwgOR5RBg8PHwK 8vbqk9SMaORV8BmDSp7vcYlm0NNZnh/msT7Cgkvk= Date: Sat, 29 Aug 2020 16:46:13 +0100 From: Jonathan Cameron To: Alexandru Ardelean Cc: Fabrice Gasnier , Alexandru Ardelean , linux-iio , linux-stm32@st-md-mailman.stormreply.com, LKML , linux-arm-kernel@lists.infradead.org, alexandre.torgue@st.com, Sergiu Cuciurean Subject: Re: [PATCH v2] iio: stm32-dac: Replace indio_dev->mlock with own device lock Message-ID: <20200829164613.3be1b2b1@archlinux> In-Reply-To: References: <20200826063850.47625-1-alexandru.ardelean@analog.com> <20200826120042.200364-1-alexandru.ardelean@analog.com> 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 27 Aug 2020 13:00:36 +0300 Alexandru Ardelean wrote: > On Thu, Aug 27, 2020 at 12:03 PM Fabrice Gasnier wrote: > > > > On 8/27/20 10:55 AM, Alexandru Ardelean wrote: > > > On Wed, Aug 26, 2020 at 3:03 PM Alexandru Ardelean > > > wrote: > > >> From: Sergiu Cuciurean > > >> > > >> As part of the general cleanup of indio_dev->mlock, this change replaces > > >> it with a local lock. The lock protects against potential races when > > >> reading the CR reg and then updating, so that the state of pm_runtime > > >> is consistent between the two operations. > > >> > > >> Signed-off-by: Sergiu Cuciurean > > >> Signed-off-by: Alexandru Ardelean > > >> --- > > > Forgot the changelog here. > > > Apologies. > > > > > > Changelog v1 -> v2: > > > * removed whitespace change for 'common' field > > > * updated comment about the lock usage > > > > Hi Alexandru, > > > > Sorry if I missed it... is there an update on the comment :-) ? > > For a moment there, I thought I didn't. > GMail's threading is confusing. > > ---------------------------------------------------------------------------- > As part of the general cleanup of indio_dev->mlock, this change replaces > it with a local lock. The lock protects against potential races when > reading the CR reg and then updating, so that the state of pm_runtime > is consistent between the two operations. > ---------------------------------------------------------------------------- I think this got confused... see below. > > > > > Best Regards, > > Fabrice > > > > > >> drivers/iio/dac/stm32-dac.c | 12 ++++++++---- > > >> 1 file changed, 8 insertions(+), 4 deletions(-) > > >> > > >> diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c > > >> index 092c796fa3d9..7a8aed476850 100644 > > >> --- a/drivers/iio/dac/stm32-dac.c > > >> +++ b/drivers/iio/dac/stm32-dac.c > > >> @@ -26,9 +26,11 @@ > > >> /** > > >> * struct stm32_dac - private data of DAC driver > > >> * @common: reference to DAC common data > > >> + * @lock: lock to protect the data buffer during regmap ops The original comment was: In this particular case I'm not sure that's what mlock was being used for. I think it's about avoiding races around checking if powered down and actually doing it. And Fabrice's reply: Hi Sergiu, Indeed, purpose is to protect against a race here when reading CR, and updating it via regmap (this also makes the subsequent pm_runtime calls to be balanced based on this). (Side note: there is no data buffer involved for the DAC.) Could you please update the comment ? Thanks, Fabrice > > >> */ > > >> struct stm32_dac { > > >> struct stm32_dac_common *common; > > >> + struct mutex lock; > > >> };