Repository navigation
Rework IBI Handling - #135
Conversation
mkj121
left a comment
There was a problem hiding this comment.
Query about the start of a transaction
mkj121
left a comment
There was a problem hiding this comment.
Much easier to understand having the IBI incorporated into the main FSM
| // to receive rest of address | ||
| if (arbitration_lost_i) begin | ||
| ibi_status_we_o = 1'b1; | ||
| ibi_status_d = IbiFailureNack; // TODO extend the encoding |
There was a problem hiding this comment.
Why does the encoding needs extending?
There was a problem hiding this comment.
Because here we are currently assigning IbiFailureNack to the IBI status while in reality we lost arbitration and weren't NACKed. If we want to distinguish this, we need to extend the encoding, which means one more bit for the respective CSR field in RDL.
There was a problem hiding this comment.
Can we change this to FUTUREFIX or we can update the RDL "LAST_IBI_STATUS" to [16:14]
756a36d to
f6db822
Compare
There was a problem hiding this comment.
Comment not actually related to this file... but https://github.com/glaserf/i3c-core/blob/ibi-rework/src/hci/tti.sv#L277 the PENDING_INTERRUPT feeds into GETSTATUS https://github.com/glaserf/i3c-core/blob/ibi-rework/src/ctrl/configuration.sv#L179.
This should probably be updated by HW to reflect if we have an outstanding IBI or not.
There was a problem hiding this comment.
Here is a suggested fix for the above issue https://github.com/clayton8/i3c-core/tree/ibi-rework - commit clayton8@ff236ed
There was a problem hiding this comment.
If we support more than 1 IBI then my fix won't work. We need another way to report number outstanding interrupts...
There was a problem hiding this comment.
Do we agree that the current form of pending IBI reporting is sufficient, even if FW chooses to go against the recommendation of only ever en-queuing one IBI at a time?
| end | ||
| end | ||
|
|
||
| DescLatch: begin |
There was a problem hiding this comment.
If we get a length of 0, we should consider reporting an error to FW and going back to Idle.
There was a problem hiding this comment.
True, there is -1 subtracted from the length in the descriptor; this can go fatally wrong if written with 0 (underflow). Alternatively, instead of encoding "no data after the MDB" with 0xFF, we could encode this with 0? Plumbing an error back to FW could get quite tedious, and currently we have two values for the length that aren't usable (0 and 0xFF).
There was a problem hiding this comment.
If the length is 0 then we should reject the request and signal the error
There was a problem hiding this comment.
So you think we should not change the encoding, leaving 0xFF for length == 0 (meaning no further data after the MDB)?
I just want to make sure that we all agree length == 0 not being an illegal transaction at all, since length excludes the MDB. Currently, length == 0 is just a bit weirdly encoded (see below on line 100).
| // Someone else decided to start transmitting an IBI at almost the exact same time and | ||
| // won arbitration - bad luck for us | ||
| ibi_status_we_o = 1'b1; | ||
| ibi_status_d = IbiFailureNack; // TODO extend the encoding |
There was a problem hiding this comment.
I think this TODO should actually be a "FUTUREFIX" or extend LAST_IBI_STATUS to 16:14?
There was a problem hiding this comment.
This is now addressed with extended encoding.
| state_d = state_q; | ||
| case (state_q) | ||
| Idle: begin | ||
| if (ibi_queue_rvalid_i) begin |
There was a problem hiding this comment.
We have a very similar "issue" in the descriptor_tx that we should think about. We have a IBI_QUEUE_RST that resets ONLY the QUEUE and not this logic. So we could get the following scenario:
- FW loads IBI with an interrupt, say 10 bytes.
- First DWORD in QUEUE popped off and length is showing 10 bytes
- Before IBI is sent FW resets the IBI QUEUE
At this point we have no data in the FIFO but we are locked and loaded to send this IBI out. - IBI finally wins arbitration and we send the IBI.
In my testing we will send an IBI of 10 bytes but the data after the MDB will be 0.
This is more of a debug flow IMO and thinking about this a little I think this is OK. I don't want to overcomplicate our design to have the IBI_QUEUE_RST have to reset the FIFO AND this logic. Honestly it is probably safer to just have this behavior.
LMK your thoughts.
There was a problem hiding this comment.
The descriptor_tx issue is actually a bit different and a bit worse IMO. The real issue in the TX path is the TX_DATA is immediately popped off and there is no way to clear this data. The TX_DATA_QUEUE_RST will clear everything in the TX FIFO but no way to clear the data once it is out of the TX DATA FIFO.
There was a problem hiding this comment.
Isn't the current behaviour, in both cases, a problem for Firmware. Data gets 'stuck' because the Controller or a bus condition terminated a transfer early. Then the next one gets mixed up.
Really under such conditions the data should actually be flushed out. In the IBI version the Controller and Target have to have a private agreement on how to get the remaining data (see Section 5.1.6.2, lines 1987-1988
There was a problem hiding this comment.
Some thoughts about this:
- Both IBI and the regular TX (private reads) path are now built in a way where there is no "immediate popping" anymore; data is taken from the respective FIFO/Queue and copied into the shift register in bux_tx_flow at the beginning of a byte transaction (but maybe this was referred to as "popping"?). Once a byte is in the shift reg, we cannot abort transmission anymore, but again, this only affects a single byte.
- For IBI, we could propagate the abort to the FSM, stop emitting data towards the target FSM and initiate the flush. However, we'd have to carefully check if there would be cases where we cannot undo the
validtoward the target FSM while the current byte has not been consumed by the shift register in tx_flow yet. In your example with 10 bytes, this would make sure that at most a single byte gets actually sent over the bus, and that that very byte contains valid data.
| bus_tx_req_o.req_valid = 1'b1; | ||
| bus_tx_req_o.req_type = TReadEnd; | ||
|
|
||
| if (bus_tx_rsp_i.done) begin |
There was a problem hiding this comment.
Reset the retry counter in HW on an IBI success?
| bus_tx_req_o.req_type = TReadCont; | ||
| bus_tx_req_o.data = ibi_byte_i; | ||
|
|
||
| if (bus_tx_rsp_i.abort) begin |
There was a problem hiding this comment.
Reset the retry counter in HW on IBI abort?
| written to the queue. Finally, the module outputs MDB and the data as 8-bit | ||
| words. | ||
|
|
||
| TODO: The TTI IBI queue must be EMPTY each time a descriptor is written. |
There was a problem hiding this comment.
Can we do the following:
- Change this to FUTUREFIX
- Should we add an assertion to enforce this?
There was a problem hiding this comment.
I am not sure this is really still needed. The FSM below stops reading from the queue once it consumed enough data for the IBI at hand.
There was a problem hiding this comment.
Isn't an issue that if there are multiple IBI requests in the FIFO and one of them fails then the firmware has no ways of knowing which one failed. Unless you add a field to the IBI descriptor which gives it a unique number which could be reported back.
Even that wouldn't work if there were multiple failures - which would then need an 'overflow' bit
There was a problem hiding this comment.
So in principle this is not an issue, since IBIs are always served in-order. So if FW enqueues multiple and keeps track of them in some SW data structure, all it needs to do is observe the IBI status as reported by HW through the interrupt and CSR and every time pop one item off its SW data structure.
However, there could be a case where multiple IBIs are processed rapidly by HW (e.g., multiple failures due to reached retry count), and FW would be too slow to process the IRQs in time, which would lead to missed status responses.
There was a problem hiding this comment.
Perhaps the simplest thing would be to tell Firmware only to issue one at a time. Then we don't have to add lots of logic
Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
310b494 to
ae401d7
Compare
glaserf
left a comment
There was a problem hiding this comment.
Thanks a lot for your feedback; please have another look. I extended the IBI status encoding, including some re-arrangement of bitfields in the TTI STATUS reg to ensure the fields are byte-aligned.
I still have to implement the retry-count reset func, per SW and upon IBI success. Stay tuned.
There was a problem hiding this comment.
Do we agree that the current form of pending IBI reporting is sufficient, even if FW chooses to go against the recommendation of only ever en-queuing one IBI at a time?
| written to the queue. Finally, the module outputs MDB and the data as 8-bit | ||
| words. | ||
|
|
||
| TODO: The TTI IBI queue must be EMPTY each time a descriptor is written. |
There was a problem hiding this comment.
I am not sure this is really still needed. The FSM below stops reading from the queue once it consumed enough data for the IBI at hand.
| state_d = state_q; | ||
| case (state_q) | ||
| Idle: begin | ||
| if (ibi_queue_rvalid_i) begin |
There was a problem hiding this comment.
Some thoughts about this:
- Both IBI and the regular TX (private reads) path are now built in a way where there is no "immediate popping" anymore; data is taken from the respective FIFO/Queue and copied into the shift register in bux_tx_flow at the beginning of a byte transaction (but maybe this was referred to as "popping"?). Once a byte is in the shift reg, we cannot abort transmission anymore, but again, this only affects a single byte.
- For IBI, we could propagate the abort to the FSM, stop emitting data towards the target FSM and initiate the flush. However, we'd have to carefully check if there would be cases where we cannot undo the
validtoward the target FSM while the current byte has not been consumed by the shift register in tx_flow yet. In your example with 10 bytes, this would make sure that at most a single byte gets actually sent over the bus, and that that very byte contains valid data.
| end | ||
| end | ||
|
|
||
| DescLatch: begin |
There was a problem hiding this comment.
True, there is -1 subtracted from the length in the descriptor; this can go fatally wrong if written with 0 (underflow). Alternatively, instead of encoding "no data after the MDB" with 0xFF, we could encode this with 0? Plumbing an error back to FW could get quite tedious, and currently we have two values for the length that aren't usable (0 and 0xFF).
| WriteMdb: begin | ||
| ibi_byte_o = data_mdb; | ||
| ibi_byte_valid_o = 1'b1; | ||
| ibi_byte_last_o = (data_len == 8'hFF); // No payload data |
There was a problem hiding this comment.
@clayton8 0xFF check for no-payload-beyond-MDB is here. We could just change it to 0, and enable up to 255 payload bytes after MDB.
| state_d = state_q; | ||
| case (state_q) | ||
| Idle: begin | ||
| if (ibi_queue_rvalid_i) begin |
There was a problem hiding this comment.
Isn't the current behaviour, in both cases, a problem for Firmware. Data gets 'stuck' because the Controller or a bus condition terminated a transfer early. Then the next one gets mixed up.
Really under such conditions the data should actually be flushed out. In the IBI version the Controller and Target have to have a private agreement on how to get the remaining data (see Section 5.1.6.2, lines 1987-1988
| written to the queue. Finally, the module outputs MDB and the data as 8-bit | ||
| words. | ||
|
|
||
| TODO: The TTI IBI queue must be EMPTY each time a descriptor is written. |
There was a problem hiding this comment.
Isn't an issue that if there are multiple IBI requests in the FIFO and one of them fails then the firmware has no ways of knowing which one failed. Unless you add a field to the IBI descriptor which gives it a unique number which could be reported back.
Even that wouldn't work if there were multiple failures - which would then need an 'overflow' bit
| end | ||
| end | ||
|
|
||
| DescLatch: begin |
There was a problem hiding this comment.
If the length is 0 then we should reject the request and signal the error
| state_d = WriteMdb; | ||
| end | ||
|
|
||
| WriteMdb: begin |
There was a problem hiding this comment.
Why aren't we handling "flush" in this state. If you look at the i3c_target_fsm.sv we can get a NACK from the controller and that causes our retry counter to increment. And after we reach our retry max, we set "flush".
Two questions:
- Why do we clear the IBI FIFO when we reach our retry max.
- Would it make more sense to notify FW about this and have FW either a. clear the IBI or b. It can increase the retry counter?
Enable independent and as-fast-as-possible flushing of IBI queue data to allow independet operation of the I3C Target FSM. Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
ad8ea23 to
d919b3b
Compare
Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
Add a field to INTERRUPT_STATUS to report pending IBIs and wire this information into the vendor-specific field of the GETSTATUS_FMT1 CCC.
Enables the reporting of lost address arbitration. Also clean up some of the plumbing and port maps between TTI and Target FSM. Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
This commit introdcues resetting of the IBI retry counter upon - Each successfully carried out IBI - Manual reset by firmware Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
Expose MWL and MRL (including IBIL) in the register file as read-only registers. Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
- Introduce more sophisticated inhibit/holdoff handling to avoid repeated status writes after IbiFailureRetry - Only to to arbitrable address header on already pending IBIs to avoid mid-address-header IBI address driving onto bus Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
Avoid firing an assertion when the monitored signals switch in opposite direction in the same simulator/delta cycle. Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
This PR changes or introduces the following:
descriptor_ibiand add autonomous flushing capability