aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/virtio_scsi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/virtio_scsi.c')
-rw-r--r--drivers/scsi/virtio_scsi.c39
1 files changed, 36 insertions, 3 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 3e79a2f00042..595af1ae4421 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -219,7 +219,7 @@ static int virtscsi_kick_event(struct virtio_scsi *vscsi,
219 struct scatterlist sg; 219 struct scatterlist sg;
220 unsigned long flags; 220 unsigned long flags;
221 221
222 sg_set_buf(&sg, &event_node->event, sizeof(struct virtio_scsi_event)); 222 sg_init_one(&sg, &event_node->event, sizeof(struct virtio_scsi_event));
223 223
224 spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags); 224 spin_lock_irqsave(&vscsi->event_vq.vq_lock, flags);
225 225
@@ -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 }
@@ -677,7 +705,11 @@ static int __devinit virtscsi_probe(struct virtio_device *vdev)
677 cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1; 705 cmd_per_lun = virtscsi_config_get(vdev, cmd_per_lun) ?: 1;
678 shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue); 706 shost->cmd_per_lun = min_t(u32, cmd_per_lun, shost->can_queue);
679 shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF; 707 shost->max_sectors = virtscsi_config_get(vdev, max_sectors) ?: 0xFFFF;
680 shost->max_lun = virtscsi_config_get(vdev, max_lun) + 1; 708
709 /* LUNs > 256 are reported with format 1, so they go in the range
710 * 16640-32767.
711 */
712 shost->max_lun = virtscsi_config_get(vdev, max_lun) + 1 + 0x4000;
681 shost->max_id = num_targets; 713 shost->max_id = num_targets;
682 shost->max_channel = 0; 714 shost->max_channel = 0;
683 shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE; 715 shost->max_cmd_len = VIRTIO_SCSI_CDB_SIZE;
@@ -733,7 +765,8 @@ static struct virtio_device_id id_table[] = {
733}; 765};
734 766
735static unsigned int features[] = { 767static unsigned int features[] = {
736 VIRTIO_SCSI_F_HOTPLUG 768 VIRTIO_SCSI_F_HOTPLUG,
769 VIRTIO_SCSI_F_CHANGE,
737}; 770};
738 771
739static struct virtio_driver virtio_scsi_driver = { 772static struct virtio_driver virtio_scsi_driver = {