Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4fd442db authored by Emmanuel Grumbach's avatar Emmanuel Grumbach Committed by Johannes Berg
Browse files

iwlwifi: virtualize SRAM access



Different transports implement the access to the SRAM in
different ways. Virtualize it.

Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 7a65d170
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -157,7 +157,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
	sram = priv->dbgfs_sram_offset & ~0x3;
	sram = priv->dbgfs_sram_offset & ~0x3;


	/* read the first u32 from sram */
	/* read the first u32 from sram */
	val = iwl_read_targ_mem(priv->trans, sram);
	val = iwl_trans_read_mem32(priv->trans, sram);


	for (; len; len--) {
	for (; len; len--) {
		/* put the address at the start of every line */
		/* put the address at the start of every line */
@@ -176,7 +176,7 @@ static ssize_t iwl_dbgfs_sram_read(struct file *file,
		if (++offset == 4) {
		if (++offset == 4) {
			sram += 4;
			sram += 4;
			offset = 0;
			offset = 0;
			val = iwl_read_targ_mem(priv->trans, sram);
			val = iwl_trans_read_mem32(priv->trans, sram);
		}
		}


		/* put in extra spaces and split lines for human readability */
		/* put in extra spaces and split lines for human readability */
+1 −1
Original line number Original line Diff line number Diff line
@@ -479,7 +479,7 @@ static int iwlagn_mac_resume(struct ieee80211_hw *hw)
			}
			}


			if (priv->wowlan_sram)
			if (priv->wowlan_sram)
				_iwl_read_targ_mem_dwords(
				iwl_trans_read_mem(
				      priv->trans, 0x800000,
				      priv->trans, 0x800000,
				      priv->wowlan_sram,
				      priv->wowlan_sram,
				      img->sec[IWL_UCODE_SECTION_DATA].len / 4);
				      img->sec[IWL_UCODE_SECTION_DATA].len / 4);
+7 −6
Original line number Original line Diff line number Diff line
@@ -408,7 +408,8 @@ static void iwl_continuous_event_trace(struct iwl_priv *priv)


	base = priv->device_pointers.log_event_table;
	base = priv->device_pointers.log_event_table;
	if (iwlagn_hw_valid_rtc_data_addr(base)) {
	if (iwlagn_hw_valid_rtc_data_addr(base)) {
		iwl_read_targ_mem_bytes(priv->trans, base, &read, sizeof(read));
		iwl_trans_read_mem_bytes(priv->trans, base,
					 &read, sizeof(read));
		capacity = read.capacity;
		capacity = read.capacity;
		mode = read.mode;
		mode = read.mode;
		num_wraps = read.wrap_counter;
		num_wraps = read.wrap_counter;
@@ -1627,7 +1628,7 @@ static void iwl_dump_nic_error_log(struct iwl_priv *priv)
	}
	}


	/*TODO: Update dbgfs with ISR error stats obtained below */
	/*TODO: Update dbgfs with ISR error stats obtained below */
	iwl_read_targ_mem_bytes(trans, base, &table, sizeof(table));
	iwl_trans_read_mem_bytes(trans, base, &table, sizeof(table));


	if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
	if (ERROR_START_OFFSET <= table.valid * ERROR_ELEM_SIZE) {
		IWL_ERR(trans, "Start IWL Error Log Dump:\n");
		IWL_ERR(trans, "Start IWL Error Log Dump:\n");
@@ -1835,10 +1836,10 @@ int iwl_dump_nic_event_log(struct iwl_priv *priv, bool full_log,
	}
	}


	/* event log header */
	/* event log header */
	capacity = iwl_read_targ_mem(trans, base);
	capacity = iwl_trans_read_mem32(trans, base);
	mode = iwl_read_targ_mem(trans, base + (1 * sizeof(u32)));
	mode = iwl_trans_read_mem32(trans, base + (1 * sizeof(u32)));
	num_wraps = iwl_read_targ_mem(trans, base + (2 * sizeof(u32)));
	num_wraps = iwl_trans_read_mem32(trans, base + (2 * sizeof(u32)));
	next_entry = iwl_read_targ_mem(trans, base + (3 * sizeof(u32)));
	next_entry = iwl_trans_read_mem32(trans, base + (3 * sizeof(u32)));


	if (capacity > logsize) {
	if (capacity > logsize) {
		IWL_ERR(priv, "Log capacity %d is bogus, limit to %d "
		IWL_ERR(priv, "Log capacity %d is bogus, limit to %d "
+0 −56
Original line number Original line Diff line number Diff line
@@ -226,59 +226,3 @@ void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask)
	spin_unlock_irqrestore(&trans->reg_lock, flags);
	spin_unlock_irqrestore(&trans->reg_lock, flags);
}
}
EXPORT_SYMBOL_GPL(iwl_clear_bits_prph);
EXPORT_SYMBOL_GPL(iwl_clear_bits_prph);

void _iwl_read_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
			       void *buf, int dwords)
{
	unsigned long flags;
	int offs;
	u32 *vals = buf;

	spin_lock_irqsave(&trans->reg_lock, flags);
	if (likely(iwl_trans_grab_nic_access(trans, false))) {
		iwl_write32(trans, HBUS_TARG_MEM_RADDR, addr);
		for (offs = 0; offs < dwords; offs++)
			vals[offs] = iwl_read32(trans, HBUS_TARG_MEM_RDAT);
		iwl_trans_release_nic_access(trans);
	}
	spin_unlock_irqrestore(&trans->reg_lock, flags);
}
EXPORT_SYMBOL_GPL(_iwl_read_targ_mem_dwords);

u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr)
{
	u32 value;

	_iwl_read_targ_mem_dwords(trans, addr, &value, 1);

	return value;
}
EXPORT_SYMBOL_GPL(iwl_read_targ_mem);

int _iwl_write_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
			       const void *buf, int dwords)
{
	unsigned long flags;
	int offs, result = 0;
	const u32 *vals = buf;

	spin_lock_irqsave(&trans->reg_lock, flags);
	if (likely(iwl_trans_grab_nic_access(trans, false))) {
		iwl_write32(trans, HBUS_TARG_MEM_WADDR, addr);
		for (offs = 0; offs < dwords; offs++)
			iwl_write32(trans, HBUS_TARG_MEM_WDAT, vals[offs]);
		iwl_trans_release_nic_access(trans);
	} else {
		result = -EBUSY;
	}
	spin_unlock_irqrestore(&trans->reg_lock, flags);

	return result;
}
EXPORT_SYMBOL_GPL(_iwl_write_targ_mem_dwords);

int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val)
{
	return _iwl_write_targ_mem_dwords(trans, addr, &val, 1);
}
EXPORT_SYMBOL_GPL(iwl_write_targ_mem);
+0 −15
Original line number Original line Diff line number Diff line
@@ -74,19 +74,4 @@ void iwl_set_bits_mask_prph(struct iwl_trans *trans, u32 ofs,
			    u32 bits, u32 mask);
			    u32 bits, u32 mask);
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);
void iwl_clear_bits_prph(struct iwl_trans *trans, u32 ofs, u32 mask);


void _iwl_read_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
			       void *buf, int dwords);

#define iwl_read_targ_mem_bytes(trans, addr, buf, bufsize)	\
	do {							\
		BUILD_BUG_ON((bufsize) % sizeof(u32));		\
		_iwl_read_targ_mem_dwords(trans, addr, buf,	\
					  (bufsize) / sizeof(u32));\
	} while (0)

int _iwl_write_targ_mem_dwords(struct iwl_trans *trans, u32 addr,
			       const void *buf, int dwords);

u32 iwl_read_targ_mem(struct iwl_trans *trans, u32 addr);
int iwl_write_targ_mem(struct iwl_trans *trans, u32 addr, u32 val);
#endif
#endif
Loading