From patchwork Mon Jan 23 06:51:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hector Martin X-Patchwork-Id: 47050 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1463052wrn; Sun, 22 Jan 2023 22:55:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXvMip2um2YqZFNQOoHthNQQPg8zQ2C583GTneezXhDfpvd/cetZ+hztfIndjGfI8ylPkjIm X-Received: by 2002:aa7:972e:0:b0:58d:b330:6e7d with SMTP id k14-20020aa7972e000000b0058db3306e7dmr26571264pfg.26.1674456902568; Sun, 22 Jan 2023 22:55:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674456902; cv=none; d=google.com; s=arc-20160816; b=MKU71KPvUieM9zGdfcGL3q3V787GXKtD1guLEL+o1I/pSTqFCVGtoGerSIciy0798r 3FO7NMt11vs1JzNcqqUutFEuowxw/iB2FDv1GzzHKD7RAk1d/88TqlkteTlH3e4Vk64n ufSfuvK77rMlHJu5zGM28i0Kjs4Kd2uaTjiXhh0QYw5nQb84fc7hpxecP3ayN6ch4k2t mR5Hw/LUANJK7DLq0k9AiNnSngQcK6GrdYWi7tO2a0Peanp0GHp0pDRaUbxfd3cVHTx6 3HH5qhttMkuJXqWeXLkQj2xxFeCK/hkHlljBq+enHV9xRyCy8d3yLbkvrs9yJ+B+Bdg1 I6PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=xyow84FyE/d92GQYuz0KgrbJeqUDraoWSFX4Vi7BtD8=; b=h5c5PmxgGvCGcH3+p/ibuKDN+QHwHyVs8wZLN7nOSHBE47CpaivqwJy3Ub8ZPZ7vv3 S8/tuhhZ2uAZ0sqp42Tl48edYV/W7yFomH4EkL2Eu5x1u5zz2RtKmIhVY00KAuwipgVP nTNGSG5aIiT8yGJbV/ZxpZU1btCppMlkUFYeHk0GiBEvPJsLzqCE725GqtST2GsCLict PRwbFJiLsRO4duhM27nb82S1mWu0umONOeOzuc5hiVv3k7EcvrtLD+YlVbXhO/8ySxVe jbx74ukSo4x2mu6GZL+AV/Tq3vAxj2cExXCRPSK473NC7bwwxtTY0+WaUCRW0F2mJ2Fd j2iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marcan.st header.s=default header.b=P+q17GaA; 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=marcan.st Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d62-20020a621d41000000b0058c57e2d56bsi27064746pfd.318.2023.01.22.22.54.50; Sun, 22 Jan 2023 22:55:02 -0800 (PST) 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=@marcan.st header.s=default header.b=P+q17GaA; 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=marcan.st Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbjAWGvr (ORCPT + 99 others); Mon, 23 Jan 2023 01:51:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbjAWGvq (ORCPT ); Mon, 23 Jan 2023 01:51:46 -0500 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8DF1204A for ; Sun, 22 Jan 2023 22:51:44 -0800 (PST) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: sendonly@marcansoft.com) by mail.marcansoft.com (Postfix) with ESMTPSA id 06EBF424EC; Mon, 23 Jan 2023 06:51:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=marcan.st; s=default; t=1674456702; bh=j2bWBmQyozgHL4EsWv4N1w989XFOWo0e4L5yN04ucaI=; h=From:To:Cc:Subject:Date; b=P+q17GaAoExZBPKuP33jcACzrUJoRNQEoH6CmYa4ECDyIqBWYKozTX6ggnmCkuUhg BAKmRCzhXHxpFbFWGq5awTdBFQHQjPnck3St6JX9OLs+xNCCmWjXWhTt8VkHEHNjvY CrWvjwxNFRv48WZaGg8QWr8bqbdsLse9FdrlgXY7q3zOFGBeRIoiUVwZuOJ985NFTP Q4+2ompsX8psMb1Wp92phoZIY0auTXVHtkIyHwiGtBiyKfwZ6dZX9vDO8haqjgH+oj 7Melgg3iSS8bg63xzByn/glTpM0PeEUMaVm8ZlvY0+IJTGJRxJXJQs7D63sw2tVlFU JYfJn950non7A== From: Hector Martin To: Sven Peter Cc: Alyssa Rosenzweig , Janne Grunau , asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Hector Martin Subject: [PATCH] soc: apple: apple-pmgr-pwrstate: Switch to IRQ-safe mode Date: Mon, 23 Jan 2023 15:51:25 +0900 Message-Id: <20230123065125.26350-1-marcan@marcan.st> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755795320772642706?= X-GMAIL-MSGID: =?utf-8?q?1755795320772642706?= This requires changing the reset path locking primitives to the spinlock path in genpd, instead of the mutex path. Signed-off-by: Hector Martin Reviewed-by: Eric Curtin Reviewed-by: Sven Peter --- drivers/soc/apple/apple-pmgr-pwrstate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/soc/apple/apple-pmgr-pwrstate.c b/drivers/soc/apple/apple-pmgr-pwrstate.c index e1122288409a..a3e2bc1d2686 100644 --- a/drivers/soc/apple/apple-pmgr-pwrstate.c +++ b/drivers/soc/apple/apple-pmgr-pwrstate.c @@ -116,8 +116,9 @@ static int apple_pmgr_ps_power_off(struct generic_pm_domain *genpd) static int apple_pmgr_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) { struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); + unsigned long flags; - mutex_lock(&ps->genpd.mlock); + spin_lock_irqsave(&ps->genpd.slock, flags); if (ps->genpd.status == GENPD_STATE_OFF) dev_err(ps->dev, "PS 0x%x: asserting RESET while powered down\n", ps->offset); @@ -129,7 +130,7 @@ static int apple_pmgr_reset_assert(struct reset_controller_dev *rcdev, unsigned regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, APPLE_PMGR_RESET); - mutex_unlock(&ps->genpd.mlock); + spin_unlock_irqrestore(&ps->genpd.slock, flags); return 0; } @@ -137,8 +138,9 @@ static int apple_pmgr_reset_assert(struct reset_controller_dev *rcdev, unsigned static int apple_pmgr_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) { struct apple_pmgr_ps *ps = rcdev_to_apple_pmgr_ps(rcdev); + unsigned long flags; - mutex_lock(&ps->genpd.mlock); + spin_lock_irqsave(&ps->genpd.slock, flags); dev_dbg(ps->dev, "PS 0x%x: deassert reset\n", ps->offset); regmap_update_bits(ps->regmap, ps->offset, APPLE_PMGR_FLAGS | APPLE_PMGR_RESET, 0); @@ -147,7 +149,7 @@ static int apple_pmgr_reset_deassert(struct reset_controller_dev *rcdev, unsigne if (ps->genpd.status == GENPD_STATE_OFF) dev_err(ps->dev, "PS 0x%x: RESET was deasserted while powered down\n", ps->offset); - mutex_unlock(&ps->genpd.mlock); + spin_unlock_irqrestore(&ps->genpd.slock, flags); return 0; } @@ -222,6 +224,7 @@ static int apple_pmgr_ps_probe(struct platform_device *pdev) return ret; } + ps->genpd.flags |= GENPD_FLAG_IRQ_SAFE; ps->genpd.name = name; ps->genpd.power_on = apple_pmgr_ps_power_on; ps->genpd.power_off = apple_pmgr_ps_power_off;