Skip to content

Commit ace5dc6

Browse files
Alex Elderkuba-moo
authored andcommitted
net: ipa: update comments
This patch just updates comments throughout the IPA code. Transaction state is now tracked using indexes into an array rather than linked lists, and a few comments refer to the "old way" of doing things. The description of how transactions are used was changed to refer to "operations" rather than "commands", to (hopefully) remove a possible ambiguity. IPA register offsets and fields are now handled differently as well, and the register documentation is updated to better describe the code. A few minor updates to comments were made (e.g., adding a missing word, fixing a typo or punctuation, etc.). Finally, the local macro atomic_dec_not_zero() is no longer used, so it is deleted. Signed-off-by: Alex Elder <elder@linaro.org> Link: https://lore.kernel.org/r/20220930224527.3503404-1-elder@linaro.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 450a580 commit ace5dc6

File tree

8 files changed

+75
-94
lines changed

8 files changed

+75
-94
lines changed

drivers/net/ipa/gsi.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@
5656
* element can also contain an immediate command, requesting the IPA perform
5757
* actions other than data transfer.
5858
*
59-
* Each TRE refers to a block of data--also located DRAM. After writing one
60-
* or more TREs to a channel, the writer (either the IPA or an EE) writes a
61-
* doorbell register to inform the receiving side how many elements have
59+
* Each TRE refers to a block of data--also located in DRAM. After writing
60+
* one or more TREs to a channel, the writer (either the IPA or an EE) writes
61+
* a doorbell register to inform the receiving side how many elements have
6262
* been written.
6363
*
6464
* Each channel has a GSI "event ring" associated with it. An event ring
@@ -1347,8 +1347,8 @@ gsi_event_trans(struct gsi *gsi, struct gsi_event *event)
13471347
* we update transactions to record their actual received lengths.
13481348
*
13491349
* When an event for a TX channel arrives we use information in the
1350-
* transaction to report the number of requests and bytes have been
1351-
* transferred.
1350+
* transaction to report the number of requests and bytes that have
1351+
* been transferred.
13521352
*
13531353
* This function is called whenever we learn that the GSI hardware has filled
13541354
* new events since the last time we checked. The ring's index field tells
@@ -1474,7 +1474,7 @@ void gsi_channel_doorbell(struct gsi_channel *channel)
14741474
iowrite32(val, gsi->virt + GSI_CH_C_DOORBELL_0_OFFSET(channel_id));
14751475
}
14761476

1477-
/* Consult hardware, move any newly completed transactions to completed list */
1477+
/* Consult hardware, move newly completed transactions to completed state */
14781478
void gsi_channel_update(struct gsi_channel *channel)
14791479
{
14801480
u32 evt_ring_id = channel->evt_ring_id;
@@ -1515,17 +1515,17 @@ void gsi_channel_update(struct gsi_channel *channel)
15151515
*
15161516
* Return: Transaction pointer, or null if none are available
15171517
*
1518-
* This function returns the first entry on a channel's completed transaction
1519-
* list. If that list is empty, the hardware is consulted to determine
1520-
* whether any new transactions have completed. If so, they're moved to the
1521-
* completed list and the new first entry is returned. If there are no more
1522-
* completed transactions, a null pointer is returned.
1518+
* This function returns the first of a channel's completed transactions.
1519+
* If no transactions are in completed state, the hardware is consulted to
1520+
* determine whether any new transactions have completed. If so, they're
1521+
* moved to completed state and the first such transaction is returned.
1522+
* If there are no more completed transactions, a null pointer is returned.
15231523
*/
15241524
static struct gsi_trans *gsi_channel_poll_one(struct gsi_channel *channel)
15251525
{
15261526
struct gsi_trans *trans;
15271527

1528-
/* Get the first transaction from the completed list */
1528+
/* Get the first completed transaction */
15291529
trans = gsi_channel_trans_complete(channel);
15301530
if (trans)
15311531
gsi_trans_move_polled(trans);

drivers/net/ipa/gsi_private.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ struct gsi_channel;
1818

1919
/**
2020
* gsi_trans_move_complete() - Mark a GSI transaction completed
21-
* @trans: Transaction to commit
21+
* @trans: Transaction whose state is to be updated
2222
*/
2323
void gsi_trans_move_complete(struct gsi_trans *trans);
2424

2525
/**
2626
* gsi_trans_move_polled() - Mark a transaction polled
27-
* @trans: Transaction to update
27+
* @trans: Transaction whose state is to be updated
2828
*/
2929
void gsi_trans_move_polled(struct gsi_trans *trans);
3030

@@ -97,8 +97,8 @@ void gsi_channel_doorbell(struct gsi_channel *channel);
9797
/* gsi_channel_update() - Update knowledge of channel hardware state
9898
* @channel: Channel to be updated
9999
*
100-
* Consult hardware, move any newly completed transactions to a
101-
* channel's completed list.
100+
* Consult hardware, change the state of any newly-completed transactions
101+
* on a channel.
102102
*/
103103
void gsi_channel_update(struct gsi_channel *channel);
104104

drivers/net/ipa/gsi_trans.c

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,36 @@
2222
* DOC: GSI Transactions
2323
*
2424
* A GSI transaction abstracts the behavior of a GSI channel by representing
25-
* everything about a related group of IPA commands in a single structure.
26-
* (A "command" in this sense is either a data transfer or an IPA immediate
25+
* everything about a related group of IPA operations in a single structure.
26+
* (A "operation" in this sense is either a data transfer or an IPA immediate
2727
* command.) Most details of interaction with the GSI hardware are managed
28-
* by the GSI transaction core, allowing users to simply describe commands
28+
* by the GSI transaction core, allowing users to simply describe operations
2929
* to be performed. When a transaction has completed a callback function
3030
* (dependent on the type of endpoint associated with the channel) allows
3131
* cleanup of resources associated with the transaction.
3232
*
33-
* To perform a command (or set of them), a user of the GSI transaction
33+
* To perform an operation (or set of them), a user of the GSI transaction
3434
* interface allocates a transaction, indicating the number of TREs required
35-
* (one per command). If sufficient TREs are available, they are reserved
35+
* (one per operation). If sufficient TREs are available, they are reserved
3636
* for use in the transaction and the allocation succeeds. This way
37-
* exhaustion of the available TREs in a channel ring is detected
38-
* as early as possible. All resources required to complete a transaction
39-
* are allocated at transaction allocation time.
37+
* exhaustion of the available TREs in a channel ring is detected as early
38+
* as possible. Any other resources that might be needed to complete a
39+
* transaction are also allocated when the transaction is allocated.
4040
*
41-
* Commands performed as part of a transaction are represented in an array
42-
* of Linux scatterlist structures. This array is allocated with the
43-
* transaction, and its entries are initialized using standard scatterlist
44-
* functions (such as sg_set_buf() or skb_to_sgvec()).
41+
* Operations performed as part of a transaction are represented in an array
42+
* of Linux scatterlist structures, allocated with the transaction. These
43+
* scatterlist structures are initialized by "adding" operations to the
44+
* transaction. If a buffer in an operation must be mapped for DMA, this is
45+
* done at the time it is added to the transaction. It is possible for a
46+
* mapping error to occur when an operation is added. In this case the
47+
* transaction should simply be freed; this correctly releases resources
48+
* associated with the transaction.
4549
*
46-
* Once a transaction's scatterlist structures have been initialized, the
47-
* transaction is committed. The caller is responsible for mapping buffers
48-
* for DMA if necessary, and this should be done *before* allocating
49-
* the transaction. Between a successful allocation and commit of a
50-
* transaction no errors should occur.
51-
*
52-
* Committing transfers ownership of the entire transaction to the GSI
53-
* transaction core. The GSI transaction code formats the content of
54-
* the scatterlist array into the channel ring buffer and informs the
55-
* hardware that new TREs are available to process.
50+
* Once all operations have been successfully added to a transaction, the
51+
* transaction is committed. Committing transfers ownership of the entire
52+
* transaction to the GSI transaction core. The GSI transaction code
53+
* formats the content of the scatterlist array into the channel ring
54+
* buffer and informs the hardware that new TREs are available to process.
5655
*
5756
* The last TRE in each transaction is marked to interrupt the AP when the
5857
* GSI hardware has completed it. Because transfers described by TREs are
@@ -125,11 +124,10 @@ void gsi_trans_pool_exit(struct gsi_trans_pool *pool)
125124
memset(pool, 0, sizeof(*pool));
126125
}
127126

128-
/* Allocate the requested number of (zeroed) entries from the pool */
129-
/* Home-grown DMA pool. This way we can preallocate and use the tre_count
130-
* to guarantee allocations will succeed. Even though we specify max_alloc
131-
* (and it can be more than one), we only allow allocation of a single
132-
* element from a DMA pool.
127+
/* Home-grown DMA pool. This way we can preallocate the pool, and guarantee
128+
* allocations will succeed. The immediate commands in a transaction can
129+
* require up to max_alloc elements from the pool. But we only allow
130+
* allocation of a single element from a DMA pool at a time.
133131
*/
134132
int gsi_trans_pool_init_dma(struct device *dev, struct gsi_trans_pool *pool,
135133
size_t size, u32 count, u32 max_alloc)
@@ -537,8 +535,8 @@ static void gsi_trans_tre_fill(struct gsi_tre *dest_tre, dma_addr_t addr,
537535
*
538536
* Formats channel ring TRE entries based on the content of the scatterlist.
539537
* Maps a transaction pointer to the last ring entry used for the transaction,
540-
* so it can be recovered when it completes. Moves the transaction to the
541-
* pending list. Finally, updates the channel ring pointer and optionally
538+
* so it can be recovered when it completes. Moves the transaction to
539+
* pending state. Finally, updates the channel ring pointer and optionally
542540
* rings the doorbell.
543541
*/
544542
static void __gsi_trans_commit(struct gsi_trans *trans, bool ring_db)

drivers/net/ipa/gsi_trans.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct gsi_trans {
7474

7575
/**
7676
* gsi_trans_pool_init() - Initialize a pool of structures for transactions
77-
* @pool: GSI transaction poll pointer
77+
* @pool: GSI transaction pool pointer
7878
* @size: Size of elements in the pool
7979
* @count: Minimum number of elements in the pool
8080
* @max_alloc: Maximum number of elements allocated at a time from pool

drivers/net/ipa/ipa_cmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* immediate command's opcode. The payload for a command resides in AP
3333
* memory and is described by a single scatterlist entry in its transaction.
3434
* Commands do not require a transaction completion callback, and are
35-
* (currently) always issued using gsi_trans_commit_wait().
35+
* always issued using gsi_trans_commit_wait().
3636
*/
3737

3838
/* Some commands can wait until indicated pipeline stages are clear */

drivers/net/ipa/ipa_data.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* communication path between the IPA and a particular execution environment
3232
* (EE), such as the AP or Modem. Each EE has a set of channels associated
3333
* with it, and each channel has an ID unique for that EE. For the most part
34-
* the only GSI channels of concern to this driver belong to the AP
34+
* the only GSI channels of concern to this driver belong to the AP.
3535
*
3636
* An endpoint is an IPA construct representing a single channel anywhere
3737
* in the system. An IPA endpoint ID maps directly to an (EE, channel_id)

drivers/net/ipa/ipa_endpoint.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
#include "ipa_gsi.h"
2424
#include "ipa_power.h"
2525

26-
#define atomic_dec_not_zero(v) atomic_add_unless((v), -1, 0)
27-
2826
/* Hardware is told about receive buffers once a "batch" has been queued */
2927
#define IPA_REPLENISH_BATCH 16 /* Must be non-zero */
3028

drivers/net/ipa/ipa_reg.h

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,53 +17,38 @@ struct ipa;
1717
* DOC: IPA Registers
1818
*
1919
* IPA registers are located within the "ipa-reg" address space defined by
20-
* Device Tree. The offset of each register within that space is specified
21-
* by symbols defined below. The address space is mapped to virtual memory
22-
* space in ipa_mem_init(). All IPA registers are 32 bits wide.
20+
* Device Tree. Each register has a specified offset within that space,
21+
* which is mapped into virtual memory space in ipa_mem_init(). Each
22+
* has a unique identifer, taken from the ipa_reg_id enumerated type.
23+
* All IPA registers are 32 bits wide.
2324
*
24-
* Certain register types are duplicated for a number of instances of
25-
* something. For example, each IPA endpoint has an set of registers
26-
* defining its configuration. The offset to an endpoint's set of registers
27-
* is computed based on an "base" offset, plus an endpoint's ID multiplied
28-
* and a "stride" value for the register. For such registers, the offset is
29-
* computed by a function-like macro that takes a parameter used in the
30-
* computation.
25+
* Certain "parameterized" register types are duplicated for a number of
26+
* instances of something. For example, each IPA endpoint has an set of
27+
* registers defining its configuration. The offset to an endpoint's set
28+
* of registers is computed based on an "base" offset, plus an endpoint's
29+
* ID multiplied and a "stride" value for the register. Similarly, some
30+
* registers have an offset that depends on execution environment. In
31+
* this case, the stride is multiplied by a member of the gsi_ee_id
32+
* enumerated type.
3133
*
32-
* Some register offsets depend on execution environment. For these an "ee"
33-
* parameter is supplied to the offset macro. The "ee" value is a member of
34-
* the gsi_ee enumerated type.
34+
* Each version of IPA implements an array of ipa_reg structures indexed
35+
* by register ID. Each entry in the array specifies the base offset and
36+
* (for parameterized registers) a non-zero stride value. Not all versions
37+
* of IPA define all registers. The offset for a register is returned by
38+
* ipa_reg_offset() when the register's ipa_reg structure is supplied;
39+
* zero is returned for an undefined register (this should never happen).
3540
*
36-
* The offset of a register dependent on endpoint ID is computed by a macro
37-
* that is supplied a parameter "ep", "txep", or "rxep". A register with an
38-
* "ep" parameter is valid for any endpoint; a register with a "txep" or
39-
* "rxep" parameter is valid only for TX or RX endpoints, respectively. The
40-
* "*ep" value is assumed to be less than the maximum valid endpoint ID
41-
* for the current hardware, and that will not exceed IPA_ENDPOINT_MAX.
42-
*
43-
* The offset of registers related to filter and route tables is computed
44-
* by a macro that is supplied a parameter "er". The "er" represents an
45-
* endpoint ID for filters, or a route ID for routes. For filters, the
46-
* endpoint ID must be less than IPA_ENDPOINT_MAX, but is further restricted
47-
* because not all endpoints support filtering. For routes, the route ID
48-
* must be less than IPA_ROUTE_MAX.
49-
*
50-
* The offset of registers related to resource types is computed by a macro
51-
* that is supplied a parameter "rt". The "rt" represents a resource type,
52-
* which is a member of the ipa_resource_type_src enumerated type for
53-
* source endpoint resources or the ipa_resource_type_dst enumerated type
54-
* for destination endpoint resources.
55-
*
56-
* Some registers encode multiple fields within them. For these, each field
57-
* has a symbol below defining a field mask that encodes both the position
58-
* and width of the field within its register.
59-
*
60-
* In some cases, different versions of IPA hardware use different offset or
61-
* field mask values. In such cases an inline_function(ipa) is used rather
62-
* than a MACRO to define the offset or field mask to use.
63-
*
64-
* Finally, some registers hold bitmasks representing endpoints. In such
65-
* cases the @available field in the @ipa structure defines the "full" set
66-
* of valid bits for the register.
41+
* Some registers encode multiple fields within them. Each field in
42+
* such a register has a unique identifier (from an enumerated type).
43+
* The position and width of the fields in a register are defined by
44+
* an array of field masks, indexed by field ID. Two functions are
45+
* used to access register fields; both take an ipa_reg structure as
46+
* argument. To encode a value to be represented in a register field,
47+
* the value and field ID are passed to ipa_reg_encode(). To extract
48+
* a value encoded in a register field, the field ID is passed to
49+
* ipa_reg_decode(). In addition, for single-bit fields, ipa_reg_bit()
50+
* can be used to either encode the bit value, or to generate a mask
51+
* used to extract the bit value.
6752
*/
6853

6954
/* enum ipa_reg_id - IPA register IDs */

0 commit comments

Comments
 (0)