From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.198 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795920444; b=SE2oA/DeHD4JthFZYVIIUjbu8hk49nXPT2xEYOlug/AWNWhlqK4AhPRpkuIdzrlAXOM0 E7au9Kwas35ZMuZEpQ2A8iQlUPTLVGk6IxuvcYvR4B0AgBPv+ZxQo8D9NOAAm7JJke5hu vhUleSCC5zTUkQG57ys/QMnZ5AmC3o07+Pi2Ldjh4rvcH4lF6p71r2hBCYUEaDZ0Nhhad /sY1Vlq8feOYZjwgsbcnMSk4+9EQ8fi4QiQmVZuCEK16Tergo3r4/zeQquja0DgtsetFc SLvM+/MNVfVQU9iJe3HTqfQnbrN4Al524+oTwu5LiLrMfBkhPgfH0CbLuS2paBvoPLw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795920444; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=wPJvdPWMvhkn7jGnVQmFqlwYiS3Vvfo8eJHiHiN7fiI=; b=Sr2fKKFUh8Ee4QdovcP2Zkr6Mcwzkmm8MbL7yiaAmXO940DNFydcN1NIZLtEtLac1H0D 6P93PYD6/1+KnqBrF+ezJ+2+DdI2sfEhAKjA6M5N88XTDaK4bk5/jVbCYz9AbYO/+AHHR SPhISDwTOQFE0SoagYYTSeagrVNVMSRzQkYYsI8OPDE1SBGmXqc6cfQu0C63vXTXeDT8f MmwpPCFdszDz3DhM1RWsuEMqgdg2pi9H0lLYBGFI4aS0Se5LCg1/4ql/HIv9KxV40d+D5 RKRYYWfZfk/okQjFT6YLR05AC/mqEF8qrF0EJMmYJxLFTdj2wyTFE+aCwSP7W9nYEig== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--zhenwenliang.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="eAke8C2/"; arc=none smtp.remote-ip=209.85.214.198 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D39E3606A31C for ; Sun, 29 Nov 2026 02:47:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D39E3606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--zhenwenliang.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=eAke8C2/ Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2edd25534afso76005215ad.2 for ; Sat, 28 Nov 2026 18:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795920443; x=1796525243; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=wPJvdPWMvhkn7jGnVQmFqlwYiS3Vvfo8eJHiHiN7fiI=; b=eAke8C2/ykF125/VD90q6oWA2ycq1Q1QnaRHPGj7AhQbAgrqSt40RVdsMWVwDe2hG8 FGIpzhyYM7XGZSx6Z5MLVU/olOsdF2jrLjmktu1AA6VJnxoqQIM7AZNUz/AGaatvgCLg 56fsNrhcz4672ErGb07zBfcHmHuNIHkc6X8MOfjHDs5OHJAoBB6i+ZcFt82ZlJiMnx8e uzovM52Ca0f4XnkqeIJaUBsY1jnN5WhuBnwWnsa4nC0G91v2FVWDj1oguK7VbUPPWvYU 6XwTtgEaAwJKpHiaSahjTVVIgb1pBhCDsu2VRWwdKuQIC774d7/1aiIztmvN7R1OW5Tt w+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795920443; x=1796525243; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=wPJvdPWMvhkn7jGnVQmFqlwYiS3Vvfo8eJHiHiN7fiI=; b=dJWXiaOoJuYjrPFdkjvwh/+Jtm6J0/igAimbC2bidU14p7+77P5y2aNrORzXES1Te8 h+I0mU18BBeCn+zCwNM9N9dNkaaapnPahSp8GROu3zsgeEPwTS3MXjedwR+Ob2viWScl vD5K15F9s+1xaTKSyoJO7nhzokNdIuk1qvOGkWspNC0nOSrA24BhcC7D8S33IEV8ceQU G2etqsPj/O1Rvwk1xJy6UPzkLJ4BNDp00RIfkdw5MEtqnl4y1deCYi3l7+7wp+Bz2S4J zBp0riPH+zlOntJ2A15oRWhYTi/wvxPWQe6mjry0oZeM+lJToE1fF3EbgrSrLc8foYts SFtg== X-Forwarded-Encrypted: i=1; AL+hErGbJ/254vY8ABqePwLHHsNJn0eDPZUVOwyTUDTOMKoRQq0zRzi+gMY7fD43WzxqZ5+rkqYCHMQv5TyHQIE=@vger.kernel.org X-Gm-Message-State: APuU4Z/sckOVn4nKtKH4tXAvwatbHUQQlm9KNYUxtumEKeGynhdVQLhM 4zHgCoS2t+yp2BSilOFXpUc3g9TcQl+UbRnlbLSiqcgbZu7Xia159kfOkakxcWhsQJztiebNYS0 b+q/5gzrkbSshoMG08rTUhst09MhAZg== X-Received: from pllh2.prod.google.com ([2002:a17:902:7482:b0:2f0:4ed9:64dd]) (user=zhenwenliang job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:ce0b:b0:2ed:102c:f24 with SMTP id d9443c01a7336-2f03f1e0c06mr300368215ad.53.1795920442814; Sat, 28 Nov 2026 18:47:22 -0800 (PST) Date: Sun, 29 Nov 2026 02:47:22 +0000 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261129024722.281255-1-zhenwenliang@google.com> Subject: [PATCH] mei: me: fix a lost wake-up in mei_me_pg_legacy_intr() From: Zhenwen Liang To: Alexander Usyskin Cc: Arnd Bergmann , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" mei_me_pg_legacy_intr() sets dev->pg_event and hw->pg_state and then calls wake_up(&dev->wait_pg) only if waitqueue_active() finds a waiter. The waiter, mei_me_pg_legacy_exit_sync(), drops device_lock before wait_event_timeout(), so the lock does not order the two sides, and nothing orders the store to pg_event before the lockless waitqueue_active() load. As described in the comment above waitqueue_active(), the waker can then see an empty queue while the waiter still reads the old pg_event, and the waiter is not woken. The waiter's wait_event_timeout() expires after dev->timeouts.pgi (1 s) and it then rechecks pg_event under device_lock, so the effect is a delay of up to 1 s, not a hang. Call wake_up() unconditionally. It takes the wait queue lock, under which the waiter adds itself to the queue, so either the waiter sees the new pg_event or the waker sees the waiter. Commit 8c27b1bce059 ("mei: me: reduce the scope on unexpected reset") likewise replaced a waitqueue_active() check with an unconditional wake_up() for wait_hw_ready in this file. The same change to this function was posted in 2015 by Kosuke Tatsukawa as part of a wider patch that also changed client.c and hw-txe.c; it received no reply. This patch changes only mei_me_pg_legacy_intr(); the other sites are not addressed here. In the herd7 x86-TSO model, a litmus test of the pattern is allowed before this change and forbidden after it. The problem was independently rediscovered, and this patch prepared, with the help of a formal analysis tool we are developing that uses AI assistance; I have reviewed the analysis and the patch. Compile-tested on x86-64 (clang) with W=1; not runtime-tested. Fixes: 3dc196eae1db ("mei: me: wait for power gating exit confirmation") Link: https://lore.kernel.org/all/17EC94B0A072C34B8DCF0D30AD16044A02874774@BPXM09GP.gisp.nec.co.jp/ Signed-off-by: Zhenwen Liang --- drivers/misc/mei/hw-me.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/mei/hw-me.c b/drivers/misc/mei/hw-me.c index 1c3ab9eb8b1b..4486209c9be9 100644 --- a/drivers/misc/mei/hw-me.c +++ b/drivers/misc/mei/hw-me.c @@ -1099,8 +1099,7 @@ static void mei_me_pg_legacy_intr(struct mei_device *dev) dev->pg_event = MEI_PG_EVENT_INTR_RECEIVED; hw->pg_state = MEI_PG_OFF; - if (waitqueue_active(&dev->wait_pg)) - wake_up(&dev->wait_pg); + wake_up(&dev->wait_pg); } /** -- 2.56.1.839.g22a8290db9-goog