<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEEDINFO "
   title="NEEDINFO - Display Port BYT-M [N2807] - Data link training fails sporadically"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=93956#c4">Comment # 4</a>
              on <a class="bz_bug_link 
          bz_status_NEEDINFO "
   title="NEEDINFO - Display Port BYT-M [N2807] - Data link training fails sporadically"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=93956">bug 93956</a>
              from <span class="vcard"><a class="email" href="mailto:zoran.stojsavljevic@intel.com" title="Zoran Stojsavljevic <zoran.stojsavljevic@intel.com>"> <span class="fn">Zoran Stojsavljevic</span></a>
</span></b>
        <pre>Hello Jim,

I would write this code differently:

482         struct drm_i915_private *dev_priv = bus->dev_priv;
483 --      int i = 0, inc, try = 0;
483 ++      int i = 0, inc = 1, try = 0;
484         int ret = 0;
485 
486         intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
487         mutex_lock(&dev_priv->gmbus_mutex);
488 
489         if (bus->force_bit) {
490                 ret = i2c_bit_algo.master_xfer(adapter, msgs, num);
491                 goto out;
492         }
493 
494 retry:
495         I915_WRITE(GMBUS0, bus->reg0);
496 
497         for (; i < num; i += inc) {
498 --              inc = 1;
499                 if (gmbus_is_index_read(msgs, i, num)) {
500                         ret = gmbus_xfer_index_read(dev_priv, &msgs[i]);
501                         inc = 2; /* an index read is two msgs */
502                 } else if (msgs[i].flags & I2C_M_RD) {
503                         ret = gmbus_xfer_read(dev_priv, &msgs[i], 0);
504                 } else {
505                         ret = gmbus_xfer_write(dev_priv, &msgs[i]);
506                 }
507 
508                 if (ret == -ETIMEDOUT)
509                         goto timeout;
510                 if (ret == -ENXIO)
511                         goto clear_err;
512 
513                 ret = gmbus_wait_hw_status(dev_priv, GMBUS_HW_WAIT_PHASE,
514                                            GMBUS_HW_WAIT_EN);
515                 if (ret == -ENXIO)
516                         goto clear_err;
517                 if (ret)
518                         goto timeout;
519         }

Since you can be potentially stuck in:
497         for (; i < num; i += inc) {

forever.

Thank you,
Zoran</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are on the CC list for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>