Skip to contentSkip to conversation

w1: mxc_w1 bus search failing after update 3.16->3.18

REGRESSION Martin Fuzzey 1 participant 1 message Feb 5, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

The commit f80b258 w1: mxc_w1: Optimize mxc_w1_ds2_touch_bit() introduced in 3.18 is causing w1 bus scanning to fail on my board with:

w1_master_driver w1_bus_master1: w1_search: max_slave_count 64 reached, will continue next search.

The problem appears to be the use of jiffies to implement a 200us delay in this code:

static u8 mxc_w1_ds2_touch_bit(void *data, u8 bit)

{
     struct mxc_w1_device *dev = data;
     unsigned long timeout;

     writeb(MXC_W1_CONTROL_WR(bit), dev->regs + MXC_W1_CONTROL);

     /* Wait for read/write bit (60us, Max 120us), use 200us for sure */
     timeout = jiffies + usecs_to_jiffies(200);

     udelay(60);

     do {
         u8 ctrl = readb(dev->regs + MXC_W1_CONTROL);

         /* RDST bit is valid after the WR1/RD bit is self-cleared */
         if (!(ctrl & MXC_W1_CONTROL_WR(bit)))
             return !!(ctrl & MXC_W1_CONTROL_RDST);
     } while (time_is_after_jiffies(timeout));

     return 0;
}

My HZ value is 100
usecs_to_jiffies(200) returns 1 but I don't think time_is_after_jiffies is accurate for timeout = jiffies + 1?

Adding one jiffy to timeout "fixes" it but that's probably not the right way.

Should this be reverted or a hrtimer used?

Regards,

Martin