From nobody Fri Sep 25 22:19:31 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 6D5ED37C11F for ; Tue, 8 Sep 2026 05:39:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845985; cv=none; b=JTGoHnPXgCjg3C0k9+RE4QqEezik7FRoG5Hs3Jt+N0lEyc1ZGaGi5KfQZmtDycJcpfAoCL/rYWrI/CzpTkOHUWVHM6jJp/EGpiDn2W79Z6As5PQnEvu0t7y5II6EIzWIoJmWOpjOktmInlBHjZYUZhzyNWK0uns2TatxtL/KecA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845985; c=relaxed/simple; bh=faRvsNO+3ng5yp7scD2ooEy+g3RDxAsErW36M1n5UGc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ccoD9hRlhNfMGVSgvPXetpgaJbCHtPgUmq/nL9dMjiWqimaHhfvmnvHeNASiGZJNf7sklS2AxAjU7z7BfOeYfjxYFIts6jFJguSmudS+2lHo174h94fsdK8K+sRYgC3IrFWm+oClFNjCnGOTCZbkAadG/JrrQrel76HCb9/pfbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=m3xFggSd; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="m3xFggSd" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49b0d78a801so42196995e9.2 for ; Mon, 07 Sep 2026 22:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845979; x=1789450779; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0Ry5IsRI3u6+OA2QrlJEuTetR9sltFKry3tbM/33hEE=; b=m3xFggSdQQMBIZKvFKAVdG3FM6JbMZdD5AVitmU25Sw/nIYzpGh1jHuCl3u2qGnSX5 wbtEyT9jpSW+bzep6HhLaFnJGg+uDwbTI4v3MFZuRwitHS179JMx27LRgxfUmzjeuh8u +PpXBYa0itQd4NkhxDzXKxEzcT7QpViN3cEn/UOjBjcS2hFhiMH0xf/H6FLLVfK2etrL +6kvJ15Pc2chJKXRTmHAZtnE2V1p6uhYPT4S5n3usGkcuIoLmnyT7BS7Oec6UosEJoNm qopxOEO/xlQyz0VI7aZSKdbbY4XX2t+2jeEWcqHt4j5goH0tv34Gaml7bxbJSjE4beak mg+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845979; x=1789450779; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0Ry5IsRI3u6+OA2QrlJEuTetR9sltFKry3tbM/33hEE=; b=KmVGUhGqqn+pCGsZtuOvs03Fn4yBY3YhLSgL3cDdolbQAzfrVPZsgRWkqqpW4Iir4O KF3t2BE0YwhPv40DiU+aGzsyIYZL2GQVfwjKDqOHzlA8CAnCSuCmGBPL/E2RS2McgHXd 1OBSRaVJoFdKngV3nWLBG8t4S5zE2BsnMKbi72naYX/LPeIW4L20+amAkw0WauOyxAO4 NYngzaeFG1JzE9dRV7tWVhiVYL+wDIb2vFahDHjU3eBLUUxQYhLs3tOYaBBjVcz2uG8v 67ePj7dN5uUtpHfLhAXsBeQMzIos3bfCkOAQn2zF6d8OvAnxowRfYsTizg0cgLguEbDj eX9A== X-Forwarded-Encrypted: i=1; AKwUvByLimwvo1niK/kMH56ZadBRT7a/qITB8WjTRi+GJfzEdlFMH1wD+LxXU1et0ZvdxnbQvO2HaRa7rafbREI=@vger.kernel.org X-Gm-Message-State: AFuF++lq9AcSxlwtZpxiFZfx0BzPFe+mMrUqhTWk9zqUJjVV0a/hfTiQ HjLYthU8itH/t2VI1etjO+ECGPzkf6zGIJv26h9M9LEFLITnY7kTJ0mi X-Gm-Gg: AYBFou18nyZ3kpgRX8zy7M4EOcgez4m+naRy/pHWaKW3rrWCXxCo2N0cnN33S6Hmcb8 tQGV6fyb4g+Tfm1lYjxCMtffaR9VFPGGAiGSA22Xtei1+HTDREVoTB4UZw2aOzNEbtRaLlYGb8B LNP1Zux4S4ZelSqIYWf7ikwIO7uuXksocQCxLZJoK0OzusacZhr9CMV0upqlzJYoP2t2EOVS2w6 wcJMtnl5yCRaBlGe6wCdMXHS5fRz4IGCKOAo/fKg+e5w7FTIK6GESrg3o1D5mLV+Wjf6MBb2j6g bCG1/hMa8SLx1psvBoRtrQ7J36CXZbLtZKKWyuI76nYJnkvI4CX2WNh/NF9XSr10ZSAaGIcAsR+ 2uTTSx2GkvborRWD7tBiLopc7qaUc6oAxvy/3mg6oAuj2W5kNbyWXZLXf+dAm8oCXAkYzURqJ+5 giqwumSZ5odGbAhsQHq1aOVJhZmVOoszd1f0pSA4EAYQlc81ImYyDzmcCpTF6cepERgnyux2y9K wu9NXC/z4x7N+4ZbgkngXJxC2MnulJBfOTDQKONfc/4qwa6KpOOMkZtexLMEKO0Mp/iUA+YHu+G fX5s8sodpsX+m6rEzmRch89u9+d4cW/4g/OXOlecog== X-Received: by 2002:a05:600c:6748:b0:49c:fc6c:bdfa with SMTP id 5b1f17b1804b1-49cfc6cbfa2mr234336305e9.17.1788845978942; Mon, 07 Sep 2026 22:39:38 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:38 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 1/6] virtio_ccw: fix synchronize_cbs() after interrupt fallback Date: Tue, 8 Sep 2026 07:38:12 +0200 Message-Id: <20260908053817.26065-2-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_ccw_synchronize_cbs() assumes the device uses adapter interrupts when vcdev->airq_info is not NULL. If registering adapter indicators fails, virtio_ccw_find_vqs() falls back to classic interrupts but can leave airq_info set. With VIRTIO_HARDEN_NOTIFICATION enabled, virtio_ccw_int_handler() invokes callbacks under vcdev->irq_lock. synchronize_cbs() instead takes the indicator area lock, so it does not synchronize with those callbacks. Use vcdev->is_thinint, which the fallback clears, to select the lock. Keep the airq_info check because is_thinint can be set before the first find_vqs() call, when airq_info is still NULL. Fixes: 3a232277c1ac ("virtio-ccw: implement synchronize_cbs()") Assisted-by: LLM Signed-off-by: Karl Mehltretter --- drivers/s390/virtio/virtio_ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_= ccw.c index bab6cad3fd5c..b90299205698 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -1062,7 +1062,7 @@ static void virtio_ccw_synchronize_cbs(struct virtio_= device *vdev) struct virtio_ccw_device *vcdev =3D to_vc_device(vdev); struct airq_info *info =3D vcdev->airq_info; =20 - if (info) { + if (vcdev->is_thinint && info) { /* * This device uses adapter interrupts: synchronize with * vring_interrupt() called by virtio_airq_handler() --=20 2.39.5 (Apple Git-154) From nobody Fri Sep 25 22:19:31 2026 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) (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 9327C37B3FD for ; Tue, 8 Sep 2026 05:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845987; cv=none; b=SdmHlB/awcOGr54mAfE0eumyRKZEWev0zO7JtvP1fH1yq/nFU8n0gSfEoghplKCNkLbI02ArTZQZpQqMzouPJT1V9kt/FyBsBil6XNWtKo4feSZ7FS53f+R674hH70gbc7sFJtPZsETRzLd4X/HcATrSfI88wefw/+nA3qRex6c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845987; c=relaxed/simple; bh=aHcAwCFI8yTOgrqgZxZPyZpx9kC63bQn/NwjoFN18eI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PR95abXfHj7+vy34OVNc0T2D1hBjedrEw7c48kJPdajMbPaJyBQoh7htECipLl/WESJZZFSnCTYi+23aAIxs7GRuR2SIm4jgsR6CEmOsJ9bkFfH/oy4LkVYVr8ZOJ4AHi+Aw+h6ZKBBKiiuJNNNhEhVQfwuRWGn4CZL/vCnE9xU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SaSVNzwj; arc=none smtp.client-ip=209.85.128.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SaSVNzwj" Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-49b0d8bc2aaso53071145e9.0 for ; Mon, 07 Sep 2026 22:39:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845981; x=1789450781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RUNN4pXUiIqbT553r7BwzJCI10zpfzMw6DzVR+9Z+tQ=; b=SaSVNzwjc/QkT/T8KwoXzG+8FahuRTRm3nYoWB5hzA1LJomjd3MSZ/fGAXSsM9inIh r+P6z+Y4jLr8e8Z22g2f4ST2/kVfIcze+g+Q1YwgMgXvVI4udoYC5gE4MbcggeyR0J25 Vhcc76tjaplrJ5hHHdDoVz4u78ZHWjS0mII5RJZ1YZJKOx8ThoySSjTO1XQlWCX9x1ZW oN/cy4uMbbZin85U94JAeAN3oeLa2kqTilU8meMyL7ObquYLLSk35BESg4DK873fh089 41SQt4dfSmv6+jhis2z/jXd/Dt8HTxBKI1gjBW9l2JMjXe+DGuUdGqKoAwQK+T5uTHn6 loaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845981; x=1789450781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RUNN4pXUiIqbT553r7BwzJCI10zpfzMw6DzVR+9Z+tQ=; b=PVzcOgqSroNCODNgLgZrAUa8wdmE2utU9mcwbl37u7sV5hrAfCAxSa7gl9DwHmoiMF zTQGpd9wKDohJHBod054MlAsnX1oUqEjx3L653tIwGmhqaqnL2sIhp8f75P6UR83ew6I H/s5w9wKfkoaTkLfRSUeZX+wM0m781LLQVBAwdkXDFV/J46vMyjI4clrfPLjxMLBCWEo o7x5mY4L8Kfc26751D70lt7z54/A6mYGGUmEckfPft4vFRfggFF7UlyAPUhSTy8Hkm9V ssu8XEYVRN7IHP6fp6fC1BgDnngSWzsJmetGjZd0kbiDRkIBfYV+ZXY2+XWHCTQgd9Ov MVqw== X-Forwarded-Encrypted: i=1; AKwUvBzZHPj+wixURL4WpW5n8pn3I39hNYNHu4MLsl5Zqc8cAQ/b2dxkTb98oKKoRDIn8N8dLLNeQKO15jf0RGQ=@vger.kernel.org X-Gm-Message-State: AFuF++llGWpQcoukhcBdq6HvW5HTuHWo9ku7tGP3ydRd0OZdFx0xaka0 Xb3s88B6hFx9lpcyjYCaL3Q95Jl2282Vs10JGA1TsLup18zOOAdqgrMy X-Gm-Gg: AYBFou1PEXa8Zq0XZKOma3ZdBbvtCvHbCmd7woP3ijW73d6XOPwD27B50yx3/Xhqb4P qEonH07hedvNw7k9Z0MiaKvSpShXr/j3U0asVjTGXXwQmJ5NTFYV8pQo+T2Sc58Dsw8X5yN4h73 mH+S+OxtxJWk2aapJwKsOrDjX9TLoWjfkiVqZbzZhWDJSCViOiZ8S5C/+MrkhH+aD1mFQgm6HiB Ra+sHgNvjd7HC4PDO1jXoKv5IEZOZpiP6bngR30BONI6BUPjEnGgQm0Km9/+lNuPgwKp7CQ1jNH ZzgNyk3jaEnxf05thqT8b7SD2XWDMBvySk5R/JKp8/94omigs7ZtTm8BGY+edssDTeyVEVn2638 YJZnwdv6aPjoaUlTCZp7c5jGw72Q6FeonWXMT+sFDNReGOE7mg7TjjdtVrqGfOGkeK2yhQnwFYm I+xq8gJREv1wTZDVNTjLwDH6d+q1Sg5oZvYtf2Fh0JPpZDEh+ndqRBq5ans5SqkSitKJch/ACQ3 h8drPrLY1zpSq54MAyGm39AQowN+jkbZL++WGl9KRTYVl4IcMmfDs45TBXEzxcMNUXxxDF+78OX M86mO0nps+aefolmqjFsh3vCne9gEFI= X-Received: by 2002:a05:600c:3b21:b0:49c:ee01:8c53 with SMTP id 5b1f17b1804b1-49cf820ab3dmr263600185e9.2.1788845980825; Mon, 07 Sep 2026 22:39:40 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.39 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:40 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 2/6] virtio_ccw: always take irq_lock in the classic interrupt handler Date: Tue, 8 Sep 2026 07:38:13 +0200 Message-Id: <20260908053817.26065-3-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_ccw_int_handler() takes vcdev->irq_lock around its vring_interrupt() calls only when VIRTIO_HARDEN_NOTIFICATION is enabled. The virtio shutdown path calls synchronize_cbs() even when notification hardening is disabled. virtio_reset_device() now does so after the transport reset too. For classic interrupts, synchronize_cbs() takes vcdev->irq_lock for writing, but the interrupt handler does not take the matching read lock in that configuration. synchronize_cbs() can return while a callback is still running. Take the read lock unconditionally so the write side can synchronize with the callbacks. Fixes: 8bd2fa086a04 ("virtio: break and reset virtio devices on device_shut= down()") Assisted-by: LLM Signed-off-by: Karl Mehltretter --- drivers/s390/virtio/virtio_ccw.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_= ccw.c index b90299205698..552d77998012 100644 --- a/drivers/s390/virtio/virtio_ccw.c +++ b/drivers/s390/virtio/virtio_ccw.c @@ -1204,13 +1204,11 @@ static void virtio_ccw_int_handler(struct ccw_devic= e *cdev, vcdev->err =3D -EIO; } virtio_ccw_check_activity(vcdev, activity); -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION /* * Paired with virtio_ccw_synchronize_cbs() and interrupts are * disabled here. */ read_lock(&vcdev->irq_lock); -#endif for_each_set_bit(i, indicators(vcdev), sizeof(*indicators(vcdev)) * BITS_PER_BYTE) { /* The bit clear must happen before the vring kick. */ @@ -1219,9 +1217,7 @@ static void virtio_ccw_int_handler(struct ccw_device = *cdev, vq =3D virtio_ccw_vq_by_ind(vcdev, i); vring_interrupt(0, vq); } -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION read_unlock(&vcdev->irq_lock); -#endif if (test_bit(0, indicators2(vcdev))) { virtio_config_changed(&vcdev->vdev); clear_bit(0, indicators2(vcdev)); --=20 2.39.5 (Apple Git-154) From nobody Fri Sep 25 22:19:31 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 1000537F326 for ; Tue, 8 Sep 2026 05:39:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845989; cv=none; b=L5ySS/gNx6R1aqLjCffwSKmbIxvE0HRREL3bO/e1uIw17Z+EVjSJ/AsMj5iyyvB73d7vyEQzGP4jyXVkuMtrwBAWqxn+kndlsFZvWlSEV6WvFIRkIQ/x52OgKKmoAwLzQ6c/uYErZY4eWb2TwyJk1+1hFRLqInt4hpUY0mI3xc8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845989; c=relaxed/simple; bh=PkogetTRkUDafLifysmf44FPwJ2N6pmK+olIC+Y8gdc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aW/JYNCBT2r+9zwS4l8PHIGwQHAOgDRgs/n+MT5J0i3rGXxIqV14U3QGGJoW0iAZHU3iFaAdBRmC3tjbCrbWnxBcFIktnpi1cFp/OUoxMc/AhEqOZXaC9Z/4Z5fimB2XQVT2uRhEc4jmti/MyHivxkHjwzKBhejYO9yZNW8TuT0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aPxUVUoq; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aPxUVUoq" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-499b2981a7bso45240705e9.3 for ; Mon, 07 Sep 2026 22:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845983; x=1789450783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=E0xn/sQ1syzuU4VFJfjc1woEjzltXnI10QEuTRC1ag8=; b=aPxUVUoqrsoMXcgBoItTO2U9EeEn6I7bwayIUsMdkXCXsSLbjN9RqwmRId5rBPBRux 7QMCDsPgp3eeQGvDt9uQdbAHLa1hi9RFxQhRC5D6mZ28XC6fdpTr6TCsMAp/TMBlXaz5 BGPqRepNqeBbMHt4IFH8Ea5EbZLEurpA96ib54YHVvYpEc3iPzqmCuzMMxa1m05mgGU1 lHYbgmaG+6L6PuFoFHx8DC2rGb7Uf49K5qv39oPEB3IEy3WmqggeIhXLSVcctBiGLJps eeQ8aaHRgm+NNKJ9VfKkEVhfKkYvSuVO6LWmhNXUp9yOeTTEUjkV/GyyYSgZdBmy/KF5 DHeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845983; x=1789450783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=E0xn/sQ1syzuU4VFJfjc1woEjzltXnI10QEuTRC1ag8=; b=FzkZUDlHwiN+gt23ZODKVNl5Ee0dwa+IHjXBjYIIRPokSlkZPPxvXDMJirGU67TSeH gXDZaRi+yxo20Jvqn9OvOYi+hmt/NQGHxkh2yzfgdKX5C6nZgj70MTiFn6jC+lwH6vxj ddfWVRFofpMDu5sOsQPyRs1DWX37JqHTI4vXQzuUPE6fOji7GpjXMDEApSm61SqhQcg8 WC6gURnH+5CYTBnoWhHJ8G5Ucg5Mf8gDuf3KaPXAOYohQSwbEfyX6jFG6ARO23+wbQ2b tldm3Nj4VooAOyfVYTV0fp0KITyYJrgZhCsRj7n0ExaVwgAM/VLZS9mYSDfcwXj+Mla3 JnwA== X-Forwarded-Encrypted: i=1; AKwUvByZiuUZTn6g/VA7qDZF+Pa+ba0JMJ1+Bn+w9B3eOl35iJUAFuIbjMHUqnKMaJJ9qU0BeuOyifeiV40H9yI=@vger.kernel.org X-Gm-Message-State: AFuF++nzb7M6gFDqpB00ghU3leJn3KrMMQS4AdDZiKZ1+/p+Ypmx6R2M /hw6QAU1xgHfZqNapSJBx0HnVRYHVylCBA7s421xTQbZPPInDk9elpaH X-Gm-Gg: AYBFou1ng51z66LaeUNSGvVsxxF+ieAgVdi9em7r/+bUz1pCqjw/mUL1l8IzjeA+I7b jsJxkUh60/DLE8ld2QO1XOqajycMfQ0IvwfpOl0TE9byUEh+ZYOuufr3oaTfPA2/LGILwUN+udD IHi/ay7AsPOi1bDo9B9PfqAUhWGo4ZtsSUKGpIC0kNmwvT+WanksgTCZkQFxuVF1QxaHIPlnH27 esudBPg3piDgvVMCHY3dVFHPXEgEZsO7W/jwiEgMr7rdIJyS8AUS5aXWr6+DxHKQdetitX1S3Sr K6dtlLvtj+SOtCigFiENjR6xNCfWXgZdslEONczMiDCv0iffTmRpBVnosFIBl/y+F5suAXF+fJi /oEyuubY2Cvt9qpsjQi4ZpuA63OpD85jv0QlBFRe6y8F/Xv7dM5NqQMrBwHwkOOYJIYlVQSOJr+ tLpOIFstYjHcJKBY6/Gxozoo+TmjexpCCd/w5rhxw2kCdMtZe/onAovBpr8uSlbAca0CfGHVr8B KVf9RTYYMiNU7wL+ySmBqTtLHSPKPpE914iIA/7N+7pHsqgeNnC2JVSOZ5LgAg+B6JZdBliti78 ha6lRM/nb3PVmNB0Gd/VpfxuqgRTKyQ= X-Received: by 2002:a05:600c:3f12:b0:49c:c8de:96a9 with SMTP id 5b1f17b1804b1-49cf7fdd2dfmr526948265e9.2.1788845982788; Mon, 07 Sep 2026 22:39:42 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:42 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 3/6] remoteproc: implement synchronize_cbs() for virtio devices Date: Tue, 8 Sep 2026 07:38:14 +0200 Message-Id: <20260908053817.26065-4-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Platform drivers invoke rproc_vq_interrupt() from hard-IRQ handlers, threaded handlers, and work items. Because rpmsg callbacks may sleep, the virtio core's synchronize_rcu() fallback does not synchronize with callbacks across all these contexts. A device reset can therefore complete while a callback is still running. Add an SRCU domain per rproc. Protect both the queue lookup and vring_interrupt() with it, and synchronize the domain in the new hook. __rproc_virtio_del_vqs() can race with rproc_vq_interrupt() too. Clear all queue pointers and synchronize the SRCU domain before freeing the queues, so callers that already found a queue can finish using it. Read rvring->vq once to avoid a second load after deletion starts. The SRCU domain has the same lifetime as struct rproc. Its cleanup can sleep, so document that rproc_free() and rproc_put() must not drop the last reference from atomic context. Assisted-by: LLM Signed-off-by: Karl Mehltretter --- drivers/remoteproc/remoteproc_core.c | 12 ++++++++ drivers/remoteproc/remoteproc_virtio.c | 37 +++++++++++++++++++++----- include/linux/remoteproc.h | 3 +++ 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remo= teproc_core.c index f003be006b1b..6756f2fe4ec5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -2367,6 +2367,7 @@ static void rproc_type_release(struct device *dev) =20 dev_info(&rproc->dev, "releasing %s\n", rproc->name); =20 + cleanup_srcu_struct(&rproc->vq_srcu); idr_destroy(&rproc->notifyids); =20 if (rproc->index >=3D 0) @@ -2464,6 +2465,11 @@ struct rproc *rproc_alloc(struct device *dev, const = char *name, if (!rproc) return NULL; =20 + if (init_srcu_struct(&rproc->vq_srcu)) { + kfree(rproc); + return NULL; + } + rproc->priv =3D &rproc[1]; rproc->auto_boot =3D true; rproc->elf_class =3D ELFCLASSNONE; @@ -2526,6 +2532,9 @@ EXPORT_SYMBOL(rproc_alloc); * * If no one holds any reference to rproc anymore, then its refcount would * now drop to zero, and it would be freed. + * + * Context: Any context, but the last reference must not be dropped from + * atomic context. */ void rproc_free(struct rproc *rproc) { @@ -2541,6 +2550,9 @@ EXPORT_SYMBOL(rproc_free); * * If no one holds any reference to rproc anymore, then its refcount would * now drop to zero, and it would be freed. + * + * Context: Any context, but the last reference must not be dropped from + * atomic context. */ void rproc_put(struct rproc *rproc) { diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/re= moteproc_virtio.c index d5e9ff045a28..7fefb4bd7adc 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -23,6 +23,7 @@ #include #include #include +#include =20 #include "remoteproc_internal.h" =20 @@ -88,15 +89,23 @@ static bool rproc_virtio_notify(struct virtqueue *vq) */ irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int notifyid) { + irqreturn_t ret =3D IRQ_NONE; struct rproc_vring *rvring; + struct virtqueue *vq; + int idx; =20 dev_dbg(&rproc->dev, "vq index %d is interrupted\n", notifyid); =20 + idx =3D srcu_read_lock(&rproc->vq_srcu); + rvring =3D idr_find(&rproc->notifyids, notifyid); - if (!rvring || !rvring->vq) - return IRQ_NONE; + vq =3D rvring ? READ_ONCE(rvring->vq) : NULL; + if (vq) + ret =3D vring_interrupt(0, vq); =20 - return vring_interrupt(0, rvring->vq); + srcu_read_unlock(&rproc->vq_srcu, idx); + + return ret; } EXPORT_SYMBOL(rproc_vq_interrupt); =20 @@ -153,7 +162,7 @@ static struct virtqueue *rp_find_vq(struct virtio_devic= e *vdev, =20 vq->num_max =3D num; =20 - rvring->vq =3D vq; + WRITE_ONCE(rvring->vq, vq); vq->priv =3D rvring; =20 /* Update vring in resource table */ @@ -165,14 +174,20 @@ static struct virtqueue *rp_find_vq(struct virtio_dev= ice *vdev, =20 static void __rproc_virtio_del_vqs(struct virtio_device *vdev) { + struct rproc *rproc =3D vdev_to_rproc(vdev); struct virtqueue *vq, *n; struct rproc_vring *rvring; =20 - list_for_each_entry_safe(vq, n, &vdev->vqs, list) { + list_for_each_entry(vq, &vdev->vqs, list) { rvring =3D vq->priv; - rvring->vq =3D NULL; - vring_del_virtqueue(vq); + WRITE_ONCE(rvring->vq, NULL); } + + /* Synchronize with rproc_vq_interrupt() callers that found a queue. */ + synchronize_srcu(&rproc->vq_srcu); + + list_for_each_entry_safe(vq, n, &vdev->vqs, list) + vring_del_virtqueue(vq); } =20 static void rproc_virtio_del_vqs(struct virtio_device *vdev) @@ -242,6 +257,13 @@ static void rproc_virtio_reset(struct virtio_device *v= dev) dev_dbg(&vdev->dev, "reset !\n"); } =20 +static void rproc_virtio_synchronize_cbs(struct virtio_device *vdev) +{ + struct rproc *rproc =3D vdev_to_rproc(vdev); + + synchronize_srcu(&rproc->vq_srcu); +} + /* provide the vdev features as retrieved from the firmware */ static u64 rproc_virtio_get_features(struct virtio_device *vdev) { @@ -330,6 +352,7 @@ static const struct virtio_config_ops rproc_virtio_conf= ig_ops =3D { .find_vqs =3D rproc_virtio_find_vqs, .del_vqs =3D rproc_virtio_del_vqs, .reset =3D rproc_virtio_reset, + .synchronize_cbs =3D rproc_virtio_synchronize_cbs, .set_status =3D rproc_virtio_set_status, .get_status =3D rproc_virtio_get_status, .get =3D rproc_virtio_get, diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 7c1546d48008..93a182b1868a 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include =20 @@ -256,6 +257,7 @@ enum rproc_features { * @mappings: list of iommu mappings we initiated, needed on shutdown * @bootaddr: address of first instruction to boot rproc with (optional) * @rvdevs: list of remote virtio devices + * @vq_srcu: SRCU domain for the virtqueue callbacks of @rvdevs * @subdevs: list of subdevices, to following the running state * @notifyids: idr for dynamically assigning rproc-wide unique notify ids * @index: index of this rproc device @@ -298,6 +300,7 @@ struct rproc { struct list_head mappings; u64 bootaddr; struct list_head rvdevs; + struct srcu_struct vq_srcu; struct list_head subdevs; struct idr notifyids; int index; --=20 2.39.5 (Apple Git-154) From nobody Fri Sep 25 22:19:31 2026 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 889D637B01E for ; Tue, 8 Sep 2026 05:39: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=1788845991; cv=none; b=h7sJzN6N5FJ9vasr8ucwfEFTu6ZXHkfI6etsZeaWCBbU1m//hQJhpJLhfqRYKMZcc6tpoBYfJAuMSTZqQZ4hcV46W74hKWRsNYIuh3yhObV3XI6X4y2cK+doYReGUxiETXQQqrg2O++YitJanAGKsLShZtw+o2y+DV9dnq8dFqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845991; c=relaxed/simple; bh=+h/0zeWFw84evQw0JV7uXbRDUk9bZb6gKcvHxLChX5o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LcKtlWnZzi/AkOW3UbjgN5KODQWYXCvg9v32IJribd1jW9ICn4cMkVwUwo2Wn1cApMPnWXkg42xajvdNt0Xgv/VN1U0ZP8DDVOjOltLa/Fqv9ip9L+/bW7NM8kjzXeaQUyCDXjNwngfzCsk027atPf8TZKAUcjbc7pnzZ8UXauw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=sHuwC9Bh; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sHuwC9Bh" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49b0dd3c9a0so40296855e9.1 for ; Mon, 07 Sep 2026 22:39:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845985; x=1789450785; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PyvGIpKH+MV7CFSZeFmHniXCtrADstZbtULW+SJuxFg=; b=sHuwC9Bhp5zJInWrqmBxu6nKmmuz8oCAYfjUDOdy+MzmmMCZ8BHmkemWSq/lpT3/p9 djM+Fl9wI7+/uBR55wakXcithRh+RYU3GLhiQAs/ALwVNRmOrfNZlTOT7830giOknf7n AuJ2oPRDiDHok8eRz2Kob1oyQoaWiOPZJ+8OObXzXpiz14+TaJfJjC8be2dZ1P2QBpF+ V8gHXAlvqTd8RyEQACUeakK5nOOXhw85zHlE1u/0FdKWylSd1Y2JLrTt23fxYTaCqyA6 ua4V5hqMpEUfUe02pFlhWgIiMzAhFmhp+202aXNx5q2OYFXkzBzrts9Z4DO0mEb8Jl92 DmPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845985; x=1789450785; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PyvGIpKH+MV7CFSZeFmHniXCtrADstZbtULW+SJuxFg=; b=mUzKAwfC9TJn03QsQoYGvfHSo51BGMr8gJqOvJJANGw0fRdJzJxIP3zpX2TawTRHni RBNKMikpgyrsIGgy3DV11OqacZ9t5yE1oz4dFXn4pw/t9PxXKtWEOI0WbBliRH+cgAcr oE8qISHcBOxKbnJTdc+g+mPkS6D3Yrbne2aOz9f7btCAKvUJIFXELsy5QAdqa9+TaoK3 ShOVmgGperUOCHeTEXQUvAfabVAp84Gc+xJ1N45p9qs0bAgSz8apwwDzeH7FukkvQtAF ptGUJCKlyfNa+d38o20yNP2snSb8/tBrnzTz5e8OVvrI6nB24hapmWy+7jKU7IYO7957 i8bw== X-Forwarded-Encrypted: i=1; AKwUvBxEjTvH8BbRNRqayr80EBzJzizeGjEFlcrMPk3evM1dUJflJZytgh1WMLxd2iJ0DGv94b8PUfTG6YFtlAA=@vger.kernel.org X-Gm-Message-State: AFuF++m/ORbcqkS32faJ9fSmEgq4w2sioVTYOA8AQZEa4GAfzt9/Dyjm g5+Hp1yOh6o4iDYHbniQq4lYpb4Rn/y3qKEBS0uwa8sNN3fHLIz+ECA1 X-Gm-Gg: AYBFou2gxgJb1CkKO52tE0qHB2xqoqYp39GywmXL90gFnLsBji/Ziwi5+5iTg4DBk7H FVkwGCmEGdHqZvrNqjsUBPXBmB2Exj7qGmIXG8gUuOfPawan9Q93khJhLHH5zsXh0MNAenWvKx8 EmNVW/5SzRk2IACwZsu5YsSi+Ut1WPPwjLOLaEyoVPlUlCqf00lOvKp3xjpm8GTSp8ycitZ/xcu NSkD7UMcA8xEo/Vgxcc01yCqcTTnCLh4FLCKYMxKZR0dUiL/dAtYz8ECE/W4RdFSniz7R8ltMnj UZCS0tuxq9jGsZEiCIrNMb4SozUQBxMucsW8wx42USrT6OlZgNji5aIucEqC9YIdhCLiR1A+ALX 8mUCa59Y7uKV0gQ5qA+dRGoBXeBCcLY88vaxptwXHLN1JK3CmMxFygfR+VlKHxe/nwI3BsfNpYS pgjkV8BlAqCF/oAXXk58UI/NcpuNjpRGC8ojaKo8G+PFl8A7PGz2BN+052sW3TPGXVuFDBpVMri Ccnx2Xe9uQEZRoplF2H7eiQDg9FL3nR5fnbuWko1yi4OC1c4Z1oyPq6dHWPkODnmWX4EUYe6D18 EdBEh9RDyrXFQMWFWiGelgKI830V3vY= X-Received: by 2002:a05:600c:a0a:b0:49c:e1f1:3dd5 with SMTP id 5b1f17b1804b1-49cf81e6cebmr470253545e9.4.1788845984552; Mon, 07 Sep 2026 22:39:44 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:44 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 4/6] um: virtio_uml: implement synchronize_cbs() Date: Tue, 8 Sep 2026 07:38:15 +0200 Message-Id: <20260908053817.26065-5-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_uml invokes virtqueue callbacks from vu_interrupt() and vu_req_interrupt(), which share vu_dev->irq. The core's synchronize_rcu() fallback already covers these IRQ handlers. Implement synchronize_cbs() with synchronize_irq() to synchronize with that IRQ instead of waiting for an RCU grace period. Assisted-by: LLM Signed-off-by: Karl Mehltretter --- arch/um/drivers/virtio_uml.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/um/drivers/virtio_uml.c b/arch/um/drivers/virtio_uml.c index 7425a8548141..1f2e62e29a27 100644 --- a/arch/um/drivers/virtio_uml.c +++ b/arch/um/drivers/virtio_uml.c @@ -20,6 +20,7 @@ * * Based on Virtio MMIO driver by Pawel Moll, copyright 2011-2014, ARM Ltd. */ +#include #include #include #include @@ -869,6 +870,14 @@ static void vu_reset(struct virtio_device *vdev) vu_dev->status =3D 0; } =20 +static void vu_synchronize_cbs(struct virtio_device *vdev) +{ + struct virtio_uml_device *vu_dev =3D to_virtio_uml_device(vdev); + + if (vu_dev->irq !=3D UM_IRQ_ALLOC) + synchronize_irq(vu_dev->irq); +} + static void vu_del_vq(struct virtqueue *vq) { struct virtio_uml_vq_info *info =3D vq->priv; @@ -1121,6 +1130,7 @@ static const struct virtio_config_ops virtio_uml_conf= ig_ops =3D { .reset =3D vu_reset, .find_vqs =3D vu_find_vqs, .del_vqs =3D vu_del_vqs, + .synchronize_cbs =3D vu_synchronize_cbs, .get_features =3D vu_get_features, .finalize_features =3D vu_finalize_features, .bus_name =3D vu_bus_name, --=20 2.39.5 (Apple Git-154) From nobody Fri Sep 25 22:19:31 2026 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 54E0237E2E9 for ; Tue, 8 Sep 2026 05:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845992; cv=none; b=Ny2D84Osuv3B3HF41TeWxnfzl9NcO/mzhWRsmN718QPY95HiZZdb1Kwpm4XdBJdevDIk5oy0Topvse4oCLDfWQOEhXBRgMmsepDk0CvXauZ8I8WRMKADjBgLBw2nR/9v89GhybQ3pc6A7CdQ6YaRzro4x/QWzLoiCpF0MkjGvf8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845992; c=relaxed/simple; bh=+wdB7PxXXtKvNQ35EUFAY1t6ihDReA2lJ+JGlRl8HqU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HAYLegAKrusSNmSukltQ0l6RpXamgnT8GsF88X0FS0eUUjqPQCQf5dV65Ge/Nwi4dD1/SPDovw1aH+C6XFAQXv8Bf5YQ+uD2KpJ+ER94GVS2tJlJVGsbtCsb3NyHMSCJ+DIQ7SpASHJ9Ijlvgm1y2iJzAgih5Dd9ENF3oH8LnYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=dy6jspNb; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dy6jspNb" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-49ccfbe062eso40270735e9.3 for ; Mon, 07 Sep 2026 22:39:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845986; x=1789450786; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=iPvq113vaLkp19diB9PBTYq+aXRuG2muF34cABuckMo=; b=dy6jspNbxGAKGG3lIe/bspSeQ5j6q6O7nVNct+gSf+FKrKUULLHhV4YZxLyD0FyzPP 5hCuizsetB/+39eiGzEi2UYzh/o2UrulEoDzGOEOimzTa7zUE3kIDqj6RdcmykWRNDMs XaxvwNCZTh9iAOBYKGR+e9eCCk+LaMpQuppd9go90pCBSfbYMiQoQp6WFlCvE0ojmTI7 5EfY5SjAJE1+pJlnUwlgKZO9u6lhxwY0Sj1NYKXMko8BRuvXThgKVpdRSQWtILOlovgH 3UbNOCwk19AmEURMWAFD6nRY2x1FC3lAAHVAnNPos6nLvfItW/9fN5KJMKcMPtNn/DCb 4GAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845986; x=1789450786; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=iPvq113vaLkp19diB9PBTYq+aXRuG2muF34cABuckMo=; b=R6qOj2jXBxeRcnLScRgYmiR/0rxhP6oAmz7qGNp4mZ6bt4uhb7YsQ8EyaeaRauyQCX ekVQE5yySLRvsDxY9zkk0z6muakOvp+2U68l6MwCz/FO4KftwcxF5qgRFpZ4zWURi3/a CM8lXQdMt0wYlef1KAqLZPbmRvnGkx0N0mToY9Vjd4wMKI0bwFTueUx1niAjH8h42Aru yVgvS60WdYSWZoStOhHv1PYYJt/mEosmEdUe+6rYoft9gIFgsv3zo4OYaWkG8Y+CC8Tb zUI3x7GSgHuV/hroO8366B93h3ryjdOU9Ag85BjGQnSzoHYEg4N8IvnEJEMdHcav9EDE UTFg== X-Forwarded-Encrypted: i=1; AKwUvBzDFPJLkvDRSxpdJvrDBolgu3vvp+G0/Er5ImCkF2upGrfxixWz1DtfR7gaD9/sBJPIx7SfuG4sQ7XEQYo=@vger.kernel.org X-Gm-Message-State: AFuF++kJCimlZmYALk51CK0VWJa8iKrJX0FiVijt6OmZd9DX4rmTbFr6 xKAfadjZ5A3gEsmCZW80B+qcXGontWIYffpTHyyVcnKZFx8fnMZxZd/w X-Gm-Gg: AYBFou1gapUerBvdhHHn2P38zqLUepYYXv2Pmyg4KcmxicU6iJAb2MT1qaOrNAd+xBy OIOjgI3hUvet9R8H4R393mNxJgsriS6NptZCOhOu30yHapAkLZcX8FmyaB1HW4tyupCdkHs7DRK Ql79j3IZJhvStMDMfxNTJsxAgWBy8uDV7E2kr1pUtKFRMiNsHmRJisCsedsNsof+cozbaNwDfBt tgoNG7QxcG65mgVlMFhK6u+XJp0TKYaNU7sdXckwzv8opY7kTdyE+HGQzTyjChr+7nxwLp6B03x 9roPzOUF9/5Uv0B8wJOz4Ouo6GI7Con7xrU4NeXxorxniajqTqfltXNa3QC+ZHf6JO8iOHWBfX+ oowMptWHHgNYt8aqZsfs+t2aZhZTRoOme84TZJrvdJX1zpgrm4dp9f0yyFjr85356Y1H7n88jyu XsNoR+UYPQMDZcQZyHBuouOo2tIpsHSrnLeadptMeBDnAfav4oc8cJnH1t+35Z1irNH1tLIt8h5 I//nyj9U4BEWgXf4xPPjLHyExgMWFERUAZpz03ZREccwD0q3jwB2mLvQw3Ubz18jlxDxYDyCcm4 +ECxb+H/FOAkyf8cn5VgRmigi6eN4iV2HNX688n9+OI= X-Received: by 2002:a05:600c:620b:b0:49c:fa20:cc07 with SMTP id 5b1f17b1804b1-49cff19cbf4mr203278645e9.30.1788845986284; Mon, 07 Sep 2026 22:39:46 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:45 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 5/6] platform/mellanox: mlxbf-tmfifo: implement synchronize_cbs() Date: Tue, 8 Sep 2026 07:38:16 +0200 Message-Id: <20260908053817.26065-6-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" TmFIFO invokes virtqueue callbacks from its FIFO work item under spin_lock_irqsave(). The core's synchronize_rcu() fallback already covers those sections. Implement synchronize_cbs() using the existing per-direction locks instead of waiting for an RCU grace period. fifo->spin_lock[0] covers the transmit callbacks, including the callback from the timeout handler. fifo->spin_lock[1] covers the receive callbacks. Take and release each lock in turn to synchronize with callbacks running under that lock. Assisted-by: LLM Signed-off-by: Karl Mehltretter --- drivers/platform/mellanox/mlxbf-tmfifo.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/me= llanox/mlxbf-tmfifo.c index 3c6408581373..664bec20a7ae 100644 --- a/drivers/platform/mellanox/mlxbf-tmfifo.c +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c @@ -1135,6 +1135,20 @@ static void mlxbf_tmfifo_virtio_reset(struct virtio_= device *vdev) tm_vdev->status =3D 0; } =20 +/* Synchronize with callbacks running in the FIFO work item. */ +static void mlxbf_tmfifo_virtio_synchronize_cbs(struct virtio_device *vdev) +{ + struct mlxbf_tmfifo_vdev *tm_vdev =3D mlxbf_vdev_to_tmfifo(vdev); + struct mlxbf_tmfifo *fifo =3D tm_vdev->vrings[0].fifo; + unsigned long flags; + int i; + + for (i =3D 0; i < ARRAY_SIZE(fifo->spin_lock); i++) { + spin_lock_irqsave(&fifo->spin_lock[i], flags); + spin_unlock_irqrestore(&fifo->spin_lock[i], flags); + } +} + /* Read the value of a configuration field. */ static void mlxbf_tmfifo_virtio_get(struct virtio_device *vdev, unsigned int offset, @@ -1179,6 +1193,7 @@ static const struct virtio_config_ops mlxbf_tmfifo_vi= rtio_config_ops =3D { .find_vqs =3D mlxbf_tmfifo_virtio_find_vqs, .del_vqs =3D mlxbf_tmfifo_virtio_del_vqs, .reset =3D mlxbf_tmfifo_virtio_reset, + .synchronize_cbs =3D mlxbf_tmfifo_virtio_synchronize_cbs, .set_status =3D mlxbf_tmfifo_virtio_set_status, .get_status =3D mlxbf_tmfifo_virtio_get_status, .get =3D mlxbf_tmfifo_virtio_get, --=20 2.39.5 (Apple Git-154) From nobody Fri Sep 25 22:19:31 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 E176E38228A for ; Tue, 8 Sep 2026 05:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845994; cv=none; b=oZHfU4nj9wjwWOuj4MwQigYpIBwcfx1Ejp1LfL90xtVmSvEKSB4tRcTNx2JiyygnAVLiM1dyXu/GKNE4BYFbQiTJdmneEGC0A+IXXKXkblO2QOtUb1j7TgMSjslIWJulR4iGhxjvbMiQaIQ48to8gVCL2lpOoMfy1iyfC7IXcsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788845994; c=relaxed/simple; bh=Z1mqy3qNtdRxgKwEWqMkljOG1k4ekHUKiS2/6Ca17Yo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZJyOx2OwQTsHHrQ+7X8hICTOcyseKhsmbYbsDsWk9Cb6Q5X7GaAOtwV+0XviX8taKc/S2UKHaBgoTSiT/2phMGEodTkv64+HLPsYyiUxoYawdqBTpznvehVZj0yJHxSKbZSGTQ6R/FqOP2YEJNpxYRM93c2/lUYuzDhmFLvHa+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UmjpCI8s; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UmjpCI8s" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-49a97714f5dso40940885e9.0 for ; Mon, 07 Sep 2026 22:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788845988; x=1789450788; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=l0UrpxibHZnDBNXE1bN5qrJqc7sTw2Bd+aGpZLtd0Ug=; b=UmjpCI8s7t3E+4yRhKMceIDOKBrqYNOKBZjVaryoL+Wx8/5meM4sQ9XpZurZfH3zlS fm9dPFfnx8NWhVMpEnO10cGpwzMYuIbKyGY2YuHQfXYqFDhg6uepkDSAbaDSU9HEDtlu MwjTnuF26Niwb9CNviqGtmx4WwjStW+BJ1nPjnxMHE5c1ZoVPpi7WYhT0dm2ReieAxbi CEV1OpQOMg3cbWpcFghWbSrBG5sOmvQMxBpbpHBVK0haUEZzsGRlCb+OqTdIr9oBGio4 6sDz2wkoyVcw+4UAETBV79kQRFAvgWv6+QUPewowi4qDn3CuhbBW78rMGb81BCHJCwo1 IlvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788845988; x=1789450788; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=l0UrpxibHZnDBNXE1bN5qrJqc7sTw2Bd+aGpZLtd0Ug=; b=K/WphE//F23Yclri9DJhsugxrgX4L1mqJsbBko781g61O6XUsbaAUaOjxYvTZLijJ4 8kIHJ+OYywpov08Uo105SPy/sB7KQQSzRKSHKq9L6pUxdyNoICaZ5MV/hZRvMANDeOsd j70Uno5mBj9FZYlm1p32qXflcgp1Ame9qTYcH3uh//OsuIUfcXoa5ax1nO7p7iC5I41B UgXTCwFfAyu9s8asj/ThxTFtxtguZET1ifeG5FIGNGezZK2SsEHQmtDovr5x0XqaZUEF gK37opSjdaSfWsQzPrf61xO6N1WSdwN307NG/lJJ0Pacb8hPR6YkSzd4HT6Q5opUNhy9 SZPA== X-Forwarded-Encrypted: i=1; AKwUvBxawTTtpIpepoDuB3tZ9L0EiKIl6ddWIST2SKo23dX1Hk4QX0hbg5UnkOSLlJRMVQloS+LcgNfAYoEoSCY=@vger.kernel.org X-Gm-Message-State: AFuF++kblaObPoOEcXQDYk2jf2EoSyefa36D8PcR5Lz76QaeRDfT/5PX qCZKFIFw0Nw3l6r71r/HdP4MYFjaIxNjt4pr+FlX/TNbe0tejbprWzpY X-Gm-Gg: AYBFou04YeiFJm6RUFYslHJLEW6NFzl1L3nVlTv8oM1u23HLrdVt4XU8hbboee1rnyF YLXTQMECATAGTvrwzPnbpjZ2s7xrr3YSEECgmgh0Iw3vWBnSxBvc43aeJ6wticG6amq2UsLYqSZ iaTa0zb12OT0eYzplSxYVw7gR+Tkb6Bg+WE6mXxVBA/u88cM42+We2JbAQFdMMbZexeCgFSIB4q Hf6+2E8JkvIjA3ZJ8yg+3/CmdHupcTBzu3BpiqHuhscBQRtoYBehv3OoO2pqmnwnPQu51S0W69Y 74z4EvkOfUR1oOtOhIv0vmqsYBzNFHCL82FIk2OXu+qbNOHPr1gFC4OuDHQqQQVBYr1Ry2zQpkS jRGCLW5yO4jsj51zWRaXn0VEX4SjchhFRIfkaec5OFb8NhuvxQiB4rTy2o4aRwff4jiPrH5Zvc7 83aEDUu/xAv1TFCVr0b5+7esfti+1loZgalUJtneVexj7/Y2/t0gFJFxHGGLvq/OxhMHgiJYX7B YnJDeYLrKFlj4DnfHIDcWZeUI8RIShIEiDtrNjn2s0MXRozcpHRQDyDU91czpYowkjsnYHzDXNk 9MHpyFRq2Hv2Jw/UofsoFW5aBLDiFD0= X-Received: by 2002:a05:600c:3587:b0:49d:17d8:abec with SMTP id 5b1f17b1804b1-49d17d8abf5mr31972855e9.21.1788845987998; Mon, 07 Sep 2026 22:39:47 -0700 (PDT) Received: from localhost.localdomain (dynamic-095-117-170-066.95.117.pool.telefonica.de. [95.117.170.66]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49cee7fec25sm523841335e9.13.2026.09.07.22.39.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 07 Sep 2026 22:39:47 -0700 (PDT) From: Karl Mehltretter To: "Michael S. Tsirkin" , Jason Wang , Gerd Hoffmann Cc: Karl Mehltretter , Xuan Zhuo , =?UTF-8?q?Eugenio=20P=C3=A9rez?= , Dmitry Torokhov , Rusty Russell , Pawel Moll , Cornelia Huck , Halil Pasic , Eric Farman , Richard Weinberger , Anton Ivanov , Johannes Berg , Hans de Goede , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , virtualization@lists.linux.dev, linux-input@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, linux-um@lists.infradead.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle Subject: [PATCH v3 6/6] virtio_vdpa: implement synchronize_cbs() Date: Tue, 8 Sep 2026 07:38:17 +0200 Message-Id: <20260908053817.26065-7-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) In-Reply-To: <20260908053817.26065-1-kmehltretter@gmail.com> References: <20260908053817.26065-1-kmehltretter@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" virtio_vdpa relies on the core's synchronize_rcu() fallback for callback synchronization. That covers IRQ handlers and sections with interrupts, preemption or bottom halves disabled. virtio_vdpa does not enforce any of those contexts when a vDPA driver invokes a callback. Add an SRCU domain per device and enter it around the virtqueue and config callbacks. Implement synchronize_cbs() with synchronize_srcu() so it covers the callbacks regardless of the calling context. SRCU uses per-CPU reader accounting, avoiding a single callback lock shared by all queues. Cover the config callback too, as virtio-pci does for its config vector. Assisted-by: LLM Signed-off-by: Karl Mehltretter --- drivers/virtio/virtio_vdpa.c | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/drivers/virtio/virtio_vdpa.c b/drivers/virtio/virtio_vdpa.c index 6bcf4567a929..f9559b6b2e0b 100644 --- a/drivers/virtio/virtio_vdpa.c +++ b/drivers/virtio/virtio_vdpa.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ struct virtio_vdpa_device { struct virtio_device vdev; struct vdpa_device *vdpa; + struct srcu_struct cb_srcu; u64 features; }; =20 @@ -114,8 +116,11 @@ static bool virtio_vdpa_notify_with_data(struct virtqu= eue *vq) static irqreturn_t virtio_vdpa_config_cb(void *private) { struct virtio_vdpa_device *vd_dev =3D private; + int idx; =20 + idx =3D srcu_read_lock(&vd_dev->cb_srcu); virtio_config_changed(&vd_dev->vdev); + srcu_read_unlock(&vd_dev->cb_srcu, idx); =20 return IRQ_HANDLED; } @@ -123,8 +128,22 @@ static irqreturn_t virtio_vdpa_config_cb(void *private) static irqreturn_t virtio_vdpa_virtqueue_cb(void *private) { struct virtqueue *vq =3D private; + struct virtio_vdpa_device *vd_dev =3D to_virtio_vdpa_device(vq->vdev); + irqreturn_t ret; + int idx; + + idx =3D srcu_read_lock(&vd_dev->cb_srcu); + ret =3D vring_interrupt(0, vq); + srcu_read_unlock(&vd_dev->cb_srcu, idx); + + return ret; +} + +static void virtio_vdpa_synchronize_cbs(struct virtio_device *vdev) +{ + struct virtio_vdpa_device *vd_dev =3D to_virtio_vdpa_device(vdev); =20 - return vring_interrupt(0, vq); + synchronize_srcu(&vd_dev->cb_srcu); } =20 static struct virtqueue * @@ -440,6 +459,7 @@ static const struct virtio_config_ops virtio_vdpa_confi= g_ops =3D { .reset =3D virtio_vdpa_reset, .find_vqs =3D virtio_vdpa_find_vqs, .del_vqs =3D virtio_vdpa_del_vqs, + .synchronize_cbs =3D virtio_vdpa_synchronize_cbs, .get_features =3D virtio_vdpa_get_features, .finalize_features =3D virtio_vdpa_finalize_features, .bus_name =3D virtio_vdpa_bus_name, @@ -454,6 +474,7 @@ static void virtio_vdpa_release_dev(struct device *_d) struct virtio_vdpa_device *vd_dev =3D container_of(vdev, struct virtio_vdpa_device, vdev); =20 + cleanup_srcu_struct(&vd_dev->cb_srcu); kfree(vd_dev); } =20 @@ -467,6 +488,11 @@ static int virtio_vdpa_probe(struct vdpa_device *vdpa) if (!vd_dev) return -ENOMEM; =20 + if (init_srcu_struct(&vd_dev->cb_srcu)) { + kfree(vd_dev); + return -ENOMEM; + } + vd_dev->vdev.dev.parent =3D vdpa->map ? &vdpa->dev : vdpa_get_map(vdpa).dma_dev; vd_dev->vdev.dev.release =3D virtio_vdpa_release_dev; @@ -489,10 +515,12 @@ static int virtio_vdpa_probe(struct vdpa_device *vdpa) return 0; =20 err: - if (reg_dev) + if (reg_dev) { put_device(&vd_dev->vdev.dev); - else + } else { + cleanup_srcu_struct(&vd_dev->cb_srcu); kfree(vd_dev); + } return ret; } =20 --=20 2.39.5 (Apple Git-154)