Skip to content

Rework IBI Handling - #135

Merged
glaserf merged 10 commits into
chipsalliance:v1p5from
glaserf:ibi-rework
Feb 20, 2026
Merged

glaserf merged 10 commits into
chipsalliance:v1p5from
glaserf:ibi-rework

Conversation

@glaserf

@glaserf glaserf commented Feb 12, 2026 •

Copy link
Copy Markdown
Collaborator

This PR changes or introduces the following:

  • Refactor descriptor_ibi and add autonomous flushing capability
  • Merge the IBI module and FSM into the main Target FSM
  • Properly handle IBI retry counter
  • Add capability to emit an IBI into the arbitrable address header and report arbitration failures to FW

@mkj121 mkj121 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query about the start of a transaction

Comment thread src/ctrl/i3c_target_fsm.sv Resolved

@mkj121 mkj121 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much easier to understand having the IBI incorporated into the main FSM

Comment thread src/ctrl/i3c_target_fsm.sv Outdated
// to receive rest of address
if (arbitration_lost_i) begin
ibi_status_we_o = 1'b1;
ibi_status_d = IbiFailureNack; // TODO extend the encoding

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does the encoding needs extending?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to FUTUREFIX or we can update the RDL "LAST_IBI_STATUS" to [16:14]

Comment thread src/ctrl/i3c_target_fsm.sv Resolved
@glaserf
glaserf force-pushed the ibi-rework branch 5 times, most recently from 756a36d to f6db822 Compare February 13, 2026 16:41
Comment thread src/ctrl/bus_tx_flow.sv

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a suggested fix for the above issue https://github.com/clayton8/i3c-core/tree/ibi-rework - commit clayton8@ff236ed

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we support more than 1 IBI then my fix won't work. We need another way to report number outstanding interrupts...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@clayton8 clayton8 Feb 15, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get a length of 0, we should consider reporting an error to FW and going back to Idle.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the length is 0 then we should reject the request and signal the error

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread src/ctrl/i3c_target_fsm.sv Outdated
// 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

@clayton8 clayton8 Feb 15, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this TODO should actually be a "FUTUREFIX" or extend LAST_IBI_STATUS to 16:14?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now addressed with extended encoding.

state_d = state_q;
case (state_q)
Idle: begin
if (ibi_queue_rvalid_i) begin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. FW loads IBI with an interrupt, say 10 bytes.
  2. First DWORD in QUEUE popped off and length is showing 10 bytes
  3. 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.
  4. 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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 valid toward 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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do the following:

  1. Change this to FUTUREFIX
  2. Should we add an assertion to enforce this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@glaserf
glaserf marked this pull request as ready for review February 16, 2026 15:57
Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
@glaserf
glaserf force-pushed the ibi-rework branch 2 times, most recently from 310b494 to ae401d7 Compare February 16, 2026 16:37

@glaserf glaserf left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/ctrl/bus_tx_flow.sv

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 valid toward 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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Comment thread src/ctrl/descriptor_ibi.sv Outdated
WriteMdb: begin
ibi_byte_o = data_mdb;
ibi_byte_valid_o = 1'b1;
ibi_byte_last_o = (data_len == 8'hFF); // No payload data

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Comment thread src/ctrl/i3c_target_fsm.sv Resolved

@mkj121 mkj121 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yet more comments

Comment thread src/ctrl/i3c_target_fsm.sv Resolved
state_d = state_q;
case (state_q)
Idle: begin
if (ibi_queue_rvalid_i) begin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the length is 0 then we should reject the request and signal the error

state_d = WriteMdb;
end

WriteMdb: begin

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Why do we clear the IBI FIFO when we reach our retry max.
  2. 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>
@glaserf
glaserf force-pushed the ibi-rework branch 5 times, most recently from ad8ea23 to d919b3b Compare February 19, 2026 20:08
Signed-off-by: Florian Glaser <glaserf@lowrisc.org>
glaserf and others added 7 commits February 20, 2026 14:02
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>
@glaserf
glaserf merged commit a788c3c into chipsalliance:v1p5 Feb 20, 2026
46 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants