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
378365void 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
471455void 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 */
529513static 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
593573static 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 */
612591static 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 */
675643struct 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}
0 commit comments