Skip to content

Commit

Permalink
Merge remote-tracking branch 'bonzini/scsi-next' into staging
Browse files Browse the repository at this point in the history
# By Hervé Poussineau (5) and Stefan Weil (1)
# Via Paolo Bonzini
* bonzini/scsi-next:
  block/iscsi: Drop iscsi_co_get_block_status for older versions of libiscsi
  lsi: add 53C810 variant
  lsi: remove todo
  lsi: ignore write accesses to CTEST0 registers
  lsi: check ssid versus sdid only if ssid is valid
  lsi: use constant name instead of its value
  • Loading branch information
aliguori committed Sep 23, 2013
2 parents 2571f8f + f35c934 commit f3ca508
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
6 changes: 6 additions & 0 deletions block/iscsi.c
Expand Up @@ -811,6 +811,8 @@ iscsi_getlength(BlockDriverState *bs)
return len;
}

#if defined(SCSI_PROVISIONING_TYPE_DEALLOCATED)

static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, int *pnum)
Expand Down Expand Up @@ -901,6 +903,8 @@ static int64_t coroutine_fn iscsi_co_get_block_status(BlockDriverState *bs,
return ret;
}

#endif /* SCSI_PROVISIONING_TYPE_DEALLOCATED */

static int
coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
Expand Down Expand Up @@ -1524,7 +1528,9 @@ static BlockDriver bdrv_iscsi = {
.bdrv_getlength = iscsi_getlength,
.bdrv_truncate = iscsi_truncate,

#if defined(SCSI_PROVISIONING_TYPE_DEALLOCATED)
.bdrv_co_get_block_status = iscsi_co_get_block_status,
#endif
.bdrv_co_discard = iscsi_co_discard,

.bdrv_aio_readv = iscsi_aio_readv,
Expand Down
32 changes: 27 additions & 5 deletions hw/scsi/lsi53c895a.c
Expand Up @@ -7,8 +7,11 @@
* This code is licensed under the LGPL.
*/

/* ??? Need to check if the {read,write}[wl] routines work properly on
big-endian targets. */
/* Note:
* LSI53C810 emulation is incorrect, in the sense that it supports
* features added in later evolutions. This should not be a problem,
* as well-behaved operating systems will not try to use them.
*/

#include <assert.h>

Expand Down Expand Up @@ -278,6 +281,7 @@ typedef struct {
uint32_t script_ram[2048];
} LSIState;

#define TYPE_LSI53C810 "lsi53c810"
#define TYPE_LSI53C895A "lsi53c895a"

#define LSI53C895A(obj) \
Expand Down Expand Up @@ -1515,7 +1519,7 @@ static uint8_t lsi_reg_readb(LSIState *s, int offset)
used for diagnostics, so should be ok. */
return 0;
case 0xc: /* DSTAT */
tmp = s->dstat | 0x80;
tmp = s->dstat | LSI_DSTAT_DFE;
if ((s->istat0 & LSI_ISTAT0_INTF) == 0)
s->dstat = 0;
lsi_update_irq(s);
Expand Down Expand Up @@ -1699,8 +1703,9 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
s->sxfer = val;
break;
case 0x06: /* SDID */
if ((val & 0xf) != (s->ssid & 0xf))
if ((s->ssid & 0x80) && (val & 0xf) != (s->ssid & 0xf)) {
BADF("Destination ID does not match SSID\n");
}
s->sdid = val & 0xf;
break;
case 0x07: /* GPREG0 */
Expand Down Expand Up @@ -1742,6 +1747,9 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val)
case 0x17: /* MBOX1 */
s->mbox1 = val;
break;
case 0x18: /* CTEST0 */
/* nothing to do */
break;
case 0x1a: /* CTEST2 */
s->ctest2 = val & LSI_CTEST2_PCICIE;
break;
Expand Down Expand Up @@ -2106,7 +2114,7 @@ static int lsi_scsi_init(PCIDevice *dev)
"lsi-io", 256);

pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io_io);
pci_register_bar(dev, 1, 0, &s->mmio_io);
pci_register_bar(dev, 1, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->mmio_io);
pci_register_bar(dev, 2, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->ram_io);
QTAILQ_INIT(&s->queue);

Expand Down Expand Up @@ -2144,9 +2152,23 @@ static const TypeInfo lsi_info = {
.class_init = lsi_class_init,
};

static void lsi53c810_class_init(ObjectClass *klass, void *data)
{
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);

k->device_id = PCI_DEVICE_ID_LSI_53C810;
}

static TypeInfo lsi53c810_info = {
.name = TYPE_LSI53C810,
.parent = TYPE_LSI53C895A,
.class_init = lsi53c810_class_init,
};

static void lsi53c895a_register_types(void)
{
type_register_static(&lsi_info);
type_register_static(&lsi53c810_info);
}

type_init(lsi53c895a_register_types)
1 change: 1 addition & 0 deletions include/hw/pci/pci_ids.h
Expand Up @@ -53,6 +53,7 @@
/* Vendors and devices. Sort key: vendor first, device next. */

#define PCI_VENDOR_ID_LSI_LOGIC 0x1000
#define PCI_DEVICE_ID_LSI_53C810 0x0001
#define PCI_DEVICE_ID_LSI_53C895A 0x0012
#define PCI_DEVICE_ID_LSI_SAS1078 0x0060

Expand Down

0 comments on commit f3ca508

Please sign in to comment.