~ubuntu-branches/ubuntu/trusty/qemu/trusty

« back to all changes in this revision

Viewing changes to hw/ide/ahci.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2013-10-22 22:47:07 UTC
  • mfrom: (1.8.3) (10.1.42 sid)
  • Revision ID: package-import@ubuntu.com-20131022224707-1lya34fw3k3f24tv
Tags: 1.6.0+dfsg-2ubuntu1
* Merge 1.6.0~rc0+dfsg-2exp from debian experimental.  Remaining changes:
  - debian/control
    * update maintainer
    * remove libiscsi, usb-redir, vde, vnc-jpeg, and libssh2-1-dev
      from build-deps
    * enable rbd
    * add qemu-system and qemu-common B/R to qemu-keymaps
    * add D:udev, R:qemu, R:qemu-common and B:qemu-common to
      qemu-system-common
    * qemu-system-arm, qemu-system-ppc, qemu-system-sparc:
      - add qemu-kvm to Provides
      - add qemu-common, qemu-kvm, kvm to B/R
      - remove openbios-sparc from qemu-system-sparc D
      - drop openbios-ppc and openhackware Depends to Suggests (for now)
    * qemu-system-x86:
      - add qemu-common to Breaks/Replaces.
      - add cpu-checker to Recommends.
    * qemu-user: add B/R:qemu-kvm
    * qemu-kvm:
      - add armhf armel powerpc sparc to Architecture
      - C/R/P: qemu-kvm-spice
    * add qemu-common package
    * drop qemu-slof which is not packaged in ubuntu
  - add qemu-system-common.links for tap ifup/down scripts and OVMF link.
  - qemu-system-x86.links:
    * remove pxe rom links which are in kvm-ipxe
    * add symlink for kvm.1 manpage
  - debian/rules
    * add kvm-spice symlink to qemu-kvm
    * call dh_installmodules for qemu-system-x86
    * update dh_installinit to install upstart script
    * run dh_installman (Closes: #709241) (cherrypicked from 1.5.0+dfsg-2)
  - Add qemu-utils.links for kvm-* symlinks.
  - Add qemu-system-x86.qemu-kvm.upstart and .default
  - Add qemu-system-x86.modprobe to set nesting=1
  - Add qemu-system-common.preinst to add kvm group
  - qemu-system-common.postinst: remove bad group acl if there, then have
    udev relabel /dev/kvm.
  - New linaro patches from qemu-linaro rebasing branch
  - Dropped patches:
    * xen-simplify-xen_enabled.patch
    * sparc-linux-user-fix-missing-symbols-in-.rel-.rela.plt-sections.patch
    * main_loop-do-not-set-nonblocking-if-xen_enabled.patch
    * xen_machine_pv-do-not-create-a-dummy-CPU-in-machine-.patch
    * virtio-rng-fix-crash
  - Kept patches:
    * expose_vms_qemu64cpu.patch - updated
    * linaro arm patches from qemu-linaro rebasing branch
  - New patches:
    * fix-pci-add: change CONFIG variable in ifdef to make sure that
      pci_add is defined.
* Add linaro patches
* Add experimental mach-virt patches for arm virtualization.
* qemu-system-common.install: add debian/tmp/usr/lib to install the
  qemu-bridge-helper

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
 
118
118
static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev)
119
119
{
120
 
    struct AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
 
120
    AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
 
121
    PCIDevice *pci_dev = PCI_DEVICE(d);
121
122
 
122
123
    DPRINTF(0, "raise irq\n");
123
124
 
124
 
    if (msi_enabled(&d->card)) {
125
 
        msi_notify(&d->card, 0);
 
125
    if (msi_enabled(pci_dev)) {
 
126
        msi_notify(pci_dev, 0);
126
127
    } else {
127
128
        qemu_irq_raise(s->irq);
128
129
    }
130
131
 
131
132
static void ahci_irq_lower(AHCIState *s, AHCIDevice *dev)
132
133
{
133
 
    struct AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
 
134
    AHCIPCIState *d = container_of(s, AHCIPCIState, ahci);
134
135
 
135
136
    DPRINTF(0, "lower irq\n");
136
137
 
137
 
    if (!msi_enabled(&d->card)) {
 
138
    if (!msi_enabled(PCI_DEVICE(d))) {
138
139
        qemu_irq_lower(s->irq);
139
140
    }
140
141
}
597
598
    if (!cmd_fis) {
598
599
        /* map cmd_fis */
599
600
        uint64_t tbl_addr = le64_to_cpu(ad->cur_cmd->tbl_addr);
600
 
        cmd_fis = dma_memory_map(ad->hba->dma, tbl_addr, &cmd_len,
 
601
        cmd_fis = dma_memory_map(ad->hba->as, tbl_addr, &cmd_len,
601
602
                                 DMA_DIRECTION_TO_DEVICE);
602
603
        cmd_mapped = 1;
603
604
    }
630
631
    ahci_trigger_irq(ad->hba, ad, PORT_IRQ_D2H_REG_FIS);
631
632
 
632
633
    if (cmd_mapped) {
633
 
        dma_memory_unmap(ad->hba->dma, cmd_fis, cmd_len,
 
634
        dma_memory_unmap(ad->hba->as, cmd_fis, cmd_len,
634
635
                         DMA_DIRECTION_TO_DEVICE, cmd_len);
635
636
    }
636
637
}
650
651
    int off_idx = -1;
651
652
    int off_pos = -1;
652
653
    int tbl_entry_size;
 
654
    IDEBus *bus = &ad->port;
 
655
    BusState *qbus = BUS(bus);
653
656
 
654
657
    if (!sglist_alloc_hint) {
655
658
        DPRINTF(ad->port_no, "no sg list given by guest: 0x%08x\n", opts);
657
660
    }
658
661
 
659
662
    /* map PRDT */
660
 
    if (!(prdt = dma_memory_map(ad->hba->dma, prdt_addr, &prdt_len,
 
663
    if (!(prdt = dma_memory_map(ad->hba->as, prdt_addr, &prdt_len,
661
664
                                DMA_DIRECTION_TO_DEVICE))){
662
665
        DPRINTF(ad->port_no, "map failed\n");
663
666
        return -1;
691
694
            goto out;
692
695
        }
693
696
 
694
 
        qemu_sglist_init(sglist, (sglist_alloc_hint - off_idx), ad->hba->dma);
 
697
        qemu_sglist_init(sglist, qbus->parent, (sglist_alloc_hint - off_idx),
 
698
                         ad->hba->as);
695
699
        qemu_sglist_add(sglist, le64_to_cpu(tbl[off_idx].addr + off_pos),
696
700
                        le32_to_cpu(tbl[off_idx].flags_size) + 1 - off_pos);
697
701
 
703
707
    }
704
708
 
705
709
out:
706
 
    dma_memory_unmap(ad->hba->dma, prdt, prdt_len,
 
710
    dma_memory_unmap(ad->hba->as, prdt, prdt_len,
707
711
                     DMA_DIRECTION_TO_DEVICE, prdt_len);
708
712
    return r;
709
713
}
836
840
    tbl_addr = le64_to_cpu(cmd->tbl_addr);
837
841
 
838
842
    cmd_len = 0x80;
839
 
    cmd_fis = dma_memory_map(s->dma, tbl_addr, &cmd_len,
 
843
    cmd_fis = dma_memory_map(s->as, tbl_addr, &cmd_len,
840
844
                             DMA_DIRECTION_FROM_DEVICE);
841
845
 
842
846
    if (!cmd_fis) {
963
967
    }
964
968
 
965
969
out:
966
 
    dma_memory_unmap(s->dma, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
 
970
    dma_memory_unmap(s->as, cmd_fis, cmd_len, DMA_DIRECTION_FROM_DEVICE,
967
971
                     cmd_len);
968
972
 
969
973
    if (s->dev[port].port.ifs[0].status & (BUSY_STAT|DRQ_STAT)) {
1104
1108
 
1105
1109
static int ahci_dma_set_inactive(IDEDMA *dma)
1106
1110
{
 
1111
    return 0;
 
1112
}
 
1113
 
 
1114
static int ahci_async_cmd_done(IDEDMA *dma)
 
1115
{
1107
1116
    AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
1108
1117
 
1109
 
    DPRINTF(ad->port_no, "dma done\n");
 
1118
    DPRINTF(ad->port_no, "async cmd done\n");
1110
1119
 
1111
1120
    /* update d2h status */
1112
1121
    ahci_write_fis_d2h(ad, NULL);
1141
1150
    .set_unit = ahci_dma_set_unit,
1142
1151
    .add_status = ahci_dma_add_status,
1143
1152
    .set_inactive = ahci_dma_set_inactive,
 
1153
    .async_cmd_done = ahci_async_cmd_done,
1144
1154
    .restart_cb = ahci_dma_restart_cb,
1145
1155
    .reset = ahci_dma_reset,
1146
1156
};
1147
1157
 
1148
 
void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports)
 
1158
void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)
1149
1159
{
1150
1160
    qemu_irq *irqs;
1151
1161
    int i;
1152
1162
 
1153
 
    s->dma = dma;
 
1163
    s->as = as;
1154
1164
    s->ports = ports;
1155
1165
    s->dev = g_malloc0(sizeof(AHCIDevice) * ports);
1156
1166
    ahci_reg_init(s);
1157
1167
    /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */
1158
 
    memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", AHCI_MEM_BAR_SIZE);
1159
 
    memory_region_init_io(&s->idp, &ahci_idp_ops, s, "ahci-idp", 32);
 
1168
    memory_region_init_io(&s->mem, OBJECT(qdev), &ahci_mem_ops, s,
 
1169
                          "ahci", AHCI_MEM_BAR_SIZE);
 
1170
    memory_region_init_io(&s->idp, OBJECT(qdev), &ahci_idp_ops, s,
 
1171
                          "ahci-idp", 32);
1160
1172
 
1161
1173
    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);
1162
1174
 
1274
1286
    },
1275
1287
};
1276
1288
 
 
1289
#define TYPE_SYSBUS_AHCI "sysbus-ahci"
 
1290
#define SYSBUS_AHCI(obj) OBJECT_CHECK(SysbusAHCIState, (obj), TYPE_SYSBUS_AHCI)
 
1291
 
1277
1292
typedef struct SysbusAHCIState {
1278
 
    SysBusDevice busdev;
 
1293
    /*< private >*/
 
1294
    SysBusDevice parent_obj;
 
1295
    /*< public >*/
 
1296
 
1279
1297
    AHCIState ahci;
1280
1298
    uint32_t num_ports;
1281
1299
} SysbusAHCIState;
1291
1309
 
1292
1310
static void sysbus_ahci_reset(DeviceState *dev)
1293
1311
{
1294
 
    SysbusAHCIState *s = DO_UPCAST(SysbusAHCIState, busdev.qdev, dev);
 
1312
    SysbusAHCIState *s = SYSBUS_AHCI(dev);
1295
1313
 
1296
1314
    ahci_reset(&s->ahci);
1297
1315
}
1298
1316
 
1299
 
static int sysbus_ahci_init(SysBusDevice *dev)
 
1317
static void sysbus_ahci_realize(DeviceState *dev, Error **errp)
1300
1318
{
1301
 
    SysbusAHCIState *s = FROM_SYSBUS(SysbusAHCIState, dev);
1302
 
    ahci_init(&s->ahci, &dev->qdev, NULL, s->num_ports);
1303
 
 
1304
 
    sysbus_init_mmio(dev, &s->ahci.mem);
1305
 
    sysbus_init_irq(dev, &s->ahci.irq);
1306
 
    return 0;
 
1319
    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
 
1320
    SysbusAHCIState *s = SYSBUS_AHCI(dev);
 
1321
 
 
1322
    ahci_init(&s->ahci, dev, NULL, s->num_ports);
 
1323
 
 
1324
    sysbus_init_mmio(sbd, &s->ahci.mem);
 
1325
    sysbus_init_irq(sbd, &s->ahci.irq);
1307
1326
}
1308
1327
 
1309
1328
static Property sysbus_ahci_properties[] = {
1313
1332
 
1314
1333
static void sysbus_ahci_class_init(ObjectClass *klass, void *data)
1315
1334
{
1316
 
    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
1317
1335
    DeviceClass *dc = DEVICE_CLASS(klass);
1318
1336
 
1319
 
    sbc->init = sysbus_ahci_init;
 
1337
    dc->realize = sysbus_ahci_realize;
1320
1338
    dc->vmsd = &vmstate_sysbus_ahci;
1321
1339
    dc->props = sysbus_ahci_properties;
1322
1340
    dc->reset = sysbus_ahci_reset;
 
1341
    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
1323
1342
}
1324
1343
 
1325
1344
static const TypeInfo sysbus_ahci_info = {
1326
 
    .name          = "sysbus-ahci",
 
1345
    .name          = TYPE_SYSBUS_AHCI,
1327
1346
    .parent        = TYPE_SYS_BUS_DEVICE,
1328
1347
    .instance_size = sizeof(SysbusAHCIState),
1329
1348
    .class_init    = sysbus_ahci_class_init,