aspeed: extensions and fixes
v2 cover aspeed: extensions and fixes
Hi,
Here is a short series adding :
- a new eMMC controller model for the AST2600 SoC (Andrew)
- accessors to control the led state of the pca9552 device (Joel)
- a 'execute-in-place' property to boot directly from CE0
Thanks,
C.
Changes since v1:
- removed ternary operator from sdhci_attach_drive()
- changed object name to "emmc"
Andrew Jeffery (2):
hw/sd: Configure number of slots exposed by the ASPEED SDHCI model hw/arm: ast2600: Wire up the eMMC controller
Cédric Le Goater (2):
ftgmac100: check RX and TX buffer alignment
hw/arm/aspeed: add a 'execute-in-place' property to boot directly from
CE0
Joel Stanley (1):
misc/pca9552: Add qom set and get
include/hw/arm/aspeed.h | 2 + include/hw/arm/aspeed_soc.h | 2 + include/hw/sd/aspeed_sdhci.h | 1 + hw/arm/aspeed.c | 72 +++++++++++++++++++++++------ hw/arm/aspeed_ast2600.c | 23 +++++++++ hw/arm/aspeed_soc.c | 2 + hw/misc/pca9552.c | 90 ++++++++++++++++++++++++++++++++++++ hw/net/ftgmac100.c | 13 ++++++ hw/sd/aspeed_sdhci.c | 11 ++++- 9 files changed, 199 insertions(+), 17 deletions(-)
Signature · 1 line
2.21.1
PATCH v2 1/5 hw/sd: Configure number of slots exposed by the ASPEED SDHCI model
From: Andrew Jeffery <[email protected]>
The AST2600 includes a second cut-down version of the SD/MMC controller found in the AST2500, named the eMMC controller. It's cut down in the sense that it only supports one slot rather than two, but it brings the total number of slots supported by the AST2600 to three.
The existing code assumed that the SD controller always provided two slots. Rework the SDHCI object to expose the number of slots as a property to be set by the SoC configuration.
--- include/hw/sd/aspeed_sdhci.h | 1 + hw/arm/aspeed.c | 2 +- hw/arm/aspeed_ast2600.c | 2 ++ hw/arm/aspeed_soc.c | 2 ++ hw/sd/aspeed_sdhci.c | 11 +++++++++-- 5 files changed, 15 insertions(+), 3 deletions(-)
include/hw/sd/aspeed_sdhci.h +1 -0
@@ -24,6 +24,7 @@ typedef struct AspeedSDHCIState {SysBusDevice parent;SDHCIState slots[ASPEED_SDHCI_NUM_SLOTS ]; +uint8_t num_slots;MemoryRegion iomem;qemu_irq irq;
hw/arm/aspeed.c +1 -1
@@ -263,7 +263,7 @@ static void aspeed_machine_init(MachineState *machine) amc->i2c_init (bmc); } -for (i =0 ; i <ARRAY_SIZE (bmc->soc.sdhci.slots); i++) { +for (i =0 ; i < bmc->soc.sdhci.num_slots; i++) {SDHCIState *sdhci = &bmc->soc.sdhci.slots[i];DriveInfo *dinfo =drive_get_next (IF_SD );BlockBackend *blk;
hw/arm/aspeed_ast2600.c +2 -0
@@ -199,6 +199,8 @@ static void aspeed_soc_ast2600_init(Object *obj)sysbus_init_child_obj (obj,"sdc" ,OBJECT (&s->sdhci),sizeof (s->sdhci),TYPE_ASPEED_SDHCI ); +object_property_set_int (OBJECT (&s->sdhci),2 ,"num-slots" , &error_abort); +/* Init sd card slot class here so that they're under the correct parent */ for (i =0 ; i <ASPEED_SDHCI_NUM_SLOTS ; ++i) { sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
hw/arm/aspeed_soc.c +2 -0
@@ -209,6 +209,8 @@ static void aspeed_soc_init(Object *obj)sysbus_init_child_obj (obj,"sdc" ,OBJECT (&s->sdhci),sizeof (s->sdhci),TYPE_ASPEED_SDHCI ); +object_property_set_int (OBJECT (&s->sdhci),2 ,"num-slots" , &error_abort); +/* Init sd card slot class here so that they're under the correct parent */ for (i =0 ; i <ASPEED_SDHCI_NUM_SLOTS ; ++i) { sysbus_init_child_obj(obj, "sdhci[*]", OBJECT(&s->sdhci.slots[i]),
hw/sd/aspeed_sdhci.c +9 -2
@@ -13,6 +13,7 @@#include "qapi/error.h" #include "hw/irq.h" #include "migration/vmstate.h" +#include "hw/qdev-properties.h" #define ASPEED_SDHCI_INFO 0x00#define ASPEED_SDHCI_INFO_RESET 0x00030000
@@ -120,14 +121,14 @@ static void aspeed_sdhci_realize(DeviceState *dev, Error **errp)/* Create input irqs for the slots */ qdev_init_gpio_in_named_with_opaque (DEVICE (sbd), aspeed_sdhci_set_irq, - sdhci,NULL ,ASPEED_SDHCI_NUM_SLOTS ); + sdhci,NULL , sdhci->num_slots);sysbus_init_irq (sbd, &sdhci->irq);memory_region_init_io (&sdhci->iomem,OBJECT (sdhci), &aspeed_sdhci_ops, sdhci,TYPE_ASPEED_SDHCI ,0x1000 );sysbus_init_mmio (sbd, &sdhci->iomem); -for (int i =0 ; i <ASPEED_SDHCI_NUM_SLOTS ; ++i) { +for (int i =0 ; i < sdhci->num_slots; ++i) {Object *sdhci_slot =OBJECT (&sdhci->slots[i]);SysBusDevice *sbd_slot =SYS_BUS_DEVICE (&sdhci->slots[i]);
@@ -174,6 +175,11 @@ static const VMStateDescription vmstate_aspeed_sdhci = { }, }; +static Property aspeed_sdhci_properties[] = { +DEFINE_PROP_UINT8 ("num-slots" , AspeedSDHCIState, num_slots,0 ), +DEFINE_PROP_END_OF_LIST (), +}; +static void aspeed_sdhci_class_init (ObjectClass *classp,void *data) {DeviceClass *dc =DEVICE_CLASS (classp);
@@ -181,6 +187,7 @@ static void aspeed_sdhci_class_init(ObjectClass *classp, void *data) dc->realize = aspeed_sdhci_realize; dc->reset = aspeed_sdhci_reset; dc->vmsd = &vmstate_aspeed_sdhci; + dc->props = aspeed_sdhci_properties; }static TypeInfo aspeed_sdhci_info = {
Signature · 1 line
2.21.1
PATCH v2 2/5 hw/arm: ast2600: Wire up the eMMC controller
In reply to Cédric Le GoaterFrom: Andrew Jeffery <[email protected]>
Initialise another SDHCI model instance for the AST2600's eMMC controller and use the SDHCI's num_slots value introduced previously to determine whether we should create an SD card instance for the new slot.
[ clg : - removed ternary operator from sdhci_attach_drive()
- changed object name to "emmc" ]
--- include/hw/arm/aspeed_soc.h | 2 ++ hw/arm/aspeed.c | 26 +++++++++++++++++--------- hw/arm/aspeed_ast2600.c | 21 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 9 deletions(-)
include/hw/arm/aspeed_soc.h +2 -0
@@ -57,6 +57,7 @@ typedef struct AspeedSoCState {AspeedGPIOState gpio;AspeedGPIOState gpio_1_8v;AspeedSDHCIState sdhci; +AspeedSDHCIState emmc; } AspeedSoCState;#define TYPE_ASPEED_SOC "aspeed-soc"
@@ -126,6 +127,7 @@ enum {ASPEED_MII4 ,ASPEED_SDRAM ,ASPEED_XDMA , + ASPEED_EMMC, };#endif /* ASPEED_SOC_H */
hw/arm/aspeed.c +17 -9
@@ -171,6 +171,19 @@ static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, } } +static void sdhci_attach_drive (SDHCIState *sdhci,DriveInfo *dinfo) +{ +DeviceState *card; + + card =qdev_create (qdev_get_child_bus (DEVICE (sdhci),"sd-bus" ), +TYPE_SD_CARD ); +if (dinfo) { +qdev_prop_set_drive (card,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); + } +object_property_set_bool (OBJECT (card), true,"realized" , &error_fatal); +} +static void aspeed_machine_init (MachineState *machine) {AspeedBoardState *bmc;
@@ -264,16 +277,11 @@ static void aspeed_machine_init(MachineState *machine) }for (i =0 ; i < bmc->soc.sdhci.num_slots; i++) { -SDHCIState *sdhci = &bmc->soc.sdhci.slots[i]; -DriveInfo *dinfo =drive_get_next (IF_SD ); -BlockBackend *blk; -DeviceState *card; +sdhci_attach_drive (&bmc->soc.sdhci.slots[i],drive_get_next (IF_SD )); + } - blk = dinfo ?blk_by_legacy_dinfo (dinfo) :NULL ; - card =qdev_create (qdev_get_child_bus (DEVICE (sdhci),"sd-bus" ), -TYPE_SD_CARD ); -qdev_prop_set_drive (card,"drive" , blk, &error_fatal); -object_property_set_bool (OBJECT (card), true,"realized" , &error_fatal); +if (bmc->soc.emmc.num_slots) { +sdhci_attach_drive (&bmc->soc.emmc.slots[0 ],drive_get_next (IF_SD )); }arm_load_kernel (ARM_CPU (first_cpu), machine, &aspeed_board_binfo);
hw/arm/aspeed_ast2600.c +21 -0
@@ -46,6 +46,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = { [ASPEED_ADC] = 0x1E6E9000, [ASPEED_VIDEO] = 0x1E700000, [ASPEED_SDHCI] = 0x1E740000, + [ASPEED_EMMC] = 0x1E750000, [ASPEED_GPIO] = 0x1E780000, [ASPEED_GPIO_1_8V] = 0x1E780800, [ASPEED_RTC] = 0x1E781000,
@@ -64,6 +65,7 @@ static const hwaddr aspeed_soc_ast2600_memmap[] = {#define ASPEED_SOC_AST2600_MAX_IRQ 128 +/* Shared Peripheral Interrupt values below are offset by -32 from datasheet */ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_UART1 ] =47 , [ASPEED_UART2 ] =48 ,
@@ -77,6 +79,7 @@ static const int aspeed_soc_ast2600_irqmap[] = { [ASPEED_ADC] = 78, [ASPEED_XDMA] = 6, [ASPEED_SDHCI] = 43, + [ASPEED_EMMC] = 15, [ASPEED_GPIO] = 40, [ASPEED_GPIO_1_8V] = 11, [ASPEED_RTC] = 13,
@@ -206,6 +209,14 @@ static void aspeed_soc_ast2600_init(Object *obj)sysbus_init_child_obj (obj,"sdhci[*]" ,OBJECT (&s->sdhci.slots[i]),sizeof (s->sdhci.slots[i]),TYPE_SYSBUS_SDHCI ); } + +sysbus_init_child_obj (obj,"emmc" ,OBJECT (&s->emmc),sizeof (s->emmc), +TYPE_ASPEED_SDHCI ); + +object_property_set_int (OBJECT (&s->emmc),1 ,"num-slots" , &error_abort); + +sysbus_init_child_obj (obj,"emmc" ,OBJECT (&s->emmc.slots[0 ]), +sizeof (s->emmc.slots[0 ]),TYPE_SYSBUS_SDHCI ); }/*
@@ -497,6 +508,16 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev, Error **errp) sc->memmap[ASPEED_SDHCI]);sysbus_connect_irq (SYS_BUS_DEVICE (&s->sdhci),0 ,aspeed_soc_get_irq (s,ASPEED_SDHCI )); + +/* eMMC */ +object_property_set_bool (OBJECT (&s->emmc), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (&s->emmc),0 , sc->memmap[ASPEED_EMMC ]); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->emmc),0 , +aspeed_soc_get_irq (s,ASPEED_EMMC )); }static void aspeed_soc_ast2600_class_init (ObjectClass *oc,void *data)
Signature · 1 line
2.21.1
PATCH v2 3/5 ftgmac100: check RX and TX buffer alignment
In reply to Cédric Le GoaterThese buffers should be aligned on 16 bytes.
--- hw/net/ftgmac100.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
hw/net/ftgmac100.c +13 -0
@@ -198,6 +198,8 @@ typedef struct {uint32_t des3; } FTGMAC100Desc; +#define FTGMAC100_DESC_ALIGNMENT 16 +/* * Specific RTL8211E MII Registers */
@@ -722,6 +724,12 @@ static void ftgmac100_write(void *opaque, hwaddr addr, s->itc = value;break ;case FTGMAC100_RXR_BADR :/* Ring buffer address */ +if (!QEMU_IS_ALIGNED (value,FTGMAC100_DESC_ALIGNMENT )) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad RX buffer alignment 0x%" + HWADDR_PRIx"\n" , __func__, value); +return ; + } + s->rx_ring = value; s->rx_descriptor = s->rx_ring;break ;
@@ -731,6 +739,11 @@ static void ftgmac100_write(void *opaque, hwaddr addr,break ;case FTGMAC100_NPTXR_BADR :/* Transmit buffer address */ +if (!QEMU_IS_ALIGNED (value,FTGMAC100_DESC_ALIGNMENT )) { +qemu_log_mask (LOG_GUEST_ERROR ,"%s: Bad TX buffer alignment 0x%" + HWADDR_PRIx"\n" , __func__, value); +return ; + } s->tx_ring = value; s->tx_descriptor = s->tx_ring;break ;
Signature · 1 line
2.21.1
PATCH v2 4/5 hw/arm/aspeed: add a 'execute-in-place' property to boot directly from CE0
In reply to Cédric Le GoaterThe overhead for the OpenBMC firmware images using the a custom U-Boot is around 2 seconds, which is fine, but with a U-Boot from mainline, it takes an extra 50 seconds or so to reach Linux. A quick survey on the number of reads performed on the flash memory region gives the following figures :
OpenBMC U-Boot 922478 (~ 3.5 MBytes)
Mainline U-Boot 20569977 (~ 80 MBytes)
QEMU must be trashing the TCG TBs and reloading text very often. Some addresses are read more than 250.000 times. Until we find a solution to improve boot time, execution from MMIO is not activated by default.
Setting this option also breaks migration compatibility.
--- include/hw/arm/aspeed.h | 2 ++ hw/arm/aspeed.c | 44 ++++++++++++++++++++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-)
include/hw/arm/aspeed.h +2 -0
@@ -19,6 +19,8 @@ typedef struct AspeedBoardState AspeedBoardState;typedef struct AspeedMachine {MachineState parent_obj; + +bool mmio_exec; }AspeedMachine ;#define ASPEED_MACHINE_CLASS (klass) \
hw/arm/aspeed.c +39 -5
68 lines not on this page · raw message
Signature · 1 line
2.21.1
PATCH v2 5/5 misc/pca9552: Add qom set and get
In reply to Cédric Le GoaterFrom: Joel Stanley <[email protected]>
Following the pattern of the work recently done with the ASPEED GPIO model, this adds support for inspecting and modifying the PCA9552 LEDs from the monitor.
(qemu) qom-set /machine/unattached/device[17] led0 on (qemu) qom-set /machine/unattached/device[17] led0 off (qemu) qom-set /machine/unattached/device[17] led0 pwm0 (qemu) qom-set /machine/unattached/device[17] led0 pwm1
[clg: - removed the "qom-get" examples from the commit log
- merged memory leak fixes from Joel ]
--- hw/misc/pca9552.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+)
hw/misc/pca9552.c +90 -0
@@ -15,12 +15,16 @@#include "hw/misc/pca9552.h" #include "hw/misc/pca9552_regs.h" #include "migration/vmstate.h" +#include "qapi/error.h" +#include "qapi/visitor.h" #define PCA9552_LED_ON 0x0#define PCA9552_LED_OFF 0x1#define PCA9552_LED_PWM0 0x2#define PCA9552_LED_PWM1 0x3 +static const char *led_state[] = {"on" ,"off" ,"pwm0" ,"pwm1" }; +static uint8_t pca9552_pin_get_config (PCA9552State *s,int pin) {uint8_t reg =PCA9552_LS0 + (pin /4 );
@@ -169,6 +173,82 @@ static int pca9552_event(I2CSlave *i2c, enum i2c_event event)return 0 ; } +static void pca9552_get_led (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +PCA9552State *s =PCA9552 (obj); +int led, rc, reg; +uint8_t state; + + rc =sscanf (name,"led%2d" , &led); +if (rc !=1 ) { +error_setg (errp,"%s: error reading %s" , __func__, name); +return ; + } +if (led <0 || led > s->nr_leds) { +error_setg (errp,"%s invalid led %s" , __func__, name); +return ; + } +/* +* Get the LSx register as the qom interface should expose the device +* state, not the modeled 'input line' behaviour which would come from +* reading the INPUTx reg +*/ + reg =PCA9552_LS0 + led /4 ; + state = (pca9552_read (s, reg) >> (led %8 )) &0x3 ; +visit_type_str (v, name, (char **)&led_state[state], errp); +} + +/* +* Return an LED selector register value based on an existing one, with +* the appropriate 2-bit state value set for the given LED number (0-3). +*/ +static inline uint8_t pca955x_ledsel (uint8_t oldval,int led_num,int state) +{ +return (oldval & (~(0x3 << (led_num <<1 )))) | + ((state &0x3 ) << (led_num <<1 )); +} + +static void pca9552_set_led (Object *obj,Visitor *v,const char *name, +void *opaque,Error **errp) +{ +PCA9552State *s =PCA9552 (obj); +Error *local_err =NULL ; +int led, rc, reg, val; +uint8_t state; +char *state_str; + +visit_type_str (v, name, &state_str, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } + rc =sscanf (name,"led%2d" , &led); +if (rc !=1 ) { +error_setg (errp,"%s: error reading %s" , __func__, name); +return ; + } +if (led <0 || led > s->nr_leds) { +error_setg (errp,"%s invalid led %s" , __func__, name); +return ; + } + +for (state =0 ; state <ARRAY_SIZE (led_state); state++) { +if (!strcmp (state_str, led_state[state])) { +break ; + } + } +if (state >=ARRAY_SIZE (led_state)) { +error_setg (errp,"%s invalid led state %s" , __func__, state_str); +return ; + } + + reg =PCA9552_LS0 + led /4 ; + val =pca9552_read (s, reg); + val =pca955x_ledsel (val, led %4 , state); +pca9552_write (s, reg, val); +} +static const VMStateDescription pca9552_vmstate = { .name ="PCA9552" , .version_id =0 ,
@@ -204,6 +284,7 @@ static void pca9552_reset(DeviceState *dev)static void pca9552_initfn (Object *obj) {PCA9552State *s =PCA9552 (obj); +int led;/* If support for the other PCA955X devices are implemented, these * constant values might be part of class structure describing the
@@ -211,6 +292,15 @@ static void pca9552_initfn(Object *obj)*/ s->max_reg =PCA9552_LS3 ; s->nr_leds =16 ; + +for (led =0 ; led < s->nr_leds; led++) { +char *name; + + name =g_strdup_printf ("led%d" , led); +object_property_add (obj, name,"bool" , pca9552_get_led, pca9552_set_led, +NULL ,NULL ,NULL ); +g_free (name); + } }static void pca9552_class_init (ObjectClass *klass,void *data)
Signature · 1 line
2.21.1
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
Hi,
This series failed the docker-quick@centos7 build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.
=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1 === TEST SCRIPT END ===
attempt to add duplicate property 'emmc' to object (type 'ast2600-a0')
Broken pipe/tmp/qemu-test/src/tests/libqtest.c:149: kill_qemu() detected QEMU death from signal 6 (Aborted) (core dumped)
ERROR - too few tests run (expected 6, got 5)
make: *** [check-qtest-aarch64] Error 1
make: *** Waiting for unfinished jobs....
TEST iotest-qcow2: 097
TEST iotest-qcow2: 098
---
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', '-n', 'docker', 'run', '--label', 'com.qemu.instance.uuid=3c0afb5628ac422c938aa1c839a31e18', '-u', '1003', '--security-opt', 'seccomp=unconfined', '--rm', '-e', 'TARGET_LIST=', '-e', 'EXTRA_CONFIGURE_OPTS=', '-e', 'V=', '-e', 'J=14', '-e', 'DEBUG=', '-e', 'SHOW_ENV=1', '-e', 'CCACHE_DIR=/var/tmp/ccache', '-v', '/home/patchew2/.cache/qemu-docker-ccache:/var/tmp/ccache:z', '-v', '/var/tmp/patchew-tester-tmp-u03ws4lu/src/docker-src.2020-01-10-05.42.48.13367:/var/tmp/qemu:z,ro', 'qemu:centos7', '/var/tmp/qemu/run', 'test-quick']' returned non-zero exit status 2. filter=--filter=label=com.qemu.instance.uuid=3c0afb5628ac422c938aa1c839a31e18
make[1]: *** [docker-run] Error 1
make[1]: Leaving directory `/var/tmp/patchew-tester-tmp-u03ws4lu/src'
make: *** [docker-run-test-quick@centos7] Error 2
real 10m33.511s
user 0m8.864s
The full log is available at
http://patchew.org/logs/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]
Quoted 7 lines · On 1/10/20 11:53 AM, [email protected] wrote:
Patchew URL: https://patchew.org/QEMU/[email protected]/
attempt to add duplicate property 'emmc' to object (type 'ast2600-a0')
Broken pipe/tmp/qemu-test/src/tests/libqtest.c:149:kill_qemu()detected QEMU death from signal 6 (Aborted) (core dumped) ERROR - too few tests run (expected 6, got 5)
make: *** [check-qtest-aarch64] Error 1
Yay patchew is back \o/
Happy new year patchew!