mbox series

[0/8] i2c: i801: collection of further improvements / refactorings

Message ID 0d6a1cdb-39a1-4fad-a6e4-48953619f33b@gmail.com
Headers show
Series i2c: i801: collection of further improvements / refactorings | expand

Message

Heiner Kallweit Sept. 22, 2023, 7:32 p.m. UTC
This series contains further improvements and refactorings.

Heiner Kallweit (8):
  i2c: i801: Replace magic value with constant in
    dmi_check_onboard_devices
  i2c: i801: Remove unused argument from tco functions
  i2c: i801: Use i2c core default adapter timeout
  i2c: i801: Define FEATURES_ICH5 as an extension of FEATURES_ICH4
  i2c: i801: Add helper i801_check_and_clear_pec_error
  i2c: i801: Split i801_block_transaction
  i2c: i801: Add SMBUS_LEN_SENTINEL
  i2c: i801: Add helper i801_get_block_len

 drivers/i2c/busses/i2c-i801.c | 216 +++++++++++++++++-----------------
 1 file changed, 106 insertions(+), 110 deletions(-)

Comments

Andi Shyti Jan. 29, 2024, 11:32 p.m. UTC | #1
Hi Heiner,

On Fri, Sep 22, 2023 at 09:34:13PM +0200, Heiner Kallweit wrote:
> Replace magic number 10 with the appropriate constant.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>

Thanks,
Andi
Andi Shyti Jan. 29, 2024, 11:46 p.m. UTC | #2
Hi Heiner,

On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
> I see no need for a driver-specific timeout value, therefore let's go
> with the i2c core default timeout of 1s set by i2c_register_adapter().

Why is the timeout value not needed in your opinion? Is the
datasheet specifying anything here?

Jean any opinion here?

Thanks,
Andi
Andi Shyti Jan. 29, 2024, 11:50 p.m. UTC | #3
Hi Heiner,

On Fri, Sep 22, 2023 at 09:37:35PM +0200, Heiner Kallweit wrote:
> Avoid code duplication and factor out checking and clearing PEC error
> bit to new helper i801_check_and_clear_pec_error().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>

Thanks,
Andi
Andi Shyti Jan. 30, 2024, 12:25 a.m. UTC | #4
Hi Heiner,

On Fri, Sep 22, 2023 at 09:41:41PM +0200, Heiner Kallweit wrote:
> Avoid code duplication and factor out retrieving and checking the
> block length value to new helper i801_get_block_len().
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

Reviewed-by: Andi Shyti <andi.shyti@kernel.org>

Thanks,
Andi
Heiner Kallweit Jan. 30, 2024, 7:10 a.m. UTC | #5
On 30.01.2024 00:46, Andi Shyti wrote:
> Hi Heiner,
> 
> On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
>> I see no need for a driver-specific timeout value, therefore let's go
>> with the i2c core default timeout of 1s set by i2c_register_adapter().
> 
> Why is the timeout value not needed in your opinion? Is the
> datasheet specifying anything here?
> 
I2C core sets a timeout of 1s if driver doesn't set a timeout value.
So for me the question is: Is there an actual need or benefit of
setting a lower timeout value? And that's something I don't see.

> Jean any opinion here?
> 
> Thanks,
> Andi

Heiner
Andi Shyti Jan. 30, 2024, 10 a.m. UTC | #6
Hi Heiner,

> > On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
> >> I see no need for a driver-specific timeout value, therefore let's go
> >> with the i2c core default timeout of 1s set by i2c_register_adapter().
> > 
> > Why is the timeout value not needed in your opinion? Is the
> > datasheet specifying anything here?
> > 
> I2C core sets a timeout of 1s if driver doesn't set a timeout value.
> So for me the question is: Is there an actual need or benefit of
> setting a lower timeout value? And that's something I don't see.

yes, that's why I am asking and I would like to have an opinion
from Jean. I will try to get hold of the datasheets, as well and
see if there is any constraint on the timeout.

Thanks,
Andi
Heiner Kallweit Jan. 30, 2024, 10:25 a.m. UTC | #7
On 30.01.2024 11:00, Andi Shyti wrote:
> Hi Heiner,
> 
>>> On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
>>>> I see no need for a driver-specific timeout value, therefore let's go
>>>> with the i2c core default timeout of 1s set by i2c_register_adapter().
>>>
>>> Why is the timeout value not needed in your opinion? Is the
>>> datasheet specifying anything here?
>>>
>> I2C core sets a timeout of 1s if driver doesn't set a timeout value.
>> So for me the question is: Is there an actual need or benefit of
>> setting a lower timeout value? And that's something I don't see.
> 
> yes, that's why I am asking and I would like to have an opinion
> from Jean. I will try to get hold of the datasheets, as well and
> see if there is any constraint on the timeout.
> 
The datasheet for the 7-series (doc# 326776-003) states:

5.21.3.2 Bus Time Out (The PCH as SMBus Master)
If there is an error in the transaction, such that an SMBus device does not signal an
acknowledge, or holds the clock lower than the allowed time-out time, the transaction
will time out. The PCH will discard the cycle and set the DEV_ERR bit. The time out
minimum is 25 ms (800 RTC clocks). The time-out counter inside the PCH will start
after the last bit of data is transferred by the PCH and it is waiting for a response.
The 25-ms time-out counter will not count under the following conditions:
1. BYTE_DONE_STATUS bit (SMBus I/O Offset 00h, Bit 7) is set
2. The SECOND_TO_STS bit (TCO I/O Offset 06h, Bit 1) is not set (this indicates that
the system has not locked up).

It's my understanding that the chip will signal timeout after 25ms. So we should never
have the case that the host timeout kicks in (as long as it's >25ms).
So the host timeout value doesn't really matter.

> Thanks,
> Andi

Heiner
Heiner Kallweit Jan. 30, 2024, 8:38 p.m. UTC | #8
On 22.09.2023 21:32, Heiner Kallweit wrote:
> This series contains further improvements and refactorings.
> 
> Heiner Kallweit (8):
>   i2c: i801: Replace magic value with constant in
>     dmi_check_onboard_devices
>   i2c: i801: Remove unused argument from tco functions
>   i2c: i801: Use i2c core default adapter timeout
>   i2c: i801: Define FEATURES_ICH5 as an extension of FEATURES_ICH4
>   i2c: i801: Add helper i801_check_and_clear_pec_error
>   i2c: i801: Split i801_block_transaction
>   i2c: i801: Add SMBUS_LEN_SENTINEL
>   i2c: i801: Add helper i801_get_block_len
> 
>  drivers/i2c/busses/i2c-i801.c | 216 +++++++++++++++++-----------------
>  1 file changed, 106 insertions(+), 110 deletions(-)
> 
Thanks for the prompt review. Let's see what Jean thinks
about patch 3. Then I can incorporate the feedback and
provide a v2 of the series.
Andi Shyti Jan. 30, 2024, 9:58 p.m. UTC | #9
Hi Heiner,

On Tue, Jan 30, 2024 at 11:25:33AM +0100, Heiner Kallweit wrote:
> On 30.01.2024 11:00, Andi Shyti wrote:
> >>> On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
> >>>> I see no need for a driver-specific timeout value, therefore let's go
> >>>> with the i2c core default timeout of 1s set by i2c_register_adapter().
> >>>
> >>> Why is the timeout value not needed in your opinion? Is the
> >>> datasheet specifying anything here?
> >>>
> >> I2C core sets a timeout of 1s if driver doesn't set a timeout value.
> >> So for me the question is: Is there an actual need or benefit of
> >> setting a lower timeout value? And that's something I don't see.
> > 
> > yes, that's why I am asking and I would like to have an opinion
> > from Jean. I will try to get hold of the datasheets, as well and
> > see if there is any constraint on the timeout.
> > 
> The datasheet for the 7-series (doc# 326776-003) states:
> 
> 5.21.3.2 Bus Time Out (The PCH as SMBus Master)
> If there is an error in the transaction, such that an SMBus device does not signal an
> acknowledge, or holds the clock lower than the allowed time-out time, the transaction
> will time out. The PCH will discard the cycle and set the DEV_ERR bit. The time out
> minimum is 25 ms (800 RTC clocks). The time-out counter inside the PCH will start
> after the last bit of data is transferred by the PCH and it is waiting for a response.
> The 25-ms time-out counter will not count under the following conditions:
> 1. BYTE_DONE_STATUS bit (SMBus I/O Offset 00h, Bit 7) is set
> 2. The SECOND_TO_STS bit (TCO I/O Offset 06h, Bit 1) is not set (this indicates that
> the system has not locked up).
> 
> It's my understanding that the chip will signal timeout after 25ms. So we should never
> have the case that the host timeout kicks in (as long as it's >25ms).
> So the host timeout value doesn't really matter.

This driver is used by many platforms. I scrolled through the
datasheets of few of them and they differ from each other.

This was set by Jean[*] that's why I need to hear from him from
where this 200 ms comes from. 

As this change doesn't change much to the economy of the driver,
I would take it out from this series or place it at the end.

As of now, I'm going to take patch 1 and 2 in and you can
resubmit a v2 without the first two patches.

Thanks,
Andi

[*] b3b8df97723d ("i2c: i801: Use wait_event_timeout to wait for interrupts")
Andi Shyti Jan. 30, 2024, 10:24 p.m. UTC | #10
Hi Heiner,

On Fri, 22 Sep 2023 21:32:57 +0200, Heiner Kallweit wrote:
> This series contains further improvements and refactorings.
> 
> Heiner Kallweit (8):
>   i2c: i801: Replace magic value with constant in
>     dmi_check_onboard_devices
>   i2c: i801: Remove unused argument from tco functions
>   i2c: i801: Use i2c core default adapter timeout
>   i2c: i801: Define FEATURES_ICH5 as an extension of FEATURES_ICH4
>   i2c: i801: Add helper i801_check_and_clear_pec_error
>   i2c: i801: Split i801_block_transaction
>   i2c: i801: Add SMBUS_LEN_SENTINEL
>   i2c: i801: Add helper i801_get_block_len
> 
> [...]

Applied the first to patches to i2c/i2c-host on

git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux.git

Thank you,
Andi

Patches applied
===============
[1/8] i2c: i801: Replace magic value with constant in dmi_check_onboard_devices
      commit: 9f14f46a276521c92cdffb0fc36f907e868d3888
[2/8] i2c: i801: Remove unused argument from tco functions
      commit: 96b125361866d998471c1380f809f2a2b4db60c0
Heiner Kallweit Jan. 31, 2024, 7:23 a.m. UTC | #11
On 30.01.2024 22:58, Andi Shyti wrote:
> Hi Heiner,
> 
> On Tue, Jan 30, 2024 at 11:25:33AM +0100, Heiner Kallweit wrote:
>> On 30.01.2024 11:00, Andi Shyti wrote:
>>>>> On Fri, Sep 22, 2023 at 09:35:55PM +0200, Heiner Kallweit wrote:
>>>>>> I see no need for a driver-specific timeout value, therefore let's go
>>>>>> with the i2c core default timeout of 1s set by i2c_register_adapter().
>>>>>
>>>>> Why is the timeout value not needed in your opinion? Is the
>>>>> datasheet specifying anything here?
>>>>>
>>>> I2C core sets a timeout of 1s if driver doesn't set a timeout value.
>>>> So for me the question is: Is there an actual need or benefit of
>>>> setting a lower timeout value? And that's something I don't see.
>>>
>>> yes, that's why I am asking and I would like to have an opinion
>>> from Jean. I will try to get hold of the datasheets, as well and
>>> see if there is any constraint on the timeout.
>>>
>> The datasheet for the 7-series (doc# 326776-003) states:
>>
>> 5.21.3.2 Bus Time Out (The PCH as SMBus Master)
>> If there is an error in the transaction, such that an SMBus device does not signal an
>> acknowledge, or holds the clock lower than the allowed time-out time, the transaction
>> will time out. The PCH will discard the cycle and set the DEV_ERR bit. The time out
>> minimum is 25 ms (800 RTC clocks). The time-out counter inside the PCH will start
>> after the last bit of data is transferred by the PCH and it is waiting for a response.
>> The 25-ms time-out counter will not count under the following conditions:
>> 1. BYTE_DONE_STATUS bit (SMBus I/O Offset 00h, Bit 7) is set
>> 2. The SECOND_TO_STS bit (TCO I/O Offset 06h, Bit 1) is not set (this indicates that
>> the system has not locked up).
>>
>> It's my understanding that the chip will signal timeout after 25ms. So we should never
>> have the case that the host timeout kicks in (as long as it's >25ms).
>> So the host timeout value doesn't really matter.
> 
> This driver is used by many platforms. I scrolled through the
> datasheets of few of them and they differ from each other.
> 
> This was set by Jean[*] that's why I need to hear from him from
> where this 200 ms comes from. 
> 
> As this change doesn't change much to the economy of the driver,
> I would take it out from this series or place it at the end.
> 
> As of now, I'm going to take patch 1 and 2 in and you can
> resubmit a v2 without the first two patches.
> 
Sounds good. Thanks!

> Thanks,
> Andi
> 
> [*] b3b8df97723d ("i2c: i801: Use wait_event_timeout to wait for interrupts")

Heiner