[PATCH v12 0/4] Add Loongson Security Engine chip driver

Qunqin Zhao posted 4 patches 3 months ago
MAINTAINERS                            |   9 +
drivers/char/tpm/Kconfig               |   9 +
drivers/char/tpm/Makefile              |   1 +
drivers/char/tpm/tpm_loongson.c        |  84 ++++++++
drivers/crypto/Kconfig                 |   1 +
drivers/crypto/Makefile                |   1 +
drivers/crypto/loongson/Kconfig        |   5 +
drivers/crypto/loongson/Makefile       |   1 +
drivers/crypto/loongson/loongson-rng.c | 209 ++++++++++++++++++++
drivers/mfd/Kconfig                    |  11 ++
drivers/mfd/Makefile                   |   2 +
drivers/mfd/loongson-se.c              | 253 +++++++++++++++++++++++++
include/linux/mfd/loongson-se.h        |  53 ++++++
13 files changed, 639 insertions(+)
create mode 100644 drivers/char/tpm/tpm_loongson.c
create mode 100644 drivers/crypto/loongson/Kconfig
create mode 100644 drivers/crypto/loongson/Makefile
create mode 100644 drivers/crypto/loongson/loongson-rng.c
create mode 100644 drivers/mfd/loongson-se.c
create mode 100644 include/linux/mfd/loongson-se.h
[PATCH v12 0/4] Add Loongson Security Engine chip driver
Posted by Qunqin Zhao 3 months ago
The Loongson Security Engine chip supports RNG, SM2, SM3 and SM4
accelerator engines. Each engine have its own DMA buffer provided
by the controller. The kernel cannot directly send commands to the
engine and must first send them to the controller, which will
forward them to the corresponding engine. Based on these engines,
TPM2 have been implemented in the chip, then let's treat TPM2 itself
as an engine.

v12: "loongson-tpm" -> "tmp_loongson"

v11: Put all updates to the MAINTAINERS in one patch
     crypto: statically initialize rng_devices.lock, use this lock in
             loongson_rng_probe().

v10: mfd: Cleanned up coding style.
     crypto: Unlimited tfm
     tpm: Added error check

v9: Moved the base driver back to drivers/mfd. Cleanned up coding style.

v8: Like Lee said, the base driver goes beyond MFD scope. Since these
    are all encryption related drivers and SM2, SM3, and SM4 drivers
    will be added to the crypto subsystem in the future, the base driver
    need to be changed when adding these drivers. Therefore, it may be
    more appropriate to place the base driver within the crypto
    subsystem.

    Removed complete callback in all driver. Removed the concepts of
    "channel", "msg" and "request" as they may be confusing. Used the
    concepts of "egnine" and "command" may be better.

v7: Addressed Huacai's comments.

v6: mfd :MFD_LS6000SE -> MFD_LOONGSON_SE,  ls6000se.c -> loongson-se.c

    crypto :CRYPTO_DEV_LS6000SE_RNG -> CRYPTO_DEV_LOONGSON_RNG,
    ls6000se-rng.c ->loongson-rng.c

    tpm: TCG_LSSE -> TCG_LOONGSON, tpm_lsse.c ->tpm_loongson.c

v5: mfd: Registered "ls6000se-rng" device in mfd driver
    tpm: Prefix all with tpm_loongson instead of tpm_lsse.
         Replace all "ls6000se" with "loongson"

v4: tpm: Removed MODULE_AUTHOR fields.
         Prefix all with tpm_lsse instead of tpm.

v3: Put the updates to the MAINTAINERS in a separate patch.
    tpm: Added reminder about Loongson security engine to git log.

v2: Removed misc driver. Added tpm driver.

Qunqin Zhao (4):
  mfd: Add support for Loongson Security Engine chip controller
  crypto: loongson - add Loongson RNG driver support
  tpm: Add a driver for Loongson TPM device
  MAINTAINERS: Add entry for Loongson Security Engine drivers

 MAINTAINERS                            |   9 +
 drivers/char/tpm/Kconfig               |   9 +
 drivers/char/tpm/Makefile              |   1 +
 drivers/char/tpm/tpm_loongson.c        |  84 ++++++++
 drivers/crypto/Kconfig                 |   1 +
 drivers/crypto/Makefile                |   1 +
 drivers/crypto/loongson/Kconfig        |   5 +
 drivers/crypto/loongson/Makefile       |   1 +
 drivers/crypto/loongson/loongson-rng.c | 209 ++++++++++++++++++++
 drivers/mfd/Kconfig                    |  11 ++
 drivers/mfd/Makefile                   |   2 +
 drivers/mfd/loongson-se.c              | 253 +++++++++++++++++++++++++
 include/linux/mfd/loongson-se.h        |  53 ++++++
 13 files changed, 639 insertions(+)
 create mode 100644 drivers/char/tpm/tpm_loongson.c
 create mode 100644 drivers/crypto/loongson/Kconfig
 create mode 100644 drivers/crypto/loongson/Makefile
 create mode 100644 drivers/crypto/loongson/loongson-rng.c
 create mode 100644 drivers/mfd/loongson-se.c
 create mode 100644 include/linux/mfd/loongson-se.h


base-commit: a79a588fc1761dc12a3064fc2f648ae66cea3c5a
-- 
2.45.2
Re: [PATCH v12 0/4] Add Loongson Security Engine chip driver
Posted by Lee Jones 1 month ago
On Sat, 05 Jul 2025 15:20:41 +0800, Qunqin Zhao wrote:
> The Loongson Security Engine chip supports RNG, SM2, SM3 and SM4
> accelerator engines. Each engine have its own DMA buffer provided
> by the controller. The kernel cannot directly send commands to the
> engine and must first send them to the controller, which will
> forward them to the corresponding engine. Based on these engines,
> TPM2 have been implemented in the chip, then let's treat TPM2 itself
> as an engine.
> 
> [...]

Applied, thanks!

[1/4] mfd: Add support for Loongson Security Engine chip controller
      commit: e551fa3159e3050c26ff010c3b595b45d7eb071a
[2/4] crypto: loongson - add Loongson RNG driver support
      commit: 766b2d724c8df071031412eea902b566a0049c31
[3/4] tpm: Add a driver for Loongson TPM device
      commit: 5c83b07df9c5a6e063328c5b885de79f8e8f0263
[4/4] MAINTAINERS: Add entry for Loongson Security Engine drivers
      commit: 74fddd5fbab879a7d039d9fb49af923927a64811

--
Lee Jones [李琼斯]

Re: [PATCH v12 0/4] Add Loongson Security Engine chip driver
Posted by Lee Jones 1 month ago
On Tue, 02 Sep 2025, Lee Jones wrote:

> On Sat, 05 Jul 2025 15:20:41 +0800, Qunqin Zhao wrote:
> > The Loongson Security Engine chip supports RNG, SM2, SM3 and SM4
> > accelerator engines. Each engine have its own DMA buffer provided
> > by the controller. The kernel cannot directly send commands to the
> > engine and must first send them to the controller, which will
> > forward them to the corresponding engine. Based on these engines,
> > TPM2 have been implemented in the chip, then let's treat TPM2 itself
> > as an engine.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/4] mfd: Add support for Loongson Security Engine chip controller
>       commit: e551fa3159e3050c26ff010c3b595b45d7eb071a
> [2/4] crypto: loongson - add Loongson RNG driver support
>       commit: 766b2d724c8df071031412eea902b566a0049c31
> [3/4] tpm: Add a driver for Loongson TPM device
>       commit: 5c83b07df9c5a6e063328c5b885de79f8e8f0263
> [4/4] MAINTAINERS: Add entry for Loongson Security Engine drivers
>       commit: 74fddd5fbab879a7d039d9fb49af923927a64811

Submitted for testing.  I'll send out a PR once successful.

Note to self: ib-mfd-char-crypto-6.18

-- 
Lee Jones [李琼斯]
[GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Lee Jones 1 month ago
Enjoy!

The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:

  Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-char-crypto-v6.18

for you to fetch changes up to 74fddd5fbab879a7d039d9fb49af923927a64811:

  MAINTAINERS: Add entry for Loongson Security Engine drivers (2025-09-02 12:29:57 +0100)

----------------------------------------------------------------
Immutable branch between MFD, Char and Crypto due for the v6.18 merge window

----------------------------------------------------------------
Qunqin Zhao (4):
      mfd: Add support for Loongson Security Engine chip controller
      crypto: loongson - add Loongson RNG driver support
      tpm: Add a driver for Loongson TPM device
      MAINTAINERS: Add entry for Loongson Security Engine drivers

 MAINTAINERS                            |   9 ++
 drivers/char/tpm/Kconfig               |   9 ++
 drivers/char/tpm/Makefile              |   1 +
 drivers/char/tpm/tpm_loongson.c        |  84 +++++++++++
 drivers/crypto/Kconfig                 |   1 +
 drivers/crypto/Makefile                |   1 +
 drivers/crypto/loongson/Kconfig        |   5 +
 drivers/crypto/loongson/Makefile       |   1 +
 drivers/crypto/loongson/loongson-rng.c | 209 +++++++++++++++++++++++++++
 drivers/mfd/Kconfig                    |  11 ++
 drivers/mfd/Makefile                   |   2 +
 drivers/mfd/loongson-se.c              | 253 +++++++++++++++++++++++++++++++++
 include/linux/mfd/loongson-se.h        |  53 +++++++
 13 files changed, 639 insertions(+)
 create mode 100644 drivers/char/tpm/tpm_loongson.c
 create mode 100644 drivers/crypto/loongson/Kconfig
 create mode 100644 drivers/crypto/loongson/Makefile
 create mode 100644 drivers/crypto/loongson/loongson-rng.c
 create mode 100644 drivers/mfd/loongson-se.c
 create mode 100644 include/linux/mfd/loongson-se.h

-- 
Lee Jones [李琼斯]
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Nathan Chancellor 3 weeks, 3 days ago
Hi Lee,

On Tue, Sep 02, 2025 at 01:42:05PM +0100, Lee Jones wrote:
> Enjoy!
> 
> The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:
> 
>   Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-char-crypto-v6.18
> 
> for you to fetch changes up to 74fddd5fbab879a7d039d9fb49af923927a64811:
> 
>   MAINTAINERS: Add entry for Loongson Security Engine drivers (2025-09-02 12:29:57 +0100)
> 
> ----------------------------------------------------------------
> Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
> 
> ----------------------------------------------------------------
> Qunqin Zhao (4):
...
>       tpm: Add a driver for Loongson TPM device

This one needs a fix up due to commit 07d8004d6fb9 ("tpm: add bufsiz
parameter in the .send callback") in 6.17-rc1, as I am seeing the
following error in next-20250912.

  drivers/char/tpm/tpm_loongson.c:48:17: error: initialization of 'int (*)(struct tpm_chip *, u8 *, size_t,  size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int,  long unsigned int)'} from incompatible pointer type 'int (*)(struct tpm_chip *, u8 *, size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int)'} [-Wincompatible-pointer-types]
     48 |         .send = tpm_loongson_send,
        |                 ^~~~~~~~~~~~~~~~~
  drivers/char/tpm/tpm_loongson.c:48:17: note: (near initialization for 'tpm_loongson_ops.send')
  drivers/char/tpm/tpm_loongson.c:31:12: note: 'tpm_loongson_send' declared here
     31 | static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
        |            ^~~~~~~~~~~~~~~~~

Can you squash it or do you want a separate patch?

Cheers,
Nathan

diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
index a4ec23639911..9e50250763d1 100644
--- a/drivers/char/tpm/tpm_loongson.c
+++ b/drivers/char/tpm/tpm_loongson.c
@@ -28,7 +28,7 @@ static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t count)
 	return cmd_ret->data_len;
 }
 
-static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
+static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t count)
 {
 	struct loongson_se_engine *tpm_engine = dev_get_drvdata(&chip->dev);
 	struct tpm_loongson_cmd *cmd = tpm_engine->command;
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Lee Jones 3 weeks ago
On Fri, 12 Sep 2025, Nathan Chancellor wrote:

> Hi Lee,
> 
> On Tue, Sep 02, 2025 at 01:42:05PM +0100, Lee Jones wrote:
> > Enjoy!
> > 
> > The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:
> > 
> >   Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)
> > 
> > are available in the Git repository at:
> > 
> >   git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-char-crypto-v6.18
> > 
> > for you to fetch changes up to 74fddd5fbab879a7d039d9fb49af923927a64811:
> > 
> >   MAINTAINERS: Add entry for Loongson Security Engine drivers (2025-09-02 12:29:57 +0100)
> > 
> > ----------------------------------------------------------------
> > Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
> > 
> > ----------------------------------------------------------------
> > Qunqin Zhao (4):
> ...
> >       tpm: Add a driver for Loongson TPM device
> 
> This one needs a fix up due to commit 07d8004d6fb9 ("tpm: add bufsiz
> parameter in the .send callback") in 6.17-rc1, as I am seeing the
> following error in next-20250912.
> 
>   drivers/char/tpm/tpm_loongson.c:48:17: error: initialization of 'int (*)(struct tpm_chip *, u8 *, size_t,  size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int,  long unsigned int)'} from incompatible pointer type 'int (*)(struct tpm_chip *, u8 *, size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int)'} [-Wincompatible-pointer-types]
>      48 |         .send = tpm_loongson_send,
>         |                 ^~~~~~~~~~~~~~~~~
>   drivers/char/tpm/tpm_loongson.c:48:17: note: (near initialization for 'tpm_loongson_ops.send')
>   drivers/char/tpm/tpm_loongson.c:31:12: note: 'tpm_loongson_send' declared here
>      31 | static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
>         |            ^~~~~~~~~~~~~~~~~
> 
> Can you squash it or do you want a separate patch?
> 
> Cheers,
> Nathan
> 
> diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
> index a4ec23639911..9e50250763d1 100644
> --- a/drivers/char/tpm/tpm_loongson.c
> +++ b/drivers/char/tpm/tpm_loongson.c
> @@ -28,7 +28,7 @@ static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t count)
>  	return cmd_ret->data_len;
>  }
>  
> -static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> +static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t count)
>  {
>  	struct loongson_se_engine *tpm_engine = dev_get_drvdata(&chip->dev);
>  	struct tpm_loongson_cmd *cmd = tpm_engine->command;

This will break my local branch.

Any chance of an immutable pull-request for:

  07d8004d6fb9 ("tpm: add bufsiz parameter in the .send callback")

-- 
Lee Jones [李琼斯]
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Nathan Chancellor 3 weeks ago
On Tue, Sep 16, 2025 at 08:58:35AM +0100, Lee Jones wrote:
> On Fri, 12 Sep 2025, Nathan Chancellor wrote:
> > > The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:
> > > 
> > >   Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)
...
> > > Qunqin Zhao (4):
> > ...
> > >       tpm: Add a driver for Loongson TPM device
> > 
> > This one needs a fix up due to commit 07d8004d6fb9 ("tpm: add bufsiz
> > parameter in the .send callback") in 6.17-rc1, as I am seeing the
> > following error in next-20250912.
> > 
> >   drivers/char/tpm/tpm_loongson.c:48:17: error: initialization of 'int (*)(struct tpm_chip *, u8 *, size_t,  size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int,  long unsigned int)'} from incompatible pointer type 'int (*)(struct tpm_chip *, u8 *, size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int)'} [-Wincompatible-pointer-types]
> >      48 |         .send = tpm_loongson_send,
> >         |                 ^~~~~~~~~~~~~~~~~
> >   drivers/char/tpm/tpm_loongson.c:48:17: note: (near initialization for 'tpm_loongson_ops.send')
> >   drivers/char/tpm/tpm_loongson.c:31:12: note: 'tpm_loongson_send' declared here
> >      31 | static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> >         |            ^~~~~~~~~~~~~~~~~
> > 
> > Can you squash it or do you want a separate patch?
> > 
> > Cheers,
> > Nathan
> > 
> > diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
> > index a4ec23639911..9e50250763d1 100644
> > --- a/drivers/char/tpm/tpm_loongson.c
> > +++ b/drivers/char/tpm/tpm_loongson.c
> > @@ -28,7 +28,7 @@ static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t count)
> >  	return cmd_ret->data_len;
> >  }
> >  
> > -static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> > +static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t count)
> >  {
> >  	struct loongson_se_engine *tpm_engine = dev_get_drvdata(&chip->dev);
> >  	struct tpm_loongson_cmd *cmd = tpm_engine->command;
> 
> This will break my local branch.
> 
> Any chance of an immutable pull-request for:
> 
>   07d8004d6fb9 ("tpm: add bufsiz parameter in the .send callback")

I might be missing something but this commit is in Linux 6.17-rc1, which
this tree is based on according to both 'git log' and the lead in to
your pull request at the top, so your local branch is already broken.
That error message was taken from the tip of your tree and the fix was
tested against it as well.

"tpm: Add a driver for Loongson TPM device" was sent back in early July,
so it was never updated for this conflict.

Cheers,
Nathan
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Lee Jones 2 weeks, 6 days ago
On Tue, 16 Sep 2025, Nathan Chancellor wrote:

> On Tue, Sep 16, 2025 at 08:58:35AM +0100, Lee Jones wrote:
> > On Fri, 12 Sep 2025, Nathan Chancellor wrote:
> > > > The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:
> > > > 
> > > >   Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)
> ...
> > > > Qunqin Zhao (4):
> > > ...
> > > >       tpm: Add a driver for Loongson TPM device
> > > 
> > > This one needs a fix up due to commit 07d8004d6fb9 ("tpm: add bufsiz
> > > parameter in the .send callback") in 6.17-rc1, as I am seeing the
> > > following error in next-20250912.
> > > 
> > >   drivers/char/tpm/tpm_loongson.c:48:17: error: initialization of 'int (*)(struct tpm_chip *, u8 *, size_t,  size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int,  long unsigned int)'} from incompatible pointer type 'int (*)(struct tpm_chip *, u8 *, size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int)'} [-Wincompatible-pointer-types]
> > >      48 |         .send = tpm_loongson_send,
> > >         |                 ^~~~~~~~~~~~~~~~~
> > >   drivers/char/tpm/tpm_loongson.c:48:17: note: (near initialization for 'tpm_loongson_ops.send')
> > >   drivers/char/tpm/tpm_loongson.c:31:12: note: 'tpm_loongson_send' declared here
> > >      31 | static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> > >         |            ^~~~~~~~~~~~~~~~~
> > > 
> > > Can you squash it or do you want a separate patch?
> > > 
> > > Cheers,
> > > Nathan
> > > 
> > > diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
> > > index a4ec23639911..9e50250763d1 100644
> > > --- a/drivers/char/tpm/tpm_loongson.c
> > > +++ b/drivers/char/tpm/tpm_loongson.c
> > > @@ -28,7 +28,7 @@ static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t count)
> > >  	return cmd_ret->data_len;
> > >  }
> > >  
> > > -static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> > > +static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t count)
> > >  {
> > >  	struct loongson_se_engine *tpm_engine = dev_get_drvdata(&chip->dev);
> > >  	struct tpm_loongson_cmd *cmd = tpm_engine->command;
> > 
> > This will break my local branch.
> > 
> > Any chance of an immutable pull-request for:
> > 
> >   07d8004d6fb9 ("tpm: add bufsiz parameter in the .send callback")
> 
> I might be missing something but this commit is in Linux 6.17-rc1, which
> this tree is based on according to both 'git log' and the lead in to
> your pull request at the top, so your local branch is already broken.
> That error message was taken from the tip of your tree and the fix was
> tested against it as well.
> 
> "tpm: Add a driver for Loongson TPM device" was sent back in early July,
> so it was never updated for this conflict.

Ah, gotcha.  I thought you were saying that 07d8004d6fb9 ("tpm: add
bufsiz parameter in the .send callback") was applied somewhere else.  In
which case, I need to figure out why my build testing didn't catch it.

I'd be happy with a formal patch from you or I can create the patch and
add your {Reported,Suggested}-by.  How would you like to proceed?

-- 
Lee Jones [李琼斯]
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Nathan Chancellor 2 weeks, 6 days ago
On Wed, Sep 17, 2025 at 10:38:23AM +0100, Lee Jones wrote:
> Ah, gotcha.  I thought you were saying that 07d8004d6fb9 ("tpm: add
> bufsiz parameter in the .send callback") was applied somewhere else.  In
> which case, I need to figure out why my build testing didn't catch it.

Maybe because this driver ultimately depends on CONFIG_LOONGARCH (i.e.,
no COMPILE_TEST)? I would argue most people don't do LoongArch builds.

> I'd be happy with a formal patch from you or I can create the patch and
> add your {Reported,Suggested}-by.  How would you like to proceed?

I sent a formal patch to make life a little easier for you :)

https://lore.kernel.org/20250917-tpm-loongson-add-bufsiz-v1-1-972a75c0aab2@kernel.org/

Cheers,
Nathan
Re: [GIT PULL] Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
Posted by Lee Jones 3 weeks ago
On Tue, 16 Sep 2025, Lee Jones wrote:

> On Fri, 12 Sep 2025, Nathan Chancellor wrote:
> 
> > Hi Lee,
> > 
> > On Tue, Sep 02, 2025 at 01:42:05PM +0100, Lee Jones wrote:
> > > Enjoy!
> > > 
> > > The following changes since commit 8f5ae30d69d7543eee0d70083daf4de8fe15d585:
> > > 
> > >   Linux 6.17-rc1 (2025-08-10 19:41:16 +0300)
> > > 
> > > are available in the Git repository at:
> > > 
> > >   git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-char-crypto-v6.18
> > > 
> > > for you to fetch changes up to 74fddd5fbab879a7d039d9fb49af923927a64811:
> > > 
> > >   MAINTAINERS: Add entry for Loongson Security Engine drivers (2025-09-02 12:29:57 +0100)
> > > 
> > > ----------------------------------------------------------------
> > > Immutable branch between MFD, Char and Crypto due for the v6.18 merge window
> > > 
> > > ----------------------------------------------------------------
> > > Qunqin Zhao (4):
> > ...
> > >       tpm: Add a driver for Loongson TPM device
> > 
> > This one needs a fix up due to commit 07d8004d6fb9 ("tpm: add bufsiz
> > parameter in the .send callback") in 6.17-rc1, as I am seeing the
> > following error in next-20250912.
> > 
> >   drivers/char/tpm/tpm_loongson.c:48:17: error: initialization of 'int (*)(struct tpm_chip *, u8 *, size_t,  size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int,  long unsigned int)'} from incompatible pointer type 'int (*)(struct tpm_chip *, u8 *, size_t)' {aka 'int (*)(struct tpm_chip *, unsigned char *, long unsigned int)'} [-Wincompatible-pointer-types]
> >      48 |         .send = tpm_loongson_send,
> >         |                 ^~~~~~~~~~~~~~~~~
> >   drivers/char/tpm/tpm_loongson.c:48:17: note: (near initialization for 'tpm_loongson_ops.send')
> >   drivers/char/tpm/tpm_loongson.c:31:12: note: 'tpm_loongson_send' declared here
> >      31 | static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> >         |            ^~~~~~~~~~~~~~~~~
> > 
> > Can you squash it or do you want a separate patch?
> > 
> > Cheers,
> > Nathan
> > 
> > diff --git a/drivers/char/tpm/tpm_loongson.c b/drivers/char/tpm/tpm_loongson.c
> > index a4ec23639911..9e50250763d1 100644
> > --- a/drivers/char/tpm/tpm_loongson.c
> > +++ b/drivers/char/tpm/tpm_loongson.c
> > @@ -28,7 +28,7 @@ static int tpm_loongson_recv(struct tpm_chip *chip, u8 *buf, size_t count)
> >  	return cmd_ret->data_len;
> >  }
> >  
> > -static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t count)
> > +static int tpm_loongson_send(struct tpm_chip *chip, u8 *buf, size_t bufsiz, size_t count)
> >  {
> >  	struct loongson_se_engine *tpm_engine = dev_get_drvdata(&chip->dev);
> >  	struct tpm_loongson_cmd *cmd = tpm_engine->command;
> 
> This will break my local branch.
> 
> Any chance of an immutable pull-request for:
> 
>   07d8004d6fb9 ("tpm: add bufsiz parameter in the .send callback")

Either that or your proposed change needs to be applied to the tree that
changed the .send API.

-- 
Lee Jones [李琼斯]