From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2C3842D0614 for ; Wed, 8 Apr 2026 06:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775630910; cv=none; b=o+EAQA+dhiuP4LeHEWXgsl15nE6eAHltX/iALdcGL7rvaVf097G7H2MhzSA0oYF5Qbzd3eI+mKRYULLTWsQocm3H3XKS4zIVHqVrFPNzUbrWDyjXt7p97cX4vgpVj9iPx6Os6ADy303AT7vEyaqwFBc9xx1vLxRY5ruhUAQ1y4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775630910; c=relaxed/simple; bh=jj4vsHhmyvWklZBA0ReybHPq5xTd0EAC4C0F2VS5aEU=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=Y34mUboP4lsT63Lr2V7DMHJar0+08NsQHAtYjEGzZnJfviioCJ4VmIAj/RPNPPHIjdjGjpiiGytz9SseRhzowclOuZyW06L3iIciw7i+oWGPVuSPFbp3CwDqw8vUvHHE9AWAqaAjTiu34ujWLewag5cvZ5yOx0RdgXjzQd6S6cE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HeY4DRMm; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HeY4DRMm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 586B8C19424; Wed, 8 Apr 2026 06:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775630909; bh=jj4vsHhmyvWklZBA0ReybHPq5xTd0EAC4C0F2VS5aEU=; h=Subject:To:Cc:From:Date:From; b=HeY4DRMmcsfaWNiZSFYDxJOMJR5uteVGAJIIDXkqgASOnd6RJ77razi3OeFwCHLo9 smniKD1dTBt3VExrLgLlC3v+IjU2a01JKeEjyt9HSe9fKxfJoUPvRFM+d/j69d3/aB JkX24l0rmxexrPtD1JckuCmdDH+UsEIKUQVOoE50= Subject: FAILED: patch "[PATCH] spi: cadence-qspi: Fix exec_mem_op error handling" failed to apply to 6.1-stable tree To: emanuele.ghidoli@toradex.com,broonie@kernel.org Cc: From: Date: Wed, 08 Apr 2026 08:48:19 +0200 Message-ID: <2026040819-resend-amiss-2b5d@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 59e1be1278f064d7172b00473b7e0c453cb1ec52 # git commit -s git send-email --to '' --in-reply-to '2026040819-resend-amiss-2b5d@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 59e1be1278f064d7172b00473b7e0c453cb1ec52 Mon Sep 17 00:00:00 2001 From: Emanuele Ghidoli Date: Fri, 13 Mar 2026 14:52:31 +0100 Subject: [PATCH] spi: cadence-qspi: Fix exec_mem_op error handling cqspi_exec_mem_op() increments the runtime PM usage counter before all refcount checks are performed. If one of these checks fails, the function returns without dropping the PM reference. Move the pm_runtime_resume_and_get() call after the refcount checks so that runtime PM is only acquired when the operation can proceed and drop the inflight_ops refcount if the PM resume fails. Cc: stable@vger.kernel.org Fixes: 7446284023e8 ("spi: cadence-quadspi: Implement refcount to handle unbind during busy") Signed-off-by: Emanuele Ghidoli Link: https://patch.msgid.link/20260313135236.46642-1-ghidoliemanuele@gmail.com Signed-off-by: Mark Brown diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 5fb0cb07c110..2ead419e896e 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1483,14 +1483,6 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) if (refcount_read(&cqspi->inflight_ops) == 0) return -ENODEV; - if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) { - ret = pm_runtime_resume_and_get(dev); - if (ret) { - dev_err(&mem->spi->dev, "resume failed with %d\n", ret); - return ret; - } - } - if (!refcount_read(&cqspi->refcount)) return -EBUSY; @@ -1502,6 +1494,14 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) return -EBUSY; } + if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) { + ret = pm_runtime_resume_and_get(dev); + if (ret) { + dev_err(&mem->spi->dev, "resume failed with %d\n", ret); + goto dec_inflight_refcount; + } + } + ret = cqspi_mem_process(mem, op); if (!(ddata && (ddata->quirks & CQSPI_DISABLE_RUNTIME_PM))) @@ -1510,6 +1510,7 @@ static int cqspi_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op *op) if (ret) dev_err(&mem->spi->dev, "operation failed with %d\n", ret); +dec_inflight_refcount: if (refcount_read(&cqspi->inflight_ops) > 1) refcount_dec(&cqspi->inflight_ops);