hw/ssi: imx_spi: Use a macro for number of chip selects supported
PATCH v2 1/2 hw/ssi: imx_spi: Use a macro for number of chip selects supported
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
---
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)
hw/ssi/imx_spi.c +2 -2
@@ -361,7 +361,7 @@ static void imx_spi_write(void *opaque, hwaddr offset, uint64_t value,/* We are in master mode */ -for (i =0 ; i <4 ; i++) { +for (i =0 ; i <ECSPI_NUM_CS ; i++) {qemu_set_irq (s->cs_lines[i], i ==imx_spi_selected_channel (s) ?0 :1 ); }
@@ -424,7 +424,7 @@ static void imx_spi_realize(DeviceState *dev, Error **errp)sysbus_init_mmio (SYS_BUS_DEVICE (dev), &s->iomem);sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->irq); -for (i =0 ; i <4 ; ++i) { +for (i =0 ; i <ECSPI_NUM_CS ; ++i) {sysbus_init_irq (SYS_BUS_DEVICE (dev), &s->cs_lines[i]); }
include/hw/ssi/imx_spi.h +4 -1
@@ -77,6 +77,9 @@#define EXTRACT (value, name) extract32(value, name##_SHIFT, name##_LENGTH) +/* number of chip selects supported */ +#define ECSPI_NUM_CS 4 +#define TYPE_IMX_SPI "imx.spi"OBJECT_DECLARE_SIMPLE_TYPE (IMXSPIState,IMX_SPI )
@@ -89,7 +92,7 @@ struct IMXSPIState {qemu_irq irq; -qemu_irq cs_lines[4 ]; +qemu_irq cs_lines[ECSPI_NUM_CS ];SSIBus *bus;
Signature · 1 line
2.25.1
PATCH v2 2/2 hw/ssi: imx_spi: Disable chip selects in imx_spi_reset()
From: Xuzhou Cheng <[email protected]>
When a write to ECSPI_CONREG register to disable the SPI controller, imx_spi_reset() is called to reset the controller, during which CS lines should have been disabled, otherwise the state machine of any devices (e.g.: SPI flashes) connected to the SPI master is stuck to its last state and responds incorrectly to any follow-up commands.
---
Changes in v2:
- Fix the "Fixes" tag in the commit message
hw/ssi/imx_spi.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/ssi/imx_spi.c +5 -0
@@ -231,6 +231,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s)static void imx_spi_reset (DeviceState *dev) {IMXSPIState *s =IMX_SPI (dev); +int i;DPRINTF ("\n" );
@@ -243,6 +244,10 @@ static void imx_spi_reset(DeviceState *dev)imx_spi_update_irq (s); +for (i =0 ; i <ECSPI_NUM_CS ; i++) { +qemu_set_irq (s->cs_lines[i],1 ); + } + s->burst_length =0 ; }
Signature · 1 line
2.25.1
Re: [PATCH v2 2/2] hw/ssi: imx_spi: Disable chip selects in imx_spi_reset()
Quoted 35 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
When a write to
ECSPI_CONREGregister to disable the SPI controller,imx_spi_reset()is called to reset the controller, during which CS lines should have been disabled, otherwise the state machine of any devices (e.g.: SPI flashes) connected to the SPI master is stuck to its last state and responds incorrectly to any follow-up commands.Fixes c906a3a01582 ("i.MX: Add the Freescale SPI Controller")Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>Acked-by Alistair Francis <[email protected]>---
Changes in v2:
- Fix the "Fixes" tag in the commit messagehw/ssi/imx_spi.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ssi/imx_spi.c +1
-0@@ -231,6 +231,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s)static void imx_spi_reset (DeviceState *dev) {IMXSPIState *s =IMX_SPI (dev); +int i;DPRINTF ("\n" );
hw/ssi/imx_spi.c static void imx_spi_reset(DeviceState *dev) · line 249
Quoted 6 lines
hw/ssi/imx_spi.c +3
-0@@ -243,6 +244,10 @@ static void imx_spi_reset(DeviceState *dev)imx_spi_update_irq (s); +for (i =0 ; i <ECSPI_NUM_CS ; i++) { +qemu_set_irq (s->cs_lines[i],1 ); + }
Calling qemu_set_irq() in a device reset function is a bad idea, because you don't know whether the thing on the other end of the IRQ line (a) has already reset before you or
(b) is going to reset after you. If you need to do this then I think you need to convert this device (and perhaps whatever it's connected to) to the 3-phase-reset API. (But you probably don't, see below.)
Usually the approach is that the device on the other end of the line is going to reset its state anyway, so there's no need to actively signal an irq line change.
If this is required only for the case of "guest requested a controller reset via the ECSPI_CONREG register" and not for full system reset, then you can handle that by having an imx_spi_soft_reset() which calls imx_spi_reset() and then does the qemu_set_irq() calls, so full system (power-cycle) reset still goes to imx_spi_reset() but guest-commanded reset via the register interface calls imx_spi_soft_reset().
thanks
-- PMM
Re: [PATCH v2 2/2] hw/ssi: imx_spi: Disable chip selects in imx_spi_reset()
Quoted 40 lines · Peter Maydell
Quoted 38 lines · Bin Meng
From: Xuzhou Cheng <[email protected]>
When a write to
ECSPI_CONREGregister to disable the SPI controller,imx_spi_reset()is called to reset the controller, during which CS lines should have been disabled, otherwise the state machine of any devices (e.g.: SPI flashes) connected to the SPI master is stuck to its last state and responds incorrectly to any follow-up commands.Fixes c906a3a01582 ("i.MX: Add the Freescale SPI Controller")Signed-off-by Xuzhou Cheng <[email protected]>Signed-off-by Bin Meng <[email protected]>Acked-by Alistair Francis <[email protected]>---
Changes in v2:
- Fix the "Fixes" tag in the commit messagehw/ssi/imx_spi.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ssi/imx_spi.c +1
-0@@ -231,6 +231,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s)static void imx_spi_reset (DeviceState *dev) {IMXSPIState *s =IMX_SPI (dev); +int i;DPRINTF ("\n" );@@ -243,6 +244,10 @@ static void imx_spi_reset(DeviceState *dev)imx_spi_update_irq (s);
Quoted 12 lines
hw/ssi/imx_spi.c static void imx_spi_reset(DeviceState *dev) · line 249
Quoted 3 lines
hw/ssi/imx_spi.c +3
-0+for (i =0 ; i <ECSPI_NUM_CS ; i++) { +qemu_set_irq (s->cs_lines[i],1 ); + }Calling
qemu_set_irq()in a device reset function is a bad idea, because you don't know whether the thing on the other end of the IRQ line (a) has already reset before you or
(b) is going to reset after you. If you need to do this then I think you need to convert this device (and perhaps whatever it's connected to) to the 3-phase-reset API. (But you probably don't, see below.)
Thanks for the review. What about the imx_spi_update_irq() in the imx_spi_reset()? Should we remove that from the imx_spi_reset() as well?
Quoted 4 lines
Usually the approach is that the device on the other end of the line is going to reset its state anyway, so there's no need to actively signal an irq line change.
Quoted 8 lines
If this is required only for the case of "guest requested a controller reset via the
ECSPI_CONREGregister" and not for full system reset, then you can handle that by having animx_spi_soft_reset()which callsimx_spi_reset()and then does theqemu_set_irq()calls, so full system (power-cycle) reset still goes toimx_spi_reset()but guest-commanded reset via the register interface callsimx_spi_soft_reset().
Regards,
Bin
Re: [PATCH v2 2/2] hw/ssi: imx_spi: Disable chip selects in imx_spi_reset()
Quoted 11 lines · Bin Meng
Quoted 8 lines · Peter Maydell
Calling
qemu_set_irq()in a device reset function is a bad idea, because you don't know whether the thing on the other end of the IRQ line (a) has already reset before you or
(b) is going to reset after you. If you need to do this then I think you need to convert this device (and perhaps whatever it's connected to) to the 3-phase-reset API. (But you probably don't, see below.)
Quoted 3 lines
Thanks for the review. What about the
imx_spi_update_irq()in theimx_spi_reset()? Should we remove that from theimx_spi_reset()as well?
Yes, I think so.
thanks
-- PMM
Hi Alistair, Peter,
Quoted 8 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>
Quoted 8 lines
---
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)
Ping, not sure who is going to pick up this series?
Regards,
Bin
Quoted 14 lines · Bin Meng
Hi Alistair, Peter,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
Quoted 8 lines
Quoted 6 lines
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
Ping?
Quoted 18 lines · Bin Meng
Quoted 16 lines · Bin Meng
Hi Alistair, Peter,
Quoted 12 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
(no changes since v1)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
Ping?
Ping?
Quoted 14 lines · Bin Meng
Hi Alistair, Peter,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
Quoted 8 lines
Quoted 6 lines
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
It should be reviewed by Jean-Christophe and then probably go via the ARM tree.
Alistair
Quoted 4 lines
Regards,
Bin
Quoted 18 lines · Alistair Francis
Quoted 16 lines · Bin Meng
Hi Alistair, Peter,
Quoted 12 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
(no changes since v1)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
It should be reviewed by Jean-Christophe and then probably go via the ARM tree.
It doesn't seem to have been sent with a cover letter. Multi-patch patchsets without a cover letter tend to get missed because when I scan through my email looking for patches I should review or pick up I'm looking for either (a) single patches or (b) the 00/nn cover letter email...
thanks
-- PMM
Quoted 27 lines · Peter Maydell
Quoted 25 lines · Alistair Francis
Quoted 22 lines · Bin Meng
Hi Alistair, Peter,
Quoted 8 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>Quoted 8 lines
---
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
Quoted 7 lines
Quoted 1 line
It should be reviewed by Jean-Christophe and then probably go via the ARM tree.
It doesn't seem to have been sent with a cover letter. Multi-patch patchsets without a cover letter tend to get missed because when I scan through my email looking for patches I should review or pick up I'm looking for either (a) single patches or (b) the 00/nn cover letter email...
Thanks. I will resend it with a cover-letter.
Regards,
Bin
Quoted 31 lines · Bin Meng
Quoted 29 lines · Peter Maydell
Quoted 26 lines · Alistair Francis
Quoted 14 lines · Bin Meng
Hi Alistair, Peter,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
Quoted 8 lines
Quoted 6 lines
(no changes since v1)
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
It should be reviewed by Jean-Christophe and then probably go via the ARM tree.
Quoted 7 lines
Quoted 5 lines
It doesn't seem to have been sent with a cover letter. Multi-patch patchsets without a cover letter tend to get missed because when I scan through my email looking for patches I should review or pick up I'm looking for either (a) single patches or (b) the 00/nn cover letter email...
Thanks. I will resend it with a cover-letter.
This series is resent and included in the following series with a cover letter:
http://patchwork.ozlabs.org/project/qemu-devel/list/?series=222931
Regards,
Bin
Quoted 18 lines · Alistair Francis
Quoted 16 lines · Bin Meng
Hi Alistair, Peter,
Quoted 12 lines · Bin Meng
From: Bin Meng <[email protected]>
Avoid using a magic number (4) everywhere for the number of chip selects supported.
Signed-off-by Bin Meng <[email protected]>Reviewed-by Alistair Francis <[email protected]>---
(no changes since v1)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
hw/ssi/imx_spi.c | 4 ++-- include/hw/ssi/imx_spi.h | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-)Ping, not sure who is going to pick up this series?
It should be reviewed by Jean-Christophe and then probably go via the ARM tree.
Ah, I just realised I apparently have hw/ssi/* listed in MAINTAINERS. As this file is specifically mentioned somewhere else in MAINTAINERS and I know very little about IMX I'm going to leave this alone still.
Alistair
Quoted 7 lines
Alistair
Quoted 4 lines
Regards,
Bin