]> git.dujemihanovic.xyz Git - linux.git/commitdiff
i3c: mipi-i3c-hci: Round IBI data chunk size to HW supported value
authorJarkko Nikula <jarkko.nikula@linux.intel.com>
Fri, 28 Jun 2024 13:15:59 +0000 (16:15 +0300)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Fri, 26 Jul 2024 12:21:29 +0000 (14:21 +0200)
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 <jarkko.nikula@linux.intel.com>
Link: https://lore.kernel.org/r/20240628131559.502822-4-jarkko.nikula@linux.intel.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/i3c/master/mipi-i3c-hci/dma.c

index 9bdfe40bc1e1e646aba2c48dd1c1309616b8e4b5..a918e96b21fddc584b39b06f4a60d6ab63f59f61 100644 (file)
@@ -279,6 +279,13 @@ static int hci_dma_init(struct i3c_hci *hci)
 
                rh->ibi_chunk_sz = dma_get_cache_alignment();
                rh->ibi_chunk_sz *= IBI_CHUNK_CACHELINES;
+               /*
+                * Round IBI data chunk size to number of bytes supported by
+                * the HW. Chunk size can be 2^n number of DWORDs which is the
+                * same as 2^(n+2) bytes, where n is 0..6.
+                */
+               rh->ibi_chunk_sz = umax(4, rh->ibi_chunk_sz);
+               rh->ibi_chunk_sz = roundup_pow_of_two(rh->ibi_chunk_sz);
                if (rh->ibi_chunk_sz > 256) {
                        ret = -EINVAL;
                        goto err_out;