lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8f68f1dc-1841-4d28-b0b5-d968b1950e81@lunn.ch>
Date:   Wed, 16 Aug 2023 03:29:24 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     "Hawkins, Nick" <nick.hawkins@....com>
Cc:     "christophe.jaillet@...adoo.fr" <christophe.jaillet@...adoo.fr>,
        "simon.horman@...igine.com" <simon.horman@...igine.com>,
        "Verdun, Jean-Marie" <verdun@....com>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "edumazet@...gle.com" <edumazet@...gle.com>,
        "kuba@...nel.org" <kuba@...nel.org>,
        "pabeni@...hat.com" <pabeni@...hat.com>,
        "robh+dt@...nel.org" <robh+dt@...nel.org>,
        "krzysztof.kozlowski+dt@...aro.org" 
        <krzysztof.kozlowski+dt@...aro.org>,
        "conor+dt@...nel.org" <conor+dt@...nel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/5] net: hpe: Add GXP UMAC MDIO

On Wed, Aug 16, 2023 at 12:55:56AM +0000, Hawkins, Nick wrote:
> Greetings Andrew,
> 
> I have a follow up question below:
> 
> >> +static int umac_mdio_read(struct mii_bus *bus, int phy_id, int reg)
> >> +{
> >> + struct umac_mdio_priv *umac_mdio = bus->priv;
> >> + unsigned int status;
> >> + unsigned int value;
> >> + int ret;
> >> +
> >> + status = __raw_readl(umac_mdio->base + UMAC_MII);
> >> +
> >> + status &= ~(UMAC_MII_PHY_ADDR_MASK | UMAC_MII_REG_ADDR_MASK);
> >> + status |= ((phy_id << UMAC_MII_PHY_ADDR_SHIFT) &
> >> + UMAC_MII_PHY_ADDR_MASK);
> >> + status |= (reg & UMAC_MII_REG_ADDR_MASK);
> >> + status |= UMAC_MII_MRNW; /* set bit for read mode */
> >> + __raw_writel(status, umac_mdio->base + UMAC_MII);
> >> +
> >> + status |= UMAC_MII_MOWNER; /* set bit to activate mii transfer */
> >> + __raw_writel(status, umac_mdio->base + UMAC_MII);
> 
> 
> > I assume UMAC_MII_MOWNER must be set in a separate operation? But
> > using __raw_writel() i'm not sure there is any barrier between the two
> > writes.
> 
> Is there a function you would recommend using instead?

writel().

In general, it is best to use writel()/readl() for correctness. In the
hot path, dealing with actually Ethernet frames where every uS counts,
you can then think about using writel_relaxed()/readl_relaxed(). But
for something slow like an MDIO bus driver, i would always avoid the
possibility of having hard to find bugs because of missing barriers.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ