SCSI patches for 2012-08-03
Anthony,
The following changes since commit 5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:
Merge remote-tracking branch 'mst/tags/for_anthony' into staging (2012-07-30 10:00:48 -0500)
are available in the git repository at:
git://github.com/bonzini/qemu.git scsi-next
for you to fetch changes up to b71760ef6180662cc2dff1f6cf673a53508c59f1:
scsi: add support for ATA_PASSTHROUGH_xx scsi command (2012-08-03 10:04:37 +0200)
The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
----------------------------------------------------------------
Cong Meng (1):
scsi: add support for ATA_PASSTHROUGH_xx scsi command
Hannes Reinecke (1):
megasas: static SAS addresses
Hervé Poussineau (2):
esp: add missing const on TypeInfo structures
esp: add Tekram DC-390 emulation (PC SCSI adapter)
Paolo Bonzini (3):
scsi-disk: fix compilation with DEBUG_SCSI Revert "megasas: disable due to build breakage"
esp: enable for all PCI machines
Ronnie Sahlberg (2):
SCSI: Update the sense code for PREVENT REMOVAL errors
SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
Stefan Weil (1):
megasas: Update function megasys_scsi_uninit
default-configs/i386-softmmu.mak | 1 - default-configs/pci.mak | 2 + hw/esp.c | 130 +++++++++++++++++++++++++++++++++++++- hw/megasas.c | 68 ++++++++++++++------ hw/mfi.h | 1 + hw/scsi-bus.c | 92 +++++++++++++++++++++++++-- hw/scsi-defs.h | 4 +- hw/scsi-disk.c | 29 +++++---- 8 files changed, 286 insertions(+), 41 deletions(-)
Signature · 1 line
1.7.10.4
PATCH 1/10 SCSI: Update the sense code for PREVENT REMOVAL errors
From: Ronnie Sahlberg <[email protected]>
Change the sense codes for failures to eject a device that is locked by PREVENT_ALLOW_MEDIUM_REMOVAL from
the generic MEDIA_LOAD_OR_EJECT_FAILED to the more specific MEDIUM_REMOVAL_PREVENTED.
The second sense code is more accurate, and is also listed in MMC annex F for the recommended sense codes for MMC devices while the first sense code is not.
--- hw/scsi-bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/scsi-bus.c +2 -2
@@ -1103,7 +1103,7 @@ const struct SCSISense sense_code_NO_MEDIUM = {/* LUN not ready, medium removal prevented */ const struct SCSISense sense_code_NOT_READY_REMOVAL_PREVENTED = { - .key =NOT_READY , .asc =0x53 , .ascq =0x00 + .key =NOT_READY , .asc =0x53 , .ascq =0x02 };/* Hardware error, internal target failure */
@@ -1153,7 +1153,7 @@ const struct SCSISense sense_code_INCOMPATIBLE_FORMAT = {/* Illegal request, medium removal prevented */ const struct SCSISense sense_code_ILLEGAL_REQ_REMOVAL_PREVENTED = { - .key =ILLEGAL_REQUEST , .asc =0x53 , .ascq =0x00 + .key =ILLEGAL_REQUEST , .asc =0x53 , .ascq =0x02 };/* Command aborted, I/O process terminated */
Signature · 1 line
1.7.10.4
PATCH 2/10 SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0
In reply to Paolo BonziniFrom: Ronnie Sahlberg <[email protected]>
The START STOP UNIT command will only eject/load media if power condition is zero.
If power condition is !0 then LOEJ and START will be ignored.
Quoted 1 line
From MMC (sbc contains similar wordings too)
The Power Conditions field requests the block device to be placed in the power condition defined in
Table 558. If this field has a value other than 0h then the Start and LoEj bits shall be ignored.
--- hw/scsi-disk.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/scsi-disk.c +6 -0
@@ -1247,6 +1247,12 @@ static int scsi_disk_emulate_start_stop(SCSIDiskReq *r)SCSIDiskState *s =DO_UPCAST (SCSIDiskState, qdev, req->dev);bool start = req->cmd.buf[4 ] &1 ;bool loej = req->cmd.buf[4 ] &2 ;/* load on start, eject on !start */ +int pwrcnd = req->cmd.buf[4 ] &0xf0 ; + +if (pwrcnd) { +/* eject/load only happens for power condition == 0 */ +return 0 ; + }if ((s->features & (1 <<SCSI_DISK_F_REMOVABLE )) && loej) {if (!start && !s->tray_open && s->tray_locked) {
Signature · 1 line
1.7.10.4
PATCH 3/10 megasas: Update function megasys_scsi_uninit
In reply to Paolo BonziniFrom: Stefan Weil <[email protected]>
Commit f90c2bcdbc69e41e575f868b984c3e2de8f51bac changed PCIUnregisterFunc, therefore the function prototype needs an update.
megasas.o is currently not linked, so this bug was not detected by the buildbots.
--- hw/megasas.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/megasas.c +1 -2
@@ -2040,7 +2040,7 @@ static const VMStateDescription vmstate_megasas = { } }; -static int megasas_scsi_uninit (PCIDevice *d) +static void megasas_scsi_uninit (PCIDevice *d) {MegasasState *s =DO_UPCAST (MegasasState, dev, d);
@@ -2050,7 +2050,6 @@ static int megasas_scsi_uninit(PCIDevice *d)memory_region_destroy (&s->mmio_io);memory_region_destroy (&s->port_io);memory_region_destroy (&s->queue_io); -return 0 ; }static const struct SCSIBusInfo megasas_scsi_info = {
Signature · 1 line
1.7.10.4
PATCH 4/10 scsi-disk: fix compilation with DEBUG_SCSI
In reply to Paolo Bonzini--- hw/scsi-disk.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
hw/scsi-disk.c +12 -11
@@ -447,7 +447,7 @@ static void scsi_write_complete(void * opaque, int ret)return ; }else {scsi_init_iovec (r,SCSI_DMA_BUF_SIZE ); -DPRINTF ("Write complete tag=0x%x more=%d\n" , r->req.tag, r->qiov.size); +DPRINTF ("Write complete tag=0x%x more=%zd\n" , r->req.tag, r->qiov.size);scsi_req_data (&r->req, r->qiov.size); }
@@ -1277,7 +1277,7 @@ static void scsi_disk_emulate_read_data(SCSIRequest *req)int buflen = r->iov.iov_len;if (buflen) { -DPRINTF ("Read buf_len=%zd\n" , buflen); +DPRINTF ("Read buf_len=%d\n" , buflen); r->iov.iov_len =0 ; r->started = true;scsi_req_data (&r->req, buflen);
@@ -1455,7 +1455,7 @@ static void scsi_disk_emulate_write_data(SCSIRequest *req)if (r->iov.iov_len) {int buflen = r->iov.iov_len; -DPRINTF ("Write buf_len=%zd\n" , buflen); +DPRINTF ("Write buf_len=%d\n" , buflen); r->iov.iov_len =0 ;scsi_req_data (&r->req, buflen);return ;
@@ -2093,23 +2093,24 @@ static SCSIRequest *scsi_new_request(SCSIDevice *d, uint32_t tag, uint32_t lun,const SCSIReqOps *ops;uint8_t command; + command = buf[0 ]; + ops = scsi_disk_reqops_dispatch[command]; +if (!ops) { + ops = &scsi_disk_emulate_reqops; + } + req =scsi_req_alloc (ops, &s->qdev, tag, lun, hba_private); +#ifdef DEBUG_SCSI -DPRINTF ("Command: lun=%d tag=0x%x data=0x%02x" , lun, buf[0 ]); +DPRINTF ("Command: lun=%d tag=0x%x data=0x%02x" , lun, tag, buf[0 ]); {int i; -for (i =1 ; i < r->req.cmd.len; i++) { +for (i =1 ; i < req->cmd.len; i++) {printf (" 0x%02x" , buf[i]); }printf ("\n" ); }#endif - command = buf[0 ]; - ops = scsi_disk_reqops_dispatch[command]; -if (!ops) { - ops = &scsi_disk_emulate_reqops; - } - req =scsi_req_alloc (ops, &s->qdev, tag, lun, hba_private);return req; }
Signature · 1 line
1.7.10.4
PATCH 5/10 megasas: static SAS addresses
In reply to Paolo BonziniFrom: Hannes Reinecke <[email protected]>
This patch introduces a new property 'sas_address' which allows the user to specify the SAS address for the HBA. The default address is following the NAA locally assigned identifier format with the locally assigned address 0x525400 as used eg for the MAC addresses.
The lower bytes are set to the pci address which will ensure uniqueness for the local machine.
The port addresses are now calculated based on the magic number 0x1221 (which is found in real hardware, too) plus the device number.
--- hw/megasas.c | 65 +++++++++++++++++++++++++++++++++++++++++++--------------- hw/mfi.h | 1 + 2 files changed, 49 insertions(+), 17 deletions(-)
hw/megasas.c +48 -17
@@ -38,6 +38,9 @@#define MEGASAS_MAX_SECTORS 0xFFFF/* No real limit */ #define MEGASAS_MAX_ARRAYS 128 +#define NAA_LOCALLY_ASSIGNED_ID 0x3ULL +#define IEEE_COMPANY_LOCALLY_ASSIGNED 0x525400 +#define MEGASAS_FLAG_USE_JBOD 0#define MEGASAS_MASK_USE_JBOD (1 << MEGASAS_FLAG_USE_JBOD)#define MEGASAS_FLAG_USE_MSIX 1
@@ -89,6 +92,8 @@ typedef struct MegasasState {int shutdown_event;int boot_event; +uint64_t sas_addr; +uint64_t reply_queue_pa;void *reply_queue;int reply_queue_len;
@@ -372,14 +377,16 @@ static uint64_t megasas_fw_time(void)return bcd_time; } -static uint64_t megasas_gen_sas_addr (uint64_t id) +/* +* Default disk sata address +* 0x1221 is the magic number as +* present in real hardware, +* so use it here, too. +*/ +static uint64_t megasas_get_sata_addr (uint16_t id) { -uint64_t addr; - - addr =0x5001a4aULL <<36 ; - addr |= id &0xfffffffff ; - -return addr; +uint64_t addr = (0x1221ULL <<48 ); +return addr & (id <<24 ); }/*
@@ -652,10 +659,7 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd)size_t dcmd_size =sizeof (info);BusChild *kid;int num_ld_disks =0 ; - - QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { - num_ld_disks++; - } +uint16_t sdev_id;memset (&info,0x0 , cmd->iov_size);if (cmd->iov_size < dcmd_size) {
@@ -669,10 +673,29 @@ static int megasas_ctrl_get_info(MegasasState *s, MegasasCmd *cmd) info.pci.subvendor =cpu_to_le16 (PCI_VENDOR_ID_LSI_LOGIC ); info.pci.subdevice =cpu_to_le16 (0x1013 ); - info.host.type =MFI_INFO_HOST_PCIX ; +/* +* For some reason the firmware supports +* only up to 8 device ports. +* Despite supporting a far larger number +* of devices for the physical devices. +* So just display the first 8 devices +* in the device port list, independent +* of how many logical devices are actually +* present. +*/ + info.host.type =MFI_INFO_HOST_PCIE ; info.device.type =MFI_INFO_DEV_SAS3G ; - info.device.port_count =2 ; - info.device.port_addr[0 ] =cpu_to_le64 (megasas_gen_sas_addr ((uint64_t )s)); + info.device.port_count =8 ; + QTAILQ_FOREACH(kid, &s->bus.qbus.children, sibling) { +SCSIDevice *sdev =DO_UPCAST (SCSIDevice, qdev, kid->child); + +if (num_ld_disks <8 ) { + sdev_id = ((sdev->id &0xFF ) >>8 ) | (sdev->lun &0xFF ); + info.device.port_addr[num_ld_disks] = +cpu_to_le64 (megasas_get_sata_addr (sdev_id)); + } + num_ld_disks++; + }memcpy (info.product_name,"MegaRAID SAS 8708EM2" ,20 ); snprintf(info.serial_number, 32, "QEMU%08lx",
@@ -761,7 +784,7 @@ static int megasas_mfc_get_defaults(MegasasState *s, MegasasCmd *cmd)return MFI_STAT_INVALID_PARAMETER ; } - info.sas_addr =cpu_to_le64 (megasas_gen_sas_addr ((uint64_t )s)); + info.sas_addr =cpu_to_le64 (s->sas_addr); info.stripe_size =3 ; info.flush_time =4 ; info.background_rate =30 ;
@@ -891,7 +914,7 @@ static int megasas_dcmd_pd_get_list(MegasasState *s, MegasasCmd *cmd) info.addr[num_pd_disks].scsi_dev_type = sdev->type; info.addr[num_pd_disks].connect_port_bitmap =0x1 ; info.addr[num_pd_disks].sas_addr[0 ] = -cpu_to_le64 (megasas_gen_sas_addr ((uint64_t )sdev)); +cpu_to_le64 (megasas_get_sata_addr (sdev_id)); num_pd_disks++; offset +=sizeof (struct mfi_pd_address ); }
@@ -994,7 +1017,7 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev, int lun, info->slot_number = (sdev->id &0xFF ); info->path_info.count =1 ; info->path_info.sas_addr[0 ] = -cpu_to_le64 (megasas_gen_sas_addr ((uint64_t )sdev)); +cpu_to_le64 (megasas_get_sata_addr (sdev_id)); info->connected_port_bitmap =0x1 ; info->device_speed =1 ; info->link_speed =1 ;
@@ -2102,6 +2125,13 @@ static int megasas_scsi_init(PCIDevice *dev)msix_vector_use (&s->dev,0 ); } +if (!s->sas_addr) { + s->sas_addr = ((NAA_LOCALLY_ASSIGNED_ID <<24 ) | +IEEE_COMPANY_LOCALLY_ASSIGNED ) <<36 ; + s->sas_addr |= (pci_bus_num (dev->bus) <<16 ); + s->sas_addr |= (PCI_SLOT (dev->devfn) <<8 ); + s->sas_addr |=PCI_FUNC (dev->devfn); + }if (s->fw_sge >=MEGASAS_MAX_SGE -MFI_PASS_FRAME_SIZE ) { s->fw_sge =MEGASAS_MAX_SGE -MFI_PASS_FRAME_SIZE ; }else if (s->fw_sge >=128 -MFI_PASS_FRAME_SIZE ) {
@@ -2136,6 +2166,7 @@ static Property megasas_properties[] = { MEGASAS_DEFAULT_SGE),DEFINE_PROP_UINT32 ("max_cmds" , MegasasState, fw_cmds,MEGASAS_DEFAULT_FRAMES ), +DEFINE_PROP_HEX64 ("sas_address" , MegasasState, sas_addr,0 ), #ifdef USE_MSIXDEFINE_PROP_BIT ("use_msix" , MegasasState, flags, MEGASAS_FLAG_USE_MSIX, false),
hw/mfi.h +1 -0
@@ -656,6 +656,7 @@ struct mfi_info_device {#define MFI_INFO_DEV_SAS3G 0x02#define MFI_INFO_DEV_SATA1 0x04#define MFI_INFO_DEV_SATA3G 0x08 +#define MFI_INFO_DEV_PCIE 0x10uint8_t reserved[6 ];uint8_t port_count;uint64_t port_addr[8 ];
Signature · 1 line
1.7.10.4
PATCH 6/10 Revert "megasas: disable due to build breakage"
In reply to Paolo BonziniThis reverts commit 92336855975805d88c7979f53bc05c2d47abab04.
--- default-configs/pci.mak | 1 + 1 file changed, 1 insertion(+)
default-configs/pci.mak +1 -0
@@ -10,6 +10,7 @@ CONFIG_EEPRO100_PCI=y CONFIG_PCNET_PCI=y CONFIG_PCNET_COMMON=y CONFIG_LSI_SCSI_PCI=y +CONFIG_MEGASAS_SCSI_PCI=y CONFIG_RTL8139_PCI=y CONFIG_E1000_PCI=y CONFIG_IDE_CORE=y
Signature · 1 line
1.7.10.4
PATCH 7/10 esp: enable for all PCI machines
In reply to Paolo Bonzini--- default-configs/i386-softmmu.mak | 1 - default-configs/pci.mak | 1 + 2 files changed, 1 insertion(+), 1 deletion(-)
default-configs/i386-softmmu.mak +0 -1
@@ -25,4 +25,3 @@ CONFIG_HPET=y CONFIG_APPLESMC=y CONFIG_I8259=y CONFIG_PFLASH_CFI01=y -CONFIG_ESP=y
default-configs/pci.mak +1 -0
@@ -17,3 +17,4 @@ CONFIG_IDE_CORE=y CONFIG_IDE_QDEV=y CONFIG_IDE_PCI=y CONFIG_AHCI=y +CONFIG_ESP=y
Signature · 1 line
1.7.10.4
PATCH 8/10 esp: add missing const on TypeInfo structures
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
--- hw/esp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
hw/esp.c +2 -2
@@ -816,7 +816,7 @@ static void sysbus_esp_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_sysbus_esp_scsi; } -static TypeInfo sysbus_esp_info = { +static const TypeInfo sysbus_esp_info = { .name ="esp" , .parent =TYPE_SYS_BUS_DEVICE , .instance_size =sizeof (SysBusESPState),
@@ -1176,7 +1176,7 @@ static void esp_pci_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_esp_pci_scsi; } -static TypeInfo esp_pci_info = { +static const TypeInfo esp_pci_info = { .name ="am53c974" , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIESPState),
Signature · 1 line
1.7.10.4
PATCH 9/10 esp: add Tekram DC-390 emulation (PC SCSI adapter)
In reply to Paolo BonziniFrom: Hervé Poussineau <[email protected]>
Difference with AMD PCscsi is that DC-390 contains a EEPROM.
This has been successfully tested on:
- MS DOS 6.22 (using DC390 ASPI driver)
- MS Windows 98 SE (using DC390 driver)
- MS Windows NT 3.1 (using DC390 driver)
- MS Windows NT 4.0 (using DC390 driver)
- hard disk and cdrom boot
--- hw/esp.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 1 deletion(-)
hw/esp.c +125 -1
@@ -26,6 +26,7 @@#include "sysbus.h" #include "pci.h" #include "scsi.h" +#include "eeprom93xx.h" #include "esp.h" #include "trace.h" #include "qemu-log.h"
@@ -823,6 +824,9 @@ static const TypeInfo sysbus_esp_info = { .class_init = sysbus_esp_class_init, }; + +#define TYPE_AM53C974_DEVICE "am53c974" +#define DMA_CMD 0x0#define DMA_STC 0x1#define DMA_SPA 0x2
@@ -1177,16 +1181,136 @@ static void esp_pci_class_init(ObjectClass *klass, void *data) }static const TypeInfo esp_pci_info = { - .name ="am53c974" , + .name =TYPE_AM53C974_DEVICE , .parent =TYPE_PCI_DEVICE , .instance_size =sizeof (PCIESPState), .class_init = esp_pci_class_init, }; +typedef struct { +PCIESPState pci; +eeprom_t *eeprom; +}DC390State ; + +#define TYPE_DC390_DEVICE "dc390" +#define DC390 (obj) \ + OBJECT_CHECK(DC390State, obj, TYPE_DC390_DEVICE) + +#define EE_ADAPT_SCSI_ID 64 +#define EE_MODE2 65 +#define EE_DELAY 66 +#define EE_TAG_CMD_NUM 67 +#define EE_ADAPT_OPTIONS 68 +#define EE_BOOT_SCSI_ID 69 +#define EE_BOOT_SCSI_LUN 70 +#define EE_CHKSUM1 126 +#define EE_CHKSUM2 127 + +#define EE_ADAPT_OPTION_F6_F8_AT_BOOT 0x01 +#define EE_ADAPT_OPTION_BOOT_FROM_CDROM 0x02 +#define EE_ADAPT_OPTION_INT13 0x04 +#define EE_ADAPT_OPTION_SCAM_SUPPORT 0x08 + + +static uint32_t dc390_read_config (PCIDevice *dev,uint32_t addr,int l) +{ +DC390State *pci =DC390 (dev); +uint32_t val; + + val =pci_default_read_config (dev, addr, l); + +if (addr ==0x00 && l ==1 ) { +/* First byte of address space is AND-ed with EEPROM DO line */ +if (!eeprom93xx_read (pci->eeprom)) { + val &= ~0xff ; + } + } + +return val; +} + +static void dc390_write_config (PCIDevice *dev, +uint32_t addr,uint32_t val,int l) +{ +DC390State *pci =DC390 (dev); +if (addr ==0x80 ) { +/* EEPROM write */ +int eesk = val &0x80 ?1 :0 ; +int eedi = val &0x40 ?1 :0 ; +eeprom93xx_write (pci->eeprom,1 , eesk, eedi); + }else if (addr ==0xc0 ) { +/* EEPROM CS low */ +eeprom93xx_write (pci->eeprom,0 ,0 ,0 ); + }else { +pci_default_write_config (dev, addr, val, l); + } +} + +static int dc390_scsi_init (PCIDevice *dev) +{ +DC390State *pci =DC390 (dev); +uint8_t *contents; +uint16_t chksum =0 ; +int i, ret; + +/* init base class */ + ret =esp_pci_scsi_init (dev); +if (ret <0 ) { +return ret; + } + +/* EEPROM */ + pci->eeprom =eeprom93xx_new (DEVICE (dev),64 ); + +/* set default eeprom values */ + contents = (uint8_t *)eeprom93xx_data (pci->eeprom); + +for (i =0 ; i <16 ; i++) { + contents[i *2 ] =0x57 ; + contents[i *2 +1 ] =0x00 ; + } + contents[EE_ADAPT_SCSI_ID ] =7 ; + contents[EE_MODE2 ] =0x0f ; + contents[EE_TAG_CMD_NUM ] =0x04 ; + contents[EE_ADAPT_OPTIONS ] =EE_ADAPT_OPTION_F6_F8_AT_BOOT + |EE_ADAPT_OPTION_BOOT_FROM_CDROM + |EE_ADAPT_OPTION_INT13 ; + +/* update eeprom checksum */ +for (i =0 ; i <EE_CHKSUM1 ; i +=2 ) { + chksum += contents[i] + (((uint16_t )contents[i +1 ]) <<8 ); + } + chksum =0x1234 - chksum; + contents[EE_CHKSUM1 ] = chksum &0xff ; + contents[EE_CHKSUM2 ] = chksum >>8 ; + +return 0 ; +} + +static void dc390_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); + + k->init = dc390_scsi_init; + k->config_read = dc390_read_config; + k->config_write = dc390_write_config; + dc->desc ="Tekram DC-390 SCSI adapter" ; +} + +static const TypeInfo dc390_info = { + .name ="dc390" , + .parent =TYPE_AM53C974_DEVICE , + .instance_size =sizeof (DC390State), + .class_init = dc390_class_init, +}; + +static void esp_register_types (void ) {type_register_static (&sysbus_esp_info);type_register_static (&esp_pci_info); +type_register_static (&dc390_info); }type_init (esp_register_types)
Signature · 1 line
1.7.10.4
PATCH 10/10 scsi: add support for ATA_PASSTHROUGH_xx scsi command
In reply to Paolo BonziniFrom: Cong Meng <[email protected]>
Correct the command names of opcode 0x85 and 0xa1, and calculate their xfer size from CDB.
--- hw/scsi-bus.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- hw/scsi-defs.h | 4 +-- 2 files changed, 87 insertions(+), 5 deletions(-)
hw/scsi-bus.c +85 -3
@@ -733,6 +733,72 @@ static int scsi_get_performance_length(int num_desc, int type, int data_type) } } +static int ata_passthrough_xfer_unit (SCSIDevice *dev,uint8_t *buf) +{ +int byte_block = (buf[2 ] >>2 ) &0x1 ; +int type = (buf[2 ] >>4 ) &0x1 ; +int xfer_unit; + +if (byte_block) { +if (type) { + xfer_unit = dev->blocksize; + }else { + xfer_unit =512 ; + } + }else { + xfer_unit =1 ; + } + +return xfer_unit; +} + +static int ata_passthrough_12_xfer_size (SCSIDevice *dev,uint8_t *buf) +{ +int length = buf[2 ] &0x3 ; +int xfer; +int unit =ata_passthrough_xfer_unit (dev, buf); + +switch (length) { +case 0 : +case 3 :/* USB-specific. */ + xfer =0 ; +break ; +case 1 : + xfer = buf[3 ]; +break ; +case 2 : + xfer = buf[4 ]; +break ; + } + +return xfer * unit; +} + +static int ata_passthrough_16_xfer_size (SCSIDevice *dev,uint8_t *buf) +{ +int extend = buf[1 ] &0x1 ; +int length = buf[2 ] &0x3 ; +int xfer; +int unit =ata_passthrough_xfer_unit (dev, buf); + +switch (length) { +case 0 : +case 3 :/* USB-specific. */ + xfer =0 ; +break ; +case 1 : + xfer = buf[4 ]; + xfer |= (extend ? buf[3 ] <<8 :0 ); +break ; +case 2 : + xfer = buf[6 ]; + xfer |= (extend ? buf[5 ] <<8 :0 ); +break ; + } + +return xfer * unit; +} +static int scsi_req_length (SCSICommand *cmd,SCSIDevice *dev,uint8_t *buf) {switch (buf[0 ] >>5 ) {
@@ -867,6 +933,17 @@ static int scsi_req_length(SCSICommand *cmd, SCSIDevice *dev, uint8_t *buf) cmd->xfer = buf[9 ] | (buf[8 ] <<8 ); }break ; +case ATA_PASSTHROUGH_12 : +if (dev->type ==TYPE_ROM ) { +/* BLANK command of MMC */ + cmd->xfer =0 ; + }else { + cmd->xfer =ata_passthrough_12_xfer_size (dev, buf); + } +break ; +case ATA_PASSTHROUGH_16 : + cmd->xfer =ata_passthrough_16_xfer_size (dev, buf); +break ; }return 0 ; }
@@ -996,9 +1073,14 @@ static void scsi_cmd_xfer_mode(SCSICommand *cmd)case SEND_DVD_STRUCTURE :case PERSISTENT_RESERVE_OUT :case MAINTENANCE_OUT : -case ATA_PASSTHROUGH : cmd->mode =SCSI_XFER_TO_DEV ;break ; +case ATA_PASSTHROUGH_12 : +case ATA_PASSTHROUGH_16 : +/* T_DIR */ + cmd->mode = (cmd->buf[2 ] &0x8 ) ? +SCSI_XFER_FROM_DEV :SCSI_XFER_TO_DEV ; +break ;default : cmd->mode =SCSI_XFER_FROM_DEV ;break ;
@@ -1335,7 +1417,7 @@ static const char *scsi_command_name(uint8_t cmd) [ PERSISTENT_RESERVE_OUT ] = "PERSISTENT_RESERVE_OUT", [ WRITE_FILEMARKS_16 ] = "WRITE_FILEMARKS_16", [ EXTENDED_COPY ] = "EXTENDED_COPY", - [ ATA_PASSTHROUGH ] = "ATA_PASSTHROUGH", + [ ATA_PASSTHROUGH_16 ] = "ATA_PASSTHROUGH_16", [ ACCESS_CONTROL_IN ] = "ACCESS_CONTROL_IN", [ ACCESS_CONTROL_OUT ] = "ACCESS_CONTROL_OUT", [ READ_16 ] = "READ_16",
@@ -1352,7 +1434,7 @@ static const char *scsi_command_name(uint8_t cmd) [ SERVICE_ACTION_IN_16 ] = "SERVICE_ACTION_IN_16", [ WRITE_LONG_16 ] = "WRITE_LONG_16", [ REPORT_LUNS ] = "REPORT_LUNS", - [ BLANK ] = "BLANK", + [ ATA_PASSTHROUGH_12 ] = "BLANK/ATA_PASSTHROUGH_12", [ MOVE_MEDIUM ] = "MOVE_MEDIUM", [ EXCHANGE_MEDIUM ] = "EXCHANGE MEDIUM", [ LOAD_UNLOAD ] = "LOAD_UNLOAD",
hw/scsi-defs.h +2 -2
@@ -100,7 +100,7 @@#define READ_REVERSE_16 0x81#define ALLOW_OVERWRITE 0x82#define EXTENDED_COPY 0x83 -#define ATA_PASSTHROUGH 0x85 +#define ATA_PASSTHROUGH_16 0x85#define ACCESS_CONTROL_IN 0x86#define ACCESS_CONTROL_OUT 0x87#define READ_16 0x88
@@ -117,7 +117,7 @@#define SERVICE_ACTION_IN_16 0x9e#define WRITE_LONG_16 0x9f#define REPORT_LUNS 0xa0 -#define BLANK 0xa1 +#define ATA_PASSTHROUGH_12 0xa1#define MAINTENANCE_IN 0xa3#define MAINTENANCE_OUT 0xa4#define MOVE_MEDIUM 0xa5
Signature · 1 line
1.7.10.4
Quoted 9 lines · Paolo Bonzini
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging (2012-07-30 10:00:48 -0500)are available in the git repository at:
Quoted 8 lines
git://github.com/bonzini/qemu.gitscsi-nextfor you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03 10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to pci_default_read_config' ../libhw64/hw/esp.o: In function dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2
It looks like sparc does link in esp.c but doesn't support pci (at least pci.o).
I must admit, it's not obvious to me whether pci.o should be added to the
sparc build or whether esp.c needs to be refactored.
Regards,
Anthony Liguori
Quoted 33 lines
----------------------------------------------------------------
Cong Meng (1):
scsi: add support forATA_PASSTHROUGH_xxscsi commandHannes Reinecke (1):
megasas: static SAS addressesHervé Poussineau (2):
esp: add missing const on TypeInfo structures
esp: add Tekram DC-390 emulation (PC SCSI adapter)Paolo Bonzini (3):
scsi-disk: fix compilation withDEBUG_SCSIRevert "megasas: disable due to build breakage"
esp: enable for all PCI machinesRonnie Sahlberg (2):
SCSI: Update the sense code for PREVENT REMOVAL errors
SCSI: STARTSTOPUNIT only eject/load media if powercondition is 0Stefan Weil (1):
megasas: Update functionmegasys_scsi_uninitdefault-configs/i386-softmmu.mak | 1 - default-configs/pci.mak | 2 + hw/esp.c | 130 +++++++++++++++++++++++++++++++++++++- hw/megasas.c | 68 ++++++++++++++------ hw/mfi.h | 1 + hw/scsi-bus.c | 92 +++++++++++++++++++++++++-- hw/scsi-defs.h | 4 +- hw/scsi-disk.c | 29 +++++---- 8 files changed, 286 insertions(+), 41 deletions(-)
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 36 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2
Quoted 3 lines
It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.
I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location. Blue/Herve, can you look at esp.c?
Paolo
Quoted 37 lines · Paolo Bonzini
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 36 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2
Quoted 8 lines
Quoted 3 lines
It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location.
Thanks.
Regards,
Anthony Liguori
Quoted 3 lines
Blue/Herve, can you look at
esp.c?Paolo
Quoted 36 lines · Paolo Bonzini
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 35 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2
Quoted 8 lines
Quoted 3 lines
It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location. Blue/Herve, can you look at
esp.c?
I just sent an email to ML to add stubs for pci_default_read_config and pci_default_write_config. I compile-tested sparc-softmmu target and it works now well.
Hervé
[1]
Quoted 41 lines · Hervé Poussineau
Quoted 40 lines · Paolo Bonzini
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 38 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.
Quoted 8 lines
Quoted 4 lines
I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location. Blue/Herve, can you look at
esp.c?I just sent an email to ML to add stubs for
pci_default_read_configandpci_default_write_config. I compile-tested sparc-softmmu target and it works now well.
Shouldn't Sparc consume pci.o?
If Sparc doesn't have PCI, then stubs don't seem like the right answer. If it has PCI, then it ought to use the generic code, no?
Regards,
Anthony Liguori
Quoted 4 lines
Hervé
[1]
Quoted 48 lines · Anthony Liguori
Quoted 46 lines · Hervé Poussineau
Quoted 44 lines · Paolo Bonzini
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 35 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2Quoted 3 lines
It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location. Blue/Herve, can you look at
esp.c?
Quoted 8 lines
Quoted 3 lines
I just sent an email to ML to add stubs for
pci_default_read_configandpci_default_write_config. I compile-tested sparc-softmmu target and it works now well.Shouldn't Sparc consume pci.o?
If Sparc doesn't have PCI, then stubs don't seem like the right answer. If it has PCI, then it ought to use the generic code, no?
Only JavaStation had PCI, but we don't emulate that.
Probably the same approach as lance & pcnet could be used.
Quoted 10 lines
Regards,
Anthony Liguori
Quoted 4 lines
Hervé
[1]
Quoted 37 lines · Paolo Bonzini
Il 03/08/2012 21:27, Anthony Liguori ha scritto:
Quoted 36 lines · Paolo Bonzini
Quoted 13 lines
Anthony,
The following changes since commit
5e3bc7144edd6e4fa2824944e5eb16c28197dd5a:Merge remote-tracking branch 'mst/tags/for_anthony' into staging
(2012-07-30 10:00:48 -0500)are available in the git repository at:
git://github.com/bonzini/qemu.gitscsi-nextQuoted 7 lines
for you to fetch changes up to
b71760ef6180662cc2dff1f6cf673a53508c59f1:scsi: add support for
ATA_PASSTHROUGH_xxscsi command (2012-08-03
10:04:37 +0200)The main change here is re-enabling megasas, but there's also Herve's retro HBA and a couple of random fixes.
CC sparc-softmmu/target-sparc/mmu_helper.o CC sparc-softmmu/target-sparc/ldst_helper.o CC sparc-softmmu/target-sparc/int32_helper.o LINK sparc-softmmu/qemu-system-sparc
../libhw64/hw/esp.o: In function `dc390_read_config':/home/anthony/git/qemu/hw/esp.c:1220: undefined reference to `pci_default_read_config'../libhw64/hw/esp.o: In function `dc390_write_config':/home/anthony/git/qemu/hw/esp.c:1245: undefined reference to `pci_default_write_config'
collect2: ld returned 1 exit status
make[1]: *** [qemu-system-sparc] Error 1
make: *** [subdir-sparc-softmmu] Error 2
Quoted 8 lines
Quoted 3 lines
It looks like sparc does link in
esp.cbut doesn't support pci (at least pci.o). I must admit, it's not obvious to me whether pci.o should be added to the sparc build or whetheresp.cneeds to be refactored.I think the latter.
I removed this patch and pushed the rest (commit e4b6526) at the same location. Blue/Herve, can you look at
esp.c?
Pulled. Thanks.
Regards,
Anthony Liguori
Quoted 2 lines
Paolo