Skip to content

Commit 0ff1db4

Browse files
author
Paolo Abeni
committed
Merge branch 'net-ipa-eight-simple-cleanups'
Alex Elder says: ==================== net: ipa: eight simple cleanups This series contains a mix of cleanups, some dating back to December, 2022. Version 1 was based on an older version of net-next/main; this version has simply been rebased. The first two make it so the IPA SUSPEND interrupt only gets enabled when necessary. That make it possible in the third patch to call device_init_wakeup() during an earlier phase of initialization, and remove two functions. The next patch removes IPA register definitions that are never used. The fifth patch makes ipa_table_hash_support() a real function, so the IPA structure only needs to be declared rather than defined when that file is parsed. The sixth patch fixes improper argument names in two function declarations. The seventh removes the declaration for a function that does not exist, and makes ipa_cmd_init() actually get called. And the last one eliminates ipa_version_supported(), in favor of just deciding that if a device is probed because its compatible matches, that device is assumed to be supported. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 57f1591 + dfdd70e commit 0ff1db4

15 files changed

+51
-167
lines changed

drivers/net/ipa/ipa_cmd.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,6 @@ enum ipa_cmd_opcode {
5353
bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
5454
bool route);
5555

56-
/**
57-
* ipa_cmd_data_valid() - Validate command-realted configuration is valid
58-
* @ipa: - IPA pointer
59-
*
60-
* Return: true if assumptions required for command are valid
61-
*/
62-
bool ipa_cmd_data_valid(struct ipa *ipa);
63-
6456
/**
6557
* ipa_cmd_pool_init() - initialize command channel pools
6658
* @channel: AP->IPA command TX GSI channel pointer

drivers/net/ipa/ipa_endpoint.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

33
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2019-2023 Linaro Ltd.
4+
* Copyright (C) 2019-2024 Linaro Ltd.
55
*/
66
#ifndef _IPA_ENDPOINT_H_
77
#define _IPA_ENDPOINT_H_
@@ -199,9 +199,9 @@ int ipa_endpoint_init(struct ipa *ipa, u32 count,
199199
const struct ipa_gsi_endpoint_data *data);
200200
void ipa_endpoint_exit(struct ipa *ipa);
201201

202-
void ipa_endpoint_trans_complete(struct ipa_endpoint *ipa,
202+
void ipa_endpoint_trans_complete(struct ipa_endpoint *endpoint,
203203
struct gsi_trans *trans);
204-
void ipa_endpoint_trans_release(struct ipa_endpoint *ipa,
204+
void ipa_endpoint_trans_release(struct ipa_endpoint *endpoint,
205205
struct gsi_trans *trans);
206206

207207
#endif /* _IPA_ENDPOINT_H_ */

drivers/net/ipa/ipa_interrupt.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737
* @ipa: IPA pointer
3838
* @irq: Linux IRQ number used for IPA interrupts
3939
* @enabled: Mask indicating which interrupts are enabled
40+
* @suspend_enabled: Bitmap of endpoints with the SUSPEND interrupt enabled
4041
*/
4142
struct ipa_interrupt {
4243
struct ipa *ipa;
4344
u32 irq;
4445
u32 enabled;
46+
unsigned long *suspend_enabled;
4547
};
4648

4749
/* Clear the suspend interrupt for all endpoints that signaled it */
@@ -194,6 +196,7 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
194196
u32 mask = BIT(endpoint_id % 32);
195197
u32 unit = endpoint_id / 32;
196198
const struct reg *reg;
199+
unsigned long weight;
197200
u32 offset;
198201
u32 val;
199202

@@ -203,6 +206,10 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
203206
if (ipa->version == IPA_VERSION_3_0)
204207
return;
205208

209+
weight = bitmap_weight(interrupt->suspend_enabled, ipa->endpoint_count);
210+
if (weight == 1 && !enable)
211+
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);
212+
206213
reg = ipa_reg(ipa, IRQ_SUSPEND_EN);
207214
offset = reg_n_offset(reg, unit);
208215
val = ioread32(ipa->reg_virt + offset);
@@ -211,8 +218,12 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
211218
val |= mask;
212219
else
213220
val &= ~mask;
221+
__change_bit(endpoint_id, interrupt->suspend_enabled);
214222

215223
iowrite32(val, ipa->reg_virt + offset);
224+
225+
if (!weight && enable)
226+
ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND);
216227
}
217228

218229
/* Enable TX_SUSPEND for an endpoint */
@@ -246,30 +257,49 @@ int ipa_interrupt_config(struct ipa *ipa)
246257

247258
interrupt->ipa = ipa;
248259

249-
/* Disable all IPA interrupt types */
260+
/* Initially all IPA interrupt types are disabled */
261+
interrupt->enabled = 0;
262+
interrupt->suspend_enabled = bitmap_zalloc(ipa->endpoint_count,
263+
GFP_KERNEL);
264+
if (!interrupt->suspend_enabled) {
265+
ret = -ENOMEM;
266+
goto err_kfree;
267+
}
268+
269+
/* Disable IPA interrupt types */
250270
reg = ipa_reg(ipa, IPA_IRQ_EN);
251271
iowrite32(0, ipa->reg_virt + reg_offset(reg));
252272

253273
ret = request_threaded_irq(irq, NULL, ipa_isr_thread, IRQF_ONESHOT,
254274
"ipa", interrupt);
255275
if (ret) {
256276
dev_err(dev, "error %d requesting \"ipa\" IRQ\n", ret);
257-
goto err_kfree;
277+
goto err_free_bitmap;
278+
}
279+
280+
ret = device_init_wakeup(dev, true);
281+
if (ret) {
282+
dev_err(dev, "error %d enabling wakeup\n", ret);
283+
goto err_free_irq;
258284
}
259285

260286
ret = dev_pm_set_wake_irq(dev, irq);
261287
if (ret) {
262288
dev_err(dev, "error %d registering \"ipa\" IRQ as wakeirq\n",
263289
ret);
264-
goto err_free_irq;
290+
goto err_disable_wakeup;
265291
}
266292

267293
ipa->interrupt = interrupt;
268294

269295
return 0;
270296

297+
err_disable_wakeup:
298+
(void)device_init_wakeup(dev, false);
271299
err_free_irq:
272300
free_irq(interrupt->irq, interrupt);
301+
err_free_bitmap:
302+
bitmap_free(interrupt->suspend_enabled);
273303
err_kfree:
274304
kfree(interrupt);
275305

@@ -285,7 +315,9 @@ void ipa_interrupt_deconfig(struct ipa *ipa)
285315
ipa->interrupt = NULL;
286316

287317
dev_pm_clear_wake_irq(dev);
318+
(void)device_init_wakeup(dev, false);
288319
free_irq(interrupt->irq, interrupt);
320+
bitmap_free(interrupt->suspend_enabled);
289321
}
290322

291323
/* Initialize the IPA interrupt structure */

drivers/net/ipa/ipa_main.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,6 @@ int ipa_setup(struct ipa *ipa)
119119
if (ret)
120120
return ret;
121121

122-
ret = ipa_power_setup(ipa);
123-
if (ret)
124-
goto err_gsi_teardown;
125-
126122
ipa_endpoint_setup(ipa);
127123

128124
/* We need to use the AP command TX endpoint to perform other
@@ -169,8 +165,6 @@ int ipa_setup(struct ipa *ipa)
169165
ipa_endpoint_disable_one(command_endpoint);
170166
err_endpoint_teardown:
171167
ipa_endpoint_teardown(ipa);
172-
ipa_power_teardown(ipa);
173-
err_gsi_teardown:
174168
gsi_teardown(&ipa->gsi);
175169

176170
return ret;
@@ -195,7 +189,6 @@ static void ipa_teardown(struct ipa *ipa)
195189
command_endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
196190
ipa_endpoint_disable_one(command_endpoint);
197191
ipa_endpoint_teardown(ipa);
198-
ipa_power_teardown(ipa);
199192
gsi_teardown(&ipa->gsi);
200193
}
201194

@@ -817,11 +810,6 @@ static int ipa_probe(struct platform_device *pdev)
817810
return -ENODEV;
818811
}
819812

820-
if (!ipa_version_supported(data->version)) {
821-
dev_err(dev, "unsupported IPA version %u\n", data->version);
822-
return -EINVAL;
823-
}
824-
825813
if (!data->modem_route_count) {
826814
dev_err(dev, "modem_route_count cannot be zero\n");
827815
return -EINVAL;
@@ -872,6 +860,10 @@ static int ipa_probe(struct platform_device *pdev)
872860
if (ret)
873861
goto err_reg_exit;
874862

863+
ret = ipa_cmd_init(ipa);
864+
if (ret)
865+
goto err_mem_exit;
866+
875867
ret = gsi_init(&ipa->gsi, pdev, ipa->version, data->endpoint_count,
876868
data->endpoint_data);
877869
if (ret)

drivers/net/ipa/ipa_power.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -232,25 +232,6 @@ void ipa_power_retention(struct ipa *ipa, bool enable)
232232
ret, enable ? "en" : "dis");
233233
}
234234

235-
int ipa_power_setup(struct ipa *ipa)
236-
{
237-
int ret;
238-
239-
ipa_interrupt_enable(ipa, IPA_IRQ_TX_SUSPEND);
240-
241-
ret = device_init_wakeup(ipa->dev, true);
242-
if (ret)
243-
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);
244-
245-
return ret;
246-
}
247-
248-
void ipa_power_teardown(struct ipa *ipa)
249-
{
250-
(void)device_init_wakeup(ipa->dev, false);
251-
ipa_interrupt_disable(ipa, IPA_IRQ_TX_SUSPEND);
252-
}
253-
254235
/* Initialize IPA power management */
255236
struct ipa_power *
256237
ipa_power_init(struct device *dev, const struct ipa_power_data *data)

drivers/net/ipa/ipa_power.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,6 @@ u32 ipa_core_clock_rate(struct ipa *ipa);
3131
*/
3232
void ipa_power_retention(struct ipa *ipa, bool enable);
3333

34-
/**
35-
* ipa_power_setup() - Set up IPA power management
36-
* @ipa: IPA pointer
37-
*
38-
* Return: 0 if successful, or a negative error code
39-
*/
40-
int ipa_power_setup(struct ipa *ipa);
41-
42-
/**
43-
* ipa_power_teardown() - Inverse of ipa_power_setup()
44-
* @ipa: IPA pointer
45-
*/
46-
void ipa_power_teardown(struct ipa *ipa);
47-
4834
/**
4935
* ipa_power_init() - Initialize IPA power management
5036
* @dev: IPA device

drivers/net/ipa/ipa_table.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0
22

33
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2018-2023 Linaro Ltd.
4+
* Copyright (C) 2018-2024 Linaro Ltd.
55
*/
66

77
#include <linux/bitops.h>
@@ -158,6 +158,12 @@ ipa_table_mem(struct ipa *ipa, bool filter, bool hashed, bool ipv6)
158158
return ipa_mem_find(ipa, mem_id);
159159
}
160160

161+
/* Return true if hashed tables are supported */
162+
bool ipa_table_hash_support(struct ipa *ipa)
163+
{
164+
return ipa->version != IPA_VERSION_4_2;
165+
}
166+
161167
bool ipa_filtered_valid(struct ipa *ipa, u64 filtered)
162168
{
163169
struct device *dev = ipa->dev;

drivers/net/ipa/ipa_table.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

33
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4-
* Copyright (C) 2019-2022 Linaro Ltd.
4+
* Copyright (C) 2019-2024 Linaro Ltd.
55
*/
66
#ifndef _IPA_TABLE_H_
77
#define _IPA_TABLE_H_
@@ -23,10 +23,7 @@ bool ipa_filtered_valid(struct ipa *ipa, u64 filtered);
2323
* ipa_table_hash_support() - Return true if hashed tables are supported
2424
* @ipa: IPA pointer
2525
*/
26-
static inline bool ipa_table_hash_support(struct ipa *ipa)
27-
{
28-
return ipa->version != IPA_VERSION_4_2;
29-
}
26+
bool ipa_table_hash_support(struct ipa *ipa);
3027

3128
/**
3229
* ipa_table_reset() - Reset filter and route tables entries to "none"

drivers/net/ipa/ipa_version.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,6 @@ enum ipa_version {
4747
IPA_VERSION_COUNT, /* Last; not a version */
4848
};
4949

50-
static inline bool ipa_version_supported(enum ipa_version version)
51-
{
52-
switch (version) {
53-
case IPA_VERSION_3_1:
54-
case IPA_VERSION_3_5_1:
55-
case IPA_VERSION_4_2:
56-
case IPA_VERSION_4_5:
57-
case IPA_VERSION_4_7:
58-
case IPA_VERSION_4_9:
59-
case IPA_VERSION_4_11:
60-
case IPA_VERSION_5_0:
61-
case IPA_VERSION_5_5:
62-
return true;
63-
default:
64-
return false;
65-
}
66-
}
67-
6850
/* Execution environment IDs */
6951
enum gsi_ee_id {
7052
GSI_EE_AP = 0x0,

drivers/net/ipa/reg/ipa_reg-v3.1.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,6 @@ static const u32 reg_qsb_max_reads_fmask[] = {
7878

7979
REG_FIELDS(QSB_MAX_READS, qsb_max_reads, 0x00000078);
8080

81-
static const u32 reg_filt_rout_hash_en_fmask[] = {
82-
[IPV6_ROUTER_HASH] = BIT(0),
83-
/* Bits 1-3 reserved */
84-
[IPV6_FILTER_HASH] = BIT(4),
85-
/* Bits 5-7 reserved */
86-
[IPV4_ROUTER_HASH] = BIT(8),
87-
/* Bits 9-11 reserved */
88-
[IPV4_FILTER_HASH] = BIT(12),
89-
/* Bits 13-31 reserved */
90-
};
91-
92-
REG_FIELDS(FILT_ROUT_HASH_EN, filt_rout_hash_en, 0x000008c);
93-
9481
static const u32 reg_filt_rout_hash_flush_fmask[] = {
9582
[IPV6_ROUTER_HASH] = BIT(0),
9683
/* Bits 1-3 reserved */
@@ -405,7 +392,6 @@ static const struct reg *reg_array[] = {
405392
[SHARED_MEM_SIZE] = &reg_shared_mem_size,
406393
[QSB_MAX_WRITES] = &reg_qsb_max_writes,
407394
[QSB_MAX_READS] = &reg_qsb_max_reads,
408-
[FILT_ROUT_HASH_EN] = &reg_filt_rout_hash_en,
409395
[FILT_ROUT_HASH_FLUSH] = &reg_filt_rout_hash_flush,
410396
[STATE_AGGR_ACTIVE] = &reg_state_aggr_active,
411397
[IPA_BCR] = &reg_ipa_bcr,

drivers/net/ipa/reg/ipa_reg-v3.5.1.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,6 @@ static const u32 reg_qsb_max_reads_fmask[] = {
8383

8484
REG_FIELDS(QSB_MAX_READS, qsb_max_reads, 0x00000078);
8585

86-
static const u32 reg_filt_rout_hash_en_fmask[] = {
87-
[IPV6_ROUTER_HASH] = BIT(0),
88-
/* Bits 1-3 reserved */
89-
[IPV6_FILTER_HASH] = BIT(4),
90-
/* Bits 5-7 reserved */
91-
[IPV4_ROUTER_HASH] = BIT(8),
92-
/* Bits 9-11 reserved */
93-
[IPV4_FILTER_HASH] = BIT(12),
94-
/* Bits 13-31 reserved */
95-
};
96-
97-
REG_FIELDS(FILT_ROUT_HASH_EN, filt_rout_hash_en, 0x000008c);
98-
9986
static const u32 reg_filt_rout_hash_flush_fmask[] = {
10087
[IPV6_ROUTER_HASH] = BIT(0),
10188
/* Bits 1-3 reserved */
@@ -416,7 +403,6 @@ static const struct reg *reg_array[] = {
416403
[SHARED_MEM_SIZE] = &reg_shared_mem_size,
417404
[QSB_MAX_WRITES] = &reg_qsb_max_writes,
418405
[QSB_MAX_READS] = &reg_qsb_max_reads,
419-
[FILT_ROUT_HASH_EN] = &reg_filt_rout_hash_en,
420406
[FILT_ROUT_HASH_FLUSH] = &reg_filt_rout_hash_flush,
421407
[STATE_AGGR_ACTIVE] = &reg_state_aggr_active,
422408
[IPA_BCR] = &reg_ipa_bcr,

drivers/net/ipa/reg/ipa_reg-v4.11.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,19 +115,6 @@ static const u32 reg_qsb_max_reads_fmask[] = {
115115

116116
REG_FIELDS(QSB_MAX_READS, qsb_max_reads, 0x00000078);
117117

118-
static const u32 reg_filt_rout_hash_en_fmask[] = {
119-
[IPV6_ROUTER_HASH] = BIT(0),
120-
/* Bits 1-3 reserved */
121-
[IPV6_FILTER_HASH] = BIT(4),
122-
/* Bits 5-7 reserved */
123-
[IPV4_ROUTER_HASH] = BIT(8),
124-
/* Bits 9-11 reserved */
125-
[IPV4_FILTER_HASH] = BIT(12),
126-
/* Bits 13-31 reserved */
127-
};
128-
129-
REG_FIELDS(FILT_ROUT_HASH_EN, filt_rout_hash_en, 0x0000148);
130-
131118
static const u32 reg_filt_rout_hash_flush_fmask[] = {
132119
[IPV6_ROUTER_HASH] = BIT(0),
133120
/* Bits 1-3 reserved */
@@ -472,7 +459,6 @@ static const struct reg *reg_array[] = {
472459
[SHARED_MEM_SIZE] = &reg_shared_mem_size,
473460
[QSB_MAX_WRITES] = &reg_qsb_max_writes,
474461
[QSB_MAX_READS] = &reg_qsb_max_reads,
475-
[FILT_ROUT_HASH_EN] = &reg_filt_rout_hash_en,
476462
[FILT_ROUT_HASH_FLUSH] = &reg_filt_rout_hash_flush,
477463
[STATE_AGGR_ACTIVE] = &reg_state_aggr_active,
478464
[LOCAL_PKT_PROC_CNTXT] = &reg_local_pkt_proc_cntxt,

0 commit comments

Comments
 (0)