aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 15:20:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2014-12-11 15:20:31 -0500
commit6b9e2cea428cf7af93a84bcb865e478d8bf1c165 (patch)
tree11be387e37129fce0c4c111803df1a2e56637b60 /drivers/scsi
parent14ba9a2e4bacc6f5a0dbe0de5390daedd544508f (diff)
parentf01a2a811ae04124fc9382925038fcbbd2f0b7c8 (diff)
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin: "virtio: virtio 1.0 support, misc patches This adds a lot of infrastructure for virtio 1.0 support. Notable missing pieces: virtio pci, virtio balloon (needs spec extension), vhost scsi. Plus, there are some minor fixes in a couple of places. Note: some net drivers are affected by these patches. David said he's fine with merging these patches through my tree. Rusty's on vacation, he acked using my tree for these, too" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (70 commits) virtio_ccw: finalize_features error handling virtio_ccw: future-proof finalize_features virtio_pci: rename virtio_pci -> virtio_pci_common virtio_pci: update file descriptions and copyright virtio_pci: split out legacy device support virtio_pci: setup config vector indirectly virtio_pci: setup vqs indirectly virtio_pci: delete vqs indirectly virtio_pci: use priv for vq notification virtio_pci: free up vq->priv virtio_pci: fix coding style for structs virtio_pci: add isr field virtio: drop legacy_only driver flag virtio_balloon: drop legacy_only driver flag virtio_ccw: rev 1 devices set VIRTIO_F_VERSION_1 virtio: allow finalize_features to fail virtio_ccw: legacy: don't negotiate rev 1/features virtio: add API to detect legacy devices virtio_console: fix sparse warnings vhost: remove unnecessary forward declarations in vhost.h ...
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/virtio_scsi.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 22e70126425b..c52bb5dfaedb 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -158,7 +158,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
158 sc, resp->response, resp->status, resp->sense_len); 158 sc, resp->response, resp->status, resp->sense_len);
159 159
160 sc->result = resp->status; 160 sc->result = resp->status;
161 virtscsi_compute_resid(sc, resp->resid); 161 virtscsi_compute_resid(sc, virtio32_to_cpu(vscsi->vdev, resp->resid));
162 switch (resp->response) { 162 switch (resp->response) {
163 case VIRTIO_SCSI_S_OK: 163 case VIRTIO_SCSI_S_OK:
164 set_host_byte(sc, DID_OK); 164 set_host_byte(sc, DID_OK);
@@ -196,10 +196,13 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
196 break; 196 break;
197 } 197 }
198 198
199 WARN_ON(resp->sense_len > VIRTIO_SCSI_SENSE_SIZE); 199 WARN_ON(virtio32_to_cpu(vscsi->vdev, resp->sense_len) >
200 VIRTIO_SCSI_SENSE_SIZE);
200 if (sc->sense_buffer) { 201 if (sc->sense_buffer) {
201 memcpy(sc->sense_buffer, resp->sense, 202 memcpy(sc->sense_buffer, resp->sense,
202 min_t(u32, resp->sense_len, VIRTIO_SCSI_SENSE_SIZE)); 203 min_t(u32,
204 virtio32_to_cpu(vscsi->vdev, resp->sense_len),
205 VIRTIO_SCSI_SENSE_SIZE));
203 if (resp->sense_len) 206 if (resp->sense_len)
204 set_driver_byte(sc, DRIVER_SENSE); 207 set_driver_byte(sc, DRIVER_SENSE);
205 } 208 }
@@ -323,7 +326,7 @@ static void virtscsi_handle_transport_reset(struct virtio_scsi *vscsi,
323 unsigned int target = event->lun[1]; 326 unsigned int target = event->lun[1];
324 unsigned int lun = (event->lun[2] << 8) | event->lun[3]; 327 unsigned int lun = (event->lun[2] << 8) | event->lun[3];
325 328
326 switch (event->reason) { 329 switch (virtio32_to_cpu(vscsi->vdev, event->reason)) {
327 case VIRTIO_SCSI_EVT_RESET_RESCAN: 330 case VIRTIO_SCSI_EVT_RESET_RESCAN:
328 scsi_add_device(shost, 0, target, lun); 331 scsi_add_device(shost, 0, target, lun);
329 break; 332 break;
@@ -349,8 +352,8 @@ static void virtscsi_handle_param_change(struct virtio_scsi *vscsi,
349 struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev); 352 struct Scsi_Host *shost = virtio_scsi_host(vscsi->vdev);
350 unsigned int target = event->lun[1]; 353 unsigned int target = event->lun[1];
351 unsigned int lun = (event->lun[2] << 8) | event->lun[3]; 354 unsigned int lun = (event->lun[2] << 8) | event->lun[3];
352 u8 asc = event->reason & 255; 355 u8 asc = virtio32_to_cpu(vscsi->vdev, event->reason) & 255;
353 u8 ascq = event->reason >> 8; 356 u8 ascq = virtio32_to_cpu(vscsi->vdev, event->reason) >> 8;
354 357
355 sdev = scsi_device_lookup(shost, 0, target, lun); 358 sdev = scsi_device_lookup(shost, 0, target, lun);
356 if (!sdev) { 359 if (!sdev) {
@@ -374,12 +377,14 @@ static void virtscsi_handle_event(struct work_struct *work)
374 struct virtio_scsi *vscsi = event_node->vscsi; 377 struct virtio_scsi *vscsi = event_node->vscsi;
375 struct virtio_scsi_event *event = &event_node->event; 378 struct virtio_scsi_event *event = &event_node->event;
376 379
377 if (event->event & VIRTIO_SCSI_T_EVENTS_MISSED) { 380 if (event->event &
378 event->event &= ~VIRTIO_SCSI_T_EVENTS_MISSED; 381 cpu_to_virtio32(vscsi->vdev, VIRTIO_SCSI_T_EVENTS_MISSED)) {
382 event->event &= ~cpu_to_virtio32(vscsi->vdev,
383 VIRTIO_SCSI_T_EVENTS_MISSED);
379 scsi_scan_host(virtio_scsi_host(vscsi->vdev)); 384 scsi_scan_host(virtio_scsi_host(vscsi->vdev));
380 } 385 }
381 386
382 switch (event->event) { 387 switch (virtio32_to_cpu(vscsi->vdev, event->event)) {
383 case VIRTIO_SCSI_T_NO_EVENT: 388 case VIRTIO_SCSI_T_NO_EVENT:
384 break; 389 break;
385 case VIRTIO_SCSI_T_TRANSPORT_RESET: 390 case VIRTIO_SCSI_T_TRANSPORT_RESET:
@@ -482,26 +487,28 @@ static int virtscsi_kick_cmd(struct virtio_scsi_vq *vq,
482 return err; 487 return err;
483} 488}
484 489
485static void virtio_scsi_init_hdr(struct virtio_scsi_cmd_req *cmd, 490static void virtio_scsi_init_hdr(struct virtio_device *vdev,
491 struct virtio_scsi_cmd_req *cmd,
486 struct scsi_cmnd *sc) 492 struct scsi_cmnd *sc)
487{ 493{
488 cmd->lun[0] = 1; 494 cmd->lun[0] = 1;
489 cmd->lun[1] = sc->device->id; 495 cmd->lun[1] = sc->device->id;
490 cmd->lun[2] = (sc->device->lun >> 8) | 0x40; 496 cmd->lun[2] = (sc->device->lun >> 8) | 0x40;
491 cmd->lun[3] = sc->device->lun & 0xff; 497 cmd->lun[3] = sc->device->lun & 0xff;
492 cmd->tag = (unsigned long)sc; 498 cmd->tag = cpu_to_virtio64(vdev, (unsigned long)sc);
493 cmd->task_attr = VIRTIO_SCSI_S_SIMPLE; 499 cmd->task_attr = VIRTIO_SCSI_S_SIMPLE;
494 cmd->prio = 0; 500 cmd->prio = 0;
495 cmd->crn = 0; 501 cmd->crn = 0;
496} 502}
497 503
498static void virtio_scsi_init_hdr_pi(struct virtio_scsi_cmd_req_pi *cmd_pi, 504static void virtio_scsi_init_hdr_pi(struct virtio_device *vdev,
505 struct virtio_scsi_cmd_req_pi *cmd_pi,
499 struct scsi_cmnd *sc) 506 struct scsi_cmnd *sc)
500{ 507{
501 struct request *rq = sc->request; 508 struct request *rq = sc->request;
502 struct blk_integrity *bi; 509 struct blk_integrity *bi;
503 510
504 virtio_scsi_init_hdr((struct virtio_scsi_cmd_req *)cmd_pi, sc); 511 virtio_scsi_init_hdr(vdev, (struct virtio_scsi_cmd_req *)cmd_pi, sc);
505 512
506 if (!rq || !scsi_prot_sg_count(sc)) 513 if (!rq || !scsi_prot_sg_count(sc))
507 return; 514 return;
@@ -509,9 +516,13 @@ static void virtio_scsi_init_hdr_pi(struct virtio_scsi_cmd_req_pi *cmd_pi,
509 bi = blk_get_integrity(rq->rq_disk); 516 bi = blk_get_integrity(rq->rq_disk);
510 517
511 if (sc->sc_data_direction == DMA_TO_DEVICE) 518 if (sc->sc_data_direction == DMA_TO_DEVICE)
512 cmd_pi->pi_bytesout = blk_rq_sectors(rq) * bi->tuple_size; 519 cmd_pi->pi_bytesout = cpu_to_virtio32(vdev,
520 blk_rq_sectors(rq) *
521 bi->tuple_size);
513 else if (sc->sc_data_direction == DMA_FROM_DEVICE) 522 else if (sc->sc_data_direction == DMA_FROM_DEVICE)
514 cmd_pi->pi_bytesin = blk_rq_sectors(rq) * bi->tuple_size; 523 cmd_pi->pi_bytesin = cpu_to_virtio32(vdev,
524 blk_rq_sectors(rq) *
525 bi->tuple_size);
515} 526}
516 527
517static int virtscsi_queuecommand(struct virtio_scsi *vscsi, 528static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
@@ -536,11 +547,11 @@ static int virtscsi_queuecommand(struct virtio_scsi *vscsi,
536 BUG_ON(sc->cmd_len > VIRTIO_SCSI_CDB_SIZE); 547 BUG_ON(sc->cmd_len > VIRTIO_SCSI_CDB_SIZE);
537 548
538 if (virtio_has_feature(vscsi->vdev, VIRTIO_SCSI_F_T10_PI)) { 549 if (virtio_has_feature(vscsi->vdev, VIRTIO_SCSI_F_T10_PI)) {
539 virtio_scsi_init_hdr_pi(&cmd->req.cmd_pi, sc); 550 virtio_scsi_init_hdr_pi(vscsi->vdev, &cmd->req.cmd_pi, sc);
540 memcpy(cmd->req.cmd_pi.cdb, sc->cmnd, sc->cmd_len); 551 memcpy(cmd->req.cmd_pi.cdb, sc->cmnd, sc->cmd_len);
541 req_size = sizeof(cmd->req.cmd_pi); 552 req_size = sizeof(cmd->req.cmd_pi);
542 } else { 553 } else {
543 virtio_scsi_init_hdr(&cmd->req.cmd, sc); 554 virtio_scsi_init_hdr(vscsi->vdev, &cmd->req.cmd, sc);
544 memcpy(cmd->req.cmd.cdb, sc->cmnd, sc->cmd_len); 555 memcpy(cmd->req.cmd.cdb, sc->cmnd, sc->cmd_len);
545 req_size = sizeof(cmd->req.cmd); 556 req_size = sizeof(cmd->req.cmd);
546 } 557 }
@@ -669,7 +680,8 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
669 cmd->sc = sc; 680 cmd->sc = sc;
670 cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){ 681 cmd->req.tmf = (struct virtio_scsi_ctrl_tmf_req){
671 .type = VIRTIO_SCSI_T_TMF, 682 .type = VIRTIO_SCSI_T_TMF,
672 .subtype = VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET, 683 .subtype = cpu_to_virtio32(vscsi->vdev,
684 VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET),
673 .lun[0] = 1, 685 .lun[0] = 1,
674 .lun[1] = sc->device->id, 686 .lun[1] = sc->device->id,
675 .lun[2] = (sc->device->lun >> 8) | 0x40, 687 .lun[2] = (sc->device->lun >> 8) | 0x40,
@@ -710,7 +722,7 @@ static int virtscsi_abort(struct scsi_cmnd *sc)
710 .lun[1] = sc->device->id, 722 .lun[1] = sc->device->id,
711 .lun[2] = (sc->device->lun >> 8) | 0x40, 723 .lun[2] = (sc->device->lun >> 8) | 0x40,
712 .lun[3] = sc->device->lun & 0xff, 724 .lun[3] = sc->device->lun & 0xff,
713 .tag = (unsigned long)sc, 725 .tag = cpu_to_virtio64(vscsi->vdev, (unsigned long)sc),
714 }; 726 };
715 return virtscsi_tmf(vscsi, cmd); 727 return virtscsi_tmf(vscsi, cmd);
716} 728}