hw/ide: share bmdma read and write functions
cover hw/ide: share bmdma read and write functions
This is a preparation before I send v3 of ich6-ide controller emulation patch. I figured that it's more trivial to split the changes this way, by extracting the bmdma functions from via.c and piix.c and sharing them together. Then, I could easily put these into use when I send v3 of the ich6-ide patch by just using the already separated functions. This was suggested by BALATON Zoltan when he submitted a code review on my ich6-ide controller emulation patch.
Liav Albani (1):
hw/ide: share bmdma read and write functions between piix.c and via.c
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)
Signature · 1 line
2.35.1
PATCH 1/1 hw/ide: share bmdma read and write functions between piix.c and via.c
Instead of letting each implementation to duplicate this code, we can share these functions between IDE PIIX3/4 and VIA implementations.
--- hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)
hw/ide/pci.c +47 -0
@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, }; +uint64_t bmdma_default_read (void *opaque,hwaddr addr, +unsigned size) +{ +BMDMAState *bm = opaque; +uint32_t val; + +if (size !=1 ) { +return ((uint64_t )1 << (size *8 )) -1 ; + } + +switch (addr &3 ) { +case 0 : + val = bm->cmd; +break ; +case 2 : + val = bm->status; +break ; +default : + val =0xff ; +break ; + } + +trace_bmdma_read_via (addr, val); +return val; +} + +void bmdma_default_write (void *opaque,hwaddr addr, +uint64_t val,unsigned size) +{ +BMDMAState *bm = opaque; + +if (size !=1 ) { +return ; + } + +trace_bmdma_write_via (addr, val); +switch (addr &3 ) { +case 0 : +bmdma_cmd_writeb (bm, val); +break ; +case 2 : + bm->status = (val &0x60 ) | (bm->status &1 ) | (bm->status & ~val &0x06 ); +break ; +default :; + } +} +void bmdma_init (IDEBus *bus,BMDMAState *bm,PCIIDEState *d) {if (bus->dma == &bm->dma) {
hw/ide/piix.c +2 -48
57 lines not on this page · raw message
hw/ide/via.c +2 -49
58 lines not on this page · raw message
include/hw/ide/pci.h +4 -0
@@ -62,6 +62,10 @@ static inline IDEState *bmdma_active_if(BMDMAState *bmdma) }void bmdma_init (IDEBus *bus,BMDMAState *bm,PCIIDEState *d); +uint64_t bmdma_default_read (void *opaque,hwaddr addr, +unsigned size); +void bmdma_default_write (void *opaque,hwaddr addr, +uint64_t val,unsigned size);void bmdma_cmd_writeb (BMDMAState *bm,uint32_t val);extern MemoryRegionOps bmdma_addr_ioport_ops;void pci_ide_create_devs (PCIDevice *dev);
Signature · 1 line
2.35.1
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 2 lines · Liav Albani
Instead of letting each implementation to duplicate this code, we can share these functions between IDE PIIX3/4 and VIA implementations.
OK but there's a way to take this even further as cmd646 also uses similar functions just with more cases so you could remove the cases handled by these functions and only leave the difference and call the default function from the default case. E.g. (untested, just to show the idea):
hw/ide/cmd646.c:
static uint64_t bmdma_read(void *opaque, hwaddr addr,
unsigned size)
{
BMDMAState *bm = opaque;
PCIDevice *pci_dev = PCI_DEVICE(bm->pci_dev);
uint32_t val;
if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3) {
case 1:
val = pci_dev->config[MRDMODE];
break;
case 3:
if (bm == &bm->pci_dev->bmdma[0]) {
val = pci_dev->config[UDIDETCR0];
} else {
val = pci_dev->config[UDIDETCR1];
}
break;
default:
val = bmdma_default_read(opaque, addr, size);
break;
}
trace_bmdma_read_cmd646(addr, val);
return val;
}Quoted 13 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 5 lines
hw/ide/pci.c +2
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, }; +uint64_t bmdma_default_read (void *opaque,hwaddr addr, +unsigned size)
Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
Regards,
BALATON Zoltan
Quoted 189 lines
hw/ide/pci.c +45
-0+{ +BMDMAState *bm = opaque; +uint32_t val; + +if (size !=1 ) { +return ((uint64_t )1 << (size *8 )) -1 ; + } + +switch (addr &3 ) { +case 0 : + val = bm->cmd; +break ; +case 2 : + val = bm->status; +break ; +default : + val =0xff ; +break ; + } + +trace_bmdma_read_via (addr, val); +return val; +} + +void bmdma_default_write (void *opaque,hwaddr addr, +uint64_t val,unsigned size) +{ +BMDMAState *bm = opaque; + +if (size !=1 ) { +return ; + } + +trace_bmdma_write_via (addr, val); +switch (addr &3 ) { +case 0 : +bmdma_cmd_writeb (bm, val); +break ; +case 2 : + bm->status = (val &0x60 ) | (bm->status &1 ) | (bm->status & ~val &0x06 ); +break ; +default :; + } +} +void bmdma_init (IDEBus *bus,BMDMAState *bm,PCIIDEState *d) {if (bus->dma == &bm->dma) {hw/ide/piix.c +2
-48@@ -35,55 +35,9 @@#include "hw/ide/pci.h" #include "trace.h" -static uint64_t bmdma_read (void *opaque,hwaddr addr,unsigned size) -{ -BMDMAState *bm = opaque; -uint32_t val; - -if (size !=1 ) { -return ((uint64_t )1 << (size *8 )) -1 ; - } - -switch (addr &3 ) { -case 0 : - val = bm->cmd; -break ; -case 2 : - val = bm->status; -break ; -default : - val =0xff ; -break ; - } - -trace_bmdma_read (addr, val); -return val; -} - -static void bmdma_write (void *opaque,hwaddr addr, -uint64_t val,unsigned size) -{ -BMDMAState *bm = opaque; - -if (size !=1 ) { -return ; - } - -trace_bmdma_write (addr, val); - -switch (addr &3 ) { -case 0 : -bmdma_cmd_writeb (bm, val); -break ; -case 2 : - bm->status = (val &0x60 ) | (bm->status &1 ) | (bm->status & ~val &0x06 ); -break ; - } -} -static const MemoryRegionOps piix_bmdma_ops = { - .read = bmdma_read, - .write = bmdma_write, + .read = bmdma_default_read, + .write = bmdma_default_write, };static void bmdma_setup_bar (PCIIDEState *d)hw/ide/via.c +2
-49@@ -33,56 +33,9 @@#include "hw/ide/pci.h" #include "trace.h" -static uint64_t bmdma_read (void *opaque,hwaddr addr, -unsigned size) -{ -BMDMAState *bm = opaque; -uint32_t val; - -if (size !=1 ) { -return ((uint64_t )1 << (size *8 )) -1 ; - } - -switch (addr &3 ) { -case 0 : - val = bm->cmd; -break ; -case 2 : - val = bm->status; -break ; -default : - val =0xff ; -break ; - } - -trace_bmdma_read_via (addr, val); -return val; -} - -static void bmdma_write (void *opaque,hwaddr addr, -uint64_t val,unsigned size) -{ -BMDMAState *bm = opaque; - -if (size !=1 ) { -return ; - } - -trace_bmdma_write_via (addr, val); -switch (addr &3 ) { -case 0 : -bmdma_cmd_writeb (bm, val); -break ; -case 2 : - bm->status = (val &0x60 ) | (bm->status &1 ) | (bm->status & ~val &0x06 ); -break ; -default :; - } -} -static const MemoryRegionOps via_bmdma_ops = { - .read = bmdma_read, - .write = bmdma_write, + .read = bmdma_default_read, + .write = bmdma_default_write, };static void bmdma_setup_bar (PCIIDEState *d)include/hw/ide/pci.h +4
-0@@ -62,6 +62,10 @@ static inline IDEState *bmdma_active_if(BMDMAState *bmdma) }void bmdma_init (IDEBus *bus,BMDMAState *bm,PCIIDEState *d); +uint64_t bmdma_default_read (void *opaque,hwaddr addr, +unsigned size); +void bmdma_default_write (void *opaque,hwaddr addr, +uint64_t val,unsigned size);void bmdma_cmd_writeb (BMDMAState *bm,uint32_t val);extern MemoryRegionOps bmdma_addr_ioport_ops;void pci_ide_create_devs (PCIDevice *dev);
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 34 lines · BALATON Zoltan
Quoted 2 lines · Liav Albani
Instead of letting each implementation to duplicate this code, we can share these functions between IDE PIIX3/4 and VIA implementations.
OK but there's a way to take this even further as cmd646 also uses similar functions just with more cases so you could remove the cases handled by these functions and only leave the difference and call the default function from the default case. E.g. (untested, just to show the idea):
hw/ide/cmd646.c:
staticuint64_tbmdma_read(void *opaque, hwaddr addr, unsigned size)
{
BMDMAState *bm = opaque;
PCIDevice*pci_dev=PCI_DEVICE(bm->pci_dev);uint32_tval;if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3){
case 1:
val = pci_dev->config[MRDMODE]; break;
case 3:
if (bm == &bm->pci_dev->bmdma[0]) { val = pci_dev->config[UDIDETCR0]; } else {
val = pci_dev->config[UDIDETCR1]; }
break;
default:
val =bmdma_default_read(opaque, addr, size); break;
}
Quoted 4 lines
trace_bmdma_read_cmd646(addr, val);
return val;
}
Yeah, I see how I can do that for both bmdma write and read of cmd646. I'll send a v2 right away with a fix.
Quoted 16 lines
Quoted 16 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------include/hw/ide/pci.h| 4 ++++4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, };
Quoted 5 lines
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 2 lines
hw/ide/pci.c +2
-0+uint64_t bmdma_default_read (void *opaque,hwaddr addr, + unsigned size)Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr, + unsigned size)
Like this?
I'm using Visual Studio Code, so I might not have the correct settings for this editor with QEMU. The checkpatch script doesn't complain on style issues, so what can I do to make this correct?
Best regards,
Liav
Quoted 2 lines
Regards,
BALATON Zoltan
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 35 lines · Liav Albani
Quoted 34 lines · BALATON Zoltan
Quoted 2 lines · Liav Albani
Instead of letting each implementation to duplicate this code, we can share these functions between IDE PIIX3/4 and VIA implementations.
OK but there's a way to take this even further as cmd646 also uses similar functions just with more cases so you could remove the cases handled by these functions and only leave the difference and call the default function from the default case. E.g. (untested, just to show the idea):
hw/ide/cmd646.c:
staticuint64_tbmdma_read(void *opaque, hwaddr addr, unsigned size)
{
BMDMAState *bm = opaque;
PCIDevice*pci_dev=PCI_DEVICE(bm->pci_dev);uint32_tval;if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3){
case 1:
val = pci_dev->config[MRDMODE]; break;
case 3:
if (bm == &bm->pci_dev->bmdma[0]) { val = pci_dev->config[UDIDETCR0]; } else {
val = pci_dev->config[UDIDETCR1]; }
break;
default:
val =bmdma_default_read(opaque, addr, size); break;
}
Quoted 5 lines
Quoted 4 lines
trace_bmdma_read_cmd646(addr, val);
return val;
}Yeah, I see how I can do that for both bmdma write and read of cmd646. I'll send a v2 right away with a fix.
Maybe even the first if that's already contained in the default function could be avoided with some reorganisation like
if (size == 1) {
remaining switch cases to set val
} else {
val = bmdma_default_read();
}but I wasn't sure that won't change anything so may need a bit more thought.
Quoted 21 lines
Quoted 16 lines
Quoted 16 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------include/hw/ide/pci.h| 4 ++++4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, };Quoted 5 lines
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 2 lines
hw/ide/pci.c +2
-0+uint64_t bmdma_default_read (void *opaque,hwaddr addr, + unsigned size)Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
Quoted 6 lines
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr, + unsigned size)
Like this?
No, like the code you've moved had it. The split line should start after the ( not on the same column. So:
uint64_t bmdma_default_read(void *opaque, hwaddr addr, unsigned size)
but this line does not need to be split at all as it fits within 80 chars so better to keep it one line and only split where needed.
Quoted 2 lines
I'm using Visual Studio Code, so I might not have the correct settings for this editor with QEMU. The checkpatch script doesn't complain on style issues, so what can I do to make this correct?
If checkpatch is happy then probably not a problem but just look at how code is indented on other places and follow the same. The coding style doc may have some words on it too. I don't know what setting Visual Studio might need.
Regards,
BALATON Zoltan
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 42 lines · BALATON Zoltan
Quoted 35 lines · Liav Albani
Quoted 34 lines · BALATON Zoltan
Quoted 2 lines · Liav Albani
Instead of letting each implementation to duplicate this code, we can share these functions between IDE PIIX3/4 and VIA implementations.
OK but there's a way to take this even further as cmd646 also uses similar functions just with more cases so you could remove the cases handled by these functions and only leave the difference and call the default function from the default case. E.g. (untested, just to show the idea):
hw/ide/cmd646.c:
staticuint64_tbmdma_read(void *opaque, hwaddr addr, unsigned size)
{
BMDMAState *bm = opaque;
PCIDevice*pci_dev=PCI_DEVICE(bm->pci_dev);uint32_tval;if (size != 1) {
return ((uint64_t)1 << (size * 8)) - 1;
}
switch(addr & 3){
case 1:
val = pci_dev->config[MRDMODE]; break;
case 3:
if (bm == &bm->pci_dev->bmdma[0]) { val = pci_dev->config[UDIDETCR0]; } else {
val = pci_dev->config[UDIDETCR1]; }
break;
default:
val =bmdma_default_read(opaque, addr, size); break;
}Quoted 5 lines
Quoted 4 lines
trace_bmdma_read_cmd646(addr, val);
return val;
}Yeah, I see how I can do that for both bmdma write and read of cmd646. I'll send a v2 right away with a fix.
Quoted 7 lines
Maybe even the first if that's already contained in the default function could be avoided with some reorganisation like
if (size == 1) {
remaining switch cases to set val} else { val = bmdma_default_read(); }
On second thought this misses the cases where size == 1 and addr is those handeled in bmdma_default_read so one would still need the default case in the if part and then it's not much better than duplicating the if. Maybe calling the default first, then handling the remaining cases, like
val = bmdma_default_read();
if (size == 1) {
remaining switch cases to set val
}
return val;
is the simplest and avoids the duplicated if. (Now we only have two trace messages instead of one but that's probably not a problem as it's only a debugging aid.
Regards.
BALATON Zoltan
Quoted 44 lines
but I wasn't sure that won't change anything so may need a bit more thought.
Quoted 21 lines
Quoted 16 lines
Quoted 16 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------include/hw/ide/pci.h| 4 ++++4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, };Quoted 5 lines
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 2 lines
hw/ide/pci.c +2
-0+uint64_t bmdma_default_read (void *opaque,hwaddr addr, + unsigned size)Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
Quoted 6 lines
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr, + unsigned size)
Like this?
No, like the code you've moved had it. The split line should start after the ( not on the same column. So:
uint64_tbmdma_default_read(void *opaque, hwaddr addr, unsigned size)but this line does not need to be split at all as it fits within 80 chars so better to keep it one line and only split where needed.
Quoted 2 lines
I'm using Visual Studio Code, so I might not have the correct settings for this editor with QEMU. The checkpatch script doesn't complain on style issues, so what can I do to make this correct?
If checkpatch is happy then probably not a problem but just look at how code is indented on other places and follow the same. The coding style doc may have some words on it too. I don't know what setting Visual Studio might need.
Regards,
BALATON Zoltan
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 11 lines · BALATON Zoltan
Quoted 7 lines · BALATON Zoltan
Maybe even the first if that's already contained in the default function could be avoided with some reorganisation like
if (size == 1) {
remaining switch cases to set val
} else {
val =bmdma_default_read();
}On second thought this misses the cases where size == 1 and addr is those handeled in
bmdma_default_readso one would still need the default case in the if part and then it's not much better than duplicating the if. Maybe calling the default first, then handling the remaining cases, like
Quoted 8 lines
val =
bmdma_default_read();
if (size == 1) {
remaining switch cases to set val
}
return val;is the simplest and avoids the duplicated if. (Now we only have two trace messages instead of one but that's probably not a problem as it's only a debugging aid.
Hmm, is it OK though to have two trace messages? I'm not against it, but if someone tries to use the debug messages to see what's going on, it's better to not have two of the same message as it will confuse people. We definitely don't want that to happen.
So, let's keep it simple (and remove code duplications) but also let's do that correctly, to ensure that in the view of the developer that uses the debug messages, it all seem clear and neat :)
Quoted 37 lines
Quoted 37 lines
but I wasn't sure that won't change anything so may need a bit more thought.
Quoted 22 lines
Quoted 17 lines
Quoted 17 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51
++------------------------------------------include/hw/ide/pci.h| 4 ++++4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, };Quoted 5 lines
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 2 lines
hw/ide/pci.c +2
-0+uint64_t bmdma_default_read (void *opaque,hwaddr addr, + unsigned size)Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
Quoted 6 lines
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr, + unsigned size)
Like this?
No, like the code you've moved had it. The split line should start after the ( not on the same column. So:
uint64_tbmdma_default_read(void *opaque, hwaddr addr, unsigned size)
Quoted 6 lines
Quoted 6 lines
but this line does not need to be split at all as it fits within 80 chars so better to keep it one line and only split where needed.
Quoted 2 lines
I'm using Visual Studio Code, so I might not have the correct settings for this editor with QEMU. The checkpatch script doesn't complain on style issues, so what can I do to make this correct?
If checkpatch is happy then probably not a problem but just look at how code is indented on other places and follow the same. The coding style doc may have some words on it too. I don't know what setting Visual Studio might need.
OK. I'll align it to the character after the start of the parenthesis. I'll take a look into other code snippets in QEMU, but at least in the IDE code, there are lots of code style issues (the checkpatch script says so) so I'll probably look into other parts of QEMU to see how it goes.
I'll take this a bit slow, as I wanted to send v2 today. This is probably not a good idea as we should let people to see this and maybe to let the maintainer (John) to look into this and put his comments on this too. I'll give this a couple of days - no rush here, although I'd be very happy to see things going forward as soon as possible, so we merge this patch and then going back to the ich6-ide patch, and then hopefully more patches to the IDE code to add more features and fixes in this part of QEMU codebase.
Thanks again for the suggestions, these are awesome and I really appreciate the effort you put into these!
Best regards,
Liav
Re: [PATCH 1/1] hw/ide: share bmdma read and write functions between piix.c and via.c
Quoted 18 lines · Liav Albani
Quoted 17 lines · BALATON Zoltan
Quoted 7 lines · BALATON Zoltan
Maybe even the first if that's already contained in the default function could be avoided with some reorganisation like
if (size == 1) {
remaining switch cases to set val
} else {
val =bmdma_default_read();
}On second thought this misses the cases where size == 1 and addr is those handeled in
bmdma_default_readso one would still need the default case in the if part and then it's not much better than duplicating the if. Maybe calling the default first, then handling the remaining cases, likeval =
bmdma_default_read();
if (size == 1) {
remaining switch cases to set val
}
return val;
Quoted 3 lines
Quoted 2 lines
is the simplest and avoids the duplicated if. (Now we only have two trace messages instead of one but that's probably not a problem as it's only a debugging aid.
Hmm, is it OK though to have two trace messages? I'm not against it, but if someone tries to use the debug messages to see what's going on, it's better to not have two of the same message as it will confuse people. We definitely don't want that to happen.
I don't think this is a problem. One message is from the bmdma default function and one is from the cmd646 specific function overriding it so both may have some usefulness and one can enable/disable them separately so for cmd646 one can only enable the specific one to avoid duplicated messages.
Quoted 1 line
So, let's keep it simple (and remove code duplications) but also let's do that correctly, to ensure that in the view of the developer that uses the debug messages, it all seem clear and neat :)
I don't see an easy way to avoid that otherwise because we can't move the trace out from the default functions because some controllers only use that so the simplest is to not care about this.
Quoted 36 lines
Quoted 36 lines
Quoted 36 lines
but I wasn't sure that won't change anything so may need a bit more thought.
Quoted 21 lines
Quoted 16 lines
Quoted 16 lines
Signed-off-by Liav Albani <[email protected]>---
hw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------include/hw/ide/pci.h| 4 ++++4 files changed, 55 insertions(+), 97 deletions(-)hw/ide/pci.c +0
-0@@ -502,6 +502,53 @@ static const struct IDEDMAOps bmdma_ops = { .reset = bmdma_reset, };Quoted 5 lines
hw/ide/pci.c static const struct IDEDMAOps bmdma_ops = { · line 506
Quoted 2 lines
hw/ide/pci.c +2
-0+uint64_t bmdma_default_read (void *opaque,hwaddr addr, + unsigned size)Indentation off? Also everywhere else, usually we indent not with the parenthesis but with the list within. (Auto indent in most editors does that probably.)
Quoted 6 lines
I guess you mean that it should be:
+uint64_t bmdma_default_read(void *opaque, hwaddr addr, + unsigned size)
Like this?
No, like the code you've moved had it. The split line should start after the ( not on the same column. So:
uint64_tbmdma_default_read(void *opaque, hwaddr addr, unsigned size)
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
but this line does not need to be split at all as it fits within 80 chars so better to keep it one line and only split where needed.
Quoted 2 lines
I'm using Visual Studio Code, so I might not have the correct settings for this editor with QEMU. The checkpatch script doesn't complain on style issues, so what can I do to make this correct?
If checkpatch is happy then probably not a problem but just look at how code is indented on other places and follow the same. The coding style doc may have some words on it too. I don't know what setting Visual Studio might need.
OK. I'll align it to the character after the start of the parenthesis. I'll take a look into other code snippets in QEMU, but at least in the IDE code, there are lots of code style issues (the checkpatch script says so) so I'll probably look into other parts of QEMU to see how it goes.
Some parts of QEMU has some old code not yet following the latest coding style. Checkpatch usually tells you and if it's a few lines it's OK to correct it in the part you touch to silence checkpatch. Otherwise a separate code style fix patch before the modifications could also be included to avoid such warnings during later changes. I think this is explained in the patch submission guidelines.
Quoted 1 line
I'll take this a bit slow, as I wanted to send v2 today. This is probably not a good idea as we should let people to see this and maybe to let the maintainer (John) to look into this and put his comments on this too. I'll give this a couple of days - no rush here, although I'd be very happy to see things going forward as soon as possible, so we merge this patch and then going back to the ich6-ide patch, and then hopefully more patches to the IDE code to add more features and fixes in this part of QEMU codebase.
The only constraint is if you want this in the next release or it's ok to postpone it further. See the planning page about the schedule: https://wiki.qemu.org/Planning/7.0 which means if it's not in a pull request until March 8 then it will miss 7.0 and you'll have plenty of time to get the remaining changes polished until development opens again in second half of April.
Regards,
BALATON Zoltan
Am 19. Februar 2022 08:08:17 UTC schrieb Liav Albani <[email protected]>:
Quoted 6 lines
This is a preparation before I send v3 of ich6-ide controller emulation patch. I figured that it's more trivial to split the changes this way, by extracting the bmdma functions from
via.candpiix.cand sharing them together. Then, I could easily put these into use when I send v3 of the ich6-ide patch by just using the already separated functions. This was suggested by BALATON Zoltan when he submitted a code review on my ich6-ide controller emulation patch.
Ping. Any news?
Quoted 9 lines
Liav Albani (1):
hw/ide: share bmdma read and write functions betweenpiix.candvia.chw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)
Quoted 10 lines · Bernhard Beschow
Am 19. Februar 2022 08:08:17 UTC schrieb Liav Albani <[email protected]>:
Quoted 6 lines
This is a preparation before I send v3 of ich6-ide controller emulation patch. I figured that it's more trivial to split the changes this way, by extracting the bmdma functions from
via.candpiix.cand sharing them together. Then, I could easily put these into use when I send v3 of the ich6-ide patch by just using the already separated functions. This was suggested by BALATON Zoltan when he submitted a code review on my ich6-ide controller emulation patch.Ping. Any news?
*cough*.
Has this been folded into subsequent series, or does this still need attention?
Quoted 11 lines
Quoted 10 lines
Liav Albani (1):
hw/ide: share bmdma read and write functions betweenpiix.candvia.chw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)
Am 9. Januar 2023 19:24:16 UTC schrieb John Snow <[email protected]>:
Quoted 10 lines · Bernhard Beschow
Quoted 9 lines
Am 19. Februar 2022 08:08:17 UTC schrieb Liav Albani <[email protected]>:
Quoted 6 lines
This is a preparation before I send v3 of ich6-ide controller emulation patch. I figured that it's more trivial to split the changes this way, by extracting the bmdma functions from
via.candpiix.cand sharing them together. Then, I could easily put these into use when I send v3 of the ich6-ide patch by just using the already separated functions. This was suggested by BALATON Zoltan when he submitted a code review on my ich6-ide controller emulation patch.
Quoted 5 lines
Quoted 1 line
Ping. Any news?
*cough*.
Has this been folded into subsequent series, or does this still need attention?
Both piix and via still have their own bmdma implementations. This patch might be worth having.
Best regards,
Bernhard
Quoted 13 lines
Quoted 12 lines
Quoted 11 lines
Liav Albani (1):
hw/ide: share bmdma read and write functions betweenpiix.candvia.chw/ide/pci.c | 47 ++++++++++++++++++++++++++++++++++++++++ hw/ide/piix.c | 50 ++----------------------------------------- hw/ide/via.c | 51 ++------------------------------------------ include/hw/ide/pci.h | 4 ++++ 4 files changed, 55 insertions(+), 97 deletions(-)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Liav Albani
On 1/11/23 01:07, Bernhard Beschow wrote:
Am 9. Januar 2023 19:24:16 UTC schrieb John Snow <[email protected]>:
On Tue, Sep 6, 2022 at 10:27 AM Bernhard Beschow <[email protected]> wrote:
Am 19. Februar 2022 08:08:17 UTC schrieb Liav Albani <[email protected]>:
This is a preparation before I send v3 of ich6-ide controller emulation patch. I figured that it's more trivial to split the changes this way, by extracting the bmdma functions from
via.candpiix.cand sharing them together. Then, I could easily put these into use when I send v3 of the ich6-ide patch by just using the already separated functions. This was suggested by BALATON Zoltan when he submitted a code review on my ich6-ide controller emulation patch.Ping. Any news?
*cough*.
Quoted 9 lines
Has this been folded into subsequent series, or does this still need attention?
Both piix and via still have their own bmdma implementations. This patch might be worth having.
Best regards,
BernhardI see. Since you are still interested, I will try to see what was the outcome of that patch as I really don't remember if it passed the CI tests, etc. If applicable, I will send this as v2, or if it's already approved, then I guess we could just let it be merged to the tree?
I was just going to run some smoke tests on it and as long as it didn't hurt anything, I'd wave it in. If you want it alongside other patches that I also should stage, you can bundle them if you'd like. Just let me know what you plan on doing.
--js