Skip to content

Commit 5e43df1

Browse files
committed
Merge branch 'net-ipa-wake-up-system-on-RX-available'
Alex Elder says: ==================== net: ipa: wake up system on RX available This series arranges for the IPA driver to wake up a suspended system if the IPA hardware has a packet to deliver to the AP. Version 2 replaced the first patch from version 1 with three patches, in response to David Miller's feedback. And based on Bjorn Andersson's feedback on version 2, this version reworks the tracking of IPA clock references. As a result, we no longer need a flag to determine whether a "don't' suspend" clock reference is held (though an bit in a bitmask is still used for a different purpose). In summary: - A refcount_t is used to track IPA clock references where an atomic_t was previously used. (This may go away soon as well, with upcoming work to implement runtime PM.) - We no longer track whether a special reference has been taken to avoid suspending IPA. - A bit in a bitmask is used to ensure we only trigger a system resume once per system suspend. And from the original series: - Suspending endpoints only occurs when suspending the driver, not when dropping the last clock reference. Resuming endpoints is also disconnected from starting the clock. - The IPA SUSPEND interrupt is now a wakeup interrupt. If it fires, it schedules a system resume operation. - The GSI interrupt is no longer a wakeup interrupt. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents ba4ee3c + 54f7e44 commit 5e43df1

6 files changed

Lines changed: 74 additions & 66 deletions

File tree

‎drivers/net/ipa/gsi.c‎

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1987,31 +1987,26 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch,
19871987
}
19881988
gsi->irq = irq;
19891989

1990-
ret = enable_irq_wake(gsi->irq);
1991-
if (ret)
1992-
dev_warn(dev, "error %d enabling gsi wake irq\n", ret);
1993-
gsi->irq_wake_enabled = !ret;
1994-
19951990
/* Get GSI memory range and map it */
19961991
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "gsi");
19971992
if (!res) {
19981993
dev_err(dev, "DT error getting \"gsi\" memory property\n");
19991994
ret = -ENODEV;
2000-
goto err_disable_irq_wake;
1995+
goto err_free_irq;
20011996
}
20021997

20031998
size = resource_size(res);
20041999
if (res->start > U32_MAX || size > U32_MAX - res->start) {
20052000
dev_err(dev, "DT memory resource \"gsi\" out of range\n");
20062001
ret = -EINVAL;
2007-
goto err_disable_irq_wake;
2002+
goto err_free_irq;
20082003
}
20092004

20102005
gsi->virt = ioremap(res->start, size);
20112006
if (!gsi->virt) {
20122007
dev_err(dev, "unable to remap \"gsi\" memory\n");
20132008
ret = -ENOMEM;
2014-
goto err_disable_irq_wake;
2009+
goto err_free_irq;
20152010
}
20162011

20172012
ret = gsi_channel_init(gsi, prefetch, count, data, modem_alloc);
@@ -2025,9 +2020,7 @@ int gsi_init(struct gsi *gsi, struct platform_device *pdev, bool prefetch,
20252020

20262021
err_iounmap:
20272022
iounmap(gsi->virt);
2028-
err_disable_irq_wake:
2029-
if (gsi->irq_wake_enabled)
2030-
(void)disable_irq_wake(gsi->irq);
2023+
err_free_irq:
20312024
free_irq(gsi->irq, gsi);
20322025

20332026
return ret;
@@ -2038,8 +2031,6 @@ void gsi_exit(struct gsi *gsi)
20382031
{
20392032
mutex_destroy(&gsi->mutex);
20402033
gsi_channel_exit(gsi);
2041-
if (gsi->irq_wake_enabled)
2042-
(void)disable_irq_wake(gsi->irq);
20432034
free_irq(gsi->irq, gsi);
20442035
iounmap(gsi->virt);
20452036
}

‎drivers/net/ipa/gsi.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ struct gsi {
150150
struct net_device dummy_dev; /* needed for NAPI */
151151
void __iomem *virt;
152152
u32 irq;
153-
bool irq_wake_enabled;
154153
u32 channel_count;
155154
u32 evt_ring_count;
156155
struct gsi_channel channel[GSI_CHANNEL_COUNT_MAX];

‎drivers/net/ipa/ipa.h‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,25 @@ struct ipa_clock;
2727
struct ipa_smp2p;
2828
struct ipa_interrupt;
2929

30+
/**
31+
* enum ipa_flag - IPA state flags
32+
* @IPA_FLAG_RESUMED: Whether resume from suspend has been signaled
33+
* @IPA_FLAG_COUNT: Number of defined IPA flags
34+
*/
35+
enum ipa_flag {
36+
IPA_FLAG_RESUMED,
37+
IPA_FLAG_COUNT, /* Last; not a flag */
38+
};
39+
3040
/**
3141
* struct ipa - IPA information
3242
* @gsi: Embedded GSI structure
43+
* @flags: Boolean state flags
3344
* @version: IPA hardware version
3445
* @pdev: Platform device
3546
* @modem_rproc: Remoteproc handle for modem subsystem
3647
* @smp2p: SMP2P information
3748
* @clock: IPA clocking information
38-
* @suspend_ref: Whether clock reference preventing suspend taken
3949
* @table_addr: DMA address of filter/route table content
4050
* @table_virt: Virtual address of filter/route table content
4151
* @interrupt: IPA Interrupt information
@@ -70,14 +80,14 @@ struct ipa_interrupt;
7080
*/
7181
struct ipa {
7282
struct gsi gsi;
83+
DECLARE_BITMAP(flags, IPA_FLAG_COUNT);
7384
enum ipa_version version;
7485
struct platform_device *pdev;
7586
struct rproc *modem_rproc;
7687
struct notifier_block nb;
7788
void *notifier;
7889
struct ipa_smp2p *smp2p;
7990
struct ipa_clock *clock;
80-
atomic_t suspend_ref;
8191

8292
dma_addr_t table_addr;
8393
__le64 *table_virt;
@@ -104,8 +114,6 @@ struct ipa {
104114
void *zero_virt;
105115
size_t zero_size;
106116

107-
struct wakeup_source *wakeup_source;
108-
109117
/* Bit masks indicating endpoint state */
110118
u32 available; /* supported by hardware */
111119
u32 filter_map;

‎drivers/net/ipa/ipa_clock.c‎

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Copyright (C) 2018-2020 Linaro Ltd.
55
*/
66

7-
#include <linux/atomic.h>
7+
#include <linux/refcount.h>
88
#include <linux/mutex.h>
99
#include <linux/clk.h>
1010
#include <linux/device.h>
@@ -51,7 +51,7 @@
5151
* @config_path: Configuration space interconnect
5252
*/
5353
struct ipa_clock {
54-
atomic_t count;
54+
refcount_t count;
5555
struct mutex mutex; /* protects clock enable/disable */
5656
struct clk *core;
5757
struct icc_path *memory_path;
@@ -195,14 +195,13 @@ static void ipa_clock_disable(struct ipa *ipa)
195195
*/
196196
bool ipa_clock_get_additional(struct ipa *ipa)
197197
{
198-
return !!atomic_inc_not_zero(&ipa->clock->count);
198+
return refcount_inc_not_zero(&ipa->clock->count);
199199
}
200200

201201
/* Get an IPA clock reference. If the reference count is non-zero, it is
202202
* incremented and return is immediate. Otherwise it is checked again
203-
* under protection of the mutex, and if appropriate the clock (and
204-
* interconnects) are enabled suspended endpoints (if any) are resumed
205-
* before returning.
203+
* under protection of the mutex, and if appropriate the IPA clock
204+
* is enabled.
206205
*
207206
* Incrementing the reference count is intentionally deferred until
208207
* after the clock is running and endpoints are resumed.
@@ -229,28 +228,23 @@ void ipa_clock_get(struct ipa *ipa)
229228
goto out_mutex_unlock;
230229
}
231230

232-
ipa_endpoint_resume(ipa);
233-
234-
atomic_inc(&clock->count);
231+
refcount_set(&clock->count, 1);
235232

236233
out_mutex_unlock:
237234
mutex_unlock(&clock->mutex);
238235
}
239236

240-
/* Attempt to remove an IPA clock reference. If this represents the last
241-
* reference, suspend endpoints and disable the clock (and interconnects)
242-
* under protection of a mutex.
237+
/* Attempt to remove an IPA clock reference. If this represents the
238+
* last reference, disable the IPA clock under protection of the mutex.
243239
*/
244240
void ipa_clock_put(struct ipa *ipa)
245241
{
246242
struct ipa_clock *clock = ipa->clock;
247243

248244
/* If this is not the last reference there's nothing more to do */
249-
if (!atomic_dec_and_mutex_lock(&clock->count, &clock->mutex))
245+
if (!refcount_dec_and_mutex_lock(&clock->count, &clock->mutex))
250246
return;
251247

252-
ipa_endpoint_suspend(ipa);
253-
254248
ipa_clock_disable(ipa);
255249

256250
mutex_unlock(&clock->mutex);
@@ -294,7 +288,7 @@ struct ipa_clock *ipa_clock_init(struct device *dev)
294288
goto err_kfree;
295289

296290
mutex_init(&clock->mutex);
297-
atomic_set(&clock->count, 0);
291+
refcount_set(&clock->count, 0);
298292

299293
return clock;
300294

@@ -311,7 +305,7 @@ void ipa_clock_exit(struct ipa_clock *clock)
311305
{
312306
struct clk *clk = clock->core;
313307

314-
WARN_ON(atomic_read(&clock->count) != 0);
308+
WARN_ON(refcount_read(&clock->count) != 0);
315309
mutex_destroy(&clock->mutex);
316310
ipa_interconnect_exit(clock);
317311
kfree(clock);

‎drivers/net/ipa/ipa_interrupt.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,16 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa)
237237
goto err_kfree;
238238
}
239239

240+
ret = enable_irq_wake(irq);
241+
if (ret) {
242+
dev_err(dev, "error %d enabling wakeup for \"ipa\" IRQ\n", ret);
243+
goto err_free_irq;
244+
}
245+
240246
return interrupt;
241247

248+
err_free_irq:
249+
free_irq(interrupt->irq, interrupt);
242250
err_kfree:
243251
kfree(interrupt);
244252

@@ -248,6 +256,12 @@ struct ipa_interrupt *ipa_interrupt_setup(struct ipa *ipa)
248256
/* Tear down the IPA interrupt framework */
249257
void ipa_interrupt_teardown(struct ipa_interrupt *interrupt)
250258
{
259+
struct device *dev = &interrupt->ipa->pdev->dev;
260+
int ret;
261+
262+
ret = disable_irq_wake(interrupt->irq);
263+
if (ret)
264+
dev_err(dev, "error %d disabling \"ipa\" IRQ wakeup\n", ret);
251265
free_irq(interrupt->irq, interrupt);
252266
kfree(interrupt);
253267
}

0 commit comments

Comments
 (0)