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: <20190809.124327.1282600811774499704.davem@davemloft.net>
Date:   Fri, 09 Aug 2019 12:43:27 -0700 (PDT)
From:   David Miller <davem@...emloft.net>
To:     Jose.Abreu@...opsys.com
Cc:     netdev@...r.kernel.org, Joao.Pinto@...opsys.com
Subject: Re: [PATCH net-next 01/12] net: stmmac: Get correct timestamp
 values from XGMAC

From: Jose Abreu <Jose.Abreu@...opsys.com>
Date: Fri,  9 Aug 2019 20:36:09 +0200

> +	void __iomem *ioaddr = hw->pcsr;
> +	int count = 0;
> +	u32 value;
> +
> +	do {
> +		if (readl_poll_timeout_atomic(ioaddr + XGMAC_TIMESTAMP_STATUS,
> +					      value, value & XGMAC_TXTSC,
> +					      100, 10000))
> +			break;
> +
> +		*ts = readl(ioaddr + XGMAC_TXTIMESTAMP_NSEC) & XGMAC_TXTSSTSLO;
> +		*ts += readl(ioaddr + XGMAC_TXTIMESTAMP_SEC) * 1000000000ULL;
> +	} while (count++);
> +
> +	if (count)
> +		return 0;
> +	return -EBUSY;

This is a very strange construct, the loop never executes more than once.
Simplified it is essentially:

	if (readl_poll_timeout_atomic(ioaddr + XGMAC_TIMESTAMP_STATUS,
				      value, value & XGMAC_TXTSC,
				      100, 10000))
		return -EBUSY;

	*ts = readl(ioaddr + XGMAC_TXTIMESTAMP_NSEC) & XGMAC_TXTSSTSLO;
	*ts += readl(ioaddr + XGMAC_TXTIMESTAMP_SEC) * 1000000000ULL;
	return 0;

Don't make the code more complicated than it needs to be, there is no
reason to use a loop here.  And using a loop makes it look like the
loop is the polling/timeout construct, when it isn't, because
readl_poll_timeout_atomic() is serving that purpose.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ