Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp914727rdb; Tue, 19 Sep 2023 14:18:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7Nii7rLuwGCwKGJBc1UklFv4FiACimUIFJWvXtrlII3rqgzWpoJuNgEiceSaS3/ctS9Qx X-Received: by 2002:a17:90b:4b90:b0:268:60d9:92cc with SMTP id lr16-20020a17090b4b9000b0026860d992ccmr848053pjb.43.1695158315758; Tue, 19 Sep 2023 14:18:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695158315; cv=none; d=google.com; s=arc-20160816; b=czq7rVKO88066vjazWulZ32bcNBkU2SQ+ufeXU3jbkKQXR/B8uGdwIG/UUf+73+V1x vuw0O7z8EY05r0fXzhxsg0UlLIP7Ubc65iRv1lrPieoDJEf9GqyLNTCdUlbgrQkPDTs5 A3wHdxfii0Iq0JUXA+B44gaOS77RB3vYu6ULGcYFY0zzKk2kjBtM1ppA+qmqASnPkQgT LU66l0+HETArVNpUihe5cj5OoOuDXTv5Ih5cSbYyvVM4LRv8rpfwfYUpweqgMbZBcSXp U5Te23PVlZbBXRJkEX+hjIhMt0Ay0pq4xhsv/bdkwY8LPWUKeWirg74FYyLOK1TUDuTu B8FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xcx2jlIFSsxYNYZTzuc6q25cxdoVpSopebg683fouEw=; fh=v2l3gtWk+QFX+bnW6khSlrzeKpE/qMywNw/tPwejDQY=; b=LmofFMixlM/WmihspcsjCiAcqTI0osblObbYXBEIp37brwr2VxbHF4s59xvRNVS//H u13DIkfoYt9aYjVaZ/hNIHJV1pC7SbcvGviA7nUiFGJgEwXARDyD4CmxjJ6Td8BQKyIt u0bN0qad+fN3GPCOjodJGXsOhaXX6Znbxe2fxhBnt0cdxuRhdvbFKRKUQDteyACy1mNL enYsfQuZPg9QruPUpQnf4r7WPxmG29n4Pdm3bJ4O4cU54wZMTG0uTiPQO0CYks5CT1zP BPkZHghbA1urma4/Splerk+phOZR6LytNhd5ZwW+jSp4391Qn5zYriqJXc5QeLb969Cg y4PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dwR0eVPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h23-20020a17090aa89700b002765b6291d6si68638pjq.86.2023.09.19.14.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 14:18:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dwR0eVPR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 3C47880E70A6; Tue, 19 Sep 2023 13:12:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233128AbjISUMi (ORCPT + 99 others); Tue, 19 Sep 2023 16:12:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232805AbjISUMh (ORCPT ); Tue, 19 Sep 2023 16:12:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F282C4 for ; Tue, 19 Sep 2023 13:12:31 -0700 (PDT) Received: from notapiano (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id DCF7B66057B6; Tue, 19 Sep 2023 21:12:27 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1695154349; bh=Gk/Fpq7OlN/7K4OFGI5P1G3mmMaho0D846k02v3os0A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dwR0eVPRMgRwtMIoqmAdY40aUrrTOaSttwHcbhXy8qgtHq12Y3m49YX6lmYSBq1xU s2PnktGWwhFNugqguFyl4o29yoMEWKMc3rILXbPOeUKIQwCfAvfQx4d0CASM5JCFi+ HQtJmlcjgXl6ssfRvrY6k4Up1JBQD7ZAzC9mfsTeHVS3WIwMxURL7BHaetASvqLmNm UgxccnBaomm30ebdVozUdI13wCw2sfdlMmbo8cNARUiEmKsFp5JUB8nPQd/sakAtig b0H8eiE++uIbdzfQp+sJWK+IbA5Bn63eSuDHNxglbPqc7M8to9/SU1gKd5jVAH4yKi yG1nga8d1f8yA== Date: Tue, 19 Sep 2023 16:12:23 -0400 From: =?utf-8?B?TsOtY29sYXMgRi4gUi4gQS4=?= Prado To: Stephen Boyd Cc: Chen-Yu Tsai , kernel@collabora.com, AngeloGioacchino Del Regno , Greg Kroah-Hartman , Hsin-Hsiung Wang , James Lo , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH v3] spmi: mtk-pmif: Serialize PMIF status check and command submission Message-ID: <7b407eda-702a-444a-b644-5e8dc31f3991@notapiano> References: <20230724154739.493724-1-nfraprado@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 13:12:38 -0700 (PDT) On Thu, Aug 10, 2023 at 06:03:53PM -0400, N?colas F. R. A. Prado wrote: > On Mon, Jul 24, 2023 at 11:47:33AM -0400, N?colas F. R. A. Prado wrote: > > Before writing the read or write command to the SPMI arbiter through the > > PMIF interface, the current status of the channel is checked to ensure > > it is idle. However, since the status only changes from idle when the > > command is written, it is possible for two concurrent calls to determine > > that the channel is idle and simultaneously send their commands. At this > > point the PMIF interface hangs, with the status register no longer being > > updated, and thus causing all subsequent operations to time out. > > > > This was observed on the mt8195-cherry-tomato-r2 machine, particularly > > after commit 46600ab142f8 ("regulator: Set PROBE_PREFER_ASYNCHRONOUS for > > drivers between 5.10 and 5.15") was applied, since then the two MT6315 > > devices present on the SPMI bus would probe assynchronously and > > sometimes (during probe or at a later point) read the bus > > simultaneously, breaking the PMIF interface and consequently slowing > > down the whole system. > > > > To fix the issue at its root cause, introduce locking around the channel > > status check and the command write, so that both become an atomic > > operation, preventing race conditions between two (or more) SPMI bus > > read/write operations. A spinlock is used since this is a fast bus, as > > indicated by the usage of the atomic variant of readl_poll, and > > '.fast_io = true' being used in the mt6315 driver, so spinlocks are > > already used for the regmap access. > > > > Fixes: b45b3ccef8c0 ("spmi: mediatek: Add support for MT6873/8192") > > Signed-off-by: N?colas F. R. A. Prado > > Hi, > > gentle ping on this one. MT8195 Chromebooks sometimes boot to a broken state > without it. Hi Stephen, once again kindling reminding you of this important fix for MediaTek platforms, solving a real issue impacting basic functionality observed on the MT8195 Chromebook. Thanks, N?colas