* [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes
@ 2014-11-26 2:08 Florian Fainelli
2014-11-26 3:39 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Florian Fainelli @ 2014-11-26 2:08 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
Hi David,
This patch series contains two bug fixes:
- first patch fixes an issue on the error path of the driver where we could
have left some of our registers mapped
- second patch enforces the use of a software reset of the switch to guarantee
the HW is in a consistent state prior to software initialization
Thanks!
Florian Fainelli (2):
net: dsa: bcm_sf2: fix unmapping registers in case of errors
net: dsa: bcm_sf2: reset switch prior to initialization
drivers/net/dsa/bcm_sf2.c | 58 +++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 25 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes
@ 2014-11-26 2:08 Florian Fainelli
2014-11-26 2:08 ` [PATCH net 1/2] net: dsa: bcm_sf2: fix unmapping registers in case of errors Florian Fainelli
2014-11-26 2:08 ` [PATCH net 2/2] net: dsa: bcm_sf2: reset switch prior to initialization Florian Fainelli
0 siblings, 2 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-11-26 2:08 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
Hi David,
This patch series contains two bug fixes:
- first patch fixes an issue on the error path of the driver where we could
have left some of our registers mapped
- second patch enforces the use of a software reset of the switch to guarantee
the HW is in a consistent state prior to software initialization
Thanks!
Florian Fainelli (2):
net: dsa: bcm_sf2: fix unmapping registers in case of errors
net: dsa: bcm_sf2: reset switch prior to initialization
drivers/net/dsa/bcm_sf2.c | 58 +++++++++++++++++++++++++++--------------------
1 file changed, 33 insertions(+), 25 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/2] net: dsa: bcm_sf2: fix unmapping registers in case of errors
2014-11-26 2:08 [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes Florian Fainelli
@ 2014-11-26 2:08 ` Florian Fainelli
2014-11-26 2:08 ` [PATCH net 2/2] net: dsa: bcm_sf2: reset switch prior to initialization Florian Fainelli
1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-11-26 2:08 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
In case we fail to ioremap() one of our registers, we would be leaking
existing mappings, unwind those accordingly on errors.
Fixes: 246d7f773c13 ("net: dsa: add Broadcom SF2 switch driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/dsa/bcm_sf2.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index b9625968daac..46632e8b6336 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -404,7 +404,8 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
*base = of_iomap(dn, i);
if (*base == NULL) {
pr_err("unable to find register: %s\n", reg_names[i]);
- return -ENODEV;
+ ret = -ENOMEM;
+ goto out_unmap;
}
base++;
}
@@ -484,7 +485,8 @@ out_free_irq0:
out_unmap:
base = &priv->core;
for (i = 0; i < BCM_SF2_REGS_NUM; i++) {
- iounmap(*base);
+ if (*base)
+ iounmap(*base);
base++;
}
return ret;
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/2] net: dsa: bcm_sf2: reset switch prior to initialization
2014-11-26 2:08 [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes Florian Fainelli
2014-11-26 2:08 ` [PATCH net 1/2] net: dsa: bcm_sf2: fix unmapping registers in case of errors Florian Fainelli
@ 2014-11-26 2:08 ` Florian Fainelli
1 sibling, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2014-11-26 2:08 UTC (permalink / raw)
To: netdev; +Cc: davem, Florian Fainelli
Our boot agent may have left the switch in an certain configuration
state, make sure we issue a software reset prior to configuring the
switch in order to ensure the HW is in a consistent state, in particular
transmit queues and internal buffers.
Fixes: 246d7f773c13 ("net: dsa: add Broadcom SF2 switch driver")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/dsa/bcm_sf2.c | 52 ++++++++++++++++++++++++++---------------------
1 file changed, 29 insertions(+), 23 deletions(-)
diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
index 46632e8b6336..4f4c2a7888e5 100644
--- a/drivers/net/dsa/bcm_sf2.c
+++ b/drivers/net/dsa/bcm_sf2.c
@@ -377,6 +377,29 @@ static irqreturn_t bcm_sf2_switch_1_isr(int irq, void *dev_id)
return IRQ_HANDLED;
}
+static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
+{
+ unsigned int timeout = 1000;
+ u32 reg;
+
+ reg = core_readl(priv, CORE_WATCHDOG_CTRL);
+ reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
+ core_writel(priv, reg, CORE_WATCHDOG_CTRL);
+
+ do {
+ reg = core_readl(priv, CORE_WATCHDOG_CTRL);
+ if (!(reg & SOFTWARE_RESET))
+ break;
+
+ usleep_range(1000, 2000);
+ } while (timeout-- > 0);
+
+ if (timeout == 0)
+ return -ETIMEDOUT;
+
+ return 0;
+}
+
static int bcm_sf2_sw_setup(struct dsa_switch *ds)
{
const char *reg_names[BCM_SF2_REGS_NUM] = BCM_SF2_REGS_NAME;
@@ -410,6 +433,12 @@ static int bcm_sf2_sw_setup(struct dsa_switch *ds)
base++;
}
+ ret = bcm_sf2_sw_rst(priv);
+ if (ret) {
+ pr_err("unable to software reset switch: %d\n", ret);
+ goto out_unmap;
+ }
+
/* Disable all interrupts and request them */
intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_MASK_SET);
intrl2_0_writel(priv, 0xffffffff, INTRL2_CPU_CLEAR);
@@ -735,29 +764,6 @@ static int bcm_sf2_sw_suspend(struct dsa_switch *ds)
return 0;
}
-static int bcm_sf2_sw_rst(struct bcm_sf2_priv *priv)
-{
- unsigned int timeout = 1000;
- u32 reg;
-
- reg = core_readl(priv, CORE_WATCHDOG_CTRL);
- reg |= SOFTWARE_RESET | EN_CHIP_RST | EN_SW_RESET;
- core_writel(priv, reg, CORE_WATCHDOG_CTRL);
-
- do {
- reg = core_readl(priv, CORE_WATCHDOG_CTRL);
- if (!(reg & SOFTWARE_RESET))
- break;
-
- usleep_range(1000, 2000);
- } while (timeout-- > 0);
-
- if (timeout == 0)
- return -ETIMEDOUT;
-
- return 0;
-}
-
static int bcm_sf2_sw_resume(struct dsa_switch *ds)
{
struct bcm_sf2_priv *priv = ds_to_priv(ds);
--
2.1.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes
2014-11-26 2:08 [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes Florian Fainelli
@ 2014-11-26 3:39 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2014-11-26 3:39 UTC (permalink / raw)
To: f.fainelli; +Cc: netdev
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 25 Nov 2014 18:08:29 -0800
> This patch series contains two bug fixes:
>
> - first patch fixes an issue on the error path of the driver where we could
> have left some of our registers mapped
>
> - second patch enforces the use of a software reset of the switch to guarantee
> the HW is in a consistent state prior to software initialization
Series applied, thanks Florian.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-26 3:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 2:08 [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes Florian Fainelli
2014-11-26 2:08 ` [PATCH net 1/2] net: dsa: bcm_sf2: fix unmapping registers in case of errors Florian Fainelli
2014-11-26 2:08 ` [PATCH net 2/2] net: dsa: bcm_sf2: reset switch prior to initialization Florian Fainelli
-- strict thread matches above, loose matches on Subject: below --
2014-11-26 2:08 [PATCH net 0/2] net: dsa: bcm_sf2: misc bugfixes Florian Fainelli
2014-11-26 3:39 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).