From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.47 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792443805; b=ZRuTzZfVPtVNCtvUi50HHOgNd3fDgJa3l1b3PlCfbGfeFzfwZLqJqbHEoz+/RoeRnxHE t+8M47SY8oZU65N9zUwoFTAWsJs/L0sOrLFsd0hXkJm1JyzCEc7GdWc42LQ2AskzA53Xe UUZw07Yr9WGmRqIKdoIpyr9qWM7RpFea8qh1GuEJlDPi2ikysAt6JO2OEFFdnLMwdVs6n nXs+h9ygACjAQagCAykfKrOkloWYNuyHa+slK0K53bAP/Ey6pefs3NTBms8pkuFX/ibp4 JgbAn0HLxagRiOanmoV5sUC27qor/Oo35eQda2MoECr5RmkxkYqu/6gaeczK2AmOo5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792443805; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; bh=bFksrm77cyr8jHa+bYjO51SDtxqIh7+jp/ljya0vLSI=; b=RY4+7ui27W44+vfC+S8yVZ0SMikrCSWsuNCH1O0pEfNu7UYXqpdSo1QYnw1CwCRGpLpN xHEOVWMGEr2n6DLP35EDhKq7uga2C/lRpj94CHGKWD9OcsDf2G/O1AOUqS4+z6C4vFEU5 6KC0oSelWvKUwySCVD4HiIMsN+W1BFNYIVIr25B7Kq2ABBM6jPyKefBftWhGTaOIzhkzL dnBTXQgK5Kpy54unLMF4DAbQr1iXjmy+wWuboMq8R1mxVKMfekMvW0v4tpXqZ8fBYhVvn +z1P7xzADSMyBfuPqq1Ri7Fd847HaykzRmBja4qltLrUcVh4umlwhrTuGs75UX1cmKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=js3Iw7wY; arc=none smtp.remote-ip=209.85.222.47 Received: from mail-ua1-f47.google.com (mail-ua1-f47.google.com [209.85.222.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4E2F606A31C for ; Mon, 19 Oct 2026 21:03:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B4E2F606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=js3Iw7wY Received: by mail-ua1-f47.google.com with SMTP id a1e0cc1a2514c-9851592ada1so759256241.0 for ; Mon, 19 Oct 2026 14:03:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1792443804; x=1793048604; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=bFksrm77cyr8jHa+bYjO51SDtxqIh7+jp/ljya0vLSI=; b=js3Iw7wYynwqlO3t0d4usi7oCUftDpJQchdczdYGmfAyX6uduBi6AUw5xsU8aog2VZ WUYVx9F3k0clssm0SpDe68hNUb2mILlxQv0BE+KBqlOiplUUPn4Z2OCgQEZMDdl67kJH NVifoGWbCKPZuCZUbK4baNijj11h+3nhviXo045eloX7IXrIT1BhW6KN/z+4xW6o9RLb CexhCSjxAX6tgNzkjGmiDMVklFjNuUeK6BbuMSuNrqYIhuS8BCK9ecNubGQpJRwVCzaj ZrTz8x29dbj5G9t16h/gr3BCniqk/wENGkv1Y2jtq0IeSL0cfBti7Ds50b3HaoahSiNd NHIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792443804; x=1793048604; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bFksrm77cyr8jHa+bYjO51SDtxqIh7+jp/ljya0vLSI=; b=PGibXr/S7OFBRERyfU8elfxtG4V4/M9TbROID7TPM9LNOyqkQcJr2Ad7WkkKJCNj/f RbzRSVubwnS9yi9ZaiNRYtTFUFD/spiQcr/oQ3iG6M2OjJo2RA+rPjbAuAMR4OkiUR9U ckyGFZ7nkKtRNPR97bcqR5pqJmbFMf6EcOSlKu2FcuJcB2gvEglFfFY7UgLC+mCg/o2Q irzF8UaM5eeJocrmyEiG8JqJb4KTZBqKZivc0+GXugxyiBd8B8P9exZQhRZNNRGpmqO/ exCnQTQa3hQCBDWxoJLCBLRUSdS0i3Zy/ozMgfImBfmpzyye5nYZSGuehvnfyeY/pDjr fReQ== X-Forwarded-Encrypted: i=1; AKwUvBxPuuMIrljoG9QUPRAFlsKvT86T9n5hCPtJvBME4+BnjBBVRFArozUvdw+om3QNxebullY/bAiumOhS@vger.kernel.org X-Gm-Message-State: AFq9FYItfvkLz7oJxng6QENs6qMGGy7rgS/kxYVUuLblfqD1mpMzWZ+J 6pRbIgodx7dAN32yBKizohJWPbUKnGKsNCaiDNNd7Jrr9DeGTdbRB0dC X-Gm-Gg: AYBFou2AAKzi17yO13c5JDOJMLdqMuBltvjLK/MK6tl+cFYD8xDdLRXQJ2B055k/oix /iXanGrEZObVDRR1DVDhd6/fpus+PBE4TNDR3W8sl3sSSOY8O9pD5RPwsQs8IIGy4GvnifRWxrr 7nVtcH7wXwKhOSXmjy3+qu6kKkbC0oIdHGVEUIwzL96B/gYJcGZExmDzuRfTh5rEWdyIrx7jOXe gvjEjjRsHao0zBOnitjwNacKlROkqEx17wlvLVitj+PyaEIz/aQkmomd1quVAhPBCyB3W+15cFD Wr8BSQalyYD5EcwjrC5G4wi/v9P46TT8gTREIFp8vnnY0f3KscGJbOPYxiLU3mHpFrAYqqQ0ux0 sYYrT0iOb6FA7t4Z0CHW8Zp09Wg6SJRSVMkG4if6X941Q+AvJ1lfAcCCT5Nf+l1XQ0wmu5nk51V UcGEw4JSxLQztJ+AeA8GYz8eetmF4kFqj0h1xf80PUJzdgiu2BSQ34Xz5O4AoAs1H+7CedL1moX xCj9A== X-Received: by 2002:a05:6102:5488:b0:7a7:5355:7fb6 with SMTP id ada2fe7eead31-7cc36a207e5mr1757779137.24.1792443803558; Mon, 19 Oct 2026 14:03:23 -0700 (PDT) Received: from localhost ([2804:30c:4067:b00:a68b:4892:7af1:b51d]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-990bb355e82sm1292902241.6.2026.10.19.14.03.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2026 14:03:22 -0700 (PDT) Date: Mon, 19 Oct 2026 18:04:28 -0300 From: Marcelo Schmitt To: Jonathan Cameron Cc: Marcelo Schmitt , linux-iio@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux@analog.com, nuno.sa@analog.com, dlechner@baylibre.com, andy@kernel.org, Michael.Hennerich@analog.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, corbet@lwn.net, skhan@linuxfoundation.org Subject: Re: [PATCH v5 06/15] iio: adc: ad4134: Protect conventional device access from debug accesses Message-ID: References: <20261017194707.48f6f242@jic23-hlaptop> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20261017194707.48f6f242@jic23-hlaptop> On 10/17, Jonathan Cameron wrote: > On Fri, 16 Oct 2026 22:58:05 -0300 > Marcelo Schmitt wrote: > > > Require debug access to acquire device synchronization locks before > > allowing any transfer from the debug interface so to avoid disrupting > > operations issued from usual (non-debug) interfaces. > > These needs more. What sort of disruption are we talking? > > A deliberate write to change state that breaks normal operation > is a debug mess up that we don't guard against, but if a read > is enough to break things, or there is an inherent disruption > of other operations by using the bus at all then state that. A read is enough to break any ongoing buffered read because register reads will cause the bus configuration to change to a state that invalidates any sample read that happens afterwards. > > What isn't regmap locking covering? regmap doens't cover IIO device direct/buffered modes. > > If this is all about the mux stuff and backend usage, > then move it to nearer that in the series and refer to that. We also need the mux usage to be synchronized which is why debugfs_reg_access now also locks on device state sync_lock. In practice, because every device access will select then deselect the mux state, we are not able to have two operations going on simultaneously (not even two register read can run concurrently due to the needed mux state care). On v3, there was a dedicated mutex for mux access synchronization. In an atempt to make things more simple, that second mutex was removed and sync_lock is now also utilized to prevent multiple threads from changing the mux state simultaneously. It shall work properly as long as any device access first claims IIO direct + get sync_lock or claims IIO buffered mode. Is it okay to have it like that? > > Jonathan > > > > > Signed-off-by: Marcelo Schmitt > > --- > > New patch in v5. > > > > I'm not sure about this one and have no strong opinion about it. > > Providing it according to suggestion from Nuno. > > https://lore.kernel.org/linux-iio/179199692826.658576.4841754843069240356.b4-review@b4/ > > From previous discussions I guess this patch might not be welcome. > > https://lore.kernel.org/linux-iio/20250421142359.11fb483f@jic23-huawei/ > > In that case, completely fine with it being dropped. > > > > drivers/iio/adc/ad4134.c | 6 ++++++ > > 1 file changed, 6 insertions(+) > > > > diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c > > index dc4d801490db..42a1272c2894 100644 > > --- a/drivers/iio/adc/ad4134.c > > +++ b/drivers/iio/adc/ad4134.c > > @@ -302,6 +302,12 @@ static int ad4134_debugfs_reg_access(struct iio_dev *indio_dev, > > { > > struct ad4134_state *st = iio_priv(indio_dev); > > > > + IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim); > > + if (IIO_DEV_ACQUIRE_FAILED(claim)) > > + return -EBUSY; > > + > > + guard(mutex)(&st->sync_lock); > > + > > if (readval) > > return regmap_read(st->regmap, reg, readval); > > >