From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 04/21] iwlwifi: pcie: set iwl_trans->cfg later in the probe function
Date: Tue, 3 Sep 2019 10:36:57 +0300 [thread overview]
Message-ID: <20190903073714.32278-5-luca@coelho.fi> (raw)
In-Reply-To: <20190903073714.32278-1-luca@coelho.fi>
From: Luca Coelho <luciano.coelho@intel.com>
Instead of setting the cfg to iwl_trans already during allocation, set
it only later when we have had the time to decide which cfg to use.
This is part of the effort to be able to decide the cfg based on HW
revision and RF ID after iwl_trans_alloc() has been called.
For now, since we still have a bunch of code checking the HW revision
and the RF ID, we set iwl_trans->cfg early, even before we decided the
real cfg to use. We only use the trans configuration at this point,
so this is fine for now. In the future, the trans configuration will
be completely independent from the rest of the config structure, so
we'll be able to avoid this.
Additionally, we can't access the PRPH registers in iwl_trans_alloc()
anymore, so move the HW REV C-step check for family 8000 code later to
the probe function as well. This step is probably not necessary, but
if that's the case it should be removed separately later on.
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
.../net/wireless/intel/iwlwifi/iwl-trans.c | 2 --
.../net/wireless/intel/iwlwifi/iwl-trans.h | 1 -
drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 28 ++++++++++++++++
.../net/wireless/intel/iwlwifi/pcie/trans.c | 33 +++++--------------
4 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
index d47ba334c7ac..28bdc9a9617e 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.c
@@ -66,7 +66,6 @@
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
struct device *dev,
- const struct iwl_cfg *cfg,
const struct iwl_trans_ops *ops)
{
struct iwl_trans *trans;
@@ -84,7 +83,6 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
#endif
trans->dev = dev;
- trans->cfg = cfg;
trans->ops = ops;
trans->num_rx_queues = 1;
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
index 09ed0dd163eb..1b9bf9f94367 100644
--- a/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-trans.h
@@ -1240,7 +1240,6 @@ static inline bool iwl_trans_dbg_ini_valid(struct iwl_trans *trans)
*****************************************************/
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
struct device *dev,
- const struct iwl_cfg *cfg,
const struct iwl_trans_ops *ops);
void iwl_trans_free(struct iwl_trans *trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
index e5c59a241068..5ecfc27a4d25 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/drv.c
@@ -994,6 +994,7 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
const struct iwl_cfg *cfg = (struct iwl_cfg *)(ent->driver_data);
const struct iwl_cfg *cfg_7265d __maybe_unused = NULL;
struct iwl_trans *iwl_trans;
+ unsigned long flags;
int ret;
if (WARN_ONCE(!cfg->trans.csr, "CSR addresses aren't configured\n"))
@@ -1023,6 +1024,18 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID);
+ /*
+ * We can already set the cfg to iwl_trans here, because the
+ * only part we use at this point is the cfg_trans
+ * information. Once we decide the real cfg, we set it again
+ * (happens later in this function). TODO: this is only
+ * temporary, while we're sorting out this whole thing, but in
+ * the future it won't be necessary, because we will separate
+ * the trans configuration entirely from the rest of the
+ * config struct.
+ */
+ iwl_trans->cfg = cfg;
+
if (cfg == &iwlax210_2ax_cfg_so_hr_a0) {
if (iwl_trans->hw_rev == CSR_HW_REV_TYPE_TY) {
cfg = &iwlax210_2ax_cfg_ty_gf_a0;
@@ -1113,6 +1126,21 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
/* now set the real cfg we decided to use */
iwl_trans->cfg = cfg;
+ if (cfg->trans.device_family >= IWL_DEVICE_FAMILY_8000 &&
+ iwl_trans_grab_nic_access(iwl_trans, &flags)) {
+ u32 hw_step;
+
+ hw_step = iwl_read_umac_prph_no_grab(iwl_trans, WFPM_CTRL_REG);
+ hw_step |= ENABLE_WFPM;
+ iwl_write_umac_prph_no_grab(iwl_trans, WFPM_CTRL_REG, hw_step);
+ hw_step = iwl_read_prph_no_grab(iwl_trans, CNVI_AUX_MISC_CHIP);
+ hw_step = (hw_step >> HW_STEP_LOCATION_BITS) & 0xF;
+ if (hw_step == 0x3)
+ iwl_trans->hw_rev = (iwl_trans->hw_rev & 0xFFFFFFF3) |
+ (SILICON_C_STEP << 2);
+ iwl_trans_release_nic_access(iwl_trans, &flags);
+ }
+
pci_set_drvdata(pdev, iwl_trans);
iwl_trans->drv = iwl_drv_start(iwl_trans);
diff --git a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
index a1863b9bf1f6..c602e4914424 100644
--- a/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/intel/iwlwifi/pcie/trans.c
@@ -1578,14 +1578,16 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans,
return 0;
}
-static void iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
- struct iwl_trans *trans)
+static void
+iwl_pcie_set_interrupt_capa(struct pci_dev *pdev,
+ struct iwl_trans *trans,
+ const struct iwl_cfg_trans_params *cfg_trans)
{
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
int max_irqs, num_irqs, i, ret;
u16 pci_cmd;
- if (!trans->cfg->trans.mq_rx_supported)
+ if (!cfg_trans->mq_rx_supported)
goto enable_msi;
max_irqs = min_t(u32, num_online_cpus() + 2, IWL_MAX_RX_HW_QUEUES);
@@ -3384,10 +3386,11 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
if (cfg->trans.gen2)
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
- &pdev->dev, cfg, &trans_ops_pcie_gen2);
+ &pdev->dev, &trans_ops_pcie_gen2);
else
trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie),
- &pdev->dev, cfg, &trans_ops_pcie);
+ &pdev->dev, &trans_ops_pcie);
+
if (!trans)
return ERR_PTR(-ENOMEM);
@@ -3482,8 +3485,6 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
* in the old format.
*/
if (cfg->trans.device_family >= IWL_DEVICE_FAMILY_8000) {
- unsigned long flags;
-
trans->hw_rev = (trans->hw_rev & 0xfff0) |
(CSR_HW_REV_STEP(trans->hw_rev << 2) << 2);
@@ -3501,27 +3502,11 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
if (ret)
goto out_no_pci;
- if (iwl_trans_grab_nic_access(trans, &flags)) {
- u32 hw_step;
-
- hw_step = iwl_read_umac_prph_no_grab(trans,
- WFPM_CTRL_REG);
- hw_step |= ENABLE_WFPM;
- iwl_write_umac_prph_no_grab(trans, WFPM_CTRL_REG,
- hw_step);
- hw_step = iwl_read_prph_no_grab(trans,
- CNVI_AUX_MISC_CHIP);
- hw_step = (hw_step >> HW_STEP_LOCATION_BITS) & 0xF;
- if (hw_step == 0x3)
- trans->hw_rev = (trans->hw_rev & 0xFFFFFFF3) |
- (SILICON_C_STEP << 2);
- iwl_trans_release_nic_access(trans, &flags);
- }
}
IWL_DEBUG_INFO(trans, "HW REV: 0x%0x\n", trans->hw_rev);
- iwl_pcie_set_interrupt_capa(pdev, trans);
+ iwl_pcie_set_interrupt_capa(pdev, trans, &cfg->trans);
trans->hw_id = (pdev->device << 16) + pdev->subsystem_device;
snprintf(trans->hw_id_str, sizeof(trans->hw_id_str),
"PCI ID: 0x%04X:0x%04X", pdev->device, pdev->subsystem_device);
--
2.23.0.rc1
next prev parent reply other threads:[~2019-09-03 7:37 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-03 7:36 [PATCH 00/21] iwlwifi: updates intended for v5.4 2019-09-03 Luca Coelho
2019-09-03 7:36 ` [PATCH 01/21] iwlwifi: separate elements from cfg that are needed by trans_alloc Luca Coelho
2019-09-03 7:36 ` [PATCH 02/21] iwlwifi: pcie: use the cfg we passed to iwl_trans_pcie_alloc() Luca Coelho
2019-09-03 7:36 ` [PATCH 03/21] iwlwifi: pcie: move some cfg mangling from trans_pcie_alloc to probe Luca Coelho
2019-09-03 7:36 ` Luca Coelho [this message]
2019-09-03 7:36 ` [PATCH 05/21] iwlwifi: pass the iwl_config_trans_params when needed Luca Coelho
2019-09-03 7:36 ` [PATCH 06/21] iwlwifi: add a pointer to the trans_cfg directly in trans Luca Coelho
2019-09-03 7:37 ` [PATCH 07/21] iwlwifi: pass the iwl_trans instead of cfg to some functions Luca Coelho
2019-09-03 7:37 ` [PATCH 08/21] iwlwifi: always access the trans configuration via trans Luca Coelho
2019-09-03 7:37 ` [PATCH 09/21] iwlwifi: fix warning iwl-trans.h is included more than once Luca Coelho
2019-09-03 7:37 ` [PATCH 10/21] iwlwifi: add support for suspend-resume flow for new device generation Luca Coelho
2019-09-03 7:37 ` [PATCH 11/21] iwlwifi: add sta_id to WOWLAN_CONFIG_CMD Luca Coelho
2019-09-03 7:37 ` [PATCH 12/21] iwlwifi: mvm: drop BA sessions on too many old-SN frames Luca Coelho
2019-09-03 7:37 ` [PATCH 13/21] iwlwifi: mvm: handle BAR_FRAME_RELEASE (0xc2) notification Luca Coelho
2019-09-03 7:37 ` [PATCH 14/21] iwlwifi: mvm: add support for single antenna diversity Luca Coelho
2019-09-03 7:37 ` [PATCH 15/21] iwlwifi: mvm: don't log un-decrypted frames Luca Coelho
2019-09-03 7:37 ` [PATCH 16/21] iwlwifi: add iwl_tlv_array_len() Luca Coelho
2019-09-03 7:37 ` [PATCH 17/21] iwlwifi: dbg_ini: remove apply point, switch to time point API Luca Coelho
2019-09-03 7:37 ` [PATCH 18/21] iwlwifi: fw api: add DRAM buffer allocation command Luca Coelho
2019-09-03 7:37 ` [PATCH 19/21] iwlwifi: dbg_ini: fix dump structs doc Luca Coelho
2019-09-03 7:37 ` [PATCH 20/21] iwlwifi: dbg_ini: remove periodic trigger Luca Coelho
2019-09-03 7:37 ` [PATCH 21/21] iwlwifi: dbg: remove iwl_fw_cancel_dumps function Luca Coelho
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=20190903073714.32278-5-luca@coelho.fi \
--to=luca@coelho.fi \
--cc=kvalo@codeaurora.org \
--cc=linux-wireless@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