Drop code for non-qdevified IDE, and clean up
cover Drop code for non-qdevified IDE, and clean up
*** Important ***
This *breaks* all non-qdevified controllers, see PATCH 01/10. Maintainers are cc'ed.
If you want still more time to qdevify your controller, please speak up now, and tell us how much.
The rest of the series is obvious cleanups enabled by dropping the special case of a non-qdevified controller. The block configuration stuff I'm working on also profits from it, and is real reason I'm posting this.
Markus Armbruster (10):
ide: Break all non-qdevified controllers
ide: Move IDEDevice pointer from IDEBus to IDEState
ide: Use IDEState member dev for "device connected" test
ide: Don't block-align IDEState member smart_selftest_data
ide: Drop redundant IDEState member bs
ide: Drop redundant IDEState geometry members
ide: Drop redundant IDEState member version
ide: Drop redundant IDEState member drive_serial_str
ide: Drop redundant IDEState member model
ide: Drop redundant IDEState member wwn
hw/ide/ahci.c | 19 ++-- hw/ide/atapi.c | 39 ++++---- hw/ide/core.c | 278 +++++++++++++++++++++------------------------------- hw/ide/internal.h | 15 +-- hw/ide/macio.c | 20 ++-- hw/ide/microdrive.c | 5 +- hw/ide/piix.c | 1 - hw/ide/qdev.c | 50 +++++----- 8 files changed, 189 insertions(+), 238 deletions(-)
Signature · 1 line
1.7.11.7
PATCH 1/10 ide: Break all non-qdevified controllers
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit d353fb72) is broken for them, because ide_identify() accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.
The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
* g3beige's first IDE channel (MacIO)
-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work
* mac99's second and third IDE channel (MacIO) All four IDE drives no longer work
* spitz, borzoi, terrier and tosa (CF microdrive) -hda no longer works
the other IDE drives have always been silently ignored
* r2d's onboard CF (MMIO)
-hda no longer works
the other IDE drives have always been silently ignored
The writing has been on the wall for a few years.
--- hw/ide/core.c | 43 +++++++++---------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-)
hw/ide/core.c +9 -34
@@ -2057,53 +2057,28 @@ void ide_init2(IDEBus *bus, qemu_irq irq) bus->dma = &ide_dma_nop; } -/* TODO convert users to qdev and remove */ +/* TODO users are *broken*; convert them to qdev and remove this function */ void ide_init2_with_non_qdev_drives (IDEBus *bus,DriveInfo *hd0,DriveInfo *hd1,qemu_irq irq) { -int i, trans; +Location loc; +int i;DriveInfo *dinfo; -uint32_t cyls, heads, secs; +loc_push_none (&loc);for (i =0 ; i <2 ; i++) { dinfo = i ==0 ? hd0 : hd1;ide_init1 (bus, i);if (dinfo) { - cyls = dinfo->cyls; - heads = dinfo->heads; - secs = dinfo->secs; - trans = dinfo->trans; -if (!cyls && !heads && !secs) { -hd_geometry_guess (dinfo->bdrv, &cyls, &heads, &secs, &trans); - }else if (trans ==BIOS_ATA_TRANSLATION_AUTO ) { - trans =hd_bios_chs_auto_trans (cyls, heads, secs); - } -if (cyls <1 || cyls >65535 ) { -error_report ("cyls must be between 1 and 65535" ); -exit (1 ); - } -if (heads <1 || heads >16 ) { -error_report ("heads must be between 1 and 16" ); -exit (1 ); - } -if (secs <1 || secs >255 ) { -error_report ("secs must be between 1 and 255" ); -exit (1 ); - } -if (ide_init_drive (&bus->ifs[i], dinfo->bdrv, - dinfo->media_cd ?IDE_CD :IDE_HD , -NULL , dinfo->serial,NULL ,0 , - cyls, heads, secs, trans) <0 ) { -error_report ("Can't set up IDE drive %s" , dinfo->id); -exit (1 ); - } -bdrv_attach_dev_nofail (dinfo->bdrv, &bus->ifs[i]); - }else { -ide_reset (&bus->ifs[i]); +qemu_opts_loc_restore (dinfo->opts); +error_report ("IDE controller not qdevified yet; drive %s ignored" , + dinfo->id); } +ide_reset (&bus->ifs[i]); } bus->irq = irq; bus->dma = &ide_dma_nop; +loc_pop (&loc); }static const MemoryRegionPortio ide_portio_list[] = {
Signature · 1 line
1.7.11.7
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 9 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Quoted 7 lines
Affected machines:
* g3beige's first IDE channel (MacIO)
-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work
* mac99's second and third IDE channel (MacIO) All four IDE drives no longer work
Nack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Alex
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 13 lines · Alexander Graf
Quoted 11 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
Quoted 7 lines
Quoted 5 lines
* g3beige's first IDE channel (MacIO)
-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work
* mac99's second and third IDE channel (MacIO) All four IDE drives no longer workNack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 23 lines · Markus Armbruster
Quoted 13 lines · Alexander Graf
Quoted 11 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
Quoted 7 lines
Quoted 5 lines
* g3beige's first IDE channel (MacIO)
(quoted diff) +0
-2-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work* mac99's second and third IDE channel (MacIO)
All four IDE drives no longer workNack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Quoted 2 lines
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
I don't know. If it's dear to you, just convert it yourself. Apparently you're quite deep into the details here already, so it's a lot easier for you than for me anyways.
Alex
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 26 lines · Alexander Graf
Quoted 24 lines · Markus Armbruster
Quoted 21 lines · Alexander Graf
Quoted 14 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
* g3beige's first IDE channel (MacIO)
(quoted diff) +0
-2-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still workQuoted 2 lines
* mac99's second and third IDE channel (MacIO)
All four IDE drives no longer workNack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Quoted 6 lines
Quoted 2 lines
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
I don't know. If it's dear to you, just convert it yourself. Apparently you're quite deep into the details here already, so it's a lot easier for you than for me anyways.
These controllers aren't dear to me, they're in the way. Have been for years. I doubt hacking them is easier for me than for you.
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 31 lines · Markus Armbruster
Quoted 29 lines · Alexander Graf
Quoted 26 lines · Markus Armbruster
Quoted 13 lines · Alexander Graf
Quoted 11 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
Quoted 8 lines
Quoted 5 lines
* g3beige's first IDE channel (MacIO)
(quoted diff) +0
-2-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work* mac99's second and third IDE channel (MacIO)
All four IDE drives no longer workNack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
Quoted 6 lines
Quoted 3 lines
I don't know. If it's dear to you, just convert it yourself. Apparently you're quite deep into the details here already, so it's a lot easier for you than for me anyways.
These controllers aren't dear to me, they're in the way. Have been for years. I doubt hacking them is easier for me than for you.
Windows XP support has been in my way plenty times too. I still don't (heavily) suggest dropping it.
Alex
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 37 lines · Alexander Graf
Quoted 35 lines · Markus Armbruster
Quoted 32 lines · Alexander Graf
Quoted 24 lines · Markus Armbruster
Quoted 13 lines · Alexander Graf
Quoted 11 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
Quoted 8 lines
Quoted 5 lines
* g3beige's first IDE channel (MacIO)
(quoted diff) +0
-2-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work* mac99's second and third IDE channel (MacIO)
All four IDE drives no longer workNack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Quoted 2 lines
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
I don't know. If it's dear to you, just convert it yourself. Apparently you're quite deep into the details here already, so it's a lot easier for you than for me anyways.
Quoted 5 lines
Quoted 2 lines
These controllers aren't dear to me, they're in the way. Have been for years. I doubt hacking them is easier for me than for you.
Windows XP support has been in my way plenty times too. I still don't (heavily) suggest dropping it.
I'm not suggesting to drop these targets. I'm suggesting they get the maintainance they need to keep up with evolving infrastructure.
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
In reply to Markus ArmbrusterAm 17.12.2012 15:43, schrieb Markus Armbruster:
Quoted 21 lines
Quoted 19 lines · Alexander Graf
Quoted 16 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
* g3beige's first IDE channel (MacIO)
-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work
* mac99's second and third IDE channel (MacIO) All four IDE drives no longer work
Quoted 4 lines
Quoted 1 line
Nack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
I believe I have a branch with macio QOM'ifications somewhere that I could revive. Note that I know little about IDE or block layer and mainly care about consistent infrastructure there; I vaguely remember something about the mac's IDE channels being mixed together from two devices unlike real hardware, guess I would be unable to fix that.
As for your question, 2013 and a gentle reminder to all involved would be nice. :) In particular we have the Soft Freeze coming up shortly after the holidays, so is this needed for 1.4 Soft Freeze or can it be deferred to 1.5 or done during the 1.4 Soft Freeze?
If Aurélien (CC'ed) doesn't manage, I can look at r2d as well. CC'ing Peter and Andrzej for the arm devices.
Regards,
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 22 lines · Andreas Färber
Am 17.12.2012 15:43, schrieb Markus Armbruster:
Quoted 21 lines
Quoted 19 lines · Alexander Graf
Quoted 16 lines · Markus Armbruster
They complicate IDE data structures and keep getting in the way. Also, TRIM support (commit
d353fb72) is broken for them, becauseide_identify()accesses IDEDevice member conf, but IDEDevice exists only with qdevified controllers.The non-qdevified controllers are still there, but attempting to connect devices to them fails with "IDE controller not qdevified yet; drive <name> ignored".
Affected machines:
* g3beige's first IDE channel (MacIO)
-hda, -hdb are on first channel, and no longer work -hdc, -hdd are on second channel, and still work
* mac99's second and third IDE channel (MacIO) All four IDE drives no longer work
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Nack. This breaks the default targets of qemu-system-ppc and qemu-system-ppc64.
Please tell us how much more time you want to qdevify IDE for these targets. Thanks!
I believe I have a branch with macio QOM'ifications somewhere that I could revive.
I'd appreciate that.
Quoted 4 lines
Note that I know little about IDE or block layer and
mainly care about consistent infrastructure there; I vaguely remember something about the mac's IDE channels being mixed together from two devices unlike real hardware, guess I would be unable to fix that.
Yes, g3beige's first IDE channel is MacIO (not qdevified), second is CMD646 (qdevified), and mac99's first IDE channel is unimplemented, second and third are MacIO (not qdevified). Inhowfar that matches real hardware I don't know.
Quoted 2 lines
As for your question, 2013 and a gentle reminder to all involved would be nice. :)
In my experience with IDE qdevification, gentle reminders do not work. But I'd be delighted to be proven wrong.
Quoted 6 lines
In particular we have the Soft Freeze coming up shortly
after the holidays, so is this needed for 1.4 Soft Freeze or can it be deferred to 1.5 or done during the 1.4 Soft Freeze?If Aurélien (CC'ed) doesn't manage, I can look at r2d as well. CC'ing Peter and Andrzej for the arm devices.
In time for 1.4 would be good, because it's in the way of the block backend configuration work I'd like to get into 1.4. If I can pull it off in time. Having to hack around IDE silliness that cannot be cleaned up while we still have non-qdevified controllers isn't helping :)
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
In reply to Markus ArmbrusterQuoted 1 line · Markus Armbruster
The writing has been on the wall for a few years.
...behind a filing cabinet in a disused lavatory with a sign on the door saying "beware of the leopard"?
We really need a better way to mark devices as "obsolete, will be removed/broken/etc in a future version"...
-- PMM
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 8 lines · Peter Maydell
Quoted 1 line · Markus Armbruster
The writing has been on the wall for a few years.
...behind a filing cabinet in a disused lavatory with a sign on the door saying "beware of the leopard"?
We really need a better way to mark devices as "obsolete, will be removed/broken/etc in a future version"...
Yes, we do.
These devices, however, are a slightly different case: "need maintenance, will be removed unless they get it". I've asked for them to be updated on several occasions, on the list[*], and in person at the last three KVM Forums.
Having your board in the tree is a privilege, not a right. You earn the privilege by doing your share of the work. In my opinion, that includes moving them off obsolete infrastructure in a timely manner, at least when keeping the obsolete infrastructure around just for you becomes a drag. Which it definitely has been in case of IDE.
[*] http://lists.nongnu.org/archive/html/qemu-devel/2012-07/msg00621.html
Re: [Qemu-devel] [PATCH 01/10] ide: Break all non-qdevified controllers
Quoted 10 lines · Markus Armbruster
Quoted 2 lines · Peter Maydell
We really need a better way to mark devices as "obsolete, will be removed/broken/etc in a future version"...
Yes, we do.
These devices, however, are a slightly different case: "need maintenance, will be removed unless they get it". I've asked for them to be updated on several occasions, on the list[*], and in person at the last three KVM Forums.
My concern is basically that I suspect there's a user community out there that doesn't necessarily read the list or go to KVM Forum. I actually have no idea which of the various elderly ARM boards are really used and which we could just delete. If back in July we'd marked the relevant boards as "this may disappear in the next version" we might have got some feedback about if anybody was actually using tosa, spitz, etc.
Quoted 2 lines
Having your board in the tree is a privilege, not a right. You earn the privilege by doing your share of the work.
I agree completely with this.
-- PMM
PATCH 2/10 ide: Move IDEDevice pointer from IDEBus to IDEState
In reply to Markus Armbruster--- hw/ide/core.c | 2 +- hw/ide/internal.h | 3 +-- hw/ide/qdev.c | 12 +++--------- 3 files changed, 5 insertions(+), 12 deletions(-)
hw/ide/core.c +1 -1
@@ -79,7 +79,7 @@ static void ide_identify(IDEState *s) {uint16_t *p;unsigned int oldsize; -IDEDevice *dev = s->unit ? s->bus->slave : s->bus->master; +IDEDevice *dev = s->dev;if (s->identify_set) {memcpy (s->io_buffer, s->identify_data,sizeof (s->identify_data));
hw/ide/internal.h +1 -2
@@ -342,6 +342,7 @@ enum ide_dma_cmd {/* NOTE: IDEState represents in fact one drive */ struct IDEState {IDEBus *bus; +IDEDevice *dev;uint8_t unit;/* ide config */ IDEDriveKind drive_kind;
@@ -447,8 +448,6 @@ struct IDEDMA {struct IDEBus {BusState qbus; -IDEDevice *master; -IDEDevice *slave;IDEState ifs[2 ];int bus_id;IDEDMA *dma;
hw/ide/qdev.c +3 -9
@@ -74,22 +74,16 @@ static int ide_qdev_init(DeviceState *qdev) goto err; }if (dev->unit ==-1 ) { - dev->unit = bus->master ?1 :0 ; + dev->unit = bus->ifs[0 ].dev ?1 :0 ; }switch (dev->unit) {case 0 : -if (bus->master) { -error_report ("IDE unit %d is in use" , dev->unit); - goto err; - } - bus->master = dev; -break ;case 1 : -if (bus->slave) { +if (bus->ifs[dev->unit].dev) {error_report ("IDE unit %d is in use" , dev->unit); goto err; } - bus->slave = dev; + bus->ifs[dev->unit].dev = dev;break ;default :error_report ("Invalid IDE unit %d" , dev->unit);
Signature · 1 line
1.7.11.7
PATCH 3/10 ide: Use IDEState member dev for "device connected" test
In reply to Markus ArmbrusterTesting dev is more obvious than testing bs, in my opinion.
--- hw/ide/ahci.c | 8 ++++---- hw/ide/core.c | 56 ++++++++++++++++++++++++++++------------------------- hw/ide/microdrive.c | 5 +++-- hw/ide/qdev.c | 2 +- 4 files changed, 38 insertions(+), 33 deletions(-)
hw/ide/ahci.c +4 -4
@@ -86,7 +86,7 @@ static uint32_t ahci_port_read(AHCIState *s, int port, int offset) val = pr->sig;break ;case PORT_SCR_STAT : -if (s->dev[port].port.ifs[0 ].bs) { +if (s->dev[port].port.ifs[0 ].dev) { val =SATA_SCR_SSTATUS_DET_DEV_PRESENT_PHY_UP |SATA_SCR_SSTATUS_SPD_GEN1 |SATA_SCR_SSTATUS_IPM_ACTIVE ; }else {
@@ -497,7 +497,7 @@ static void ahci_reset_port(AHCIState *s, int port) d->init_d2h_sent =0 ; ide_state = &s->dev[port].port.ifs[0 ]; -if (!ide_state->bs) { +if (!ide_state->dev) {return ; }
@@ -523,7 +523,7 @@ static void ahci_reset_port(AHCIState *s, int port) } s->dev[port].port_state =STATE_RUN ; -if (!ide_state->bs) { +if (!ide_state->dev) { s->dev[port].port_regs.sig =0 ; ide_state->status =SEEK_STAT |WRERR_STAT ; }else if (ide_state->drive_kind ==IDE_CD ) {
@@ -848,7 +848,7 @@ static int handle_cmd(AHCIState *s, int port, int slot)/* The device we are working for */ ide_state = &s->dev[port].port.ifs[0 ]; -if (!ide_state->bs) { +if (!ide_state->dev) {DPRINTF (port,"error: guest accessed unused port" ); goto out; }
hw/ide/core.c +30 -26
180 lines not on this page · raw message
hw/ide/microdrive.c +3 -2
@@ -223,10 +223,11 @@ static uint16_t md_common_read(void *opaque, uint32_t at)return ide_ioport_read (&s->bus,0x1 );case 0xe :/* Alternate Status */ ifs =idebus_active_if (&s->bus); -if (ifs->bs) +if (ifs->dev) {return ifs->status; -else + }else {return 0 ; + }case 0xf :/* Device Address */ ifs =idebus_active_if (&s->bus);return 0xc2 | ((~ifs->select <<2 ) &0x3c );
hw/ide/qdev.c +1 -1
@@ -111,7 +111,7 @@ int ide_get_geometry(BusState *bus, int unit, {IDEState *s = &DO_UPCAST (IDEBus, qbus, bus)->ifs[unit]; -if (s->drive_kind !=IDE_HD || !s->bs) { +if (s->drive_kind !=IDE_HD || !s->dev) {return -1 ; }
Signature · 1 line
1.7.11.7
PATCH 4/10 ide: Don't block-align IDEState member smart_selftest_data
In reply to Markus ArmbrusterAll uses are simple array subscripts.
--- hw/ide/core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/ide/core.c +1 -2
@@ -2006,8 +2006,7 @@ static void ide_init1(IDEBus *bus, int unit) s->io_buffer =qemu_memalign (2048 , s->io_buffer_total_len);memset (s->io_buffer,0 , s->io_buffer_total_len); - s->smart_selftest_data =qemu_blockalign (s->bs,512 ); -memset (s->smart_selftest_data,0 ,512 ); + s->smart_selftest_data =g_malloc0 (512 ); s->sector_write_timer =qemu_new_timer_ns (vm_clock, ide_sector_write_timer_cb, s);
Signature · 1 line
1.7.11.7
PATCH 5/10 ide: Drop redundant IDEState member bs
In reply to Markus ArmbrusterIt's a copy of dev->conf.bs. The copy was needed for non-qdevified controllers, which lacked dev.
Note how pci_piix3_xen_ide_unplug() cleared the copy. We'll get back to that in the next few commits.
--- hw/ide/ahci.c | 11 +++++----- hw/ide/atapi.c | 37 ++++++++++++++++++--------------- hw/ide/core.c | 62 ++++++++++++++++++++++++++++++------------------------- hw/ide/internal.h | 3 +-- hw/ide/macio.c | 20 ++++++++++-------- hw/ide/piix.c | 1 - hw/ide/qdev.c | 2 +- 7 files changed, 73 insertions(+), 63 deletions(-)
hw/ide/ahci.c +6 -5
@@ -732,7 +732,7 @@ static void ncq_cb(void *opaque, int ret)DPRINTF (ncq_tfs->drive->port_no,"NCQ transfer tag %d finished\n" , ncq_tfs->tag); -bdrv_acct_done (ncq_tfs->drive->port.ifs[0 ].bs, &ncq_tfs->acct); +bdrv_acct_done (ncq_tfs->drive->port.ifs[0 ].dev->conf.bs, &ncq_tfs->acct);qemu_sglist_destroy (&ncq_tfs->sglist); ncq_tfs->used =0 ; }
@@ -743,6 +743,7 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,NCQFrame *ncq_fis = (NCQFrame *)cmd_fis;uint8_t tag = ncq_fis->tag >>3 ;NCQTransferState *ncq_tfs = &s->dev[port].ncq_tfs[tag]; +BlockDriverState *bs = ncq_tfs->drive->port.ifs[0 ].dev->conf.bs;if (ncq_tfs->used) {/* error - already in use */
@@ -782,9 +783,9 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,DPRINTF (port,"tag %d aio read %" PRId64"\n" , ncq_tfs->tag, ncq_tfs->lba); -dma_acct_start (ncq_tfs->drive->port.ifs[0 ].bs, &ncq_tfs->acct, +dma_acct_start (bs, &ncq_tfs->acct, &ncq_tfs->sglist,BDRV_ACCT_READ ); - ncq_tfs->aiocb =dma_bdrv_read (ncq_tfs->drive->port.ifs[0 ].bs, + ncq_tfs->aiocb =dma_bdrv_read (bs, &ncq_tfs->sglist, ncq_tfs->lba, ncq_cb, ncq_tfs);break ;
@@ -795,9 +796,9 @@ static void process_ncq_command(AHCIState *s, int port, uint8_t *cmd_fis,DPRINTF (port,"tag %d aio write %" PRId64"\n" , ncq_tfs->tag, ncq_tfs->lba); -dma_acct_start (ncq_tfs->drive->port.ifs[0 ].bs, &ncq_tfs->acct, +dma_acct_start (bs, &ncq_tfs->acct, &ncq_tfs->sglist,BDRV_ACCT_WRITE ); - ncq_tfs->aiocb =dma_bdrv_write (ncq_tfs->drive->port.ifs[0 ].bs, + ncq_tfs->aiocb =dma_bdrv_write (bs, &ncq_tfs->sglist, ncq_tfs->lba, ncq_cb, ncq_tfs);break ;
hw/ide/atapi.c +20 -17
@@ -106,18 +106,19 @@ static void cd_data_to_raw(uint8_t *buf, int lba)static int cd_read_sector (IDEState *s,int lba,uint8_t *buf,int sector_size) { +BlockDriverState *bs = s->dev->conf.bs;int ret;switch (sector_size) {case 2048 : -bdrv_acct_start (s->bs, &s->acct,4 *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); - ret =bdrv_read (s->bs, (int64_t )lba <<2 , buf,4 ); -bdrv_acct_done (s->bs, &s->acct); +bdrv_acct_start (bs, &s->acct,4 *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); + ret =bdrv_read (bs, (int64_t )lba <<2 , buf,4 ); +bdrv_acct_done (bs, &s->acct);break ;case 2352 : -bdrv_acct_start (s->bs, &s->acct,4 *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); - ret =bdrv_read (s->bs, (int64_t )lba <<2 , buf +16 ,4 ); -bdrv_acct_done (s->bs, &s->acct); +bdrv_acct_start (bs, &s->acct,4 *BDRV_SECTOR_SIZE ,BDRV_ACCT_READ ); + ret =bdrv_read (bs, (int64_t )lba <<2 , buf +16 ,4 ); +bdrv_acct_done (bs, &s->acct);if (ret <0 )return ret;cd_data_to_raw (buf, lba);
@@ -253,7 +254,7 @@ static void ide_atapi_cmd_reply(IDEState *s, int size, int max_size) s->io_buffer_index =0 ;if (s->atapi_dma) { -bdrv_acct_start (s->bs, &s->acct, size,BDRV_ACCT_READ ); +bdrv_acct_start (s->dev->conf.bs, &s->acct, size,BDRV_ACCT_READ ); s->status =READY_STAT |SEEK_STAT |DRQ_STAT ; s->bus->dma->ops->start_dma (s->bus->dma, s, ide_atapi_cmd_read_dma_cb);
@@ -349,13 +350,13 @@ static void ide_atapi_cmd_read_dma_cb(void *opaque, int ret) s->bus->dma->iov.iov_len = n *4 *512 ;qemu_iovec_init_external (&s->bus->dma->qiov, &s->bus->dma->iov,1 ); - s->bus->dma->aiocb =bdrv_aio_readv (s->bs, (int64_t )s->lba <<2 , + s->bus->dma->aiocb =bdrv_aio_readv (s->dev->conf.bs, (int64_t )s->lba <<2 , &s->bus->dma->qiov, n *4 , ide_atapi_cmd_read_dma_cb, s);return ; eot: -bdrv_acct_done (s->bs, &s->acct); +bdrv_acct_done (s->dev->conf.bs, &s->acct); s->bus->dma->ops->add_status (s->bus->dma,BM_STATUS_INT );ide_set_inactive (s); }
@@ -371,7 +372,8 @@ static void ide_atapi_cmd_read_dma(IDEState *s, int lba, int nb_sectors, s->io_buffer_size =0 ; s->cd_sector_size = sector_size; -bdrv_acct_start (s->bs, &s->acct, s->packet_transfer_size,BDRV_ACCT_READ ); +bdrv_acct_start (s->dev->conf.bs, &s->acct, s->packet_transfer_size, +BDRV_ACCT_READ );/* XXX: check if BUSY_STAT should be set */ s->status =READY_STAT |SEEK_STAT |DRQ_STAT |BUSY_STAT ;
@@ -504,7 +506,7 @@ static unsigned int event_status_media(IDEState *s, media_status =0 ;if (s->tray_open) { media_status =MS_TRAY_OPEN ; - }else if (bdrv_is_inserted (s->bs)) { + }else if (bdrv_is_inserted (s->dev->conf.bs)) { media_status =MS_MEDIA_PRESENT ; }
@@ -800,7 +802,7 @@ static void cmd_test_unit_ready(IDEState *s, uint8_t *buf)static void cmd_prevent_allow_medium_removal (IDEState *s,uint8_t * buf) { s->tray_locked = buf[4 ] &1 ; -bdrv_lock_medium (s->bs, buf[4 ] &1 ); +bdrv_lock_medium (s->dev->conf.bs, buf[4 ] &1 );ide_atapi_cmd_ok (s); }
@@ -884,14 +886,14 @@ static void cmd_start_stop_unit(IDEState *s, uint8_t* buf)if (loej) {if (!start && !s->tray_open && s->tray_locked) { - sense =bdrv_is_inserted (s->bs) + sense =bdrv_is_inserted (s->dev->conf.bs) ?NOT_READY :ILLEGAL_REQUEST ;ide_atapi_cmd_error (s, sense,ASC_MEDIA_REMOVAL_PREVENTED );return ; }if (s->tray_open != !start) { -bdrv_eject (s->bs, !start); +bdrv_eject (s->dev->conf.bs, !start); s->tray_open = !start; } }
@@ -1094,6 +1096,7 @@ static const struct {void ide_atapi_cmd (IDEState *s) {uint8_t *buf; +bool is_inserted; buf = s->io_buffer;#ifdef DEBUG_IDE_ATAPI
@@ -1124,8 +1127,9 @@ void ide_atapi_cmd(IDEState *s)* GET_EVENT_STATUS_NOTIFICATION to detect such tray open/close * states rely on this behavior. */ + is_inserted =bdrv_is_inserted (s->dev->conf.bs);if (!(atapi_cmd_table[s->io_buffer[0 ]].flags &ALLOW_UA ) && - !s->tray_open &&bdrv_is_inserted (s->bs) && s->cdrom_changed) { + !s->tray_open && is_inserted && s->cdrom_changed) {if (s->cdrom_changed ==1 ) {ide_atapi_cmd_error (s,NOT_READY ,ASC_MEDIUM_NOT_PRESENT );
@@ -1134,13 +1138,12 @@ void ide_atapi_cmd(IDEState *s)ide_atapi_cmd_error (s,UNIT_ATTENTION ,ASC_MEDIUM_MAY_HAVE_CHANGED ); s->cdrom_changed =0 ; } -return ; }/* Report a Not Ready condition if appropriate for the command */ if ((atapi_cmd_table[s->io_buffer[0 ]].flags &CHECK_READY ) && - (!media_present (s) || !bdrv_is_inserted (s->bs))) + (!media_present (s) || !is_inserted)) {ide_atapi_cmd_error (s,NOT_READY ,ASC_MEDIUM_NOT_PRESENT );return ;
hw/ide/core.c +34 -28
205 lines not on this page · raw message
hw/ide/internal.h +1 -2
@@ -374,7 +374,6 @@ struct IDEState {/* set for lba48 access */ uint8_t lba48; -BlockDriverState *bs;char version[9 ];/* ATAPI specific */ struct unreported_events events;
@@ -545,7 +544,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);void ide_data_writel (void *opaque,uint32_t addr,uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr); -int ide_init_drive(IDEState *s, BlockDriverState *bs, IDEDriveKind kind, +int ide_init_drive(IDEState *s, IDEDriveKind kind, const char *version, const char *serial, const char *model, uint64_t wwn, uint32_t cylinders, uint32_t heads, uint32_t secs,
hw/ide/macio.c +11 -9
@@ -82,13 +82,13 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) io->addr += io->len; io->len =0 ; - m->aiocb =dma_bdrv_read (s->bs, &s->sg, + m->aiocb =dma_bdrv_read (s->dev->conf.bs, &s->sg, (int64_t )(s->lba <<2 ) + (s->io_buffer_index >>9 ), pmac_ide_atapi_transfer_cb, io);return ; done: -bdrv_acct_done (s->bs, &s->acct); +bdrv_acct_done (s->dev->conf.bs, &s->acct); io->dma_end (opaque); }
@@ -97,6 +97,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)DBDMA_io *io = opaque;MACIOIDEState *m = io->opaque;IDEState *s =idebus_active_if (&m->bus); +BlockDriverState *bs = s->dev->conf.bs;int n;int64_t sector_num;
@@ -141,15 +142,15 @@ static void pmac_ide_transfer_cb(void *opaque, int ret)switch (s->dma_cmd) {case IDE_DMA_READ : - m->aiocb =dma_bdrv_read (s->bs, &s->sg, sector_num, + m->aiocb =dma_bdrv_read (bs, &s->sg, sector_num, pmac_ide_transfer_cb, io);break ;case IDE_DMA_WRITE : - m->aiocb =dma_bdrv_write (s->bs, &s->sg, sector_num, + m->aiocb =dma_bdrv_write (bs, &s->sg, sector_num, pmac_ide_transfer_cb, io);break ;case IDE_DMA_TRIM : - m->aiocb =dma_bdrv_io (s->bs, &s->sg, sector_num, + m->aiocb =dma_bdrv_io (bs, &s->sg, sector_num, ide_issue_trim, pmac_ide_transfer_cb, s,DMA_DIRECTION_TO_DEVICE );break ;
@@ -158,7 +159,7 @@ static void pmac_ide_transfer_cb(void *opaque, int ret) done:if (s->dma_cmd ==IDE_DMA_READ || s->dma_cmd ==IDE_DMA_WRITE ) { -bdrv_acct_done (s->bs, &s->acct); +bdrv_acct_done (bs, &s->acct); } io->dma_end (io); }
@@ -167,20 +168,21 @@ static void pmac_ide_transfer(DBDMA_io *io) {MACIOIDEState *m = io->opaque;IDEState *s =idebus_active_if (&m->bus); +BlockDriverState *bs = s->dev->conf.bs; s->io_buffer_size =0 ;if (s->drive_kind ==IDE_CD ) { -bdrv_acct_start (s->bs, &s->acct, io->len,BDRV_ACCT_READ ); +bdrv_acct_start (bs, &s->acct, io->len,BDRV_ACCT_READ );pmac_ide_atapi_transfer_cb (io,0 );return ; }switch (s->dma_cmd) {case IDE_DMA_READ : -bdrv_acct_start (s->bs, &s->acct, io->len,BDRV_ACCT_READ ); +bdrv_acct_start (bs, &s->acct, io->len,BDRV_ACCT_READ );break ;case IDE_DMA_WRITE : -bdrv_acct_start (s->bs, &s->acct, io->len,BDRV_ACCT_WRITE ); +bdrv_acct_start (bs, &s->acct, io->len,BDRV_ACCT_WRITE );break ;default :break ;
hw/ide/piix.c +0 -1
@@ -184,7 +184,6 @@ static int pci_piix3_xen_ide_unplug(DeviceState *dev)bdrv_detach_dev (di->bdrv, ds); }bdrv_close (di->bdrv); - pci_ide->bus[di->bus].ifs[di->unit].bs =NULL ;drive_put_ref (di); } }
hw/ide/qdev.c +1 -1
@@ -148,7 +148,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)return -1 ; } -if (ide_init_drive (s, dev->conf.bs, kind, +if (ide_init_drive (s, kind, dev->version, dev->serial, dev->model, dev->wwn, dev->conf.cyls, dev->conf.heads, dev->conf.secs, dev->chs_trans) <0 ) {
Signature · 1 line
1.7.11.7
PATCH 6/10 ide: Drop redundant IDEState geometry members
In reply to Markus ArmbrusterMembers cylinders, heads, sectors, chs_trans are copies of dev->conf.cyls, dev->conf.heads, dev->conf.secs, dev->chs_trans. Copies were needed for non-qdevified controllers, which lacked dev.
Note that pci_piix3_xen_ide_unplug() did not clear the copies (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copies were used only when the copy of bs was non-null, thus no bug there.
--- hw/ide/core.c | 52 ++++++++++++++++++++++++---------------------------- hw/ide/internal.h | 5 +---- hw/ide/qdev.c | 12 +++++------- 3 files changed, 30 insertions(+), 39 deletions(-)
hw/ide/core.c +24 -28
@@ -89,11 +89,11 @@ static void ide_identify(IDEState *s)memset (s->io_buffer,0 ,512 ); p = (uint16_t *)s->io_buffer;put_le16 (p +0 ,0x0040 ); -put_le16 (p +1 , s->cylinders); -put_le16 (p +3 , s->heads); -put_le16 (p +4 ,512 * s->sectors);/* XXX: retired, remove ? */ +put_le16 (p +1 , s->dev->conf.cyls); +put_le16 (p +3 , s->dev->conf.heads); +put_le16 (p +4 ,512 * s->dev->conf.secs);/* XXX: retired, remove ? */ put_le16 (p +5 ,512 );/* XXX: retired, remove ? */ -put_le16 (p +6 , s->sectors); +put_le16 (p +6 , s->dev->conf.secs);padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */ put_le16 (p +20 ,3 );/* XXX: retired, remove ? */ put_le16 (p +21 ,512 );/* cache size in sectors */
@@ -108,10 +108,10 @@ static void ide_identify(IDEState *s)put_le16 (p +51 ,0x200 );/* PIO transfer cycle */ put_le16 (p +52 ,0x200 );/* DMA transfer cycle */ put_le16 (p +53 ,1 | (1 <<1 ) | (1 <<2 ));/* words 54-58,64-70,88 are valid */ -put_le16 (p +54 , s->cylinders); -put_le16 (p +55 , s->heads); -put_le16 (p +56 , s->sectors); - oldsize = s->cylinders * s->heads * s->sectors; +put_le16 (p +54 , s->dev->conf.cyls); +put_le16 (p +55 , s->dev->conf.heads); +put_le16 (p +56 , s->dev->conf.secs); + oldsize = s->dev->conf.cyls * s->dev->conf.heads * s->dev->conf.secs;put_le16 (p +57 , oldsize);put_le16 (p +58 , oldsize >>16 );if (s->mult_sectors)
@@ -249,12 +249,12 @@ static void ide_cfata_identify(IDEState *s)memset (p,0 ,sizeof (s->identify_data)); - cur_sec = s->cylinders * s->heads * s->sectors; + cur_sec = s->dev->conf.cyls * s->dev->conf.heads * s->dev->conf.secs;put_le16 (p +0 ,0x848a );/* CF Storage Card signature */ -put_le16 (p +1 , s->cylinders);/* Default cylinders */ -put_le16 (p +3 , s->heads);/* Default heads */ -put_le16 (p +6 , s->sectors);/* Default sectors per track */ +put_le16 (p +1 , s->dev->conf.cyls);/* Default cylinders */ +put_le16 (p +3 , s->dev->conf.heads);/* Default heads */ +put_le16 (p +6 , s->dev->conf.secs);/* Default sectors per track */ put_le16 (p +7 , s->nb_sectors >>16 );/* Sectors per card */ put_le16 (p +8 , s->nb_sectors);/* Sectors per card */ padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */
@@ -270,9 +270,9 @@ static void ide_cfata_identify(IDEState *s)put_le16 (p +51 ,0x0002 );/* PIO cycle timing mode */ put_le16 (p +52 ,0x0001 );/* DMA cycle timing mode */ put_le16 (p +53 ,0x0003 );/* Translation params valid */ -put_le16 (p +54 , s->cylinders);/* Current cylinders */ -put_le16 (p +55 , s->heads);/* Current heads */ -put_le16 (p +56 , s->sectors);/* Current sectors */ +put_le16 (p +54 , s->dev->conf.cyls);/* Current cylinders */ +put_le16 (p +55 , s->dev->conf.heads);/* Current heads */ +put_le16 (p +56 , s->dev->conf.secs);/* Current sectors */ put_le16 (p +57 , cur_sec);/* Current capacity */ put_le16 (p +58 , cur_sec >>16 );/* Current capacity */ if (s->mult_sectors)/* Multiple sector setting */
@@ -433,8 +433,10 @@ int64_t ide_get_sector(IDEState *s) ((int64_t ) s->lcyl <<8 ) | s->sector; } }else { - sector_num = ((s->hcyl <<8 ) | s->lcyl) * s->heads * s->sectors + - (s->select &0x0f ) * s->sectors + (s->sector -1 ); + sector_num = + (((s->hcyl <<8 ) | s->lcyl) * s->dev->conf.heads + + (s->select &0x0f )) * s->dev->conf.secs + + (s->sector -1 ); }return sector_num; }
@@ -457,12 +459,12 @@ void ide_set_sector(IDEState *s, int64_t sector_num) s->hob_hcyl = sector_num >>40 ; } }else { - cyl = sector_num / (s->heads * s->sectors); - r = sector_num % (s->heads * s->sectors); + cyl = sector_num / (s->dev->conf.heads * s->dev->conf.secs); + r = sector_num % (s->dev->conf.heads * s->dev->conf.secs); s->hcyl = cyl >>8 ; s->lcyl = cyl; - s->select = (s->select &0xf0 ) | ((r / s->sectors) &0x0f ); - s->sector = (r % s->sectors) +1 ; + s->select = (s->select &0xf0 ) | ((r / s->dev->conf.secs) &0x0f ); + s->sector = (r % s->dev->conf.secs) +1 ; } }
@@ -1930,9 +1932,7 @@ static const BlockDevOps ide_cd_block_ops = {int ide_init_drive (IDEState *s,IDEDriveKind kind,const char *version,const char *serial,const char *model, -uint64_t wwn, -uint32_t cylinders,uint32_t heads,uint32_t secs, -int chs_trans) +uint64_t wwn) {BlockDriverState *bs = s->dev->conf.bs;uint64_t nb_sectors;
@@ -1940,10 +1940,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind, s->drive_kind = kind;bdrv_get_geometry (bs, &nb_sectors); - s->cylinders = cylinders; - s->heads = heads; - s->sectors = secs; - s->chs_trans = chs_trans; s->nb_sectors = nb_sectors; s->wwn = wwn;/* The SMART values should be preserved across power cycles
hw/ide/internal.h +1 -4
@@ -346,7 +346,6 @@ struct IDEState {uint8_t unit;/* ide config */ IDEDriveKind drive_kind; -int cylinders, heads, sectors, chs_trans;int64_t nb_sectors;int mult_sectors;int identify_set;
@@ -546,9 +545,7 @@ uint32_t ide_data_readl(void *opaque, uint32_t addr);int ide_init_drive (IDEState *s,IDEDriveKind kind,const char *version,const char *serial,const char *model, -uint64_t wwn, -uint32_t cylinders,uint32_t heads,uint32_t secs, -int chs_trans); +uint64_t wwn);void ide_init2 (IDEBus *bus,qemu_irq irq);void ide_init2_with_non_qdev_drives (IDEBus *bus,DriveInfo *hd0,DriveInfo *hd1,qemu_irq irq);
hw/ide/qdev.c +5 -7
@@ -115,15 +115,15 @@ int ide_get_geometry(BusState *bus, int unit,return -1 ; } - *cyls = s->cylinders; - *heads = s->heads; - *secs = s->sectors; + *cyls = s->dev->conf.cyls; + *heads = s->dev->conf.heads; + *secs = s->dev->conf.secs;return 0 ; }int ide_get_bios_chs_trans (BusState *bus,int unit) { -return DO_UPCAST (IDEBus, qbus, bus)->ifs[unit].chs_trans; +return DO_UPCAST (IDEBus, qbus, bus)->ifs[unit].dev->chs_trans; }/* --------------------------------- */
@@ -149,9 +149,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) }if (ide_init_drive (s, kind, - dev->version, dev->serial, dev->model, dev->wwn, - dev->conf.cyls, dev->conf.heads, dev->conf.secs, - dev->chs_trans) <0 ) { + dev->version, dev->serial, dev->model, dev->wwn) <0 ) {return -1 ; }
Signature · 1 line
1.7.11.7
PATCH 7/10 ide: Drop redundant IDEState member version
In reply to Markus ArmbrusterIt's a copy of dev->version. The copy was needed for non-qdevified controllers, which lacked dev.
Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there.
--- hw/ide/atapi.c | 2 +- hw/ide/core.c | 14 ++++---------- hw/ide/internal.h | 3 +-- hw/ide/qdev.c | 9 +++++---- 4 files changed, 11 insertions(+), 17 deletions(-)
hw/ide/atapi.c +1 -1
@@ -634,7 +634,7 @@ static void cmd_inquiry(IDEState *s, uint8_t *buf) buf[7 ] =0 ;/* reserved */ padstr8 (buf +8 ,8 ,"QEMU" );padstr8 (buf +16 ,16 ,"QEMU DVD-ROM" ); -padstr8 (buf +32 ,4 , s->version); +padstr8 (buf +32 ,4 , s->dev->version);ide_atapi_cmd_reply (s,36 , max_len); }
hw/ide/core.c +4 -10
@@ -98,7 +98,7 @@ static void ide_identify(IDEState *s)put_le16 (p +20 ,3 );/* XXX: retired, remove ? */ put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */ -padstr ((char *)(p +23 ), s->version,8 );/* firmware version */ +padstr ((char *)(p +23 ), s->dev->version,8 );/* firmware version */ padstr ((char *)(p +27 ), s->drive_model_str,40 );/* model */ #if MAX_MULT_SECTORS >1 put_le16 (p +47 ,0x8000 |MAX_MULT_SECTORS );
@@ -202,7 +202,7 @@ static void ide_atapi_identify(IDEState *s)put_le16 (p +20 ,3 );/* buffer type */ put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */ -padstr ((char *)(p +23 ), s->version,8 );/* firmware version */ +padstr ((char *)(p +23 ), s->dev->version,8 );/* firmware version */ padstr ((char *)(p +27 ), s->drive_model_str,40 );/* model */ put_le16 (p +48 ,1 );/* dword I/O (XXX: should not be set on CDROM) */ #ifdef USE_DMA_CDROM
@@ -259,7 +259,7 @@ static void ide_cfata_identify(IDEState *s)put_le16 (p +8 , s->nb_sectors);/* Sectors per card */ padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */ put_le16 (p +22 ,0x0004 );/* ECC bytes */ -padstr ((char *) (p +23 ), s->version,8 );/* Firmware Revision */ +padstr ((char *) (p +23 ), s->dev->version,8 );/* Firmware Revision */ padstr ((char *) (p +27 ), s->drive_model_str,40 );/* Model number */ #if MAX_MULT_SECTORS >1 put_le16 (p +47 ,0x8000 |MAX_MULT_SECTORS );
@@ -1931,7 +1931,7 @@ static const BlockDevOps ide_cd_block_ops = { };int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *version,const char *serial,const char *model, +const char *serial,const char *model,uint64_t wwn) {BlockDriverState *bs = s->dev->conf.bs;
@@ -1983,12 +1983,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind, } } -if (version) { -pstrcpy (s->version,sizeof (s->version), version); - }else { -pstrcpy (s->version,sizeof (s->version),qemu_get_version ()); - } -ide_reset (s);bdrv_iostatus_enable (bs);return 0 ;
hw/ide/internal.h +1 -2
@@ -373,7 +373,6 @@ struct IDEState {/* set for lba48 access */ uint8_t lba48; -char version[9 ];/* ATAPI specific */ struct unreported_events events;uint8_t sense_key;
@@ -544,7 +543,7 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr);int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *version,const char *serial,const char *model, +const char *serial,const char *model,uint64_t wwn);void ide_init2 (IDEBus *bus,qemu_irq irq); void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
hw/ide/qdev.c +5 -4
@@ -148,14 +148,15 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)return -1 ; } +if (!dev->version) { + dev->version =g_strdup (qemu_get_version ()); + } +if (ide_init_drive (s, kind, - dev->version, dev->serial, dev->model, dev->wwn) <0 ) { + dev->serial, dev->model, dev->wwn) <0 ) {return -1 ; } -if (!dev->version) { - dev->version =g_strdup (s->version); - }if (!dev->serial) { dev->serial =g_strdup (s->drive_serial_str); }
Signature · 1 line
1.7.11.7
PATCH 8/10 ide: Drop redundant IDEState member drive_serial_str
In reply to Markus ArmbrusterIt's a copy of dev->serial. The copy was needed for non-qdevified controllers, which lacked dev.
Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there.
--- hw/ide/core.c | 14 ++++---------- hw/ide/internal.h | 3 +-- hw/ide/qdev.c | 10 +++++----- 3 files changed, 10 insertions(+), 17 deletions(-)
hw/ide/core.c +4 -10
@@ -94,7 +94,7 @@ static void ide_identify(IDEState *s)put_le16 (p +4 ,512 * s->dev->conf.secs);/* XXX: retired, remove ? */ put_le16 (p +5 ,512 );/* XXX: retired, remove ? */ put_le16 (p +6 , s->dev->conf.secs); -padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */ +padstr ((char *)(p +10 ), s->dev->serial,20 );/* serial number */ put_le16 (p +20 ,3 );/* XXX: retired, remove ? */ put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */
@@ -198,7 +198,7 @@ static void ide_atapi_identify(IDEState *s) p = (uint16_t *)s->io_buffer;/* Removable CDROM, 50us response, 12 byte packets */ put_le16 (p +0 , (2 <<14 ) | (5 <<8 ) | (1 <<7 ) | (2 <<5 ) | (0 <<0 )); -padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */ +padstr ((char *)(p +10 ), s->dev->serial,20 );/* serial number */ put_le16 (p +20 ,3 );/* buffer type */ put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */
@@ -257,7 +257,7 @@ static void ide_cfata_identify(IDEState *s)put_le16 (p +6 , s->dev->conf.secs);/* Default sectors per track */ put_le16 (p +7 , s->nb_sectors >>16 );/* Sectors per card */ put_le16 (p +8 , s->nb_sectors);/* Sectors per card */ -padstr ((char *)(p +10 ), s->drive_serial_str,20 );/* serial number */ +padstr ((char *)(p +10 ), s->dev->serial,20 );/* serial number */ put_le16 (p +22 ,0x0004 );/* ECC bytes */ padstr ((char *) (p +23 ), s->dev->version,8 );/* Firmware Revision */ padstr ((char *) (p +27 ), s->drive_model_str,40 );/* Model number */
@@ -1931,7 +1931,7 @@ static const BlockDevOps ide_cd_block_ops = { };int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *serial,const char *model, +const char *model,uint64_t wwn) {BlockDriverState *bs = s->dev->conf.bs;
@@ -1961,12 +1961,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind,return -1 ; } } -if (serial) { -pstrcpy (s->drive_serial_str,sizeof (s->drive_serial_str), serial); - }else { -snprintf (s->drive_serial_str,sizeof (s->drive_serial_str), -"QM%05d" , s->drive_serial); - }if (model) {pstrcpy (s->drive_model_str,sizeof (s->drive_model_str), model); }else {
hw/ide/internal.h +1 -2
@@ -351,7 +351,6 @@ struct IDEState {int identify_set;uint8_t identify_data[512 ];int drive_serial; -char drive_serial_str[21 ];char drive_model_str[41 ];uint64_t wwn;/* ide regs */
@@ -543,7 +542,7 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr);int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *serial,const char *model, +const char *model,uint64_t wwn);void ide_init2 (IDEBus *bus,qemu_irq irq); void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
hw/ide/qdev.c +5 -5
@@ -148,19 +148,19 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind)return -1 ; } +if (!dev->serial) { + dev->serial =g_strdup_printf ("QM%05d" , s->drive_serial); + } +if (!dev->version) { dev->version =g_strdup (qemu_get_version ()); }if (ide_init_drive (s, kind, - dev->serial, dev->model, dev->wwn) <0 ) { + dev->model, dev->wwn) <0 ) {return -1 ; } -if (!dev->serial) { - dev->serial =g_strdup (s->drive_serial_str); - } -add_boot_device_path (dev->conf.bootindex, &dev->qdev, dev->unit ?"/disk@1" :"/disk@0" );
Signature · 1 line
1.7.11.7
PATCH 9/10 ide: Drop redundant IDEState member model
In reply to Markus ArmbrusterIt's a copy of dev->serial. The copy was needed for non-qdevified controllers, which lacked dev.
Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there.
--- hw/ide/core.c | 22 +++------------------- hw/ide/internal.h | 2 -- hw/ide/qdev.c | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 22 deletions(-)
hw/ide/core.c +3 -19
@@ -99,7 +99,7 @@ static void ide_identify(IDEState *s)put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */ padstr ((char *)(p +23 ), s->dev->version,8 );/* firmware version */ -padstr ((char *)(p +27 ), s->drive_model_str,40 );/* model */ +padstr ((char *)(p +27 ), s->dev->model,40 );/* model */ #if MAX_MULT_SECTORS >1 put_le16 (p +47 ,0x8000 |MAX_MULT_SECTORS );#endif
@@ -203,7 +203,7 @@ static void ide_atapi_identify(IDEState *s)put_le16 (p +21 ,512 );/* cache size in sectors */ put_le16 (p +22 ,4 );/* ecc bytes */ padstr ((char *)(p +23 ), s->dev->version,8 );/* firmware version */ -padstr ((char *)(p +27 ), s->drive_model_str,40 );/* model */ +padstr ((char *)(p +27 ), s->dev->model,40 );/* model */ put_le16 (p +48 ,1 );/* dword I/O (XXX: should not be set on CDROM) */ #ifdef USE_DMA_CDROM put_le16 (p +49 ,1 <<9 |1 <<8 );/* DMA and LBA supported */
@@ -260,7 +260,7 @@ static void ide_cfata_identify(IDEState *s)padstr ((char *)(p +10 ), s->dev->serial,20 );/* serial number */ put_le16 (p +22 ,0x0004 );/* ECC bytes */ padstr ((char *) (p +23 ), s->dev->version,8 );/* Firmware Revision */ -padstr ((char *) (p +27 ), s->drive_model_str,40 );/* Model number */ +padstr ((char *) (p +27 ), s->dev->model,40 );/* Model number */ #if MAX_MULT_SECTORS >1 put_le16 (p +47 ,0x8000 |MAX_MULT_SECTORS );#else
@@ -1931,7 +1931,6 @@ static const BlockDevOps ide_cd_block_ops = { };int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *model,uint64_t wwn) {BlockDriverState *bs = s->dev->conf.bs;
@@ -1961,21 +1960,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind,return -1 ; } } -if (model) { -pstrcpy (s->drive_model_str,sizeof (s->drive_model_str), model); - }else { -switch (kind) { -case IDE_CD : -strcpy (s->drive_model_str,"QEMU DVD-ROM" ); -break ; -case IDE_CFATA : -strcpy (s->drive_model_str,"QEMU MICRODRIVE" ); -break ; -default : -strcpy (s->drive_model_str,"QEMU HARDDISK" ); -break ; - } - }ide_reset (s);bdrv_iostatus_enable (bs);
hw/ide/internal.h +0 -2
@@ -351,7 +351,6 @@ struct IDEState {int identify_set;uint8_t identify_data[512 ];int drive_serial; -char drive_model_str[41 ];uint64_t wwn;/* ide regs */ uint8_t feature;
@@ -542,7 +541,6 @@ void ide_data_writel(void *opaque, uint32_t addr, uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr);int ide_init_drive (IDEState *s,IDEDriveKind kind, -const char *model,uint64_t wwn);void ide_init2 (IDEBus *bus,qemu_irq irq); void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
hw/ide/qdev.c +15 -1
@@ -156,8 +156,22 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) dev->version =g_strdup (qemu_get_version ()); } +if (!dev->model) { +switch (kind) { +case IDE_CD : + dev->model =g_strdup ("QEMU DVD-ROM" ); +break ; +case IDE_CFATA : + dev->model =g_strdup ("QEMU MICRODRIVE" ); +break ; +default : + dev->model =g_strdup ("QEMU HARDDISK" ); +break ; + } + } +if (ide_init_drive (s, kind, - dev->model, dev->wwn) <0 ) { + dev->wwn) <0 ) {return -1 ; }
Signature · 1 line
1.7.11.7
PATCH 10/10 ide: Drop redundant IDEState member wwn
In reply to Markus ArmbrusterIt's a copy of dev->wwn. The copy was needed for non-qdevified controllers, which lacked dev.
Note that pci_piix3_xen_ide_unplug() did not clear the copy (it only cleared the copy of bs). Begs the question whether stale data could have been used after unplug. As far as I can tell, the copy was used only when the copy of bs was non-null, thus no bug there.
--- hw/ide/core.c | 18 ++++++++---------- hw/ide/internal.h | 4 +--- hw/ide/qdev.c | 3 +-- 3 files changed, 10 insertions(+), 15 deletions(-)
hw/ide/core.c +8 -10
@@ -142,7 +142,7 @@ static void ide_identify(IDEState *s)/* 13=flush_cache_ext,12=flush_cache,10=lba48 */ put_le16 (p +83 , (1 <<14 ) | (1 <<13 ) | (1 <<12 ) | (1 <<10 ));/* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */ -if (s->wwn) { +if (s->dev->wwn) {put_le16 (p +84 , (1 <<14 ) | (1 <<8 ) |0 ); }else {put_le16 (p +84 , (1 <<14 ) |0 );
@@ -156,7 +156,7 @@ static void ide_identify(IDEState *s)/* 13=flush_cache_ext,12=flush_cache,10=lba48 */ put_le16 (p +86 , (1 <<13 ) | (1 <<12 ) | (1 <<10 ));/* 14=set to 1, 8=has WWN, 1=SMART self test, 0=SMART error logging */ -if (s->wwn) { +if (s->dev->wwn) {put_le16 (p +87 , (1 <<14 ) | (1 <<8 ) |0 ); }else {put_le16 (p +87 , (1 <<14 ) |0 );
@@ -170,12 +170,12 @@ static void ide_identify(IDEState *s)if (dev && dev->conf.physical_block_size)put_le16 (p +106 ,0x6000 |get_physical_block_exp (&dev->conf)); -if (s->wwn) { +if (s->dev->wwn) {/* LE 16-bit words 111-108 contain 64-bit World Wide Name */ -put_le16 (p +108 , s->wwn >>48 ); -put_le16 (p +109 , s->wwn >>32 ); -put_le16 (p +110 , s->wwn >>16 ); -put_le16 (p +111 , s->wwn); +put_le16 (p +108 , s->dev->wwn >>48 ); +put_le16 (p +109 , s->dev->wwn >>32 ); +put_le16 (p +110 , s->dev->wwn >>16 ); +put_le16 (p +111 , s->dev->wwn); }if (dev && dev->conf.discard_granularity) {put_le16 (p +169 ,1 );/* TRIM support */
@@ -1930,8 +1930,7 @@ static const BlockDevOps ide_cd_block_ops = { .is_medium_locked = ide_cd_is_medium_locked, }; -int ide_init_drive (IDEState *s,IDEDriveKind kind, -uint64_t wwn) +int ide_init_drive (IDEState *s,IDEDriveKind kind) {BlockDriverState *bs = s->dev->conf.bs;uint64_t nb_sectors;
@@ -1940,7 +1939,6 @@ int ide_init_drive(IDEState *s, IDEDriveKind kind,bdrv_get_geometry (bs, &nb_sectors); s->nb_sectors = nb_sectors; - s->wwn = wwn;/* The SMART values should be preserved across power cycles but they aren't. */ s->smart_enabled =1 ;
hw/ide/internal.h +1 -3
@@ -351,7 +351,6 @@ struct IDEState {int identify_set;uint8_t identify_data[512 ];int drive_serial; -uint64_t wwn;/* ide regs */ uint8_t feature;uint8_t error;
@@ -540,8 +539,7 @@ uint32_t ide_data_readw(void *opaque, uint32_t addr);void ide_data_writel (void *opaque,uint32_t addr,uint32_t val);uint32_t ide_data_readl (void *opaque,uint32_t addr); -int ide_init_drive (IDEState *s,IDEDriveKind kind, -uint64_t wwn); +int ide_init_drive (IDEState *s,IDEDriveKind kind);void ide_init2 (IDEBus *bus,qemu_irq irq);void ide_init2_with_non_qdev_drives (IDEBus *bus,DriveInfo *hd0,DriveInfo *hd1,qemu_irq irq);
hw/ide/qdev.c +1 -2
@@ -170,8 +170,7 @@ static int ide_dev_initfn(IDEDevice *dev, IDEDriveKind kind) } } -if (ide_init_drive (s, kind, - dev->wwn) <0 ) { +if (ide_init_drive (s, kind) <0 ) {return -1 ; }
Signature · 1 line
1.7.11.7
Quoted 11 lines · Markus Armbruster
*** Important ***
This *breaks* all non-qdevified controllers, see PATCH 01/10. Maintainers are cc'ed.If you want still more time to qdevify your controller, please speak up now, and tell us how much.
The rest of the series is obvious cleanups enabled by dropping the special case of a non-qdevified controller. The block configuration stuff I'm working on also profits from it, and is real reason I'm posting this.
Breaking is not the right approach. If you're asserting that the code is unused and unloved, then remove it entirely from the tree.
Just breaking something is always wrong though.
I only see three users of ide_init2_with_non_qdev_drives. Is there any reason you didn't just convert these users to qdev?
Regards,
Anthony Liguori
Quoted 25 lines
Markus Armbruster (10):
ide: Break all non-qdevified controllers
ide: Move IDEDevice pointer from IDEBus to IDEState
ide: Use IDEState member dev for "device connected" test
ide: Don't block-align IDEState membersmart_selftest_data
ide: Drop redundant IDEState member bs
ide: Drop redundant IDEState geometry members
ide: Drop redundant IDEState member version
ide: Drop redundant IDEState memberdrive_serial_str
ide: Drop redundant IDEState member model
ide: Drop redundant IDEState member wwnhw/ide/ahci.c | 19 ++-- hw/ide/atapi.c | 39 ++++---- hw/ide/core.c | 278 +++++++++++++++++++++------------------------------- hw/ide/internal.h | 15 +-- hw/ide/macio.c | 20 ++-- hw/ide/microdrive.c | 5 +- hw/ide/piix.c | 1 - hw/ide/qdev.c | 50 +++++----- 8 files changed, 189 insertions(+), 238 deletions(-)Signature · 1 line
1.7.11.7
Quoted 9 lines · Anthony Liguori
Quoted 7 lines · Markus Armbruster
*** Important ***
This *breaks* all non-qdevified controllers, see PATCH 01/10. Maintainers are cc'ed.If you want still more time to qdevify your controller, please speak up now, and tell us how much.
Quoted 7 lines
Quoted 4 lines
The rest of the series is obvious cleanups enabled by dropping the special case of a non-qdevified controller. The block configuration stuff I'm working on also profits from it, and is real reason I'm posting this.
Breaking is not the right approach. If you're asserting that the code is unused and unloved, then remove it entirely from the tree.
Can do.
Quoted 4 lines
Just breaking something is always wrong though.
I only see three users of
ide_init2_with_non_qdev_drives. Is there any reason you didn't just convert these users to qdev?
Yes: it's more work than I can do on the side.