From mboxrd@z Thu Jan 1 00:00:00 1970 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 3D0951E1C22; Thu, 30 Jan 2025 15:53:44 +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=1738252424; cv=none; b=RJHHN/uvRlu8CC/KrO66axWMHNqKIniWUHIiRWU3bkXuOhzkV1i4sZdxIFceU7hdUpxOY46XC60ugvpQzFTWxV0NHIrBc3OZvjpOa8aI058CThB0d3u8KpzVE9KgvFcWi8x+r5GdKX5l6kHEwaK0MDOx3bdVO5rnRo3rlqI1WmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738252424; c=relaxed/simple; bh=7h9AoUeAiY5qK0t9g6t0B8QXd1IuLuDyE6xrUN15wak=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=g6OWQFuD5lIlCr8C/EY8bBpbi4wNvvHIdLQIFSQ2ipDWsWqkTaezA2H92sho7232XHX4y19ZLulL96hebkpu4GOF0Vo+enyKuceRvIOlCxyrM8p/l+8ndBvVL08s5hFZ3xDIVx1yr45yGXbOuD5N4XeElECc4Ue80/6EWAusY7c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MSz+AemA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MSz+AemA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80DABC4CED2; Thu, 30 Jan 2025 15:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1738252424; bh=7h9AoUeAiY5qK0t9g6t0B8QXd1IuLuDyE6xrUN15wak=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MSz+AemA4HvWhT1qKASkH7CfaAnGuQSnaQXbmGIPuHfXTnG/WnW0aDSkvlEQ1QJOl g8DdVDe34FcQbv36QMe+Uyuzi2aLTwFdU4qx+qsIjxOsBUnXa3/u0ygyMIJYJLoKek 4ECPnGEz06oz6QaDvo1kNOgHJhDipV0V2h9mhZcqf49x476PMeM30vSZqy36X1xhe/ FQ8vyRtKVRxA89Ul3mAmS0eRm7VJ/1GpKx6X879LQB5dvXYrsFpFxXN2IU2VYlYQLe R5ONbV/D8AMNG2+8dIYd/UZfN5BADD9yv4ysItJYhHvD3BLjE7UvsHy4eTz1VOOumK GTbhRXnWMjCzQ== Message-ID: <59cbde54-e1df-4e92-9291-5546118dd2ca@kernel.org> Date: Thu, 30 Jan 2025 16:53:36 +0100 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFC] soc: qcom: pmic_glink: Fix device access from worker during suspend To: Abel Vesa , Bjorn Andersson Cc: Konrad Dybcio , Caleb Connolly , Dmitry Baryshkov , Johan Hovold , Neil Armstrong , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20250110-soc-qcom-pmic-glink-fix-device-access-on-worker-while-suspended-v1-1-e32fd6bf322e@linaro.org> <8aef8331-662d-49ee-a918-8a4a5000d9ec@kernel.org> <7nce4if7gowtbvenqhwzw6bazgfcgml6enwufomqxs4uruj3vs@sgagkj3zpx4t> Content-Language: en-US From: Krzysztof Kozlowski Autocrypt: addr=krzk@kernel.org; keydata= xsFNBFVDQq4BEAC6KeLOfFsAvFMBsrCrJ2bCalhPv5+KQF2PS2+iwZI8BpRZoV+Bd5kW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esyE6zIqftdo4MOJho8uctOiWbwNNq2U9pPWmu 4vXVFBYIGmpyNPYzRm0QPwARAQABwsF8BBgBCgAmAhsMFiEEm9B+DgxR+NWWd7dUG5NDfTtB YpsFAmA872oFCRRflLYACgkQG5NDfTtBYpvScw/9GrqBrVLuJoJ52qBBKUBDo4E+5fU1bjt0 Gv0nh/hNJuecuRY6aemU6HOPNc2t8QHMSvwbSF+Vp9ZkOvrM36yUOufctoqON+wXrliEY0J4 ksR89ZILRRAold9Mh0YDqEJc1HmuxYLJ7lnbLYH1oui8bLbMBM8S2Uo9RKqV2GROLi44enVt vdrDvo+CxKj2K+d4cleCNiz5qbTxPUW/cgkwG0lJc4I4sso7l4XMDKn95c7JtNsuzqKvhEVS oic5by3fbUnuI0cemeizF4QdtX2uQxrP7RwHFBd+YUia7zCcz0//rv6FZmAxWZGy5arNl6Vm lQqNo7/Poh8WWfRS+xegBxc6hBXahpyUKphAKYkah+m+I0QToCfnGKnPqyYIMDEHCS/RfqA5 t8F+O56+oyLBAeWX7XcmyM6TGeVfb+OZVMJnZzK0s2VYAuI0Rl87FBFYgULdgqKV7R7WHzwD uZwJCLykjad45hsWcOGk3OcaAGQS6NDlfhM6O9aYNwGL6tGt/6BkRikNOs7VDEa4/HlbaSJo 7FgndGw1kWmkeL6oQh7wBvYll2buKod4qYntmNKEicoHGU+x91Gcan8mCoqhJkbqrL7+nXG2 5Q/GS5M9RFWS+nYyJh+c3OcfKqVcZQNANItt7+ULzdNJuhvTRRdC3g9hmCEuNSr+CLMdnRBY fv0= In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 29/01/2025 09:46, Abel Vesa wrote: >> >>> 1. Maybe the driver just lacks proper suspend/resume handling? >>> I assume all this happens during system suspend, so what certainty you >>> have that your second work - pmic_glink_altmode_pdr_notify() - is not >>> executed as well? >>> >>> 2. Follow up: all other drivers and all other future use cases will be >>> affected as well. Basically what this patch is admitting is that driver >>> can be executed anytime, even during suspend, so each call of >>> pmic_glink_send() has to be audited. Now and in the future, because what >>> stops some developer of adding one more path calling pmic_glink_send(), >>> which also turns out to be executed during suspend? >>> >>> 3. So qcom_battmgr.c is buggy as well? >>> >>> 4. ucsi_glink.c? I don't see handling suspend, either... >>> >>> Maybe the entire problem is how pmic glink was designed: not as proper >>> bus driver which handles both child-parent relationship and system suspend. >> >> The underlying problem is that GLINK register its interrupt as >> IRQF_NO_SUSPEND (for historical reasons) and as such incoming messages >> will be delivered in late suspend and early resume. In this specific >> case, a specific message is handled by pmic_glink_altmode_callback(), by >> invoking schedule_work() which in this case happens to schedule >> pmic_glink_altmode_worker before we've resumed the I2C controller. >> >> I presume with your suggestion about a pmic_glink bus driver we'd come >> up with some mechanism for pmic_glink to defer these messages until >> resume has happened? > > So is the suggestion here to rework the entire pmic_glink into a bus > driver? (I like the sound of that) > > I'd assume the new bus driver will have to queue the messages until it > has resumed, which is fine. Queue or just disable interrupts/notifications to clients. > > But still doesn't solve the fact that we can't filter out when to > wake-up or not. What am I missing here? I think this was not the concern in my email. I was only wondering about the design flaw that we allow pmic glink to send notifications to children anytime. And that's not how the bus-like driver should be written. Best regards, Krzysztof