[Intel-gfx] [PATCH 2/5] intel_mmio: Allow mmio without debugfs
Jesse Barnes
jbarnes at virtuousgeek.org
Fri Feb 22 17:49:05 CET 2013
On Thu, 21 Feb 2013 22:05:33 -0800
Ben Widawsky <ben at bwidawsk.net> wrote:
> With the introduction of the forcewake dance:
>
> commit cac8f8b52621f246a7cff412f340a7db28cb1b99
> Author: Ben Widawsky <ben at bwidawsk.net>
> Date: Thu Jul 28 13:40:19 2011 -0700
>
> forcewake: Add mmio code to do proper forcewake stuff for gen6
>
> We lost the ability to do register access when either debugfs isn't
> mounted, or when the driver isn't loaded. The latter can be beneficial
> in debugging situations.
>
> This patch will allow the driver to still do mmio (leaving forcewake
> management up to the callers) provided that the i915 driver appears to
> not be loaded (according to sysfs)
>
> Requested by Jesse.
>
> Cc: Jesse Barnes <jbarnes at virtuousgeek.org>
> Signed-off-by: Ben Widawsky <ben at bwidawsk.net>
> ---
> lib/intel_mmio.c | 30 ++++++++++++++++++++++++++----
> 1 file changed, 26 insertions(+), 4 deletions(-)
>
> diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
> index 2281037..3933080 100644
> --- a/lib/intel_mmio.c
> +++ b/lib/intel_mmio.c
> @@ -43,6 +43,8 @@
>
> #include "intel_gpu_tools.h"
>
> +#define FAKEKEY 0x2468ace0
> +
> void *mmio;
>
> static struct _mmio_data {
> @@ -153,6 +155,22 @@ release_forcewake_lock(int fd)
> close(fd);
> }
>
> +/* Dumb check to see if i915 was loaded */
> +static bool
> +i915_loaded(void)
> +{
> + struct stat sb;
> + int ret;
> +
> + ret = stat("/sys/module/i915/", &sb);
> + if (ret) {
> + return false;
> + }
> +
> + assert(S_ISDIR(sb.st_mode));
> + return true;
> +}
> +
> /*
> * Initialize register access library.
> *
> @@ -188,10 +206,14 @@ intel_register_access_init(struct pci_device *pci_dev, int safe)
> ret = find_debugfs_path("/debug/dri");
> if (ret) {
> fprintf(stderr, "Couldn't find path to dri/debugfs entry\n");
> - return ret;
> + if (i915_loaded()) {
> + fprintf(stderr, "i915 loaded; not proceeding.\n");
> + return ret;
> + }
> }
> - }
> - mmio_data.key = get_forcewake_lock();
> + mmio_data.key = FAKEKEY;
> + } else
> + mmio_data.key = get_forcewake_lock();
>
> done:
> mmio_data.inited++;
> @@ -201,7 +223,7 @@ done:
> void
> intel_register_access_fini(void)
> {
> - if (mmio_data.key)
> + if (mmio_data.key && mmio_data.key != FAKEKEY)
> release_forcewake_lock(mmio_data.key);
> mmio_data.inited--;
> }
Cool thanks. So it looks like it'll bail out if you've loaded i915 but
debugfs isn't mounted? I guess that's fine; in that case we really do
want to do the forcewake thing...
--
Jesse Barnes, Intel Open Source Technology Center
More information about the Intel-gfx
mailing list