i3c: mipi-i3c-hci: Allow only relevant INTR_STATUS bit updates
PATCH 1/4 i3c: mipi-i3c-hci: Allow only relevant INTR_STATUS bit updates
Since MIPI I3C HCI specification version v0.8 INTR_STATUS bits 9:0 are reserved. Version v0.5 has bits 9 and 5:0 in use but not handled by the current driver code and not needed in DMA transfers.
PIO transfers with v0.5 would require changes to both core.c: i3c_hci_irq_handler() and pio.c: hci_pio_irq_handler() though.
For these reasons don't enable signal updates from INTR_STATUS bits 9:0.
This change is a no-op for specification versions v0.8 and beyond but gets rid of "unexpected INTR_STATUS" errors if somebody (read me) wants to run code on old v0.5 IP version.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +3 -2
@@ -699,9 +699,10 @@ static int i3c_hci_init(struct i3c_hci *hci)if (ret)return -ENXIO ; -/* Disable all interrupts and allow all signal updates */ +/* Disable all interrupts */ reg_write (INTR_SIGNAL_ENABLE ,0x0 ); -reg_write (INTR_STATUS_ENABLE ,0xffffffff ); +/* Allow signal updates relevant to IP versions 0.8 and beyond */ +reg_write (INTR_STATUS_ENABLE ,GENMASK (31 ,10 ));/* Make sure our data ordering fits the host's */ regval =reg_read (HC_CONTROL );
Signature · 7 lines
2.47.2 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
PATCH 2/4 i3c: mipi-i3c-hci: Fix handling status of i3c_hci_irq_handler()
Return IRQ_HANDLED from the i3c_hci_irq_handler() only if some INTR_STATUS bit was set or if DMA/PIO handler handled it.
Currently it returns IRQ_HANDLED in case INTR_STATUS is zero and IO handler returns false. Which could be the case if interrupt comes from other device or is spurious.
--- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +3 -3
@@ -594,6 +594,7 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)if (val) {reg_write (INTR_STATUS , val); + result =IRQ_HANDLED ; }if (val &INTR_HC_RESET_CANCEL ) {
@@ -605,12 +606,11 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) val &= ~INTR_HC_INTERNAL_ERR ; } - hci->io->irq_handler (hci); +if (hci->io->irq_handler (hci)) + result =IRQ_HANDLED ;if (val)dev_err (&hci->master.dev,"unexpected INTR_STATUS %#x\n" , val); -else - result =IRQ_HANDLED ;return result; }
Signature · 7 lines
2.47.2 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
reviewerRe: [PATCH 2/4] i3c: mipi-i3c-hci: Fix handling status of i3c_hci_irq_handler()
Quoted 17 lines · Jarkko Nikula
Return
IRQ_HANDLEDfrom thei3c_hci_irq_handler()only if someINTR_STATUSbit was set or if DMA/PIO handler handled it.Currently it returns
IRQ_HANDLEDin caseINTR_STATUSis zero and IO handler returns false. Which could be the case if interrupt comes from other device or is spurious.Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +0
-0
drivers/i3c/master/mipi-i3c-hci/core.c static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) · line 597
Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/core.c +1
-0@@ -594,6 +594,7 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)if (val) {reg_write (INTR_STATUS , val); + result =IRQ_HANDLED ;
Not related this patch.reg_write(INTR_STATUS, val); should be unconditional since INTR_STATUS is w1c.
I am strange why need return IRQ_NONE case. I suppose it should always return IRQ_HANDLED.
Frank
Quoted 26 lines
drivers/i3c/master/mipi-i3c-hci/core.c +2
-4}if (val &INTR_HC_RESET_CANCEL ) {@@ -605,12 +606,11 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) val &= ~INTR_HC_INTERNAL_ERR ; } - hci->io->irq_handler (hci); +if (hci->io->irq_handler (hci)) + result =IRQ_HANDLED ;if (val)dev_err (&hci->master.dev,"unexpected INTR_STATUS %#x\n" , val); -else - result =IRQ_HANDLED ;return result; } --2.47.2
--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH 2/4] i3c: mipi-i3c-hci: Fix handling status of i3c_hci_irq_handler()
Hi
Quoted 27 lines · Frank Li
Quoted 17 lines · Jarkko Nikula
Return
IRQ_HANDLEDfrom thei3c_hci_irq_handler()only if someINTR_STATUSbit was set or if DMA/PIO handler handled it.Currently it returns
IRQ_HANDLEDin caseINTR_STATUSis zero and IO handler returns false. Which could be the case if interrupt comes from other device or is spurious.Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i3c/master/mipi-i3c-hci/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +0
-0drivers/i3c/master/mipi-i3c-hci/core.c static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) · line 597
Quoted 4 lines
drivers/i3c/master/mipi-i3c-hci/core.c +1
-0@@ -594,6 +594,7 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id)if (val) {reg_write (INTR_STATUS , val); + result =IRQ_HANDLED ;Not related this patch.
reg_write(INTR_STATUS, val); should be unconditional sinceINTR_STATUSis w1c.
Quoted 3 lines
I am strange why need return
IRQ_NONEcase. I suppose it should always returnIRQ_HANDLED.
This makes driver more ready for shared interrupts and let kernel interrupt code be able to disable bad behaving interrupt (misrouted, wrong polarity, etc) by returning IRQ_NONE when we know interrupt wasn't generated by this device.
Currently driver doesn't support shared interrupts since IRQF_SHARED flag is not passed to the devm_request_irq() call in i3c_hci_probe(). I didn't change that since I don't have a setup to test.
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
PATCH 3/4 i3c: mipi-i3c-hci: Change name of INTR_STATUS bit 11
In reply to Jarkko NikulaINTR_STATUS bit 11 INTR_HC_RESET_CANCEL was probably projected for the MIPI I3C HCI specification version 2 but was not ever implemented.
This bit is first time specified in the v1.2 as HC_SEQ_CANCEL_STAT "Host Controller Cancelled Transaction Sequence". Update the definition and debug print of it accordingly.
While at it, change DBG() print to dev_dbg().
--- drivers/i3c/master/mipi-i3c-hci/core.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +5 -4
@@ -78,7 +78,7 @@#define INTR_SIGNAL_ENABLE 0x28#define INTR_FORCE 0x2c#define INTR_HC_CMD_SEQ_UFLOW_STAT BIT(12)/* Cmd Sequence Underflow */ -#define INTR_HC_RESET_CANCEL BIT(11)/* HC Cancelled Reset */ +#define INTR_HC_SEQ_CANCEL BIT(11)/* HC Cancelled Transaction Sequence */ #define INTR_HC_INTERNAL_ERR BIT(10)/* HC Internal Error */ #define DAT_SECTION 0x30/* Device Address Table */
@@ -597,9 +597,10 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) result =IRQ_HANDLED ; } -if (val &INTR_HC_RESET_CANCEL ) { -DBG ("cancelled reset" ); - val &= ~INTR_HC_RESET_CANCEL ; +if (val &INTR_HC_SEQ_CANCEL ) { +dev_dbg (&hci->master.dev, +"Host Controller Cancelled Transaction Sequence\n" ); + val &= ~INTR_HC_SEQ_CANCEL ; }if (val &INTR_HC_INTERNAL_ERR ) {dev_err (&hci->master.dev,"Host Controller Internal Error\n" );
Signature · 7 lines
2.47.2 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
PATCH 4/4 i3c: mipi-i3c-hci: Move unexpected INTR_STATUS print before IO handler
In reply to Jarkko NikulaMove "unexpected INTR_STATUS" error print before calling the IO handler as it is more consistent that way. Otherwise it may be confusing if generic interrupt related prints are mixed with IO handler prints.
Since this error print is more indication of missing code rather than runtime error downgrade it to dev_warn_once().
--- drivers/i3c/master/mipi-i3c-hci/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/i3c/master/mipi-i3c-hci/core.c +4 -3
@@ -607,12 +607,13 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) val &= ~INTR_HC_INTERNAL_ERR ; } +if (val) +dev_warn_once (&hci->master.dev, +"unexpected INTR_STATUS %#x\n" , val); +if (hci->io->irq_handler (hci)) result =IRQ_HANDLED ; -if (val) -dev_err (&hci->master.dev,"unexpected INTR_STATUS %#x\n" , val); -return result; }
Signature · 7 lines
2.47.2 -- linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Re: [PATCH 4/4] i3c: mipi-i3c-hci: Move unexpected INTR_STATUS print before IO handler
Quoted 8 lines · Jarkko Nikula
Move "unexpected
INTR_STATUS" error print before calling the IO handler as it is more consistent that way. Otherwise it may be confusing if generic interrupt related prints are mixed with IO handler prints.Since this error print is more indication of missing code rather than runtime error downgrade it to
dev_warn_once().Signed-off-by Jarkko Nikula <[email protected]>
Quoted 33 lines
--- drivers/i3c/master/mipi-i3c-hci/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +4
-4@@ -607,12 +607,13 @@ static irqreturn_t i3c_hci_irq_handler(int irq, void *dev_id) val &= ~INTR_HC_INTERNAL_ERR ; } +if (val) +dev_warn_once (&hci->master.dev, +"unexpected INTR_STATUS %#x\n" , val); +if (hci->io->irq_handler (hci)) result =IRQ_HANDLED ; -if (val) -dev_err (&hci->master.dev,"unexpected INTR_STATUS %#x\n" , val); -return result; } --2.47.2
--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
reviewerQuoted 6 lines · Jarkko Nikula
Since MIPI I3C HCI specification version v0.8
INTR_STATUSbits 9:0 are reserved. Version v0.5 has bits 9 and 5:0 in use but not handled by the current driver code and not needed in DMA transfers.PIO transfers with v0.5 would require changes to both
core.c:i3c_hci_irq_handler()andpio.c:hci_pio_irq_handler()though.
If reasonable, why not change core.c and pio.c?
Quoted 6 lines
For these reasons don't enable signal updates from
INTR_STATUSbits 9:0.This change is a no-op for specification versions v0.8 and beyond but gets rid of "unexpected
INTR_STATUS" errors if somebody (read me) wants to run code on old v0.5 IP version.
I think, simple said
"Get rid of "unexpected INTR_STATUS" errors at old v0.5 IP version and no-op for version above v0.8."
Quoted 11 lines
Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i3c/master/mipi-i3c-hci/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +0
-0
drivers/i3c/master/mipi-i3c-hci/core.c static int i3c_hci_init(struct i3c_hci *hci) · line 705
Quoted 9 lines
drivers/i3c/master/mipi-i3c-hci/core.c +3
-2@@ -699,9 +699,10 @@ static int i3c_hci_init(struct i3c_hci *hci)if (ret)return -ENXIO ; -/* Disable all interrupts and allow all signal updates */ +/* Disable all interrupts */ reg_write (INTR_SIGNAL_ENABLE ,0x0 ); -reg_write (INTR_STATUS_ENABLE ,0xffffffff ); +/* Allow signal updates relevant to IP versions 0.8 and beyond */ +reg_write (INTR_STATUS_ENABLE ,GENMASK (31 ,10 ));
Generally, just enable needed IRQ in driver. Define some BITS for difference type IRQs.
Frank
Quoted 11 lines
drivers/i3c/master/mipi-i3c-hci/core.c +0
-1/* Make sure our data ordering fits the host's */ regval =reg_read (HC_CONTROL ); --2.47.2
--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Hi Frank
Sorry the delay, somehow I missed your comments to this patch :-|
Quoted 10 lines · Frank Li
Quoted 6 lines · Jarkko Nikula
Since MIPI I3C HCI specification version v0.8
INTR_STATUSbits 9:0 are reserved. Version v0.5 has bits 9 and 5:0 in use but not handled by the current driver code and not needed in DMA transfers.PIO transfers with v0.5 would require changes to both
core.c:i3c_hci_irq_handler()andpio.c:hci_pio_irq_handler()though.If reasonable, why not change
core.candpio.c?
I had two reasons for that. The v0.5 compatible IP I use in testing doesn't support PIO transfers and thus didn't want to add code that is not tested.
Then I believe perhaps nobody will release HW with this old IP and thus it would be dead code anyway.
Quoted 11 lines
Quoted 6 lines
For these reasons don't enable signal updates from
INTR_STATUSbits 9:0.This change is a no-op for specification versions v0.8 and beyond but gets rid of "unexpected
INTR_STATUS" errors if somebody (read me) wants to run code on old v0.5 IP version.I think, simple said
"Get rid of "unexpectedINTR_STATUS" errors at old v0.5 IP version and no-op for version above v0.8."
Makes sense, will change.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i3c/master/mipi-i3c-hci/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +0
-0@@ -699,9 +699,10 @@ static int i3c_hci_init(struct i3c_hci *hci)if (ret)return -ENXIO ;
Quoted 10 lines
drivers/i3c/master/mipi-i3c-hci/core.c static int i3c_hci_init(struct i3c_hci *hci) · line 705
Quoted 6 lines
drivers/i3c/master/mipi-i3c-hci/core.c +3
-2-/* Disable all interrupts and allow all signal updates */ +/* Disable all interrupts */ reg_write (INTR_SIGNAL_ENABLE ,0x0 ); -reg_write (INTR_STATUS_ENABLE ,0xffffffff ); +/* Allow signal updates relevant to IP versions 0.8 and beyond */ +reg_write (INTR_STATUS_ENABLE ,GENMASK (31 ,10 ));Generally, just enable needed IRQ in driver. Define some BITS for difference type IRQs.
I was thinking too these need changes too but decided those are better to do in another patch(es).
Currently all of these generic interrupt sources are disabled so they won't generate interrupt but their status will be printed when handler is called due to DMA/PIO interrupt. Known bits 10 INTR_HC_INTERNAL_ERR and 11 INTR_HC_SEQ_CANCEL will print their message and unknowns just "unexpected INTR_STATUS" with hex of unhandled status bits.
Bits 12:14 can be defined since v1.2 describes them. I'm open for ideas does it make more sense to allow signal updates only from known sources or keep all bits enabled so that in future IP versions "unexpected INTR_STATUS" can be seen from user reports if something odd happens and driver is not yet handling that.
Another change is should known generic interrupt sources be enabled so handler will be called immediately when that condition occurs.
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c
Frank Li
reviewerQuoted 67 lines · Jarkko Nikula
Hi Frank
Sorry the delay, somehow I missed your comments to this patch :-|
Quoted 10 lines · Frank Li
Quoted 6 lines · Jarkko Nikula
Since MIPI I3C HCI specification version v0.8
INTR_STATUSbits 9:0 are reserved. Version v0.5 has bits 9 and 5:0 in use but not handled by the current driver code and not needed in DMA transfers.PIO transfers with v0.5 would require changes to both
core.c:i3c_hci_irq_handler()andpio.c:hci_pio_irq_handler()though.If reasonable, why not change
core.candpio.c?I had two reasons for that. The v0.5 compatible IP I use in testing doesn't support PIO transfers and thus didn't want to add code that is not tested.
Then I believe perhaps nobody will release HW with this old IP and thus it would be dead code anyway.
Quoted 11 lines
Quoted 6 lines
For these reasons don't enable signal updates from
INTR_STATUSbits 9:0.This change is a no-op for specification versions v0.8 and beyond but gets rid of "unexpected
INTR_STATUS" errors if somebody (read me) wants to run code on old v0.5 IP version.I think, simple said
"Get rid of "unexpectedINTR_STATUS" errors at old v0.5 IP version and no-op for version above v0.8."Makes sense, will change.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Jarkko Nikula <[email protected]>--- drivers/i3c/master/mipi-i3c-hci/core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/i3c/master/mipi-i3c-hci/core.c +0
-0@@ -699,9 +699,10 @@ static int i3c_hci_init(struct i3c_hci *hci)if (ret)return -ENXIO ;Quoted 10 lines
drivers/i3c/master/mipi-i3c-hci/core.c static int i3c_hci_init(struct i3c_hci *hci) · line 705
Quoted 6 lines
drivers/i3c/master/mipi-i3c-hci/core.c +3
-2-/* Disable all interrupts and allow all signal updates */ +/* Disable all interrupts */ reg_write (INTR_SIGNAL_ENABLE ,0x0 ); -reg_write (INTR_STATUS_ENABLE ,0xffffffff ); +/* Allow signal updates relevant to IP versions 0.8 and beyond */ +reg_write (INTR_STATUS_ENABLE ,GENMASK (31 ,10 ));Generally, just enable needed IRQ in driver. Define some BITS for difference type IRQs.
I was thinking too these need changes too but decided those are better to do in another patch(es).
Currently all of these generic interrupt sources are disabled so they won't generate interrupt but their status will be printed when handler is called due to DMA/PIO interrupt. Known bits 10
INTR_HC_INTERNAL_ERRand 11INTR_HC_SEQ_CANCELwill print their message and unknowns just "unexpectedINTR_STATUS" with hex of unhandled status bits.
Quoted 5 lines
Bits 12:14 can be defined since v1.2 describes them. I'm open for ideas does it make more sense to allow signal updates only from known sources or keep all bits enabled so that in future IP versions "unexpected
INTR_STATUS" can be seen from user reports if something odd happens and driver is not yet handling that.
I think we can defer it until someone really complain it. I am fine for your current change.
Frank
Quoted 8 lines
Another change is should known generic interrupt sources be enabled so handler will be called immediately when that condition occurs.
--
linux-i3c mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-i3c
Signature · 3 lines
linux-i3c mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-i3c