Subject: Re: DRI/DRM Intel 945GM problem
To: None <tech-x11@netbsd.org>
From: Ahmad M. Afuni <pseudo.statistic@gmail.com>
List: tech-x11
Date: 05/21/2007 01:24:09
Hey,

Applied your patch but, unfortunately, it caused my system to lock up.
Xorg.0.log says the same thing about being unable to load the module.

Thanks anyway,

Ahmad
On 5/20/07, Chavdar Ivanov <ci4ic4@gmail.com> wrote:
> On 20/05/07, Ahmad M. Afuni <pseudo.statistic@gmail.com> wrote:
> > Hey,
> > I compiled my kernel (GENERIC.MP) with:
> > i915drm*        at vga?         # Intel i915, i945 DRM driver
> > And so dmesg tells me:
> > i915drm0 at vga1
> > info: [drm] Intel i945GM (unit 0)
> > info: [drm] AGP at 0xc0000000 256MB
> > info: [drm] Initialized i915 1.5.0 20060119
> > Which seems OK.
> > Now, to install xorg, I installed (from pkgsrc) x11/xf86-video-i810,
> > modular-xorg-server, and the usual mouse/keyboard input drivers.
> > I had:
> > X11_TYPE=modular
> > PKG_OPTIONS.xorg-server=dri
> > in my mk.conf.
> > Now, after installing the above, I tried X out, only to have this in
> > my Xorg.0.log:
> > drmOpenDevice: node name is /dev/dri/card0
> > drmOpenDevice: open result is 8, (OK)
> > drmOpenDevice: node name is /dev/dri/card0
> > drmOpenDevice: open result is 8, (OK)
> > [drm] failed to load kernel module "i915"
>
> I am sure I have been there at some point, but I can hardly remember
> exactly how I fixed it. I've kinda lost the number of
> modular-xorg-server* and mesa-dri* compilations; it's good fun,
> anyway.
>
>  You got your /dev/dri/card0 as expected with the right mode?
>
> You followed generally what is in:
> http://mail-index.netbsd.org/tech-x11/2007/03/19/0000.html ?
>
> Maybe the following will help you (it did it for me), taken against
> -current from a few days ago:
>
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> --- sys/dev/pci/agp_i810.c.orig 2007-05-14 20:13:55.000000000 +0100
> +++ sys/dev/pci/agp_i810.c      2007-05-14 14:43:51.000000000 +0100
> @@ -71,28 +71,6 @@
>                 }                                                       \
>         } while (0)
>
> -#define CHIP_I810 0    /* i810/i815 */
> -#define CHIP_I830 1    /* 830M/845G */
> -#define CHIP_I855 2    /* 852GM/855GM/865G */
> -#define CHIP_I915 3    /* 915G/915GM/945G/945GM */
> -
> -struct agp_i810_softc {
> -       u_int32_t initial_aperture;     /* aperture size at startup */
> -       struct agp_gatt *gatt;
> -       int chiptype;                   /* i810-like or i830 */
> -       u_int32_t dcache_size;          /* i810 only */
> -       u_int32_t stolen;               /* number of i830/845 gtt entries
> -                                          for stolen memory */
> -       bus_space_tag_t bst;            /* register bus_space tag */
> -       bus_space_handle_t bsh;         /* register bus_space handle */
> -       bus_space_tag_t gtt_bst;        /* GTT bus_space tag */
> -       bus_space_handle_t gtt_bsh;     /* GTT bus_space handle */
> -       struct pci_attach_args vga_pa;
> -
> -       void *sc_powerhook;
> -       struct pci_conf_state sc_pciconf;
> -};
> -
>  static u_int32_t agp_i810_get_aperture(struct agp_softc *);
>  static int agp_i810_set_aperture(struct agp_softc *, u_int32_t);
>  static int agp_i810_bind_page(struct agp_softc *, off_t, bus_addr_t);
> @@ -725,7 +703,7 @@
>          * Until the issue is solved, simply restore it.
>          */
>
> -#if 0
> +#if 1
>         regval = bus_space_read_4(isc->bst, isc->bsh, AGP_I810_PGTBL_CTL);
>         if (regval != (isc->gatt->ag_physical | 1)) {
>                 printf("agp_i810_bind_memory: PGTBL_CTL is 0x%x - fixing\n",
> --- sys/dev/pci/agpvar.h.orig   2007-05-14 20:13:55.000000000 +0100
> +++ sys/dev/pci/agpvar.h        2007-05-14 14:45:43.000000000 +0100
> @@ -161,6 +161,28 @@
>         size_t            ag_size;
>  };
>
> +#define CHIP_I810 0    /* i810/i815 */
> +#define CHIP_I830 1    /* 830M/845G */
> +#define CHIP_I855 2    /* 852GM/855GM/865G */
> +#define CHIP_I915 3    /* 915G/915GM/945G/945GM */
> +
> +struct agp_i810_softc {
> +       u_int32_t initial_aperture;     /* aperture size at startup */
> +       struct agp_gatt *gatt;
> +       int chiptype;                   /* i810-like or i830 */
> +       u_int32_t dcache_size;          /* i810 only */
> +       u_int32_t stolen;               /* number of i830/845 gtt entries
> +                                          for stolen memory */
> +       bus_space_tag_t bst;            /* register bus_space tag */
> +       bus_space_handle_t bsh;         /* register bus_space handle */
> +       bus_space_tag_t gtt_bst;        /* GTT bus_space tag */
> +       bus_space_handle_t gtt_bsh;     /* GTT bus_space handle */
> +       struct pci_attach_args vga_pa;
> +
> +       void *sc_powerhook;
> +       struct pci_conf_state sc_pciconf;
> +};
> +
>  int agpbusprint(void *, const char *);
>
>  /*
> --- sys/dev/drm/drm_drv.c.orig  2007-05-14 20:14:08.000000000 +0100
> +++ sys/dev/drm/drm_drv.c       2007-05-14 14:49:54.000000000 +0100
> @@ -526,7 +526,7 @@
>         }
>
>         for(i = 0; i<DRM_MAX_PCI_RESOURCE; i++) {
> -               if (dev->pci_map_data[i].mapped > 1) {
> +               if (dev->pci_map_data[i].mapped > 0) {
>                         bus_space_unmap(dev->pci_map_data[i].maptype,
>                                         dev->pci_map_data[i].bsh,
>                                         dev->pci_map_data[i].size);
> @@ -691,7 +691,7 @@
>         i = 0;
>
>         for (i = 0; i < DRM_MAX_PCI_RESOURCE; i++)
> -               if (dev->pci_map_data[i].mapped != 0)
> +               if (dev->pci_map_data[i].mapped > 0)
>                 {
>                         bus_space_unmap(dev->pa.pa_memt,
>                                         dev->pci_map_data[i].bsh,
> --- sys/dev/drm/drm_memory.c.orig       2007-05-14 20:14:08.000000000 +0100
> +++ sys/dev/drm/drm_memory.c    2007-05-14 14:51:39.000000000 +0100
> @@ -97,8 +97,9 @@
>                         map->bst = dev->pa.pa_memt;
>                         map->cnt = &(dev->pci_map_data[i].mapped);
>                         map->mapsize = dev->pci_map_data[i].size;
> -                       dev->pci_map_data[i].mapped++;
> -                       if (dev->pci_map_data[i].mapped > 1)
> +                        if (dev->pci_map_data[i].mapped >= 0)
> +                                dev->pci_map_data[i].mapped++;
> +                        if (dev->pci_map_data[i].mapped != 1)
>                         {
>                                 map->bsh = dev->pci_map_data[i].bsh;
>                                 return dev->pci_map_data[i].vaddr;
> --- sys/dev/pci/drm/i915_drv.c.orig     2007-05-14 20:13:55.000000000 +0100
> +++ sys/dev/pci/drm/i915_drv.c  2007-05-14 14:54:36.000000000 +0100
> @@ -39,6 +39,8 @@
>  #include "i915_drm.h"
>  #include "i915_drv.h"
>  #include "drm_pciids.h"
> +#include "agp_i810.h"
> +
>
>  /* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
>  static drm_pci_id_list_t i915_pciidlist[] = {
> @@ -134,9 +136,34 @@
>         struct pci_attach_args *pa = aux;
>         drm_device_t *dev = (drm_device_t *)self;
>
> +#if NAGP_I810 > 0
> +       struct agp_softc *agpsc;
> +       struct agp_i810_softc *agpi810sc;
> +       int reg;
> +#endif
> +
> +
>         i915_configure(dev);
>
>         drm_attach(self, pa, i915_pciidlist);
> +
> +#if NAGP_I810 > 0
> +       agpsc = (struct agp_softc *)agp_find_device(0);
> +       if(agpsc == NULL || agpsc->as_chipc == NULL)
> +               return;
> +
> +       agpi810sc = agpsc->as_chipc;
> +        if(agpi810sc->chiptype == CHIP_I915)
> +               reg = 0;
> +       else
> +               reg = 1;
> +
> +       dev->pci_map_data[reg].bsh = agpi810sc->bsh;
> +       dev->pci_map_data[reg].mapped = -1; /* never unmap */
> +       dev->pci_map_data[reg].vaddr =
> +               bus_space_vaddr(agpi810sc->bst, agpi810sc->bsh);
> +#endif
> +
>  }
>
>  CFATTACH_DECL(i915drm, sizeof(drm_device_t), i915drm_probe, i915drm_attach,
> --------------------------------------------------------
>
> > (II) I810(0): [drm] drmOpen failed
> > (EE) I810(0): [dri] DRIScreenInit failed. Disabling DRI.
> > Afterwards, realizing that I needed mesa-dri, I installed wip/mesa-dri
> > and copied over the MesaLib.buildlink3.mk file over to
> > graphics/MesaLib/buildlink3.mk.
>
> I am presently running Xorg7.2+Mesa652+dri on my laptop; the only
> problem is I could not get AIGLX to work. Of the more interesting
> OpenGL applications available, I got Blender to run accelerated, and
> of course BZFlag!
>
> I got even Xorg7.3 + Mesa653+dri working, but for some reason the
> server did not recognize the 'vt05' option, which lead to some weird
> effects when used with gdm - like sometimes the keyboard attached to
> one of the wscons terminals behind... also on occasions some keys got
> repeated many times with no reason; this was even running with AIGLX
> and Composite and   I was able to try starting Compiz and Beryl; the
> latter kinda ran, but gave mostly white background with occasional
> window brought in with ALT-Tab; the former did tjhe '--replace' bit
> but then refused to continue due to the lack of a particular call.
> I've since reverted back to the initial accelerated setup - mainly
> because of the problem with the VTs (and also because otherwise I had
> to recompile every OpenGL application - that's another story).
>
> > Furthermore, I pkg_deleted i810's driver and rebuilt it.
>
> I also did that just in case, although I don't believe it made any difference.
>
> > Still, exact same error. I must've missed something.
> > Anyone know what that might be?
> >
> > Thanks,
> > Ahmad
> >
>
> Chavdar Ivanov
>