NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: xsrc/42262: Thinkpad T500 Intel GM45 Express X doesn't like i915drm



The following reply was made to PR xsrc/42262; it has been noted by GNATS.

From: Jeremy Morse <jeremy.morse%gmail.com@localhost>
To: Matthias Pfaller <leo%marco.de@localhost>
Cc: gnats-bugs%NetBSD.org@localhost, xsrc-manager%netbsd.org@localhost, 
 gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost, 
spz%serpens.de@localhost
Subject: Re: xsrc/42262: Thinkpad T500 Intel GM45 Express X doesn't like 
  i915drm
Date: Sun, 10 Jan 2010 14:54:13 +0000

 This is an OpenPGP/MIME signed message (RFC 2440 and 3156)
 --------------enigB1D19646EEC11719B8DAA618
 Content-Type: multipart/mixed;
  boundary="------------050208090909040702040405"
 
 This is a multi-part message in MIME format.
 --------------050208090909040702040405
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 I've ETOOMUCHWORK'd on this for a while, but recently had access to a
 laptop with GM45 graphics and a serial port. It looks like the previous
 patches I posted were going in the right direction but with not enough
 detail - the attached patch gets X started fine on the laptop with
 commands queued through drm, however in Xorg log I get:
 
 (EE) AIGLX error: dlopen of /usr/X11R7/lib/modules/dri/i965_dri.so
 failed (/usr/X11R7/lib/modules/dri/i965_dri.so: Undefined symbol
 "driDriverApi" (symnum =3D 157))
 
 Which is a userland problem that I don't know how to fix right now.
 However it should address both the hang and crash previously reported.
 
 Some details on the patch:
  * latest intel gfx cards wish to sub-map part of agp space, which
 netbsd drm can't do right now
  * patch re-implements parts of drm_netbsd_ioremap to support this
  * entire mapping recorded in pci_map_data, submapping in drm_local_map_t=
 
  * store mapping vaddr in local_map's "handle" field
  * also inject some error checking + handling for drm_addmap
 
 --=20
 Thanks,
 Jeremy
 
 --------------050208090909040702040405
 Content-Type: text/plain;
  name="drm4.diff"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
  filename="drm4.diff"
 
 Index: bsd-core/drmP.h
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/sys/external/bsd/drm/dist/bsd-core/drmP.h,v
 retrieving revision 1.9.10.2
 diff -u -p -r1.9.10.2 drmP.h
 --- bsd-core/drmP.h    14 Aug 2009 21:40:49 -0000      1.9.10.2
 +++ bsd-core/drmP.h    10 Jan 2010 14:16:17 -0000
 @@ -650,6 +650,19 @@ typedef struct drm_sg_mem {
 =20
  typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;
 =20
 +#if defined(__NetBSD__)
 +/* XXX - moved pci_map_data_t declaration forward for use by drm_local_m=
 ap_t..*/
 +typedef struct {
 +      int                     mapped;
 +      int                     maptype;
 +      bus_addr_t              base;
 +      bus_size_t              size;
 +      bus_space_handle_t      bsh;
 +      int                     flags;
 +      void *                  vaddr;
 +} pci_map_data_t;
 +#endif
 +
  typedef struct drm_local_map {
        unsigned long   offset;  /* Physical address (0 for SAREA)*/
        unsigned long   size;    /* Physical size (bytes)           */
 @@ -667,7 +680,7 @@ typedef struct drm_local_map {
        bus_space_handle_t bsh;
        drm_dma_handle_t *dmah;
  #if defined(__NetBSD__)
 -      int *cnt;
 +      pci_map_data_t *fullmap;
        bus_size_t mapsize;
  #endif
        TAILQ_ENTRY(drm_local_map) link;
 @@ -784,18 +797,6 @@ struct drm_driver_info {
  /* Length for the array of resource pointers for drm_get_resource_*. */
  #define DRM_MAX_PCI_RESOURCE  6
 =20
 -#if defined(__NetBSD__)
 -typedef struct {
 -      int                     mapped;
 -      int                     maptype;
 -      bus_addr_t              base;
 -      bus_size_t              size;
 -      bus_space_handle_t      bsh;
 -      int                     flags;
 -      void *                  vaddr;
 -} pci_map_data_t;
 -#endif
 -
  /**=20
   * DRM device functions structure
   */
 Index: bsd-core/drm_bufs.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/sys/external/bsd/drm/dist/bsd-core/drm_bufs.c,v
 retrieving revision 1.2.10.1
 diff -u -p -r1.2.10.1 drm_bufs.c
 --- bsd-core/drm_bufs.c        20 Jun 2009 23:36:59 -0000      1.2.10.1
 +++ bsd-core/drm_bufs.c        10 Jan 2010 14:16:17 -0000
 @@ -159,16 +159,25 @@ int drm_addmap(struct drm_device * dev,=20
        map->size =3D size;
        map->type =3D type;
        map->flags =3D flags;
 -#ifdef __NetBSD__
 -      map->cnt =3D NULL;
 +#if defined(__NetBSD__)
 +      map->fullmap =3D NULL;
        map->mapsize =3D 0;
  #endif
 =20
        switch (map->type) {
        case _DRM_REGISTERS:
                map->handle =3D drm_ioremap(dev, map);
 +              if (map->handle =3D=3D NULL) {
 +                      DRM_ERROR("drm_addmap couldn't ioremap registers with "
 +                              "base %lX, size %lX\n",
 +                              (long) offset, (long) size);
 +                      DRM_LOCK();
 +                      return EINVAL;
 +              }
 +
                if (!(map->flags & _DRM_WRITE_COMBINING))
                        break;
 +
                /* FALLTHROUGH */
        case _DRM_FRAME_BUFFER:
                if (drm_mtrr_add(map->offset, map->size, DRM_MTRR_WC) =3D=3D 0)
 Index: bsd-core/drm_memory.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/sys/external/bsd/drm/dist/bsd-core/drm_memory.c,v
 retrieving revision 1.3.10.1
 diff -u -p -r1.3.10.1 drm_memory.c
 --- bsd-core/drm_memory.c      20 Jun 2009 23:36:59 -0000      1.3.10.1
 +++ bsd-core/drm_memory.c      10 Jan 2010 14:16:18 -0000
 @@ -85,29 +85,45 @@ void drm_mem_uninit(void)
  static void *
  drm_netbsd_ioremap(struct drm_device *dev, drm_local_map_t *map, int wc)=
 
  {
 +      bus_space_handle_t h;
        int i, reg, reason;
        for(i =3D 0; i<DRM_MAX_PCI_RESOURCE; i++) {
                reg =3D PCI_MAPREG_START + i*4;
                if ((dev->pci_map_data[i].maptype =3D=3D PCI_MAPREG_TYPE_MEM ||
                     dev->pci_map_data[i].maptype =3D=3D
                        (PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_64BIT))=
  &&
 -                  dev->pci_map_data[i].base =3D=3D map->offset             &&
 -                  dev->pci_map_data[i].size >=3D map->size)
 +                  map->offset >=3D dev->pci_map_data[i].base             &&
 +                  map->offset + map->size <=3D dev->pci_map_data[i].base +
 +                                              dev->pci_map_data[i].size)=
 
                {
                        map->bst =3D dev->pa.pa_memt;
 -                      map->cnt =3D &(dev->pci_map_data[i].mapped);
 -                      map->mapsize =3D dev->pci_map_data[i].size;
 +                      map->fullmap =3D &(dev->pci_map_data[i]);
 +                      map->mapsize =3D map->size;
                        dev->pci_map_data[i].mapped++;
                        if (dev->pci_map_data[i].mapped > 1)
                        {
 -                              map->bsh =3D dev->pci_map_data[i].bsh;
 -                              return dev->pci_map_data[i].vaddr;
 +                              if ((reason =3D bus_space_subregion(
 +                                              dev->pa.pa_memt,
 +                                              dev->pci_map_data[i].bsh,
 +                                              map->offset - 
dev->pci_map_data[i].base,
 +                                              map->size, &h)) !=3D 0)  {
 +                                      DRM_DEBUG("ioremap failed to "
 +                                              "bus_space_subregion: %d\n",
 +                                              reason);
 +                                      return NULL;
 +                              }
 +                              map->bsh =3D h;
 +                              map->handle =3D bus_space_vaddr(dev->pa.pa_memt,
 +                                                                      h);
 +                              return map->handle;
                        }
                        DRM_DEBUG("ioremap%s: flags %d\n", wc ? "_wc" : "",
                                  dev->pci_map_data[i].flags);
 -                      if ((reason =3D bus_space_map(map->bst, map->offset,
 +                      if ((reason =3D bus_space_map(map->bst,
 +                                      dev->pci_map_data[i].base,
                                        dev->pci_map_data[i].size,
 -                                      dev->pci_map_data[i].flags, &map->bsh)))
 +                                      dev->pci_map_data[i].flags,
 +                                      &dev->pci_map_data[i].bsh)))
                        {
                                dev->pci_map_data[i].mapped--;
  #if NAGP_I810 > 0 /* XXX horrible kludge: agp might have mapped it */
 @@ -118,13 +134,29 @@ drm_netbsd_ioremap(struct drm_device *de
                                          reason);
                                return NULL;
                        }
 -                      dev->pci_map_data[i].bsh =3D map->bsh;
 -                      dev->pci_map_data[i].vaddr =3D
 -                                      bus_space_vaddr(map->bst, map->bsh);
 +
 +                      dev->pci_map_data[i].vaddr =3D bus_space_vaddr(map->bst,
 +                                              dev->pci_map_data[i].bsh);
 +
 +                      /* Caller might have requested a submapping of that */
 +                      if ((reason =3D bus_space_subregion(
 +                                      dev->pa.pa_memt,
 +                                      dev->pci_map_data[i].bsh,
 +                                      map->offset - dev->pci_map_data[i].base,
 +                                      map->size, &h)) !=3D 0)  {
 +                              DRM_DEBUG("ioremap failed to "
 +                                      "bus_space_subregion: %d\n",
 +                                      reason);
 +                              return NULL;
 +                      }
 +
                        DRM_DEBUG("ioremap mem found for %lx, %lx: %p\n",
                                map->offset, map->size,
                                dev->agp_map_data[i].vaddr);
 -                      return dev->pci_map_data[i].vaddr;
 +
 +                      map->bsh =3D h;
 +                      map->handle =3D bus_space_vaddr(dev->pa.pa_memt, h);
 +                      return map->handle;
                }
        }
        /* failed to find a valid mapping; all hope isn't lost though */
 @@ -133,7 +165,7 @@ drm_netbsd_ioremap(struct drm_device *de
                    dev->agp_map_data[i].base =3D=3D map->offset &&
                    dev->agp_map_data[i].size >=3D map->size) {
                        map->bst =3D dev->pa.pa_memt;
 -                      map->cnt =3D &(dev->agp_map_data[i].mapped);
 +                      map->fullmap =3D &(dev->agp_map_data[i]);
                        map->mapsize =3D dev->agp_map_data[i].size;
                        dev->agp_map_data[i].mapped++;
                        map->bsh =3D dev->agp_map_data[i].bsh;
 @@ -148,7 +180,7 @@ drm_netbsd_ioremap(struct drm_device *de
                        dev->agp_map_data[i].size =3D map->size;
                        dev->agp_map_data[i].flags =3D BUS_SPACE_MAP_LINEAR;
                        dev->agp_map_data[i].maptype =3D PCI_MAPREG_TYPE_MEM;
 -                      map->cnt =3D &(dev->agp_map_data[i].mapped);
 +                      map->fullmap =3D &(dev->agp_map_data[i]);
                        map->mapsize =3D dev->agp_map_data[i].size;
 =20
                        DRM_DEBUG("ioremap%s: flags %d\n", wc ? "_wc" : "",
 @@ -201,14 +233,16 @@ void drm_ioremapfree(drm_local_map_t *ma
  #if defined(__FreeBSD__)
        pmap_unmapdev((vm_offset_t) map->handle, map->size);
  #elif   defined(__NetBSD__)
 -      if (map->cnt =3D=3D NULL) {
 +      if (map->fullmap =3D=3D NULL) {
                DRM_INFO("drm_ioremapfree called for unknown map\n");
                return;
        }
 -      if (*(map->cnt) > 0) {
 -              (*(map->cnt))--;
 -              if(*(map->cnt) =3D=3D 0)
 -                      bus_space_unmap(map->bst, map->bsh, map->mapsize);
 +
 +      if (map->fullmap->mapped > 0) {
 +              map->fullmap->mapped--;
 +              if(map->fullmap->mapped =3D=3D 0)
 +                      bus_space_unmap(map->bst, map->fullmap->bsh,
 +                                      map->fullmap->size);
        }
  #endif
  }
 Index: shared-core/i915_dma.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /cvsroot/src/sys/external/bsd/drm/dist/shared-core/i915_dma.c,v=
 
 retrieving revision 1.1.1.3.10.1
 diff -u -p -r1.1.1.3.10.1 i915_dma.c
 --- shared-core/i915_dma.c     20 Jun 2009 23:37:01 -0000      1.1.1.3.10.1
 +++ shared-core/i915_dma.c     10 Jan 2010 14:16:21 -0000
 @@ -864,6 +864,8 @@ int i915_driver_load(struct drm_device *
 =20
        ret =3D drm_addmap(dev, base, size, _DRM_REGISTERS,
            _DRM_KERNEL | _DRM_DRIVER, &dev_priv->mmio_map);
 +      if (ret)
 +              return ret;
 =20
        if (IS_GM45(dev))
                dev->driver->get_vblank_counter =3D gm45_get_vblank_counter;
 
 --------------050208090909040702040405--
 
 --------------enigB1D19646EEC11719B8DAA618
 Content-Type: application/pgp-signature; name="signature.asc"
 Content-Description: OpenPGP digital signature
 Content-Disposition: attachment; filename="signature.asc"
 
 -----BEGIN PGP SIGNATURE-----
 
 iQEcBAEBAgAGBQJLSeoZAAoJEF93OTEVsi2VUyQH/3OXFcArwtJlEjSRA/mKok/8
 EA1Z3KRIuPf8Z04EUhENf6i3JokOiFjMC4Tj6x3dSGptXOqzzG6dC+Fc7JeA1wZm
 7q2zxAm24YRshl7roCyjWlpEg74HLYcGoXOWELWKAH8+bCAlcjKLRNAEKKczRUif
 auYt4k0SmO3QU6MmPAFvGfkKxOyuscgCYyiLLnMYex9YX7E/SbujuhowarjHFPtn
 izufWNLaMWuOGxn1gAcm6kqi+S1e5WAjZx1pp9PIB7KS0zBUAPDK3VI4tjU+VekN
 hPr6rE8wGoSTwRoiBsRMbiCFUs0F6KNYJjjncvoRJB595QJPkIe1kfiohVYXw9k=
 =53Xb
 -----END PGP SIGNATURE-----
 
 --------------enigB1D19646EEC11719B8DAA618--
 


Home | Main Index | Thread Index | Old Index