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

Commit a2c15fa4 authored by Rabin Vincent's avatar Rabin Vincent Committed by Dan Williams
Browse files

DMAENGINE: ste_dma40: fix desc_get



Fix desc_get to alloc a descriptor from the cache if the ones in the
list are waiting for the ack.  Also, memzero the descriptor when
allocated from the list to ensure all fields are cleared.

Acked-by: default avatarJonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: default avatarRabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent c6134c96
Loading
Loading
Loading
Loading
+14 −9
Original line number Original line Diff line number Diff line
@@ -419,24 +419,29 @@ static void d40_desc_remove(struct d40_desc *d40d)


static struct d40_desc *d40_desc_get(struct d40_chan *d40c)
static struct d40_desc *d40_desc_get(struct d40_chan *d40c)
{
{
	struct d40_desc *desc = NULL;

	if (!list_empty(&d40c->client)) {
		struct d40_desc *d;
		struct d40_desc *d;
		struct d40_desc *_d;
		struct d40_desc *_d;


	if (!list_empty(&d40c->client)) {
		list_for_each_entry_safe(d, _d, &d40c->client, node)
		list_for_each_entry_safe(d, _d, &d40c->client, node)
			if (async_tx_test_ack(&d->txd)) {
			if (async_tx_test_ack(&d->txd)) {
				d40_pool_lli_free(d);
				d40_pool_lli_free(d);
				d40_desc_remove(d);
				d40_desc_remove(d);
				desc = d;
				memset(desc, 0, sizeof(*desc));
				break;
				break;
			}
			}
	} else {
		d = kmem_cache_alloc(d40c->base->desc_slab, GFP_NOWAIT);
		if (d != NULL) {
			memset(d, 0, sizeof(struct d40_desc));
			INIT_LIST_HEAD(&d->node);
		}
	}
	}
	return d;

	if (!desc)
		desc = kmem_cache_zalloc(d40c->base->desc_slab, GFP_NOWAIT);

	if (desc)
		INIT_LIST_HEAD(&desc->node);

	return desc;
}
}


static void d40_desc_free(struct d40_chan *d40c, struct d40_desc *d40d)
static void d40_desc_free(struct d40_chan *d40c, struct d40_desc *d40d)