From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70DA342B318 for ; Tue, 11 Aug 2026 10:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786443113; cv=none; b=bMUKo7QiwVToVfAoVyE/Oc8OP00iXluvqhgQNctAueBqybEXG/2c+w04XT5jb1pzfBK2FQjOkRPFFEWw2Qz2h4jenK0lyLMDlk/aLi12BjFtvF5zp78GWI25adFNMEH1LxZVrzIx8AjoBXvp547v2GRXQkgdWVhBjwS2ONLLR5s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786443113; c=relaxed/simple; bh=TtpVesbSC6uE8J9ZxjgUfx5QYR49uFgu3nvmBYE3IvU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hzfQUe1guBZI0TZYYS3HKRY2gEbO5Or+TyxSyeBpwxxcSDaRNWAbXPikQlTmLh+iIIUB7pxz5s+O/c3bMblxvCm29pMEY8bzCkxRpZ3Wtv4famlsj91CrID0gobJxe7vs6qsbHmAwflBD5H0xHJdoU5DgcFNF3rHTXaIKExoUFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=MfaJYIir; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MfaJYIir" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49553515a8bso45324285e9.1 for ; Tue, 11 Aug 2026 03:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1786443105; x=1787047905; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=9oGjBDmrMT1HdtDTd1zYF2GyNqQyxEZ7UjS4ThjuxXQ=; b=MfaJYIirDSO8Zff6kkB5rRRWRU8oKse+T+6VjX5rAd1RiRH/mDQPikgs75hQ49V7hV VyHd0rZRXGmVux5DdP7pAqqpdm8Aml46E4/UR0yG8cGvOYRTheWcQ25rTJDdDiXJx0Ql yDBVFv+hRwTMt3CfugeiWvNDE/UcjRKTFHXBnwLAGkUwHKjW1FZ+IV90a8O5Z8z3kViN m3KI8ud8LJ89Qe+s5Kvluh6sLz5qubhBjbSUvsNhXbKlZa6BwZxdRuOx9kJVuDI8aH8R tLSjQnatqzSgoS6YYgFMLBtQc5O2qGE6ssX0HRJWvUkOwWIm9wDklTlgsxrDCuNaN0C2 xw3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786443105; x=1787047905; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9oGjBDmrMT1HdtDTd1zYF2GyNqQyxEZ7UjS4ThjuxXQ=; b=GS0h5d2PGdqxwuNNzAnYMko5VOc5OT+vXLBhuFC+/ZWNa/5lhp97pZQbI3TEizHauZ CVe+Q7bi3+/02pY1rA55+Tv8/+IPdo/t57ZM6lGCwzmrFtvF3AeWZccwdEJYeeMa47dA Xv1tucvPh74XwRjU7/yWfZEpGgRNg4euJ061WZ+yXs1d11+EuTKb39c3CFj/LVTNbgff SBJXn7in+NiBOBN8QDOfFkBh6iwDAc7K0PJLTQcvD6+MpSskUVfulOJlUv5WUOuChsJ+ 6/l/HxJNOjYeSS3qwKfzX44fUFpWApm9I/B2I2CRPxdC+7xSRTB6KGNIVi/XFM4T6/EC Rs6A== X-Forwarded-Encrypted: i=1; AHgh+Rrm3RsGjLQx3KsBuIPTGpjwXt/MjfdGt13cdPJhg5UQCEnnmvhV7AKIROA87rPoqVDXt16RczTJFpGtcRI=@vger.kernel.org X-Gm-Message-State: AOJu0YzeYlN9y/+VVBrakDbeZvuc2/uLELlWPC0CLwb+STm82byQrRBf 8/WrPZVs+Jyvve6T3NVYEQqh/CFre76H8e8Xooghf1vCY+N+s7B/H6dJpNSoSTmG060= X-Gm-Gg: AR+sD11aUcJ16sr/ojBCWleppCxwUt9GiHxw/wf6i4v3pqtKYvuIfm8udXqc2CILu/C F3u+MIHvgTQXFVgvrmxfwfLCh92vnGz2F3bORo0Q3F5zgX4mvrp4wBwa66s4FqWlVA82zrvDi8H LpvTgvY7hCwbByiIVG1iJscgi/Recc+cmQugEZGWwH+u7jHDlEHDxsvhA16LuCRwkGFOaJofLEa LFbznhezzRzbcCH9Uz6upy/4Vh0m6Qm3CKhSD7fDG0Ah2X7fvnyaHCuWIUxv1HivDSjolto215z 35oNgKjbbfmBNpUopO6oux8zcTJF7z3yItyo3JPz0fsMLEq4TNwBuNm5PI8Avuc3RdhDBRowEBk PfFW1Lo/auwEZOGuLXNGgvOKWJPP3ZXPug/18DXZa+PUcm/DG9BAjTSOG0coQKhMKufqVhvN9oa RK3+63p6zF1IblcJ7RTRaLBp83h6s4+ZpaviOpKGwaEtWriw3BJZ/xb7c/B6S4u1yNlh49Plo= X-Received: by 2002:a05:600c:8b4c:b0:499:593c:3384 with SMTP id 5b1f17b1804b1-49978434835mr35593495e9.6.1786443104947; Tue, 11 Aug 2026 03:11:44 -0700 (PDT) Received: from [192.168.0.252] ([79.115.156.91]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49977bab2f5sm23183255e9.0.2026.08.11.03.11.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Aug 2026 03:11:44 -0700 (PDT) Message-ID: <0ff8afdc-7a11-4a6c-9f62-6f8ba712c4ac@linaro.org> Date: Tue, 11 Aug 2026 13:11:41 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] mtd: spi-nor: use guard() in spi_nor_rww_start_exclusive To: Runyu Xiao Cc: Pratyush Yadav , Michael Walle , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, jianhao.xu@seu.edu.cn References: <20260811041349.333176-1-runyu.xiao@seu.edu.cn> <20260811083111.403453-1-runyu.xiao@seu.edu.cn> Content-Language: en-US From: Tudor Ambarus In-Reply-To: <20260811083111.403453-1-runyu.xiao@seu.edu.cn> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 8/11/26 11:31 AM, Runyu Xiao wrote: > Commit 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex cleanup > helpers") converted the RWW start helpers to scoped mutex cleanup, but > left spi_nor_rww_start_exclusive() using a plain mutex_lock(). > > spi_nor_rww_start_exclusive() is used as a wait_event_killable() > condition. When it returns false on the busy path, the raw mutex_lock() > leaves nor->lock held and blocks the operation that must clear the RWW > state in spi_nor_rww_end_exclusive(). > > Use guard(mutex) here as well so this helper matches the other RWW > start helpers and releases nor->lock on the false return path. > > Fixes: 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex cleanup helpers") The fixes tag is wrong. The blamed commit did not change the functionality of the code, while yours does. You shall instead blame the commit that failed to release the lock in the first place. But then if you want to have this backported to stable kernels you may want to add 03e7bb864d9a ("mtd: spi-nor: use scope-based mutex cleanup helpers") as a prerequisite patch, as it includes . Cheers, ta > Cc: stable@vger.kernel.org > Signed-off-by: Runyu Xiao > --- > Changes in v3: > - Reframe the changelog around the scoped-helper conversion that missed > spi_nor_rww_start_exclusive(). > > Changes in v2: > - Replace the analysis-style explanation with a short maintainer-facing > description of the busy-path lock hold. > - Keep the fix focused on using guard(mutex) so the mutex is released on > both paths. > > drivers/mtd/spi-nor/core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c > index ccf4396cdcd0..8bc117b46e02 100644 > --- a/drivers/mtd/spi-nor/core.c > +++ b/drivers/mtd/spi-nor/core.c > @@ -1310,7 +1310,7 @@ static bool spi_nor_rww_start_exclusive(struct spi_nor *nor) > { > struct spi_nor_rww *rww = &nor->rww; > > - mutex_lock(&nor->lock); > + guard(mutex)(&nor->lock); > > if (rww->ongoing_io || rww->ongoing_rd || rww->ongoing_pe) > return false;