From: Arun Menon <[email protected]>

The global increase of TPM_BUFSIZE to 8KB is necessary to support
Post-Quantum Cryptography (PQC) payloads. However, applying this increase
to the tpm_tis_i2c driver is unnecessary and wasteful due to physical
transport limitations as pointed out in [1]

This commit introduces a local buffer limit that is used in the i2c
driver.

[1] 
https://sashiko.dev/#/patchset/20260324071803.324774-1-armenon%40redhat.com?patch=8319

Signed-off-by: Arun Menon <[email protected]>
Reviewed-by: Jarkko Sakkinen <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jarkko Sakkinen <[email protected]>
---
 drivers/char/tpm/tpm_tis_i2c.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/char/tpm/tpm_tis_i2c.c b/drivers/char/tpm/tpm_tis_i2c.c
index 8bcbc84815fd..36f56ee75cd4 100644
--- a/drivers/char/tpm/tpm_tis_i2c.c
+++ b/drivers/char/tpm/tpm_tis_i2c.c
@@ -61,6 +61,7 @@ struct tpm_tis_i2c_reset_timings {
        unsigned int assert_us;
        unsigned int deassert_us;
 };
+#define TPM_I2C_BUFSIZE 4096
 
 struct tpm_tis_i2c_phy {
        struct tpm_tis_data priv;
@@ -240,7 +241,7 @@ static int tpm_tis_i2c_write_bytes(struct tpm_tis_data 
*data, u32 addr, u16 len,
        int ret;
        u16 wrote = 0;
 
-       if (len > TPM_BUFSIZE - 1)
+       if (len > TPM_I2C_BUFSIZE - 1)
                return -EIO;
 
        phy->io_buf[0] = reg;
@@ -349,7 +350,7 @@ static int tpm_tis_i2c_probe(struct i2c_client *dev)
        if (!phy)
                return -ENOMEM;
 
-       phy->io_buf = devm_kzalloc(&dev->dev, TPM_BUFSIZE, GFP_KERNEL);
+       phy->io_buf = devm_kzalloc(&dev->dev, TPM_I2C_BUFSIZE, GFP_KERNEL);
        if (!phy->io_buf)
                return -ENOMEM;
 
-- 
2.56.0


Reply via email to