Skip to content

Commit 8797972

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: remove command info pool
The ipa_cmd_info structure now contains only one field, and it's an enumerated type whose values all fit in 8 bits. Currently we'll never use more than 8 TREs in a command transaction, and we can represent that number of command opcodes in the same space as a 64 bit pointer to an ipa_cmd_info structure. Define IPA_COMMAND_TRANS_TRE_MAX as the maximum number of TREs that can be in a command transaction. Replace the info pointer in a transaction with a fixed-size array named cmd_opcode[] of that many bytes. Store the opcode in this array when adding a command TRE to a transaction, as was done previously for the info array. This makes the ipa_cmd_info unused, so get rid of it. When committing an immediate command transaction, use the channel's Boolean command flag to determine whether to fill in the opcode, which will be taken (as before) from the array in the transaction. This makes the command info pool unnecessary, so get rid of it. Signed-off-by: Alex Elder <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4de284b commit 8797972

File tree

5 files changed

+18
-50
lines changed

5 files changed

+18
-50
lines changed

drivers/net/ipa/gsi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ struct gsi_trans_info {
8484
struct gsi_trans_pool pool; /* transaction pool */
8585
struct gsi_trans_pool sg_pool; /* scatterlist pool */
8686
struct gsi_trans_pool cmd_pool; /* command payload DMA pool */
87-
struct gsi_trans_pool info_pool;/* command information pool */
8887
struct gsi_trans **map; /* TRE -> transaction map */
8988

9089
spinlock_t spinlock; /* protects updates to the lists */

drivers/net/ipa/gsi_trans.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
436436
sg_dma_address(sg) = addr;
437437
sg_dma_len(sg) = size;
438438

439-
trans->info[which].opcode = opcode;
439+
trans->cmd_opcode[which] = opcode;
440440
}
441441

442442
/* Add a page transfer to a transaction. It will fill the only TRE. */
@@ -552,10 +552,10 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
552552
struct gsi_ring *ring = &channel->tre_ring;
553553
enum ipa_cmd_opcode opcode = IPA_CMD_NONE;
554554
bool bei = channel->toward_ipa;
555-
struct ipa_cmd_info *info;
556555
struct gsi_tre *dest_tre;
557556
struct scatterlist *sg;
558557
u32 byte_count = 0;
558+
u8 *cmd_opcode;
559559
u32 avail;
560560
u32 i;
561561

@@ -566,7 +566,7 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
566566
* If there is no info array we're doing a simple data
567567
* transfer request, whose opcode is IPA_CMD_NONE.
568568
*/
569-
info = trans->info ? &trans->info[0] : NULL;
569+
cmd_opcode = channel->command ? &trans->cmd_opcode[0] : NULL;
570570
avail = ring->count - ring->index % ring->count;
571571
dest_tre = gsi_ring_virt(ring, ring->index);
572572
for_each_sg(trans->sgl, sg, trans->used, i) {
@@ -577,8 +577,8 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
577577
byte_count += len;
578578
if (!avail--)
579579
dest_tre = gsi_ring_virt(ring, 0);
580-
if (info)
581-
opcode = info++->opcode;
580+
if (cmd_opcode)
581+
opcode = *cmd_opcode++;
582582

583583
gsi_trans_tre_fill(dest_tre, addr, len, last_tre, bei, opcode);
584584
dest_tre++;

drivers/net/ipa/gsi_trans.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ struct gsi;
2222
struct gsi_trans;
2323
struct gsi_trans_pool;
2424

25+
/* Maximum number of TREs in an IPA immediate command transaction */
26+
#define IPA_COMMAND_TRANS_TRE_MAX 8
27+
2528
/**
2629
* struct gsi_trans - a GSI transaction
2730
*
@@ -34,8 +37,8 @@ struct gsi_trans_pool;
3437
* @used: Number of TREs *used* (could be less than tre_count)
3538
* @len: Total # of transfer bytes represented in sgl[] (set by core)
3639
* @data: Preserved but not touched by the core transaction code
40+
* @cmd_opcode: Array of command opcodes (command channel only)
3741
* @sgl: An array of scatter/gather entries managed by core code
38-
* @info: Array of command information structures (command channel)
3942
* @direction: DMA transfer direction (DMA_NONE for commands)
4043
* @refcount: Reference count used for destruction
4144
* @completion: Completed when the transaction completes
@@ -58,8 +61,8 @@ struct gsi_trans {
5861
u32 len; /* total # bytes across sgl[] */
5962

6063
void *data;
64+
u8 cmd_opcode[IPA_COMMAND_TRANS_TRE_MAX];
6165
struct scatterlist *sgl;
62-
struct ipa_cmd_info *info; /* array of entries, or null */
6366
enum dma_data_direction direction;
6467

6568
refcount_t refcount;

drivers/net/ipa/ipa_cmd.c

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max)
349349
{
350350
struct gsi_trans_info *trans_info = &channel->trans_info;
351351
struct device *dev = channel->gsi->dev;
352-
int ret;
353352

354353
/* This is as good a place as any to validate build constants */
355354
ipa_cmd_validate_build();
@@ -358,28 +357,16 @@ int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max)
358357
* a single transaction can require up to tlv_count of them,
359358
* so we treat them as if that many can be allocated at once.
360359
*/
361-
ret = gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool,
362-
sizeof(union ipa_cmd_payload),
363-
tre_max, channel->tlv_count);
364-
if (ret)
365-
return ret;
366-
367-
/* Each TRE needs a command info structure */
368-
ret = gsi_trans_pool_init(&trans_info->info_pool,
369-
sizeof(struct ipa_cmd_info),
370-
tre_max, channel->tlv_count);
371-
if (ret)
372-
gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool);
373-
374-
return ret;
360+
return gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool,
361+
sizeof(union ipa_cmd_payload),
362+
tre_max, channel->tlv_count);
375363
}
376364

377365
void ipa_cmd_pool_exit(struct gsi_channel *channel)
378366
{
379367
struct gsi_trans_info *trans_info = &channel->trans_info;
380368
struct device *dev = channel->gsi->dev;
381369

382-
gsi_trans_pool_exit(&trans_info->info_pool);
383370
gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool);
384371
}
385372

@@ -652,28 +639,16 @@ void ipa_cmd_pipeline_clear_wait(struct ipa *ipa)
652639
wait_for_completion(&ipa->completion);
653640
}
654641

655-
static struct ipa_cmd_info *
656-
ipa_cmd_info_alloc(struct ipa_endpoint *endpoint, u32 tre_count)
657-
{
658-
struct gsi_channel *channel;
659-
660-
channel = &endpoint->ipa->gsi.channel[endpoint->channel_id];
661-
662-
return gsi_trans_pool_alloc(&channel->trans_info.info_pool, tre_count);
663-
}
664-
665642
/* Allocate a transaction for the command TX endpoint */
666643
struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count)
667644
{
668645
struct ipa_endpoint *endpoint;
669-
struct gsi_trans *trans;
670646

671-
endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
647+
if (WARN_ON(tre_count > IPA_COMMAND_TRANS_TRE_MAX))
648+
return NULL;
672649

673-
trans = gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id,
674-
tre_count, DMA_NONE);
675-
if (trans)
676-
trans->info = ipa_cmd_info_alloc(endpoint, tre_count);
650+
endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
677651

678-
return trans;
652+
return gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id,
653+
tre_count, DMA_NONE);
679654
}

drivers/net/ipa/ipa_cmd.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,6 @@ enum ipa_cmd_opcode {
4646
IPA_CMD_IP_PACKET_TAG_STATUS = 0x14,
4747
};
4848

49-
/**
50-
* struct ipa_cmd_info - information needed for an IPA immediate command
51-
*
52-
* @opcode: The command opcode.
53-
*/
54-
struct ipa_cmd_info {
55-
enum ipa_cmd_opcode opcode;
56-
};
57-
5849
/**
5950
* ipa_cmd_table_valid() - Validate a memory region holding a table
6051
* @ipa: - IPA pointer

0 commit comments

Comments
 (0)