mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Grumbach, Emmanuel" <emmanuel.grumbach@intel.com>
To: "Luis R. Rodriguez" <mcgrof@kernel.org>,
	"Berg, Johannes" <johannes.berg@intel.com>,
	"Coelho, Luciano" <luciano.coelho@intel.com>,
	"tj@kernel.org" <tj@kernel.org>,
	"arjan@linux.intel.com" <arjan@linux.intel.com>,
	"ming.lei@canonical.com" <ming.lei@canonical.com>,
	"zajec5@gmail.com" <zajec5@gmail.com>
Cc: "jeyu@redhat.com" <jeyu@redhat.com>,
	"rusty@rustcorp.com.au" <rusty@rustcorp.com.au>,
	"pmladek@suse.com" <pmladek@suse.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	linuxwifi <linuxwifi@intel.com>,
	"linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [RFC 2/5] iwlwifi: fix request_module() use
Date: Sun, 19 Feb 2017 09:47:59 +0000	[thread overview]
Message-ID: <0BA3FCBA62E2DC44AF3030971E174FB3A8F4AE27@hasmsx107.ger.corp.intel.com> (raw)
In-Reply-To: <20170217020903.6370-3-mcgrof@kernel.org>

> 
> The return value of request_module() being 0 does not mean that the driver
> which was requested has loaded. To properly check that the driver was
> loaded each driver can use internal mechanisms to vet the driver is now
> present. The helper try_then_request_module() was added to help with
> this, allowing drivers to specify their own validation as the first argument.
> 
> On iwlwifi the use case is a bit more complicated given that the value we
> need to check for is protected with a mutex later used on the
> module_init() of the module we are asking for. If we were to lock and
> request_module() we'd deadlock. iwlwifi needs its own wrapper then so it
> can handle its special locking requirements.
> 
> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>

I don't see the problem with the current code. We don't assume that everything has been
loaded immediately after request_module returns. We just free the intermediate firmware
structures that won't be using anymore. What happens here is that after request_module
returns, we patiently wait until it is loaded, and when that happens, iwl{d,m}vm's init function
will be called. That one is the one that continues the flow by calling:

	ret = iwl_opmode_register("iwlmvm", &iwl_mvm_ops);

(for the iwlmvm case).

Where am I wrong here?


> ---
>  drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 34 ++++++++++++++++++++---
> -----
>  1 file changed, 25 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
> b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
> index e198d6f5fcea..6beb92d19ea7 100644
> --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
> +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c
> @@ -1231,6 +1231,29 @@ static void _iwl_op_mode_stop(struct iwl_drv
> *drv)
>  	}
>  }
> 
> +static void iwlwifi_try_load_op(struct iwlwifi_opmode_table *op,
> +				struct iwl_drv *drv)
> +{
> +	int ret = 0;
> +
> +	ret = request_module("%s", op->name);
> +	if (ret)
> +		goto out;
> +
> +	mutex_lock(&iwlwifi_opmode_table_mtx);
> +	if (!op->ops)
> +		ret = -ENOENT;
> +	mutex_unlock(&iwlwifi_opmode_table_mtx);
> +
> +out:
> +#ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
> +	if (ret)
> +		IWL_ERR(drv,
> +			"failed to load module %s (error %d), is dynamic
> loading enabled?\n",
> +			op->name, ret);
> +#endif
> +}
> +
>  /**
>   * iwl_req_fw_callback - callback when firmware was loaded
>   *
> @@ -1471,15 +1494,8 @@ static void iwl_req_fw_callback(const struct
> firmware *ucode_raw, void *context)
>  	 * else from proceeding if the module fails to load
>  	 * or hangs loading.
>  	 */
> -	if (load_module) {
> -		err = request_module("%s", op->name);
> -#ifdef CONFIG_IWLWIFI_OPMODE_MODULAR
> -		if (err)
> -			IWL_ERR(drv,
> -				"failed to load module %s (error %d), is
> dynamic loading enabled?\n",
> -				op->name, err);
> -#endif
> -	}
> +	if (load_module)
> +		iwlwifi_try_load_op(op, drv);
>  	goto free;
> 
>   try_again:
> --
> 2.11.0

  reply	other threads:[~2017-02-19  9:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-17  2:08 [RFC 0/5] iwlwifi: enhance final opmode work Luis R. Rodriguez
2017-02-17  2:08 ` [RFC 1/5] iwlwifi: fix drv cleanup on opmode registration failure Luis R. Rodriguez
2017-02-19  9:16   ` Grumbach, Emmanuel
2017-02-20 17:32     ` Luis R. Rodriguez
2017-02-17  2:09 ` [RFC 2/5] iwlwifi: fix request_module() use Luis R. Rodriguez
2017-02-19  9:47   ` Grumbach, Emmanuel [this message]
2017-02-21  2:23     ` Luis R. Rodriguez
2017-02-21  7:16       ` Grumbach, Emmanuel
2017-02-21 18:15         ` Luis R. Rodriguez
2017-02-21 20:17           ` Luis R. Rodriguez
2017-02-22  0:18             ` Luis R. Rodriguez
2017-02-22  2:09               ` [PATCH v2 0/2] iwlwifi: corner case fix and request module changes Luis R. Rodriguez
2017-02-22  2:09                 ` [PATCH v2 1/2] iwlwifi: fix drv cleanup on opmode registration failure Luis R. Rodriguez
2017-02-22  2:09                 ` [PATCH v2 2/2] iwlwifi: simplify requesting ops module Luis R. Rodriguez
2017-02-22  2:10               ` [PATCH v2 0/2] iwlwifi: share opmode start code Luis R. Rodriguez
2017-02-22  2:10                 ` [PATCH v2 1/2] iwlwifi: share opmode start work code Luis R. Rodriguez
2017-02-22  2:10                 ` [PATCH v2 2/2] iwlwifi: convert final opmode work into a workqueue Luis R. Rodriguez
2017-02-17  2:09 ` [RFC 3/5] iwlwifi: share opmode start work code Luis R. Rodriguez
2017-02-17  2:09 ` [RFC 4/5] iwlwifi: move opmode loading to shared routine Luis R. Rodriguez
2017-02-17  2:09 ` [RFC 5/5] iwlwifi: convert final opmode work into a workqueue Luis R. Rodriguez
2017-03-01  7:12 ` [RFC 0/5] iwlwifi: enhance final opmode work Johannes Berg

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=0BA3FCBA62E2DC44AF3030971E174FB3A8F4AE27@hasmsx107.ger.corp.intel.com \
    --to=emmanuel.grumbach@intel.com \
    --cc=arjan@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeyu@redhat.com \
    --cc=johannes.berg@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxwifi@intel.com \
    --cc=luciano.coelho@intel.com \
    --cc=mcgrof@kernel.org \
    --cc=ming.lei@canonical.com \
    --cc=pmladek@suse.com \
    --cc=rusty@rustcorp.com.au \
    --cc=tj@kernel.org \
    --cc=zajec5@gmail.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

all inboxes | Powered by JetHome®