aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/scsi/virtio_scsi.c31
-rw-r--r--include/linux/virtio_scsi.h2
2 files changed, 32 insertions, 1 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index a7cf726bc747..595af1ae4421 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -279,6 +279,31 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
279 } 279 }
280} 280}
281 281
282static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
283 struct virtio_scsi_event *event)
284{
285 struct scsi_device *sdev;
286 struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
287 unsigned int target = event->lun[1];
288 unsigned int lun = (event->lun[2] << 8) | event->lun[3];
289 u8 asc = event->reason & 255;
290 u8 ascq = event->reason >> 8;
291
292 sdev = scsi_device_lookup(shost, 0, target, lun);
293 if (!sdev) {
294 pr_err("SCSI device %d 0 %d %d not found\n",
295 shost->host_no, target, lun);
296 return;
297 }
298
299 /* Handle "Parameters changed", "Mode parameters changed", and
300 "Capacity data has changed". */
301 if (asc == 0x2a && (ascq == 0x00 || ascq == 0x01 || ascq == 0x09))
302 scsi_rescan_device(&sdev->sdev_gendev);
303
304 scsi_device_put(sdev);
305}
306
282static void virtscsi_handle_event(struct work_struct *work) 307static void virtscsi_handle_event(struct work_struct *work)
283{ 308{
284 struct virtio_scsi_event_node *event_node = 309 struct virtio_scsi_event_node *event_node =
@@ -297,6 +322,9 @@ static void virtscsi_handle_event(struct work_struct *work)
297 case VIRTIO_SCSI_T_TRANSPORT_RESET: 322 case VIRTIO_SCSI_T_TRANSPORT_RESET:
298 virtscsi_handle_transport_reset(vscsi, event); 323 virtscsi_handle_transport_reset(vscsi, event);
299 break; 324 break;
325 case VIRTIO_SCSI_T_PARAM_CHANGE:
326 virtscsi_handle_param_change(vscsi, event);
327 break;
300 default: 328 default:
301 pr_err("Unsupport virtio scsi event %x\n", event->event); 329 pr_err("Unsupport virtio scsi event %x\n", event->event);
302 } 330 }
@@ -737,7 +765,8 @@ static struct virtio_device_id id_table[] = {
737}; 765};
738 766
739static unsigned int features[] = { 767static unsigned int features[] = {
740 VIRTIO_SCSI_F_HOTPLUG 768 VIRTIO_SCSI_F_HOTPLUG,
769 VIRTIO_SCSI_F_CHANGE,
741}; 770};
742 771
743static struct virtio_driver virtio_scsi_driver = { 772static struct virtio_driver virtio_scsi_driver = {
diff --git a/include/linux/virtio_scsi.h b/include/linux/virtio_scsi.h
index dc8d305b0e05..d6b4440387b7 100644
--- a/include/linux/virtio_scsi.h
+++ b/include/linux/virtio_scsi.h
@@ -72,6 +72,7 @@ struct virtio_scsi_config {
72/* Feature Bits */ 72/* Feature Bits */
73#define VIRTIO_SCSI_F_INOUT 0 73#define VIRTIO_SCSI_F_INOUT 0
74#define VIRTIO_SCSI_F_HOTPLUG 1 74#define VIRTIO_SCSI_F_HOTPLUG 1
75#define VIRTIO_SCSI_F_CHANGE 2
75 76
76/* Response codes */ 77/* Response codes */
77#define VIRTIO_SCSI_S_OK 0 78#define VIRTIO_SCSI_S_OK 0
@@ -108,6 +109,7 @@ struct virtio_scsi_config {
108#define VIRTIO_SCSI_T_NO_EVENT 0 109#define VIRTIO_SCSI_T_NO_EVENT 0
109#define VIRTIO_SCSI_T_TRANSPORT_RESET 1 110#define VIRTIO_SCSI_T_TRANSPORT_RESET 1
110#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2 111#define VIRTIO_SCSI_T_ASYNC_NOTIFY 2
112#define VIRTIO_SCSI_T_PARAM_CHANGE 3
111 113
112/* Reasons of transport reset event */ 114/* Reasons of transport reset event */
113#define VIRTIO_SCSI_EVT_RESET_HARD 0 115#define VIRTIO_SCSI_EVT_RESET_HARD 0