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

Commit 77998437 authored by Shiva Krishna Pittala's avatar Shiva Krishna Pittala Committed by nshrivas
Browse files

qcacmn: Separate out nbuf map/unmap code

Put the nbuf map/unmap code under NBUF_MAP_UNMAP_DEBUG.
nbuf map/unmap debug will be enabled on WIN once
the nbuf map/unmap related false positives are fixed.

Change-Id: I6b62539d39664db3ff62411fe8632633f53488c8
CRs-Fixed: 2284128
parent 6151f79f
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -572,7 +572,7 @@ qdf_nbuf_set_send_complete_flag(qdf_nbuf_t buf, bool flag)
	__qdf_nbuf_set_send_complete_flag(buf, flag);
}

#ifdef NBUF_MEMORY_DEBUG
#ifdef NBUF_MAP_UNMAP_DEBUG
/**
 * qdf_nbuf_map_check_for_leaks() - check for nbut map leaks
 *
@@ -660,7 +660,7 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
	qdf_nbuf_unmap_nbytes_single_debug(osdev, buf, dir, nbytes, \
					   __FILE__, __LINE__)

#else /* NBUF_MEMORY_DEBUG */
#else /* NBUF_MAP_UNMAP_DEBUG */

static inline QDF_STATUS
qdf_nbuf_map(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
@@ -713,7 +713,7 @@ qdf_nbuf_unmap_nbytes_single(
{
	return __qdf_nbuf_unmap_nbytes_single(osdev, buf, dir, nbytes);
}
#endif /* NBUF_MEMORY_DEBUG */
#endif /* NBUF_MAP_UNMAP_DEBUG */

static inline void
qdf_nbuf_sync_for_cpu(qdf_device_t osdev, qdf_nbuf_t buf, qdf_dma_dir_t dir)
+32 −11
Original line number Diff line number Diff line
@@ -587,7 +587,9 @@ qdf_nbuf_history_add(qdf_nbuf_t nbuf, const char *file, uint32_t line,
	event->type = type;
	event->timestamp = qdf_get_log_timestamp();
}
#endif /* NBUF_MEMORY_DEBUG */

#ifdef NBUF_MAP_UNMAP_DEBUG
struct qdf_nbuf_map_metadata {
	struct hlist_node node;
	qdf_nbuf_t nbuf;
@@ -863,7 +865,35 @@ void qdf_nbuf_unmap_nbytes_single_debug(qdf_device_t osdev,
}

qdf_export_symbol(qdf_nbuf_unmap_nbytes_single_debug);
#endif /* NBUF_MEMORY_DEBUG */

static void qdf_nbuf_panic_on_free_if_mapped(qdf_nbuf_t nbuf, uint8_t *file,
					     uint32_t line)
{
	struct qdf_nbuf_map_metadata *meta;

	qdf_spin_lock_irqsave(&qdf_nbuf_map_lock);
	meta = qdf_nbuf_meta_get(nbuf);
	if (meta)
		QDF_DEBUG_PANIC(
			"Nbuf freed @ %s:%u while mapped from %s:%u",
			kbasename(file), line, meta->file, meta->line);
	qdf_spin_unlock_irqrestore(&qdf_nbuf_map_lock);
}
#else
static inline void qdf_nbuf_map_tracking_init(void)
{
}

static inline void qdf_nbuf_map_tracking_deinit(void)
{
}

static inline void qdf_nbuf_panic_on_free_if_mapped(qdf_nbuf_t nbuf,
						    uint8_t *file,
						    uint32_t line)
{
}
#endif /* NBUF_MAP_UNMAP_DEBUG */

/**
 * __qdf_nbuf_map() - map a buffer to local bus address space
@@ -2636,16 +2666,7 @@ void qdf_nbuf_free_debug(qdf_nbuf_t nbuf, uint8_t *file, uint32_t line)

	/* Remove SKB from internal QDF tracking table */
	if (qdf_likely(nbuf)) {
		struct qdf_nbuf_map_metadata *meta;

		qdf_spin_lock_irqsave(&qdf_nbuf_map_lock);
		meta = qdf_nbuf_meta_get(nbuf);
		if (meta)
			QDF_DEBUG_PANIC(
				"Nbuf freed @ %s:%u while mapped from %s:%u",
				kbasename(file), line, meta->file, meta->line);
		qdf_spin_unlock_irqrestore(&qdf_nbuf_map_lock);

		qdf_nbuf_panic_on_free_if_mapped(nbuf, file, line);
		qdf_net_buf_debug_delete_node(nbuf);
		qdf_nbuf_history_add(nbuf, file, line, QDF_NBUF_FREE);
	}