All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Menon <armenon@redhat.com>
To: Stefan Berger <stefanb@linux.ibm.com>
Cc: qemu-devel@nongnu.org, marcandre.lureau@redhat.com
Subject: Re: [PATCH 5/6] tests: Implement aspeed_i2c_restart to reenable selection of master
Date: Wed, 29 Apr 2026 17:02:03 +0530	[thread overview]
Message-ID: <afHsM-XJk_yq54aw@fedora> (raw)
In-Reply-To: <20260428130718.1325177-6-stefanb@linux.ibm.com>

Hi,

On Tue, Apr 28, 2026 at 01:07:17PM +0000, Stefan Berger wrote:
> For some TPM  I2C tests it is important to be able to reenable the
> selection of the master. Implement aspeed_i2c_restart to enable this.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
>  tests/qtest/qtest_aspeed.c | 8 +++++++-
>  tests/qtest/qtest_aspeed.h | 2 ++
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/qtest_aspeed.c b/tests/qtest/qtest_aspeed.c
> index f6da9adea9..13934cc660 100644
> --- a/tests/qtest/qtest_aspeed.c
> +++ b/tests/qtest/qtest_aspeed.c
> @@ -15,11 +15,17 @@
>  #include "qtest_aspeed.h"
>  #include "hw/i2c/aspeed_i2c.h"
>  
> +static int once;

can we make this a boolean?

> +
> +void aspeed_i2c_restart(void)
> +{
> +    once = false;
> +}
> +
>  static void aspeed_i2c_startup(QTestState *s, uint32_t baseaddr,
>                                 uint8_t slave_addr, uint8_t reg)
>  {
>      uint32_t v;
> -    static int once;

Can we check if the A_I2CD_MASTER_EN bit is set directly without having
the need to store a global static variable? For example:

static bool is_aspeed_i2c_master_enabled(QTestState *s, uint32_t baseaddr)
{
    uint32_t reg_val;

    return ((qtest_readl(s, baseaddr + A_I2CC_FUN_CTRL)
            & A_I2CD_MASTER_EN) != 0);
}
>  
and use it here:
>      if (!once) {
if (!is_aspeed_i2c_master_enabled(s, baseaddr)) {


for restarts, we can directly write to the register
  qtest_writel(s, bus_addr + A_I2CC_FUN_CTRL, 0);
and the subsequent call to aspeed_i2c_startup() will handle the init properly.

>          /* one time: enable master */
> diff --git a/tests/qtest/qtest_aspeed.h b/tests/qtest/qtest_aspeed.h
> index d35b0c7cba..c0a095bb46 100644
> --- a/tests/qtest/qtest_aspeed.h
> +++ b/tests/qtest/qtest_aspeed.h
> @@ -23,6 +23,8 @@ static inline uint32_t ast2600_i2c_calc_bus_addr(uint8_t bus_num)
>      return AST2600_ASPEED_I2C_BASE_ADDR + 0x80 + bus_num * 0x80;
>  }
>  
> +void aspeed_i2c_restart(void);
> +
>  uint8_t aspeed_i2c_readb(QTestState *s,
>                           uint32_t baseaddr, uint8_t slave_addr, uint8_t reg);
>  uint16_t aspeed_i2c_readw(QTestState *s,
> -- 
> 2.43.0
> 

Regards,
Arun Menon



  reply	other threads:[~2026-04-29 11:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 13:07 [PATCH 0/6] Add test case for TPM over I2C with swtpm Stefan Berger
2026-04-28 13:07 ` [PATCH 1/6] tests: Move TPM I2C bus read/write functions to common files Stefan Berger
2026-04-29 11:29   ` Arun Menon
2026-04-28 13:07 ` [PATCH 2/6] tests: Have TPM I2C read/write functions take QTestState as first parameter Stefan Berger
2026-04-29 11:30   ` Arun Menon
2026-04-28 13:07 ` [PATCH 3/6] tests: Set sizes for arrays of expected TPM responses and requests Stefan Berger
2026-04-29 11:29   ` Arun Menon
2026-04-28 13:07 ` [PATCH 4/6] tests: Rename id of tpmdev to tpm0 Stefan Berger
2026-04-29 11:30   ` Arun Menon
2026-04-28 13:07 ` [PATCH 5/6] tests: Implement aspeed_i2c_restart to reenable selection of master Stefan Berger
2026-04-29 11:32   ` Arun Menon [this message]
2026-04-29 12:13     ` Stefan Berger
2026-04-28 13:07 ` [PATCH 6/6] tests: Add a TPM TIS I2C swtpm test Stefan Berger
2026-04-29 11:32   ` Arun Menon

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=afHsM-XJk_yq54aw@fedora \
    --to=armenon@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.ibm.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.