qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/6] hw/scsi/virtio-scsi: Use RCU_READ macro


From: Manos Pitsidianakis
Subject: Re: [PATCH 4/6] hw/scsi/virtio-scsi: Use RCU_READ macro
Date: Wed, 24 Jan 2024 11:17:07 +0200
User-agent: meli 0.8.5-rc.3

On Wed, 24 Jan 2024 09:41, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
Replace the manual rcu_read_(un)lock calls by the
WITH_RCU_READ_LOCK_GUARD macro (See commit ef46ae67ba
"docs/style: call out the use of GUARD macros").

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/scsi/virtio-scsi.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c
index 690aceec45..998227404a 100644
--- a/hw/scsi/virtio-scsi.c
+++ b/hw/scsi/virtio-scsi.c
@@ -343,14 +343,14 @@ static void virtio_scsi_do_one_tmf_bh(VirtIOSCSIReq *req)
        target = req->req.tmf.lun[1];
        qatomic_inc(&s->resetting);

-        rcu_read_lock();
-        QTAILQ_FOREACH_RCU(kid, &s->bus.qbus.children, sibling) {
-            SCSIDevice *d1 = SCSI_DEVICE(kid->child);
-            if (d1->channel == 0 && d1->id == target) {
-                device_cold_reset(&d1->qdev);
+        WITH_RCU_READ_LOCK_GUARD() {
+            QTAILQ_FOREACH_RCU(kid, &s->bus.qbus.children, sibling) {
+                SCSIDevice *d1 = SCSI_DEVICE(kid->child);
+                if (d1->channel == 0 && d1->id == target) {
+                    device_cold_reset(&d1->qdev);
+                }
            }
        }
-        rcu_read_unlock();

        qatomic_dec(&s->resetting);
        break;
--
2.41.0


Unrelated to your patch: I just noticed in hw/scsi/virtio-scsi.c, s->resetting is used to flag whether the bus is resetting; but there's no check if a resetting is taking place before starting another. Is this single threaded code so it's not necessary?

As for the patch:

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]