[PATCH 09/14] pmbus: Reset out buf after switching pages

Peter Delevoryas posted 14 patches 3 years, 7 months ago
Only 11 patches received!
[PATCH 09/14] pmbus: Reset out buf after switching pages
Posted by Peter Delevoryas 3 years, 7 months ago
Signed-off-by: Peter Delevoryas <pdel@fb.com>
---
 hw/i2c/pmbus_device.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/i2c/pmbus_device.c b/hw/i2c/pmbus_device.c
index 62885fa6a1..efddc36fd9 100644
--- a/hw/i2c/pmbus_device.c
+++ b/hw/i2c/pmbus_device.c
@@ -1088,6 +1088,7 @@ static int pmbus_write_data(SMBusDevice *smd, uint8_t *buf, uint8_t len)
 
     if (pmdev->code == PMBUS_PAGE) {
         pmdev->page = pmbus_receive8(pmdev);
+        pmdev->out_buf_len = 0;
         return 0;
     }
 
-- 
2.30.2
Re: [PATCH 09/14] pmbus: Reset out buf after switching pages
Posted by Cédric Le Goater 3 years, 7 months ago
On 6/27/22 21:55, Peter Delevoryas wrote:
> Signed-off-by: Peter Delevoryas <pdel@fb.com>

is that a bug ?


> ---
>   hw/i2c/pmbus_device.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/i2c/pmbus_device.c b/hw/i2c/pmbus_device.c
> index 62885fa6a1..efddc36fd9 100644
> --- a/hw/i2c/pmbus_device.c
> +++ b/hw/i2c/pmbus_device.c
> @@ -1088,6 +1088,7 @@ static int pmbus_write_data(SMBusDevice *smd, uint8_t *buf, uint8_t len)
>   
>       if (pmdev->code == PMBUS_PAGE) {
>           pmdev->page = pmbus_receive8(pmdev);
> +        pmdev->out_buf_len = 0;
>           return 0;
>       }
>
Re: [PATCH 09/14] pmbus: Reset out buf after switching pages
Posted by Peter Delevoryas 3 years, 7 months ago

> On Jun 27, 2022, at 11:51 PM, Cédric Le Goater <clg@kaod.org> wrote:
> 
> On 6/27/22 21:55, Peter Delevoryas wrote:
>> Signed-off-by: Peter Delevoryas <pdel@fb.com>
> 
> is that a bug ?

I believe so yes, although I don’t really have any experience with
real pmbus devices. But, I would assume that when you’re switching
pages, you wouldn’t retain any remaining data from the transfer
buffer of the previous page, because that would return data
from the previous page.

Here’s the tag I should have included:

Fixes: 3746d5c15e70570b ("hw/i2c: add support for PMBus”)

> 
> 
>> ---
>>  hw/i2c/pmbus_device.c | 1 +
>>  1 file changed, 1 insertion(+)
>> diff --git a/hw/i2c/pmbus_device.c b/hw/i2c/pmbus_device.c
>> index 62885fa6a1..efddc36fd9 100644
>> --- a/hw/i2c/pmbus_device.c
>> +++ b/hw/i2c/pmbus_device.c
>> @@ -1088,6 +1088,7 @@ static int pmbus_write_data(SMBusDevice *smd, uint8_t *buf, uint8_t len)
>>        if (pmdev->code == PMBUS_PAGE) {
>>          pmdev->page = pmbus_receive8(pmdev);
>> +        pmdev->out_buf_len = 0;
>>          return 0;
>>      }
>>  
>