From: Jarkko Nikula <jarkko.nikula@linux.intel.com>
To: linux-i3c@lists.infradead.org
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>
Subject: [PATCH 4/4] i3c: mipi-i3c-hci: Round IBI data chunk size to HW supported value
Date: Fri, 28 Jun 2024 16:15:59 +0300 [thread overview]
Message-ID: <20240628131559.502822-4-jarkko.nikula@linux.intel.com> (raw)
In-Reply-To: <20240628131559.502822-1-jarkko.nikula@linux.intel.com>
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>
---
drivers/i3c/master/mipi-i3c-hci/dma.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c
index 9bdfe40bc1e1..a918e96b21fd 100644
--- a/drivers/i3c/master/mipi-i3c-hci/dma.c
+++ b/drivers/i3c/master/mipi-i3c-hci/dma.c
@@ -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;
--
2.43.0
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
next prev parent reply other threads:[~2024-06-28 13:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-28 13:15 [PATCH 1/4] i3c: mipi-i3c-hci: Switch to lower_32_bits()/upper_32_bits() helpers Jarkko Nikula
2024-06-28 13:15 ` [PATCH 2/4] i3c: mipi-i3c-hci: Set IBI Status and Data Ring base addresses Jarkko Nikula
2024-06-28 13:15 ` [PATCH 3/4] i3c: mipi-i3c-hci: Error out instead on BUG_ON() in IBI DMA setup Jarkko Nikula
2024-06-28 13:15 ` Jarkko Nikula [this message]
2024-06-28 14:42 ` [PATCH 1/4] i3c: mipi-i3c-hci: Switch to lower_32_bits()/upper_32_bits() helpers Alexandre Belloni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240628131559.502822-4-jarkko.nikula@linux.intel.com \
--to=jarkko.nikula@linux.intel.com \
--cc=alexandre.belloni@bootlin.com \
--cc=linux-i3c@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox