All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Assmann <sassmann@redhat.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next 05/15] iavf: untangle any pending iavf_open() operations from iavf_close()
Date: Thu, 10 Jun 2021 08:14:21 +0200	[thread overview]
Message-ID: <20210610061421.ztmmqwnoybprgyut@p50> (raw)
In-Reply-To: <20210604165335.33329-5-anthony.l.nguyen@intel.com>

On 2021-06-04 09:53, Tony Nguyen wrote:
> From: Nicholas Nunley <nicholas.d.nunley@intel.com>
> 
> When the iavf interface is opened some of the steps necessary to
> configure the hardware require communication with the PF driver. Since
> these operations involve waiting for a response from the PF driver they can
> be time-consuming, so the iavf driver schedules them for later and
> proceeds with the remaining configuration. If the interface is closed
> immediately after it is opened then some of these operations may still be
> pending, although the iavf_close() routine assumes they have all
> completed. In rare cases this can lead to iavf_open() configuration
> operations completing after iavf_close(), which can mean the device
> interrupts and/or DMA engine are active on a disabled interface.
> 
> To fix this:
> 1. In iavf_close() any pending unsent operations from iavf_open() are
> canceled.
> 2. If the operation was already sent by the time iavf_close() is called,
> but the driver is still awaiting the response back from the PF driver, then
> ignore the response if it is received when the interface is down instead of
> handling it in the usual manner.
> 3. Place a lock around the handling of all PF driver responses to ensure
> that these can't conflict with concurrent processing of iavf_open() and
> iavf_close(), or the other configuration tasks. In essence change (2)
> above protects against unexpected responses received after iavf_close(),
> and this change protects against responses received during iavf_close().
> 
> Signed-off-by: Nicholas Nunley <nicholas.d.nunley@intel.com>
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_main.c     | 10 ++++++++++
>  drivers/net/ethernet/intel/iavf/iavf_virtchnl.c |  3 ++-
>  2 files changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c
> index 91818ba7c8a3..eda8ebb8e7b8 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_main.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_main.c
> @@ -1025,6 +1025,12 @@ void iavf_down(struct iavf_adapter *adapter)
>  		adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER;
>  		adapter->aq_required |= IAVF_FLAG_AQ_DEL_ADV_RSS_CFG;
>  		adapter->aq_required |= IAVF_FLAG_AQ_DISABLE_QUEUES;
> +		/* In case the queue configure or enable operations are still
> +		 * pending from when the interface was opened, make sure
> +		 * they're canceled here.
> +		 */
> +		adapter->aq_required &= ~IAVF_FLAG_AQ_ENABLE_QUEUES;
> +		adapter->aq_required &= ~IAVF_FLAG_AQ_CONFIGURE_QUEUES;
>  	}
>  
>  	mod_delayed_work(iavf_wq, &adapter->watchdog_task, 0);
> @@ -2325,8 +2331,12 @@ static void iavf_adminq_task(struct work_struct *work)
>  		if (ret || !v_op)
>  			break; /* No event to process or error cleaning ARQ */
>  
> +		while (test_and_set_bit(__IAVF_IN_CRITICAL_TASK,
> +					&adapter->crit_section))
> +			usleep_range(500, 1000);
>  		iavf_virtchnl_completion(adapter, v_op, v_ret, event.msg_buf,
>  					 event.msg_len);
> +		clear_bit(__IAVF_IN_CRITICAL_TASK, &adapter->crit_section);

This has potential to cause a deadlock. Please see my patch from about 3
months ago [1] which fixes the locking here and elsewhere. Also adds
a timeout and prints a warning just in case.
I'm glad you recognized the problem so I'd say it's finally time to give
that 3 months old patch the attention it deserves.

  Stefan

[1] https://patchwork.ozlabs.org/project/intel-wired-lan/patch/20210316100141.53551-1-sassmann at kpanic.de/


  reply	other threads:[~2021-06-10  6:14 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-04 16:53 [Intel-wired-lan] [PATCH net-next 01/15] iavf: correctly track whether the interface is running during resets Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 02/15] iavf: obtain the crit_section lock in iavf_open() immediately Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 03/15] iavf: obtain crit_section lock in iavf_close() immediately Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 04/15] iavf: wrap driver state change in crit_section lock Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 05/15] iavf: untangle any pending iavf_open() operations from iavf_close() Tony Nguyen
2021-06-10  6:14   ` Stefan Assmann [this message]
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 06/15] iavf: disable interrupts before disabling napi Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 07/15] iavf: Restore non MAC filters after link down Tony Nguyen
2021-11-02 16:36   ` Kuruvinakunnel, George
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 08/15] iavf: restore MSI state on reset Tony Nguyen
2021-11-03 19:41   ` Kuruvinakunnel, George
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 09/15] iavf: Fix carrier on state Tony Nguyen
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 10/15] iavf: Add change MTU message Tony Nguyen
2021-11-02  0:34   ` Kuruvinakunnel, George
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 11/15] iavf: Prevent changing static ITR values if adaptive moderation is on Tony Nguyen
2021-11-02  0:21   ` Kuruvinakunnel, George
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 12/15] iavf: Log info when VF is entering and leaving Allmulti mode Tony Nguyen
2021-11-02  0:47   ` Kuruvinakunnel, George
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 13/15] iavf: Set RSS LUT and key in reset handle path Tony Nguyen
2021-08-06  7:26   ` Jankowski, Konrad0
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 14/15] iavf: return errno code instead of status code Tony Nguyen
2021-11-17 10:27   ` Jankowski, Konrad0
2021-06-04 16:53 ` [Intel-wired-lan] [PATCH net-next 15/15] iavf: don't be so alarming Tony Nguyen
2021-11-03 19:45   ` Kuruvinakunnel, George

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=20210610061421.ztmmqwnoybprgyut@p50 \
    --to=sassmann@redhat.com \
    --cc=intel-wired-lan@osuosl.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.