Date: Mon, 6 Oct 2014 20:15:22 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Martin Galvan <omgalvan.86@gmail.com> Cc: freebsd-drivers@freebsd.org, freebsd-embedded@freebsd.org Subject: Re: A few questions about SD/MMC drivers Message-ID: <20141006171521.GD26076@kib.kiev.ua> In-Reply-To: <CAN19L9ENsuAR6_aXwJSRdfDz6UgE6kU%2BrCkGGsdK7tRcUes%2B0w@mail.gmail.com> References: <CAN19L9ENsuAR6_aXwJSRdfDz6UgE6kU%2BrCkGGsdK7tRcUes%2B0w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Oct 05, 2014 at 07:05:16PM -0300, Martin Galvan wrote:
> 3) Finally, I noticed in the Linux driver they sometimes wrap a
> register read operation around a do-while loop waiting on both the
> result of that read and a timer, like this:
>
> do {
> read_value = read_a_register(some_register);
> } while ((read_value != desired_value) && (time_before(jiffies, expire));
>
> where "expire" is an unsigned long whose value is computed as the sum
> of a global called "jiffies" and the result of a call to
> msecs_to_jiffies(). This is done so after the loop they can check
> whether the register holds the desired value or a timeout occurred. Do
> we have something similar on BSD? If not, what would be a safer way to
> implement a timeout mechanism than simply decreasing a counter?
Look at the _intel_wait_for() in the sys/dev/drm2/i915/intel_drv.h.
There is improved version of the macro in the i915 update I posted
several days ago.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20141006171521.GD26076>
