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] [day] [month] [year] [list]
Date:	Thu, 25 Jun 2015 20:55:51 -0500
From:	Scott Wood <scottwood@...escale.com>
To:	igal.liberman@...escale.com
CC:	netdev@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org,
	madalin.bucur@...escale.com, pebolle@...cali.nl
Subject: Re: [v2,3/9] fsl/fman: Add the FMan MAC FLIB

On Wed, 2015-06-24 at 22:34 +0300, igal.liberman@...escale.com wrote:
> From: Igal Liberman <Igal.Liberman@...escale.com>
> 
> The FMan MAC FLib provides basic API used by the drivers to
> configure and control the FMan MAC hardware.
> 
> Signed-off-by: Igal Liberman <Igal.Liberman@...escale.com>
...
> > +int fman_dtsec_mii_write_reg(struct dtsec_mii_reg __iomem *regs, uint8_t 
> addr,
> +                          uint8_t reg, uint16_t data, uint16_t dtsec_freq)
> +{
> +     uint32_t tmp;
> +
> +     /* Setup the MII Mgmt clock speed */
> +     iowrite32be((uint32_t)dtsec_mii_get_div(dtsec_freq), &regs->miimcfg);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Stop the MII management read cycle */
> +     iowrite32be(0, &regs->miimcom);
> +     /* Dummy read to make sure MIIMCOM is written */
> +     tmp = ioread32be(&regs->miimcom);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Setting up MII Management Address Register */
> +     tmp = (uint32_t)((addr << MIIMADD_PHY_ADDR_SHIFT) | reg);
> +     iowrite32be(tmp, &regs->miimadd);
> +     /* Memory barrier */
> +     wmb();
> +
> +     /* Setting up MII Management Control Register with data */
> +     iowrite32be((uint32_t)data, &regs->miimcon);
> +     /* Dummy read to make sure MIIMCON is written */
> +     tmp = ioread32be(&regs->miimcon);
> +     /* Memory barrier */
> +     wmb();

iowrite32be() should already contain a memory barrier.

> +
> +     /* Wait until MII management write is complete */
> +     /* todo: a timeout could be useful here */
> +     while ((ioread32be(&regs->miimind)) & MIIMIND_BUSY)
> +             ; /* busy wait */
> +
> +     return 0;
> +}

Please add the timeout.

> +     /* Read MII management status  */
> +     *data = (uint16_t)ioread32be(&regs->miimstat);

Unnecessary cast (please check for these throughout the patchset).

There are also casts in this patchset that are only needed because a variable 
was unnecessarily defined with a smaller-than-32-bit data type.


> +void fman_memac_reset(struct memac_regs __iomem *regs)
> +{
> +     uint32_t tmp;
> +
> +     tmp = ioread32be(&regs->command_config);
> +
> +     tmp |= CMD_CFG_SW_RESET;
> +
> +     iowrite32be(tmp, &regs->command_config);
> +
> +     while (ioread32be(&regs->command_config) & CMD_CFG_SW_RESET)
> +             ;
> +}

Timeout, here and in all such loops.

-Scott

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ