Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 334140
b: refs/heads/master
c: 865b58c
h: refs/heads/master
v: v3
  • Loading branch information
Paolo Bonzini authored and James Bottomley committed Oct 9, 2012
1 parent 61210a8 commit 8317850
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 9da5f5ac6affad8dd8cd80f5cca26e4335e1728b
refs/heads/master: 865b58c05b841964f48f574c2027311bd04db8a1
31 changes: 30 additions & 1 deletion trunk/drivers/scsi/virtio_scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,31 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
}
}

static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
struct virtio_scsi_event *event)
{
struct scsi_device *sdev;
struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
unsigned int target = event->lun[1];
unsigned int lun = (event->lun[2] << 8) | event->lun[3];
u8 asc = event->reason & 255;
u8 ascq = event->reason >> 8;

sdev = scsi_device_lookup(shost, 0, target, lun);
if (!sdev) {
pr_err("SCSI device %d 0 %d %d not found\n",
shost->host_no, target, lun);
return;
}

/* Handle "Parameters changed", "Mode parameters changed", and
"Capacity data has changed". */
if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09))
scsi_rescan_device(&sdev->sdev_gendev);

scsi_device_put(sdev);
}

static void virtscsi_handle_event(struct work_struct *work)
{
struct virtio_scsi_event_node *event_node =
Expand All @@ -297,6 +322,9 @@ static void virtscsi_handle_event(struct work_struct *work)
case VIRTIO_SCSI_T_TRANSPORT_RESET:
virtscsi_handle_transport_reset(vscsi, event);
break;
case VIRTIO_SCSI_T_PARAM_CHANGE:
virtscsi_handle_param_change(vscsi, event);
break;
default:
pr_err("Unsupport virtio scsi event %x\n", event->event);
}
Expand Down Expand Up @@ -737,7 +765,8 @@ static struct virtio_device_id id_table[] = {
};

static unsigned int features[] = {
VIRTIO_SCSI_F_HOTPLUG
VIRTIO_SCSI_F_HOTPLUG,
VIRTIO_SCSI_F_CHANGE,
};

static struct virtio_driver virtio_scsi_driver = {
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/virtio_scsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct virtio_scsi_config {
/* Feature Bits */
#define VIRTIO_SCSI_F_INOUT 0
#define VIRTIO_SCSI_F_HOTPLUG 1
#define VIRTIO_SCSI_F_CHANGE 2

/* Response codes */
#define VIRTIO_SCSI_S_OK 0
Expand Down Expand Up @@ -108,6 +109,7 @@ struct virtio_scsi_config {
#define VIRTIO_SCSI_T_NO_EVENT 0
#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
#define VIRTIO_SCSI_T_PARAM_CHANGE 3

/* Reasons of transport reset event */
#define VIRTIO_SCSI_EVT_RESET_HARD 0
Expand Down

0 comments on commit 8317850

Please sign in to comment.