Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp918946lqa; Sun, 28 Apr 2024 09:45:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVECfoVTODcXyWah8wDelwQdwtqV+dzbeC25+fdVFSIdMZy+8uqeptFBrclQBxCF0VY7jJJRTCIkzMqYgXJQMyAfcU6TPtStYJMjRsxhA== X-Google-Smtp-Source: AGHT+IElnvx5eKObzWL3Tk9g5ell2dhPBHGrLiYxJ1jHAI4P0FUvFRQ8vFZOaSFub77h0UoiW6cG X-Received: by 2002:a05:6a20:4389:b0:1a9:b2ee:5f72 with SMTP id i9-20020a056a20438900b001a9b2ee5f72mr8833831pzl.36.1714322741223; Sun, 28 Apr 2024 09:45:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714322741; cv=pass; d=google.com; s=arc-20160816; b=DnZonb4+Q6yD9QqROi8i890ee9KWB0jEo3DKqJq1hSe50UgcS/aLbQVTndSNNlvXbj 58o5mYjxWFE+oBXvuw9zfQ4EgyfWocRc31hx7R6uyveMXEMsjArvBunzO1nZOzBDx3da t4eybtEQFecbh/AxOepRkgANrdE+btw3b4rpsHTeRxeLiAu3Qi4hdhG12PR0RGrLZaYr 4/tbVBLWLS3dkpxxsaT1CJvdsYKLYTrOgU1eoajjwtWSxZWdCVM75vAji8hA6NZs4F1/ vz11a/zW+bymhIcSmp4QBe2QCUo5FK9kTL9glUKnFhc0qBjj57Qy0Xx+mDPT0EU/q67l C8BA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=lYcImCFsBIBKmPB1WLd/VrBYxf1694Ln0pkHt2RllUE=; fh=ZCRim7CrZNyvBokUEY/YEj9pcUJWR3kaaYID0S+RZ5I=; b=r50HqlE7i+0jjWOd/uH/zBlpdK3wIDWgQ0N6jyynzI8gydlm0aZCfsZxKeD5OeKInM JvXn6SnTseyKQTszq3eOO44dObFpAjvFQg967i8JTsWdFxVOvolp+/Xzbcv50vgg+wMJ feyU/2HiNfPBDjefZ57QBosYCvoZ/JqYUbecPsy34/Xml6/NVJfirnL1lfVBX+qCpjry y4f/bJ6BBERvsiPDQF0GfpWZ6X8N2KZUPEalMx9ujc6HK4Gp6W0iuCx2k9zj1nsh0o8D n2jgaGE4SJ9H22fUfmJlWZrvoLuNyTZwUNlcVm8tv1vrc2jmwsoGMP1gTtdVMa3wonS+ Xk0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="lX/FJlg4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l7-20020a17090ac58700b002a2d9b88dc1si20431122pjt.163.2024.04.28.09.45.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 09:45:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="lX/FJlg4"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-161504-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161504-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id A2548B212DF for ; Sun, 28 Apr 2024 16:45:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40C1171B4F; Sun, 28 Apr 2024 16:45:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lX/FJlg4" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B9E410F1; Sun, 28 Apr 2024 16:45:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714322725; cv=none; b=Cqo4Hh+UBJSWmlLnVSkaKRt+gsMKm64O+5jB+QQwsQQuYTjIEqm5sCrjXlEvnPRIkqPlg9Cqq4rrmWRWcR/Y/sImLRwQZZ7qFudwal8SX5Ogoj7oiKeMIBlxaS8fAulNSBo8EPlRaxvfBhF3rYE9O7QG+ml11g0wAiSPMr+QUPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714322725; c=relaxed/simple; bh=5kYP3pmRZkJtkUEFsEYFM/NTR8a+xkpPppKIoM24f7M=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HfztS3GdYLvuNHoHnEw1ka9XA+abUWllWNc8spzYdTbW6A7qGqiOrTwRRAy3t3vJGJZ4Ji8tHjKWB6VWtAOq5ZKRElXIFJYa4XPBkmKYkvMZcvgBZNo6l0nNUjpJuQWOCeGigzb+Ra6zMTeISHSCY+Yo4DrOsOtm1BecVtWGIdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lX/FJlg4; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4545FC113CC; Sun, 28 Apr 2024 16:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714322724; bh=5kYP3pmRZkJtkUEFsEYFM/NTR8a+xkpPppKIoM24f7M=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=lX/FJlg4IpPctey9rwJ5G71OlFBAyAGflEF2JWbzPkYVdFa2eAGLCUuxXDzuyC51U EQG48mWWgUpvPUUcNKuKLcrZZNNvkWmZ+4Qhcmtwsgm1dP3AUioxs/vXmCq8CILtD4 69ih+C2EZ9BiIeVUbXKJWsmqz6mKaz1TjpCAI745GXZXz0KJBOZQlQFx4eMd7/xxrM tqkO9mx4TM8zJd75bOeoyxxrnTvUQow7vtK1CoSp0Sspl10td6BINSsZ6Z3S5W58kY exKRWup/Hg1PG4eqJ3XMLi82kg53EptCw/8Ey6s8RoZn/YA3KHxBGMsPwkWuhM8waE IXREY/XBX+adg== Date: Sun, 28 Apr 2024 17:45:09 +0100 From: Jonathan Cameron To: Andy Shevchenko Cc: =?UTF-8?B?T25kxZllag==?= Jirman , Aren Moynihan , Lars-Peter Clausen , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Liam Girdwood , Mark Brown , Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?= , linux-iio@vger.kernel.org, phone-devel@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Willow Barraco Subject: Re: [PATCH v2 2/6] iio: light: stk3310: Implement vdd supply and power it off during suspend Message-ID: <20240428174509.6de97d54@jic23-huawei> In-Reply-To: References: <20240423223309.1468198-2-aren@peacevolution.org> <20240423223309.1468198-4-aren@peacevolution.org> <5qqil7ltqhdeabml6toqpcy773uhjxgwaz3txpy4kv4sz55o2y@hmar674eey7s> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Wed, 24 Apr 2024 18:20:41 +0300 Andy Shevchenko wrote: > On Wed, Apr 24, 2024 at 3:59=E2=80=AFPM Ond=C5=99ej Jirman = wrote: > > On Wed, Apr 24, 2024 at 02:16:06AM GMT, Andy Shevchenko wrote: =20 > > > On Wed, Apr 24, 2024 at 1:41=E2=80=AFAM Aren Moynihan wrote: =20 >=20 > ... >=20 > > > > ret =3D stk3310_init(indio_dev); > > > > if (ret < 0) > > > > - return ret; > > > > + goto err_vdd_disable; =20 > > > > > > This is wrong. You will have the regulator being disabled _before_ > > > IRQ. Note, that the original code likely has a bug which sets states > > > before disabling IRQ and removing a handler. =20 > > > > How so? stk3310_init is called before enabling the interrupt. =20 >=20 > Exactly, IRQ is registered with devm and hence the error path and > remove stages will got it in a wrong order. >=20 > > Original code has a bug that IRQ is enabled before registering the > > IIO device, =20 >=20 > Indeed, but this is another bug. It shouldn't be. A device that produces interrupts before we have told it to is a) buggy, b) almost certainly already had it's interrupt masked due to spurious interrupt detection. Definitely don't want to do it in the opposite order where userspace could turn the device on and have it start generating interrupts before the irq is registered. I'd rather assume non buggy hardware (and that if there are bugs, the normal protections kick in) than introduce a race into the software.=20 >=20 > > so if IRQ is triggered before registration, iio_push_event > > from IRQ handler may be called on a not yet registered IIO device. > > > > Never saw it happen, though. :) =20 >=20 > Because nobody cares enough to enable DEBUG_SHIRQ In most devices there is a status register and we should be doing nothing unless that is set. Interestingly this device either doesn't have one or the driver doesn't read it - it reads a flag only and so will always push an event. Such a register read doesn't require the IIO device registration to be complete. There are corner cases where that isn't true that need to manually mask at the host but they are rare. There is also a basic level of defense in iio_push_event() against that being called when the event interface is not registered. Jonathan >=20