Commit fda1bd0d authored by Mordechay Goodstein's avatar Mordechay Goodstein Committed by Luca Coelho
Browse files

iwlwifi: iwl-trans: move all txcmd init to trans alloc



txcmd fields is not directly related to the PCIe transport,
so move to the common iwl_trans_alloc function.

Signed-off-by: default avatarMordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200924162105.862ef88d1ab2.Iba220a962b5d6d05c030b9275d97a89202d055dc@changeid


Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
parent ccca2cb4
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -5,9 +5,8 @@
 *
 * GPL LICENSE SUMMARY
 *
 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
 * Copyright(c) 2018 - 2019 Intel Corporation
 * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
@@ -27,9 +26,8 @@
 *
 * BSD LICENSE
 *
 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
 * Copyright(c) 2018 - 2019 Intel Corporation
 * Copyright(c) 2012 - 2014, 2018 - 2020 Intel Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
@@ -61,6 +59,7 @@

#ifndef __iwl_fw_api_tx_h__
#define __iwl_fw_api_tx_h__
#include <linux/ieee80211.h>

/**
 * enum iwl_tx_flags - bitmasks for tx_flags in TX command
+25 −3
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
 *
 * Copyright(c) 2015 Intel Mobile Communications GmbH
 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
 * Copyright(c) 2019 - 2020 Intel Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
@@ -28,6 +29,7 @@
 *
 * Copyright(c) 2015 Intel Mobile Communications GmbH
 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
 * Copyright(c) 2019 - 2020 Intel Corporation
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
@@ -60,6 +62,7 @@
#include <linux/kernel.h>
#include <linux/bsearch.h>

#include "fw/api/tx.h"
#include "iwl-trans.h"
#include "iwl-drv.h"
#include "iwl-fh.h"
@@ -67,10 +70,10 @@
struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
				  struct device *dev,
				  const struct iwl_trans_ops *ops,
				  unsigned int cmd_pool_size,
				  unsigned int cmd_pool_align)
				  const struct iwl_cfg_trans_params *cfg_trans)
{
	struct iwl_trans *trans;
	int txcmd_size, txcmd_align;
#ifdef CONFIG_LOCKDEP
	static struct lock_class_key __key;
#endif
@@ -79,6 +82,25 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
	if (!trans)
		return NULL;

	trans->trans_cfg = cfg_trans;
	if (!cfg_trans->gen2) {
		txcmd_size = sizeof(struct iwl_tx_cmd);
		txcmd_align = sizeof(void *);
	} else if (cfg_trans->device_family < IWL_DEVICE_FAMILY_AX210) {
		txcmd_size = sizeof(struct iwl_tx_cmd_gen2);
		txcmd_align = 64;
	} else {
		txcmd_size = sizeof(struct iwl_tx_cmd_gen3);
		txcmd_align = 128;
	}

	txcmd_size += sizeof(struct iwl_cmd_header);
	txcmd_size += 36; /* biggest possible 802.11 header */

	/* Ensure device TX cmd cannot reach/cross a page boundary in gen2 */
	if (WARN_ON(cfg_trans->gen2 && txcmd_size >= txcmd_align))
		return ERR_PTR(-EINVAL);

#ifdef CONFIG_LOCKDEP
	lockdep_init_map(&trans->sync_cmd_lockdep_map, "sync_cmd_lockdep_map",
			 &__key, 0);
@@ -92,7 +114,7 @@ struct iwl_trans *iwl_trans_alloc(unsigned int priv_size,
		 "iwl_cmd_pool:%s", dev_name(trans->dev));
	trans->dev_cmd_pool =
		kmem_cache_create(trans->dev_cmd_pool_name,
				  cmd_pool_size, cmd_pool_align,
				  txcmd_size, txcmd_align,
				  SLAB_HWCACHE_ALIGN, NULL);
	if (!trans->dev_cmd_pool)
		return NULL;
+3 −4
Original line number Diff line number Diff line
@@ -1438,8 +1438,7 @@ 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_trans_ops *ops,
				  unsigned int cmd_pool_size,
				  unsigned int cmd_pool_align);
			  const struct iwl_cfg_trans_params *cfg_trans);
void iwl_trans_free(struct iwl_trans *trans);

/*****************************************************
+0 −3
Original line number Diff line number Diff line
@@ -1002,9 +1002,6 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)

	trans_pcie = IWL_TRANS_GET_PCIE_TRANS(iwl_trans);

	/* the trans_cfg should never change, so set it now */
	iwl_trans->trans_cfg = trans;

	iwl_trans->hw_rf_id = iwl_read32(iwl_trans, CSR_HW_RF_ID);

	for (i = 0; i < ARRAY_SIZE(iwl_dev_info_table); i++) {
+3 −19
Original line number Diff line number Diff line
@@ -3502,34 +3502,18 @@ struct iwl_trans *iwl_trans_pcie_alloc(struct pci_dev *pdev,
{
	struct iwl_trans_pcie *trans_pcie;
	struct iwl_trans *trans;
	int ret, addr_size, txcmd_size, txcmd_align;
	int ret, addr_size;
	const struct iwl_trans_ops *ops = &trans_ops_pcie_gen2;

	if (!cfg_trans->gen2) {
	if (!cfg_trans->gen2)
		ops = &trans_ops_pcie;
		txcmd_size = sizeof(struct iwl_tx_cmd);
		txcmd_align = sizeof(void *);
	} else if (cfg_trans->device_family < IWL_DEVICE_FAMILY_AX210) {
		txcmd_size = sizeof(struct iwl_tx_cmd_gen2);
		txcmd_align = 64;
	} else {
		txcmd_size = sizeof(struct iwl_tx_cmd_gen3);
		txcmd_align = 128;
	}

	txcmd_size += sizeof(struct iwl_cmd_header);
	txcmd_size += 36; /* biggest possible 802.11 header */

	/* Ensure device TX cmd cannot reach/cross a page boundary in gen2 */
	if (WARN_ON(cfg_trans->gen2 && txcmd_size >= txcmd_align))
		return ERR_PTR(-EINVAL);

	ret = pcim_enable_device(pdev);
	if (ret)
		return ERR_PTR(ret);

	trans = iwl_trans_alloc(sizeof(struct iwl_trans_pcie), &pdev->dev, ops,
				txcmd_size, txcmd_align);
				cfg_trans);
	if (!trans)
		return ERR_PTR(-ENOMEM);