All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Farman <farman@linux.ibm.com>
To: Joshua Daley <jdaley@linux.ibm.com>, linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux.dev,
	mst@redhat.com, jasowang@redhat.com, pbonzini@redhat.com,
	stefanha@redhat.com, eperezma@redhat.com,
	James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com, mjrosato@linux.ibm.com,
	frankja@linux.ibm.com
Subject: Re: [PATCH 1/1] scsi: virtio_scsi: move INIT_WORK calls to virtscsi_init
Date: Tue, 03 Mar 2026 16:45:20 -0500	[thread overview]
Message-ID: <77b2b44d7101d55151c8e9852ce41783205ed987.camel@linux.ibm.com> (raw)
In-Reply-To: <20260226204345.1904786-2-jdaley@linux.ibm.com>

On Thu, 2026-02-26 at 21:43 +0100, Joshua Daley wrote:
> The last step of virtscsi_handle_event is to call virtscsi_kick_event,
> which calls INIT_WORK on it's own work item. INIT_WORK resets the
> work item's data bits to 0.
> 
> If this occurs while the work item is being flushed by
> cancel_work_sync, then kernel/workqueue.c/work_offqd_enable triggers a
> kernel warning, as it expects the "disable" bit to be 1:
> 
> [   21.450115] workqueue: work disable count underflowed
> [   21.450117] WARNING: CPU: 1 PID: 56 at kernel/workqueue.c:4328 enable_work+0x10a/0x120
> ...
> [   21.450171] Call Trace:
> [   21.450173]  [<000003db2e5bdc3e>] enable_work+0x10e/0x120
> [   21.450176] ([<000003db2e5bdc3a>] enable_work+0x10a/0x120)
> [   21.450178]  [<000003db2e5bdd86>] cancel_work_sync+0x86/0xa0
> [   21.450181]  [<000003daae97d9e4>] virtscsi_remove+0xb4/0xd0 [virtio_scsi]
> [   21.450184]  [<000003db2ef3b5ca>] virtio_dev_remove+0x6a/0xd0
> [   21.450186]  [<000003db2ef9106c>] device_release_driver_internal+0x1ac/0x260
> [   21.450190]  [<000003db2ef8edc8>] bus_remove_device+0xf8/0x190
> [   21.450192]  [<000003db2ef88d72>] device_del+0x142/0x340
> [   21.450194]  [<000003db2ef88fa0>] device_unregister+0x30/0xa0
> [   21.450196]  [<000003db2ef3b2fa>] unregister_virtio_device+0x2a/0x40
> 
> This warning may occur if a controller is detached immediately
> following a disk detach.
> 
> Move the INIT_WORK call to prevent this. Don't re-init event list
> work items in virtscsi_kick_event, init them only once in
> virtscsi_init instead.
> 
> Signed-off-by: Joshua Daley <jdaley@linux.ibm.com>

The fact that the INIT_WORK points to virtscsi_handle_event(), which itself calls
virtscsi_kick_event() and re-inits the workqueue struct today, does seem odd. Moving this to _init,
as part of the _probe() process, seems correct to me. One nit below, but FWIW:

Reviewed-by: Eric Farman <farman@linux.ibm.com>
Tested-by: Eric Farman <farman@linux.ibm.com>

> ---
>  drivers/scsi/virtio_scsi.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
> index 0ed8558dad72..173092931df6 100644
> --- a/drivers/scsi/virtio_scsi.c
> +++ b/drivers/scsi/virtio_scsi.c
> @@ -242,7 +242,6 @@ static int virtscsi_kick_event(struct virtio_scsi *vscsi,

Just before this hunk is a prototype for virtscsi_handle_event(), since it was previously used in
this function but defined afterwards. I suspect it can be removed now?

>  	struct scatterlist sg;
>  	unsigned long flags;
>  
> -	INIT_WORK(&event_node->work, virtscsi_handle_event);
>  	sg_init_one(&sg, event_node->event, sizeof(struct virtio_scsi_event));
>  
>  	spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
> @@ -898,6 +897,11 @@ static int virtscsi_init(struct virtio_device *vdev,
>  	virtscsi_config_set(vdev, cdb_size, VIRTIO_SCSI_CDB_SIZE);
>  	virtscsi_config_set(vdev, sense_size, VIRTIO_SCSI_SENSE_SIZE);
>  
> +	if (virtio_has_feature(vdev, VIRTIO_SCSI_F_HOTPLUG)) {
> +		for (i = 0; i < VIRTIO_SCSI_EVENT_LEN; i++)
> +			INIT_WORK(&vscsi->event_list[i].work, virtscsi_handle_event);
> +	}
> +
>  	err = 0;
>  
>  out:

  reply	other threads:[~2026-03-03 21:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-26 20:43 [PATCH 0/1] scsi: virtio_scsi: move INIT_WORK calls to virtscsi_init Joshua Daley
2026-02-26 20:43 ` [PATCH 1/1] " Joshua Daley
2026-03-03 21:45   ` Eric Farman [this message]
2026-03-04 18:14     ` Joshua Daley
2026-03-09  3:06   ` Stefan Hajnoczi
2026-03-09 21:03     ` Joshua Daley
2026-03-09 23:07       ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=77b2b44d7101d55151c8e9852ce41783205ed987.camel@linux.ibm.com \
    --to=farman@linux.ibm.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=eperezma@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=jasowang@redhat.com \
    --cc=jdaley@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=virtualization@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.