Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp685463rdg; Thu, 10 Aug 2023 16:39:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGOep+RtcCpPu2g7lGGsqAHHwTFELpHR1+NW840OLbUawf7YtX4OqbegB63mLyJtW9R7y4N X-Received: by 2002:a17:90a:9501:b0:269:32d2:5ac4 with SMTP id t1-20020a17090a950100b0026932d25ac4mr79582pjo.25.1691710756034; Thu, 10 Aug 2023 16:39:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691710756; cv=none; d=google.com; s=arc-20160816; b=Wv/yI5vVfhN2Mgd4HOhgiIYe97AwjIDgYOOsDZmgqgjsoEB3AcpsYlibkU6MiihNEM WTo5ewBxA3fGncXBXTil46nUhism16UhFtx+icmkjBf++lU83+DiKoueHLhPA4QFWyvZ LERxmcRvJmsI8dXY5sjOWhGvsw9jzOPFUAFDlGHEUvKuhMKkmZRXfUhn1dWrizOfMKeY lMxhoB7wY0842seUMbXJGWvaLSk2IBEEuoirk2uh5bFAMDE9G/4T70k0rzXk8QzXH03a Ltwn0Sl+QrpDeQ64+1EbMbjJhqyBQuB5UOacyeQoLb8OIS4kK6J1G8tvE34gtsRSoOz0 ATXQ== 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=3k2OOXXjJ/0jlJYbFzrhAWpYad7xcBCqy2YqNYhfHdE=; fh=QXAgf+MXbdB153tcGjSeNZgcUjOYhXnB1FnxOv5tmRk=; b=wwnJdKeVCUp73C9OCo9VweyaT5UZWmGBG8k0x1B1VxbVGNPrshBl1HuAG8RrPhnFe2 5L8lJdR9+GCHa9O8GYZwcv9HLYtZGMVBuYEl/k5gUG1iKTG+yj0d3h7NO9PcDzZ4xH0c E3pBg5ZuhxNrESGHWjkKlc5nEtIwgDUPZ0EyiP8rbyA6Fc614avu0IY4nMzOBSJjbA1+ CEh3h2FpOPnQPfBQGCte9fpTfV0YiACeeXByKyPzlk+cpWEoDRiRBBxrDFyir0mZZoLx oqOZ+nhdM6Q0XBooIbMzzEEVugVTtbrVexMStOvRzigjx0iRWvm9GfexnOsrhkl9P9A6 QRWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=M4Bh+ORv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020a17090ab28f00b002637aa0a4dbsi4384771pjr.103.2023.08.10.16.39.04; Thu, 10 Aug 2023 16:39:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=M4Bh+ORv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230414AbjHJWD4 (ORCPT + 99 others); Thu, 10 Aug 2023 18:03:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbjHJWDz (ORCPT ); Thu, 10 Aug 2023 18:03:55 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 483F8128 for ; Thu, 10 Aug 2023 15:03:55 -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 264AE6607234; Thu, 10 Aug 2023 23:03:52 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1691705033; bh=6T/7egYNdrUimo6+730pCHWC9ylPwq+ljDhhdzr7HFc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=M4Bh+ORvPNXXa126m8W13yZjzuJM+v4pK5z3u1dNQVk7UyncP6Ixr9iX87JeV8EHE JNo5lZvuBnDW/1SmhcWVsPTpnTRor6Pxuxr1Iew54EOJukMeaE9krX7mf+KrsGP7Yp I+59Y0JH/bSyTeq9pOMgtVQxOeRYZH3g7g4jJtDzHpbTUHjk9FzmwFNivz3DNG+bSR jCJVOcRnklH+dkXvrfH3uUDGw3eBHfzCBPxnMqfit4fM2BMxIgbY98EjxfXHNIuSuZ YKaVqApvuUgTHUrSegmo9tkduOni5mBN5DWLSi9ayBe2CWdBsg9j9+2yPkG6y6lyC7 B1La0X3KYgxNw== Date: Thu, 10 Aug 2023 18:03:47 -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: 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: <20230724154739.493724-1-nfraprado@collabora.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, N?colas