summaryrefslogtreecommitdiffstats
path: root/hw
diff options
context:
space:
mode:
Diffstat (limited to 'hw')
-rw-r--r--hw/alpha/Kconfig4
-rw-r--r--hw/alpha/alpha_sys.h4
-rw-r--r--hw/alpha/dp264.c59
-rw-r--r--hw/alpha/typhoon.c20
-rw-r--r--hw/core/machine.c132
-rw-r--r--hw/i386/pc.c108
-rw-r--r--hw/i386/x86.c15
-rw-r--r--hw/scsi/scsi-generic.c6
-rw-r--r--hw/usb/meson.build6
9 files changed, 194 insertions, 160 deletions
diff --git a/hw/alpha/Kconfig b/hw/alpha/Kconfig
index 15c59ff264..9af650c94e 100644
--- a/hw/alpha/Kconfig
+++ b/hw/alpha/Kconfig
@@ -3,9 +3,7 @@ config DP264
imply PCI_DEVICES
imply TEST_DEVICES
imply E1000_PCI
- select I82374
- select I8254
- select I8259
+ select I82378
select IDE_CMD646
select MC146818RTC
select PCI
diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h
index e2c02e2bbe..2263e821da 100644
--- a/hw/alpha/alpha_sys.h
+++ b/hw/alpha/alpha_sys.h
@@ -10,8 +10,8 @@
#include "hw/intc/i8259.h"
-PCIBus *typhoon_init(MemoryRegion *, ISABus **, qemu_irq *, AlphaCPU *[4],
- pci_map_irq_fn);
+PCIBus *typhoon_init(MemoryRegion *, qemu_irq *, qemu_irq *, AlphaCPU *[4],
+ pci_map_irq_fn, uint8_t devfn_min);
/* alpha_pci.c. */
extern const MemoryRegionOps alpha_pci_ignore_ops;
diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c
index 1017ecf330..c78ed96d0e 100644
--- a/hw/alpha/dp264.c
+++ b/hw/alpha/dp264.c
@@ -15,9 +15,7 @@
#include "qemu/error-report.h"
#include "hw/rtc/mc146818rtc.h"
#include "hw/ide/pci.h"
-#include "hw/timer/i8254.h"
#include "hw/isa/superio.h"
-#include "hw/dma/i8257.h"
#include "net/net.h"
#include "qemu/cutils.h"
#include "qemu/datadir.h"
@@ -58,8 +56,10 @@ static void clipper_init(MachineState *machine)
AlphaCPU *cpus[4];
PCIBus *pci_bus;
PCIDevice *pci_dev;
+ DeviceState *i82378_dev;
ISABus *isa_bus;
qemu_irq rtc_irq;
+ qemu_irq isa_irq;
long size, i;
char *palcode_filename;
uint64_t palcode_entry;
@@ -72,19 +72,57 @@ static void clipper_init(MachineState *machine)
cpus[i] = ALPHA_CPU(cpu_create(machine->cpu_type));
}
+ /*
+ * arg0 -> memory size
+ * arg1 -> kernel entry point
+ * arg2 -> config word
+ *
+ * Config word: bits 0-5 -> ncpus
+ * bit 6 -> nographics option (for HWRPB CTB)
+ *
+ * See init_hwrpb() in the PALcode.
+ */
cpus[0]->env.trap_arg0 = ram_size;
cpus[0]->env.trap_arg1 = 0;
- cpus[0]->env.trap_arg2 = smp_cpus;
-
- /* Init the chipset. */
- pci_bus = typhoon_init(machine->ram, &isa_bus, &rtc_irq, cpus,
- clipper_pci_map_irq);
+ cpus[0]->env.trap_arg2 = smp_cpus | (!machine->enable_graphics << 6);
+
+ /*
+ * Init the chipset. Because we're using CLIPPER IRQ mappings,
+ * the minimum PCI device IdSel is 1.
+ */
+ pci_bus = typhoon_init(machine->ram, &isa_irq, &rtc_irq, cpus,
+ clipper_pci_map_irq, PCI_DEVFN(1, 0));
+
+ /*
+ * Init the PCI -> ISA bridge.
+ *
+ * Technically, PCI-based Alphas shipped with one of three different
+ * PCI-ISA bridges:
+ *
+ * - Intel i82378 SIO
+ * - Cypress CY82c693UB
+ * - ALI M1533
+ *
+ * (An Intel i82375 PCI-EISA bridge was also used on some models.)
+ *
+ * For simplicity, we model an i82378 here, even though it wouldn't
+ * have been on any Tsunami/Typhoon systems; it's close enough, and
+ * we don't want to deal with modelling the CY82c693UB (which has
+ * incompatible edge/level control registers, plus other peripherals
+ * like IDE and USB) or the M1533 (which also has IDE and USB).
+ *
+ * Importantly, we need to provide a PCI device node for it, otherwise
+ * some operating systems won't notice there's an ISA bus to configure.
+ */
+ i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(7, 0), "i82378"));
+ isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
+
+ /* Connect the ISA PIC to the Typhoon IRQ used for ISA interrupts. */
+ qdev_connect_gpio_out(i82378_dev, 0, isa_irq);
/* Since we have an SRM-compatible PALcode, use the SRM epoch. */
mc146818_rtc_init(isa_bus, 1900, rtc_irq);
- i8254_pit_init(isa_bus, 0x40, 0, NULL);
-
/* VGA setup. Don't bother loading the bios. */
pci_vga_init(pci_bus);
@@ -93,9 +131,6 @@ static void clipper_init(MachineState *machine)
pci_nic_init_nofail(&nd_table[i], pci_bus, "e1000", NULL);
}
- /* 2 82C37 (dma) */
- isa_create_simple(isa_bus, "i82374");
-
/* Super I/O */
isa_create_simple(isa_bus, TYPE_SMC37C669_SUPERIO);
diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c
index 87020cbe0d..bd39c8ca86 100644
--- a/hw/alpha/typhoon.c
+++ b/hw/alpha/typhoon.c
@@ -814,8 +814,9 @@ static void typhoon_alarm_timer(void *opaque)
cpu_interrupt(CPU(s->cchip.cpu[cpu]), CPU_INTERRUPT_TIMER);
}
-PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_irq,
- AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq)
+PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq,
+ qemu_irq *p_rtc_irq, AlphaCPU *cpus[4],
+ pci_map_irq_fn sys_map_irq, uint8_t devfn_min)
{
MemoryRegion *addr_space = get_system_memory();
DeviceState *dev;
@@ -843,6 +844,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_irq,
}
}
+ *p_isa_irq = qemu_allocate_irq(typhoon_set_isa_irq, s, 0);
*p_rtc_irq = qemu_allocate_irq(typhoon_set_timer_irq, s, 0);
/* Main memory region, 0x00.0000.0000. Real hardware supports 32GB,
@@ -885,7 +887,7 @@ PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_irq,
b = pci_register_root_bus(dev, "pci",
typhoon_set_irq, sys_map_irq, s,
&s->pchip.reg_mem, &s->pchip.reg_io,
- 0, 64, TYPE_PCI_BUS);
+ devfn_min, 64, TYPE_PCI_BUS);
phb->bus = b;
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
@@ -918,18 +920,6 @@ PCIBus *typhoon_init(MemoryRegion *ram, ISABus **isa_bus, qemu_irq *p_rtc_irq,
/* Pchip1 PCI I/O, 0x802.FC00.0000, 32MB. */
/* Pchip1 PCI configuration, 0x802.FE00.0000, 16MB. */
- /* Init the ISA bus. */
- /* ??? Technically there should be a cy82c693ub pci-isa bridge. */
- {
- qemu_irq *isa_irqs;
-
- *isa_bus = isa_bus_new(NULL, get_system_memory(), &s->pchip.reg_io,
- &error_abort);
- isa_irqs = i8259_init(*isa_bus,
- qemu_allocate_irq(typhoon_set_isa_irq, s, 0));
- isa_bus_irqs(*isa_bus, isa_irqs);
- }
-
return b;
}
diff --git a/hw/core/machine.c b/hw/core/machine.c
index d0e9348888..ca69f0343a 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -740,69 +740,63 @@ void machine_set_cpu_numa_node(MachineState *machine,
}
}
-static void smp_parse(MachineState *ms, QemuOpts *opts)
+static void smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp)
{
- if (opts) {
- unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
- unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
- unsigned cores = qemu_opt_get_number(opts, "cores", 0);
- unsigned threads = qemu_opt_get_number(opts, "threads", 0);
-
- /* compute missing values, prefer sockets over cores over threads */
- if (cpus == 0 || sockets == 0) {
- cores = cores > 0 ? cores : 1;
- threads = threads > 0 ? threads : 1;
- if (cpus == 0) {
- sockets = sockets > 0 ? sockets : 1;
- cpus = cores * threads * sockets;
- } else {
- ms->smp.max_cpus =
- qemu_opt_get_number(opts, "maxcpus", cpus);
- sockets = ms->smp.max_cpus / (cores * threads);
- }
- } else if (cores == 0) {
- threads = threads > 0 ? threads : 1;
- cores = cpus / (sockets * threads);
- cores = cores > 0 ? cores : 1;
- } else if (threads == 0) {
- threads = cpus / (cores * sockets);
- threads = threads > 0 ? threads : 1;
- } else if (sockets * cores * threads < cpus) {
- error_report("cpu topology: "
- "sockets (%u) * cores (%u) * threads (%u) < "
- "smp_cpus (%u)",
- sockets, cores, threads, cpus);
- exit(1);
- }
+ unsigned cpus = config->has_cpus ? config->cpus : 0;
+ unsigned sockets = config->has_sockets ? config->sockets : 0;
+ unsigned cores = config->has_cores ? config->cores : 0;
+ unsigned threads = config->has_threads ? config->threads : 0;
- ms->smp.max_cpus =
- qemu_opt_get_number(opts, "maxcpus", cpus);
+ if (config->has_dies && config->dies != 0 && config->dies != 1) {
+ error_setg(errp, "dies not supported by this machine's CPU topology");
+ }
- if (ms->smp.max_cpus < cpus) {
- error_report("maxcpus must be equal to or greater than smp");
- exit(1);
+ /* compute missing values, prefer sockets over cores over threads */
+ if (cpus == 0 || sockets == 0) {
+ cores = cores > 0 ? cores : 1;
+ threads = threads > 0 ? threads : 1;
+ if (cpus == 0) {
+ sockets = sockets > 0 ? sockets : 1;
+ cpus = cores * threads * sockets;
+ } else {
+ ms->smp.max_cpus = config->has_maxcpus ? config->maxcpus : cpus;
+ sockets = ms->smp.max_cpus / (cores * threads);
}
+ } else if (cores == 0) {
+ threads = threads > 0 ? threads : 1;
+ cores = cpus / (sockets * threads);
+ cores = cores > 0 ? cores : 1;
+ } else if (threads == 0) {
+ threads = cpus / (cores * sockets);
+ threads = threads > 0 ? threads : 1;
+ } else if (sockets * cores * threads < cpus) {
+ error_setg(errp, "cpu topology: "
+ "sockets (%u) * cores (%u) * threads (%u) < "
+ "smp_cpus (%u)",
+ sockets, cores, threads, cpus);
+ return;
+ }
- if (sockets * cores * threads != ms->smp.max_cpus) {
- error_report("Invalid CPU topology: "
- "sockets (%u) * cores (%u) * threads (%u) "
- "!= maxcpus (%u)",
- sockets, cores, threads,
- ms->smp.max_cpus);
- exit(1);
- }
+ ms->smp.max_cpus = config->has_maxcpus ? config->maxcpus : cpus;
- ms->smp.cpus = cpus;
- ms->smp.cores = cores;
- ms->smp.threads = threads;
- ms->smp.sockets = sockets;
+ if (ms->smp.max_cpus < cpus) {
+ error_setg(errp, "maxcpus must be equal to or greater than smp");
+ return;
}
- if (ms->smp.cpus > 1) {
- Error *blocker = NULL;
- error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
- replay_add_blocker(blocker);
+ if (sockets * cores * threads != ms->smp.max_cpus) {
+ error_setg(errp, "Invalid CPU topology: "
+ "sockets (%u) * cores (%u) * threads (%u) "
+ "!= maxcpus (%u)",
+ sockets, cores, threads,
+ ms->smp.max_cpus);
+ return;
}
+
+ ms->smp.cpus = cpus;
+ ms->smp.cores = cores;
+ ms->smp.threads = threads;
+ ms->smp.sockets = sockets;
}
static void machine_class_init(ObjectClass *oc, void *data)
@@ -971,6 +965,7 @@ static void machine_initfn(Object *obj)
ms->smp.cpus = mc->default_cpus;
ms->smp.max_cpus = mc->default_cpus;
ms->smp.cores = 1;
+ ms->smp.dies = 1;
ms->smp.threads = 1;
ms->smp.sockets = 1;
}
@@ -1134,8 +1129,29 @@ MemoryRegion *machine_consume_memdev(MachineState *machine,
bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
{
MachineClass *mc = MACHINE_GET_CLASS(ms);
+ ERRP_GUARD();
- mc->smp_parse(ms, opts);
+ if (opts) {
+ SMPConfiguration config = {
+ .has_cpus = !!qemu_opt_get(opts, "cpus"),
+ .cpus = qemu_opt_get_number(opts, "cpus", 0),
+ .has_sockets = !!qemu_opt_get(opts, "sockets"),
+ .sockets = qemu_opt_get_number(opts, "sockets", 0),
+ .has_dies = !!qemu_opt_get(opts, "dies"),
+ .dies = qemu_opt_get_number(opts, "dies", 0),
+ .has_cores = !!qemu_opt_get(opts, "cores"),
+ .cores = qemu_opt_get_number(opts, "cores", 0),
+ .has_threads = !!qemu_opt_get(opts, "threads"),
+ .threads = qemu_opt_get_number(opts, "threads", 0),
+ .has_maxcpus = !!qemu_opt_get(opts, "maxcpus"),
+ .maxcpus = qemu_opt_get_number(opts, "maxcpus", 0),
+ };
+
+ mc->smp_parse(ms, &config, errp);
+ if (*errp) {
+ return false;
+ }
+ }
/* sanity-check smp_cpus and max_cpus against mc */
if (ms->smp.cpus < mc->min_cpus) {
@@ -1151,6 +1167,12 @@ bool machine_smp_parse(MachineState *ms, QemuOpts *opts, Error **errp)
mc->name, mc->max_cpus);
return false;
}
+
+ if (ms->smp.cpus > 1) {
+ Error *blocker = NULL;
+ error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
+ replay_add_blocker(blocker);
+ }
return true;
}
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index c6d8d0d84d..8e1220db72 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -710,73 +710,61 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level)
* This function is very similar to smp_parse()
* in hw/core/machine.c but includes CPU die support.
*/
-void pc_smp_parse(MachineState *ms, QemuOpts *opts)
+static void pc_smp_parse(MachineState *ms, SMPConfiguration *config, Error **errp)
{
- X86MachineState *x86ms = X86_MACHINE(ms);
-
- if (opts) {
- unsigned cpus = qemu_opt_get_number(opts, "cpus", 0);
- unsigned sockets = qemu_opt_get_number(opts, "sockets", 0);
- unsigned dies = qemu_opt_get_number(opts, "dies", 1);
- unsigned cores = qemu_opt_get_number(opts, "cores", 0);
- unsigned threads = qemu_opt_get_number(opts, "threads", 0);
-
- /* compute missing values, prefer sockets over cores over threads */
- if (cpus == 0 || sockets == 0) {
- cores = cores > 0 ? cores : 1;
- threads = threads > 0 ? threads : 1;
- if (cpus == 0) {
- sockets = sockets > 0 ? sockets : 1;
- cpus = cores * threads * dies * sockets;
- } else {
- ms->smp.max_cpus =
- qemu_opt_get_number(opts, "maxcpus", cpus);
- sockets = ms->smp.max_cpus / (cores * threads * dies);
- }
- } else if (cores == 0) {
- threads = threads > 0 ? threads : 1;
- cores = cpus / (sockets * dies * threads);
- cores = cores > 0 ? cores : 1;
- } else if (threads == 0) {
- threads = cpus / (cores * dies * sockets);
- threads = threads > 0 ? threads : 1;
- } else if (sockets * dies * cores * threads < cpus) {
- error_report("cpu topology: "
- "sockets (%u) * dies (%u) * cores (%u) * threads (%u) < "
- "smp_cpus (%u)",
- sockets, dies, cores, threads, cpus);
- exit(1);
- }
-
- ms->smp.max_cpus =
- qemu_opt_get_number(opts, "maxcpus", cpus);
-
- if (ms->smp.max_cpus < cpus) {
- error_report("maxcpus must be equal to or greater than smp");
- exit(1);
+ unsigned cpus = config->has_cpus ? config->cpus : 0;
+ unsigned sockets = config->has_sockets ? config->sockets : 0;
+ unsigned dies = config->has_dies ? config->dies : 1;
+ unsigned cores = config->has_cores ? config->cores : 0;
+ unsigned threads = config->has_threads ? config->threads : 0;
+
+ /* compute missing values, prefer sockets over cores over threads */
+ if (cpus == 0 || sockets == 0) {
+ cores = cores > 0 ? cores : 1;
+ threads = threads > 0 ? threads : 1;
+ if (cpus == 0) {
+ sockets = sockets > 0 ? sockets : 1;
+ cpus = cores * threads * dies * sockets;
+ } else {
+ ms->smp.max_cpus = config->has_maxcpus ? config->maxcpus : cpus;
+ sockets = ms->smp.max_cpus / (cores * threads * dies);
}
+ } else if (cores == 0) {
+ threads = threads > 0 ? threads : 1;
+ cores = cpus / (sockets * dies * threads);
+ cores = cores > 0 ? cores : 1;
+ } else if (threads == 0) {
+ threads = cpus / (cores * dies * sockets);
+ threads = threads > 0 ? threads : 1;
+ } else if (sockets * dies * cores * threads < cpus) {
+ error_setg(errp, "cpu topology: "
+ "sockets (%u) * dies (%u) * cores (%u) * threads (%u) < "
+ "smp_cpus (%u)",
+ sockets, dies, cores, threads, cpus);
+ return;
+ }
- if (sockets * dies * cores * threads != ms->smp.max_cpus) {
- error_report("Invalid CPU topology deprecated: "
- "sockets (%u) * dies (%u) * cores (%u) * threads (%u) "
- "!= maxcpus (%u)",
- sockets, dies, cores, threads,
- ms->smp.max_cpus);
- exit(1);
- }
+ ms->smp.max_cpus = config->has_maxcpus ? config->maxcpus : cpus;
- ms->smp.cpus = cpus;
- ms->smp.cores = cores;
- ms->smp.threads = threads;
- ms->smp.sockets = sockets;
- x86ms->smp_dies = dies;
+ if (ms->smp.max_cpus < cpus) {
+ error_setg(errp, "maxcpus must be equal to or greater than smp");
+ return;
}
- if (ms->smp.cpus > 1) {
- Error *blocker = NULL;
- error_setg(&blocker, QERR_REPLAY_NOT_SUPPORTED, "smp");
- replay_add_blocker(blocker);
+ if (sockets * dies * cores * threads != ms->smp.max_cpus) {
+ error_setg(errp, "Invalid CPU topology deprecated: "
+ "sockets (%u) * dies (%u) * cores (%u) * threads (%u) "
+ "!= maxcpus (%u)",
+ sockets, dies, cores, threads,
+ ms->smp.max_cpus);
+ return;
}
+
+ ms->smp.cpus = cpus;
+ ms->smp.cores = cores;
+ ms->smp.threads = threads;
+ ms->smp.sockets = sockets;
+ ms->smp.dies = dies;
}
static
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index d30cf27e29..00448ed55a 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -64,7 +64,7 @@ inline void init_topo_info(X86CPUTopoInfo *topo_info,
{
MachineState *ms = MACHINE(x86ms);
- topo_info->dies_per_pkg = x86ms->smp_dies;
+ topo_info->dies_per_pkg = ms->smp.dies;
topo_info->cores_per_die = ms->smp.cores;
topo_info->threads_per_core = ms->smp.threads;
}
@@ -293,7 +293,7 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
init_topo_info(&topo_info, x86ms);
- env->nr_dies = x86ms->smp_dies;
+ env->nr_dies = ms->smp.dies;
/*
* If APIC ID is not set,
@@ -301,13 +301,13 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
*/
if (cpu->apic_id == UNASSIGNED_APIC_ID) {
int max_socket = (ms->smp.max_cpus - 1) /
- smp_threads / smp_cores / x86ms->smp_dies;
+ smp_threads / smp_cores / ms->smp.dies;
/*
* die-id was optional in QEMU 4.0 and older, so keep it optional
* if there's only one die per socket.
*/
- if (cpu->die_id < 0 && x86ms->smp_dies == 1) {
+ if (cpu->die_id < 0 && ms->smp.dies == 1) {
cpu->die_id = 0;
}
@@ -322,9 +322,9 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev,
if (cpu->die_id < 0) {
error_setg(errp, "CPU die-id is not set");
return;
- } else if (cpu->die_id > x86ms->smp_dies - 1) {
+ } else if (cpu->die_id > ms->smp.dies - 1) {
error_setg(errp, "Invalid CPU die-id: %u must be in range 0:%u",
- cpu->die_id, x86ms->smp_dies - 1);
+ cpu->die_id, ms->smp.dies - 1);
return;
}
if (cpu->core_id < 0) {
@@ -477,7 +477,7 @@ const CPUArchIdList *x86_possible_cpu_arch_ids(MachineState *ms)
&topo_info, &topo_ids);
ms->possible_cpus->cpus[i].props.has_socket_id = true;
ms->possible_cpus->cpus[i].props.socket_id = topo_ids.pkg_id;
- if (x86ms->smp_dies > 1) {
+ if (ms->smp.dies > 1) {
ms->possible_cpus->cpus[i].props.has_die_id = true;
ms->possible_cpus->cpus[i].props.die_id = topo_ids.die_id;
}
@@ -1269,7 +1269,6 @@ static void x86_machine_initfn(Object *obj)
x86ms->smm = ON_OFF_AUTO_AUTO;
x86ms->acpi = ON_OFF_AUTO_AUTO;
- x86ms->smp_dies = 1;
x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
x86ms->oem_id = g_strndup(ACPI_BUILD_APPNAME6, 6);
x86ms->oem_table_id = g_strndup(ACPI_BUILD_APPNAME8, 8);
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 40e039864f..665baf900e 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -179,10 +179,12 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
(r->req.cmd.buf[1] & 0x01)) {
page = r->req.cmd.buf[2];
if (page == 0xb0) {
- uint32_t max_transfer =
- blk_get_max_transfer(s->conf.blk) / s->blocksize;
+ uint64_t max_transfer = blk_get_max_hw_transfer(s->conf.blk);
+ uint32_t max_iov = blk_get_max_iov(s->conf.blk);
assert(max_transfer);
+ max_transfer = MIN_NON_ZERO(max_transfer, max_iov * qemu_real_host_page_size)
+ / s->blocksize;
stl_be_p(&r->buf[8], max_transfer);
/* Also take care of the opt xfer len. */
stl_be_p(&r->buf[12],
diff --git a/hw/usb/meson.build b/hw/usb/meson.build
index f357270d0b..4f24b5274d 100644
--- a/hw/usb/meson.build
+++ b/hw/usb/meson.build
@@ -49,7 +49,7 @@ softmmu_ss.add(when: ['CONFIG_POSIX', 'CONFIG_USB_STORAGE_MTP'], if_true: files(
# smartcard
softmmu_ss.add(when: 'CONFIG_USB_SMARTCARD', if_true: files('dev-smartcard-reader.c'))
-if config_host.has_key('CONFIG_SMARTCARD')
+if cacard.found()
usbsmartcard_ss = ss.source_set()
usbsmartcard_ss.add(when: 'CONFIG_USB_SMARTCARD',
if_true: [cacard, files('ccid-card-emulated.c', 'ccid-card-passthru.c')])
@@ -64,7 +64,7 @@ if u2f.found()
endif
# usb redirect
-if config_host.has_key('CONFIG_USB_REDIR')
+if usbredir.found()
usbredir_ss = ss.source_set()
usbredir_ss.add(when: 'CONFIG_USB',
if_true: [usbredir, files('redirect.c', 'quirks.c')])
@@ -72,7 +72,7 @@ if config_host.has_key('CONFIG_USB_REDIR')
endif
# usb pass-through
-softmmu_ss.add(when: ['CONFIG_USB', 'CONFIG_USB_LIBUSB', libusb],
+softmmu_ss.add(when: ['CONFIG_USB', libusb],
if_true: files('host-libusb.c'),
if_false: files('host-stub.c'))
softmmu_ss.add(when: 'CONFIG_ALL', if_true: files('host-stub.c'))