Skip to content

Commit 4642f7e

Browse files
jhnikulaalexandrebelloni
authored andcommitted
i3c: mipi-i3c-hci: Round IBI data chunk size to HW supported value
The dma.c: hci_dma_init() sets the CHUNK_SIZE field in the IBI_SETUP register incorrectly if the calculated ibi_chunk_sz is not exactly 2^(n+2) bytes, where n is 0..6. Fix this by rounding the chunk size up to nearest 2^(n+2) bytes. Signed-off-by: Jarkko Nikula <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 8a2be2f commit 4642f7e

File tree

1 file changed

+7
-0
lines changed
  • drivers/i3c/master/mipi-i3c-hci

1 file changed

+7
-0
lines changed

drivers/i3c/master/mipi-i3c-hci/dma.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ static int hci_dma_init(struct i3c_hci *hci)
279279

280280
rh->ibi_chunk_sz = dma_get_cache_alignment();
281281
rh->ibi_chunk_sz *= IBI_CHUNK_CACHELINES;
282+
/*
283+
* Round IBI data chunk size to number of bytes supported by
284+
* the HW. Chunk size can be 2^n number of DWORDs which is the
285+
* same as 2^(n+2) bytes, where n is 0..6.
286+
*/
287+
rh->ibi_chunk_sz = umax(4, rh->ibi_chunk_sz);
288+
rh->ibi_chunk_sz = roundup_pow_of_two(rh->ibi_chunk_sz);
282289
if (rh->ibi_chunk_sz > 256) {
283290
ret = -EINVAL;
284291
goto err_out;

0 commit comments

Comments
 (0)