@@ -159,6 +159,8 @@ struct ar9331_sw_priv {
159159 struct dsa_switch ds ;
160160 struct dsa_switch_ops ops ;
161161 struct irq_domain * irqdomain ;
162+ u32 irq_mask ;
163+ struct mutex lock_irq ;
162164 struct mii_bus * mbus ; /* mdio master */
163165 struct mii_bus * sbus ; /* mdio slave */
164166 struct regmap * regmap ;
@@ -520,32 +522,44 @@ static irqreturn_t ar9331_sw_irq(int irq, void *data)
520522static void ar9331_sw_mask_irq (struct irq_data * d )
521523{
522524 struct ar9331_sw_priv * priv = irq_data_get_irq_chip_data (d );
523- struct regmap * regmap = priv -> regmap ;
524- int ret ;
525525
526- ret = regmap_update_bits (regmap , AR9331_SW_REG_GINT_MASK ,
527- AR9331_SW_GINT_PHY_INT , 0 );
528- if (ret )
529- dev_err (priv -> dev , "could not mask IRQ\n" );
526+ priv -> irq_mask = 0 ;
530527}
531528
532529static void ar9331_sw_unmask_irq (struct irq_data * d )
530+ {
531+ struct ar9331_sw_priv * priv = irq_data_get_irq_chip_data (d );
532+
533+ priv -> irq_mask = AR9331_SW_GINT_PHY_INT ;
534+ }
535+
536+ static void ar9331_sw_irq_bus_lock (struct irq_data * d )
537+ {
538+ struct ar9331_sw_priv * priv = irq_data_get_irq_chip_data (d );
539+
540+ mutex_lock (& priv -> lock_irq );
541+ }
542+
543+ static void ar9331_sw_irq_bus_sync_unlock (struct irq_data * d )
533544{
534545 struct ar9331_sw_priv * priv = irq_data_get_irq_chip_data (d );
535546 struct regmap * regmap = priv -> regmap ;
536547 int ret ;
537548
538549 ret = regmap_update_bits (regmap , AR9331_SW_REG_GINT_MASK ,
539- AR9331_SW_GINT_PHY_INT ,
540- AR9331_SW_GINT_PHY_INT );
550+ AR9331_SW_GINT_PHY_INT , priv -> irq_mask );
541551 if (ret )
542- dev_err (priv -> dev , "could not unmask IRQ\n" );
552+ dev_err (priv -> dev , "failed to change IRQ mask\n" );
553+
554+ mutex_unlock (& priv -> lock_irq );
543555}
544556
545557static struct irq_chip ar9331_sw_irq_chip = {
546558 .name = AR9331_SW_NAME ,
547559 .irq_mask = ar9331_sw_mask_irq ,
548560 .irq_unmask = ar9331_sw_unmask_irq ,
561+ .irq_bus_lock = ar9331_sw_irq_bus_lock ,
562+ .irq_bus_sync_unlock = ar9331_sw_irq_bus_sync_unlock ,
549563};
550564
551565static int ar9331_sw_irq_map (struct irq_domain * domain , unsigned int irq ,
@@ -584,6 +598,7 @@ static int ar9331_sw_irq_init(struct ar9331_sw_priv *priv)
584598 return irq ? irq : - EINVAL ;
585599 }
586600
601+ mutex_init (& priv -> lock_irq );
587602 ret = devm_request_threaded_irq (dev , irq , NULL , ar9331_sw_irq ,
588603 IRQF_ONESHOT , AR9331_SW_NAME , priv );
589604 if (ret ) {
0 commit comments