This patch generalize the use of shared memory, as size of this memory is
now allocated and freed by handlers, and also changes the location of those
actions for better resource management
Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
spin_lock_init(&priv->hcmd_lock);
spin_lock_init(&priv->lq_mngr.lock);
spin_lock_init(&priv->hcmd_lock);
spin_lock_init(&priv->lq_mngr.lock);
- priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
- sizeof(struct iwl4965_shared),
- &priv->shared_phys);
-
- if (!priv->shared_virt) {
- ret = -ENOMEM;
- goto err;
- }
-
- memset(priv->shared_virt, 0, sizeof(struct iwl4965_shared));
-
-
for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
for (i = 0; i < IWL_IBSS_MAC_HASH_SIZE; i++)
INIT_LIST_HEAD(&priv->ibss_mac_hash[i]);
&priv->eeprom[EEPROM_4965_BOARD_PBA]);
}
&priv->eeprom[EEPROM_4965_BOARD_PBA]);
}
+static int iwl4965_alloc_shared_mem(struct iwl_priv *priv)
+{
+ priv->shared_virt = pci_alloc_consistent(priv->pci_dev,
+ sizeof(struct iwl4965_shared),
+ &priv->shared_phys);
+ if (!priv->shared_virt)
+ return -ENOMEM;
+
+ memset(priv->shared_virt, 0, sizeof(struct iwl4965_shared));
+
+ return 0;
+}
+
+static void iwl4965_free_shared_mem(struct iwl_priv *priv)
+{
+ if (priv->shared_virt)
+ pci_free_consistent(priv->pci_dev,
+ sizeof(struct iwl4965_shared),
+ priv->shared_virt,
+ priv->shared_phys);
+}
+
#define IWL_TX_CRC_SIZE 4
#define IWL_TX_DELIMITER_SIZE 4
#define IWL_TX_CRC_SIZE 4
#define IWL_TX_DELIMITER_SIZE 4
static struct iwl_lib_ops iwl4965_lib = {
.init_drv = iwl4965_init_drv,
.set_hw_params = iwl4965_hw_set_hw_params,
static struct iwl_lib_ops iwl4965_lib = {
.init_drv = iwl4965_init_drv,
.set_hw_params = iwl4965_hw_set_hw_params,
+ .alloc_shared_mem = iwl4965_alloc_shared_mem,
+ .free_shared_mem = iwl4965_free_shared_mem,
.txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl,
.hw_nic_init = iwl4965_hw_nic_init,
.is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr,
.txq_update_byte_cnt_tbl = iwl4965_txq_update_byte_cnt_tbl,
.hw_nic_init = iwl4965_hw_nic_init,
.is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr,
int (*init_drv)(struct iwl_priv *priv);
/* set hw dependant perameters */
int (*set_hw_params)(struct iwl_priv *priv);
int (*init_drv)(struct iwl_priv *priv);
/* set hw dependant perameters */
int (*set_hw_params)(struct iwl_priv *priv);
+ /* ucode shared memory */
+ int (*alloc_shared_mem)(struct iwl_priv *priv);
+ void (*free_shared_mem)(struct iwl_priv *priv);
void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv,
struct iwl4965_tx_queue *txq,
u16 byte_cnt);
void (*txq_update_byte_cnt_tbl)(struct iwl_priv *priv,
struct iwl4965_tx_queue *txq,
u16 byte_cnt);
*
******************************************************************************/
*
******************************************************************************/
-static void iwl4965_unset_hw_params(struct iwl_priv *priv)
-{
- if (priv->shared_virt)
- pci_free_consistent(priv->pci_dev,
- sizeof(struct iwl4965_shared),
- priv->shared_virt,
- priv->shared_phys);
-}
-
/**
* iwl4965_supported_rate_to_ie - fill in the supported rate in IE field
*
/**
* iwl4965_supported_rate_to_ie - fill in the supported rate in IE field
*
iwl4965_hw_nic_stop_master(priv);
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
iwl4965_hw_nic_reset(priv);
iwl4965_hw_nic_stop_master(priv);
iwl_set_bit(priv, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
iwl4965_hw_nic_reset(priv);
+ priv->cfg->ops->lib->free_shared_mem(priv);
exit:
memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp));
exit:
memset(&priv->card_alive, 0, sizeof(struct iwl4965_alive_resp));
iwl_rfkill_set_hw_state(priv);
iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
iwl_rfkill_set_hw_state(priv);
iwl_write32(priv, CSR_INT, 0xFFFFFFFF);
+ ret = priv->cfg->ops->lib->alloc_shared_mem(priv);
+ if (ret) {
+ IWL_ERROR("Unable to allocate shared memory\n");
+ return ret;
+ }
+
ret = priv->cfg->ops->lib->hw_nic_init(priv);
if (ret) {
IWL_ERROR("Unable to init nic\n");
ret = priv->cfg->ops->lib->hw_nic_init(priv);
if (ret) {
IWL_ERROR("Unable to init nic\n");
err = iwl_setup(priv);
if (err)
err = iwl_setup(priv);
if (err)
- goto out_unset_hw_params;
/* At this point both hw and priv are initialized. */
/**********************************
/* At this point both hw and priv are initialized. */
/**********************************
err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
if (err) {
IWL_ERROR("failed to create sysfs device attributes\n");
err = sysfs_create_group(&pdev->dev.kobj, &iwl4965_attribute_group);
if (err) {
IWL_ERROR("failed to create sysfs device attributes\n");
- goto out_unset_hw_params;
}
err = iwl_dbgfs_register(priv, DRV_NAME);
}
err = iwl_dbgfs_register(priv, DRV_NAME);
out_remove_sysfs:
sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
out_remove_sysfs:
sysfs_remove_group(&pdev->dev.kobj, &iwl4965_attribute_group);
- out_unset_hw_params:
- iwl4965_unset_hw_params(priv);
out_free_eeprom:
iwl_eeprom_free(priv);
out_iounmap:
out_free_eeprom:
iwl_eeprom_free(priv);
out_iounmap:
iwl4965_rx_queue_free(priv, &priv->rxq);
iwl4965_hw_txq_ctx_free(priv);
iwl4965_rx_queue_free(priv, &priv->rxq);
iwl4965_hw_txq_ctx_free(priv);
- iwl4965_unset_hw_params(priv);
iwlcore_clear_stations_table(priv);
iwl_eeprom_free(priv);
iwlcore_clear_stations_table(priv);
iwl_eeprom_free(priv);