From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.3]) (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 ADC3944CAC6 for ; Fri, 16 Oct 2026 10:05:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.3 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792145135; cv=none; b=B49EyZQiSaGIZ0BGvIlG4nJ7xsw0vYvjHV16tbV5JmnQuj3qzTfRpNFVcM7zDm5ctTCl84csYazjhsS81pP84HFONyNHK73ASK9iuQMGeJucAIpMU3awMxouLzpUB4fnHHqpOqY9LHMKNyO9L7vFUopEZRj6bV8EcGZ27C9jrcQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792145135; c=relaxed/simple; bh=h8f8KEg8cKDqshsZfL/HUAjX02nPGZIq1YAVidDt4Gw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ECXFgk1nsPLnUrX+jpsnqIRu8nNgicitOL992JzE/3sEJJv7PtzQwbuwUgxL+M9zl38LvHfELh0Nucrb0IUEvR4pUweCKEk6BSXoD5G5XcHNzYqfV6N0MHdP/nWfNKO8p/GJ7sY/c9YQNj/reo4Vq1VTj9msPurZVDDjxYtXTAI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=l7LoSSjs; arc=none smtp.client-ip=117.135.210.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="l7LoSSjs" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=AW E1s/ZRz2DA7ggepag+U192x43cO6TBe8drdtmVl30=; b=l7LoSSjsy15QSzu++C ldjQnpGbTYjYFQw1GTqXeUcr0GEAnefh+M5MceRPiQyKCf+m/IlN6REhoSEAjJT7 O4kSp/9xJN28D8D4WNoQzjq4Q2z1z0cJM+havi85N1L+sd/4pSCsTp69ADy1SXAl fOdJLzRuTxKpCA5ifCNNUHqdg= Received: from pc.localdomain (unknown []) by gzga-smtp-mtada-g0-3 (Coremail) with SMTP id _____wD3fxXj9tFqdQTxAQ--.15252S4; Fri, 16 Oct 2026 18:05:26 +0800 (CST) From: Jiale Yao To: Matti Vaittinen , Liam Girdwood , Mark Brown , linux-kernel@vger.kernel.org Cc: Jiale Yao Subject: [PATCH 2/2] regulator: irq: freeze deferred hardware access during suspend Date: Fri, 16 Oct 2026 18:05:22 +0800 Message-Id: <20261016100522.2582557-3-yaojiale02@163.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261016100522.2582557-1-yaojiale02@163.com> References: <20261016100522.2582557-1-yaojiale02@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:_____wD3fxXj9tFqdQTxAQ--.15252S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxGFWrGF4UZry3Kry7Xw1UWrg_yoW5ur18pF WayrWYvr4IyFWxWr43Zw12v3W5Ka1kJwnrCa1xJr4Syw1FyF13Z3WvyF1YgFW8JrZ5Wa12 yFWDZrWxZa18XFJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zi3kusUUUUU= X-CM-SenderInfo: x1dryxhdohiji6rwjhhfrp/xtbC7wcGQGrR9udxdQAA3A The regulator IRQ helper delays status checks and recovery callbacks on non-freezable workqueues. Those callbacks may access regulator hardware after the backing bus has been suspended. Use system_freezable_wq for normal-priority callbacks. Allocate a freezable high-priority workqueue when requested so the high_prio contract is preserved while hardware access is frozen across suspend. Signed-off-by: Jiale Yao --- drivers/regulator/irq_helpers.c | 38 +++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/regulator/irq_helpers.c b/drivers/regulator/irq_helpers.c index 5b3cfac28667..cdbd170d2b15 100644 --- a/drivers/regulator/irq_helpers.c +++ b/drivers/regulator/irq_helpers.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "internal.h" @@ -27,6 +28,7 @@ struct regulator_irq { int irq; int retry_cnt; struct delayed_work isr_work; + struct workqueue_struct *wq; }; /* @@ -145,12 +147,7 @@ static void regulator_notifier_isr_work(struct work_struct *work) return; reschedule: - if (!d->high_prio) - mod_delayed_work(system_dfl_wq, &h->isr_work, - msecs_to_jiffies(tmo)); - else - mod_delayed_work(system_highpri_wq, &h->isr_work, - msecs_to_jiffies(tmo)); + mod_delayed_work(h->wq, &h->isr_work, msecs_to_jiffies(tmo)); } static irqreturn_t regulator_notifier_isr(int irq, void *data) @@ -248,13 +245,8 @@ static irqreturn_t regulator_notifier_isr(int irq, void *data) } if (d->irq_off_ms) { - if (!d->high_prio) - schedule_delayed_work(&h->isr_work, - msecs_to_jiffies(d->irq_off_ms)); - else - mod_delayed_work(system_highpri_wq, - &h->isr_work, - msecs_to_jiffies(d->irq_off_ms)); + mod_delayed_work(h->wq, &h->isr_work, + msecs_to_jiffies(d->irq_off_ms)); } return IRQ_HANDLED; @@ -363,13 +355,25 @@ void *regulator_irq_helper(struct device *dev, init_rdev_errors(h); - if (h->desc.irq_off_ms) + if (h->desc.irq_off_ms) { + if (h->desc.high_prio) { + h->wq = alloc_workqueue("regulator_irq_highpri", + WQ_FREEZABLE | WQ_HIGHPRI, 0); + if (!h->wq) + return ERR_PTR(-ENOMEM); + } else { + h->wq = system_freezable_wq; + } + INIT_DELAYED_WORK(&h->isr_work, regulator_notifier_isr_work); + } ret = request_threaded_irq(h->irq, NULL, regulator_notifier_isr, IRQF_ONESHOT | irq_flags, h->desc.name, h); if (ret) { dev_err(dev, "Failed to request IRQ %d\n", irq); + if (h->desc.irq_off_ms && h->desc.high_prio) + destroy_workqueue(h->wq); return ERR_PTR(ret); } @@ -393,8 +397,11 @@ void regulator_irq_helper_cancel(void **handle) struct regulator_irq *h = *handle; free_irq(h->irq, h); - if (h->desc.irq_off_ms) + if (h->desc.irq_off_ms) { cancel_delayed_work_sync(&h->isr_work); + if (h->desc.high_prio) + destroy_workqueue(h->wq); + } h = NULL; } @@ -441,4 +448,3 @@ int regulator_irq_map_event_simple(int irq, struct regulator_irq_data *rid, return 0; } EXPORT_SYMBOL_GPL(regulator_irq_map_event_simple); - -- 2.34.1