Linux Integrity Measurement development
 help / color / mirror / Atom feed
From: shaopeijie@cestc.cn
To: pmenzel@molgen.mpg.de
Cc: jarkko@kernel.org, peterhuewe@gmx.de, jgg@ziepe.ca,
	linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails
Date: Tue, 23 May 2023 10:45:07 +0800	[thread overview]
Message-ID: <20230523024507.4277-1-shaopeijie@cestc.cn> (raw)
In-Reply-To: <20230522070140.33719-1-shaopeijie@cestc.cn>

Thank you, Paul.

>Dear Peijie,
>
>
>Thank you for your patch.
>
>The fix: tag in your commit message summary is uncommon. I suggest:
>
>> tpm_tis_spi: Release chip select when flow control fails
>

I will change it in v3 version.

>
>Am 22.05.23 um 09:01 schrieb shaopeijie@cestc.cn:
>> From: Peijie Shao <shaopeijie@cestc.cn>
>> 
>> The failure paths in tpm_tis_spi_transfer() do not deactivate
>> chip select. Send an empty message (cs_select == 0) to overcome
>> this.
>
>Does the standard require to deactivate it?

Yes.
<TCG_PCClientTPMInterfaceSpecification_TIS__1-3_27_03212013.pdf>, section
6.4.2 Electrical Specification, Figure 4 Timing Diagram, describes the timing.

Moreover, when multi devices are sharing with the same SPI bus, only one cs can be 
activated simultaneously. If two or more cs are activated, corresponding devices 
may response at same time, cause bus conflicts.

>
>A note on your test setup would be nice to have in the commit message.
>
>> Signed-off-by: Peijie Shao <shaopeijie@cestc.cn>
>> ---
>> Changes since v1:
>>      1. Deactive cs all of the failure path, not only flow control.
>
>Deactivate

Sorry, will be fixed in v3 version.

>
>
>Kind regards,
>
>Paul
>
>
>>      2. change and update comments.
>> ---
>>   drivers/char/tpm/tpm_tis_spi_main.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>> 
>> diff --git a/drivers/char/tpm/tpm_tis_spi_main.c b/drivers/char/tpm/tpm_tis_spi_main.c
>> index 1f5207974..9bfaba092 100644
>> --- a/drivers/char/tpm/tpm_tis_spi_main.c
>> +++ b/drivers/char/tpm/tpm_tis_spi_main.c
>> @@ -136,6 +136,14 @@ int tpm_tis_spi_transfer(struct tpm_tis_data *data, u32 addr, u16 len,
>>   	}
>>   
>>   exit:
>> +	if (ret < 0) {
>> +		/* Deactivate chip select */
>> +		memset(&spi_xfer, 0, sizeof(spi_xfer));
>> +		spi_message_init(&m);
>> +		spi_message_add_tail(&spi_xfer, &m);
>> +		spi_sync_locked(phy->spi_device, &m);
>> +	}
>> +
>>   	spi_bus_unlock(phy->spi_device->master);
>>   	return ret;
>>   }

Peijie, Shao



  parent reply	other threads:[~2023-05-23  2:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  7:01 [PATCH v2] tpm_tis_spi: fix:release chip select when flow control fails shaopeijie
2023-05-22  8:17 ` Paul Menzel
2023-05-24  2:52   ` Jarkko Sakkinen
2023-05-23  2:45 ` shaopeijie [this message]
2023-05-23  2:45 ` [PATCH v3] tpm_tis_spi: Release " shaopeijie
2023-05-24  2:06   ` Jarkko Sakkinen
2023-05-24  3:14   ` Jarkko Sakkinen
  -- strict thread matches above, loose matches on Subject: below --
2023-05-23  2:54 Re: [PATCH v2] tpm_tis_spi: fix:release " shaopeijie

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=20230523024507.4277-1-shaopeijie@cestc.cn \
    --to=shaopeijie@cestc.cn \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterhuewe@gmx.de \
    --cc=pmenzel@molgen.mpg.de \
    /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