From: Heiner Kallweit <hkallweit1@gmail.com>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Jean Delvare <jdelvare@suse.com>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>
Subject: Re: [PATCH 1/4] i2c: i801: Use i2c_mark_adapter_suspended/resumed
Date: Fri, 16 Jun 2023 08:00:03 +0200 [thread overview]
Message-ID: <1dbab8ee-324b-edb2-9489-72e75ad4f5dd@gmail.com> (raw)
In-Reply-To: <20230615214517.niwhcdnzxuumed2k@intel.intel>
On 15.06.2023 23:45, Andi Shyti wrote:
> Hi Heiner,
>
> On Thu, Jun 15, 2023 at 11:17:12PM +0200, Heiner Kallweit wrote:
>> On 15.06.2023 00:24, Andi Shyti wrote:
>>> Hi Heiner,
>>>
>>> On Sat, Mar 04, 2023 at 10:31:23PM +0100, Heiner Kallweit wrote:
>>>> When entering the shutdown/remove/suspend callbacks, at first we should
>>>> ensure that transfers are finished and I2C core can't start further
>>>> transfers. Use i2c_mark_adapter_suspended() for this purpose.
>>>>
>>>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>>>> ---
>>>> drivers/i2c/busses/i2c-i801.c | 6 ++++++
>>>> 1 file changed, 6 insertions(+)
>>>>
>>>> diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
>>>> index ac5326747..d6a0c3b53 100644
>>>> --- a/drivers/i2c/busses/i2c-i801.c
>>>> +++ b/drivers/i2c/busses/i2c-i801.c
>>>> @@ -1773,6 +1773,8 @@ static void i801_remove(struct pci_dev *dev)
>>>> {
>>>> struct i801_priv *priv = pci_get_drvdata(dev);
>>>>
>>>> + i2c_mark_adapter_suspended(&priv->adapter);
>>>> +
>>>> outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
>>>> i801_disable_host_notify(priv);
>>>> i801_del_mux(priv);
>>>> @@ -1796,6 +1798,8 @@ static void i801_shutdown(struct pci_dev *dev)
>>>> {
>>>> struct i801_priv *priv = pci_get_drvdata(dev);
>>>>
>>>> + i2c_mark_adapter_suspended(&priv->adapter);
>>>> +
>>>
>>> is this really needed in the shutdown and remove function?
>>>
>> I think yes. Otherwise we may interrupt an active transfer, or a user
>> may start a transfer whilst we are in cleanup.
>> Note: i2c_mark_adapter_suspended() takes the I2C bus lock, therefore it
>> will sleep until an active transfer is finished.
>
> yes, I think you are right.
>
>>> I'm OK with it, though.
>>>
>>>> /* Restore config registers to avoid hard hang on some systems */
>>>> outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
>>>> i801_disable_host_notify(priv);
>>>> @@ -1807,6 +1811,7 @@ static int i801_suspend(struct device *dev)
>>>> {
>>>> struct i801_priv *priv = dev_get_drvdata(dev);
>>>>
>>>> + i2c_mark_adapter_suspended(&priv->adapter);
>>>> outb_p(priv->original_hstcnt, SMBHSTCNT(priv));
>>>> pci_write_config_byte(priv->pci_dev, SMBHSTCFG, priv->original_hstcfg);
>>>> return 0;
>>>> @@ -1818,6 +1823,7 @@ static int i801_resume(struct device *dev)
>>>>
>>>> i801_setup_hstcfg(priv);
>>>> i801_enable_host_notify(&priv->adapter);
>>>> + i2c_mark_adapter_resumed(&priv->adapter);
>>>
>>> BTW, I see that very few drivers are using suspended and resumed
>>> and I wonder why. Should these perhaps be added in the basic pm
>>> functions?
>>>
>> For my understanding, which functions are you referring to?
>
> I am referring about having a more generalised pm function which
> can mark the i2c adapter supsended or resumed even before or
> after the driver specific functions are called.
>
In case of i801 this bus driver is a pci_driver and the remove callback
is handled by the PCI core (pci_device_remove()), I2C core isn't involved.
At a first glance I fail to see how we could inject I2C-specific code.
> This way all drivers can benefit from it.
>
> In any case this out of the scope of this patch.
>
> I'm going to give my approval, if then Jean has something to say,
> I guess there is still time to chime in.
>
> Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
>
> Thank you,
> Andi
>
>>> I'm OK to r-b this, but i want first Jean to give it an ack.
>>>
>>> Andi
>>
next prev parent reply other threads:[~2023-06-16 6:00 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-04 21:30 [PATCH 0/4] i2c: i801: next set of improvements Heiner Kallweit
2023-03-04 21:31 ` [PATCH 1/4] i2c: i801: Use i2c_mark_adapter_suspended/resumed Heiner Kallweit
2023-06-14 22:24 ` Andi Shyti
2023-06-15 21:17 ` Heiner Kallweit
2023-06-15 21:45 ` Andi Shyti
2023-06-16 6:00 ` Heiner Kallweit [this message]
2023-06-26 17:20 ` Jean Delvare
2023-08-27 16:20 ` Heiner Kallweit
2023-03-04 21:33 ` [PATCH 2/4] i2c: i801: Replace acpi_lock with I2C bus lock Heiner Kallweit
2023-06-14 22:31 ` Andi Shyti
2023-06-15 21:22 ` Heiner Kallweit
2023-06-15 21:49 ` Andi Shyti
2023-06-26 17:59 ` Jean Delvare
2023-08-27 16:21 ` Heiner Kallweit
2023-08-28 7:01 ` Jean Delvare
2023-09-15 14:01 ` Heiner Kallweit
2023-03-04 21:36 ` [PATCH 3/4] i2c: i801: Improve i801_block_transaction_byte_by_byte Heiner Kallweit
2023-06-14 22:32 ` Andi Shyti
2023-06-15 21:48 ` Andi Shyti
2023-06-27 13:46 ` Jean Delvare
2023-08-27 17:14 ` Heiner Kallweit
2023-08-28 13:27 ` Jean Delvare
2023-08-28 15:10 ` Jean Delvare
2023-08-29 6:08 ` Heiner Kallweit
2023-08-29 6:29 ` Heiner Kallweit
2023-03-04 21:37 ` [PATCH 4/4] i2c: i801: Switch to new macro DEFINE_SIMPLE_DEV_PM_OPS Heiner Kallweit
2023-06-14 22:37 ` Andi Shyti
2023-06-28 7:15 ` Jean Delvare
2023-09-22 9:54 ` Wolfram Sang
2023-09-22 10:20 ` Heiner Kallweit
2023-05-16 20:29 ` [PATCH 0/4] i2c: i801: next set of improvements Heiner Kallweit
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=1dbab8ee-324b-edb2-9489-72e75ad4f5dd@gmail.com \
--to=hkallweit1@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=jdelvare@suse.com \
--cc=linux-i2c@vger.kernel.org \
/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