svn commit: r186295 - head/sys/dev/drm

2008-12-18 Thread Robert Noland
Author: rnoland
Date: Thu Dec 18 21:04:50 2008
New Revision: 186295
URL: http://svn.freebsd.org/changeset/base/186295

Log:
  rework drm_scatter.c which allocates scatter / gather pages for use by
  ati pci gart to use bus_dma to handle the allocations.  This fixes
  a garbled screen issue on at least some radeons (X1400 tested).  It is
  also likely that this is the correct fix for PR# 119324, though that
  is not confirmed yet.
  
  Reviewed by:  jhb@ (mentor, prior version)
  Approved by:  kib@
  MFC after:2 weeks

Modified:
  head/sys/dev/drm/drmP.h
  head/sys/dev/drm/drm_scatter.c

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Thu Dec 18 19:15:25 2008(r186294)
+++ head/sys/dev/drm/drmP.h Thu Dec 18 21:04:50 2008(r186295)
@@ -473,11 +473,13 @@ typedef struct drm_agp_head {
 } drm_agp_head_t;
 
 typedef struct drm_sg_mem {
-   unsigned long   handle;
-   void*virtual;
-   int pages;
-   dma_addr_t  *busaddr;
-   drm_dma_handle_t *dmah; /* Handle to PCI memory for ATI PCIGART table */
+   unsigned long handle;
+   void *virtual;
+   int   pages;
+   dma_addr_t   *busaddr;
+   struct drm_dma_handle*sg_dmah;  /* Handle for sg_pages   */
+   struct drm_dma_handle*dmah; /* Handle to PCI memory  */
+   /* for ATI PCIGART table */
 } drm_sg_mem_t;
 
 typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;

Modified: head/sys/dev/drm/drm_scatter.c
==
--- head/sys/dev/drm/drm_scatter.c  Thu Dec 18 19:15:25 2008
(r186294)
+++ head/sys/dev/drm/drm_scatter.c  Thu Dec 18 21:04:50 2008
(r186295)
@@ -39,20 +39,16 @@ __FBSDID("$FreeBSD$");
 
 #include "dev/drm/drmP.h"
 
-#define DEBUG_SCATTER 0
+static void drm_sg_alloc_cb(void *arg, bus_dma_segment_t *segs,
+   int nsegs, int error);
 
-void drm_sg_cleanup(drm_sg_mem_t *entry)
+int
+drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather *request)
 {
-   free((void *)entry->handle, DRM_MEM_PAGES);
-   free(entry->busaddr, DRM_MEM_PAGES);
-   free(entry, DRM_MEM_SGLISTS);
-}
-
-int drm_sg_alloc(struct drm_device * dev, struct drm_scatter_gather * request)
-{
-   drm_sg_mem_t *entry;
+   struct drm_sg_mem *entry;
+   struct drm_dma_handle *dmah;
unsigned long pages;
-   int i;
+   int ret;
 
if (dev->sg)
return EINVAL;
@@ -69,21 +65,56 @@ int drm_sg_alloc(struct drm_device * dev
entry->busaddr = malloc(pages * sizeof(*entry->busaddr), DRM_MEM_PAGES,
M_WAITOK | M_ZERO);
if (!entry->busaddr) {
-   drm_sg_cleanup(entry);
+   free(entry, DRM_MEM_SGLISTS);
return ENOMEM;
}
 
-   entry->handle = (long)malloc(pages << PAGE_SHIFT, DRM_MEM_PAGES,
-   M_WAITOK | M_ZERO);
-   if (entry->handle == 0) {
-   drm_sg_cleanup(entry);
+   dmah = malloc(sizeof(struct drm_dma_handle), DRM_MEM_DMA,
+   M_ZERO | M_NOWAIT);
+   if (dmah == NULL) {
+   free(entry->busaddr, DRM_MEM_PAGES);
+   free(entry, DRM_MEM_SGLISTS);
+   return ENOMEM;
+   }
+
+   ret = bus_dma_tag_create(NULL, PAGE_SIZE, 0, /* tag, align, boundary */
+   BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */
+   NULL, NULL, /* filtfunc, filtfuncargs */
+   request->size, pages, /* maxsize, nsegs */
+   PAGE_SIZE, 0, /* maxsegsize, flags */
+   NULL, NULL, /* lockfunc, lockfuncargs */
+   &dmah->tag);
+   if (ret != 0) {
+   free(dmah, DRM_MEM_DMA);
+   free(entry->busaddr, DRM_MEM_PAGES);
+   free(entry, DRM_MEM_SGLISTS);
return ENOMEM;
}
 
-   for (i = 0; i < pages; i++) {
-   entry->busaddr[i] = vtophys(entry->handle + i * PAGE_SIZE);
+   ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr,
+   BUS_DMA_NOWAIT | BUS_DMA_ZERO | BUS_DMA_NOCACHE, &dmah->map);
+   if (ret != 0) {
+   bus_dma_tag_destroy(dmah->tag);
+   free(dmah, DRM_MEM_DMA);
+   free(entry->busaddr, DRM_MEM_PAGES);
+   free(entry, DRM_MEM_SGLISTS);
+   return ENOMEM;
}
 
+   ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr,
+   request->size, drm_sg_alloc_cb, entry, 0);
+   if (ret != 0) {
+   bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
+   bus_dma_tag_destroy(dmah->tag);
+   free(dmah, DRM_MEM_DMA);
+   free(entry->busaddr, DRM_MEM_PAGES);
+   free(entry, DRM_MEM_SGLISTS);

svn commit: r186299 - head/sys/dev/drm

2008-12-18 Thread Robert Noland
Author: rnoland
Date: Thu Dec 18 21:58:57 2008
New Revision: 186299
URL: http://svn.freebsd.org/changeset/base/186299

Log:
  We only want drm to ever attach to the primary pci device.
  Intel 855 chips present the same pci id for both heads.  This prevents
  us from attaching to the dummy second head.  All other chips that I
  am aware of either only present a single pci id, or different ids
  for each head so that we only match on the correct head.
  
  Approved by:  kib@
  MFC after:2 weeks

Modified:
  head/sys/dev/drm/drmP.h
  head/sys/dev/drm/drm_drv.c

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Thu Dec 18 21:46:18 2008(r186298)
+++ head/sys/dev/drm/drmP.h Thu Dec 18 21:58:57 2008(r186299)
@@ -87,6 +87,7 @@ struct drm_file;
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 

Modified: head/sys/dev/drm/drm_drv.c
==
--- head/sys/dev/drm/drm_drv.c  Thu Dec 18 21:46:18 2008(r186298)
+++ head/sys/dev/drm/drm_drv.c  Thu Dec 18 21:58:57 2008(r186299)
@@ -152,6 +152,10 @@ int drm_probe(device_t dev, drm_pci_id_l
device = pci_get_device(dev);
 #endif
 
+   if (pci_get_class(dev) != PCIC_DISPLAY
+   || pci_get_subclass(dev) != PCIS_DISPLAY_VGA)
+   return ENXIO;
+
id_entry = drm_find_description(vendor, device, idlist);
if (id_entry != NULL) {
device_set_desc(dev, id_entry->name);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186300 - head/sys/dev/drm

2008-12-18 Thread Robert Noland
Author: rnoland
Date: Thu Dec 18 22:01:46 2008
New Revision: 186300
URL: http://svn.freebsd.org/changeset/base/186300

Log:
  Garbage collect entries from pcireg.h since we now include it.
  
  Approved by:  kib@
  MFC after:2 weeks

Modified:
  head/sys/dev/drm/drmP.h

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Thu Dec 18 21:58:57 2008(r186299)
+++ head/sys/dev/drm/drmP.h Thu Dec 18 22:01:46 2008(r186300)
@@ -212,15 +212,6 @@ enum {
 #define DRM_MTRR_WCMDF_WRITECOMBINE
 #define jiffiesticks
 
-/* Capabilities taken from src/sys/dev/pci/pcireg.h. */
-#ifndef PCIY_AGP
-#define PCIY_AGP   0x02
-#endif
-
-#ifndef PCIY_EXPRESS
-#define PCIY_EXPRESS   0x10
-#endif
-
 typedef unsigned long dma_addr_t;
 typedef u_int64_t u64;
 typedef u_int32_t u32;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186374 - head/sys/vm

2008-12-21 Thread Robert Noland
Author: rnoland
Date: Sun Dec 21 16:56:13 2008
New Revision: 186374
URL: http://svn.freebsd.org/changeset/base/186374

Log:
  Fix printing of KASSERT message missed in r163604.
  
  Approved by:  kib

Modified:
  head/sys/vm/vm_object.c

Modified: head/sys/vm/vm_object.c
==
--- head/sys/vm/vm_object.c Sun Dec 21 14:04:10 2008(r186373)
+++ head/sys/vm/vm_object.c Sun Dec 21 16:56:13 2008(r186374)
@@ -672,7 +672,7 @@ vm_object_terminate(vm_object_t object)
while ((p = TAILQ_FIRST(&object->memq)) != NULL) {
KASSERT(!p->busy && (p->oflags & VPO_BUSY) == 0,
("vm_object_terminate: freeing busy page %p "
-   "p->busy = %d, p->flags %x\n", p, p->busy, p->flags));
+   "p->busy = %d, p->oflags %x\n", p, p->busy, p->oflags));
if (p->wire_count == 0) {
vm_page_free(p);
cnt.v_pfree++;
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186384 - head/sys/dev/agp

2008-12-21 Thread Robert Noland
Author: rnoland
Date: Sun Dec 21 22:00:39 2008
New Revision: 186384
URL: http://svn.freebsd.org/changeset/base/186384

Log:
  Fix AGP_DEBUG macro to use c99 __VA_ARGS__ and build if enabled.
  
  Approved by:  kib

Modified:
  head/sys/dev/agp/agppriv.h

Modified: head/sys/dev/agp/agppriv.h
==
--- head/sys/dev/agp/agppriv.h  Sun Dec 21 21:54:01 2008(r186383)
+++ head/sys/dev/agp/agppriv.h  Sun Dec 21 22:00:39 2008(r186384)
@@ -36,15 +36,12 @@
 #include 
 #include 
 
-#define AGP_DEBUGxx
-
 #ifdef AGP_DEBUG
-#define AGP_DPF(x...) do { \
-printf("agp: ");   \
-printf(##x);   \
+#define AGP_DPF(fmt, ...) do { \
+printf("agp: " fmt, __VA_ARGS__);  \
 } while (0)
 #else
-#define AGP_DPF(x...) do {} while (0)
+#define AGP_DPF(fmt, ...) do {} while (0)
 #endif
 
 #include "agp_if.h"
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186385 - head/sys/dev/agp

2008-12-21 Thread Robert Noland
Author: rnoland
Date: Sun Dec 21 22:30:37 2008
New Revision: 186385
URL: http://svn.freebsd.org/changeset/base/186385

Log:
  Deal with 0 length args...
  
  Approved by:  kib

Modified:
  head/sys/dev/agp/agppriv.h

Modified: head/sys/dev/agp/agppriv.h
==
--- head/sys/dev/agp/agppriv.h  Sun Dec 21 22:00:39 2008(r186384)
+++ head/sys/dev/agp/agppriv.h  Sun Dec 21 22:30:37 2008(r186385)
@@ -38,7 +38,7 @@
 
 #ifdef AGP_DEBUG
 #define AGP_DPF(fmt, ...) do { \
-printf("agp: " fmt, __VA_ARGS__);  \
+printf("agp: " fmt, ##__VA_ARGS__);\
 } while (0)
 #else
 #define AGP_DPF(fmt, ...) do {} while (0)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186386 - head/sys/dev/drm

2008-12-21 Thread Robert Noland
Author: rnoland
Date: Sun Dec 21 22:32:01 2008
New Revision: 186386
URL: http://svn.freebsd.org/changeset/base/186386

Log:
  Convert DRM_[DEBUG,ERROR,INFO] macros to c99 __VA_ARGS__.
  
  Approved by:  kib

Modified:
  head/sys/dev/drm/drmP.h

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Sun Dec 21 22:30:37 2008(r186385)
+++ head/sys/dev/drm/drmP.h Sun Dec 21 22:32:01 2008(r186386)
@@ -300,16 +300,16 @@ for ( ret = 0 ; !ret && !(condition) ; )
DRM_LOCK(); \
 }
 
-#define DRM_ERROR(fmt, arg...) \
+#define DRM_ERROR(fmt, ...) \
printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt,   \
-   DRM_CURRENTPID, __func__ , ## arg)
+   DRM_CURRENTPID, __func__ , ##__VA_ARGS__)
 
-#define DRM_INFO(fmt, arg...)  printf("info: [" DRM_NAME "] " fmt , ## arg)
+#define DRM_INFO(fmt, ...)  printf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__)
 
-#define DRM_DEBUG(fmt, arg...) do {\
+#define DRM_DEBUG(fmt, ...) do {   \
if (drm_debug_flag) \
printf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID,  \
-   __func__ , ## arg); \
+   __func__ , ##__VA_ARGS__);  \
 } while (0)
 
 typedef struct drm_pci_id_list
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186434 - head/sys/dev/agp

2008-12-23 Thread Robert Noland
Author: rnoland
Date: Tue Dec 23 16:16:30 2008
New Revision: 186434
URL: http://svn.freebsd.org/changeset/base/186434

Log:
  Fix up handling of Intel G4X chips some more.
  
  Note that you need at least xf86-video-intel 2.4.3 for this to work.
  The G4X doesn't put the GATT into the same area of stolen memory
  as all the other chips and older versions of the driver didn't
  handle that properly.
  
  Tested by:ganbold
  Approved by:  kib
  MFC after:2 weeks

Modified:
  head/sys/dev/agp/agp_i810.c

Modified: head/sys/dev/agp/agp_i810.c
==
--- head/sys/dev/agp/agp_i810.c Tue Dec 23 16:04:33 2008(r186433)
+++ head/sys/dev/agp/agp_i810.c Tue Dec 23 16:16:30 2008(r186434)
@@ -167,7 +167,7 @@ static const struct agp_i810_match {
"Intel GM965 SVGA controller"},
{0x2A128086, CHIP_I965, 0x0002,
"Intel GME965 SVGA controller"},
-   {0x2A428086, CHIP_I965, 0x0002,
+   {0x2A428086, CHIP_G4X, 0x0002,
"Intel GM45 SVGA controller"},
{0x2E028086, CHIP_G4X, 0x0002,
"Intel 4 Series SVGA controller"},
@@ -284,6 +284,7 @@ agp_i810_probe(device_t dev)
case CHIP_I915:
case CHIP_I965:
case CHIP_G33:
+   case CHIP_G4X:
deven = pci_read_config(bdev, AGP_I915_DEVEN, 4);
if ((deven & AGP_I915_DEVEN_D2F0) ==
AGP_I915_DEVEN_D2F0_DISABLED) {
@@ -348,6 +349,7 @@ agp_i810_dump_regs(device_t dev)
case CHIP_I915:
case CHIP_I965:
case CHIP_G33:
+   case CHIP_G4X:
device_printf(dev, "AGP_I855_GCC1: 0x%02x\n",
pci_read_config(sc->bdev, AGP_I855_GCC1, 1));
device_printf(dev, "AGP_I915_MSAC: 0x%02x\n",
@@ -397,7 +399,7 @@ agp_i810_attach(device_t dev)
return error;
 
if (sc->chiptype != CHIP_I965 && sc->chiptype != CHIP_G33 &&
-   ptoa((vm_paddr_t)Maxmem) > 0xul)
+   sc->chiptype != CHIP_G4X && ptoa((vm_paddr_t)Maxmem) > 0xul)
{
device_printf(dev, "agp_i810.c does not support physical "
"memory above 4GB.\n");
@@ -659,8 +661,7 @@ agp_i810_attach(device_t dev)
return EINVAL;
}
 
-   if (sc->chiptype != CHIP_G4X)
-   gtt_size += 4;
+   gtt_size += 4;
 
sc->stolen = (stolen - gtt_size) * 1024 / 4096;
if (sc->stolen > 0)
@@ -780,6 +781,7 @@ agp_i810_set_aperture(device_t dev, u_in
case CHIP_I915:
case CHIP_I965:
case CHIP_G33:
+   case CHIP_G4X:
return agp_generic_set_aperture(dev, aperture);
}
 
@@ -798,7 +800,8 @@ agp_i810_write_gtt_entry(device_t dev, i
u_int32_t pte;
 
pte = (u_int32_t)physical | 1;
-   if (sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33) {
+   if (sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33 ||
+   sc->chiptype == CHIP_G4X) {
pte |= (physical & 0x000full) >> 28;
} else {
/* If we do actually have memory above 4GB on an older system,
@@ -825,6 +828,10 @@ agp_i810_write_gtt_entry(device_t dev, i
bus_write_4(sc->sc_res[0],
(offset >> AGP_PAGE_SHIFT) * 4 + (512 * 1024), pte);
break;
+   case CHIP_G4X:
+   bus_write_4(sc->sc_res[0],
+   (offset >> AGP_PAGE_SHIFT) * 4 + (2 * 1024 * 1024), pte);
+   break;
}
 }
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r186465 - head/sys/dev/drm

2008-12-23 Thread Robert Noland
Author: rnoland
Date: Tue Dec 23 22:53:57 2008
New Revision: 186465
URL: http://svn.freebsd.org/changeset/base/186465

Log:
  Only set registers if irqs are enabled
  
  Approved by:  kib
  Obtained from:drm git

Modified:
  head/sys/dev/drm/radeon_irq.c

Modified: head/sys/dev/drm/radeon_irq.c
==
--- head/sys/dev/drm/radeon_irq.c   Tue Dec 23 22:51:10 2008
(r186464)
+++ head/sys/dev/drm/radeon_irq.c   Tue Dec 23 22:53:57 2008
(r186465)
@@ -47,7 +47,8 @@ void radeon_irq_set_state(struct drm_dev
else
dev_priv->irq_enable_reg &= ~mask;
 
-   RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
+   if (dev->irq_enabled)
+   RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
 }
 
 static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
@@ -59,7 +60,8 @@ static void r500_vbl_irq_set_state(struc
else
dev_priv->r500_disp_irq_reg &= ~mask;
 
-   RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
+   if (dev->irq_enabled)
+   RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
 }
 
 int radeon_enable_vblank(struct drm_device *dev, int crtc)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"


svn commit: r183828 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 17:38:04 2008
New Revision: 183828
URL: http://svn.freebsd.org/changeset/base/183828

Log:
  Add support for Radeon rs740 (HD 2100)
  
  Approved by:  jhb (mentor)
  Obtained from:drm git master

Modified:
  head/sys/dev/drm/drm_pciids.h
  head/sys/dev/drm/radeon_cp.c
  head/sys/dev/drm/radeon_drv.h

Modified: head/sys/dev/drm/drm_pciids.h
==
--- head/sys/dev/drm/drm_pciids.h   Mon Oct 13 17:33:55 2008
(r183827)
+++ head/sys/dev/drm/drm_pciids.h   Mon Oct 13 17:38:04 2008
(r183828)
@@ -242,6 +242,10 @@
{0x1002, 0x7835, 
CHIP_RS300|RADEON_IS_IGP|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI Radeon 
RS350 Mobility IGP"}, \
{0x1002, 0x791e, 
CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 
X1250 IGP"}, \
{0x1002, 0x791f, 
CHIP_RS690|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS690 
X1270 IGP"}, \
+   {0x1002, 0x796c, 
CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 
HD2100 IGP"}, \
+   {0x1002, 0x796d, 
CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 
HD2100 IGP"}, \
+   {0x1002, 0x796e, 
CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 
HD2100 IGP"}, \
+   {0x1002, 0x796f, 
CHIP_RS740|RADEON_IS_IGP|RADEON_NEW_MEMMAP|RADEON_IS_IGPGART, "ATI Radeon RS740 
HD2100 IGP"}, \
{0, 0, 0, NULL}
 
 #define r128_PCI_IDS \

Modified: head/sys/dev/drm/radeon_cp.c
==
--- head/sys/dev/drm/radeon_cp.cMon Oct 13 17:33:55 2008
(r183827)
+++ head/sys/dev/drm/radeon_cp.cMon Oct 13 17:38:04 2008
(r183828)
@@ -73,7 +73,8 @@ static u32 RS690_READ_MCIND(drm_radeon_p
 
 static u32 IGP_READ_MCIND(drm_radeon_private_t *dev_priv, int addr)
 {
-if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690)
+   if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+   ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))
return RS690_READ_MCIND(dev_priv, addr);
else
return RS480_READ_MCIND(dev_priv, addr);
@@ -84,7 +85,8 @@ u32 radeon_read_fb_location(drm_radeon_p
 
if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
return R500_READ_MCIND(dev_priv, RV515_MC_FB_LOCATION);
-   else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690)
+   else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))
return RS690_READ_MCIND(dev_priv, RS690_MC_FB_LOCATION);
else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
return R500_READ_MCIND(dev_priv, R520_MC_FB_LOCATION);
@@ -96,7 +98,8 @@ static void radeon_write_fb_location(drm
 {
if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
R500_WRITE_MCIND(RV515_MC_FB_LOCATION, fb_loc);
-   else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690)
+   else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))
RS690_WRITE_MCIND(RS690_MC_FB_LOCATION, fb_loc);
else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
R500_WRITE_MCIND(R520_MC_FB_LOCATION, fb_loc);
@@ -108,7 +111,8 @@ static void radeon_write_agp_location(dr
 {
if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515)
R500_WRITE_MCIND(RV515_MC_AGP_LOCATION, agp_loc);
-   else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690)
+   else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740))
RS690_WRITE_MCIND(RS690_MC_AGP_LOCATION, agp_loc);
else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515)
R500_WRITE_MCIND(R520_MC_AGP_LOCATION, agp_loc);
@@ -124,7 +128,8 @@ static void radeon_write_agp_base(drm_ra
if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV515) {
R500_WRITE_MCIND(RV515_MC_AGP_BASE, agp_base_lo);
R500_WRITE_MCIND(RV515_MC_AGP_BASE_2, agp_base_hi);
-   } else if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) {
+   } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+  ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) {
RS690_WRITE_MCIND(RS690_MC_AGP_BASE, agp_base_lo);
RS690_WRITE_MCIND(RS690_MC_AGP_BASE_2, agp_base_hi);
} else if ((dev_priv->flags & RADEON_FAMILY_MASK) > CHIP_RV515) {
@@ -369,8 +374,9 @@ static void radeon_cp_load_microcode(drm
RADEON_WRITE(RADEON_CP_ME_RAM_DATAL,
  

svn commit: r183830 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 17:43:39 2008
New Revision: 183830
URL: http://svn.freebsd.org/changeset/base/183830

Log:
  Several of the newer radeon cards have moved around the registers for enabling
  busmastering support.  This also adds register definitions for MSI support,
  which we will be using shortly.
  
  Approved by:  jhb (mentor)
  Obtained from:drm git master

Modified:
  head/sys/dev/drm/drm_pciids.h
  head/sys/dev/drm/radeon_cp.c
  head/sys/dev/drm/radeon_drv.h

Modified: head/sys/dev/drm/drm_pciids.h
==
--- head/sys/dev/drm/drm_pciids.h   Mon Oct 13 17:42:21 2008
(r183829)
+++ head/sys/dev/drm/drm_pciids.h   Mon Oct 13 17:43:39 2008
(r183830)
@@ -86,18 +86,18 @@
{0x1002, 0x5460, CHIP_RV380|RADEON_IS_MOBILITY, "ATI Radeon Mobility 
X300 M22"}, \
{0x1002, 0x5462, CHIP_RV380|RADEON_IS_MOBILITY, "ATI Radeon Mobility 
X600 SE M24C"}, \
{0x1002, 0x5464, CHIP_RV380|RADEON_IS_MOBILITY, "ATI FireGL M22 GL 
5464"}, \
-   {0x1002, 0x5548, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800"}, \
-   {0x1002, 0x5549, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 
Pro"}, \
-   {0x1002, 0x554A, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT 
PE"}, \
-   {0x1002, 0x554B, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 
SE"}, \
-   {0x1002, 0x554C, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
XTP"}, \
-   {0x1002, 0x554D, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
XL"}, \
-   {0x1002, 0x554E, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
SE"}, \
-   {0x1002, 0x554F, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800"}, \
-   {0x1002, 0x5550, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL V7100 R423"}, 
\
-   {0x1002, 0x5551, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL V5100 R423 
UQ"}, \
-   {0x1002, 0x5552, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 
UR"}, \
-   {0x1002, 0x5554, CHIP_R420|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 
UT"}, \
+   {0x1002, 0x5548, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800"}, \
+   {0x1002, 0x5549, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 
Pro"}, \
+   {0x1002, 0x554A, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 XT 
PE"}, \
+   {0x1002, 0x554B, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 
SE"}, \
+   {0x1002, 0x554C, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
XTP"}, \
+   {0x1002, 0x554D, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
XL"}, \
+   {0x1002, 0x554E, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800 
SE"}, \
+   {0x1002, 0x554F, CHIP_R423|RADEON_NEW_MEMMAP, "ATI Radeon R430 X800"}, \
+   {0x1002, 0x5550, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL V7100 R423"}, 
\
+   {0x1002, 0x5551, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL V5100 R423 
UQ"}, \
+   {0x1002, 0x5552, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 
UR"}, \
+   {0x1002, 0x5554, CHIP_R423|RADEON_NEW_MEMMAP, "ATI FireGL unknown R423 
UT"}, \
{0x1002, 0x564A, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility FireGL V5000 M26"}, \
{0x1002, 0x564B, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility FireGL V5000 M26"}, \
{0x1002, 0x564F, CHIP_RV410|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Radeon Mobility X700 XL M26"}, \
@@ -127,16 +127,16 @@
{0x1002, 0x5b65, CHIP_RV380|RADEON_NEW_MEMMAP, "ATI FireMV 2200 PCIE 
(RV370) 5B65"}, \
{0x1002, 0x5c61, CHIP_RV280|RADEON_IS_MOBILITY, "ATI Radeon RV280 
Mobility"}, \
{0x1002, 0x5c63, CHIP_RV280|RADEON_IS_MOBILITY, "ATI Radeon RV280 
Mobility"}, \
-   {0x1002, 0x5d48, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility Radeon X800 XT M28"}, \
-   {0x1002, 0x5d49, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility FireGL V5100 M28"}, \
-   {0x1002, 0x5d4a, CHIP_R420|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility Radeon X800 M28"}, \
-   {0x1002, 0x5d4c, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850"}, \
-   {0x1002, 0x5d4d, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 XT 
PE"}, \
-   {0x1002, 0x5d4e, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 
SE"}, \
-   {0x1002, 0x5d4f, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 
Pro"}, \
-   {0x1002, 0x5d50, CHIP_R420|RADEON_NEW_MEMMAP, "ATI unknown Radeon / 
FireGL R480"}, \
-   {0x1002, 0x5d52, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R480 X850 
XT"}, \
-   {0x1002, 0x5d57, CHIP_R420|RADEON_NEW_MEMMAP, "ATI Radeon R423 X800 
XT"}, \
+   {0x1002, 0x5d48, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility Radeon X800 XT M28"}, \
+   {0x1002, 0x5d49, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility FireGL V5100 M28"}, \
+   {0x1002, 0x5d4a, CHIP_R423|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP, "ATI 
Mobility Radeo

svn commit: r183831 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 17:47:13 2008
New Revision: 183831
URL: http://svn.freebsd.org/changeset/base/183831

Log:
  Correct the interrupt handling in the Intel i915 driver.
  
  Approved by:  jhb (mentor)

Modified:
  head/sys/dev/drm/i915_irq.c

Modified: head/sys/dev/drm/i915_irq.c
==
--- head/sys/dev/drm/i915_irq.c Mon Oct 13 17:43:39 2008(r183830)
+++ head/sys/dev/drm/i915_irq.c Mon Oct 13 17:47:13 2008(r183831)
@@ -460,26 +460,31 @@ irqreturn_t i915_driver_irq_handler(DRM_
 */
if (iir & I915_DISPLAY_PIPE_A_EVENT_INTERRUPT) {
pipea_stats = I915_READ(PIPEASTAT);
-   if (pipea_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS|
-  PIPE_VBLANK_INTERRUPT_STATUS))
+
+   /* The vblank interrupt gets enabled even if we didn't ask for
+  it, so make sure it's shut down again */
+   if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_A))
+   pipea_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE |
+PIPE_VBLANK_INTERRUPT_ENABLE);
+   else if (pipea_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS|
+   PIPE_VBLANK_INTERRUPT_STATUS))
{
vblank++;
drm_handle_vblank(dev, i915_get_plane(dev, 0));
}
+
I915_WRITE(PIPEASTAT, pipea_stats);
}
if (iir & I915_DISPLAY_PIPE_B_EVENT_INTERRUPT) {
pipeb_stats = I915_READ(PIPEBSTAT);
-   /* Ack the event */
-   I915_WRITE(PIPEBSTAT, pipeb_stats);
 
/* The vblank interrupt gets enabled even if we didn't ask for
   it, so make sure it's shut down again */
if (!(dev_priv->vblank_pipe & DRM_I915_VBLANK_PIPE_B))
-   pipeb_stats &= ~(I915_VBLANK_INTERRUPT_ENABLE);
-
-   if (pipeb_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS|
-  PIPE_VBLANK_INTERRUPT_STATUS))
+   pipeb_stats &= ~(PIPE_START_VBLANK_INTERRUPT_ENABLE |
+PIPE_VBLANK_INTERRUPT_ENABLE);
+   else if (pipeb_stats & (PIPE_START_VBLANK_INTERRUPT_STATUS|
+   PIPE_VBLANK_INTERRUPT_STATUS))
{
vblank++;
drm_handle_vblank(dev, i915_get_plane(dev, 1));
@@ -950,9 +955,9 @@ void i915_driver_irq_preinstall(struct d
 {
drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
 
-   I915_WRITE16(HWSTAM, 0xeffe);
-   I915_WRITE16(IMR, 0x0);
-   I915_WRITE16(IER, 0x0);
+   I915_WRITE(HWSTAM, 0xeffe);
+   I915_WRITE(IMR, 0x);
+   I915_WRITE(IER, 0x0);
 }
 
 int i915_driver_irq_postinstall(struct drm_device * dev)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r183832 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 17:52:41 2008
New Revision: 183832
URL: http://svn.freebsd.org/changeset/base/183832

Log:
  The linux list compat code had an error which prevented list_for_each_safe()
  from operating on a list with a single item.  This code is used much more by
  the i915 driver with xorg-7.4.  Correct it to match the actual linux
  implementation.
  
  Approved by:  jhb (mentor)

Modified:
  head/sys/dev/drm/drm_linux_list.h

Modified: head/sys/dev/drm/drm_linux_list.h
==
--- head/sys/dev/drm/drm_linux_list.h   Mon Oct 13 17:47:13 2008
(r183831)
+++ head/sys/dev/drm/drm_linux_list.h   Mon Oct 13 17:52:41 2008
(r183832)
@@ -69,6 +69,6 @@ list_del(struct list_head *entry) {
 
 #define list_for_each_safe(entry, temp, head)  \
 for (entry = (head)->next, temp = (entry)->next;   \
-   temp != head;   \
-   entry = temp, temp = temp->next)
+   entry != head;  \
+   entry = temp, temp = entry->next)
 
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r183834 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 18:06:33 2008
New Revision: 183834
URL: http://svn.freebsd.org/changeset/base/183834

Log:
  Correct memory leak of info->rects.  Previously we would free info, but
  but abandon info->rects.
  
  Approved by:  jhb (mentor)

Modified:
  head/sys/dev/drm/drm_drawable.c

Modified: head/sys/dev/drm/drm_drawable.c
==
--- head/sys/dev/drm/drm_drawable.c Mon Oct 13 18:03:27 2008
(r183833)
+++ head/sys/dev/drm/drm_drawable.c Mon Oct 13 18:06:33 2008
(r183834)
@@ -74,8 +74,8 @@ int drm_adddraw(struct drm_device *dev, 
struct drm_draw *draw = data;
struct bsd_drm_drawable_info *info;
 
-   info = drm_calloc(1, sizeof(struct bsd_drm_drawable_info),
-   DRM_MEM_DRAWABLE);
+   info = malloc(sizeof(struct bsd_drm_drawable_info), DRM_MEM_DRAWABLE,
+   M_NOWAIT | M_ZERO);
if (info == NULL)
return ENOMEM;
 
@@ -102,8 +102,8 @@ int drm_rmdraw(struct drm_device *dev, v
(struct bsd_drm_drawable_info *)info);
DRM_SPINUNLOCK(&dev->drw_lock);
free_unr(dev->drw_unrhdr, draw->handle);
-   drm_free(info, sizeof(struct bsd_drm_drawable_info),
-   DRM_MEM_DRAWABLE);
+   free(info->rects, DRM_MEM_DRAWABLE);
+   free(info, DRM_MEM_DRAWABLE);
return 0;
} else {
DRM_SPINUNLOCK(&dev->drw_lock);
@@ -126,9 +126,7 @@ int drm_update_draw(struct drm_device *d
case DRM_DRAWABLE_CLIPRECTS:
DRM_SPINLOCK(&dev->drw_lock);
if (update->num != info->num_rects) {
-   drm_free(info->rects,
-   sizeof(*info->rects) * info->num_rects,
-   DRM_MEM_DRAWABLE);
+   free(info->rects, DRM_MEM_DRAWABLE);
info->rects = NULL;
info->num_rects = 0;
}
@@ -137,8 +135,8 @@ int drm_update_draw(struct drm_device *d
return 0;
}
if (info->rects == NULL) {
-   info->rects = drm_alloc(sizeof(*info->rects) *
-   update->num, DRM_MEM_DRAWABLE);
+   info->rects = malloc(sizeof(*info->rects) *
+   update->num, DRM_MEM_DRAWABLE, M_NOWAIT);
if (info->rects == NULL) {
DRM_SPINUNLOCK(&dev->drw_lock);
return ENOMEM;
@@ -167,8 +165,8 @@ void drm_drawable_free_all(struct drm_de
(struct bsd_drm_drawable_info *)info);
DRM_SPINUNLOCK(&dev->drw_lock);
free_unr(dev->drw_unrhdr, info->handle);
-   drm_free(info, sizeof(struct bsd_drm_drawable_info),
-   DRM_MEM_DRAWABLE);
+   free(info->info.rects, DRM_MEM_DRAWABLE);
+   free(info, DRM_MEM_DRAWABLE);
DRM_SPINLOCK(&dev->drw_lock);
}
DRM_SPINUNLOCK(&dev->drw_lock);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r183833 - head/sys/dev/drm

2008-10-13 Thread Robert Noland
Author: rnoland
Date: Mon Oct 13 18:03:27 2008
New Revision: 183833
URL: http://svn.freebsd.org/changeset/base/183833

Log:
  Rework memory allocation to allocate memory with different type names.  This
  will ease the identification of memory leaks as the OS will be able to track
  allocations for us by malloc type.  vmstat -m will show all of the
  allocations.
  
  Convert the calls to drm_alloc() and friends, which are used in shared code
  to static __inline__ while we are here.
  
  Approved by:  jhb (mentor)

Modified:
  head/sys/dev/drm/ati_pcigart.c
  head/sys/dev/drm/drmP.h
  head/sys/dev/drm/drm_agpsupport.c
  head/sys/dev/drm/drm_auth.c
  head/sys/dev/drm/drm_bufs.c
  head/sys/dev/drm/drm_context.c
  head/sys/dev/drm/drm_dma.c
  head/sys/dev/drm/drm_drv.c
  head/sys/dev/drm/drm_fops.c
  head/sys/dev/drm/drm_ioctl.c
  head/sys/dev/drm/drm_irq.c
  head/sys/dev/drm/drm_memory.c
  head/sys/dev/drm/drm_pci.c
  head/sys/dev/drm/drm_scatter.c
  head/sys/dev/drm/drm_sysctl.c
  head/sys/dev/drm/i915_drv.c
  head/sys/dev/drm/mach64_drv.c
  head/sys/dev/drm/mga_drv.c
  head/sys/dev/drm/r128_drv.c
  head/sys/dev/drm/radeon_drv.c
  head/sys/dev/drm/savage_drv.c
  head/sys/dev/drm/sis_drv.c
  head/sys/dev/drm/tdfx_drv.c

Modified: head/sys/dev/drm/ati_pcigart.c
==
--- head/sys/dev/drm/ati_pcigart.c  Mon Oct 13 17:52:41 2008
(r183832)
+++ head/sys/dev/drm/ati_pcigart.c  Mon Oct 13 18:03:27 2008
(r183833)
@@ -64,7 +64,8 @@ drm_ati_alloc_pcigart_table(struct drm_d
struct drm_dma_handle *dmah;
int flags, ret;
 
-   dmah = malloc(sizeof(struct drm_dma_handle), M_DRM, M_ZERO | M_NOWAIT);
+   dmah = malloc(sizeof(struct drm_dma_handle), DRM_MEM_DMA,
+   M_ZERO | M_NOWAIT);
if (dmah == NULL)
return ENOMEM;
 
@@ -77,7 +78,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */
&dmah->tag);
if (ret != 0) {
-   free(dmah, M_DRM);
+   free(dmah, DRM_MEM_DMA);
return ENOMEM;
}
 
@@ -88,7 +89,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, flags, &dmah->map);
if (ret != 0) {
bus_dma_tag_destroy(dmah->tag);
-   free(dmah, M_DRM);
+   free(dmah, DRM_MEM_DMA);
return ENOMEM;
}
DRM_LOCK();
@@ -98,7 +99,7 @@ drm_ati_alloc_pcigart_table(struct drm_d
if (ret != 0) {
bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
bus_dma_tag_destroy(dmah->tag);
-   free(dmah, M_DRM);
+   free(dmah, DRM_MEM_DMA);
return ENOMEM;
}
 
@@ -115,7 +116,7 @@ drm_ati_free_pcigart_table(struct drm_de
 
bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
bus_dma_tag_destroy(dmah->tag);
-   free(dmah, M_DRM);
+   free(dmah, DRM_MEM_DMA);
dev->sg->dmah = NULL;
 }
 

Modified: head/sys/dev/drm/drmP.h
==
--- head/sys/dev/drm/drmP.h Mon Oct 13 17:52:41 2008(r183832)
+++ head/sys/dev/drm/drmP.h Mon Oct 13 18:03:27 2008(r183833)
@@ -129,27 +129,24 @@ struct drm_file;
 #define DRM_KERNEL_CONTEXT0 /* Change drm_resctx if changed
  */
 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed
  */
 
-#define DRM_MEM_DMA   0
-#define DRM_MEM_SAREA 1
-#define DRM_MEM_DRIVER2
-#define DRM_MEM_MAGIC 3
-#define DRM_MEM_IOCTLS4
-#define DRM_MEM_MAPS  5
-#define DRM_MEM_BUFS  6
-#define DRM_MEM_SEGS  7
-#define DRM_MEM_PAGES 8
-#define DRM_MEM_FILES9
-#define DRM_MEM_QUEUES   10
-#define DRM_MEM_CMDS 11
-#define DRM_MEM_MAPPINGS  12
-#define DRM_MEM_BUFLISTS  13
-#define DRM_MEM_AGPLISTS  14
-#define DRM_MEM_TOTALAGP  15
-#define DRM_MEM_BOUNDAGP  16
-#define DRM_MEM_CTXBITMAP 17
-#define DRM_MEM_STUB 18
-#define DRM_MEM_SGLISTS  19
-#define DRM_MEM_DRAWABLE  20
+MALLOC_DECLARE(DRM_MEM_DMA);
+MALLOC_DECLARE(DRM_MEM_SAREA);
+MALLOC_DECLARE(DRM_MEM_DRIVER);
+MALLOC_DECLARE(DRM_MEM_MAGIC);
+MALLOC_DECLARE(DRM_MEM_IOCTLS);
+MALLOC_DECLARE(DRM_MEM_MAPS);
+MALLOC_DECLARE(DRM_MEM_BUFS);
+MALLOC_DECLARE(DRM_MEM_SEGS);
+MALLOC_DECLARE(DRM_MEM_PAGES);
+MALLOC_DECLARE(DRM_MEM_FILES);
+MALLOC_DECLARE(DRM_MEM_QUEUES);
+MALLOC_DECLARE(DRM_MEM_CMDS);
+MALLOC_DECLARE(DRM_MEM_MAPPINGS);
+MALLOC_DECLARE(DRM_MEM_BUFLISTS);
+MALLOC_DECLARE(DRM_MEM_AGPLISTS);
+MALLOC_DECLARE(DRM_MEM_CTXBITMAP);
+MALLOC_DECLARE(DRM_MEM_SGLISTS);
+MALLOC_DECLARE(DRM_MEM_DRAWABLE);
 
 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
 
@@ -160,8 +157,6 @@ struct drm_file;
 
 #define DRM_IF_VERSION(maj, min) (maj << 16 | min)
 
-MALLOC_DECLARE(M_DRM);
-
 #define __OS_HAS_AGP   1
 
 #defin

svn commit: r184212 - head/sys/dev/drm

2008-10-23 Thread Robert Noland
Author: rnoland
Date: Thu Oct 23 20:19:56 2008
New Revision: 184212
URL: http://svn.freebsd.org/changeset/base/184212

Log:
  This check is invalid and I disabled it once already.  I accidentally
  reintroduced it with the sync to git master.  Commit the fix in both
  places this time.
  
  Approved by:  jhb (mentor)
  MFC after:2 weeks

Modified:
  head/sys/dev/drm/drm_lock.c

Modified: head/sys/dev/drm/drm_lock.c
==
--- head/sys/dev/drm/drm_lock.c Thu Oct 23 20:07:08 2008(r184211)
+++ head/sys/dev/drm/drm_lock.c Thu Oct 23 20:19:56 2008(r184212)
@@ -105,17 +105,15 @@ int drm_unlock(struct drm_device *dev, v
 {
struct drm_lock *lock = data;
 
+   DRM_DEBUG("%d (pid %d) requests unlock (0x%08x), flags = 0x%08x\n",
+   lock->context, DRM_CURRENTPID, dev->lock.hw_lock->lock,
+   lock->flags);
+
if (lock->context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
DRM_CURRENTPID, lock->context);
return EINVAL;
}
-   /* Check that the context unlock being requested actually matches
-* who currently holds the lock.
-*/
-   if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
-   _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) != lock->context)
-   return EINVAL;
 
DRM_SPINLOCK(&dev->tsk_lock);
if (dev->locked_task_call != NULL) {
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r184213 - head/sys/dev/drm

2008-10-23 Thread Robert Noland
Author: rnoland
Date: Thu Oct 23 20:23:03 2008
New Revision: 184213
URL: http://svn.freebsd.org/changeset/base/184213

Log:
  Replace calls to minor() with dev2unit().  Ed already fixed this once,
  but I inadvertently overwrote the change when I synced to git.  Commit
  the fix in both places, so this doesn't happen again.
  
  Approved by:  jhb (mentor)
  MFC after:2 weeks

Modified:
  head/sys/dev/drm/drm_drv.c
  head/sys/dev/drm/drm_fops.c

Modified: head/sys/dev/drm/drm_drv.c
==
--- head/sys/dev/drm/drm_drv.c  Thu Oct 23 20:19:56 2008(r184212)
+++ head/sys/dev/drm/drm_drv.c  Thu Oct 23 20:23:03 2008(r184213)
@@ -537,7 +537,7 @@ int drm_open(struct cdev *kdev, int flag
struct drm_device *dev = NULL;
int retcode = 0;
 
-   dev = DRIVER_SOFTC(minor(kdev));
+   dev = DRIVER_SOFTC(dev2unit(kdev));
 
DRM_DEBUG("open_count = %d\n", dev->open_count);
 

Modified: head/sys/dev/drm/drm_fops.c
==
--- head/sys/dev/drm/drm_fops.c Thu Oct 23 20:19:56 2008(r184212)
+++ head/sys/dev/drm/drm_fops.c Thu Oct 23 20:23:03 2008(r184213)
@@ -44,7 +44,7 @@ int drm_open_helper(struct cdev *kdev, i
struct drm_device *dev)
 {
struct drm_file *priv;
-   int m = minor(kdev);
+   int m = dev2unit(kdev);
int retcode;
 
if (flags & O_EXCL)
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r184263 - head/sys/dev/drm

2008-10-25 Thread Robert Noland
Author: rnoland
Date: Sat Oct 25 16:29:28 2008
New Revision: 184263
URL: http://svn.freebsd.org/changeset/base/184263

Log:
  drm/i915: fix ioremap of a user address for non-root (CVE-2008-3831)
  
  Olaf Kirch noticed that the i915_set_status_page() function of the i915
  kernel driver calls ioremap with an address offset that is supplied by
  userspace via ioctl. The function zeroes the mapped memory via memset
  and tells the hardware about the address. Turns out that access to that
  ioctl is not restricted to root so users could probably exploit that to
  do nasty things. We haven't tried to write actual exploit code though.
  
  It only affects the Intel G33 series and newer.
  
  Approved by:  bz (secteam)
  Obtained from:Intel drm repo
  Security: CVE-2008-3831

Modified:
  head/sys/dev/drm/i915_dma.c

Modified: head/sys/dev/drm/i915_dma.c
==
--- head/sys/dev/drm/i915_dma.c Sat Oct 25 14:01:29 2008(r184262)
+++ head/sys/dev/drm/i915_dma.c Sat Oct 25 16:29:28 2008(r184263)
@@ -1228,7 +1228,7 @@ struct drm_ioctl_desc i915_ioctls[] = {
DRM_IOCTL_DEF(DRM_I915_GET_VBLANK_PIPE,  i915_vblank_pipe_get, DRM_AUTH 
),
DRM_IOCTL_DEF(DRM_I915_VBLANK_SWAP, i915_vblank_swap, DRM_AUTH),
DRM_IOCTL_DEF(DRM_I915_MMIO, i915_mmio, DRM_AUTH),
-   DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, DRM_AUTH),
+   DRM_IOCTL_DEF(DRM_I915_HWS_ADDR, i915_set_status_page, 
DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
 #ifdef I915_HAVE_BUFFER
DRM_IOCTL_DEF(DRM_I915_EXECBUFFER, i915_execbuffer, DRM_AUTH),
 #endif
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r184373 - head/sys/dev/drm

2008-10-27 Thread Robert Noland
Author: rnoland
Date: Mon Oct 27 21:16:07 2008
New Revision: 184373
URL: http://svn.freebsd.org/changeset/base/184373

Log:
  Don't report GEM capability until we actually have GEM support.
  
  This was causing the newer Intel video drivers to fail and abort X.
  
  Approved by:  jhb (mentor)

Modified:
  head/sys/dev/drm/i915_dma.c

Modified: head/sys/dev/drm/i915_dma.c
==
--- head/sys/dev/drm/i915_dma.c Mon Oct 27 21:06:16 2008(r184372)
+++ head/sys/dev/drm/i915_dma.c Mon Oct 27 21:16:07 2008(r184373)
@@ -914,7 +914,8 @@ static int i915_getparam(struct drm_devi
value = dev->pci_device;
break;
case I915_PARAM_HAS_GEM:
-   value = 1;
+   /* We need to reset this to 1 once we have GEM */
+   value = 0;
break;
default:
DRM_ERROR("Unknown parameter %d\n", param->param);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r184374 - head/sys/dev/drm

2008-10-27 Thread Robert Noland
Author: rnoland
Date: Mon Oct 27 21:21:36 2008
New Revision: 184374
URL: http://svn.freebsd.org/changeset/base/184374

Log:
  Fix some fallout from the busmaster disable cleanup
  
  rs400 is just like rs480
  
  Approved by:  jhb (mentor)
  Obtained from:drm git

Modified:
  head/sys/dev/drm/radeon_cp.c
  head/sys/dev/drm/radeon_drv.h

Modified: head/sys/dev/drm/radeon_cp.c
==
--- head/sys/dev/drm/radeon_cp.cMon Oct 27 21:16:07 2008
(r184373)
+++ head/sys/dev/drm/radeon_cp.cMon Oct 27 21:21:36 2008
(r184374)
@@ -655,15 +655,14 @@ static void radeon_cp_init_ring_buffer(s
RADEON_WRITE(RADEON_SCRATCH_UMSK, 0x7);
 
/* Turn on bus mastering */
-   if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) ||
-   ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
+   if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS690) ||
((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS740)) {
-   /* rs400, rs690/rs740 */
-   tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS400_BUS_MASTER_DIS;
+   /* rs600/rs690/rs740 */
+   tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS;
RADEON_WRITE(RADEON_BUS_CNTL, tmp);
} else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) ||
((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) {
-   /* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */
+   /* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS;
RADEON_WRITE(RADEON_BUS_CNTL, tmp);
} /* PCIE cards appears to not need this */

Modified: head/sys/dev/drm/radeon_drv.h
==
--- head/sys/dev/drm/radeon_drv.h   Mon Oct 27 21:16:07 2008
(r184373)
+++ head/sys/dev/drm/radeon_drv.h   Mon Oct 27 21:21:36 2008
(r184374)
@@ -442,11 +442,11 @@ extern int r300_do_cp_cmdbuf(struct drm_
  * handling, not bus mastering itself.
  */
 #define RADEON_BUS_CNTL0x0030
-/* r1xx, r2xx, r300, r(v)350, r420/r481, rs480 */
+/* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
 #  define RADEON_BUS_MASTER_DIS(1 << 6)
-/* rs400, rs690/rs740 */
-#  define RS400_BUS_MASTER_DIS (1 << 14)
-#  define RS400_MSI_REARM  (1 << 20)
+/* rs600/rs690/rs740 */
+#  define RS600_BUS_MASTER_DIS (1 << 14)
+#  define RS600_MSI_REARM  (1 << 20)
 /* see RS480_MSI_REARM in AIC_CNTL for rs480 */
 
 #define RADEON_BUS_CNTL1   0x0034
@@ -939,7 +939,7 @@ extern int r300_do_cp_cmdbuf(struct drm_
 
 #define RADEON_AIC_CNTL0x01d0
 #  define RADEON_PCIGART_TRANSLATE_EN  (1 << 0)
-#  define RS480_MSI_REARM  (1 << 3)
+#  define RS400_MSI_REARM  (1 << 3)
 #define RADEON_AIC_STAT0x01d4
 #define RADEON_AIC_PT_BASE 0x01d8
 #define RADEON_AIC_LO_ADDR 0x01dc
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


svn commit: r184375 - head/sys/dev/drm

2008-10-27 Thread Robert Noland
Author: rnoland
Date: Mon Oct 27 21:24:34 2008
New Revision: 184375
URL: http://svn.freebsd.org/changeset/base/184375

Log:
  Fix error in busmaster enable logic
  
  rs400/rs480 should clear the RADEON_BUS_MASTER_DIS bit.  This should get
  the rs485 IGP chips going again.
  
  Approved by:  jhb (mentor)
  Obtained from:drm git master

Modified:
  head/sys/dev/drm/radeon_cp.c

Modified: head/sys/dev/drm/radeon_cp.c
==
--- head/sys/dev/drm/radeon_cp.cMon Oct 27 21:21:36 2008
(r184374)
+++ head/sys/dev/drm/radeon_cp.cMon Oct 27 21:24:34 2008
(r184375)
@@ -660,8 +660,10 @@ static void radeon_cp_init_ring_buffer(s
/* rs600/rs690/rs740 */
tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RS600_BUS_MASTER_DIS;
RADEON_WRITE(RADEON_BUS_CNTL, tmp);
-   } else if (!(((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV380) ||
-   ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R423))) {
+   } else if (((dev_priv->flags & RADEON_FAMILY_MASK) <= CHIP_RV350) ||
+  ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_R420) ||
+  ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS400) ||
+  ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS480)) {
/* r1xx, r2xx, r300, r(v)350, r420/r481, rs400/rs480 */
tmp = RADEON_READ(RADEON_BUS_CNTL) & ~RADEON_BUS_MASTER_DIS;
RADEON_WRITE(RADEON_BUS_CNTL, tmp);
___
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[EMAIL PROTECTED]"


Re: svn commit: r185050 - head/usr.sbin/powerd

2008-11-18 Thread Robert Noland
On Tue, 2008-11-18 at 13:24 +, Alexander Motin wrote:
> Author: mav
> Date: Tue Nov 18 13:24:38 2008
> New Revision: 185050
> URL: http://svn.freebsd.org/changeset/base/185050
> 
> Log:
>   Set of powerd enchancements:
>   
>   1. Make it more SMP polite. Previous version uses average CPU load that
>   often leads to load underestimation. It make powerd with default
>   configuration unusable on systems with more then 2 CPUs. I propose to use
>   summary load instead of average one. IMO this is the best we can do without
>   specially tuned scheduler. Also as soon as measuring total load on SMP
>   systems is more useful then total idle, I have switched to it.
>   
>   2. Make powerd's operation independent from number and size of frequency
>   levels. I have added internal frequency counter which translated into real
>   frequencies only on a last stage and only as good as gone. Some systems may
>   have only several power levels, while others - many of them, so adaptation
>   time with previous approach was completely different.
>   
>   3. As part of previous I have changed adaptive mode to rise frequency on
>   demand up to 2 times and fall on 1/8 per time internal.
>   
>   4. For desktop (AC-powered) systems I have added one more mode - 
> "hiadaptive".
>   It rises frequency twice faster, drops it 4 times slower, prefers twice
>   lower CPU load and has additional delay before leaving the highest frequency
>   after the period of maximum load. This mode was specially made to improve
>   interactivity of the systems where operation capabilities are more
>   significant then power consumption, but keeping maximum frequency all the
>   time is not needed.
>   
>   5. I have reduced default polling interval from 1/2 to 1/4 of second.
>   It is not so important for algorithm math now, but gives better system
>   interactivity.
>   
>   Discussed on:   mobile@

Somehow this seems to be too sensitive.  My laptop previously idled at
150Mhz... Occasionally bouncing up to maybe 450Mhz.  With the new algo,
it will sometimes drop to 900Mhz, but winds itself right back up to
1.8Ghz.

robert.

> Modified:
>   head/usr.sbin/powerd/powerd.8
>   head/usr.sbin/powerd/powerd.c
> 
> Modified: head/usr.sbin/powerd/powerd.8
> ==
> --- head/usr.sbin/powerd/powerd.8 Tue Nov 18 12:42:59 2008
> (r185049)
> +++ head/usr.sbin/powerd/powerd.8 Tue Nov 18 13:24:38 2008
> (r185050)
> @@ -47,7 +47,8 @@ utility monitors the system state and se
>  accordingly.
>  It offers three modes (maximum, minimum, and adaptive) that can be
>  individually selected while on AC power or batteries.
> -The modes maximum, minimum, and adaptive may be abbreviated max, min, adp.
> +The modes maximum, minimum, adaptive and hiadaptive may be abbreviated
> +max, min, adp, hadp.
>  .Pp
>  Maximum mode chooses the highest performance values.
>  Minimum mode selects the lowest performance values to get the most power
> @@ -56,8 +57,10 @@ Adaptive mode attempts to strike a balan
>  the system appears idle and increasing it when the system is busy.
>  It offers a good balance between a small performance loss for greatly
>  increased power savings.
> -The default mode is
> -adaptive.
> +Hiadaptive mode is alike adaptive mode, but tuned for systems where
> +performance and interactivity are more important then power consumption.
> +It rises frequency faster, drops slower and keeps twice lower CPU load.
> +The default mode is adaptive for battery power and hiadaptive for the rest.
>  .Pp
>  The
>  .Nm
> @@ -72,10 +75,9 @@ Selects the
>  .Ar mode
>  to use while on battery power.
>  .It Fl i Ar percent
> -Specifies the CPU idle percent level when
> -adaptive
> +Specifies the CPU load percent level when adaptive
>  mode should begin to degrade performance to save power.
> -The default is 90% or higher.
> +The default is 50% or lower.
>  .It Fl n Ar mode
>  Selects the
>  .Ar mode
> @@ -83,16 +85,15 @@ to use normally when the AC line state i
>  .It Fl p Ar ival
>  Specifies a different polling interval (in milliseconds) for AC line state
>  and system idle levels.
> -The default is 500 ms.
> +The default is 250 ms.
>  .It Fl P Ar pidfile
>  Specifies an alternative file in which the process ID should be stored.
>  The default is
>  .Pa /var/run/powerd.pid .
>  .It Fl r Ar percent
> -Specifies the CPU idle percent level where
> -adaptive
> +Specifies the CPU load percent level where adaptive
>  mode should consider the CPU running and increase performance.
> -The default is 65% or lower.
> +The default is 75% or higther.
>  .It Fl v
>  Verbose mode.
>  Messages about power changes will be printed to stdout and
> 
> Modified: head/usr.sbin/powerd/powerd.c
> ==
> --- head/usr.sbin/powerd/powerd.c Tue Nov 18 12:42:59 2008
> (r185049)
> +++ head/usr.sbin/powerd/powerd.c Tu

Re: svn commit: r185050 - head/usr.sbin/powerd

2008-11-19 Thread Robert Noland
On Wed, 2008-11-19 at 10:07 +0200, Alexander Motin wrote:
> Robert Noland wrote:
> > On Tue, 2008-11-18 at 13:24 +, Alexander Motin wrote:
> >> Log:
> >>   Set of powerd enchancements:
> >>   
> > Somehow this seems to be too sensitive.  My laptop previously idled at
> > 150Mhz... Occasionally bouncing up to maybe 450Mhz.  With the new algo,
> > it will sometimes drop to 900Mhz, but winds itself right back up to
> > 1.8Ghz.
> 
> Can you give me any details? How many CPUs do you have, which set of
> frequencies does it have? Are there any powerd options specified? Does
> powerd detects battery power? With AC or unknown power it will run in
> hiadaptive mode which keeps much higher frequencies. Can you run `powerd
> -v` and look what happens there?
> 
> powerd now drops/rises frequency exponentially, so lower frequency will
> be reached only after some period of idle. Rising is much faster to
> quickly restore system interactivity.

Right, what I expected, was a quicker ramp-up and a slower decay,
leading to more stable frequency while idling.

This is a Dell D630, Core2duo.  ACPI, line detection works and I was
testing with AC attached.  With AC attached, my concern isn't power, as
much as potential thermal impacts.  Idling at high frequency isn't
enough to kick my fans on high on this laptop, but I've had some that
would.

FreeBSD 8.0-CURRENT #1: Tue Nov 18 20:01:48 EST 2008
[EMAIL PROTECTED]:/usr/obj/usr/src/sys/D630
Timecounter "i8254" frequency 1193182 Hz quality 0
CPU: Intel(R) Core(TM)2 Duo CPU T7100  @ 1.80GHz (1795.00-MHz
686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6fd  Stepping = 13

Features=0xbfebfbff

Features2=0xe3bd
  AMD Features=0x2010
  AMD Features2=0x1
  Cores per package: 2

dev.cpu.0.freq: 1800
dev.cpu.0.freq_levels: 1800/31000 1575/27125 1350/23250 1200/13000
1050/11375 900/9750 750/8125 600/6500 450/4875 300/3250 150/1625
dev.est.0.freq_settings: 1800/31000 1200/13000
dev.est.1.freq_settings: 1800/31000 1200/13000

dev.p4tcc.0.freq_settings: 1/-1 8750/-1 7500/-1 6250/-1 5000/-1
3750/-1 2500/-1 1250/-1
dev.p4tcc.1.freq_settings: 1/-1 8750/-1 7500/-1 6250/-1 5000/-1
3750/-1 2500/-1 1250/-1

robert.



signature.asc
Description: This is a digitally signed message part


svn commit: r185443 - in stable/7/sys: . pci

2008-11-29 Thread Robert Noland
Author: rnoland
Date: Sat Nov 29 17:33:38 2008
New Revision: 185443
URL: http://svn.freebsd.org/changeset/base/185443

Log:
  MFC r183555: Correctly handle Intel g33 chips and add support for g45
  chips.
  
  g33 based chips use a different method of identifying the gtt size.
  g45 based chips gtt is located in a different area of stolen memory.
  
  Approved by:  re@ (kensmith)

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/pci/agp_i810.c
  stable/7/sys/pci/agpreg.h

Modified: stable/7/sys/pci/agp_i810.c
==
--- stable/7/sys/pci/agp_i810.c Sat Nov 29 17:14:06 2008(r185442)
+++ stable/7/sys/pci/agp_i810.c Sat Nov 29 17:33:38 2008(r185443)
@@ -70,6 +70,7 @@ enum {
CHIP_I915,  /* 915G/915GM */
CHIP_I965,  /* G965 */
CHIP_G33,   /* G33/Q33/Q35 */
+   CHIP_G4X,   /* G45/Q45 */
 };
 
 /* The i810 through i855 have the registers at BAR 1, and the GATT gets
@@ -133,7 +134,7 @@ static const struct agp_i810_match {
{0x25628086, CHIP_I830, 0x0002,
"Intel 82845M (845M GMCH) SVGA controller"},
{0x35828086, CHIP_I855, 0x0002,
-   "Intel 82852/5"},
+   "Intel 82852/855GM SVGA controller"},
{0x25728086, CHIP_I855, 0x0002,
"Intel 82865G (865G GMCH) SVGA controller"},
{0x25828086, CHIP_I915, 0x0002,
@@ -154,18 +155,26 @@ static const struct agp_i810_match {
"Intel G965 SVGA controller"},
{0x29928086, CHIP_I965, 0x0002,
"Intel Q965 SVGA controller"},
-   {0x29a28086, CHIP_I965, 0x0002,
+   {0x29A28086, CHIP_I965, 0x0002,
"Intel G965 SVGA controller"},
-   {0x29b28086, CHIP_G33, 0x0002,
+   {0x29B28086, CHIP_G33, 0x0002,
"Intel Q35 SVGA controller"},
-   {0x29c28086, CHIP_G33, 0x0002,
+   {0x29C28086, CHIP_G33, 0x0002,
"Intel G33 SVGA controller"},
-   {0x29d28086, CHIP_G33, 0x0002,
+   {0x29D28086, CHIP_G33, 0x0002,
"Intel Q33 SVGA controller"},
-   {0x2a028086, CHIP_I965, 0x0002,
+   {0x2A028086, CHIP_I965, 0x0002,
"Intel GM965 SVGA controller"},
-   {0x2a128086, CHIP_I965, 0x0002,
+   {0x2A128086, CHIP_I965, 0x0002,
"Intel GME965 SVGA controller"},
+   {0x2A428086, CHIP_I965, 0x0002,
+   "Intel GM45 SVGA controller"},
+   {0x2E028086, CHIP_G4X, 0x0002,
+   "Intel 4 Series SVGA controller"},
+   {0x2E128086, CHIP_G4X, 0x0002,
+   "Intel Q45 SVGA controller"},
+   {0x2E228086, CHIP_G4X, 0x0002,
+   "Intel G45 SVGA controller"},
{0, 0, 0, NULL}
 };
 
@@ -377,6 +386,7 @@ agp_i810_attach(device_t dev)
agp_set_aperture_resource(dev, AGP_I915_GMADR);
break;
case CHIP_I965:
+   case CHIP_G4X:
sc->sc_res_spec = agp_i965_res_spec;
agp_set_aperture_resource(dev, AGP_I915_GMADR);
break;
@@ -476,7 +486,8 @@ agp_i810_attach(device_t dev)
 
gatt->ag_physical = pgtblctl & ~1;
} else if (sc->chiptype == CHIP_I855 || sc->chiptype == CHIP_I915 ||
-   sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33) {
+   sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33 ||
+   sc->chiptype == CHIP_G4X) {
unsigned int gcc1, pgtblctl, stolen, gtt_size;
 
/* Stolen memory is set up at the beginning of the aperture by
@@ -491,7 +502,6 @@ agp_i810_attach(device_t dev)
gtt_size = 256;
break;
case CHIP_I965:
-   case CHIP_G33:
switch (bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL) &
AGP_I810_PGTBL_SIZE_MASK) {
case AGP_I810_PGTBL_SIZE_128KB:
@@ -503,6 +513,33 @@ agp_i810_attach(device_t dev)
case AGP_I810_PGTBL_SIZE_512KB:
gtt_size = 512;
break;
+   case AGP_I965_PGTBL_SIZE_1MB:
+   gtt_size = 1024;
+   break;
+   case AGP_I965_PGTBL_SIZE_2MB:
+   gtt_size = 2048;
+   break;
+   case AGP_I965_PGTBL_SIZE_1_5MB:
+   gtt_size = 1024 + 512;
+   break;
+   default:
+   device_printf(dev, "Bad PGTBL size\n");
+   bus_release_resources(dev, sc->sc_res_spec,
+   sc->sc_res);
+   free(gatt, M_AGP);
+   agp_generic_detach(dev);
+   return EINVAL;

svn commit: r185445 - in releng/7.1/sys: . pci

2008-11-29 Thread Robert Noland
Author: rnoland
Date: Sat Nov 29 17:36:08 2008
New Revision: 185445
URL: http://svn.freebsd.org/changeset/base/185445

Log:
  MFC r183555: Correctly handle Intel g33 chips and add support for g45
  chips.
  
  g33 based chips use a different method of identifying the gtt size.
  g45 based chips gtt is located in a different area of stolen memory.
  
  Approved by:  re@ (kensmith)

Modified:
  releng/7.1/sys/   (props changed)
  releng/7.1/sys/pci/agp_i810.c
  releng/7.1/sys/pci/agpreg.h

Modified: releng/7.1/sys/pci/agp_i810.c
==
--- releng/7.1/sys/pci/agp_i810.c   Sat Nov 29 17:34:46 2008
(r185444)
+++ releng/7.1/sys/pci/agp_i810.c   Sat Nov 29 17:36:08 2008
(r185445)
@@ -70,6 +70,7 @@ enum {
CHIP_I915,  /* 915G/915GM */
CHIP_I965,  /* G965 */
CHIP_G33,   /* G33/Q33/Q35 */
+   CHIP_G4X,   /* G45/Q45 */
 };
 
 /* The i810 through i855 have the registers at BAR 1, and the GATT gets
@@ -133,7 +134,7 @@ static const struct agp_i810_match {
{0x25628086, CHIP_I830, 0x0002,
"Intel 82845M (845M GMCH) SVGA controller"},
{0x35828086, CHIP_I855, 0x0002,
-   "Intel 82852/5"},
+   "Intel 82852/855GM SVGA controller"},
{0x25728086, CHIP_I855, 0x0002,
"Intel 82865G (865G GMCH) SVGA controller"},
{0x25828086, CHIP_I915, 0x0002,
@@ -154,18 +155,26 @@ static const struct agp_i810_match {
"Intel G965 SVGA controller"},
{0x29928086, CHIP_I965, 0x0002,
"Intel Q965 SVGA controller"},
-   {0x29a28086, CHIP_I965, 0x0002,
+   {0x29A28086, CHIP_I965, 0x0002,
"Intel G965 SVGA controller"},
-   {0x29b28086, CHIP_G33, 0x0002,
+   {0x29B28086, CHIP_G33, 0x0002,
"Intel Q35 SVGA controller"},
-   {0x29c28086, CHIP_G33, 0x0002,
+   {0x29C28086, CHIP_G33, 0x0002,
"Intel G33 SVGA controller"},
-   {0x29d28086, CHIP_G33, 0x0002,
+   {0x29D28086, CHIP_G33, 0x0002,
"Intel Q33 SVGA controller"},
-   {0x2a028086, CHIP_I965, 0x0002,
+   {0x2A028086, CHIP_I965, 0x0002,
"Intel GM965 SVGA controller"},
-   {0x2a128086, CHIP_I965, 0x0002,
+   {0x2A128086, CHIP_I965, 0x0002,
"Intel GME965 SVGA controller"},
+   {0x2A428086, CHIP_I965, 0x0002,
+   "Intel GM45 SVGA controller"},
+   {0x2E028086, CHIP_G4X, 0x0002,
+   "Intel 4 Series SVGA controller"},
+   {0x2E128086, CHIP_G4X, 0x0002,
+   "Intel Q45 SVGA controller"},
+   {0x2E228086, CHIP_G4X, 0x0002,
+   "Intel G45 SVGA controller"},
{0, 0, 0, NULL}
 };
 
@@ -377,6 +386,7 @@ agp_i810_attach(device_t dev)
agp_set_aperture_resource(dev, AGP_I915_GMADR);
break;
case CHIP_I965:
+   case CHIP_G4X:
sc->sc_res_spec = agp_i965_res_spec;
agp_set_aperture_resource(dev, AGP_I915_GMADR);
break;
@@ -476,7 +486,8 @@ agp_i810_attach(device_t dev)
 
gatt->ag_physical = pgtblctl & ~1;
} else if (sc->chiptype == CHIP_I855 || sc->chiptype == CHIP_I915 ||
-   sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33) {
+   sc->chiptype == CHIP_I965 || sc->chiptype == CHIP_G33 ||
+   sc->chiptype == CHIP_G4X) {
unsigned int gcc1, pgtblctl, stolen, gtt_size;
 
/* Stolen memory is set up at the beginning of the aperture by
@@ -491,7 +502,6 @@ agp_i810_attach(device_t dev)
gtt_size = 256;
break;
case CHIP_I965:
-   case CHIP_G33:
switch (bus_read_4(sc->sc_res[0], AGP_I810_PGTBL_CTL) &
AGP_I810_PGTBL_SIZE_MASK) {
case AGP_I810_PGTBL_SIZE_128KB:
@@ -503,6 +513,33 @@ agp_i810_attach(device_t dev)
case AGP_I810_PGTBL_SIZE_512KB:
gtt_size = 512;
break;
+   case AGP_I965_PGTBL_SIZE_1MB:
+   gtt_size = 1024;
+   break;
+   case AGP_I965_PGTBL_SIZE_2MB:
+   gtt_size = 2048;
+   break;
+   case AGP_I965_PGTBL_SIZE_1_5MB:
+   gtt_size = 1024 + 512;
+   break;
+   default:
+   device_printf(dev, "Bad PGTBL size\n");
+   bus_release_resources(dev, sc->sc_res_spec,
+   sc->sc_res);
+   free(gatt, M_AGP);
+   agp_generic_detach(dev);
+