Skip to content

Commit 0598cec

Browse files
committed
Merge branch 'ipa-next'
Alex Elder says: ==================== net: ipa: a few more small items This series consists of three small sets of changes. Version 2 adds a patch that avoids a warning that occurs when handling a modem crash (I unfortunately didn't notice it earlier). All other patches are the same--just rebased. The first three patches allow a few endpoint features to be specified. At this time, currently-defined endpoints retain the same configuration, but when the monitor functionality is added in the next cycle these options will be required. The fourth patch simply removes an unused function, explaining also why it would likely never be used. The fifth patch is new. It counts the number of modem TX endpoints and uses it to determine how many TREs a transaction needs when when handling a modem crash. It is needed to avoid exceeding the limited number of commands imposed by the last four patches. And the last four patches refactor code related to IPA immediate commands, eliminating an unused field and then simplifying and removing some unneeded code. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 60f243a + a224bd4 commit 0598cec

14 files changed

+156
-162
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: 6 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,8 @@ void gsi_trans_free(struct gsi_trans *trans)
410410

411411
/* Add an immediate command to a transaction */
412412
void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
413-
dma_addr_t addr, enum dma_data_direction direction,
414-
enum ipa_cmd_opcode opcode)
413+
dma_addr_t addr, enum ipa_cmd_opcode opcode)
415414
{
416-
struct ipa_cmd_info *info;
417415
u32 which = trans->used++;
418416
struct scatterlist *sg;
419417

@@ -438,9 +436,7 @@ void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
438436
sg_dma_address(sg) = addr;
439437
sg_dma_len(sg) = size;
440438

441-
info = &trans->info[which];
442-
info->opcode = opcode;
443-
info->direction = direction;
439+
trans->cmd_opcode[which] = opcode;
444440
}
445441

446442
/* Add a page transfer to a transaction. It will fill the only TRE. */
@@ -556,10 +552,10 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
556552
struct gsi_ring *ring = &channel->tre_ring;
557553
enum ipa_cmd_opcode opcode = IPA_CMD_NONE;
558554
bool bei = channel->toward_ipa;
559-
struct ipa_cmd_info *info;
560555
struct gsi_tre *dest_tre;
561556
struct scatterlist *sg;
562557
u32 byte_count = 0;
558+
u8 *cmd_opcode;
563559
u32 avail;
564560
u32 i;
565561

@@ -570,7 +566,7 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
570566
* If there is no info array we're doing a simple data
571567
* transfer request, whose opcode is IPA_CMD_NONE.
572568
*/
573-
info = trans->info ? &trans->info[0] : NULL;
569+
cmd_opcode = channel->command ? &trans->cmd_opcode[0] : NULL;
574570
avail = ring->count - ring->index % ring->count;
575571
dest_tre = gsi_ring_virt(ring, ring->index);
576572
for_each_sg(trans->sgl, sg, trans->used, i) {
@@ -581,8 +577,8 @@ static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)
581577
byte_count += len;
582578
if (!avail--)
583579
dest_tre = gsi_ring_virt(ring, 0);
584-
if (info)
585-
opcode = info++->opcode;
580+
if (cmd_opcode)
581+
opcode = *cmd_opcode++;
586582

587583
gsi_trans_tre_fill(dest_tre, addr, len, last_tre, bei, opcode);
588584
dest_tre++;
@@ -637,28 +633,6 @@ void gsi_trans_commit_wait(struct gsi_trans *trans)
637633
gsi_trans_free(trans);
638634
}
639635

640-
/* Commit a GSI transaction and wait for it to complete, with timeout */
641-
int gsi_trans_commit_wait_timeout(struct gsi_trans *trans,
642-
unsigned long timeout)
643-
{
644-
unsigned long timeout_jiffies = msecs_to_jiffies(timeout);
645-
unsigned long remaining = 1; /* In case of empty transaction */
646-
647-
if (!trans->used)
648-
goto out_trans_free;
649-
650-
refcount_inc(&trans->refcount);
651-
652-
__gsi_trans_commit(trans, true);
653-
654-
remaining = wait_for_completion_timeout(&trans->completion,
655-
timeout_jiffies);
656-
out_trans_free:
657-
gsi_trans_free(trans);
658-
659-
return remaining ? 0 : -ETIMEDOUT;
660-
}
661-
662636
/* Process the completion of a transaction; called while polling */
663637
void gsi_trans_complete(struct gsi_trans *trans)
664638
{

drivers/net/ipa/gsi_trans.h

Lines changed: 9 additions & 15 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
@@ -57,9 +60,11 @@ struct gsi_trans {
5760
u8 used; /* # entries used in sgl[] */
5861
u32 len; /* total # bytes across sgl[] */
5962

60-
void *data;
63+
union {
64+
void *data;
65+
u8 cmd_opcode[IPA_COMMAND_TRANS_TRE_MAX];
66+
};
6167
struct scatterlist *sgl;
62-
struct ipa_cmd_info *info; /* array of entries, or null */
6368
enum dma_data_direction direction;
6469

6570
refcount_t refcount;
@@ -165,12 +170,10 @@ void gsi_trans_free(struct gsi_trans *trans);
165170
* @buf: Buffer pointer for command payload
166171
* @size: Number of bytes in buffer
167172
* @addr: DMA address for payload
168-
* @direction: Direction of DMA transfer (or DMA_NONE if none required)
169173
* @opcode: IPA immediate command opcode
170174
*/
171175
void gsi_trans_cmd_add(struct gsi_trans *trans, void *buf, u32 size,
172-
dma_addr_t addr, enum dma_data_direction direction,
173-
enum ipa_cmd_opcode opcode);
176+
dma_addr_t addr, enum ipa_cmd_opcode opcode);
174177

175178
/**
176179
* gsi_trans_page_add() - Add a page transfer to a transaction
@@ -205,15 +208,6 @@ void gsi_trans_commit(struct gsi_trans *trans, bool ring_db);
205208
*/
206209
void gsi_trans_commit_wait(struct gsi_trans *trans);
207210

208-
/**
209-
* gsi_trans_commit_wait_timeout() - Commit a GSI transaction and wait for
210-
* it to complete, with timeout
211-
* @trans: Transaction to commit
212-
* @timeout: Timeout period (in milliseconds)
213-
*/
214-
int gsi_trans_commit_wait_timeout(struct gsi_trans *trans,
215-
unsigned long timeout);
216-
217211
/**
218212
* gsi_trans_read_byte() - Issue a single byte read TRE on a channel
219213
* @gsi: GSI pointer

drivers/net/ipa/ipa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ struct ipa_interrupt;
6262
* @initialized: Bit mask indicating endpoints initialized
6363
* @set_up: Bit mask indicating endpoints set up
6464
* @enabled: Bit mask indicating endpoints enabled
65+
* @modem_tx_count: Number of defined modem TX endoints
6566
* @endpoint: Array of endpoint information
6667
* @channel_map: Mapping of GSI channel to IPA endpoint
6768
* @name_map: Mapping of IPA endpoint name to IPA endpoint
@@ -114,6 +115,7 @@ struct ipa {
114115
u32 set_up;
115116
u32 enabled;
116117

118+
u32 modem_tx_count;
117119
struct ipa_endpoint endpoint[IPA_ENDPOINT_MAX];
118120
struct ipa_endpoint *channel_map[GSI_CHANNEL_COUNT_MAX];
119121
struct ipa_endpoint *name_map[IPA_ENDPOINT_COUNT];

drivers/net/ipa/ipa_cmd.c

Lines changed: 22 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,13 @@
2626
* other than data transfer to another endpoint.
2727
*
2828
* Immediate commands are represented by GSI transactions just like other
29-
* transfer requests, represented by a single GSI TRE. Each immediate
30-
* command has a well-defined format, having a payload of a known length.
31-
* This allows the transfer element's length field to be used to hold an
32-
* immediate command's opcode. The payload for a command resides in DRAM
33-
* and is described by a single scatterlist entry in its transaction.
34-
* Commands do not require a transaction completion callback. To commit
35-
* an immediate command transaction, either gsi_trans_commit_wait() or
36-
* gsi_trans_commit_wait_timeout() is used.
29+
* transfer requests, and use a single GSI TRE. Each immediate command
30+
* has a well-defined format, having a payload of a known length. This
31+
* allows the transfer element's length field to be used to hold an
32+
* immediate command's opcode. The payload for a command resides in AP
33+
* memory and is described by a single scatterlist entry in its transaction.
34+
* Commands do not require a transaction completion callback, and are
35+
* (currently) always issued using gsi_trans_commit_wait().
3736
*/
3837

3938
/* Some commands can wait until indicated pipeline stages are clear */
@@ -350,7 +349,6 @@ int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max)
350349
{
351350
struct gsi_trans_info *trans_info = &channel->trans_info;
352351
struct device *dev = channel->gsi->dev;
353-
int ret;
354352

355353
/* This is as good a place as any to validate build constants */
356354
ipa_cmd_validate_build();
@@ -359,28 +357,16 @@ int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max)
359357
* a single transaction can require up to tlv_count of them,
360358
* so we treat them as if that many can be allocated at once.
361359
*/
362-
ret = gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool,
363-
sizeof(union ipa_cmd_payload),
364-
tre_max, channel->tlv_count);
365-
if (ret)
366-
return ret;
367-
368-
/* Each TRE needs a command info structure */
369-
ret = gsi_trans_pool_init(&trans_info->info_pool,
370-
sizeof(struct ipa_cmd_info),
371-
tre_max, channel->tlv_count);
372-
if (ret)
373-
gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool);
374-
375-
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);
376363
}
377364

378365
void ipa_cmd_pool_exit(struct gsi_channel *channel)
379366
{
380367
struct gsi_trans_info *trans_info = &channel->trans_info;
381368
struct device *dev = channel->gsi->dev;
382369

383-
gsi_trans_pool_exit(&trans_info->info_pool);
384370
gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool);
385371
}
386372

@@ -403,7 +389,6 @@ void ipa_cmd_table_init_add(struct gsi_trans *trans,
403389
dma_addr_t hash_addr)
404390
{
405391
struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
406-
enum dma_data_direction direction = DMA_TO_DEVICE;
407392
struct ipa_cmd_hw_ip_fltrt_init *payload;
408393
union ipa_cmd_payload *cmd_payload;
409394
dma_addr_t payload_addr;
@@ -434,7 +419,7 @@ void ipa_cmd_table_init_add(struct gsi_trans *trans,
434419
payload->nhash_rules_addr = cpu_to_le64(addr);
435420

436421
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
437-
direction, opcode);
422+
opcode);
438423
}
439424

440425
/* Initialize header space in IPA-local memory */
@@ -443,7 +428,6 @@ void ipa_cmd_hdr_init_local_add(struct gsi_trans *trans, u32 offset, u16 size,
443428
{
444429
struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
445430
enum ipa_cmd_opcode opcode = IPA_CMD_HDR_INIT_LOCAL;
446-
enum dma_data_direction direction = DMA_TO_DEVICE;
447431
struct ipa_cmd_hw_hdr_init_local *payload;
448432
union ipa_cmd_payload *cmd_payload;
449433
dma_addr_t payload_addr;
@@ -465,7 +449,7 @@ void ipa_cmd_hdr_init_local_add(struct gsi_trans *trans, u32 offset, u16 size,
465449
payload->flags = cpu_to_le32(flags);
466450

467451
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
468-
direction, opcode);
452+
opcode);
469453
}
470454

471455
void ipa_cmd_register_write_add(struct gsi_trans *trans, u32 offset, u32 value,
@@ -522,15 +506,14 @@ void ipa_cmd_register_write_add(struct gsi_trans *trans, u32 offset, u32 value,
522506
payload->clear_options = cpu_to_le32(options);
523507

524508
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
525-
DMA_NONE, opcode);
509+
opcode);
526510
}
527511

528512
/* Skip IP packet processing on the next data transfer on a TX channel */
529513
static void ipa_cmd_ip_packet_init_add(struct gsi_trans *trans, u8 endpoint_id)
530514
{
531515
struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
532516
enum ipa_cmd_opcode opcode = IPA_CMD_IP_PACKET_INIT;
533-
enum dma_data_direction direction = DMA_TO_DEVICE;
534517
struct ipa_cmd_ip_packet_init *payload;
535518
union ipa_cmd_payload *cmd_payload;
536519
dma_addr_t payload_addr;
@@ -542,7 +525,7 @@ static void ipa_cmd_ip_packet_init_add(struct gsi_trans *trans, u8 endpoint_id)
542525
IPA_PACKET_INIT_DEST_ENDPOINT_FMASK);
543526

544527
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
545-
direction, opcode);
528+
opcode);
546529
}
547530

548531
/* Use a DMA command to read or write a block of IPA-resident memory */
@@ -553,7 +536,6 @@ void ipa_cmd_dma_shared_mem_add(struct gsi_trans *trans, u32 offset, u16 size,
553536
enum ipa_cmd_opcode opcode = IPA_CMD_DMA_SHARED_MEM;
554537
struct ipa_cmd_hw_dma_mem_mem *payload;
555538
union ipa_cmd_payload *cmd_payload;
556-
enum dma_data_direction direction;
557539
dma_addr_t payload_addr;
558540
u16 flags;
559541

@@ -584,17 +566,14 @@ void ipa_cmd_dma_shared_mem_add(struct gsi_trans *trans, u32 offset, u16 size,
584566
payload->flags = cpu_to_le16(flags);
585567
payload->system_addr = cpu_to_le64(addr);
586568

587-
direction = toward_ipa ? DMA_TO_DEVICE : DMA_FROM_DEVICE;
588-
589569
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
590-
direction, opcode);
570+
opcode);
591571
}
592572

593573
static void ipa_cmd_ip_tag_status_add(struct gsi_trans *trans)
594574
{
595575
struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
596576
enum ipa_cmd_opcode opcode = IPA_CMD_IP_PACKET_TAG_STATUS;
597-
enum dma_data_direction direction = DMA_TO_DEVICE;
598577
struct ipa_cmd_ip_packet_tag_status *payload;
599578
union ipa_cmd_payload *cmd_payload;
600579
dma_addr_t payload_addr;
@@ -605,14 +584,13 @@ static void ipa_cmd_ip_tag_status_add(struct gsi_trans *trans)
605584
payload->tag = le64_encode_bits(0, IP_PACKET_TAG_STATUS_TAG_FMASK);
606585

607586
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
608-
direction, opcode);
587+
opcode);
609588
}
610589

611590
/* Issue a small command TX data transfer */
612591
static void ipa_cmd_transfer_add(struct gsi_trans *trans)
613592
{
614593
struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
615-
enum dma_data_direction direction = DMA_TO_DEVICE;
616594
enum ipa_cmd_opcode opcode = IPA_CMD_NONE;
617595
union ipa_cmd_payload *payload;
618596
dma_addr_t payload_addr;
@@ -621,7 +599,7 @@ static void ipa_cmd_transfer_add(struct gsi_trans *trans)
621599
payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
622600

623601
gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
624-
direction, opcode);
602+
opcode);
625603
}
626604

627605
/* Add immediate commands to a transaction to clear the hardware pipeline */
@@ -661,28 +639,16 @@ void ipa_cmd_pipeline_clear_wait(struct ipa *ipa)
661639
wait_for_completion(&ipa->completion);
662640
}
663641

664-
static struct ipa_cmd_info *
665-
ipa_cmd_info_alloc(struct ipa_endpoint *endpoint, u32 tre_count)
666-
{
667-
struct gsi_channel *channel;
668-
669-
channel = &endpoint->ipa->gsi.channel[endpoint->channel_id];
670-
671-
return gsi_trans_pool_alloc(&channel->trans_info.info_pool, tre_count);
672-
}
673-
674642
/* Allocate a transaction for the command TX endpoint */
675643
struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count)
676644
{
677645
struct ipa_endpoint *endpoint;
678-
struct gsi_trans *trans;
679646

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

682-
trans = gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id,
683-
tre_count, DMA_NONE);
684-
if (trans)
685-
trans->info = ipa_cmd_info_alloc(endpoint, tre_count);
650+
endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
686651

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

drivers/net/ipa/ipa_cmd.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +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-
* @direction: Direction of data transfer for DMA commands
54-
*/
55-
struct ipa_cmd_info {
56-
enum ipa_cmd_opcode opcode;
57-
enum dma_data_direction direction;
58-
};
59-
6049
/**
6150
* ipa_cmd_table_valid() - Validate a memory region holding a table
6251
* @ipa: - IPA pointer

0 commit comments

Comments
 (0)