Re: [PATCH 1/2] net: ethernet: bgmac: init sequence bug

From: Sergei Shtylyov
Date: Thu Feb 02 2017 - 04:47:51 EST


Hello!

On 2/2/2017 1:39 AM, Jon Mason wrote:

From: Zac Schroff <zschroff@xxxxxxxxxxxx>

Fix a bug in the 'bgmac' driver init sequence that blind writes for init
sequence where it should preserve most bits other than the ones it is
deliberately manipulating.

Signed-off-by: Zac Schroff <zschroff@xxxxxxxxxxxx>
Signed-off-by: Jon Mason <jon.mason@xxxxxxxxxxxx>
Fixes: f6a95a24957 ("net: ethernet: bgmac: Add platform device support")
---
drivers/net/ethernet/broadcom/bgmac-platform.c | 10 +++++++---
include/linux/bcma/bcma_regs.h | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac-platform.c b/drivers/net/ethernet/broadcom/bgmac-platform.c
index 6f736c1..9bbe05c 100644
--- a/drivers/net/ethernet/broadcom/bgmac-platform.c
+++ b/drivers/net/ethernet/broadcom/bgmac-platform.c
@@ -61,15 +61,19 @@ static bool platform_bgmac_clk_enabled(struct bgmac *bgmac)

static void platform_bgmac_clk_enable(struct bgmac *bgmac, u32 flags)
{
- bgmac_idm_write(bgmac, BCMA_IOCTL,
- (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC | flags));
+ u32 regval;
+
+ /* Some bits of BCMA_IOCTL set by HW/ATF & should not change */
+ regval = bgmac_idm_read(bgmac, BCMA_IOCTL) & BCMA_IOCTL_DO_NOT_MODIFY;
+ regval |= ((flags & (~BCMA_IOCTL_DO_NOT_MODIFY)) | BCMA_IOCTL_CLK);

The innermost parens aren't necessary. And the outermost as well.

[...]

MBR, Sergei