Skip to content

Commit eb236c2

Browse files
Doug Bergerdavem330
authored andcommitted
net: bcmgenet: Move wake-up event out of side band ISR
The side band interrupt service routine is not available on chips like 7211, or rather, it does not permit the signaling of wake-up events due to the complex interrupt hierarchy. Move the wake-up event accounting into a .resume_noirq function, account for possible wake-up events and clear the MPD/HFB interrupts from there, while leaving the hardware untouched until the resume function proceeds with doing its usual business. Because bcmgenet_wol_power_down_cfg() now enables the MPD and HFB interrupts, it is invoked by a .suspend_noirq function to prevent the servicing of interrupts after the clocks have been disabled. Signed-off-by: Doug Berger <[email protected]> Signed-off-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df8f348 commit eb236c2

File tree

3 files changed

+67
-13
lines changed

3 files changed

+67
-13
lines changed

drivers/net/ethernet/broadcom/genet/bcmgenet.c

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,10 +3270,7 @@ static irqreturn_t bcmgenet_isr0(int irq, void *dev_id)
32703270

32713271
static irqreturn_t bcmgenet_wol_isr(int irq, void *dev_id)
32723272
{
3273-
struct bcmgenet_priv *priv = dev_id;
3274-
3275-
pm_wakeup_event(&priv->pdev->dev, 0);
3276-
3273+
/* Acknowledge the interrupt */
32773274
return IRQ_HANDLED;
32783275
}
32793276

@@ -4174,13 +4171,12 @@ static void bcmgenet_shutdown(struct platform_device *pdev)
41744171
}
41754172

41764173
#ifdef CONFIG_PM_SLEEP
4177-
static int bcmgenet_resume(struct device *d)
4174+
static int bcmgenet_resume_noirq(struct device *d)
41784175
{
41794176
struct net_device *dev = dev_get_drvdata(d);
41804177
struct bcmgenet_priv *priv = netdev_priv(dev);
4181-
unsigned long dma_ctrl;
4182-
u32 offset, reg;
41834178
int ret;
4179+
u32 reg;
41844180

41854181
if (!netif_running(dev))
41864182
return 0;
@@ -4190,6 +4186,34 @@ static int bcmgenet_resume(struct device *d)
41904186
if (ret)
41914187
return ret;
41924188

4189+
if (device_may_wakeup(d) && priv->wolopts) {
4190+
/* Account for Wake-on-LAN events and clear those events
4191+
* (Some devices need more time between enabling the clocks
4192+
* and the interrupt register reflecting the wake event so
4193+
* read the register twice)
4194+
*/
4195+
reg = bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_STAT);
4196+
reg = bcmgenet_intrl2_0_readl(priv, INTRL2_CPU_STAT);
4197+
if (reg & UMAC_IRQ_WAKE_EVENT)
4198+
pm_wakeup_event(&priv->pdev->dev, 0);
4199+
}
4200+
4201+
bcmgenet_intrl2_0_writel(priv, UMAC_IRQ_WAKE_EVENT, INTRL2_CPU_CLEAR);
4202+
4203+
return 0;
4204+
}
4205+
4206+
static int bcmgenet_resume(struct device *d)
4207+
{
4208+
struct net_device *dev = dev_get_drvdata(d);
4209+
struct bcmgenet_priv *priv = netdev_priv(dev);
4210+
unsigned long dma_ctrl;
4211+
u32 offset, reg;
4212+
int ret;
4213+
4214+
if (!netif_running(dev))
4215+
return 0;
4216+
41934217
/* From WOL-enabled suspend, switch to regular clock */
41944218
if (device_may_wakeup(d) && priv->wolopts)
41954219
bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC);
@@ -4262,7 +4286,6 @@ static int bcmgenet_suspend(struct device *d)
42624286
{
42634287
struct net_device *dev = dev_get_drvdata(d);
42644288
struct bcmgenet_priv *priv = netdev_priv(dev);
4265-
int ret = 0;
42664289
u32 offset;
42674290

42684291
if (!netif_running(dev))
@@ -4282,23 +4305,46 @@ static int bcmgenet_suspend(struct device *d)
42824305
priv->hfb_en[2] = bcmgenet_hfb_reg_readl(priv, offset + sizeof(u32));
42834306
bcmgenet_hfb_reg_writel(priv, 0, HFB_CTRL);
42844307

4308+
return 0;
4309+
}
4310+
4311+
static int bcmgenet_suspend_noirq(struct device *d)
4312+
{
4313+
struct net_device *dev = dev_get_drvdata(d);
4314+
struct bcmgenet_priv *priv = netdev_priv(dev);
4315+
int ret = 0;
4316+
4317+
if (!netif_running(dev))
4318+
return 0;
4319+
42854320
/* Prepare the device for Wake-on-LAN and switch to the slow clock */
42864321
if (device_may_wakeup(d) && priv->wolopts)
42874322
ret = bcmgenet_power_down(priv, GENET_POWER_WOL_MAGIC);
42884323
else if (priv->internal_phy)
42894324
ret = bcmgenet_power_down(priv, GENET_POWER_PASSIVE);
42904325

4326+
/* Let the framework handle resumption and leave the clocks on */
4327+
if (ret)
4328+
return ret;
4329+
42914330
/* Turn off the clocks */
42924331
clk_disable_unprepare(priv->clk);
42934332

4294-
if (ret)
4295-
bcmgenet_resume(d);
4296-
4297-
return ret;
4333+
return 0;
42984334
}
4335+
#else
4336+
#define bcmgenet_suspend NULL
4337+
#define bcmgenet_suspend_noirq NULL
4338+
#define bcmgenet_resume NULL
4339+
#define bcmgenet_resume_noirq NULL
42994340
#endif /* CONFIG_PM_SLEEP */
43004341

4301-
static SIMPLE_DEV_PM_OPS(bcmgenet_pm_ops, bcmgenet_suspend, bcmgenet_resume);
4342+
static const struct dev_pm_ops bcmgenet_pm_ops = {
4343+
.suspend = bcmgenet_suspend,
4344+
.suspend_noirq = bcmgenet_suspend_noirq,
4345+
.resume = bcmgenet_resume,
4346+
.resume_noirq = bcmgenet_resume_noirq,
4347+
};
43024348

43034349
static const struct acpi_device_id genet_acpi_match[] = {
43044350
{ "BCM6E4E", (kernel_ulong_t)&bcm2711_plat_data },

drivers/net/ethernet/broadcom/genet/bcmgenet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ struct bcmgenet_mib_counters {
312312
#define UMAC_IRQ_HFB_SM (1 << 10)
313313
#define UMAC_IRQ_HFB_MM (1 << 11)
314314
#define UMAC_IRQ_MPD_R (1 << 12)
315+
#define UMAC_IRQ_WAKE_EVENT (UMAC_IRQ_HFB_SM | UMAC_IRQ_HFB_MM | \
316+
UMAC_IRQ_MPD_R)
315317
#define UMAC_IRQ_RXDMA_MBDONE (1 << 13)
316318
#define UMAC_IRQ_RXDMA_PDONE (1 << 14)
317319
#define UMAC_IRQ_RXDMA_BDONE (1 << 15)

drivers/net/ethernet/broadcom/genet/bcmgenet_wol.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ int bcmgenet_wol_power_down_cfg(struct bcmgenet_priv *priv,
193193
bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
194194
}
195195

196+
reg = UMAC_IRQ_MPD_R;
197+
if (hfb_enable)
198+
reg |= UMAC_IRQ_HFB_SM | UMAC_IRQ_HFB_MM;
199+
200+
bcmgenet_intrl2_0_writel(priv, reg, INTRL2_CPU_MASK_CLEAR);
201+
196202
return 0;
197203
}
198204

0 commit comments

Comments
 (0)