From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 1F72B39F166; Sat, 12 Sep 2026 07:05:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789196729; cv=none; b=lbHE7g3e6kXBwBqd7o1bgjZNK6CqIKfOzfgf916QnT8qEzCMFbICsz2X6DfntEtTMsD0qwQ1b2U/F0ZTWf9smTaB+D112KOkt+q06uQ+wA5vz9zrXF0aXYV9z8+A+Bo7k0RRInGqpg2vvvc03/sz7C9UY5GgWdkKN13zRyMUcyA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789196729; c=relaxed/simple; bh=pEkoGrDqSfTRUxP8NfVGzqmztOHL2KVlzdSNNBAX2YY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DsxzPgORofLeKJdZuYX9uqxn+AyuB6x2IjQFLVnmFztYT3P2DSKRD0m73++0xN2C6jofiF7YBrMGRtsnwYwgcZ8XPAXs3cT3xmCxB/NbF98SZAii5J4UD0WqYV/CwvB+4MulBwXZEiEcjrGtSXXrhWBvUjcVpq+iLmr2Baupbd0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ncCJHx7X; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ncCJHx7X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29BFA1F000FF; Sat, 12 Sep 2026 07:05:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789196724; bh=LHtwKGLTJ/ZxamE8fwxCiUf50BUTmwoaM8A5euJRhSk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ncCJHx7X/YC7efy0JHMTvyzFV4L8eLA/t3BM+5glTySoxc+Jt10JtKLtBU6eco0yi bp38BowWIoLQWEf1wr+6Wq4zjj4YQMAeIoXgw3Ld+I1fzWw8EpDjc41VdQcS0Qahwf jOXGF7/AeiiBfXT1AfcsgrZTZv+jSeriERSxV9Tc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li Chen , "Michael S. Tsirkin" , Sasha Levin Subject: [PATCH 7.2 0024/1815] nvdimm: virtio_pmem: always wake -ENOSPC waiters Date: Sat, 12 Sep 2026 08:29:34 +0200 Message-ID: <20260912065649.574023679@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065648.999753832@linuxfoundation.org> References: <20260912065648.999753832@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Li Chen [ Upstream commit 811808761e19fdea1c25b7c76734b8945f758f27 ] virtio_pmem_host_ack() reclaims virtqueue descriptors with virtqueue_get_buf(). The -ENOSPC waiter wakeup is tied to completing the returned token. If token completion is skipped for any reason, reclaimed descriptors may not wake a waiter and the submitter may sleep forever waiting for a free slot. Always wake one -ENOSPC waiter for each virtqueue completion before touching the returned token. Signed-off-by: Li Chen Signed-off-by: Michael S. Tsirkin Message-ID: <20260630092338.2094628-7-me@linux.beauty> Stable-dep-of: e57140944b5a ("nvdimm: virtio_pmem: refcount requests for token lifetime") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/nvdimm/nd_virtio.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) --- a/drivers/nvdimm/nd_virtio.c +++ b/drivers/nvdimm/nd_virtio.c @@ -15,26 +15,33 @@ struct virtio_pmem_flush_work { struct bio *bio; }; +static void virtio_pmem_wake_one_waiter(struct virtio_pmem *vpmem) +{ + struct virtio_pmem_request *req_buf; + + if (list_empty(&vpmem->req_list)) + return; + + req_buf = list_first_entry(&vpmem->req_list, + struct virtio_pmem_request, list); + req_buf->wq_buf_avail = true; + wake_up(&req_buf->wq_buf); + list_del(&req_buf->list); +} + /* The interrupt handler */ void virtio_pmem_host_ack(struct virtqueue *vq) { struct virtio_pmem *vpmem = vq->vdev->priv; - struct virtio_pmem_request *req_data, *req_buf; + struct virtio_pmem_request *req_data; unsigned long flags; unsigned int len; spin_lock_irqsave(&vpmem->pmem_lock, flags); while ((req_data = virtqueue_get_buf(vq, &len)) != NULL) { + virtio_pmem_wake_one_waiter(vpmem); req_data->done = true; wake_up(&req_data->host_acked); - - if (!list_empty(&vpmem->req_list)) { - req_buf = list_first_entry(&vpmem->req_list, - struct virtio_pmem_request, list); - req_buf->wq_buf_avail = true; - wake_up(&req_buf->wq_buf); - list_del(&req_buf->list); - } } spin_unlock_irqrestore(&vpmem->pmem_lock, flags); }