netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@google.com, Slawomir Laba <slawomirx.laba@intel.com>,
	netdev@vger.kernel.org, jan.sokolowski@intel.com,
	Mateusz Palczewski <mateusz.palczewski@intel.com>,
	Marek Szlosek <marek.szlosek@intel.com>
Subject: Re: [PATCH net 1/1] iavf: Fix shutdown pci callback to match the remove one
Date: Sun, 15 Jan 2023 14:06:19 +0200	[thread overview]
Message-ID: <Y8PsO9J3PghkBjEs@unreal> (raw)
In-Reply-To: <20230113215012.971028-1-anthony.l.nguyen@intel.com>

On Fri, Jan 13, 2023 at 01:50:12PM -0800, Tony Nguyen wrote:
> From: Slawomir Laba <slawomirx.laba@intel.com>
> 
> Make the flow for pci shutdown be the same to the pci remove.
> 
> iavf_shutdown was implementing an incomplete version
> of iavf_remove. It misses several calls to the kernel like
> iavf_free_misc_irq, iavf_reset_interrupt_capability, iounmap
> that might break the system on reboot or hibernation.
> 
> Implement the call of iavf_remove directly in iavf_shutdown to
> close this gap.
> 
> Fixes: 5eae00c57f5e ("i40evf: main driver core")
> Signed-off-by: Slawomir Laba <slawomirx.laba@intel.com>
> Signed-off-by: Mateusz Palczewski <mateusz.palczewski@intel.com>
> Tested-by: Marek Szlosek <marek.szlosek@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c | 40 +++++++--------------
>  1 file changed, 12 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index adc02adef83a..34c9bd62546b 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -4812,34 +4812,6 @@ int iavf_process_config(struct iavf_adapter *adapter)
>  	return 0;
>  }
>  
> -/**
> - * iavf_shutdown - Shutdown the device in preparation for a reboot
> - * @pdev: pci device structure
> - **/
> -static void iavf_shutdown(struct pci_dev *pdev)
> -{
> -	struct iavf_adapter *adapter = iavf_pdev_to_adapter(pdev);
> -	struct net_device *netdev = adapter->netdev;
> -
> -	netif_device_detach(netdev);
> -
> -	if (netif_running(netdev))
> -		iavf_close(netdev);
> -
> -	if (iavf_lock_timeout(&adapter->crit_lock, 5000))
> -		dev_warn(&adapter->pdev->dev, "%s: failed to acquire crit_lock\n", __func__);
> -	/* Prevent the watchdog from running. */
> -	iavf_change_state(adapter, __IAVF_REMOVE);
> -	adapter->aq_required = 0;
> -	mutex_unlock(&adapter->crit_lock);
> -
> -#ifdef CONFIG_PM
> -	pci_save_state(pdev);
> -
> -#endif
> -	pci_disable_device(pdev);
> -}
> -
>  /**
>   * iavf_probe - Device Initialization Routine
>   * @pdev: PCI device information struct
> @@ -5177,6 +5149,18 @@ static void iavf_remove(struct pci_dev *pdev)
>  	pci_disable_device(pdev);
>  }
>  
> +/**
> + * iavf_shutdown - Shutdown the device in preparation for a reboot
> + * @pdev: pci device structure
> + **/
> +static void iavf_shutdown(struct pci_dev *pdev)
> +{
> +	iavf_remove(pdev);
> +
> +	if (system_state == SYSTEM_POWER_OFF)
> +		pci_set_power_state(pdev, PCI_D3hot);

Why do you need it? and why does "system_state == SYSTEM_POWER_OFF" line
exist in small number of old drivers?

What is missing in PCI core power state management, which pushes you
to set D3 state in hibernation?

Thanks


> +}
> +
>  static SIMPLE_DEV_PM_OPS(iavf_pm_ops, iavf_suspend, iavf_resume);
>  
>  static struct pci_driver iavf_driver = {
> -- 
> 2.38.1
> 

      reply	other threads:[~2023-01-15 12:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 21:50 [PATCH net 1/1] iavf: Fix shutdown pci callback to match the remove one Tony Nguyen
2023-01-15 12:06 ` Leon Romanovsky [this message]

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=Y8PsO9J3PghkBjEs@unreal \
    --to=leon@kernel.org \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jan.sokolowski@intel.com \
    --cc=kuba@kernel.org \
    --cc=marek.szlosek@intel.com \
    --cc=mateusz.palczewski@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=slawomirx.laba@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).