[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <YffkwwxtZ/cul5CF@smile.fi.intel.com>
Date: Mon, 31 Jan 2022 15:31:47 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Jan Dąbroś <jsd@...ihalf.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-i2c <linux-i2c@...r.kernel.org>,
Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Hans de Goede <hdegoede@...hat.com>,
Wolfram Sang <wsa@...nel.org>,
Raul E Rangel <rrangel@...omium.org>,
Marcin Wojtas <mw@...ihalf.com>,
Grzegorz Jaszczyk <jaz@...ihalf.com>, upstream@...ihalf.com,
Tom Lendacky <thomas.lendacky@....com>,
"Deucher, Alexander" <alexander.deucher@....com>,
"Easow, Nimesh" <Nimesh.Easow@....com>,
"Limonciello, Mario" <mario.limonciello@....com>,
kernel test robot <lkp@...el.com>
Subject: Re: [PATCH v2 2/2] i2c: designware: Add AMD PSP I2C bus support
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@...ux.intel.com>
> 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@...ihalf.com> 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
Powered by blists - more mailing lists