Re: [PATCH net-next 17/19] net: ethernet: ti: cpsw: introduce mac sl module api

From: Andrew Lunn
Date: Tue Apr 23 2019 - 15:02:02 EST


On Tue, Apr 23, 2019 at 04:09:08PM +0300, Grygorii Strashko wrote:
> +void cpsw_sl_reset(struct cpsw_sl *sl, unsigned long tmo)
> +{
> + unsigned long timeout = jiffies + msecs_to_jiffies(tmo);
> +
> + /* Set the soft reset bit */
> + cpsw_sl_reg_write(sl, CPSW_SL_SOFT_RESET, CPSW_SL_SOFT_RESET_BIT);
> +
> + /* Wait for the bit to clear */
> + do {
> + cpu_relax();
> + } while ((cpsw_sl_reg_read(sl, CPSW_SL_SOFT_RESET) &
> + CPSW_SL_SOFT_RESET_BIT) &&
> + time_after(timeout, jiffies));

Hi Grygorii

If you are waiting for milliseconds, you probably should have a
sleep/delay in here.

> +int cpsw_sl_wait_for_idle(struct cpsw_sl *sl, unsigned long tmo)
> +{
> + unsigned long timeout = jiffies + msecs_to_jiffies(tmo);
> +
> + do {
> + cpu_relax();
> + } while (!(cpsw_sl_reg_read(sl, CPSW_SL_MACSTATUS) &
> + sl->idle_mask) && time_after(timeout, jiffies));
> +

Same here.

> + if (!(cpsw_sl_reg_read(sl, CPSW_SL_MACSTATUS) & sl->idle_mask)) {
> + dev_err(sl->dev, "cpsw_sl failed to soft-reset.\n");
> + return -ETIMEDOUT;
> + }
> +
> + return 0;

Andrew