Re: [PATCH v2 2/2] i2c: designware: Add AMD PSP I2C bus support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jan 31, 2022 at 12:56:27PM +0100, Jan Dąbroś wrote:
> pt., 28 sty 2022 o 16:50 Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> napisał(a):
> > On Fri, Jan 28, 2022 at 03:59:40PM +0100, Jan Dąbroś wrote:
> > > pt., 28 sty 2022 o 15:48 Jan Dabros <jsd@xxxxxxxxxxxx> napisał(a):

...

> > > > +struct psp_mbox {
> > > > +       u32 cmd_fields;
> >
> > > > +       phys_addr_t i2c_req_addr;
> >
> > But phys_addr_t is platform-dependent type. Perhaps you meant to use u64
> > here
> > always?
> 
> Once I remove the "depends on X86_64" I believe this should be left
> platform-dependent.

If it's a protocol or HW layout, it may not be platform-dependent.

> > > > +} __packed;

...

> > > > +       if (psp_send_cmd(req))
> >
> > > > +               return -EIO;
> >
> > Why is error code shadowed?
> >
> 
> Just as a side note - it wasn't modified in v2 when moving above to
> psp_send_check_i2c_req(), but let me explain why I have introduced this
> initially.
> 
> We have two means of timeouts in the context of this driver:
> 1. Timeout of internal mailbox, which means we cannot communicate with a
> PSP for a programmed timeout. This timeout is encountered inside
> psp_send_cmd().
> 2. Timeout of i2c arbitration - which means that we can communicate with
> PSP, but PSP refuses to release i2c bus for too long. This timeout is
> returned by psp_send_i2c_req() in case of error.
> (side note: both error conditions are very unlikely to happen at runtime)
> 
> I wanted to clearly distinguish between these two and thus put all errors
> around mailbox into "-EIO category", which is actually true.

At very least this code needs more or less the above to be put as a comment.

...

> > > > +cleanup:
> > > > +       mutex_unlock(&psp_i2c_access_mutex);
> > > > +       return 0;
> >
> > Not sure I understand why we ignore all above errors here.
> >
> 
> Actually we are not ignoring them, since each error sets "psp_i2c_mbox_fail
> = true;". This means that if there is any error on x86-PSP interface, we
> are ignoring i2c-arbitration and just fall back to normal (that is
> no-quirk) operation.
> 
> From the i2c-client perspective (who is eventually gathering error code
> from above) I think we can claim that everything is fine, since bus is
> granted to it. For developers there is an error message in case some debug
> will be necessary.

Perhaps needs a comment (sorry, if I overlooked it).

...

> > > > +       if (!dev || !dev->dev)
> > > > +               return -ENODEV;
> >
> > At which circumstances may we get
> >         dev != NULL
> >         dev->dev == NULL
> > ?
> >
> > ...
> >
> > > >         if (!dev || !dev->dev)
> > > > -               return 0;
> > > > +               return -ENODEV;
> >
> > I see the same here, perhaps Hans knows the answer :-)
> 
> Right, so I must admit that I simply used *-baytrail.c as a reference and
> thinking that additional check shouldn't hurt us (always better than not
> enough safety..). Looking more at this now - `dw_i2c_plat_probe()` will
> boil-out earlier if `dev->dev == NULL`. Should I remove this extra check in
> *-baytrail.c in the same commit?

Maybe. Please, double check that it's not needed indeed.

-- 
With Best Regards,
Andy Shevchenko





[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux