* [PATCH net-next] net: ethernet: ti: davinci_mdio: switch to readl/writel_relaxed()
@ 2019-03-28 17:09 Grygorii Strashko
2019-03-29 1:00 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Grygorii Strashko @ 2019-03-28 17:09 UTC (permalink / raw)
To: David S. Miller
Cc: netdev, Sekhar Nori, linux-kernel, linux-omap, linux-arm-kernel,
Grygorii Strashko
Switch to readl/writel_relaxed() APIs, because this is recommended
API and the MDIO block is reused on Keystone 2 SoCs
where LE/BE modes are supported.
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
drivers/net/ethernet/ti/davinci_mdio.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c
index a98aedae1b41..64776b47799b 100644
--- a/drivers/net/ethernet/ti/davinci_mdio.c
+++ b/drivers/net/ethernet/ti/davinci_mdio.c
@@ -140,7 +140,7 @@ static void davinci_mdio_init_clk(struct davinci_mdio_data *data)
static void davinci_mdio_enable(struct davinci_mdio_data *data)
{
/* set enable and clock divider */
- __raw_writel(data->clk_div | CONTROL_ENABLE, &data->regs->control);
+ writel_relaxed(data->clk_div | CONTROL_ENABLE, &data->regs->control);
}
static int davinci_mdio_reset(struct mii_bus *bus)
@@ -159,7 +159,7 @@ static int davinci_mdio_reset(struct mii_bus *bus)
msleep(PHY_MAX_ADDR * data->access_time);
/* dump hardware version info */
- ver = __raw_readl(&data->regs->version);
+ ver = readl_relaxed(&data->regs->version);
dev_info(data->dev,
"davinci mdio revision %d.%d, bus freq %ld\n",
(ver >> 8) & 0xff, ver & 0xff,
@@ -169,7 +169,7 @@ static int davinci_mdio_reset(struct mii_bus *bus)
goto done;
/* get phy mask from the alive register */
- phy_mask = __raw_readl(&data->regs->alive);
+ phy_mask = readl_relaxed(&data->regs->alive);
if (phy_mask) {
/* restrict mdio bus to live phys only */
dev_info(data->dev, "detected phy mask %x\n", ~phy_mask);
@@ -196,11 +196,11 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
u32 reg;
while (time_after(timeout, jiffies)) {
- reg = __raw_readl(®s->user[0].access);
+ reg = readl_relaxed(®s->user[0].access);
if ((reg & USERACCESS_GO) == 0)
return 0;
- reg = __raw_readl(®s->control);
+ reg = readl_relaxed(®s->control);
if ((reg & CONTROL_IDLE) == 0) {
usleep_range(100, 200);
continue;
@@ -216,7 +216,7 @@ static inline int wait_for_user_access(struct davinci_mdio_data *data)
return -EAGAIN;
}
- reg = __raw_readl(®s->user[0].access);
+ reg = readl_relaxed(®s->user[0].access);
if ((reg & USERACCESS_GO) == 0)
return 0;
@@ -263,7 +263,7 @@ static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)
if (ret < 0)
break;
- __raw_writel(reg, &data->regs->user[0].access);
+ writel_relaxed(reg, &data->regs->user[0].access);
ret = wait_for_user_access(data);
if (ret == -EAGAIN)
@@ -271,7 +271,7 @@ static int davinci_mdio_read(struct mii_bus *bus, int phy_id, int phy_reg)
if (ret < 0)
break;
- reg = __raw_readl(&data->regs->user[0].access);
+ reg = readl_relaxed(&data->regs->user[0].access);
ret = (reg & USERACCESS_ACK) ? (reg & USERACCESS_DATA) : -EIO;
break;
}
@@ -307,7 +307,7 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id,
if (ret < 0)
break;
- __raw_writel(reg, &data->regs->user[0].access);
+ writel_relaxed(reg, &data->regs->user[0].access);
ret = wait_for_user_access(data);
if (ret == -EAGAIN)
@@ -472,9 +472,9 @@ static int davinci_mdio_runtime_suspend(struct device *dev)
u32 ctrl;
/* shutdown the scan state machine */
- ctrl = __raw_readl(&data->regs->control);
+ ctrl = readl_relaxed(&data->regs->control);
ctrl &= ~CONTROL_ENABLE;
- __raw_writel(ctrl, &data->regs->control);
+ writel_relaxed(ctrl, &data->regs->control);
wait_for_idle(data);
return 0;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: ethernet: ti: davinci_mdio: switch to readl/writel_relaxed()
2019-03-28 17:09 [PATCH net-next] net: ethernet: ti: davinci_mdio: switch to readl/writel_relaxed() Grygorii Strashko
@ 2019-03-29 1:00 ` Arnd Bergmann
2019-03-29 9:11 ` Grygorii Strashko
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-29 1:00 UTC (permalink / raw)
To: Grygorii Strashko
Cc: David S. Miller, Networking, Sekhar Nori,
Linux Kernel Mailing List, linux-omap, Linux ARM
On Fri, Mar 29, 2019 at 1:10 AM Grygorii Strashko
<grygorii.strashko@ti.com> wrote:
>
> Switch to readl/writel_relaxed() APIs, because this is recommended
> API and the MDIO block is reused on Keystone 2 SoCs
> where LE/BE modes are supported.
>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
In general, my recommendation would be to use readl/writel instead of
readl_relaxed/writel_relaxed everywhere, because they have much
more predictible behavior. If you want to use the _relaxed version
in the fast-path for data traffic, that is usually fine, but then I would
add a comment next to it to explain why it is safe there without extra
barriers to serialize with spinlocks and DMA.
Changing away from __raw_*() to enable big-endian mode is of
course a good idea as well.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: ethernet: ti: davinci_mdio: switch to readl/writel_relaxed()
2019-03-29 1:00 ` Arnd Bergmann
@ 2019-03-29 9:11 ` Grygorii Strashko
0 siblings, 0 replies; 3+ messages in thread
From: Grygorii Strashko @ 2019-03-29 9:11 UTC (permalink / raw)
To: Arnd Bergmann
Cc: David S. Miller, Networking, Sekhar Nori,
Linux Kernel Mailing List, linux-omap, Linux ARM
Hi Arnd,
On 29.03.19 03:00, Arnd Bergmann wrote:
> On Fri, Mar 29, 2019 at 1:10 AM Grygorii Strashko
> <grygorii.strashko@ti.com> wrote:
>>
>> Switch to readl/writel_relaxed() APIs, because this is recommended
>> API and the MDIO block is reused on Keystone 2 SoCs
>> where LE/BE modes are supported.
>>
>> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
>
> In general, my recommendation would be to use readl/writel instead of
> readl_relaxed/writel_relaxed everywhere, because they have much
> more predictible behavior. If you want to use the _relaxed version
> in the fast-path for data traffic, that is usually fine, but then I would
> add a comment next to it to explain why it is safe there without extra
> barriers to serialize with spinlocks and DMA.
>
it's not fast path, so readl/writel should be ok. I'll resend.
--
Best regards,
grygorii
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-29 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-28 17:09 [PATCH net-next] net: ethernet: ti: davinci_mdio: switch to readl/writel_relaxed() Grygorii Strashko
2019-03-29 1:00 ` Arnd Bergmann
2019-03-29 9:11 ` Grygorii Strashko
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).