Ide patches
The following changes since commit 0d2fa03dae4fbe185a082f361342b1e30aed4582:
Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180608' into staging (2018-06-08 16:26:51 +0100)
are available in the Git repository at:
https://github.com/jnsnow/qemu.git tags/ide-pull-request
for you to fetch changes up to c173723f247c69974a83af1395020d0f01a0d334:
ide: introduce ide_transfer_start_norecurse (2018-06-08 13:36:31 -0400)
----------------------------------------------------------------
AHCI Pull request
----------------------------------------------------------------
John Snow (21):
ahci: trim signatures on raise/lower
ahci: fix PxCI register race
ahci: don't schedule unnecessary BH
ahci: add port register enumeration
ahci: modify ahci_port_read to use register numbers
ahci: make port read traces more descriptive
ahci: fix spacing damage on ahci_port_write
ahci: combine identical clauses in port write
ahci: modify ahci_port_write to use register numbers
ahci: make port write traces more descriptive
ahci: delete old port register address definitions
ahci: add host register enumeration
ahci: fix host register max address
ahci: modify ahci_mem_read_32 to work on register numbers
ahci: make mem_read_32 traces more descriptive
ahci: fix spacing damage on ahci_mem_write
ahci: adjust ahci_mem_write to work on registers
ahci: delete old host register address definitions
ahci: make ahci_mem_write traces more descriptive libqos/ahci: track sector size
ahci: move PIO Setup FIS before transfer, fix it for ATAPI commands
Paolo Bonzini (5):
ide: push end_transfer_func out of start_transfer callback, rename
callback
ide: call ide_cmd_done from ide_transfer_stop
ide: make ide_transfer_stop idempotent
atapi: call ide_set_irq before ide_transfer_start
ide: introduce ide_transfer_start_norecurse
Thomas Huth (4):
tests/boot-sector: Add magic bytes to s390x boot code header tests/cdrom-test: Test booting from CD-ROM ISO image file tests/cdrom-test: Test that -cdrom parameter is working
MAINTAINERS: Add the cdrom-test to John's section
MAINTAINERS | 1 + hw/ide/ahci.c | 371 +++++++++++++++++++++++++++------------------- hw/ide/ahci_internal.h | 63 +++++--- hw/ide/atapi.c | 44 +++--- hw/ide/core.c | 39 ++--- hw/ide/trace-events | 15 +- include/hw/ide/internal.h | 4 +- tests/Makefile.include | 2 + tests/boot-sector.c | 9 +- tests/cdrom-test.c | 222 +++++++++++++++++++++++++++ tests/libqos/ahci.c | 45 +++--- tests/libqos/ahci.h | 3 +- 12 files changed, 573 insertions(+), 245 deletions(-) create mode 100644 tests/cdrom-test.c
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 02/30] ahci: fix PxCI register race
AHCI presently signals completion prior to the PxCI register being cleared to indicate completion. If a guest driver attempts to issue a new command in its IRQ handler, it might be surprised to learn there is still a command pending.
In the case of Windows 10's boot driver, it will actually poll the IRQ register hoping to find out when the command is done running -- which will never happen, as there isn't a command running.
Fix this: clear PxCI in ahci_cmd_done and not in the asynchronous BH. Because it now runs synchronously, we don't need to check if the command is actually done by spying on the ATA registers. We know it's done.
Message-id: [email protected]
--- hw/ide/ahci.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
hw/ide/ahci.c +6 -7
@@ -532,13 +532,6 @@ static void ahci_check_cmd_bh(void *opaque)qemu_bh_delete (ad->check_bh); ad->check_bh =NULL ; -if ((ad->busy_slot !=-1 ) && - !(ad->port.ifs[0 ].status & (BUSY_STAT |DRQ_STAT ))) { -/* no longer busy */ - ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); - ad->busy_slot =-1 ; - } -check_cmd (ad->hba, ad->port_no); }
@@ -1425,6 +1418,12 @@ static void ahci_cmd_done(IDEDMA *dma)trace_ahci_cmd_done (ad->hba, ad->port_no); +/* no longer busy */ +if (ad->busy_slot !=-1 ) { + ad->port_regs.cmd_issue &= ~(1 << ad->busy_slot); + ad->busy_slot =-1 ; + } +/* update d2h status */ ahci_write_fis_d2h (ad);
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 14/30] ahci: modify ahci_mem_read_32 to work on register numbers
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
hw/ide/ahci.c +11 -6
@@ -386,22 +386,27 @@ static uint64_t ahci_mem_read_32(void *opaque, hwaddr addr)uint32_t val =0 ;if (addr <AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR ) { -switch (addr) { -case HOST_CAP : +enum AHCIHostReg regnum = addr /4 ; +assert (regnum <AHCI_HOST_REG__COUNT ); + +switch (regnum) { +case AHCI_HOST_REG_CAP : val = s->control_regs.cap;break ; -case HOST_CTL : +case AHCI_HOST_REG_CTL : val = s->control_regs.ghc;break ; -case HOST_IRQ_STAT : +case AHCI_HOST_REG_IRQ_STAT : val = s->control_regs.irqstatus;break ; -case HOST_PORTS_IMPL : +case AHCI_HOST_REG_PORTS_IMPL : val = s->control_regs.impl;break ; -case HOST_VERSION : +case AHCI_HOST_REG_VERSION : val = s->control_regs.version;break ; +default : +break ; } } else if ((addr >= AHCI_PORT_REGS_START_ADDR) && (addr < (AHCI_PORT_REGS_START_ADDR +
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 01/30] ahci: trim signatures on raise/lower
In reply to John SnowThese functions work on the AHCI device, not the individual AHCI devices, so trim the AHCIDevice argument.
Message-id: [email protected]
--- hw/ide/ahci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/ide/ahci.c +4 -4
@@ -131,7 +131,7 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset)return val; } -static void ahci_irq_raise (AHCIState *s,AHCIDevice *dev) +static void ahci_irq_raise (AHCIState *s) {DeviceState *dev_state = s->container; PCIDevice *pci_dev = (PCIDevice *) object_dynamic_cast(OBJECT(dev_state),
@@ -146,7 +146,7 @@ static void ahci_irq_raise(AHCIState *s, AHCIDevice *dev) } } -static void ahci_irq_lower (AHCIState *s,AHCIDevice *dev) +static void ahci_irq_lower (AHCIState *s) {DeviceState *dev_state = s->container; PCIDevice *pci_dev = (PCIDevice *) object_dynamic_cast(OBJECT(dev_state),
@@ -174,9 +174,9 @@ static void ahci_check_irq(AHCIState *s)trace_ahci_check_irq (s, old_irq, s->control_regs.irqstatus);if (s->control_regs.irqstatus && (s->control_regs.ghc &HOST_CTL_IRQ_EN )) { -ahci_irq_raise (s,NULL ); +ahci_irq_raise (s); }else { -ahci_irq_lower (s,NULL ); +ahci_irq_lower (s); } }
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 03/30] ahci: don't schedule unnecessary BH
In reply to John SnowThe comment gives us a hint. *Maybe* we still have something to process. Well, why not check?
Message-id: [email protected]
--- hw/ide/ahci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ide/ahci.c +1 -2
@@ -1427,8 +1427,7 @@ static void ahci_cmd_done(IDEDMA *dma)/* update d2h status */ ahci_write_fis_d2h (ad); -if (!ad->check_bh) { -/* maybe we still have something to process, check later */ +if (ad->port_regs.cmd_issue && !ad->check_bh) { ad->check_bh =qemu_bh_new (ahci_check_cmd_bh, ad);qemu_bh_schedule (ad->check_bh); }
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 08/30] ahci: combine identical clauses in port write
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 4 ---- 1 file changed, 4 deletions(-)
hw/ide/ahci.c +0 -4
@@ -330,11 +330,7 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)check_cmd (s, port);break ;case PORT_TFDATA : -/* Read Only. */ -break ;case PORT_SIG : -/* Read Only */ -break ;case PORT_SCR_STAT :/* Read Only */ break ;
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 11/30] ahci: delete old port register address definitions
In reply to John SnowThey're now unused.
Message-id: [email protected]
--- hw/ide/ahci_internal.h | 18 ------------------ 1 file changed, 18 deletions(-)
hw/ide/ahci_internal.h +0 -18
@@ -102,24 +102,6 @@ enum AHCIPortReg {AHCI_PORT_REG__COUNT =32 }; -/* registers for each SATA port */ -#define PORT_LST_ADDR 0x00/* command list DMA addr */ -#define PORT_LST_ADDR_HI 0x04/* command list DMA addr hi */ -#define PORT_FIS_ADDR 0x08/* FIS rx buf addr */ -#define PORT_FIS_ADDR_HI 0x0c/* FIS rx buf addr hi */ -#define PORT_IRQ_STAT 0x10/* interrupt status */ -#define PORT_IRQ_MASK 0x14/* interrupt enable/disable mask */ -#define PORT_CMD 0x18/* port command */ - -#define PORT_TFDATA 0x20/* taskfile data */ -#define PORT_SIG 0x24/* device TF signature */ -#define PORT_SCR_STAT 0x28/* SATA phy register: SStatus */ -#define PORT_SCR_CTL 0x2c/* SATA phy register: SControl */ -#define PORT_SCR_ERR 0x30/* SATA phy register: SError */ -#define PORT_SCR_ACT 0x34/* SATA phy register: SActive */ -#define PORT_CMD_ISSUE 0x38/* command issue */ -#define PORT_RESERVED 0x3c/* reserved */ -/* Port interrupt bit descriptors */ enum AHCIPortIRQ {AHCI_PORT_IRQ_BIT_DHRS =0 ,
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 12/30] ahci: add host register enumeration
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 15 +++++++++++++++ hw/ide/ahci_internal.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+)
hw/ide/ahci.c +15 -0
@@ -47,6 +47,21 @@ static bool ahci_map_fis_address(AHCIDevice *ad);static void ahci_unmap_clb_address (AHCIDevice *ad);static void ahci_unmap_fis_address (AHCIDevice *ad); +__attribute__((__unused__))/* TODO */ +static const char *AHCIHostReg_lookup[AHCI_HOST_REG__COUNT ] = { + [AHCI_HOST_REG_CAP ] ="CAP" , + [AHCI_HOST_REG_CTL ] ="GHC" , + [AHCI_HOST_REG_IRQ_STAT ] ="IS" , + [AHCI_HOST_REG_PORTS_IMPL ] ="PI" , + [AHCI_HOST_REG_VERSION ] ="VS" , + [AHCI_HOST_REG_CCC_CTL ] ="CCC_CTL" , + [AHCI_HOST_REG_CCC_PORTS ] ="CCC_PORTS" , + [AHCI_HOST_REG_EM_LOC ] ="EM_LOC" , + [AHCI_HOST_REG_EM_CTL ] ="EM_CTL" , + [AHCI_HOST_REG_CAP2 ] ="CAP2" , + [AHCI_HOST_REG_BOHC ] ="BOHC" , +}; +static const char *AHCIPortReg_lookup[AHCI_PORT_REG__COUNT ] = { [AHCI_PORT_REG_LST_ADDR ] ="PxCLB" , [AHCI_PORT_REG_LST_ADDR_HI ] ="PxCLBU" ,
hw/ide/ahci_internal.h +15 -0
@@ -61,6 +61,21 @@#define HOST_PORTS_IMPL 0x0c/* bitmap of implemented ports */ #define HOST_VERSION 0x10/* AHCI spec. version compliancy */ +enum AHCIHostReg { +AHCI_HOST_REG_CAP =0 ,/* CAP: host capabilities */ +AHCI_HOST_REG_CTL =1 ,/* GHC: global host control */ +AHCI_HOST_REG_IRQ_STAT =2 ,/* IS: interrupt status */ +AHCI_HOST_REG_PORTS_IMPL =3 ,/* PI: bitmap of implemented ports */ +AHCI_HOST_REG_VERSION =4 ,/* VS: AHCI spec. version compliancy */ +AHCI_HOST_REG_CCC_CTL =5 ,/* CCC_CTL: CCC Control */ +AHCI_HOST_REG_CCC_PORTS =6 ,/* CCC_PORTS: CCC Ports */ +AHCI_HOST_REG_EM_LOC =7 ,/* EM_LOC: Enclosure Mgmt Location */ +AHCI_HOST_REG_EM_CTL =8 ,/* EM_CTL: Enclosure Mgmt Control */ +AHCI_HOST_REG_CAP2 =9 ,/* CAP2: host capabilities, extended */ +AHCI_HOST_REG_BOHC =10 ,/* BOHC: firmare/os handoff ctrl & status */ +AHCI_HOST_REG__COUNT =11 +}; +/* HOST_CTL bits */ #define HOST_CTL_RESET (1 << 0)/* reset controller; self-clear */ #define HOST_CTL_IRQ_EN (1 << 1)/* global IRQ enable */
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 13/30] ahci: fix host register max address
In reply to John SnowYes, comment, it ought to be 0x2C.
Message-id: [email protected]
--- hw/ide/ahci_internal.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ide/ahci_internal.h +1 -2
@@ -224,8 +224,7 @@ enum AHCIPortIRQ {#define SATA_SIGNATURE_CDROM 0xeb140101#define SATA_SIGNATURE_DISK 0x00000101 -#define AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR 0x20 -/* Shouldn't this be 0x2c? */ +#define AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR 0x2c#define AHCI_PORT_REGS_START_ADDR 0x100#define AHCI_PORT_ADDR_OFFSET_MASK 0x7f
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 04/30] ahci: add port register enumeration
In reply to John SnowInstead of tracking offsets, lets count the registers.
Message-id: [email protected]
--- hw/ide/ahci.c | 25 +++++++++++++++++++++++++ hw/ide/ahci_internal.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+)
hw/ide/ahci.c +25 -0
@@ -46,6 +46,31 @@ static bool ahci_map_fis_address(AHCIDevice *ad);static void ahci_unmap_clb_address (AHCIDevice *ad);static void ahci_unmap_fis_address (AHCIDevice *ad); +__attribute__((__unused__))/* TODO */ +static const char *AHCIPortReg_lookup[AHCI_PORT_REG__COUNT ] = { + [AHCI_PORT_REG_LST_ADDR ] ="PxCLB" , + [AHCI_PORT_REG_LST_ADDR_HI ] ="PxCLBU" , + [AHCI_PORT_REG_FIS_ADDR ] ="PxFB" , + [AHCI_PORT_REG_FIS_ADDR_HI ] ="PxFBU" , + [AHCI_PORT_REG_IRQ_STAT ] ="PxIS" , + [AHCI_PORT_REG_IRQ_MASK ] ="PXIE" , + [AHCI_PORT_REG_CMD ] ="PxCMD" , + [7 ] ="Reserved" , + [AHCI_PORT_REG_TFDATA ] ="PxTFD" , + [AHCI_PORT_REG_SIG ] ="PxSIG" , + [AHCI_PORT_REG_SCR_STAT ] ="PxSSTS" , + [AHCI_PORT_REG_SCR_CTL ] ="PxSCTL" , + [AHCI_PORT_REG_SCR_ERR ] ="PxSERR" , + [AHCI_PORT_REG_SCR_ACT ] ="PxSACT" , + [AHCI_PORT_REG_CMD_ISSUE ] ="PxCI" , + [AHCI_PORT_REG_SCR_NOTIF ] ="PxSNTF" , + [AHCI_PORT_REG_FIS_CTL ] ="PxFBS" , + [AHCI_PORT_REG_DEV_SLEEP ] ="PxDEVSLP" , + [18 ...27 ] ="Reserved" , + [AHCI_PORT_REG_VENDOR_1 ... +AHCI_PORT_REG_VENDOR_4 ] ="PxVS" , +}; +static const char *AHCIPortIRQ_lookup[AHCI_PORT_IRQ__COUNT ] = { [AHCI_PORT_IRQ_BIT_DHRS ] ="DHRS" , [AHCI_PORT_IRQ_BIT_PSS ] ="PSS" ,
hw/ide/ahci_internal.h +29 -0
@@ -74,6 +74,34 @@#define HOST_CAP_NCQ (1 << 30)/* Native Command Queueing */ #define HOST_CAP_64 (1U << 31)/* PCI DAC (64-bit DMA) support */ +/* registers for each SATA port */ +enum AHCIPortReg { +AHCI_PORT_REG_LST_ADDR =0 ,/* PxCLB: command list DMA addr */ +AHCI_PORT_REG_LST_ADDR_HI =1 ,/* PxCLBU: command list DMA addr hi */ +AHCI_PORT_REG_FIS_ADDR =2 ,/* PxFB: FIS rx buf addr */ +AHCI_PORT_REG_FIS_ADDR_HI =3 ,/* PxFBU: FIX rx buf addr hi */ +AHCI_PORT_REG_IRQ_STAT =4 ,/* PxIS: interrupt status */ +AHCI_PORT_REG_IRQ_MASK =5 ,/* PxIE: interrupt enable/disable mask */ +AHCI_PORT_REG_CMD =6 ,/* PxCMD: port command */ +/* RESERVED */ +AHCI_PORT_REG_TFDATA =8 ,/* PxTFD: taskfile data */ +AHCI_PORT_REG_SIG =9 ,/* PxSIG: device TF signature */ +AHCI_PORT_REG_SCR_STAT =10 ,/* PxSSTS: SATA phy register: SStatus */ +AHCI_PORT_REG_SCR_CTL =11 ,/* PxSCTL: SATA phy register: SControl */ +AHCI_PORT_REG_SCR_ERR =12 ,/* PxSERR: SATA phy register: SError */ +AHCI_PORT_REG_SCR_ACT =13 ,/* PxSACT: SATA phy register: SActive */ +AHCI_PORT_REG_CMD_ISSUE =14 ,/* PxCI: command issue */ +AHCI_PORT_REG_SCR_NOTIF =15 ,/* PxSNTF: SATA phy register: SNotification */ +AHCI_PORT_REG_FIS_CTL =16 ,/* PxFBS: Port multiplier switching ctl */ +AHCI_PORT_REG_DEV_SLEEP =17 ,/* PxDEVSLP: device sleep control */ +/* RESERVED */ +AHCI_PORT_REG_VENDOR_1 =28 ,/* PxVS: Vendor Specific */ +AHCI_PORT_REG_VENDOR_2 =29 , +AHCI_PORT_REG_VENDOR_3 =30 , +AHCI_PORT_REG_VENDOR_4 =31 , +AHCI_PORT_REG__COUNT =32 +}; +/* registers for each SATA port */ #define PORT_LST_ADDR 0x00/* command list DMA addr */ #define PORT_LST_ADDR_HI 0x04/* command list DMA addr hi */
@@ -82,6 +110,7 @@#define PORT_IRQ_STAT 0x10/* interrupt status */ #define PORT_IRQ_MASK 0x14/* interrupt enable/disable mask */ #define PORT_CMD 0x18/* port command */ +#define PORT_TFDATA 0x20/* taskfile data */ #define PORT_SIG 0x24/* device TF signature */ #define PORT_SCR_STAT 0x28/* SATA phy register: SStatus */
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 05/30] ahci: modify ahci_port_read to use register numbers
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-)
hw/ide/ahci.c +19 -19
@@ -93,41 +93,42 @@ static const char *AHCIPortIRQ_lookup[AHCI_PORT_IRQ__COUNT] = { [AHCI_PORT_IRQ_BIT_CPDS ] ="CPDS" }; -static uint32_t ahci_port_read (AHCIState *s,int port,int offset) +static uint32_t ahci_port_read (AHCIState *s,int port,int offset) {uint32_t val; -AHCIPortRegs *pr; - pr = &s->dev[port].port_regs; +AHCIPortRegs *pr = &s->dev[port].port_regs; +enum AHCIPortReg regnum = offset /sizeof (uint32_t ); +assert (regnum < (AHCI_PORT_ADDR_OFFSET_LEN /sizeof (uint32_t ))); -switch (offset) { -case PORT_LST_ADDR : +switch (regnum) { +case AHCI_PORT_REG_LST_ADDR : val = pr->lst_addr;break ; -case PORT_LST_ADDR_HI : +case AHCI_PORT_REG_LST_ADDR_HI : val = pr->lst_addr_hi;break ; -case PORT_FIS_ADDR : +case AHCI_PORT_REG_FIS_ADDR : val = pr->fis_addr;break ; -case PORT_FIS_ADDR_HI : +case AHCI_PORT_REG_FIS_ADDR_HI : val = pr->fis_addr_hi;break ; -case PORT_IRQ_STAT : +case AHCI_PORT_REG_IRQ_STAT : val = pr->irq_stat;break ; -case PORT_IRQ_MASK : +case AHCI_PORT_REG_IRQ_MASK : val = pr->irq_mask;break ; -case PORT_CMD : +case AHCI_PORT_REG_CMD : val = pr->cmd;break ; -case PORT_TFDATA : +case AHCI_PORT_REG_TFDATA : val = pr->tfdata;break ; -case PORT_SIG : +case AHCI_PORT_REG_SIG : val = pr->sig;break ; -case PORT_SCR_STAT : +case AHCI_PORT_REG_SCR_STAT :if (s->dev[port].port.ifs[0 ].blk) { val =SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |SATA_SCR_SSTATUS_SPD_GEN1 |SATA_SCR_SSTATUS_IPM_ACTIVE ;
@@ -135,19 +136,18 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset) val =SATA_SCR_SSTATUS_DET_NODEV ; }break ; -case PORT_SCR_CTL : +case AHCI_PORT_REG_SCR_CTL : val = pr->scr_ctl;break ; -case PORT_SCR_ERR : +case AHCI_PORT_REG_SCR_ERR : val = pr->scr_err;break ; -case PORT_SCR_ACT : +case AHCI_PORT_REG_SCR_ACT : val = pr->scr_act;break ; -case PORT_CMD_ISSUE : +case AHCI_PORT_REG_CMD_ISSUE : val = pr->cmd_issue;break ; -case PORT_RESERVED :default : val =0 ; }
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 06/30] ahci: make port read traces more descriptive
In reply to John SnowA trace is added to let us watch unimplemented registers specifically, as these are more likely to cause us trouble. Otherwise, the port read traces now tell us what register is getting hit, which is nicer.
Message-id: [email protected]
--- hw/ide/ahci.c | 5 +++-- hw/ide/trace-events | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)
hw/ide/ahci.c +3 -2
@@ -46,7 +46,6 @@ static bool ahci_map_fis_address(AHCIDevice *ad);static void ahci_unmap_clb_address (AHCIDevice *ad);static void ahci_unmap_fis_address (AHCIDevice *ad); -__attribute__((__unused__))/* TODO */ static const char *AHCIPortReg_lookup[AHCI_PORT_REG__COUNT ] = { [AHCI_PORT_REG_LST_ADDR ] ="PxCLB" , [AHCI_PORT_REG_LST_ADDR_HI ] ="PxCLBU" ,
@@ -149,10 +148,12 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset) val = pr->cmd_issue;break ;default : +trace_ahci_port_read_default (s, port, AHCIPortReg_lookup[regnum], + offset); val =0 ; } -trace_ahci_port_read (s, port, offset, val); +trace_ahci_port_read (s, port, AHCIPortReg_lookup[regnum], offset, val);return val; }
hw/ide/trace-events +2 -1
@@ -63,7 +63,8 @@ ide_atapi_cmd_read_dma_cb_aio(void *s, int lba, int n) "IDEState: %p; aio read: ide_atapi_cmd_packet(void *s, uint16_t limit, const char *packet) "IDEState: %p; limit=0x%x packet: %s" # hw/ide/ahci.c -ahci_port_read(void *s, int port, int offset, uint32_t ret) "ahci(%p)[%d]: port read @ 0x%x: 0x%08x" +ahci_port_read(void *s, int port, const char *reg, int offset, uint32_t ret) "ahci(%p)[%d]: port read [reg:%s] @ 0x%x: 0x%08x" +ahci_port_read_default(void *s, int port, const char *reg, int offset) "ahci(%p)[%d]: unimplemented port read [reg:%s] @ 0x%x" ahci_irq_raise(void *s) "ahci(%p): raise irq" ahci_irq_lower(void *s) "ahci(%p): lower irq" ahci_check_irq(void *s, uint32_t old, uint32_t new) "ahci(%p): check irq 0x%08x --> 0x%08x"
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 09/30] ahci: modify ahci_port_write to use register numbers
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-)
hw/ide/ahci.c +17 -15
@@ -282,30 +282,32 @@ static int ahci_cond_start_engines(AHCIDevice *ad)static void ahci_port_write (AHCIState *s,int port,int offset,uint32_t val) {AHCIPortRegs *pr = &s->dev[port].port_regs; +enum AHCIPortReg regnum = offset /sizeof (uint32_t ); +assert (regnum < (AHCI_PORT_ADDR_OFFSET_LEN /sizeof (uint32_t )));trace_ahci_port_write (s, port, offset, val); -switch (offset) { -case PORT_LST_ADDR : +switch (regnum) { +case AHCI_PORT_REG_LST_ADDR : pr->lst_addr = val;break ; -case PORT_LST_ADDR_HI : +case AHCI_PORT_REG_LST_ADDR_HI : pr->lst_addr_hi = val;break ; -case PORT_FIS_ADDR : +case AHCI_PORT_REG_FIS_ADDR : pr->fis_addr = val;break ; -case PORT_FIS_ADDR_HI : +case AHCI_PORT_REG_FIS_ADDR_HI : pr->fis_addr_hi = val;break ; -case PORT_IRQ_STAT : +case AHCI_PORT_REG_IRQ_STAT : pr->irq_stat &= ~val;ahci_check_irq (s);break ; -case PORT_IRQ_MASK : +case AHCI_PORT_REG_IRQ_MASK : pr->irq_mask = val &0xfdc000ff ;ahci_check_irq (s);break ; -case PORT_CMD : +case AHCI_PORT_REG_CMD :/* Block any Read-only fields from being set; * including LIST_ON and FIS_ON. * The spec requires to set ICC bits to zero after the ICC change
@@ -329,26 +331,26 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)check_cmd (s, port);break ; -case PORT_TFDATA : -case PORT_SIG : -case PORT_SCR_STAT : +case AHCI_PORT_REG_TFDATA : +case AHCI_PORT_REG_SIG : +case AHCI_PORT_REG_SCR_STAT :/* Read Only */ break ; -case PORT_SCR_CTL : +case AHCI_PORT_REG_SCR_CTL :if (((pr->scr_ctl &AHCI_SCR_SCTL_DET ) ==1 ) && ((val &AHCI_SCR_SCTL_DET ) ==0 )) {ahci_reset_port (s, port); } pr->scr_ctl = val;break ; -case PORT_SCR_ERR : +case AHCI_PORT_REG_SCR_ERR : pr->scr_err &= ~val;break ; -case PORT_SCR_ACT : +case AHCI_PORT_REG_SCR_ACT :/* RW1 */ pr->scr_act |= val;break ; -case PORT_CMD_ISSUE : +case AHCI_PORT_REG_CMD_ISSUE : pr->cmd_issue |= val;check_cmd (s, port);break ;
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 10/30] ahci: make port write traces more descriptive
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 8 +++++++- hw/ide/trace-events | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-)
hw/ide/ahci.c +7 -1
@@ -27,6 +27,7 @@#include "hw/pci/pci.h" #include "qemu/error-report.h" +#include "qemu/log.h" #include "sysemu/block-backend.h" #include "sysemu/dma.h" #include "hw/ide/internal.h"
@@ -284,8 +285,8 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)AHCIPortRegs *pr = &s->dev[port].port_regs;enum AHCIPortReg regnum = offset /sizeof (uint32_t );assert (regnum < (AHCI_PORT_ADDR_OFFSET_LEN /sizeof (uint32_t ))); +trace_ahci_port_write (s, port, AHCIPortReg_lookup[regnum], offset, val); -trace_ahci_port_write (s, port, offset, val);switch (regnum) {case AHCI_PORT_REG_LST_ADDR : pr->lst_addr = val;
@@ -355,6 +356,11 @@ static void ahci_port_write(AHCIState *s, int port, int offset, uint32_t val)check_cmd (s, port);break ;default : +trace_ahci_port_write_unimpl (s, port, AHCIPortReg_lookup[regnum], + offset, val); +qemu_log_mask (LOG_UNIMP ,"Attempted write to unimplemented register: " +"AHCI port %d register %s, offset 0x%x: 0x%" PRIx32, + port, AHCIPortReg_lookup[regnum], offset, val);break ; } }
hw/ide/trace-events +2 -1
@@ -69,7 +69,8 @@ ahci_irq_raise(void *s) "ahci(%p): raise irq" ahci_irq_lower(void *s) "ahci(%p): lower irq" ahci_check_irq(void *s, uint32_t old, uint32_t new) "ahci(%p): check irq 0x%08x --> 0x%08x" ahci_trigger_irq(void *s, int port, const char *name, uint32_t val, uint32_t old, uint32_t new, uint32_t effective) "ahci(%p)[%d]: trigger irq +%s (0x%08x); irqstat: 0x%08x --> 0x%08x; effective: 0x%08x" -ahci_port_write(void *s, int port, int offset, uint32_t val) "ahci(%p)[%d]: port write @ 0x%x: 0x%08x" +ahci_port_write(void *s, int port, const char *reg, int offset, uint32_t val) "ahci(%p)[%d]: port write [reg:%s] @ 0x%x: 0x%08x" +ahci_port_write_unimpl(void *s, int port, const char *reg, int offset, uint32_t val) "ahci(%p)[%d]: unimplemented port write [reg:%s] @ 0x%x: 0x%08x" ahci_mem_read_32(void *s, uint64_t addr, uint32_t val) "ahci(%p): mem read @ 0x%"PRIx64": 0x%08x" ahci_mem_read(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): read%u @ 0x%"PRIx64": 0x%016"PRIx64 ahci_mem_write(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u @ 0x%"PRIx64": 0x%016"PRIx64
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 15/30] ahci: make mem_read_32 traces more descriptive
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 7 +++++-- hw/ide/trace-events | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-)
hw/ide/ahci.c +5 -2
@@ -47,7 +47,6 @@ static bool ahci_map_fis_address(AHCIDevice *ad);static void ahci_unmap_clb_address (AHCIDevice *ad);static void ahci_unmap_fis_address (AHCIDevice *ad); -__attribute__((__unused__))/* TODO */ static const char *AHCIHostReg_lookup[AHCI_HOST_REG__COUNT ] = { [AHCI_HOST_REG_CAP ] ="CAP" , [AHCI_HOST_REG_CTL ] ="GHC" ,
@@ -406,13 +405,17 @@ static uint64_t ahci_mem_read_32(void *opaque, hwaddr addr) val = s->control_regs.version;break ;default : -break ; +trace_ahci_mem_read_32_host_default (s, AHCIHostReg_lookup[regnum], + addr); } +trace_ahci_mem_read_32_host (s, AHCIHostReg_lookup[regnum], addr, val); }else if ((addr >=AHCI_PORT_REGS_START_ADDR ) && (addr < (AHCI_PORT_REGS_START_ADDR + (s->ports *AHCI_PORT_ADDR_OFFSET_LEN )))) { val =ahci_port_read (s, (addr -AHCI_PORT_REGS_START_ADDR ) >>7 , addr &AHCI_PORT_ADDR_OFFSET_MASK ); + }else { +trace_ahci_mem_read_32_default (s, addr, val); }trace_ahci_mem_read_32 (s, addr, val);
hw/ide/trace-events +3 -0
@@ -72,6 +72,9 @@ ahci_trigger_irq(void *s, int port, const char *name, uint32_t val, uint32_t old ahci_port_write(void *s, int port, const char *reg, int offset, uint32_t val) "ahci(%p)[%d]: port write [reg:%s] @ 0x%x: 0x%08x" ahci_port_write_unimpl(void *s, int port, const char *reg, int offset, uint32_t val) "ahci(%p)[%d]: unimplemented port write [reg:%s] @ 0x%x: 0x%08x" ahci_mem_read_32(void *s, uint64_t addr, uint32_t val) "ahci(%p): mem read @ 0x%"PRIx64": 0x%08x" +ahci_mem_read_32_default(void *s, uint64_t addr, uint32_t val) "ahci(%p): mem read @ 0x%"PRIx64": 0x%08x" +ahci_mem_read_32_host(void *s, const char *reg, uint64_t addr, uint32_t val) "ahci(%p): mem read [reg:%s] @ 0x%"PRIx64": 0x%08x" +ahci_mem_read_32_host_default(void *s, const char *reg, uint64_t addr) "ahci(%p): unimplemented mem read [reg:%s] @ 0x%"PRIx64 ahci_mem_read(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): read%u @ 0x%"PRIx64": 0x%016"PRIx64 ahci_mem_write(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u @ 0x%"PRIx64": 0x%016"PRIx64 ahci_mem_write_unknown(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u to unknown register 0x%"PRIx64": 0x%016"PRIx64
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 16/30] ahci: fix spacing damage on ahci_mem_write
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-)
hw/ide/ahci.c +23 -24
@@ -469,37 +469,36 @@ static void ahci_mem_write(void *opaque, hwaddr addr,if (addr <AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR ) {switch (addr) { -case HOST_CAP :/* R/WO, RO */ -/* FIXME handle R/WO */ -break ; -case HOST_CTL :/* R/W */ -if (val &HOST_CTL_RESET ) { -ahci_reset (s); - }else { - s->control_regs.ghc = (val &0x3 ) |HOST_CTL_AHCI_EN ; -ahci_check_irq (s); - } -break ; -case HOST_IRQ_STAT :/* R/WC, RO */ - s->control_regs.irqstatus &= ~val; +case HOST_CAP :/* R/WO, RO */ +/* FIXME handle R/WO */ +break ; +case HOST_CTL :/* R/W */ +if (val &HOST_CTL_RESET ) { +ahci_reset (s); + }else { + s->control_regs.ghc = (val &0x3 ) |HOST_CTL_AHCI_EN ;ahci_check_irq (s); -break ; -case HOST_PORTS_IMPL :/* R/WO, RO */ -/* FIXME handle R/WO */ -break ; -case HOST_VERSION :/* RO */ -/* FIXME report write? */ -break ; -default : -trace_ahci_mem_write_unknown (s, size, addr, val); + } +break ; +case HOST_IRQ_STAT :/* R/WC, RO */ + s->control_regs.irqstatus &= ~val; +ahci_check_irq (s); +break ; +case HOST_PORTS_IMPL :/* R/WO, RO */ +/* FIXME handle R/WO */ +break ; +case HOST_VERSION :/* RO */ +/* FIXME report write? */ +break ; +default : +trace_ahci_mem_write_unknown (s, size, addr, val); } }else if ((addr >=AHCI_PORT_REGS_START_ADDR ) && (addr < (AHCI_PORT_REGS_START_ADDR + - (s->ports *AHCI_PORT_ADDR_OFFSET_LEN )))) { + (s->ports *AHCI_PORT_ADDR_OFFSET_LEN )))) {ahci_port_write (s, (addr -AHCI_PORT_REGS_START_ADDR ) >>7 , addr &AHCI_PORT_ADDR_OFFSET_MASK , val); } - }static const MemoryRegionOps ahci_mem_ops = {
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 17/30] ahci: adjust ahci_mem_write to work on registers
In reply to John SnowActually, this function looks pretty broken, but for now, let's finish up what this series of commits came here to do.
Message-id: [email protected]
--- hw/ide/ahci.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
hw/ide/ahci.c +9 -6
@@ -468,11 +468,14 @@ static void ahci_mem_write(void *opaque, hwaddr addr, }if (addr <AHCI_GENERIC_HOST_CONTROL_REGS_MAX_ADDR ) { -switch (addr) { -case HOST_CAP :/* R/WO, RO */ +enum AHCIHostReg regnum = addr /4 ; +assert (regnum <AHCI_HOST_REG__COUNT ); + +switch (regnum) { +case AHCI_HOST_REG_CAP :/* R/WO, RO */ /* FIXME handle R/WO */ break ; -case HOST_CTL :/* R/W */ +case AHCI_HOST_REG_CTL :/* R/W */ if (val &HOST_CTL_RESET ) {ahci_reset (s); }else {
@@ -480,14 +483,14 @@ static void ahci_mem_write(void *opaque, hwaddr addr,ahci_check_irq (s); }break ; -case HOST_IRQ_STAT :/* R/WC, RO */ +case AHCI_HOST_REG_IRQ_STAT :/* R/WC, RO */ s->control_regs.irqstatus &= ~val;ahci_check_irq (s);break ; -case HOST_PORTS_IMPL :/* R/WO, RO */ +case AHCI_HOST_REG_PORTS_IMPL :/* R/WO, RO */ /* FIXME handle R/WO */ break ; -case HOST_VERSION :/* RO */ +case AHCI_HOST_REG_VERSION :/* RO */ /* FIXME report write? */ break ;default :
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 07/30] ahci: fix spacing damage on ahci_port_write
In reply to John SnowChurn.
Message-id: [email protected]
--- hw/ide/ahci.c | 142 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 71 insertions(+), 71 deletions(-)
hw/ide/ahci.c +71 -71
@@ -279,85 +279,85 @@ static int ahci_cond_start_engines(AHCIDevice *ad)return 0 ; } -static void ahci_port_write (AHCIState *s,int port,int offset,uint32_t val) +static void ahci_port_write (AHCIState *s,int port,int offset,uint32_t val) {AHCIPortRegs *pr = &s->dev[port].port_regs;trace_ahci_port_write (s, port, offset, val);switch (offset) { -case PORT_LST_ADDR : - pr->lst_addr = val; -break ; -case PORT_LST_ADDR_HI : - pr->lst_addr_hi = val; -break ; -case PORT_FIS_ADDR : - pr->fis_addr = val; -break ; -case PORT_FIS_ADDR_HI : - pr->fis_addr_hi = val; -break ; -case PORT_IRQ_STAT : - pr->irq_stat &= ~val; -ahci_check_irq (s); -break ; -case PORT_IRQ_MASK : - pr->irq_mask = val &0xfdc000ff ; -ahci_check_irq (s); -break ; -case PORT_CMD : -/* Block any Read-only fields from being set; -* including LIST_ON and FIS_ON. -* The spec requires to set ICC bits to zero after the ICC change -* is done. We don't support ICC state changes, therefore always -* force the ICC bits to zero. -*/ - pr->cmd = (pr->cmd &PORT_CMD_RO_MASK ) | - (val & ~(PORT_CMD_RO_MASK |PORT_CMD_ICC_MASK )); +case PORT_LST_ADDR : + pr->lst_addr = val; +break ; +case PORT_LST_ADDR_HI : + pr->lst_addr_hi = val; +break ; +case PORT_FIS_ADDR : + pr->fis_addr = val; +break ; +case PORT_FIS_ADDR_HI : + pr->fis_addr_hi = val; +break ; +case PORT_IRQ_STAT : + pr->irq_stat &= ~val; +ahci_check_irq (s); +break ; +case PORT_IRQ_MASK : + pr->irq_mask = val &0xfdc000ff ; +ahci_check_irq (s); +break ; +case PORT_CMD : +/* Block any Read-only fields from being set; +* including LIST_ON and FIS_ON. +* The spec requires to set ICC bits to zero after the ICC change +* is done. We don't support ICC state changes, therefore always +* force the ICC bits to zero. +*/ + pr->cmd = (pr->cmd &PORT_CMD_RO_MASK ) | + (val & ~(PORT_CMD_RO_MASK |PORT_CMD_ICC_MASK )); -/* Check FIS RX and CLB engines */ -ahci_cond_start_engines (&s->dev[port]); +/* Check FIS RX and CLB engines */ +ahci_cond_start_engines (&s->dev[port]); -/* XXX usually the FIS would be pending on the bus here and -issuing deferred until the OS enables FIS receival. -Instead, we only submit it once - which works in most -cases, but is a hack. */ -if ((pr->cmd &PORT_CMD_FIS_ON ) && - !s->dev[port].init_d2h_sent) { -ahci_init_d2h (&s->dev[port]); - } +/* XXX usually the FIS would be pending on the bus here and +issuing deferred until the OS enables FIS receival. +Instead, we only submit it once - which works in most +cases, but is a hack. */ +if ((pr->cmd &PORT_CMD_FIS_ON ) && + !s->dev[port].init_d2h_sent) { +ahci_init_d2h (&s->dev[port]); + } -check_cmd (s, port); -break ; -case PORT_TFDATA : -/* Read Only. */ -break ; -case PORT_SIG : -/* Read Only */ -break ; -case PORT_SCR_STAT : -/* Read Only */ -break ; -case PORT_SCR_CTL : -if (((pr->scr_ctl &AHCI_SCR_SCTL_DET ) ==1 ) && - ((val &AHCI_SCR_SCTL_DET ) ==0 )) { -ahci_reset_port (s, port); - } - pr->scr_ctl = val; -break ; -case PORT_SCR_ERR : - pr->scr_err &= ~val; -break ; -case PORT_SCR_ACT : -/* RW1 */ - pr->scr_act |= val; -break ; -case PORT_CMD_ISSUE : - pr->cmd_issue |= val; -check_cmd (s, port); -break ; -default : -break ; +check_cmd (s, port); +break ; +case PORT_TFDATA : +/* Read Only. */ +break ; +case PORT_SIG : +/* Read Only */ +break ; +case PORT_SCR_STAT : +/* Read Only */ +break ; +case PORT_SCR_CTL : +if (((pr->scr_ctl &AHCI_SCR_SCTL_DET ) ==1 ) && + ((val &AHCI_SCR_SCTL_DET ) ==0 )) { +ahci_reset_port (s, port); + } + pr->scr_ctl = val; +break ; +case PORT_SCR_ERR : + pr->scr_err &= ~val; +break ; +case PORT_SCR_ACT : +/* RW1 */ + pr->scr_act |= val; +break ; +case PORT_CMD_ISSUE : + pr->cmd_issue |= val; +check_cmd (s, port); +break ; +default : +break ; } }
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 18/30] ahci: delete old host register address definitions
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci_internal.h | 6 ------ 1 file changed, 6 deletions(-)
hw/ide/ahci_internal.h +0 -6
@@ -55,12 +55,6 @@#define RX_FIS_UNK 0x60/* offset of Unknown FIS data */ /* global controller registers */ -#define HOST_CAP 0x00/* host capabilities */ -#define HOST_CTL 0x04/* global host control */ -#define HOST_IRQ_STAT 0x08/* interrupt status */ -#define HOST_PORTS_IMPL 0x0c/* bitmap of implemented ports */ -#define HOST_VERSION 0x10/* AHCI spec. version compliancy */ -enum AHCIHostReg {AHCI_HOST_REG_CAP =0 ,/* CAP: host capabilities */ AHCI_HOST_REG_CTL =1 ,/* GHC: global host control */
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 20/30] tests/boot-sector: Add magic bytes to s390x boot code header
In reply to John SnowFrom: Thomas Huth <[email protected]>
We're going to use the s390x boot code for testing CD-ROM booting. But the ISO loader of the s390-ccw bios is a little bit more picky than the network loader and expects some magic bytes in the header of the file (see linux_s390_magic in pc-bios/s390-ccw/bootmap.c), so we've got to add them in our boot code here, too.
--- tests/boot-sector.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
tests/boot-sector.c +6 -3
@@ -68,8 +68,11 @@ static uint8_t x86_boot_sector[512] = { };/* For s390x, use a mini "kernel" with the appropriate signature */ -static const uint8_t s390x_psw[] = { -0x00 ,0x08 ,0x00 ,0x00 ,0x80 ,0x01 ,0x00 ,0x00 +static const uint8_t s390x_psw_and_magic[] = { +0x00 ,0x08 ,0x00 ,0x00 ,0x80 ,0x01 ,0x00 ,0x00 ,/* Program status word */ +0x02 ,0x00 ,0x00 ,0x18 ,0x60 ,0x00 ,0x00 ,0x50 ,/* Magic: */ +0x02 ,0x00 ,0x00 ,0x68 ,0x60 ,0x00 ,0x00 ,0x50 ,/* see linux_s390_magic */ +0x40 ,0x40 ,0x40 ,0x40 ,0x40 ,0x40 ,0x40 ,0x40 /* in the s390-ccw bios */ };static const uint8_t s390x_code[] = {0xa7 ,0xf4 ,0x00 ,0x0a ,/* j 0x10010 */
@@ -110,7 +113,7 @@ int boot_sector_init(char *fname) }else if (g_str_equal (arch,"s390x" )) { len =0x10000 +sizeof (s390x_code); boot_code =g_malloc0 (len); -memcpy (boot_code, s390x_psw,sizeof (s390x_psw)); +memcpy (boot_code, s390x_psw_and_magic,sizeof (s390x_psw_and_magic));memcpy (&boot_code[0x10000 ], s390x_code,sizeof (s390x_code)); }else {g_assert_not_reached ();
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 19/30] ahci: make ahci_mem_write traces more descriptive
In reply to John SnowMessage-id: [email protected]
--- hw/ide/ahci.c | 15 ++++++++++++++- hw/ide/trace-events | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-)
hw/ide/ahci.c +14 -1
@@ -494,13 +494,26 @@ static void ahci_mem_write(void *opaque, hwaddr addr,/* FIXME report write? */ break ;default : -trace_ahci_mem_write_unknown (s, size, addr, val); +qemu_log_mask (LOG_UNIMP , +"Attempted write to unimplemented register: " +"AHCI host register %s, " +"offset 0x%" PRIx64": 0x%" PRIx64, + AHCIHostReg_lookup[regnum], addr, val); +trace_ahci_mem_write_host_unimpl (s, size, + AHCIHostReg_lookup[regnum], addr); } +trace_ahci_mem_write_host (s, size, AHCIHostReg_lookup[regnum], + addr, val); }else if ((addr >=AHCI_PORT_REGS_START_ADDR ) && (addr < (AHCI_PORT_REGS_START_ADDR + (s->ports *AHCI_PORT_ADDR_OFFSET_LEN )))) {ahci_port_write (s, (addr -AHCI_PORT_REGS_START_ADDR ) >>7 , addr &AHCI_PORT_ADDR_OFFSET_MASK , val); + }else { +qemu_log_mask (LOG_UNIMP ,"Attempted write to unimplemented register: " +"AHCI global register at offset 0x%" PRIx64": 0x%" PRIx64, + addr, val); +trace_ahci_mem_write_unimpl (s, size, addr, val); } }
hw/ide/trace-events +3 -1
@@ -77,7 +77,9 @@ ahci_mem_read_32_host(void *s, const char *reg, uint64_t addr, uint32_t val) "ah ahci_mem_read_32_host_default(void *s, const char *reg, uint64_t addr) "ahci(%p): unimplemented mem read [reg:%s] @ 0x%"PRIx64 ahci_mem_read(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): read%u @ 0x%"PRIx64": 0x%016"PRIx64 ahci_mem_write(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u @ 0x%"PRIx64": 0x%016"PRIx64 -ahci_mem_write_unknown(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u to unknown register 0x%"PRIx64": 0x%016"PRIx64 +ahci_mem_write_host_unimpl(void *s, unsigned size, const char *reg, uint64_t addr) "ahci(%p) unimplemented write%u [reg:%s] @ 0x%"PRIx64 +ahci_mem_write_host(void *s, unsigned size, const char *reg, uint64_t addr, uint64_t val) "ahci(%p) write%u [reg:%s] @ 0x%"PRIx64": 0x%016"PRIx64 +ahci_mem_write_unimpl(void *s, unsigned size, uint64_t addr, uint64_t val) "ahci(%p): write%u to unknown register 0x%"PRIx64": 0x%016"PRIx64 ahci_set_signature(void *s, int port, uint8_t nsector, uint8_t sector, uint8_t lcyl, uint8_t hcyl, uint32_t sig) "ahci(%p)[%d]: set signature sector:0x%02x nsector:0x%02x lcyl:0x%02x hcyl:0x%02x (cumulatively: 0x%08x)" ahci_reset_port(void *s, int port) "ahci(%p)[%d]: reset port" ahci_unmap_fis_address_null(void *s, int port) "ahci(%p)[%d]: Attempt to unmap NULL FIS address"
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 23/30] MAINTAINERS: Add the cdrom-test to John's section
In reply to John SnowFrom: Thomas Huth <[email protected]>
The cdrom-test checks various block types - IDE, SCSI and virtio, so it's a little bit hard to decide where this should belong to in the MAINTAINERS file. But John volunteered to take it, so let's put it into the IDE section for now.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -1003,6 +1003,7 @@ F: hw/block/cdrom.c F: hw/block/hd-geometry.c F: tests/ide-test.c F: tests/ahci-test.c +F: tests/cdrom-test.c F: tests/libqos/ahci* T: git git://github.com/jnsnow/qemu.git ide
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 24/30] libqos/ahci: track sector size
In reply to John SnowIt's not always 512, and it does wind up mattering for PIO tranfers, because this means DRQ blocks are four times as big for ATAPI. Replace an instance of 2048 with the correct define, too.
This patch by itself winds changing no behavior. fis->count is ignored for CMD_PACKET, and sect_count only gets used in non-ATAPI cases.
Message-id: [email protected]
--- tests/libqos/ahci.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tests/libqos/ahci.c +6 -4
@@ -90,6 +90,7 @@ struct AHCICommand {uint32_t interrupts;uint64_t xbytes;uint32_t prd_size; +uint32_t sector_size;uint64_t buffer;AHCICommandProp *props;/* Data to be transferred to the guest */
@@ -796,7 +797,7 @@ static void command_header_init(AHCICommand *cmd)static void command_table_init (AHCICommand *cmd) {RegH2DFIS *fis = &(cmd->fis); -uint16_t sect_count = (cmd->xbytes /AHCI_SECTOR_SIZE ); +uint16_t sect_count = (cmd->xbytes / cmd->sector_size); fis->fis_type =REG_H2D_FIS ; fis->flags =REG_H2D_FIS_CMD ;/* "Command" bit */
@@ -819,7 +820,7 @@ static void command_table_init(AHCICommand *cmd)if (cmd->props->lba28 || cmd->props->lba48) { fis->device =ATA_DEVICE_LBA ; } - fis->count = (cmd->xbytes /AHCI_SECTOR_SIZE ); + fis->count = (cmd->xbytes / cmd->sector_size); } fis->icc =0x00 ; fis->control =0x00 ;
@@ -857,6 +858,7 @@ AHCICommand *ahci_command_create(uint8_t command_name) cmd->xbytes = props->size; cmd->prd_size =4096 ; cmd->buffer =0xabad1dea ; + cmd->sector_size = props->atapi ?ATAPI_SECTOR_SIZE :AHCI_SECTOR_SIZE ;if (!cmd->props->ncq) { cmd->interrupts =AHCI_PX_IS_DHRS ;
@@ -1033,7 +1035,7 @@ void ahci_command_set_buffer(AHCICommand *cmd, uint64_t buffer)static void ahci_atapi_set_size (AHCICommand *cmd,uint64_t xbytes) {unsigned char *cbd = cmd->atapi_cmd; -uint64_t nsectors = xbytes /2048 ; +uint64_t nsectors = xbytes /ATAPI_SECTOR_SIZE ;uint32_t tmp;g_assert (cbd);
@@ -1080,7 +1082,7 @@ void ahci_command_set_sizes(AHCICommand *cmd, uint64_t xbytes, cmd->prd_size = prd_size; } cmd->xbytes = xbytes; - sect_count = (cmd->xbytes /AHCI_SECTOR_SIZE ); + sect_count = (cmd->xbytes / cmd->sector_size);if (cmd->props->ncq) {NCQFIS *nfis = (NCQFIS *)&(cmd->fis);
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 28/30] ide: make ide_transfer_stop idempotent
In reply to John SnowFrom: Paolo Bonzini <[email protected]>
There is code checking s->end_transfer_func and it was not taught about ide_transfer_cancel. We can just use ide_transfer_stop because s->end_transfer_func is only ever called in the DRQ phase.
ide_transfer_cancel can then be removed, since it would just be calling ide_transfer_halt.
Message-id: [email protected]
--- hw/ide/core.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
hw/ide/core.c +4 -10
@@ -547,10 +547,9 @@ static void ide_cmd_done(IDEState *s) } } -static void ide_transfer_halt (IDEState *s, -void (*end_transfer_func)(IDEState *)) +static void ide_transfer_halt (IDEState *s) { - s->end_transfer_func = end_transfer_func; + s->end_transfer_func = ide_transfer_stop; s->data_ptr = s->io_buffer; s->data_end = s->io_buffer; s->status &= ~DRQ_STAT ;
@@ -558,15 +557,10 @@ static void ide_transfer_halt(IDEState *s,void ide_transfer_stop (IDEState *s) { -ide_transfer_halt (s, ide_transfer_stop); +ide_transfer_halt (s);ide_cmd_done (s); } -static void ide_transfer_cancel (IDEState *s) -{ -ide_transfer_halt (s, ide_transfer_cancel); -} -int64_t ide_get_sector (IDEState *s) {int64_t sector_num;
@@ -1361,7 +1355,7 @@ static bool cmd_nop(IDEState *s, uint8_t cmd)static bool cmd_device_reset (IDEState *s,uint8_t cmd) {/* Halt PIO (in the DRQ phase), then DMA */ -ide_transfer_cancel (s); +ide_transfer_halt (s);ide_cancel_dma_sync (s);/* Reset any PIO commands, reset signature, etc */
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 29/30] atapi: call ide_set_irq before ide_transfer_start
In reply to John SnowFrom: Paolo Bonzini <[email protected]>
The ATAPI_INT_REASON_IO interrupt is raised when I/O starts, but in the AHCI case ide_set_irq was actually called at the end of a mutual recursion. Move it early, with the side effect that ide_transfer_start becomes a tail call in ide_atapi_cmd_reply_end.
Message-id: [email protected]
--- hw/ide/atapi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/ide/atapi.c +6 -6
@@ -287,6 +287,7 @@ void ide_atapi_cmd_reply_end(IDEState *s) }else {/* a new transfer is needed */ s->nsector = (s->nsector & ~7 ) |ATAPI_INT_REASON_IO ; +ide_set_irq (s->bus); byte_count_limit =atapi_byte_count_limit (s);trace_ide_atapi_cmd_reply_end_bcl (s, byte_count_limit); size = s->packet_transfer_size;
@@ -304,13 +305,12 @@ void ide_atapi_cmd_reply_end(IDEState *s)if (size > (s->cd_sector_size - s->io_buffer_index)) size = (s->cd_sector_size - s->io_buffer_index); } - s->packet_transfer_size -= size; - s->elementary_transfer_size -= size; - s->io_buffer_index += size; -ide_transfer_start (s, s->io_buffer + s->io_buffer_index - size, - size, ide_atapi_cmd_reply_end); -ide_set_irq (s->bus);trace_ide_atapi_cmd_reply_end_new (s, s->status); + s->packet_transfer_size -= size; + s->elementary_transfer_size -= size; + s->io_buffer_index += size; +ide_transfer_start (s, s->io_buffer + s->io_buffer_index - size, + size, ide_atapi_cmd_reply_end); } } }
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 22/30] tests/cdrom-test: Test that -cdrom parameter is working
In reply to John SnowFrom: Thomas Huth <[email protected]>
Commit 1454509726719e0933c800 recently broke the "-cdrom" parameter on a couple of boards without us noticing it immediately. Thus let's add a test which checks that "-cdrom" can at least be used to start QEMU with certain machine types.
--- tests/cdrom-test.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+)
tests/cdrom-test.c +58 -0
@@ -13,6 +13,7 @@#include "qemu/osdep.h" #include "libqtest.h" #include "boot-sector.h" +#include "qapi/qmp/qdict.h" static char isoimage[] ="cdrom-boot-iso-XXXXXX" ;
@@ -89,6 +90,32 @@ cleanup:return ret; } +/** +* Check that at least the -cdrom parameter is basically working, i.e. we can +* see the filename of the ISO image in the output of "info block" afterwards +*/ +static void test_cdrom_param (gconstpointer data) +{ +QTestState *qts; +char *resp; + + qts =qtest_startf ("-M %s -cdrom %s" , (const char *)data, isoimage); + resp =qtest_hmp (qts,"info block" ); +g_assert (strstr (resp, isoimage) !=0 ); +g_free (resp); +qtest_quit (qts); +} + +static void add_cdrom_param_tests (const char **machines) +{ +while (*machines) { +char *testname =g_strdup_printf ("cdrom/param/%s" , *machines); +qtest_add_data_func (testname, *machines, test_cdrom_param); +g_free (testname); + machines++; + } +} +static void test_cdboot (gconstpointer data) {QTestState *qts;
@@ -154,6 +181,37 @@ int main(int argc, char **argv)add_x86_tests (); }else if (g_str_equal (arch,"s390x" )) {add_s390x_tests (); + }else if (g_str_equal (arch,"ppc64" )) { +const char *ppcmachines[] = { +"pseries" ,"mac99" ,"g3beige" ,"40p" ,"prep" ,NULL + }; +add_cdrom_param_tests (ppcmachines); + }else if (g_str_equal (arch,"sparc" )) { +const char *sparcmachines[] = { +"LX" ,"SPARCClassic" ,"SPARCbook" ,"SS-10" ,"SS-20" ,"SS-4" , +"SS-5" ,"SS-600MP" ,"Voyager" ,"leon3_generic" ,NULL + }; +add_cdrom_param_tests (sparcmachines); + }else if (g_str_equal (arch,"sparc64" )) { +const char *sparc64machines[] = { +"niagara" ,"sun4u" ,"sun4v" ,NULL + }; +add_cdrom_param_tests (sparc64machines); + }else if (!strncmp (arch,"mips64" ,6 )) { +const char *mips64machines[] = { +"magnum" ,"malta" ,"mips" ,"pica61" ,NULL + }; +add_cdrom_param_tests (mips64machines); + }else if (g_str_equal (arch,"arm" ) ||g_str_equal (arch,"aarch64" )) { +const char *armmachines[] = { +"realview-eb" ,"realview-eb-mpcore" ,"realview-pb-a8" , +"realview-pbx-a9" ,"versatileab" ,"versatilepb" ,"vexpress-a15" , +"vexpress-a9" ,"virt" ,NULL + }; +add_cdrom_param_tests (armmachines); + }else { +const char *nonemachine[] = {"none" ,NULL }; +add_cdrom_param_tests (nonemachine); } ret =g_test_run ();
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 21/30] tests/cdrom-test: Test booting from CD-ROM ISO image file
In reply to John SnowFrom: Thomas Huth <[email protected]>
We already have the code for a boot file in tests/boot-sector.c, so if the genisoimage program is available, we can easily create a bootable CD ISO image that we can use for testing whether our CD-ROM emulation and the BIOS CD-ROM boot works correctly.
--- tests/Makefile.include | 2 + tests/cdrom-test.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+) create mode 100644 tests/cdrom-test.c
tests/Makefile.include +2 -0
@@ -179,6 +179,7 @@ check-qtest-generic-y = tests/qmp-test$(EXESUF) gcov-files-generic-y = monitor.c qapi/qmp-dispatch.c check-qtest-generic-y += tests/device-introspect-test$(EXESUF) gcov-files-generic-y = qdev-monitor.c qmp.c +check-qtest-generic-y += tests/cdrom-test$(EXESUF) gcov-files-ipack-y += hw/ipack/ipack.c check-qtest-ipack-y += tests/ipoctal232-test$(EXESUF)
@@ -844,6 +845,7 @@ tests/test-qapi-util$(EXESUF): tests/test-qapi-util.o $(test-util-obj-y) tests/numa-test$(EXESUF): tests/numa-test.o tests/vmgenid-test$(EXESUF): tests/vmgenid-test.o tests/boot-sector.o tests/acpi-utils.o tests/sdhci-test$(EXESUF): tests/sdhci-test.o $(libqos-pc-obj-y) +tests/cdrom-test$(EXESUF): tests/cdrom-test.o tests/boot-sector.o $(libqos-obj-y) tests/migration/stress$(EXESUF): tests/migration/stress.o $(call quiet-command, $(LINKPROG) -static -O3 $(PTHREAD_LIB) -o $@ $< ,"LINK","$(TARGET_DIR)$@")
tests/cdrom-test.c new file +164 -0
164 lines not on this page · raw message
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 25/30] ahci: move PIO Setup FIS before transfer, fix it for ATAPI commands
In reply to John SnowThe PIO Setup FIS is written in the PIO:Entry state, which comes before the ATA and ATAPI data transfer states. As a result, the PIO Setup FIS interrupt is now raised before DMA ends for ATAPI commands, and tests have to be adjusted.
This is also hinted by the description of the command header in the AHCI specification, where the "A" bit is described as
When ‘1’, indicates that a PIO setup FIS shall be sent by the device indicating a transfer for the ATAPI command.
and also by the description of the ACMD (ATAPI command region):
The ATAPI command must be either 12 or 16 bytes in length. The length transmitted by the HBA is determined by the PIO setup FIS that is sent by the device requesting the ATAPI command.
QEMU, which conflates the "generator" and the "receiver" of the FIS into one device, always uses ATAPI_PACKET_SIZE, aka 12, for the length.
Message-id: [email protected]
--- hw/ide/ahci.c | 18 ++++++------------ tests/libqos/ahci.c | 35 +++++++++++++++++++++-------------- tests/libqos/ahci.h | 3 +-- 3 files changed, 28 insertions(+), 28 deletions(-)
hw/ide/ahci.c +6 -12
@@ -1259,7 +1259,6 @@ static void handle_reg_h2d_fis(AHCIState *s, int port,g_free (pretty_fis); } s->dev[port].done_atapi_packet = false; -/* XXX send PIO setup FIS */ } ide_state->error =0 ;
@@ -1353,10 +1352,12 @@ static void ahci_start_transfer(IDEDMA *dma)int is_atapi = opts &AHCI_CMD_ATAPI ;int has_sglist =0 ; +/* PIO FIS gets written prior to transfer */ +ahci_write_fis_pio (ad, size); +if (is_atapi && !ad->done_atapi_packet) {/* already prepopulated iobuffer */ ad->done_atapi_packet = true; - size =0 ; goto out; }
@@ -1376,19 +1377,12 @@ static void ahci_start_transfer(IDEDMA *dma) } } -out: -/* declare that we processed everything */ - s->data_ptr = s->data_end; -/* Update number of transferred bytes, destroy sglist */ dma_buf_commit (s, size); - +out: +/* declare that we processed everything */ + s->data_ptr = s->data_end; s->end_transfer_func (s); - -if (!(s->status &DRQ_STAT )) { -/* done with PIO send/receive */ -ahci_write_fis_pio (ad,le32_to_cpu (ad->cur_cmd->status)); - } } static void ahci_start_dma(IDEDMA *dma, IDEState *s,
tests/libqos/ahci.c +21 -14
@@ -478,10 +478,10 @@ void ahci_port_check_d2h_sanity(AHCIQState *ahci, uint8_t port, uint8_t slot)g_free (d2h); } -void ahci_port_check_pio_sanity (AHCIQState *ahci,uint8_t port, -uint8_t slot,size_t buffsize) +void ahci_port_check_pio_sanity (AHCIQState *ahci,AHCICommand *cmd) {PIOSetupFIS *pio =g_malloc0 (0x20 ); +uint8_t port = cmd->port;/* We cannot check the Status or E_Status registers, because * the status may have again changed between the PIO Setup FIS
@@ -489,15 +489,22 @@ void ahci_port_check_pio_sanity(AHCIQState *ahci, uint8_t port,qtest_memread (ahci->parent->qts, ahci->port[port].fb +0x20 , pio,0x20 ); g_assert_cmphex(pio->fis_type, ==, 0x5f); -/* BUG: PIO Setup FIS as utilized by QEMU tries to fit the entire -* transfer size in a uint16_t field. The maximum transfer size can -* eclipse this; the field is meant to convey the size of data per -* each Data FIS, not the entire operation as a whole. For now, -* we will sanity check the broken case where applicable. */ -if (buffsize <=UINT16_MAX ) { - g_assert_cmphex(le16_to_cpu(pio->tx_count), ==, buffsize); +/* Data transferred by PIO will either be: +* (1) 12 or 16 bytes for an ATAPI command packet (QEMU always uses 12), or +* (2) Actual data from the drive. +* If we do both, (2) winds up erasing any evidence of (1). +*/ +if (cmd->props->atapi && (cmd->xbytes ==0 || cmd->props->dma)) { +g_assert (le16_to_cpu (pio->tx_count) ==12 || +le16_to_cpu (pio->tx_count) ==16 ); + }else { +/* The AHCI test suite here does not test any PIO command that specifies +* a DRQ block larger than one sector (like 0xC4), so this should always +* be one sector or less. */ +size_t pio_len = ((cmd->xbytes % cmd->sector_size) ? + (cmd->xbytes % cmd->sector_size) : cmd->sector_size); + g_assert_cmphex(le16_to_cpu(pio->tx_count), ==, pio_len); } -g_free (pio); }
@@ -832,9 +839,9 @@ void ahci_command_enable_atapi_dma(AHCICommand *cmd)RegH2DFIS *fis = &(cmd->fis);g_assert (cmd->props->atapi); fis->feature_low |=0x01 ; - cmd->interrupts &= ~AHCI_PX_IS_PSS ; +/* PIO is still used to transfer the ATAPI command */ +g_assert (cmd->props->pio); cmd->props->dma = true; - cmd->props->pio = false;/* BUG: We expect the DMA Setup interrupt for DMA commands */ /* cmd->interrupts |= AHCI_PX_IS_DSS; */ }
@@ -846,7 +853,7 @@ AHCICommand *ahci_command_create(uint8_t command_name)g_assert (props); cmd =g_new0 (AHCICommand,1 ); -g_assert (!(props->dma && props->pio)); +g_assert (!(props->dma && props->pio) || props->atapi);g_assert (!(props->lba28 && props->lba48));g_assert (!(props->read && props->write));g_assert (!props->size || props->data);
@@ -1218,7 +1225,7 @@ void ahci_command_verify(AHCIQState *ahci, AHCICommand *cmd)ahci_port_check_d2h_sanity (ahci, port, slot); }if (cmd->props->pio) { -ahci_port_check_pio_sanity (ahci, port, slot, cmd->xbytes); +ahci_port_check_pio_sanity (ahci, cmd); } }
tests/libqos/ahci.h +1 -2
@@ -596,8 +596,7 @@ void ahci_port_check_interrupts(AHCIQState *ahci, uint8_t port, uint32_t intr_mask);void ahci_port_check_nonbusy (AHCIQState *ahci,uint8_t port,uint8_t slot);void ahci_port_check_d2h_sanity (AHCIQState *ahci,uint8_t port,uint8_t slot); -void ahci_port_check_pio_sanity (AHCIQState *ahci,uint8_t port, -uint8_t slot,size_t buffsize); +void ahci_port_check_pio_sanity (AHCIQState *ahci,AHCICommand *cmd);void ahci_port_check_cmd_sanity (AHCIQState *ahci,AHCICommand *cmd);/* Misc */
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 26/30] ide: push end_transfer_func out of start_transfer callback, rename callback
In reply to John SnowFrom: Paolo Bonzini <[email protected]>
Now that end_transfer_func is a tail call in ahci_start_transfer, formalize the fact that the callback (of which ahci_start_transfer is the sole implementation) takes care of the transfer too: rename it to pio_transfer and, if it is present, call the end_transfer_func as soon as it returns.
Message-id: [email protected]
--- hw/ide/ahci.c | 13 ++++++------- hw/ide/core.c | 8 +++++--- hw/ide/trace-events | 2 +- include/hw/ide/internal.h | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-)
hw/ide/ahci.c +6 -7
@@ -1340,8 +1340,8 @@ out:return 0 ; } -/* DMA dev <-> ram */ -static void ahci_start_transfer (IDEDMA *dma) +/* Transfer PIO data between RAM and device */ +static void ahci_pio_transfer (IDEDMA *dma) {AHCIDevice *ad =DO_UPCAST (AHCIDevice, dma, dma);IDEState *s = &ad->port.ifs[0 ];
@@ -1365,9 +1365,9 @@ static void ahci_start_transfer(IDEDMA *dma) has_sglist =1 ; } -trace_ahci_start_transfer (ad->hba, ad->port_no, is_write ?"writ" :"read" , - size, is_atapi ?"atapi" :"ata" , - has_sglist ?"" :"o" ); +trace_ahci_pio_transfer (ad->hba, ad->port_no, is_write ?"writ" :"read" , + size, is_atapi ?"atapi" :"ata" , + has_sglist ?"" :"o" );if (has_sglist && size) {if (is_write) {
@@ -1382,7 +1382,6 @@ static void ahci_start_transfer(IDEDMA *dma) out:/* declare that we processed everything */ s->data_ptr = s->data_end; - s->end_transfer_func (s); } static void ahci_start_dma(IDEDMA *dma, IDEState *s,
@@ -1503,7 +1502,7 @@ static const IDEDMAOps ahci_dma_ops = { .start_dma = ahci_start_dma, .restart = ahci_restart, .restart_dma = ahci_restart_dma, - .start_transfer = ahci_start_transfer, + .pio_transfer = ahci_pio_transfer, .prepare_buf = ahci_dma_prepare_buf, .commit_buf = ahci_commit_buf, .rw_buf = ahci_dma_rw_buf,
hw/ide/core.c +5 -3
@@ -526,16 +526,18 @@ static void ide_clear_retry(IDEState *s)void ide_transfer_start (IDEState *s,uint8_t *buf,int size,EndTransferFunc *end_transfer_func) { - s->end_transfer_func = end_transfer_func; s->data_ptr = buf; s->data_end = buf + size;ide_set_retry (s);if (!(s->status &ERR_STAT )) { s->status |=DRQ_STAT ; } -if (s->bus->dma->ops->start_transfer) { - s->bus->dma->ops->start_transfer (s->bus->dma); +if (!s->bus->dma->ops->pio_transfer) { + s->end_transfer_func = end_transfer_func; +return ; } + s->bus->dma->ops->pio_transfer (s->bus->dma); +end_transfer_func (s); }static void ide_cmd_done (IDEState *s)
hw/ide/trace-events +1 -1
@@ -108,7 +108,7 @@ handle_cmd_badport(void *s, int port) "ahci(%p)[%d]: guest accessed unused port" handle_cmd_badfis(void *s, int port) "ahci(%p)[%d]: guest provided an invalid cmd FIS" handle_cmd_badmap(void *s, int port, uint64_t len) "ahci(%p)[%d]: dma_memory_map failed, 0x%02"PRIx64" != 0x80" handle_cmd_unhandled_fis(void *s, int port, uint8_t b0, uint8_t b1, uint8_t b2) "ahci(%p)[%d]: unhandled FIS type. cmd_fis: 0x%02x-%02x-%02x" -ahci_start_transfer(void *s, int port, const char *rw, uint32_t size, const char *tgt, const char *sgl) "ahci(%p)[%d]: %sing %d bytes on %s w/%s sglist" +ahci_pio_transfer(void *s, int port, const char *rw, uint32_t size, const char *tgt, const char *sgl) "ahci(%p)[%d]: %sing %d bytes on %s w/%s sglist" ahci_start_dma(void *s, int port) "ahci(%p)[%d]: start dma" ahci_dma_prepare_buf(void *s, int port, int32_t io_buffer_size, int32_t limit) "ahci(%p)[%d]: prepare buf limit=%"PRId32" prepared=%"PRId32 ahci_dma_prepare_buf_fail(void *s, int port) "ahci(%p)[%d]: sglist population failed"
include/hw/ide/internal.h +1 -1
@@ -444,7 +444,7 @@ struct IDEState {struct IDEDMAOps {DMAStartFunc *start_dma; -DMAVoidFunc *start_transfer; +DMAVoidFunc *pio_transfer;DMAInt32Func *prepare_buf;DMAu32Func *commit_buf;DMAIntFunc *rw_buf;
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 27/30] ide: call ide_cmd_done from ide_transfer_stop
In reply to John SnowFrom: Paolo Bonzini <[email protected]>
The code can simply be moved to the sole caller that has notify == true.
Message-id: [email protected]
--- hw/ide/core.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
hw/ide/core.c +4 -7
@@ -548,26 +548,23 @@ static void ide_cmd_done(IDEState *s) }static void ide_transfer_halt (IDEState *s, -void (*end_transfer_func)(IDEState *), -bool notify) +void (*end_transfer_func)(IDEState *)) { s->end_transfer_func = end_transfer_func; s->data_ptr = s->io_buffer; s->data_end = s->io_buffer; s->status &= ~DRQ_STAT ; -if (notify) { -ide_cmd_done (s); - } }void ide_transfer_stop (IDEState *s) { -ide_transfer_halt (s, ide_transfer_stop, true); +ide_transfer_halt (s, ide_transfer_stop); +ide_cmd_done (s); }static void ide_transfer_cancel (IDEState *s) { -ide_transfer_halt (s, ide_transfer_cancel, false); +ide_transfer_halt (s, ide_transfer_cancel); }int64_t ide_get_sector (IDEState *s)
Signature · 1 line
2.14.3
[Qemu-devel] [PULL 30/30] ide: introduce ide_transfer_start_norecurse
In reply to John SnowFrom: Paolo Bonzini <[email protected]>
For the case where the end_transfer_func is also the caller of ide_transfer_start, the mutual recursion can lead to unlimited stack usage. Introduce a new version that can be used to change tail recursion into a loop, and use it in trace_ide_atapi_cmd_reply_end.
Message-id: [email protected]
--- hw/ide/atapi.c | 42 +++++++++++++++++++++++------------------- hw/ide/core.c | 16 ++++++++++++---- include/hw/ide/internal.h | 2 ++ 3 files changed, 37 insertions(+), 23 deletions(-)
hw/ide/atapi.c +23 -19
@@ -245,15 +245,11 @@ static uint16_t atapi_byte_count_limit(IDEState *s)void ide_atapi_cmd_reply_end (IDEState *s) {int byte_count_limit, size, ret; -trace_ide_atapi_cmd_reply_end (s, s->packet_transfer_size, - s->elementary_transfer_size, - s->io_buffer_index); -if (s->packet_transfer_size <=0 ) { -/* end of transfer */ -ide_atapi_cmd_ok (s); -ide_set_irq (s->bus); -trace_ide_atapi_cmd_reply_end_eot (s, s->status); - }else { +while (s->packet_transfer_size >0 ) { +trace_ide_atapi_cmd_reply_end (s, s->packet_transfer_size, + s->elementary_transfer_size, + s->io_buffer_index); +/* see if a new sector must be read */ if (s->lba !=-1 && s->io_buffer_index >= s->cd_sector_size) {if (!s->elementary_transfer_size) {
@@ -279,11 +275,6 @@ void ide_atapi_cmd_reply_end(IDEState *s) size = s->cd_sector_size - s->io_buffer_index;if (size > s->elementary_transfer_size) size = s->elementary_transfer_size; - s->packet_transfer_size -= size; - s->elementary_transfer_size -= size; - s->io_buffer_index += size; -ide_transfer_start (s, s->io_buffer + s->io_buffer_index - size, - size, ide_atapi_cmd_reply_end); }else {/* a new transfer is needed */ s->nsector = (s->nsector & ~7 ) |ATAPI_INT_REASON_IO ;
@@ -306,13 +297,26 @@ void ide_atapi_cmd_reply_end(IDEState *s) size = (s->cd_sector_size - s->io_buffer_index); }trace_ide_atapi_cmd_reply_end_new (s, s->status); - s->packet_transfer_size -= size; - s->elementary_transfer_size -= size; - s->io_buffer_index += size; -ide_transfer_start (s, s->io_buffer + s->io_buffer_index - size, - size, ide_atapi_cmd_reply_end); + } + s->packet_transfer_size -= size; + s->elementary_transfer_size -= size; + s->io_buffer_index += size; + +/* Some adapters process PIO data right away. In that case, we need +* to avoid mutual recursion between ide_transfer_start +* and ide_atapi_cmd_reply_end. +*/ +if (!ide_transfer_start_norecurse (s, + s->io_buffer + s->io_buffer_index - size, + size, ide_atapi_cmd_reply_end)) { +return ; } } + +/* end of transfer */ +trace_ide_atapi_cmd_reply_end_eot (s, s->status); +ide_atapi_cmd_ok (s); +ide_set_irq (s->bus); }/* send a reply of 'size' bytes in s->io_buffer to an ATAPI command */
hw/ide/core.c +12 -4
@@ -523,8 +523,8 @@ static void ide_clear_retry(IDEState *s) }/* prepare data transfer and tell what to do after */ -void ide_transfer_start (IDEState *s,uint8_t *buf,int size, -EndTransferFunc *end_transfer_func) +bool ide_transfer_start_norecurse (IDEState *s,uint8_t *buf,int size, +EndTransferFunc *end_transfer_func) { s->data_ptr = buf; s->data_end = buf + size;
@@ -534,10 +534,18 @@ void ide_transfer_start(IDEState *s, uint8_t *buf, int size, }if (!s->bus->dma->ops->pio_transfer) { s->end_transfer_func = end_transfer_func; -return ; +return false; } s->bus->dma->ops->pio_transfer (s->bus->dma); -end_transfer_func (s); +return true; +} + +void ide_transfer_start (IDEState *s,uint8_t *buf,int size, +EndTransferFunc *end_transfer_func) +{ +if (ide_transfer_start_norecurse (s, buf, size, end_transfer_func)) { +end_transfer_func (s); + } }static void ide_cmd_done (IDEState *s)
include/hw/ide/internal.h +2 -0
@@ -623,6 +623,8 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val);void ide_transfer_start (IDEState *s,uint8_t *buf,int size,EndTransferFunc *end_transfer_func); +bool ide_transfer_start_norecurse (IDEState *s,uint8_t *buf,int size, +EndTransferFunc *end_transfer_func);void ide_transfer_stop (IDEState *s);void ide_set_inactive (IDEState *s,bool more); BlockAIOCB *ide_issue_trim(
Signature · 1 line
2.14.3
Peter Maydell
AppliedQuoted 10 lines · John Snow
The following changes since commit
0d2fa03dae4fbe185a082f361342b1e30aed4582:Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180608' into staging (2018-06-08 16:26:51 +0100)
are available in the Git repository at:
https://github.com/jnsnow/qemu.git tags/ide-pull-request
for you to fetch changes up to
c173723f247c69974a83af1395020d0f01a0d334:
Quoted 7 lines
ide: introduce
ide_transfer_start_norecurse(2018-06-08 13:36:31 -0400)----------------------------------------------------------------
AHCI Pull request
----------------------------------------------------------------
Applied, thanks.
-- PMM