Skip to contentSkip to conversation

GMA50 series update

PATCH In review Alan Cox 6 participants 75 messages Jul 5, 2011 – Oct 18, 2011

Subsystems (4)
lore
Share & tools
lore

Alan Cox

author
#0 lore raw

cover GMA50 series update

(Rebased versus the patches Greg took earlier)

The main things here are modularisation and support for Cedarview (this is unaccelerated as it has no 2D acceleration). I have some crazy ideas about using the GTT to do 2D console acceleration however but not much can be done for X.

At this point I think the Poulsbo (GMA500) and Cedarview code are probably ready to move out of staging - hence the modularisation work. The MID platforms need more cleaning up.

HDMI support at this point is pretty basic with no HDMI audio support. I'm hoping that will be something that can be addressed in future and now the basic bits are there I need to take a look at Oaktrail (Atom Z760/GMA600) and see if the same code can be used to bring up HDMI on that device too.

Alan

---

Alan Cox (48):
gma500: power can be touched in IRQ state
gma500: Fix missing memory check
gma500: Workaround for Medfield/Cedarview cursor bug
gma500: Fix backlight crash
gma500: Add the HDMI bits
gma500: begin adding CDV specific code
gma500: move the power header
gma500: move the BIOS header
gma500: tidying up the power stuff a spot
gma500: move the i2c code
gma500: the MMU code is also generic
gma500: move opregion files
gma500: tidy up the opregion and lid code
gma500: Rename the psb_intel_bios code
gma500: begin the config based split
gma500: the GEM and GTT code is device independant
gma500: The 2D code is now also device independent
gma500: move framebuffer file
gma500: tidy the framebuffer fixme and oddments
gma500: the 'mrst' BIOS is actually MID generic
gma500: Add the beginnings of Cedarview support
gma500: move configuration bits into the psb_ops structure
gma500: remove an un-needed check
gma500: add more ops
gma500: enable Medfield CRTC support
gma500: Read the GCT panel type information for Medfield
gma500: Fix early Medfield crash
gma500: continue abstracting platform specific code
gma500: being abstracting out devices a bit more
gma500: Only fiddle with clock gating on PSB
gma500: Update the GEM todo
gma500: psb_fb tidy/cleanup pass
gma500: Extract BIOSisy stuff from psb_drv
gma500: Move our other GEM helper into the bits want to push into GEM
gma500: Medfield support
gma500: 2D polish
gma500: CodingStyle pass
gma500: Use the GEM tweaks to provide a GEM frame buffer
gma500: GEM glue
gma500: Kill spare kref
gma500: nuke the PSB debug stuff
gma500: nuke the last bits of TTM code
gma500: 2D acceleration tidying
gma500: polish for completion of this phase
gma500: trim some of the debug
gma500: Do sane FB cleanup
gma500: revamp frame buffer creation and handling
gma500: Ensure the frame buffer has a linear virtual mapping

Jani Nikula (1):

      commit ee12661199b82934552c7636b10217a9aa42958a
 drivers/staging/gma500/Kconfig                |   27 
 drivers/staging/gma500/Makefile               |   43 +
 drivers/staging/gma500/accel_2d.c             |  358 ++++++
 drivers/staging/gma500/backlight.c            |   47 +
 drivers/staging/gma500/cdv_device.c           |  350 ++++++
 drivers/staging/gma500/cdv_intel_display.c    | 1513 +++++++++++++++++++++++++
 drivers/staging/gma500/cdv_intel_lvds.c       |  718 ++++++++++++
 drivers/staging/gma500/displays/hdmi.h        |   33 +
 drivers/staging/gma500/displays/pyr_cmd.h     |   34 +
 drivers/staging/gma500/displays/pyr_vid.h     |   34 +
 drivers/staging/gma500/displays/tmd_cmd.h     |   34 +
 drivers/staging/gma500/displays/tmd_vid.h     |   34 +
 drivers/staging/gma500/displays/tpo_cmd.h     |   35 +
 drivers/staging/gma500/displays/tpo_vid.h     |   33 +
 drivers/staging/gma500/framebuffer.c          |  810 +++++++++++++
 drivers/staging/gma500/framebuffer.h          |   49 +
 drivers/staging/gma500/gem.c                  |  252 ++++
 drivers/staging/gma500/gem_glue.c             |  110 ++
 drivers/staging/gma500/gem_glue.h             |    4 
 drivers/staging/gma500/gtt.c                  |  510 ++++++++
 drivers/staging/gma500/gtt.h                  |   62 +
 drivers/staging/gma500/intel_bios.c           |  303 +++++
 drivers/staging/gma500/intel_bios.h           |  430 +++++++
 drivers/staging/gma500/intel_i2c.c            |  169 +++
 drivers/staging/gma500/intel_opregion.c       |   80 +
 drivers/staging/gma500/mdfld_device.c         |  713 ++++++++++++
 drivers/staging/gma500/mdfld_dsi_dbi.c        |  872 ++++++++++++++
 drivers/staging/gma500/mdfld_dsi_dbi.h        |  188 +++
 drivers/staging/gma500/mdfld_dsi_dbi_dpu.h    |  157 +++
 drivers/staging/gma500/mdfld_dsi_dpi.c        |  991 ++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_dpi.h        |   80 +
 drivers/staging/gma500/mdfld_dsi_output.c     |  980 ++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_output.h     |  328 +++++
 drivers/staging/gma500/mdfld_dsi_pkg_sender.c | 1097 ++++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_pkg_sender.h |  158 +++
 drivers/staging/gma500/mdfld_intel_display.c  | 1415 +++++++++++++++++++++++
 drivers/staging/gma500/mdfld_msic.h           |   31 +
 drivers/staging/gma500/mdfld_output.c         |  144 ++
 drivers/staging/gma500/mdfld_output.h         |   80 +
 drivers/staging/gma500/mdfld_pyr_cmd.c        |  575 ++++++++++
 drivers/staging/gma500/mdfld_tmd_vid.c        |  144 ++
 drivers/staging/gma500/mdfld_tpo_cmd.c        |  495 ++++++++
 drivers/staging/gma500/mdfld_tpo_vid.c        |  140 ++
 drivers/staging/gma500/mid_bios.c             |  271 ++++
 drivers/staging/gma500/mid_bios.h             |   21 
 drivers/staging/gma500/mmu.c                  |  858 ++++++++++++++
 drivers/staging/gma500/mrst.h                 |   38 -
 drivers/staging/gma500/mrst_crtc.c            |   31 -
 drivers/staging/gma500/mrst_device.c          |  377 ++++++
 drivers/staging/gma500/mrst_lvds.c            |   26 
 drivers/staging/gma500/power.c                |  315 +++++
 drivers/staging/gma500/power.h                |   67 +
 drivers/staging/gma500/psb_2d.c               |  410 -------
 drivers/staging/gma500/psb_bl.c               |  227 ----
 drivers/staging/gma500/psb_device.c           |  352 ++++++
 drivers/staging/gma500/psb_drm.h              |  109 --
 drivers/staging/gma500/psb_drv.c              |  419 +------
 drivers/staging/gma500/psb_drv.h              |  460 +++++---
 drivers/staging/gma500/psb_fb.c               |  834 --------------
 drivers/staging/gma500/psb_fb.h               |   49 -
 drivers/staging/gma500/psb_gem.c              |  308 -----
 drivers/staging/gma500/psb_gtt.c              |  539 ---------
 drivers/staging/gma500/psb_gtt.h              |   61 -
 drivers/staging/gma500/psb_intel_bios.c       |  306 -----
 drivers/staging/gma500/psb_intel_bios.h       |  430 -------
 drivers/staging/gma500/psb_intel_display.c    |  164 +--
 drivers/staging/gma500/psb_intel_display.h    |    3 
 drivers/staging/gma500/psb_intel_drv.h        |   24 
 drivers/staging/gma500/psb_intel_i2c.c        |  169 ---
 drivers/staging/gma500/psb_intel_lvds.c       |   91 --
 drivers/staging/gma500/psb_intel_opregion.c   |   78 -
 drivers/staging/gma500/psb_intel_reg.h        | 1144 ++++++++++---------
 drivers/staging/gma500/psb_intel_sdvo.c       |   35 -
 drivers/staging/gma500/psb_intel_sdvo_regs.h  |   14 
 drivers/staging/gma500/psb_irq.c              |   99 +-
 drivers/staging/gma500/psb_irq.h              |    8 
 drivers/staging/gma500/psb_lid.c              |    6 
 drivers/staging/gma500/psb_mmu.c              |  858 --------------
 drivers/staging/gma500/psb_powermgmt.c        |  489 --------
 drivers/staging/gma500/psb_powermgmt.h        |   67 -
 drivers/staging/gma500/psb_reg.h              |  842 +++++++-------
 81 files changed, 18550 insertions(+), 6709 deletions(-)
 create mode 100644 drivers/staging/gma500/accel_2d.c
 create mode 100644 drivers/staging/gma500/backlight.c
 create mode 100644 drivers/staging/gma500/cdv_device.c
 create mode 100644 drivers/staging/gma500/cdv_intel_display.c
 create mode 100644 drivers/staging/gma500/cdv_intel_lvds.c
 create mode 100644 drivers/staging/gma500/displays/hdmi.h
 create mode 100644 drivers/staging/gma500/displays/pyr_cmd.h
 create mode 100644 drivers/staging/gma500/displays/pyr_vid.h
 create mode 100644 drivers/staging/gma500/displays/tmd_cmd.h
 create mode 100644 drivers/staging/gma500/displays/tmd_vid.h
 create mode 100644 drivers/staging/gma500/displays/tpo_cmd.h
 create mode 100644 drivers/staging/gma500/displays/tpo_vid.h
 create mode 100644 drivers/staging/gma500/framebuffer.c
 create mode 100644 drivers/staging/gma500/framebuffer.h
 create mode 100644 drivers/staging/gma500/gem.c
 create mode 100644 drivers/staging/gma500/gem_glue.c
 create mode 100644 drivers/staging/gma500/gem_glue.h
 create mode 100644 drivers/staging/gma500/gtt.c
 create mode 100644 drivers/staging/gma500/gtt.h
 create mode 100644 drivers/staging/gma500/intel_bios.c
 create mode 100644 drivers/staging/gma500/intel_bios.h
 create mode 100644 drivers/staging/gma500/intel_i2c.c
 create mode 100644 drivers/staging/gma500/intel_opregion.c
 create mode 100644 drivers/staging/gma500/mdfld_device.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi_dpu.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dpi.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dpi.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_output.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_output.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_pkg_sender.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_pkg_sender.h
 create mode 100644 drivers/staging/gma500/mdfld_intel_display.c
 create mode 100644 drivers/staging/gma500/mdfld_msic.h
 create mode 100644 drivers/staging/gma500/mdfld_output.c
 create mode 100644 drivers/staging/gma500/mdfld_output.h
 create mode 100644 drivers/staging/gma500/mdfld_pyr_cmd.c
 create mode 100644 drivers/staging/gma500/mdfld_tmd_vid.c
 create mode 100644 drivers/staging/gma500/mdfld_tpo_cmd.c
 create mode 100644 drivers/staging/gma500/mdfld_tpo_vid.c
 create mode 100644 drivers/staging/gma500/mid_bios.c
 create mode 100644 drivers/staging/gma500/mid_bios.h
 create mode 100644 drivers/staging/gma500/mmu.c
 create mode 100644 drivers/staging/gma500/mrst_device.c
 create mode 100644 drivers/staging/gma500/power.c
 create mode 100644 drivers/staging/gma500/power.h
 delete mode 100644 drivers/staging/gma500/psb_2d.c
 delete mode 100644 drivers/staging/gma500/psb_bl.c
 create mode 100644 drivers/staging/gma500/psb_device.c
 delete mode 100644 drivers/staging/gma500/psb_fb.c
 delete mode 100644 drivers/staging/gma500/psb_fb.h
 delete mode 100644 drivers/staging/gma500/psb_gem.c
 delete mode 100644 drivers/staging/gma500/psb_gtt.c
 delete mode 100644 drivers/staging/gma500/psb_gtt.h
 delete mode 100644 drivers/staging/gma500/psb_intel_bios.c
 delete mode 100644 drivers/staging/gma500/psb_intel_bios.h
 delete mode 100644 drivers/staging/gma500/psb_intel_i2c.c
 delete mode 100644 drivers/staging/gma500/psb_intel_opregion.c
 delete mode 100644 drivers/staging/gma500/psb_mmu.c
 delete mode 100644 drivers/staging/gma500/psb_powermgmt.c
 delete mode 100644 drivers/staging/gma500/psb_powermgmt.h
Signature · 1 line
Signature
author
#1 lore raw

PATCH 1/49 gma500: Ensure the frame buffer has a linear virtual mapping

From: Alan Cox <[email protected]>

We need this for the framebuffer in order to ensure that the kernel framebuffer layer can handle it when using KMS. Except for the base framebuffer this isn't a concern.

Add an npage field to the gtt as too many copies of the page calculation are getting spread around the code.

---

 drivers/staging/gma500/psb_fb.c  |   47 ++++++++++++++++++++++++--------------
 drivers/staging/gma500/psb_fb.h  |    1 +
 drivers/staging/gma500/psb_gtt.c |   18 ++++++---------
 drivers/staging/gma500/psb_gtt.h |    5 ++--
 4 files changed, 42 insertions(+), 29 deletions(-)
drivers/staging/gma500/psb_fb.c +30 -17
index b276fe9..4b05cdc 100644
@@ -254,17 +254,13 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
 				vma->vm_pgoff, fb_screen_base,
                                 dev_priv->vram_addr);
 
-        /* FIXME: ultimately this needs to become 'if entirely stolen memory' */
-	if (1 || fb_screen_base == dev_priv->vram_addr) {
-		vma->vm_ops = &psbfb_vm_ops;
-		vma->vm_private_data = (void *)psbfb;
-		vma->vm_flags |= VM_RESERVED | VM_IO |
-						VM_MIXEDMAP | VM_DONTEXPAND;
-	} else {
-	        /* GTT memory backed by kernel/user pages, needs a different
-	           approach ? - GEM ? */
-	}
-
+        /* If this is a GEM object then info->screen_base is the virtual
+           kernel remapping of the object. FIXME: Review if this is
+           suitable for our mmap work */
+	vma->vm_ops = &psbfb_vm_ops;
+	vma->vm_private_data = (void *)psbfb;
+	vma->vm_flags |= VM_RESERVED | VM_IO |
+					VM_MIXEDMAP | VM_DONTEXPAND;
 	return 0;
 }
 
@@ -349,8 +345,6 @@ err:
  *
  *	FIXME: console speed up - allocate twice the space if room and use
  *	hardware scrolling for acceleration.
- *	FIXME: we need to vm_map_ram  a linear mapping if the object has to
- *	be GEM host mapped, otherwise the cfb layer's brain will fall out.
  */
 static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
 {
@@ -439,10 +433,22 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 	info->fix.smem_start = dev->mode_config.fb_base;
 	info->fix.smem_len = size;
 
-	/* Accessed via stolen memory directly, This only works for stolem
-	   memory however. Need to address this once we start using gtt
-	   pages we allocate. FIXME: vm_map_ram for that case */
-	info->screen_base = (char *)dev_priv->vram_addr + backing->offset;
+	if (backing->stolen) {
+		/* Accessed stolen memory directly */
+		info->screen_base = (char *)dev_priv->vram_addr +
+							backing->offset;
+	} else {
+		/* Pin the pages into the GTT and create a mapping to them */
+		psb_gtt_pin(backing);
+		info->screen_base = vm_map_ram(backing->pages, backing->npage,
+				-1, PAGE_KERNEL);
+		if (info->screen_base == NULL) {
+			psb_gtt_unpin(backing);
+			ret = -ENOMEM;
+			goto out_err0;
+		}
+		psbfb->vm_map = 1;
+	}
 	info->screen_size = size;
 	memset(info->screen_base, 0, size);
 
@@ -570,6 +576,13 @@ int psb_fbdev_destroy(struct drm_device *dev, struct psb_fbdev *fbdev)
 
 	if (fbdev->psb_fb_helper.fbdev) {
 		info = fbdev->psb_fb_helper.fbdev;
+
+		/* If this is our base framebuffer then kill any virtual map
+		   for the framebuffer layer and unpin it */
+		if (psbfb->vm_map) {
+			vm_unmap_ram(info->screen_base, psbfb->gtt->npage);
+			psb_gtt_unpin(psbfb->gtt);
+		}
 		/* FIXME: this is a bit more inside knowledge than I'd like
 		   but I don't see how to make a fake GEM object of the
 		   stolen space nicely */
drivers/staging/gma500/psb_fb.h +1 -0
index c8ec0d6..2153c74 100644
@@ -33,6 +33,7 @@ struct psb_framebuffer {
 	struct address_space *addr_space;
 	struct fb_info *fbdev;
 	struct gtt_range *gtt;
+	bool vm_map;		/* True if we must undo a vm_map_ram */
 };
 
 struct psb_fbdev {
drivers/staging/gma500/psb_gtt.c +8 -10
index 15a51f1..5a296e1 100644
@@ -79,7 +79,6 @@ u32 *psb_gtt_entry(struct drm_device *dev, struct gtt_range *r)
 static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
 {
 	u32 *gtt_slot, pte;
-	int numpages = (r->resource.end + 1 - r->resource.start) >> PAGE_SHIFT;
 	struct page **pages;
 	int i;
 
@@ -94,10 +93,10 @@ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
 	pages = r->pages;
 
 	/* Make sure changes are visible to the GPU */
-	set_pages_array_uc(pages, numpages);
+	set_pages_array_uc(pages, r->npage);
 
 	/* Write our page entries into the GTT itself */
-	for (i = 0; i < numpages; i++) {
+	for (i = 0; i < r->npage; i++) {
 		pte = psb_gtt_mask_pte(page_to_pfn(*pages++), 0/*type*/);
 		iowrite32(pte, gtt_slot++);
 	}
@@ -120,7 +119,6 @@ static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	u32 *gtt_slot, pte;
-	int numpages = (r->resource.end + 1 - r->resource.start) >> PAGE_SHIFT;
 	int i;
 
 	WARN_ON(r->stolen);
@@ -128,10 +126,10 @@ static void psb_gtt_remove(struct drm_device *dev, struct gtt_range *r)
 	gtt_slot = psb_gtt_entry(dev, r);
 	pte = psb_gtt_mask_pte(page_to_pfn(dev_priv->scratch_page), 0);
 
-	for (i = 0; i < numpages; i++)
+	for (i = 0; i < r->npage; i++)
 		iowrite32(pte, gtt_slot++);
 	ioread32(gtt_slot - 1);
-	set_pages_array_wb(r->pages, numpages);
+	set_pages_array_wb(r->pages, r->npage);
 }
 
 /**
@@ -149,7 +147,7 @@ static int psb_gtt_attach_pages(struct gtt_range *gt)
 	struct address_space *mapping;
 	int i;
 	struct page *p;
-	int pages = (gt->resource.end + 1 - gt->resource.start) >> PAGE_SHIFT;
+	int pages = gt->gem.size / PAGE_SIZE;
 
 	WARN_ON(gt->pages);
 
@@ -160,6 +158,8 @@ static int psb_gtt_attach_pages(struct gtt_range *gt)
 	gt->pages = kmalloc(pages * sizeof(struct page *), GFP_KERNEL);
 	if (gt->pages == NULL)
 		return -ENOMEM;
+	gt->npage = pages;
+
 	for (i = 0; i < pages; i++) {
 		/* FIXME: review flags later */
 		p = read_cache_page_gfp(mapping, i,
@@ -191,9 +191,7 @@ err:
 static void psb_gtt_detach_pages(struct gtt_range *gt)
 {
 	int i;
-	int pages = (gt->resource.end + 1 - gt->resource.start) >> PAGE_SHIFT;
-
-	for (i = 0; i < pages; i++) {
+	for (i = 0; i < gt->npage; i++) {
 		/* FIXME: do we need to force dirty */
 		set_page_dirty(gt->pages[i]);
 		/* Undo the reference we took when populating the table */
drivers/staging/gma500/psb_gtt.h +3 -2
index 535ae00..37287eb 100644
@@ -46,9 +46,10 @@ struct gtt_range {
 	struct kref kref;
 	struct drm_gem_object gem;	/* GEM high level stuff */
 	int in_gart;			/* Currently in the GART (ref ct) */
-        bool stolen;			/* Backed from stolen RAM */
-        bool mmapping;			/* Is mmappable */
+	bool stolen;			/* Backed from stolen RAM */
+	bool mmapping;			/* Is mmappable */
 	struct page **pages;		/* Backing pages if present */
+	int npage;			/* Number of backing pages */
 };
 
 extern struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
author
#2 lore raw

PATCH 2/49 gma500: revamp frame buffer creation and handling

In reply to Alan Cox

From: Alan Cox <[email protected]>

Restructure this to work the same way as the i915 frame buffer does. That cleans up various chunks of code.

We can now set a mode in modetest but mode restore is a bit iffy

---

 drivers/staging/gma500/psb_2d.c  |   13 +--
 drivers/staging/gma500/psb_fb.c  |  195 +++++++++++++++++++++-----------------
 drivers/staging/gma500/psb_fb.h  |    2 
 drivers/staging/gma500/psb_gem.c |   18 +++-
 drivers/staging/gma500/psb_gtt.c |    2 
 5 files changed, 133 insertions(+), 97 deletions(-)
drivers/staging/gma500/psb_2d.c +3 -10
index 0bd834c..060eeaf 100644
@@ -148,7 +148,7 @@ static void psbfb_fillrect_accel(struct fb_info *info,
 				 const struct fb_fillrect *r)
 {
 	struct psb_fbdev *fbdev = info->par;
-	struct psb_framebuffer *psbfb = fbdev->pfb;
+	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
 	struct drm_psb_private *dev_priv = dev->dev_private;
@@ -291,7 +291,7 @@ static void psbfb_copyarea_accel(struct fb_info *info,
 				 const struct fb_copyarea *a)
 {
 	struct psb_fbdev *fbdev = info->par;
-	struct psb_framebuffer *psbfb = fbdev->pfb;
+	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
 	struct drm_psb_private *dev_priv = dev->dev_private;
@@ -360,19 +360,12 @@ void psbfb_imageblit(struct fb_info *info, const struct fb_image *image)
 int psbfb_sync(struct fb_info *info)
 {
 	struct psb_fbdev *fbdev = info->par;
-	struct psb_framebuffer *psbfb = fbdev->pfb;
+	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	unsigned long _end = jiffies + DRM_HZ;
 	int busy = 0;
 
-#if 0
-        /* Just a way to quickly test if cmd issue explodes */
-	u32 test[2] = {
-	        PSB_2D_FENCE_BH,
-        };
-	psbfb_2d_submit(dev_priv, test, 1);
-#endif	
 	/*
 	 * First idle the 2D engine.
 	 */
drivers/staging/gma500/psb_fb.c +110 -85

329 lines not on this page · raw message

drivers/staging/gma500/psb_fb.h +1 -1
index 2153c74..fd7e51a 100644
@@ -38,7 +38,7 @@ struct psb_framebuffer {
 
 struct psb_fbdev {
 	struct drm_fb_helper psb_fb_helper;
-	struct psb_framebuffer *pfb;
+	struct psb_framebuffer pfb;
 };
 
 
drivers/staging/gma500/psb_gem.c +17 -1
index 98d8ab3..b24b964 100644
@@ -51,6 +51,7 @@ void psb_gem_free_object(struct drm_gem_object *obj)
 	}
 	drm_gem_object_release(obj);
 	/* This must occur last as it frees up the memory of the GEM object */
+	pr_err("GEM destroyed %p, %p\n", gtt, obj);
 	psb_gtt_free_range(obj->dev, gtt);
 }
 
@@ -176,21 +177,28 @@ static int psb_gem_create(struct drm_file *file,
 
 	size = roundup(size, PAGE_SIZE);
 
+	dev_err(dev->dev, "GEM creating %lld\n", size);
+
 	/* Allocate our object - for now a direct gtt range which is not 
 	   stolen memory backed */
 	r = psb_gtt_alloc_range(dev, size, "gem", 0);
-	if (r == NULL)
+	if (r == NULL) {
+		dev_err(dev->dev, "no memory for %lld byte GEM object\n", size);
 		return -ENOSPC;
+	}
 	/* Initialize the extra goodies GEM needs to do all the hard work */
 	if (drm_gem_object_init(dev, &r->gem, size) != 0) {
 		psb_gtt_free_range(dev, r);
 		/* GEM doesn't give an error code and we don't have an
 		   EGEMSUCKS so make something up for now - FIXME */
+		dev_err(dev->dev, "GEM init failed for %lld\n", size);
 		return -ENOMEM;
 	}
 	/* Give the object a handle so we can carry it more easily */
 	ret = drm_gem_handle_create(file, &r->gem, &handle);
 	if (ret) {
+		dev_err(dev->dev, "GEM handle failed for %p, %lld\n",
+							&r->gem, size);
 		drm_gem_object_release(&r->gem);
 		psb_gtt_free_range(dev, r);
 		return ret;
@@ -198,6 +206,8 @@ static int psb_gem_create(struct drm_file *file,
 	/* We have the initial and handle reference but need only one now */
 	drm_gem_object_unreference(&r->gem);
 	*handlep = handle;
+	dev_err(dev->dev, "GEM handle %x for %p OK\n",
+				handle, &r->gem);
 	return 0;
 }
 
@@ -273,9 +283,12 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	   something from beneath our feet */
 	mutex_lock(&dev->struct_mutex);
 
+	dev_err(dev->dev, "Fault on GTT %p\n", r);
+
 	/* For now the mmap pins the object and it stays pinned. As things
 	   stand that will do us no harm */
 	if (r->mmapping == 0) {
+		dev_err(dev->dev, "Need to pin %p\n", r);
 		ret = psb_gtt_pin(r);
 		if (ret < 0) {
 		        DRM_ERROR("gma500: pin failed: %d\n", ret);
@@ -289,10 +302,13 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	page_offset = ((unsigned long) vmf->virtual_address - vma->vm_start)
 				>> PAGE_SHIFT;
 
+	dev_err(dev->dev, "Page offset %p %d\n", r, (int)page_offset);
         /* CPU view of the page, don't go via the GART for CPU writes */
 	pfn = page_to_phys(r->pages[page_offset]) >> PAGE_SHIFT;
 	ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
 
+	dev_err(dev->dev, "PFN %ld for VA %p = %d\n", pfn, vmf->virtual_address, ret);
+
 fail:
         mutex_unlock(&dev->struct_mutex);
 	switch (ret) {
drivers/staging/gma500/psb_gtt.c +2 -0
index 5a296e1..c6a7492 100644
@@ -314,6 +314,7 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
 				len, start, end, PAGE_SIZE, NULL, NULL);
 	if (ret == 0) {
 		gt->offset = gt->resource.start - r->start;
+		dev_err(dev->dev, "GTT new %p, %d\n", gt, gt->stolen);
 		return gt;
 	}
 	kfree(gt);
@@ -340,6 +341,7 @@ static void psb_gtt_destroy(struct kref *kref)
 	}
 	WARN_ON(gt->in_gart && !gt->stolen);
 	release_resource(&gt->resource);
+	pr_err("GTT destroyed %p, %d\n", gt, gt->stolen);
 	kfree(gt);
 }
 
author
#3 lore raw

PATCH 3/49 gma500: Do sane FB cleanup

In reply to Alan Cox

From: Alan Cox <[email protected]>

If we get a user frame buffer destroyed which is being displayed then clean up the mess nicely. We can now run a slightly modified modetest including setting modes, and handling crashes.

Modetest still blows up but this is because libdrm 2.4.25 is busted.

---

 drivers/staging/gma500/psb_fb.c            |   24 +++++++++++++++++++++++-
 drivers/staging/gma500/psb_intel_display.c |   22 +++++++++++++---------
 2 files changed, 36 insertions(+), 10 deletions(-)
drivers/staging/gma500/psb_fb.c +23 -1
index 5977add..d005025 100644
@@ -719,16 +719,38 @@ static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
 {
 	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 	struct gtt_range *r = psbfb->gtt;
+	struct drm_device *dev = fb->dev;
+	struct drm_psb_private *dev_priv = dev->dev_private;
+	struct psb_fbdev *fbdev = dev_priv->fbdev;
+	struct drm_crtc *crtc;
+	int reset = 0;
 
 	/* Should never get stolen memory for a user fb */
 	WARN_ON(r->stolen);
 	pr_err("user framebuffer destroy %p, fbdev %p\n",
 						psbfb, psbfb->fbdev);
+	/* Check if we are erroneously live */
+	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
+		if (crtc->fb == fb)
+			reset = 1;
+
+	if (reset)
+		pr_err("DRM: gma500, forcing reset\n");
+
+	if (reset)
+		/* 
+		 * Now force a sane response before we permit the DRM crc layer to
+		 * do stupid things like blank the display. Instead we reset this
+		 * framebuffer as if the user had forced a reset. We must do this
+		 * before the cleanup so that the DRM layer doesn't get a chance
+		 * to stick its oar in where it isn't wanted.
+		 */
+		drm_fb_helper_restore_fbdev_mode(&fbdev->psb_fb_helper);
+
         /* Let DRM do its clean up */
 	drm_framebuffer_cleanup(fb);
 	/*  We are no longer using the resource in GEM */
 	drm_gem_object_unreference_unlocked(&r->gem);
-
 	kfree(fb);
 }
 
drivers/staging/gma500/psb_intel_display.c +13 -9
index a358987..540304c 100644
@@ -352,15 +352,15 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
 
 	PSB_DEBUG_ENTRY("\n");
 
+	if (!gma_power_begin(dev, true))
+		return 0;
+
 	/* no fb bound */
 	if (!crtc->fb) {
 		DRM_DEBUG("No FB bound\n");
-		return 0;
+		goto psb_intel_pipe_cleaner;
 	}
 
-	if (!gma_power_begin(dev, true))
-		return 0;
-
 	/* We are displaying this buffer, make sure it is actually loaded
 	   into the GTT */
 	ret = psb_gtt_pin(psbfb->gtt);
@@ -409,6 +409,7 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
 		REG_READ(dspbase);
 	}
 
+psb_intel_pipe_cleaner:
 	/* If there was a previous display we can now unpin it */
 	if (old_fb)
 		psb_gtt_unpin(to_psb_fb(old_fb)->gtt);
@@ -588,6 +589,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
+	struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
 	int pipe = psb_intel_crtc->pipe;
 	int fp_reg = (pipe == 0) ? FPA0 : FPB0;
 	int dpll_reg = (pipe == 0) ? DPLL_A : DPLL_B;
@@ -610,6 +612,12 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 	struct drm_mode_config *mode_config = &dev->mode_config;
 	struct drm_connector *connector;
 
+	/* No scan out no play */
+	if (crtc->fb == NULL) {
+	        crtc_funcs->mode_set_base(crtc, x, y, old_fb);
+                return 0;
+        }
+
 	list_for_each_entry(connector, &mode_config->connector_list, head) {
 		struct psb_intel_output *psb_intel_output =
 		    to_psb_intel_output(connector);
@@ -786,11 +794,7 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 	REG_WRITE(dspcntr_reg, dspcntr);
 
 	/* Flush the plane changes */
-	{
-		struct drm_crtc_helper_funcs *crtc_funcs =
-		    crtc->helper_private;
-		crtc_funcs->mode_set_base(crtc, x, y, old_fb);
-	}
+	crtc_funcs->mode_set_base(crtc, x, y, old_fb);
 
 	psb_intel_wait_for_vblank(dev);
 
author
#4 lore raw

PATCH 4/49 gma500: trim some of the debug

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/psb_fb.c  |    6 +-----
 drivers/staging/gma500/psb_gem.c |   11 -----------
 drivers/staging/gma500/psb_gtt.c |    2 --
 3 files changed, 1 insertions(+), 18 deletions(-)
drivers/staging/gma500/psb_fb.c +1 -5
index d005025..156f8ad 100644
@@ -727,17 +727,13 @@ static void psb_user_framebuffer_destroy(struct drm_framebuffer *fb)
 
 	/* Should never get stolen memory for a user fb */
 	WARN_ON(r->stolen);
-	pr_err("user framebuffer destroy %p, fbdev %p\n",
-						psbfb, psbfb->fbdev);
+
 	/* Check if we are erroneously live */
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
 		if (crtc->fb == fb)
 			reset = 1;
 
 	if (reset)
-		pr_err("DRM: gma500, forcing reset\n");
-
-	if (reset)
 		/* 
 		 * Now force a sane response before we permit the DRM crc layer to
 		 * do stupid things like blank the display. Instead we reset this
drivers/staging/gma500/psb_gem.c +0 -11
index b24b964..125ea6b 100644
@@ -51,7 +51,6 @@ void psb_gem_free_object(struct drm_gem_object *obj)
 	}
 	drm_gem_object_release(obj);
 	/* This must occur last as it frees up the memory of the GEM object */
-	pr_err("GEM destroyed %p, %p\n", gtt, obj);
 	psb_gtt_free_range(obj->dev, gtt);
 }
 
@@ -177,8 +176,6 @@ static int psb_gem_create(struct drm_file *file,
 
 	size = roundup(size, PAGE_SIZE);
 
-	dev_err(dev->dev, "GEM creating %lld\n", size);
-
 	/* Allocate our object - for now a direct gtt range which is not 
 	   stolen memory backed */
 	r = psb_gtt_alloc_range(dev, size, "gem", 0);
@@ -206,8 +203,6 @@ static int psb_gem_create(struct drm_file *file,
 	/* We have the initial and handle reference but need only one now */
 	drm_gem_object_unreference(&r->gem);
 	*handlep = handle;
-	dev_err(dev->dev, "GEM handle %x for %p OK\n",
-				handle, &r->gem);
 	return 0;
 }
 
@@ -283,12 +278,9 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	   something from beneath our feet */
 	mutex_lock(&dev->struct_mutex);
 
-	dev_err(dev->dev, "Fault on GTT %p\n", r);
-
 	/* For now the mmap pins the object and it stays pinned. As things
 	   stand that will do us no harm */
 	if (r->mmapping == 0) {
-		dev_err(dev->dev, "Need to pin %p\n", r);
 		ret = psb_gtt_pin(r);
 		if (ret < 0) {
 		        DRM_ERROR("gma500: pin failed: %d\n", ret);
@@ -302,13 +294,10 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	page_offset = ((unsigned long) vmf->virtual_address - vma->vm_start)
 				>> PAGE_SHIFT;
 
-	dev_err(dev->dev, "Page offset %p %d\n", r, (int)page_offset);
         /* CPU view of the page, don't go via the GART for CPU writes */
 	pfn = page_to_phys(r->pages[page_offset]) >> PAGE_SHIFT;
 	ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
 
-	dev_err(dev->dev, "PFN %ld for VA %p = %d\n", pfn, vmf->virtual_address, ret);
-
 fail:
         mutex_unlock(&dev->struct_mutex);
 	switch (ret) {
drivers/staging/gma500/psb_gtt.c +0 -2
index c6a7492..5a296e1 100644
@@ -314,7 +314,6 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
 				len, start, end, PAGE_SIZE, NULL, NULL);
 	if (ret == 0) {
 		gt->offset = gt->resource.start - r->start;
-		dev_err(dev->dev, "GTT new %p, %d\n", gt, gt->stolen);
 		return gt;
 	}
 	kfree(gt);
@@ -341,7 +340,6 @@ static void psb_gtt_destroy(struct kref *kref)
 	}
 	WARN_ON(gt->in_gart && !gt->stolen);
 	release_resource(&gt->resource);
-	pr_err("GTT destroyed %p, %d\n", gt, gt->stolen);
 	kfree(gt);
 }
 
author
#5 lore raw

PATCH 5/49 gma500: polish for completion of this phase

In reply to Alan Cox

From: Alan Cox <[email protected]>

Give the driver its own proper DRM name, clean up copyright headers and so forth

---

 drivers/staging/gma500/mrst_crtc.c     |    4 +
 drivers/staging/gma500/mrst_lvds.c     |    2 -
 drivers/staging/gma500/psb_2d.c        |    7 --
 drivers/staging/gma500/psb_bl.c        |    4 +
 drivers/staging/gma500/psb_drm.h       |   90 +-------------------------------
 drivers/staging/gma500/psb_drv.c       |    4 +
 drivers/staging/gma500/psb_drv.h       |   85 +++++++++++++++---------------
 drivers/staging/gma500/psb_fb.c        |    3 -
 drivers/staging/gma500/psb_fb.h        |    3 -
 drivers/staging/gma500/psb_gtt.h       |    7 +-
 drivers/staging/gma500/psb_intel_drv.h |   19 +------
 drivers/staging/gma500/psb_irq.h       |    8 +--
 drivers/staging/gma500/psb_powermgmt.c |    4 +
 drivers/staging/gma500/psb_powermgmt.h |    2 -
 drivers/staging/gma500/psb_reg.h       |    2 -
 15 files changed, 67 insertions(+), 177 deletions(-)
drivers/staging/gma500/mrst_crtc.c +2 -2
index e4a0c03..fd97c80 100644
@@ -86,7 +86,7 @@ static const struct mrst_limit_t *mrst_limit(struct drm_crtc *crtc)
 {
 	const struct mrst_limit_t *limit = NULL;
 	struct drm_device *dev = crtc->dev;
-	DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+	struct drm_psb_private *dev_priv = dev->dev_private;
 
 	if (psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)
 	    || psb_intel_pipe_has_type(crtc, INTEL_OUTPUT_MIPI)) {
@@ -296,7 +296,7 @@ static int mrst_crtc_mode_set(struct drm_crtc *crtc,
 {
 	struct drm_device *dev = crtc->dev;
 	struct psb_intel_crtc *psb_intel_crtc = to_psb_intel_crtc(crtc);
-	DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+	struct drm_psb_private *dev_priv = dev->dev_private;
 	int pipe = psb_intel_crtc->pipe;
 	int fp_reg = (pipe == 0) ? MRST_FPA0 : FPB0;
 	int dpll_reg = (pipe == 0) ? MRST_DPLL_A : DPLL_B;
drivers/staging/gma500/mrst_lvds.c +1 -1
index 4a08b74..22ea00e 100644
@@ -46,7 +46,7 @@ static void mrst_lvds_set_power(struct drm_device *dev,
 				struct psb_intel_output *output, bool on)
 {
 	u32 pp_status;
-	DRM_DRIVER_PRIVATE_T *dev_priv = dev->dev_private;
+	struct drm_psb_private *dev_priv = dev->dev_private;
 	PSB_DEBUG_ENTRY("\n");
 
 	if (!gma_power_begin(dev, true))
drivers/staging/gma500/psb_2d.c +1 -6
index 060eeaf..c3d7085 100644
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright (c) 2007, Intel Corporation.
+ * Copyright (c) 2007-2011, Intel Corporation.
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -396,8 +396,3 @@ int psbfb_sync(struct fb_info *info)
 out:
 	return (busy) ? -EBUSY : 0;
 }
-
-/*
-	info->fix.accel = FB_ACCEL_I830;
-	info->flags = FBINFO_DEFAULT;
-*/
drivers/staging/gma500/psb_bl.c +2 -2
index 5dffc71..2f9674d 100644
@@ -1,7 +1,7 @@
 /*
- *  psb backlight interface
+ * GMA500 Backlight Interface
  *
- * Copyright (c) 2009, Intel Corporation.
+ * Copyright (c) 2009-2011, Intel Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
drivers/staging/gma500/psb_drm.h +2 -88

121 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +2 -2
index aa87b1b..9bd0a5d 100644
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright (c) 2007, Intel Corporation.
+ * Copyright (c) 2007-2011, Intel Corporation.
  * All Rights Reserved.
  * Copyright (c) 2008, Tungsten Graphics, Inc. Cedar Park, TX., USA.
  * All Rights Reserved.
@@ -1462,6 +1462,6 @@ static void __exit psb_exit(void)
 late_initcall(psb_init);
 module_exit(psb_exit);
 
-MODULE_AUTHOR(DRIVER_AUTHOR);
+MODULE_AUTHOR("Alan Cox <[email protected]> and others");
 MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
drivers/staging/gma500/psb_drv.h +41 -44

217 lines not on this page · raw message

drivers/staging/gma500/psb_fb.c +1 -2
index 156f8ad..0a77abf 100644
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright (c) 2007, Intel Corporation.
+ * Copyright (c) 2007-2011, Intel Corporation.
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -56,7 +56,6 @@ void *psbfb_vdc_reg(struct drm_device *dev)
 	dev_priv = (struct drm_psb_private *) dev->dev_private;
 	return dev_priv->vdc_reg;
 }
-/*EXPORT_SYMBOL(psbfb_vdc_reg); */
 
 static int psbfb_setcolreg(unsigned regno, unsigned red, unsigned green,
 			   unsigned blue, unsigned transp,
drivers/staging/gma500/psb_fb.h +1 -2
index fd7e51a..ed6e856 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Intel Corporation
+ * Copyright (c) 2008-2011, Intel Corporation
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -41,7 +41,6 @@ struct psb_fbdev {
 	struct psb_framebuffer pfb;
 };
 
-
 #define to_psb_fb(x) container_of(x, struct psb_framebuffer, base)
 
 extern int psb_intel_connector_clones(struct drm_device *dev, int type_mask);
drivers/staging/gma500/psb_gtt.h +4 -3
index 37287eb..7e1f21e 100644
@@ -22,6 +22,7 @@
 
 #include <drm/drmP.h>
 
+/* This wants cleaning up with respect to the psb_dev and un-needed stuff */
 struct psb_gtt {
 	struct drm_device *dev;
 	uint32_t gatt_start;
@@ -41,9 +42,9 @@ extern void psb_gtt_takedown(struct drm_device *dev);
 
 /* Each gtt_range describes an allocation in the GTT area */
 struct gtt_range {
-	struct resource resource;
-	u32 offset;
-	struct kref kref;
+	struct resource resource;	/* Resource for our allocation */
+	u32 offset;			/* GTT offset of our object */
+	struct kref kref;		/* Can probably go FIXME - GEM kref will do */
 	struct drm_gem_object gem;	/* GEM high level stuff */
 	int in_gart;			/* Currently in the GART (ref ct) */
 	bool stolen;			/* Backed from stolen RAM */
drivers/staging/gma500/psb_intel_drv.h +4 -15
index 6006ddd..75a95f7 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, Intel Corporation.
+ * Copyright (c) 2009-2011, Intel Corporation.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms and conditions of the GNU General Public License,
@@ -26,11 +26,6 @@
 #include <linux/gpio.h>
 
 /*
- * MOORESTOWN defines
- */
-#define DELAY_TIME1 2000 /* 1000 = 1ms */
-
-/*
  * Display related stuff
  */
 
@@ -61,16 +56,10 @@
 #define INTEL_DVO_CHIP_TMDS 2
 #define INTEL_DVO_CHIP_TVOUT 4
 
-enum mipi_panel_type {
-	NSC_800X480 = 1,
-	LGE_480X1024 = 2,
-	TPO_864X480 = 3
-};
-
-/**
+/*
  * Hold information useally put on the device driver privates here,
  * since it needs to be shared across multiple of devices drivers privates.
-*/
+ */
 struct psb_intel_mode_device {
 
 	/*
@@ -79,7 +68,7 @@ struct psb_intel_mode_device {
 	 size_t(*bo_offset) (struct drm_device *dev, void *bo);
 
 	/*
-	 * Cursor
+	 * Cursor (Can go ?)
 	 */
 	int cursor_needs_physical;
 
drivers/staging/gma500/psb_irq.h +2 -6
index 3e56f33..216fda3 100644
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright (c) 2009, Intel Corporation.
+ * Copyright (c) 2009-2011, Intel Corporation.
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
@@ -34,10 +34,6 @@ int  psb_irq_postinstall(struct drm_device *dev);
 void psb_irq_uninstall(struct drm_device *dev);
 irqreturn_t psb_irq_handler(DRM_IRQ_ARGS);
 
-void psb_irq_preinstall_islands(struct drm_device *dev, int hw_islands);
-int  psb_irq_postinstall_islands(struct drm_device *dev, int hw_islands);
-void psb_irq_uninstall_islands(struct drm_device *dev, int hw_islands);
-
 int psb_irq_enable_dpst(struct drm_device *dev);
 int psb_irq_disable_dpst(struct drm_device *dev);
 void psb_irq_turn_on_dpst(struct drm_device *dev);
@@ -46,4 +42,4 @@ int  psb_enable_vblank(struct drm_device *dev, int pipe);
 void psb_disable_vblank(struct drm_device *dev, int pipe);
 u32  psb_get_vblank_counter(struct drm_device *dev, int pipe);
 
-#endif //_SYSIRQ_H_
+#endif /* _SYSIRQ_H_ */
drivers/staging/gma500/psb_powermgmt.c +2 -2
index 1495415..50f2234 100644
@@ -1,7 +1,7 @@
 /**************************************************************************
- * Copyright (c) 2009, Intel Corporation.
+ * Copyright (c) 2009-2011, Intel Corporation.
  * All Rights Reserved.
-
+ *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * to deal in the Software without restriction, including without limitation
drivers/staging/gma500/psb_powermgmt.h +1 -1
index e005229..333b28d 100644
@@ -1,5 +1,5 @@
 /**************************************************************************
- * Copyright (c) 2009, Intel Corporation.
+ * Copyright (c) 2009-2011, Intel Corporation.
  * All Rights Reserved.
 
  * Permission is hereby granted, free of charge, to any person obtaining a
drivers/staging/gma500/psb_reg.h +1 -1
index 9ad4989..529fda8 100644
@@ -573,7 +573,7 @@
 #define MDFLD_PWRGT_DISPLAY_C_CNTR  0x00030000
 #define MDFLD_PWRGT_DISP_MIPI_CNTR  0x000c0000
 #define MDFLD_PWRGT_DISPLAY_CNTR    (MDFLD_PWRGT_DISPLAY_A_CNTR | MDFLD_PWRGT_DISPLAY_B_CNTR | MDFLD_PWRGT_DISPLAY_C_CNTR | MDFLD_PWRGT_DISP_MIPI_CNTR)// 0x000fc00c
-// Display SSS register bits are different in A0 vs. B0
+/* Display SSS register bits are different in A0 vs. B0 */
 #define PSB_PWRGT_GFX_MASK	    0x3
 #define MDFLD_PWRGT_DISPLAY_A_STS  		0x000000c0
 #define MDFLD_PWRGT_DISPLAY_B_STS  		0x00000300
author
#6 lore raw

PATCH 6/49 gma500: 2D acceleration tidying

In reply to Alan Cox

From: Alan Cox <[email protected]>

We have a FIXME to do the power management for which the framework now exists, and we also need to deal with an erratum. Some operations exactly 8 pixels wide or high fail. The work around is to do two smaller ones (see the Intel released X driver bits) but for console quite frankly if it's 8bits wide and/or high its not worth it so fall back.

---

 drivers/staging/gma500/psb_2d.c |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)
drivers/staging/gma500/psb_2d.c +13 -6
index c3d7085..494bad5 100644
@@ -183,10 +183,14 @@ static void psbfb_fillrect_accel(struct fb_info *info,
 		cfb_fillrect(info, r);
 		return;
 	}
-
+	if (!gma_power_begin(dev, false)) {
+		cfb_fillrect(info, r);
+		return;
+	}
 	psb_accel_2d_fillrect(dev_priv,
 			      offset, stride, format,
 			      r->dx, r->dy, r->width, r->height, r->color);
+	gma_power_end(dev);
 }
 
 void psbfb_fillrect(struct fb_info *info,
@@ -198,9 +202,7 @@ void psbfb_fillrect(struct fb_info *info,
 	if (1 || (info->flags & FBINFO_HWACCEL_DISABLED))
 		return cfb_fillrect(info, rect);
 
-	/*psb_check_power_state(dev, PSB_DEVICE_SGX); */
 	psbfb_fillrect_accel(info, rect);
-	/* Drop power again here on MRST FIXMEAC */
 }
 
 static u32 psb_accel_2d_copy_direction(int xdir, int ydir)
@@ -331,10 +333,15 @@ static void psbfb_copyarea_accel(struct fb_info *info,
 		return;
 	}
 
+	if (!gma_power_begin(dev, false)) {
+		cfb_copyarea(info, a);
+		return;
+	}
 	psb_accel_2d_copy(dev_priv,
 			  offset, stride, src_format,
 			  offset, stride, dst_format,
 			  a->sx, a->sy, a->dx, a->dy, a->width, a->height);
+	gma_power_end(dev);
 }
 
 void psbfb_copyarea(struct fb_info *info,
@@ -343,12 +350,12 @@ void psbfb_copyarea(struct fb_info *info,
 	if (unlikely(info->state != FBINFO_STATE_RUNNING))
 		return;
 
-	if (info->flags & FBINFO_HWACCEL_DISABLED)
+        /* Avoid the 8 pixel erratum */
+	if (region->width == 8 || region->height == 8 ||
+	        (info->flags & FBINFO_HWACCEL_DISABLED))
 		return cfb_copyarea(info, region);
 
-	/* psb_check_power_state(dev, PSB_DEVICE_SGX); */
 	psbfb_copyarea_accel(info, region);
-	/* Need to power back off here for MRST FIXMEAC */
 }
 
 void psbfb_imageblit(struct fb_info *info, const struct fb_image *image)
author
#7 lore raw

PATCH 7/49 gma500: nuke the last bits of TTM code

In reply to Alan Cox

From: Alan Cox <[email protected]>

We don't seem to need this for our task.

---

 drivers/staging/gma500/psb_drv.c |    6 ----
 drivers/staging/gma500/psb_gtt.c |   62 ++++++++++++--------------------------
 2 files changed, 19 insertions(+), 49 deletions(-)
drivers/staging/gma500/psb_drv.c +0 -6
index 9bd0a5d..ab1da30 100644
@@ -409,8 +409,6 @@ static int psb_do_init(struct drm_device *dev)
 	struct psb_gtt *pg = dev_priv->pg;
 
 	uint32_t stolen_gtt;
-	uint32_t tt_start;
-	uint32_t tt_pages;
 
 	int ret = -ENOMEM;
 
@@ -449,10 +447,6 @@ static int psb_do_init(struct drm_device *dev)
 
 	spin_lock_init(&dev_priv->irqmask_lock);
 
-	tt_pages = (pg->gatt_pages < PSB_TT_PRIV0_PLIMIT) ?
-	    pg->gatt_pages : PSB_TT_PRIV0_PLIMIT;
-	tt_start = dev_priv->gatt_free_offset - pg->mmu_gatt_start;
-	tt_pages -= tt_start >> PAGE_SHIFT;
 	/* FIXME: can we kill ta_mem_size ? */
 	dev_priv->sizes.ta_mem_size = 0;
 
drivers/staging/gma500/psb_gtt.c +19 -43

148 lines not on this page · raw message

author
#8 lore raw

PATCH 8/49 gma500: nuke the PSB debug stuff

In reply to Alan Cox

From: Alan Cox <[email protected]>

Lose all the PSB debug gunge. We can replace it with dev_dbg() like normal drivers if and when we need debug on stuff.

---

 drivers/staging/gma500/mrst_crtc.c          |   23 ++----
 drivers/staging/gma500/mrst_lvds.c          |   12 +--
 drivers/staging/gma500/psb_bl.c             |    8 --
 drivers/staging/gma500/psb_drv.c            |   33 +++------
 drivers/staging/gma500/psb_drv.h            |   96 +++-----------------------
 drivers/staging/gma500/psb_fb.c             |   34 +--------
 drivers/staging/gma500/psb_gem.c            |    6 +-
 drivers/staging/gma500/psb_gtt.c            |    6 +-
 drivers/staging/gma500/psb_intel_bios.c     |   17 +----
 drivers/staging/gma500/psb_intel_display.c  |   99 +++------------------------
 drivers/staging/gma500/psb_intel_lvds.c     |   53 ++------------
 drivers/staging/gma500/psb_intel_opregion.c |    7 --
 drivers/staging/gma500/psb_intel_sdvo.c     |   34 ++++-----
 drivers/staging/gma500/psb_irq.c            |   33 ++-------
 14 files changed, 87 insertions(+), 374 deletions(-)
drivers/staging/gma500/mrst_crtc.c +7 -16
index fd97c80..fb9f2a2 100644
@@ -103,7 +103,7 @@ static const struct mrst_limit_t *mrst_limit(struct drm_crtc *crtc)
 		}
 	} else {
 		limit = NULL;
-		PSB_DEBUG_ENTRY("mrst_limit Wrong display type.\n");
+		dev_err(dev->dev, "mrst_limit Wrong display type.\n");
 	}
 
 	return limit;
@@ -117,7 +117,7 @@ static void mrst_clock(int refclk, struct mrst_clock_t *clock)
 
 void mrstPrintPll(char *prefix, struct mrst_clock_t *clock)
 {
-	PSB_DEBUG_ENTRY("%s: dotclock = %d,  m = %d, p1 = %d.\n",
+	pr_debug("%s: dotclock = %d,  m = %d, p1 = %d.\n",
 	     prefix, clock->dot, clock->m, clock->p1);
 }
 
@@ -149,8 +149,7 @@ mrstFindBestPLL(struct drm_crtc *crtc, int target, int refclk,
 			}
 		}
 	}
-	DRM_DEBUG("mrstFindBestPLL err = %d.\n", err);
-
+	dev_dbg(crtc->dev->dev, "mrstFindBestPLL err = %d.\n", err);
 	return err != target;
 }
 
@@ -172,8 +171,6 @@ static void mrst_crtc_dpms(struct drm_crtc *crtc, int mode)
 	u32 temp;
 	bool enabled;
 
-	PSB_DEBUG_ENTRY("mode = %d, pipe = %d\n", mode, pipe);
-
 	if (!gma_power_begin(dev, true))
 		return;
 
@@ -320,8 +317,6 @@ static int mrst_crtc_mode_set(struct drm_crtc *crtc,
 	uint64_t scalingType = DRM_MODE_SCALE_FULLSCREEN;
 	struct drm_encoder *encoder;
 
-	PSB_DEBUG_ENTRY("pipe = 0x%x\n", pipe);
-
 	if (!gma_power_begin(dev, true))
 		return 0;
 
@@ -446,10 +441,9 @@ static int mrst_crtc_mode_set(struct drm_crtc *crtc,
 	ok = mrstFindBestPLL(crtc, adjusted_mode->clock, refclk, &clock);
 
 	if (!ok) {
-		PSB_DEBUG_ENTRY(
-			"mrstFindBestPLL fail in mrst_crtc_mode_set.\n");
+		dev_dbg(dev->dev, "mrstFindBestPLL fail in mrst_crtc_mode_set.\n");
 	} else {
-		PSB_DEBUG_ENTRY("mrst_crtc_mode_set pixel clock = %d,"
+		dev_dbg(dev->dev, "mrst_crtc_mode_set pixel clock = %d,"
 			 "m = %x, p1 = %x.\n", clock.dot, clock.m,
 			 clock.p1);
 	}
@@ -540,11 +534,9 @@ int mrst_pipe_set_base(struct drm_crtc *crtc,
 	u32 dspcntr;
 	int ret = 0;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	/* no fb bound */
 	if (!crtc->fb) {
-		DRM_DEBUG("No FB bound\n");
+		dev_dbg(dev->dev, "No FB bound\n");
 		return 0;
 	}
 
@@ -574,13 +566,12 @@ int mrst_pipe_set_base(struct drm_crtc *crtc,
 		dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
 		break;
 	default:
-		DRM_ERROR("Unknown color depth\n");
+		dev_err(dev->dev, "Unknown color depth\n");
 		ret = -EINVAL;
 		goto pipe_set_base_exit;
 	}
 	REG_WRITE(dspcntr_reg, dspcntr);
 
-	DRM_DEBUG("Writing base %08lX %08lX %d %d\n", start, offset, x, y);
 	if (0 /* FIXMEAC - check what PSB needs */) {
 		REG_WRITE(dspbase, offset);
 		REG_READ(dspbase);
drivers/staging/gma500/mrst_lvds.c +2 -10
index 22ea00e..aac80cc 100644
@@ -47,7 +47,6 @@ static void mrst_lvds_set_power(struct drm_device *dev,
 {
 	u32 pp_status;
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	PSB_DEBUG_ENTRY("\n");
 
 	if (!gma_power_begin(dev, true))
 		return;
@@ -77,8 +76,6 @@ static void mrst_lvds_dpms(struct drm_encoder *encoder, int mode)
 	struct drm_device *dev = encoder->dev;
 	struct psb_intel_output *output = enc_to_psb_intel_output(encoder);
 
-	PSB_DEBUG_ENTRY("\n");
-
 	if (mode == DRM_MODE_DPMS_ON)
 		mrst_lvds_set_power(dev, output, true);
 	else
@@ -97,8 +94,6 @@ static void mrst_lvds_mode_set(struct drm_encoder *encoder,
 	u32 lvds_port;
 	uint64_t v = DRM_MODE_SCALE_FULLSCREEN;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	if (!gma_power_begin(dev, true))
 		return;
 
@@ -252,8 +247,6 @@ void mrst_lvds_init(struct drm_device *dev,
 	struct i2c_adapter *i2c_adap;
 	struct drm_display_mode *scan;	/* *modes, *bios_mode; */
 
-	PSB_DEBUG_ENTRY("\n");
-
 	psb_intel_output = kzalloc(sizeof(struct psb_intel_output), GFP_KERNEL);
 	if (!psb_intel_output)
 		return;
@@ -348,8 +341,7 @@ void mrst_lvds_init(struct drm_device *dev,
 
 	/* If we still don't have a mode after all that, give up. */
 	if (!mode_dev->panel_fixed_mode) {
-		DRM_DEBUG
-		    ("Found no modes on the lvds, ignoring the LVDS\n");
+		dev_err(dev->dev, "Found no modes on the lvds, ignoring the LVDS\n");
 		goto failed_find;
 	}
 
@@ -358,7 +350,7 @@ out:
 	return;
 
 failed_find:
-	DRM_DEBUG("No LVDS modes found, disabling.\n");
+	dev_dbg(dev->dev, "No LVDS modes found, disabling.\n");
 	if (psb_intel_output->ddc_bus)
 		psb_intel_i2c_destroy(psb_intel_output->ddc_bus);
 
drivers/staging/gma500/psb_bl.c +1 -7
index 2f9674d..4a00047 100644
@@ -56,8 +56,6 @@ int psb_set_brightness(struct backlight_device *bd)
 	struct drm_device *dev = bl_get_data(psb_backlight_device);
 	int level = bd->props.brightness;
 
-	DRM_DEBUG_DRIVER("backlight level set to %d\n", level);
-
 	/* Percentage 1-100% being valid */
 	if (level < 1)
 		level = 1;
@@ -75,8 +73,6 @@ int mrst_set_brightness(struct backlight_device *bd)
 	u32 blc_pwm_ctl;
 	u32 max_pwm_blc;
 
-	DRM_DEBUG_DRIVER("backlight level set to %d\n", level);
-
 	/* Percentage 1-100% being valid */
 	if (level < 1)
 		level = 1;
@@ -111,8 +107,6 @@ int mrst_set_brightness(struct backlight_device *bd)
 
 int psb_get_brightness(struct backlight_device *bd)
 {
-	DRM_DEBUG_DRIVER("brightness = 0x%x\n", psb_brightness);
-
 	/* return locally cached var instead of HW read (due to DPST etc.) */
 	/* FIXME: ideally return actual value in case firmware fiddled with
 	   it */
@@ -144,7 +138,7 @@ static int device_backlight_init(struct drm_device *dev)
 	} else {
 		/* get bl_max_freq and pol from dev_priv*/
 		if (!dev_priv->lvds_bl) {
-			DRM_ERROR("Has no valid LVDS backlight info\n");
+			dev_err(dev->dev, "Has no valid LVDS backlight info\n");
 			return 1;
 		}
 		bl_max_freq = dev_priv->lvds_bl->freq;
drivers/staging/gma500/psb_drv.c +11 -22
index ab1da30..6ea06dd 100644
@@ -35,17 +35,14 @@
 #include <linux/pm_runtime.h>
 #include <acpi/video.h>
 
-int drm_psb_debug;
 static int drm_psb_trap_pagefaults;
 
 int drm_psb_no_fb;
 
 static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
 
-MODULE_PARM_DESC(debug, "Enable debug output");
 MODULE_PARM_DESC(no_fb, "Disable FBdev");
 MODULE_PARM_DESC(trap_pagefaults, "Error and reset on MMU pagefaults");
-module_param_named(debug, drm_psb_debug, int, 0600);
 module_param_named(no_fb, drm_psb_no_fb, int, 0600);
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
 
@@ -215,7 +212,8 @@ void mrst_get_fuse_settings(struct drm_device *dev)
 		dev_priv->core_freq = 166;
 		break;
 	default:
-		DRM_ERROR("Invalid SKU values, SKU value = 0x%08x\n", fuse_value_tmp);
+		dev_warn(dev->dev, "Invalid SKU values, SKU value = 0x%08x\n",
+								fuse_value_tmp);
 		dev_priv->core_freq = 0;
 	}
 	DRM_INFO("LNC core clk is %dMHz.\n", dev_priv->core_freq);
@@ -231,7 +229,8 @@ void mid_get_pci_revID (struct drm_psb_private *dev_priv)
 	pci_read_config_dword(pci_gfx_root, 0x08, &platform_rev_id);
 	dev_priv->platform_rev_id = (uint8_t) platform_rev_id;
 	pci_dev_put(pci_gfx_root);
-	PSB_DEBUG_ENTRY("platform_rev_id is %x\n",	dev_priv->platform_rev_id);
+	dev_info(dev_priv->dev->dev, "platform_rev_id is %x\n",
+							dev_priv->platform_rev_id);
 }
 
 void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
@@ -413,7 +412,7 @@ static int psb_do_init(struct drm_device *dev)
 	int ret = -ENOMEM;
 
 	if (pg->mmu_gatt_start & 0x0FFFFFFF) {
-		DRM_ERROR("Gatt must be 256M aligned. This is a bug.\n");
+		dev_err(dev->dev, "Gatt must be 256M aligned. This is a bug.\n");
 		ret = -EINVAL;
 		goto out_err;
 	}
@@ -447,9 +446,6 @@ static int psb_do_init(struct drm_device *dev)
 
 	spin_lock_init(&dev_priv->irqmask_lock);
 
-	/* FIXME: can we kill ta_mem_size ? */
-	dev_priv->sizes.ta_mem_size = 0;
-
 	PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0);
 	PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK1);
 	PSB_RSGX32(PSB_CR_BIF_BANK1);
@@ -553,7 +549,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 	dev->dev_private = (void *) dev_priv;
 	dev_priv->chipset = chipset;
 
-	PSB_DEBUG_INIT("Mapping MMIO\n");
 	resource_start = pci_resource_start(dev->pdev, PSB_MMIO_RESOURCE);
 
 	dev_priv->vdc_reg =
@@ -679,7 +674,6 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 	pm_runtime_set_active(&dev->pdev->dev);
 #endif
 	/*Intel drm driver load is done, continue doing pvr load*/
-	DRM_DEBUG("Pvr driver load\n");
 	return 0;
 out_err:
 	psb_driver_unload(dev);
@@ -721,7 +715,7 @@ static int psb_dc_state_ioctl(struct drm_device *dev, void * data,
 		obj = drm_mode_object_find(dev, obj_id,
 				DRM_MODE_OBJECT_CRTC);
 		if (!obj) {
-			DRM_DEBUG("Invalid CRTC object.\n");
+			dev_dbg(dev->dev, "Invalid CRTC object.\n");
 			return -EINVAL;
 		}
 
@@ -741,7 +735,7 @@ static int psb_dc_state_ioctl(struct drm_device *dev, void * data,
 		obj = drm_mode_object_find(dev, obj_id,
 				DRM_MODE_OBJECT_CONNECTOR);
 		if (!obj) {
-			DRM_DEBUG("Invalid connector id.\n");
+			dev_dbg(dev->dev, "Invalid connector id.\n");
 			return -EINVAL;
 		}
 
@@ -753,8 +747,6 @@ static int psb_dc_state_ioctl(struct drm_device *dev, void * data,
 
 		return 0;
 	}
-
-	DRM_DEBUG("Bad flags 0x%x\n", flags);
 	return -EINVAL;
 }
 
@@ -832,7 +824,7 @@ static int psb_gamma_ioctl(struct drm_device *dev, void *data,
 	obj_id = lut_arg->output_id;
 	obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_CONNECTOR);
 	if (!obj) {
-		DRM_DEBUG("Invalid Connector object.\n");
+		dev_dbg(dev->dev, "Invalid Connector object.\n");
 		return -EINVAL;
 	}
 
@@ -873,7 +865,7 @@ static int psb_mode_operation_ioctl(struct drm_device *dev, void *data,
 	case PSB_MODE_OPERATION_SET_DC_BASE:
 		obj = drm_mode_object_find(dev, obj_id, DRM_MODE_OBJECT_FB);
 		if (!obj) {
-			DRM_ERROR("Invalid FB id %d\n", obj_id);
+			dev_dbg(dev->dev, "Invalid FB id %d\n", obj_id);
 			return -EINVAL;
 		}
 
@@ -945,7 +937,7 @@ mode_op_out:
 		return ret;
 
 	default:
-		DRM_DEBUG("Unsupported psb mode operation");
+		dev_dbg(dev->dev, "Unsupported psb mode operation\n");
 		return -EOPNOTSUPP;
 	}
 
@@ -1336,9 +1328,6 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
 	struct drm_device *dev = file_priv->minor->dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	static unsigned int runtime_allowed;
-	unsigned int nr = DRM_IOCTL_NR(cmd);
-
-	DRM_DEBUG("cmd = %x, nr = %x\n", cmd, nr);
 
 	if (runtime_allowed == 1 && dev_priv->is_lvds_on) {
 		runtime_allowed++;
@@ -1439,7 +1428,7 @@ static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	/* MLD Added this from Inaky's patch */
 	if (pci_enable_msi(pdev))
-		DRM_ERROR("Enable MSI failed!\n");
+                dev_warn(&pdev->dev, "Enable MSI failed!\n");
 	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
drivers/staging/gma500/psb_drv.h +10 -86

145 lines not on this page · raw message

drivers/staging/gma500/psb_fb.c +4 -30
index 0a77abf..988f4db 100644
@@ -100,7 +100,6 @@ static int psbfb_kms_off(struct drm_device *dev, int suspend)
 {
 	struct drm_framebuffer *fb = 0;
 	struct psb_framebuffer *psbfb = to_psb_fb(fb);
-	DRM_DEBUG("psbfb_kms_off_ioctl\n");
 
 	mutex_lock(&dev->mode_config.mutex);
 	list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
@@ -134,8 +133,6 @@ static int psbfb_kms_on(struct drm_device *dev, int resume)
 	struct drm_framebuffer *fb = 0;
 	struct psb_framebuffer *psbfb = to_psb_fb(fb);
 
-	DRM_DEBUG("psbfb_kms_on_ioctl\n");
-
 	mutex_lock(&dev->mode_config.mutex);
 	list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
 		struct fb_info *info = psbfb->fbdev;
@@ -217,12 +214,10 @@ static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 
 static void psbfb_vm_open(struct vm_area_struct *vma)
 {
-	DRM_DEBUG("vm_open\n");
 }
 
 static void psbfb_vm_close(struct vm_area_struct *vma)
 {
-	DRM_DEBUG("vm_close\n");
 }
 
 static struct vm_operations_struct psbfb_vm_ops = {
@@ -237,7 +232,6 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
 	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	char *fb_screen_base = NULL;
 	struct drm_device *dev = psbfb->base.dev;
-	struct drm_psb_private *dev_priv = dev->dev_private;
 
 	if (vma->vm_pgoff != 0)
 		return -EINVAL;
@@ -249,10 +243,6 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
 
 	fb_screen_base = (char *)info->screen_base;
 
-	DRM_DEBUG("vm_pgoff 0x%lx, screen base %p vram_addr %p\n",
-				vma->vm_pgoff, fb_screen_base,
-                                dev_priv->vram_addr);
-
         /* If this is a GEM object then info->screen_base is the virtual
            kernel remapping of the object. FIXME: Review if this is
            suitable for our mmap work */
@@ -523,14 +513,10 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 	info->pixmap.flags = FB_PIXMAP_SYSTEM;
 	info->pixmap.scan_align = 1;
 
-	DRM_DEBUG("fb depth is %d\n", fb->depth);
-	DRM_DEBUG("   pitch is %d\n", fb->pitch);
-
-	printk(KERN_INFO"allocated %dx%d fb\n",
-				psbfb->base.width, psbfb->base.height);
+	dev_info(dev->dev, "allocated %dx%d fb\n",
+					psbfb->base.width, psbfb->base.height);
 
 	mutex_unlock(&dev->struct_mutex);
-
 	return 0;
 out_unref:
         if (backing->stolen)
@@ -575,13 +561,11 @@ static struct drm_framebuffer *psb_user_framebuffer_create
 static void psbfb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green,
 							u16 blue, int regno)
 {
-	DRM_DEBUG("%s\n", __func__);
 }
 
 static void psbfb_gamma_get(struct drm_crtc *crtc, u16 *red,
 					u16 *green, u16 *blue, int regno)
 {
-	DRM_DEBUG("%s\n", __func__);
 }
 
 static int psbfb_probe(struct drm_fb_helper *helper,
@@ -591,8 +575,6 @@ static int psbfb_probe(struct drm_fb_helper *helper,
 	int new_fb = 0;
 	int ret;
 
-	DRM_DEBUG("%s\n", __func__);
-
 	if (!helper->fb) {
 		ret = psbfb_create(psb_fbdev, sizes);
 		if (ret)
@@ -650,7 +632,7 @@ int psb_fbdev_init(struct drm_device *dev)
 
 	fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
 	if (!fbdev) {
-		DRM_ERROR("no memory\n");
+		dev_err(dev->dev, "no memory\n");
 		return -ENOMEM;
 	}
 
@@ -781,8 +763,6 @@ static void psb_setup_outputs(struct drm_device *dev)
 	    (struct drm_psb_private *) dev->dev_private;
 	struct drm_connector *connector;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	drm_mode_create_scaling_mode_property(dev);
 
 	psb_create_backlight_property(dev);
@@ -791,7 +771,7 @@ static void psb_setup_outputs(struct drm_device *dev)
 		if (dev_priv->iLVDS_enable)
 			mrst_lvds_init(dev, &dev_priv->mode_dev);
 		else
-			DRM_ERROR("DSI is not supported\n");
+			dev_err(dev->dev, "DSI is not supported\n");
 	} else {
 		psb_intel_lvds_init(dev, &dev_priv->mode_dev);
 		psb_intel_sdvo_init(dev, SDVOB);
@@ -811,7 +791,6 @@ static void psb_setup_outputs(struct drm_device *dev)
 			clone_mask = (1 << INTEL_OUTPUT_SDVO);
 			break;
 		case INTEL_OUTPUT_LVDS:
-			PSB_DEBUG_ENTRY("LVDS.\n");
 			if (IS_MRST(dev))
 				crtc_mask = (1 << 0);
 			else
@@ -819,17 +798,14 @@ static void psb_setup_outputs(struct drm_device *dev)
 			clone_mask = (1 << INTEL_OUTPUT_LVDS);
 			break;
 		case INTEL_OUTPUT_MIPI:
-			PSB_DEBUG_ENTRY("MIPI.\n");
 			crtc_mask = (1 << 0);
 			clone_mask = (1 << INTEL_OUTPUT_MIPI);
 			break;
 		case INTEL_OUTPUT_MIPI2:
-			PSB_DEBUG_ENTRY("MIPI2.\n");
 			crtc_mask = (1 << 2);
 			clone_mask = (1 << INTEL_OUTPUT_MIPI2);
 			break;
 		case INTEL_OUTPUT_HDMI:
-			PSB_DEBUG_ENTRY("HDMI.\n");
 			crtc_mask = (1 << 1);
 			clone_mask = (1 << INTEL_OUTPUT_HDMI);
 			break;
@@ -849,8 +825,6 @@ void psb_modeset_init(struct drm_device *dev)
 	struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
 	int i;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	drm_mode_config_init(dev);
 
 	dev->mode_config.min_width = 0;
drivers/staging/gma500/psb_gem.c +3 -3
index 125ea6b..7f6f479 100644
@@ -87,7 +87,7 @@ static int psb_gem_create_mmap_offset(struct drm_gem_object *obj)
 	list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
 					obj->size / PAGE_SIZE, 0, 0);
 	if (!list->file_offset_node) {
-		DRM_ERROR("failed to allocate offset for bo %d\n", obj->name);
+		dev_err(dev->dev, "failed to allocate offset for bo %d\n", obj->name);
 		ret = -ENOSPC;
 		goto free_it;
 	}
@@ -100,7 +100,7 @@ static int psb_gem_create_mmap_offset(struct drm_gem_object *obj)
 	list->hash.key = list->file_offset_node->start;
 	ret = drm_ht_insert_item(&mm->offset_hash, &list->hash);
 	if (ret) {
-		DRM_ERROR("failed to add to map hash\n");
+		dev_err(dev->dev, "failed to add to map hash\n");
 		goto free_mm;
 	}
 	return 0;
@@ -283,7 +283,7 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (r->mmapping == 0) {
 		ret = psb_gtt_pin(r);
 		if (ret < 0) {
-		        DRM_ERROR("gma500: pin failed: %d\n", ret);
+		        dev_err(dev->dev, "gma500: pin failed: %d\n", ret);
 		        goto fail;
                 }
 		r->mmapping = 1;
drivers/staging/gma500/psb_gtt.c +3 -3
index 8fcb833..54a9308 100644
@@ -456,7 +456,7 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 
 	if (resume && (gtt_pages != pg->gtt_pages) &&
 	    (stolen_size != pg->stolen_size)) {
-		DRM_ERROR("GTT resume error.\n");
+		dev_err(dev->dev, "GTT resume error.\n");
 		ret = -EINVAL;
 		goto out_err;
 	}
@@ -470,14 +470,14 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	 */
 	dev_priv->gtt_map = ioremap_nocache(pg->gtt_phys_start, gtt_pages << PAGE_SHIFT);
 	if (!dev_priv->gtt_map) {
-		DRM_ERROR("Failure to map gtt.\n");
+		dev_err(dev->dev, "Failure to map gtt.\n");
 		ret = -ENOMEM;
 		goto out_err;
 	}
 
 	dev_priv->vram_addr = ioremap_wc(dev_priv->stolen_base, stolen_size);
 	if (!dev_priv->vram_addr) {
-		DRM_ERROR("Failure to map stolen base.\n");
+		dev_err(dev->dev, "Failure to map stolen base.\n");
 		ret = -ENOMEM;
 		goto out_err;
 	}
drivers/staging/gma500/psb_intel_bios.c +5 -12
index 417965d..5b3e88c 100644
@@ -96,25 +96,20 @@ static void parse_backlight_data(struct drm_psb_private *dev_priv,
 
 	dev_priv->lvds_bl = NULL;
 
-	if (lvds_opts) {
-		DRM_DEBUG("lvds_options found at %p\n", lvds_opts);
+	if (lvds_opts)
 		p_type = lvds_opts->panel_type;
-	} else {
-		DRM_DEBUG("no lvds_options\n");
+	else
 		return;
-	}
 
 	bl_start = find_section(bdb, BDB_LVDS_BACKLIGHT);
 	vbt_lvds_bl = (struct bdb_lvds_backlight *)(bl_start + 1) + p_type;
 
 	lvds_bl = kzalloc(sizeof(*vbt_lvds_bl), GFP_KERNEL);
 	if (!lvds_bl) {
-		DRM_DEBUG("No memory\n");
+		dev_err(dev_priv->dev->dev, "out of memory for backlight data\n");
 		return;
 	}
-
 	memcpy(lvds_bl, vbt_lvds_bl, sizeof(*vbt_lvds_bl));
-
 	dev_priv->lvds_bl = lvds_bl;
 }
 
@@ -156,14 +151,12 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
 
 	if (panel_fixed_mode->htotal > 0 && panel_fixed_mode->vtotal > 0) {
 		dev_priv->lfp_lvds_vbt_mode = panel_fixed_mode;
-		DRM_DEBUG("Found panel mode in BIOS VBT tables:\n");
 		drm_mode_debug_printmodeline(panel_fixed_mode);
 	} else {
-		DRM_DEBUG("Ignoring bogus LVDS VBT mode.\n");
+		dev_dbg(dev_priv->dev->dev, "ignoring invalid LVDS VBT\n");
 		dev_priv->lvds_vbt = 0;
 		kfree(panel_fixed_mode);
 	}
-
 	return;
 }
 
@@ -257,7 +250,7 @@ bool psb_intel_init_bios(struct drm_device *dev)
 	}
 
 	if (!vbt) {
-		DRM_ERROR("VBT signature missing\n");
+		dev_err(dev->dev, "VBT signature missing\n");
 		pci_unmap_rom(pdev, bios);
 		return -1;
 	}
drivers/staging/gma500/psb_intel_display.c +12 -87

217 lines not on this page · raw message

drivers/staging/gma500/psb_intel_lvds.c +8 -45

149 lines not on this page · raw message

drivers/staging/gma500/psb_intel_opregion.c +1 -6
index 65e3e9b..51cf1d6 100644
@@ -58,11 +58,8 @@ int psb_intel_opregion_init(struct drm_device *dev)
 	dev_priv->lid_state = NULL;
 
 	pci_read_config_dword(dev->pdev, 0xfc, &opregion_phy);
-	if (opregion_phy == 0) {
-		DRM_DEBUG("Opregion not supported, won't support lid-switch\n");
+	if (opregion_phy == 0)
 		return -ENOTSUPP;
-	}
-	DRM_DEBUG("OpRegion detected at 0x%8x\n", opregion_phy);
 
 	base = ioremap(opregion_phy, 8*1024);
 	if (!base)
@@ -70,8 +67,6 @@ int psb_intel_opregion_init(struct drm_device *dev)
 
 	lid_state = base + 0x01ac;
 
-	DRM_DEBUG("Lid switch state 0x%08x\n", *lid_state);
-
 	dev_priv->lid_state = lid_state;
 	dev_priv->lid_last_state = *lid_state;
 	return 0;
drivers/staging/gma500/psb_intel_sdvo.c +14 -20
index df1c006..e313ce2 100644
@@ -107,14 +107,10 @@ static bool psb_intel_sdvo_read_byte(
 
 	ret = i2c_transfer(&sdvo_priv->i2c_bus->adapter, msgs, 2);
 	if (ret == 2) {
-		/* DRM_DEBUG("got back from addr %02X = %02x\n",
-		 * out_buf[0], buf[0]);
-		 */
 		*ch = buf[0];
 		return true;
 	}
 
-	DRM_DEBUG("i2c transfer returned %d\n", ret);
 	return false;
 }
 
@@ -205,24 +201,24 @@ static void psb_intel_sdvo_write_cmd(struct psb_intel_output *psb_intel_output,
 	int i;
 
 	if (0) {
-		DRM_DEBUG("%s: W: %02X ", SDVO_NAME(sdvo_priv), cmd);
+		printk(KERN_DEBUG "%s: W: %02X ", SDVO_NAME(sdvo_priv), cmd);
 		for (i = 0; i < args_len; i++)
-			printk(KERN_INFO"%02X ", ((u8 *) args)[i]);
+			printk(KERN_CONT "%02X ", ((u8 *) args)[i]);
 		for (; i < 8; i++)
-			printk("   ");
+			printk(KERN_CONT "   ");
 		for (i = 0;
 		     i <
 		     sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]);
 		     i++) {
 			if (cmd == sdvo_cmd_names[i].cmd) {
-				printk("(%s)", sdvo_cmd_names[i].name);
+				printk(KERN_CONT "(%s)", sdvo_cmd_names[i].name);
 				break;
 			}
 		}
 		if (i ==
 		    sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]))
-			printk("(%02X)", cmd);
-		printk("\n");
+			printk(KERN_CONT "(%02X)", cmd);
+		printk(KERN_CONT "\n");
 	}
 
 	for (i = 0; i < args_len; i++) {
@@ -267,17 +263,17 @@ static u8 psb_intel_sdvo_read_response(
 					 &status);
 
 		if (0) {
-			DRM_DEBUG("%s: R: ", SDVO_NAME(sdvo_priv));
+			pr_debug("%s: R: ", SDVO_NAME(sdvo_priv));
 			for (i = 0; i < response_len; i++)
-				printk(KERN_INFO"%02X ", ((u8 *) response)[i]);
+				printk(KERN_CONT "%02X ", ((u8 *) response)[i]);
 			for (; i < 8; i++)
 				printk("   ");
 			if (status <= SDVO_CMD_STATUS_SCALING_NOT_SUPP)
-				printk(KERN_INFO"(%s)",
+				printk(KERN_CONT "(%s)",
 					 cmd_status_names[status]);
 			else
-				printk(KERN_INFO"(??? %d)", status);
-			printk("\n");
+				printk(KERN_CONT "(??? %d)", status);
+			printk(KERN_CONT "\n");
 		}
 
 		if (status != SDVO_CMD_STATUS_PENDING)
@@ -997,7 +993,6 @@ int psb_intel_sdvo_supports_hotplug(struct drm_connector *connector)
 	u8 response[2];
 	u8 status;
 	struct psb_intel_output *psb_intel_output;
-	DRM_DEBUG("\n");
 
 	if (!connector)
 		return 0;
@@ -1198,7 +1193,7 @@ void psb_intel_sdvo_init(struct drm_device *dev, int output_device)
 	/* Read the regs to test if we can talk to the device */
 	for (i = 0; i < 0x40; i++) {
 		if (!psb_intel_sdvo_read_byte(psb_intel_output, i, &ch[i])) {
-			DRM_DEBUG("No SDVO device found on SDVO%c\n",
+			dev_dbg(dev->dev, "No SDVO device found on SDVO%c\n",
 				  output_device == SDVOB ? 'B' : 'C');
 			goto err_i2c;
 		}
@@ -1242,8 +1237,7 @@ void psb_intel_sdvo_init(struct drm_device *dev, int output_device)
 		unsigned char bytes[2];
 
 		memcpy(bytes, &sdvo_priv->caps.output_flags, 2);
-		DRM_DEBUG
-		    ("%s: No active RGB or TMDS outputs (0x%02x%02x)\n",
+		dev_dbg(dev->dev, "%s: No active RGB or TMDS outputs (0x%02x%02x)\n",
 		     SDVO_NAME(sdvo_priv), bytes[0], bytes[1]);
 		goto err_i2c;
 	}
@@ -1267,7 +1261,7 @@ void psb_intel_sdvo_init(struct drm_device *dev, int output_device)
 					       pixel_clock_max);
 
 
-	DRM_DEBUG("%s device VID/DID: %02X:%02X.%02X, "
+	dev_dbg(dev->dev, "%s device VID/DID: %02X:%02X.%02X, "
 		  "clock range %dMHz - %dMHz, "
 		  "input 1: %c, input 2: %c, "
 		  "output 1: %c, output 2: %c\n",
drivers/staging/gma500/psb_irq.c +6 -27
index 9ea37e5..1cbfeb6 100644
@@ -187,7 +187,8 @@ static void mid_pipe_event_handler(struct drm_device *dev, uint32_t pipe)
 	}
 
 	if (i == WAIT_STATUS_CLEAR_LOOP_COUNT)
-		DRM_ERROR("%s, can't clear the status bits in pipe_stat_reg, its value = 0x%x.\n",
+		dev_err(dev->dev,
+	"%s, can't clear the status bits in pipe_stat_reg, its value = 0x%x.\n",
 			__func__, PSB_RVDC32(pipe_stat_reg));
 
 	if (pipe_stat_val & PIPE_VBLANK_STATUS)
@@ -219,21 +220,11 @@ irqreturn_t psb_irq_handler(DRM_IRQ_ARGS)
 
 	vdc_stat = PSB_RVDC32(PSB_INT_IDENTITY_R);
 
-	if (vdc_stat & _MDFLD_DISP_ALL_IRQ_FLAG) {
-		PSB_DEBUG_IRQ("Got DISP interrupt\n");
+	if (vdc_stat & _MDFLD_DISP_ALL_IRQ_FLAG)
 		dsp_int = 1;
-	}
 
-	if (vdc_stat & _PSB_IRQ_SGX_FLAG) {
-		PSB_DEBUG_IRQ("Got SGX interrupt\n");
+	if (vdc_stat & _PSB_IRQ_SGX_FLAG)
 		sgx_int = 1;
-	}
-	if (vdc_stat & _PSB_IRQ_MSVDX_FLAG)
-		PSB_DEBUG_IRQ("Got MSVDX interrupt\n");
-
-	if (vdc_stat & _LNC_IRQ_TOPAZ_FLAG)
-		PSB_DEBUG_IRQ("Got TOPAZ interrupt\n");
-
 
 	vdc_stat &= dev_priv->vdc_irq_mask;
 	spin_unlock(&dev_priv->irqmask_lock);
@@ -293,8 +284,6 @@ int psb_irq_postinstall(struct drm_device *dev)
 	    (struct drm_psb_private *) dev->dev_private;
 	unsigned long irqflags;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	/* This register is safe even if display island is off */
@@ -326,8 +315,6 @@ void psb_irq_uninstall(struct drm_device *dev)
 	    (struct drm_psb_private *) dev->dev_private;
 	unsigned long irqflags;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	PSB_WVDC32(0xFFFFFFFF, PSB_HWSTAM);
@@ -395,8 +382,6 @@ int psb_irq_enable_dpst(struct drm_device *dev)
 		(struct drm_psb_private *) dev->dev_private;
 	unsigned long irqflags;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	/* enable DPST */
@@ -435,8 +420,6 @@ int psb_irq_disable_dpst(struct drm_device *dev)
 	    (struct drm_psb_private *) dev->dev_private;
 	unsigned long irqflags;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	mid_disable_pipe_event(dev_priv, 0);
@@ -472,8 +455,6 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
 	uint32_t reg_val = 0;
 	uint32_t pipeconf_reg = mid_pipeconf(pipe);
 
-	PSB_DEBUG_ENTRY("\n");
-
 	if (gma_power_begin(dev, false)) {
 		reg_val = REG_READ(pipeconf_reg);
 		gma_power_end(dev);
@@ -500,8 +481,6 @@ void psb_disable_vblank(struct drm_device *dev, int pipe)
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
 
-	PSB_DEBUG_ENTRY("\n");
-
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	mid_disable_pipe_event(dev_priv, pipe);
@@ -535,7 +514,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
 		pipeconf_reg = PIPECCONF;
 		break;
 	default:
-		DRM_ERROR("%s, invalded pipe.\n", __func__);
+		dev_err(dev->dev, "%s, invalid pipe.\n", __func__);
 		return 0;
 	}
 
@@ -545,7 +524,7 @@ u32 psb_get_vblank_counter(struct drm_device *dev, int pipe)
 	reg_val = REG_READ(pipeconf_reg);
 
 	if (!(reg_val & PIPEACONF_ENABLE)) {
-		DRM_ERROR("trying to get vblank count for disabled pipe %d\n",
+		dev_err(dev->dev, "trying to get vblank count for disabled pipe %d\n",
 								pipe);
 		goto psb_get_vblank_counter_exit;
 	}
author
#9 lore raw

PATCH 9/49 gma500: Kill spare kref

In reply to Alan Cox

From: Alan Cox <[email protected]>

We are using the underlying kref in the GEM object so we don't need our own

---

 drivers/staging/gma500/psb_fb.c  |    1 -
 drivers/staging/gma500/psb_gtt.c |   41 ++++++--------------------------------
 drivers/staging/gma500/psb_gtt.h |    1 -
 3 files changed, 6 insertions(+), 37 deletions(-)
drivers/staging/gma500/psb_fb.c +0 -1
index 988f4db..fb75aba 100644
@@ -231,7 +231,6 @@ static int psbfb_mmap(struct fb_info *info, struct vm_area_struct *vma)
 	struct psb_fbdev *fbdev = info->par;
 	struct psb_framebuffer *psbfb = &fbdev->pfb;
 	char *fb_screen_base = NULL;
-	struct drm_device *dev = psbfb->base.dev;
 
 	if (vma->vm_pgoff != 0)
 		return -EINVAL;
drivers/staging/gma500/psb_gtt.c +6 -35

62 lines not on this page · raw message

drivers/staging/gma500/psb_gtt.h +0 -1
index 7e1f21e..4d6dc5f 100644
@@ -44,7 +44,6 @@ extern void psb_gtt_takedown(struct drm_device *dev);
 struct gtt_range {
 	struct resource resource;	/* Resource for our allocation */
 	u32 offset;			/* GTT offset of our object */
-	struct kref kref;		/* Can probably go FIXME - GEM kref will do */
 	struct drm_gem_object gem;	/* GEM high level stuff */
 	int in_gart;			/* Currently in the GART (ref ct) */
 	bool stolen;			/* Backed from stolen RAM */
author
#10 lore raw

PATCH 10/49 gma500: GEM glue

In reply to Alan Cox

From: Alan Cox <[email protected]>

Add this temporarily so we can keep making progress and also bundle all the GEM bits we need together in our staging driver while we get them into GEM itself.

---

 drivers/staging/gma500/Makefile   |    3 ++
 drivers/staging/gma500/gem_glue.c |   47 +++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/gem_glue.h |    4 +++
 3 files changed, 53 insertions(+), 1 deletions(-)
 create mode 100644 drivers/staging/gma500/gem_glue.c
 create mode 100644 drivers/staging/gma500/gem_glue.h
drivers/staging/gma500/Makefile +2 -1
index db73ec6..01aaa28 100644
@@ -3,7 +3,8 @@
 #
 ccflags-y += -Iinclude/drm
 
-psb_gfx-y += psb_bl.o \
+psb_gfx-y += gem_glue.o \
+	  psb_bl.o \
 	  psb_drv.o \
 	  psb_gem.o \
 	  psb_fb.o \
drivers/staging/gma500/gem_glue.c new file +47 -0

47 lines not on this page · raw message

drivers/staging/gma500/gem_glue.h new file +4 -0
new file mode 100644
index 0000000..c38285b
@@ -0,0 +1,4 @@
+extern void drm_gem_object_release_wrap(struct drm_gem_object *obj);
+extern int drm_gem_private_object_init(struct drm_device *dev,
+			struct drm_gem_object *obj, size_t size);
+
author
#11 lore raw

PATCH 11/49 gma500: Use the GEM tweaks to provide a GEM frame buffer

In reply to Alan Cox

From: Alan Cox <[email protected]>

We can now make our system frame buffer a GEM object.

---

 drivers/staging/gma500/psb_fb.c  |   11 +++++++----
 drivers/staging/gma500/psb_gem.c |   11 ++++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)
drivers/staging/gma500/psb_fb.c +7 -4
index fb75aba..400dbee 100644
@@ -186,6 +186,8 @@ static int psbfb_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	struct psb_framebuffer *psbfb = vma->vm_private_data;
 	struct drm_device *dev = psbfb->base.dev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
+
+	/* FIXME: assumes fb at stolen base which may not be true */
 	unsigned long phys_addr = (unsigned long)dev_priv->stolen_base;
 
 	page_num = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
@@ -381,8 +383,11 @@ static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
 	struct gtt_range *backing;
 	/* Begin by trying to use stolen memory backing */
 	backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
-	if (backing)
-		return backing;
+	if (backing) {
+	        if (drm_gem_private_object_init(dev, &backing->gem, aligned_size) == 0)
+        		return backing;
+                psb_gtt_free_range(dev, backing);
+        }
 	/* Next try using GEM host memory */
 	backing = psb_gtt_alloc_range(dev, aligned_size, "fb(gem)", 0);
 	if (backing == NULL)
@@ -683,8 +688,6 @@ static int psb_user_framebuffer_create_handle(struct drm_framebuffer *fb,
 {
         struct psb_framebuffer *psbfb = to_psb_fb(fb);
         struct gtt_range *r = psbfb->gtt;
-        if (r->stolen)
-                return -EOPNOTSUPP;
         return drm_gem_handle_create(file_priv, &r->gem, handle);
 }
 
drivers/staging/gma500/psb_gem.c +8 -3
index 7f6f479..4aec38c 100644
@@ -49,7 +49,7 @@ void psb_gem_free_object(struct drm_gem_object *obj)
 		kfree(list->map);
 		list->map = NULL;
 	}
-	drm_gem_object_release(obj);
+	drm_gem_object_release_wrap(obj);
 	/* This must occur last as it frees up the memory of the GEM object */
 	psb_gtt_free_range(obj->dev, gtt);
 }
@@ -268,9 +268,11 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	unsigned long pfn;
 	pgoff_t page_offset;
 	struct drm_device *dev;
+	struct drm_psb_private *dev_priv;
 
 	obj = vma->vm_private_data;	/* GEM object */
 	dev = obj->dev;
+	dev_priv = dev->dev_private;
 
 	r = container_of(obj, struct gtt_range, gem);	/* Get the gtt range */
 
@@ -294,8 +296,11 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	page_offset = ((unsigned long) vmf->virtual_address - vma->vm_start)
 				>> PAGE_SHIFT;
 
-        /* CPU view of the page, don't go via the GART for CPU writes */
-	pfn = page_to_phys(r->pages[page_offset]) >> PAGE_SHIFT;
+	/* CPU view of the page, don't go via the GART for CPU writes */
+	if (r->stolen)
+		pfn = (dev_priv->stolen_base + r->offset) >> PAGE_SHIFT;
+	else
+		pfn = page_to_pfn(r->pages[page_offset]);
 	ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
 
 fail:
author
#12 lore raw

PATCH 12/49 gma500: CodingStyle pass

In reply to Alan Cox

From: Alan Cox <[email protected]>

Start the style cleanup

---

 drivers/staging/gma500/mrst.h                |   38 -
 drivers/staging/gma500/mrst_lvds.c           |    8 
 drivers/staging/gma500/psb_2d.c              |   23 -
 drivers/staging/gma500/psb_drm.h             |    8 
 drivers/staging/gma500/psb_drv.c             |   25 -
 drivers/staging/gma500/psb_drv.h             |   63 +-
 drivers/staging/gma500/psb_fb.c              |  145 ++--
 drivers/staging/gma500/psb_gem.c             |   19 
 drivers/staging/gma500/psb_gtt.c             |   35 -
 drivers/staging/gma500/psb_intel_display.c   |   12 
 drivers/staging/gma500/psb_intel_opregion.c  |    8 
 drivers/staging/gma500/psb_intel_reg.h       | 1055 +++++++++++++-------------
 drivers/staging/gma500/psb_intel_sdvo.c      |    3 
 drivers/staging/gma500/psb_intel_sdvo_regs.h |   14 
 drivers/staging/gma500/psb_reg.h             |  840 ++++++++++-----------
 15 files changed, 1156 insertions(+), 1140 deletions(-)
drivers/staging/gma500/mrst.h +19 -19
index 5e4aaeb..7bacb9a 100644
@@ -25,7 +25,7 @@ struct mrst_vbt {
 	u8 size;
 	u8 checksum;
 	void *mrst_gct;
-} __attribute__ ((packed));
+} __packed;
 
 struct mrst_timing_info {
 	u16 pixel_clock;
@@ -58,7 +58,7 @@ struct mrst_timing_info {
 	u8 stereo:1;
 	u8 unknown6:1;
 	u8 interlaced:1;
-} __attribute__((packed));
+} __packed;
 
 struct gct_r10_timing_info {
 	u16 pixel_clock;
@@ -82,7 +82,7 @@ struct gct_r10_timing_info {
 	u16 vsync_pulse_width_hi:2;
 	u16 vsync_positive:1;
 	u16 rsvd_2:3;
-} __attribute__((packed));
+} __packed;
 
 struct mrst_panel_descriptor_v1 {
 	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
@@ -111,7 +111,7 @@ struct mrst_panel_descriptor_v1 {
 			/* Bit 6, Reserved, 2 bits, 00b */
 			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
 			/* Bit 14, Reserved, 2 bits, 00b */
-} __attribute__ ((packed));
+} __packed;
 
 struct mrst_panel_descriptor_v2 {
 	u32 Panel_Port_Control; /* 1 dword, Register 0x61180 if LVDS */
@@ -141,10 +141,10 @@ struct mrst_panel_descriptor_v2 {
 			/* Bit 6, Reserved, 2 bits, 00b */
 			/* Bit 8, Minimum Supported Frame Rate, 6 bits, 0 - 63Hz */
 			/* Bit 14, Reserved, 2 bits, 00b */
-} __attribute__ ((packed));
+} __packed;
 
 union mrst_panel_rx {
-	struct{
+	struct {
 		u16 NumberOfLanes:2; /*Num of Lanes, 2 bits,0 = 1 lane,*/
 			/* 1 = 2 lanes, 2 = 3 lanes, 3 = 4 lanes. */
 		u16 MaxLaneFreq:3; /* 0: 100MHz, 1: 200MHz, 2: 300MHz, */
@@ -159,10 +159,10 @@ union mrst_panel_rx {
 		u16 Rsvd:5;/*5 bits,00000b */
 	} panelrx;
 	u16 panel_receiver;
-} __attribute__ ((packed));
+} __packed;
 
 struct mrst_gct_v1 {
-	union{ /*8 bits,Defined as follows: */
+	union { /*8 bits,Defined as follows: */
 		struct {
 			u8 PanelType:4; /*4 bits, Bit field for panels*/
 					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
@@ -176,10 +176,10 @@ struct mrst_gct_v1 {
 	};
 	struct mrst_panel_descriptor_v1 panel[4];/*panel descrs,38 bytes each*/
 	union mrst_panel_rx panelrx[4]; /* panel receivers*/
-} __attribute__ ((packed));
+} __packed;
 
 struct mrst_gct_v2 {
-	union{ /*8 bits,Defined as follows: */
+	union { /*8 bits,Defined as follows: */
 		struct {
 			u8 PanelType:4; /*4 bits, Bit field for panels*/
 					/* 0 - 3: 0 = LVDS, 1 = MIPI*/
@@ -193,7 +193,7 @@ struct mrst_gct_v2 {
 	};
 	struct mrst_panel_descriptor_v2 panel[4];/*panel descrs,38 bytes each*/
 	union mrst_panel_rx panelrx[4]; /* panel receivers*/
-} __attribute__ ((packed));
+} __packed;
 
 struct mrst_gct_data {
 	u8 bpi; /* boot panel index, number of panel used during boot */
@@ -205,13 +205,13 @@ struct mrst_gct_data {
 	u32 PP_Cycle_Delay;
 	u16 Panel_Backlight_Inverter_Descriptor;
 	u16 Panel_MIPI_Display_Descriptor;
-} __attribute__ ((packed));
+} __packed;
 
-#define MODE_SETTING_IN_CRTC 	0x1
-#define MODE_SETTING_IN_ENCODER 0x2
-#define MODE_SETTING_ON_GOING 	0x3
-#define MODE_SETTING_IN_DSR 	0x4
-#define MODE_SETTING_ENCODER_DONE 0x8
-#define GCT_R10_HEADER_SIZE	16
-#define GCT_R10_DISPLAY_DESC_SIZE	28
+#define MODE_SETTING_IN_CRTC		0x1
+#define MODE_SETTING_IN_ENCODER		0x2
+#define MODE_SETTING_ON_GOING		0x3
+#define MODE_SETTING_IN_DSR		0x4
+#define MODE_SETTING_ENCODER_DONE	0x8
 
+#define GCT_R10_HEADER_SIZE		16
+#define GCT_R10_DISPLAY_DESC_SIZE	28
drivers/staging/gma500/mrst_lvds.c +4 -4
index aac80cc..a746571 100644
@@ -298,10 +298,10 @@ void mrst_lvds_init(struct drm_device *dev,
 	 /* This ifdef can go once the cpu ident stuff is cleaned up in arch */
 #if defined(CONFIG_X86_MRST)
 	if (mrst_identify_cpu())
-        	i2c_adap = i2c_get_adapter(2);
-        else	/* Oaktrail uses I2C 1 */
-#endif        
-        	i2c_adap = i2c_get_adapter(1);
+		i2c_adap = i2c_get_adapter(2);
+	else	/* Oaktrail uses I2C 1 */
+#endif
+		i2c_adap = i2c_get_adapter(1);
 
 	if (i2c_adap == NULL)
 		printk(KERN_ALERT "No ddc adapter available!\n");
drivers/staging/gma500/psb_2d.c +12 -11
index 494bad5..dea4bc1 100644
@@ -43,11 +43,11 @@
 
 void psb_spank(struct drm_psb_private *dev_priv)
 {
-        PSB_WSGX32(_PSB_CS_RESET_BIF_RESET | _PSB_CS_RESET_DPM_RESET |
+	PSB_WSGX32(_PSB_CS_RESET_BIF_RESET | _PSB_CS_RESET_DPM_RESET |
 		_PSB_CS_RESET_TA_RESET | _PSB_CS_RESET_USE_RESET |
 		_PSB_CS_RESET_ISP_RESET | _PSB_CS_RESET_TSP_RESET |
 		_PSB_CS_RESET_TWOD_RESET, PSB_CR_SOFT_RESET);
-	(void) PSB_RSGX32(PSB_CR_SOFT_RESET);
+	PSB_RSGX32(PSB_CR_SOFT_RESET);
 
 	msleep(1);
 
@@ -71,7 +71,7 @@ static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
 	uint32_t avail = PSB_RSGX32(PSB_CR_2D_SOCIF);
 	unsigned long t = jiffies + HZ;
 
-	while(avail < size) {
+	while (avail < size) {
 		avail = PSB_RSGX32(PSB_CR_2D_SOCIF);
 		if (time_after(jiffies, t)) {
 			psb_spank(dev_priv);
@@ -85,7 +85,7 @@ static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
    it with console use */
 
 int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
-	 	  	   unsigned size)
+								unsigned size)
 {
 	int ret = 0;
 	int i;
@@ -99,9 +99,10 @@ int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
 			return ret;
 
 		submit_size <<= 2;
-		for (i = 0; i < submit_size; i += 4) {
+
+		for (i = 0; i < submit_size; i += 4)
 			PSB_WSGX32(*cmdbuf++, PSB_SGX_2D_SLAVE_PORT + i);
-		}
+
 		(void)PSB_RSGX32(PSB_SGX_2D_SLAVE_PORT + i - 4);
 	}
 	return 0;
@@ -209,10 +210,10 @@ static u32 psb_accel_2d_copy_direction(int xdir, int ydir)
 {
 	if (xdir < 0)
 		return (ydir < 0) ? PSB_2D_COPYORDER_BR2TL :
-                			PSB_2D_COPYORDER_TR2BL;
+						PSB_2D_COPYORDER_TR2BL;
 	else
 		return (ydir < 0) ? PSB_2D_COPYORDER_BL2TR :
-                			PSB_2D_COPYORDER_TL2BR;
+						PSB_2D_COPYORDER_TL2BR;
 }
 
 /*
@@ -350,9 +351,9 @@ void psbfb_copyarea(struct fb_info *info,
 	if (unlikely(info->state != FBINFO_STATE_RUNNING))
 		return;
 
-        /* Avoid the 8 pixel erratum */
+	/* Avoid the 8 pixel erratum */
 	if (region->width == 8 || region->height == 8 ||
-	        (info->flags & FBINFO_HWACCEL_DISABLED))
+		(info->flags & FBINFO_HWACCEL_DISABLED))
 		return cfb_copyarea(info, region);
 
 	psbfb_copyarea_accel(info, region);
@@ -360,7 +361,7 @@ void psbfb_copyarea(struct fb_info *info,
 
 void psbfb_imageblit(struct fb_info *info, const struct fb_image *image)
 {
-        /* For now */
+	/* For now */
 	cfb_imageblit(info, image);
 }
 
drivers/staging/gma500/psb_drm.h +4 -4
index b005293..8c259b8 100644
@@ -118,10 +118,10 @@ struct drm_psb_register_rw_arg {
 		u32 OGAMC3;
 		u32 OGAMC4;
 		u32 OGAMC5;
-        	u32 IEP_ENABLED;
-        	u32 IEP_BLE_MINMAX;
-        	u32 IEP_BSSCC_CONTROL;
-                u32 b_wait_vblank;
+		u32 IEP_ENABLED;
+		u32 IEP_BLE_MINMAX;
+		u32 IEP_BSSCC_CONTROL;
+		u32 b_wait_vblank;
 	} overlay;
 
 	u32 sprite_enable_mask;
drivers/staging/gma500/psb_drv.c +11 -14
index 6ea06dd..3c2363a 100644
@@ -47,7 +47,7 @@ module_param_named(no_fb, drm_psb_no_fb, int, 0600);
 module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
 
 
-static struct pci_device_id pciidlist[] = {
+static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PSB_8108 },
 	{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_PSB_8109 },
 	{ 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_MRST_4100},
@@ -185,8 +185,7 @@ void mrst_get_fuse_settings(struct drm_device *dev)
 	 if (dev_priv->iLVDS_enable) {
 		dev_priv->is_lvds_on = true;
 		dev_priv->is_mipi_on = false;
-	}
-	else {
+	} else {
 		dev_priv->is_mipi_on = true;
 		dev_priv->is_lvds_on = false;
 	}
@@ -196,7 +195,7 @@ void mrst_get_fuse_settings(struct drm_device *dev)
 	pci_write_config_dword(pci_root, 0xD0, FB_REG09);
 	pci_read_config_dword(pci_root, 0xD4, &fuse_value);
 
-	DRM_INFO("SKU values is 0x%x. \n", fuse_value);
+	DRM_INFO("SKU values is 0x%x.\n", fuse_value);
 	fuse_value_tmp = (fuse_value & FB_SKU_MASK) >> FB_SKU_SHIFT;
 
 	dev_priv->fuse_reg_value = fuse_value;
@@ -220,7 +219,7 @@ void mrst_get_fuse_settings(struct drm_device *dev)
 	pci_dev_put(pci_root);
 }
 
-void mid_get_pci_revID (struct drm_psb_private *dev_priv)
+void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 {
 	uint32_t platform_rev_id = 0;
 	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
@@ -230,7 +229,7 @@ void mid_get_pci_revID (struct drm_psb_private *dev_priv)
 	dev_priv->platform_rev_id = (uint8_t) platform_rev_id;
 	pci_dev_put(pci_gfx_root);
 	dev_info(dev_priv->dev->dev, "platform_rev_id is %x\n",
-							dev_priv->platform_rev_id);
+					dev_priv->platform_rev_id);
 }
 
 void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
@@ -285,7 +284,7 @@ void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
 		dev_priv->gct_data.Panel_Port_Control =
 		  ((struct mrst_gct_v1 *)pGCT)->panel[bpi].Panel_Port_Control;
 		dev_priv->gct_data.Panel_MIPI_Display_Descriptor =
-		  ((struct mrst_gct_v1 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
+			((struct mrst_gct_v1 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
 		break;
 	case 1:
 		vbt->mrst_gct = NULL;
@@ -303,7 +302,7 @@ void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
 		dev_priv->gct_data.Panel_Port_Control =
 		  ((struct mrst_gct_v2 *)pGCT)->panel[bpi].Panel_Port_Control;
 		dev_priv->gct_data.Panel_MIPI_Display_Descriptor =
-		  ((struct mrst_gct_v2 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
+			((struct mrst_gct_v2 *)pGCT)->panel[bpi].Panel_MIPI_Display_Descriptor;
 		break;
 	case 0x10:
 		/*header definition changed from rev 01 (v2) to rev 10h. */
@@ -449,13 +448,12 @@ static int psb_do_init(struct drm_device *dev)
 	PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK0);
 	PSB_WSGX32(0x00000000, PSB_CR_BIF_BANK1);
 	PSB_RSGX32(PSB_CR_BIF_BANK1);
-        PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) | _PSB_MMU_ER_MASK,
+	PSB_WSGX32(PSB_RSGX32(PSB_CR_BIF_CTRL) | _PSB_MMU_ER_MASK,
 							PSB_CR_BIF_CTRL);
 	psb_spank(dev_priv);
 
 	/* mmu_gatt ?? */
-      	PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
-
+	PSB_WSGX32(pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
 	return 0;
 out_err:
 	psb_do_takedown(dev);
@@ -1335,7 +1333,6 @@ static long psb_unlocked_ioctl(struct file *filp, unsigned int cmd,
 		dev_priv->rpm_enabled = 1;
 	}
 	return drm_ioctl(filp, cmd, arg);
-	
 	/* FIXME: do we need to wrap the other side of this */
 }
 
@@ -1367,7 +1364,7 @@ static struct vm_operations_struct psb_gem_vm_ops = {
 
 static struct drm_driver driver = {
 	.driver_features = DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | \
-			   DRIVER_IRQ_VBL | DRIVER_MODESET| DRIVER_GEM ,
+			   DRIVER_IRQ_VBL | DRIVER_MODESET | DRIVER_GEM ,
 	.load = psb_driver_load,
 	.unload = psb_driver_unload,
 
@@ -1428,7 +1425,7 @@ static int psb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
 	/* MLD Added this from Inaky's patch */
 	if (pci_enable_msi(pdev))
-                dev_warn(&pdev->dev, "Enable MSI failed!\n");
+		dev_warn(&pdev->dev, "Enable MSI failed!\n");
 	return drm_get_pci_dev(pdev, ent, &driver);
 }
 
drivers/staging/gma500/psb_drv.h +34 -29

147 lines not on this page · raw message

drivers/staging/gma500/psb_fb.c +76 -69

254 lines not on this page · raw message

drivers/staging/gma500/psb_gem.c +10 -9
index 4aec38c..3f658e4 100644
@@ -82,12 +82,13 @@ static int psb_gem_create_mmap_offset(struct drm_gem_object *obj)
 	map = list->map;
 	map->type = _DRM_GEM;
 	map->size = obj->size;
-	map->handle =obj;
+	map->handle = obj;
 
 	list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
 					obj->size / PAGE_SIZE, 0, 0);
 	if (!list->file_offset_node) {
-		dev_err(dev->dev, "failed to allocate offset for bo %d\n", obj->name);
+		dev_err(dev->dev, "failed to allocate offset for bo %d\n",
+								obj->name);
 		ret = -ENOSPC;
 		goto free_it;
 	}
@@ -130,7 +131,7 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
 
 	if (!(dev->driver->driver_features & DRIVER_GEM))
 		return -ENODEV;
-		
+
 	mutex_lock(&dev->struct_mutex);
 
 	/* GEM does all our handle to object mapping */
@@ -140,7 +141,7 @@ int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
 		goto unlock;
 	}
 	/* What validation is needed here ? */
-	
+
 	/* Make it mmapable */
 	if (!obj->map_list.map) {
 		ret = psb_gem_create_mmap_offset(obj);
@@ -176,7 +177,7 @@ static int psb_gem_create(struct drm_file *file,
 
 	size = roundup(size, PAGE_SIZE);
 
-	/* Allocate our object - for now a direct gtt range which is not 
+	/* Allocate our object - for now a direct gtt range which is not
 	   stolen memory backed */
 	r = psb_gtt_alloc_range(dev, size, "gem", 0);
 	if (r == NULL) {
@@ -285,9 +286,9 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	if (r->mmapping == 0) {
 		ret = psb_gtt_pin(r);
 		if (ret < 0) {
-		        dev_err(dev->dev, "gma500: pin failed: %d\n", ret);
-		        goto fail;
-                }
+			dev_err(dev->dev, "gma500: pin failed: %d\n", ret);
+			goto fail;
+		}
 		r->mmapping = 1;
 	}
 
@@ -304,7 +305,7 @@ int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	ret = vm_insert_pfn(vma, (unsigned long)vmf->virtual_address, pfn);
 
 fail:
-        mutex_unlock(&dev->struct_mutex);
+	mutex_unlock(&dev->struct_mutex);
 	switch (ret) {
 	case 0:
 	case -ERESTARTSYS:
drivers/staging/gma500/psb_gtt.c +19 -16
index 9da1375..6cfa59b 100644
@@ -52,7 +52,7 @@ static inline uint32_t psb_gtt_mask_pte(uint32_t pfn, int type)
  *	psb_gtt_entry		-	find the GTT entries for a gtt_range
  *	@dev: our DRM device
  *	@r: our GTT range
- * 
+ *
  *	Given a gtt_range object return the GTT offset of the page table
  *	entries for this gtt_range
  */
@@ -102,7 +102,6 @@ static int psb_gtt_insert(struct drm_device *dev, struct gtt_range *r)
 	}
 	/* Make sure all the entries are set before we return */
 	ioread32(gtt_slot - 1);
-	
 	return 0;
 }
 
@@ -257,7 +256,7 @@ void psb_gtt_unpin(struct gtt_range *gt)
 	}
 	mutex_unlock(&dev_priv->gtt_mutex);
 }
-	
+
 /*
  *	GTT resource allocator - allocate and manage GTT address space
  */
@@ -289,11 +288,11 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
 		/* The start of the GTT is the stolen pages */
 		start = r->start;
 		end = r->start + dev_priv->pg->stolen_size - 1;
-        } else {
-        	/* The rest we will use for GEM backed objects */
-        	start = r->start + dev_priv->pg->stolen_size;
-        	end = r->end;
-        }
+	} else {
+		/* The rest we will use for GEM backed objects */
+		start = r->start + dev_priv->pg->stolen_size;
+		end = r->end;
+	}
 
 	gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL);
 	if (gt == NULL)
@@ -318,8 +317,8 @@ struct gtt_range *psb_gtt_alloc_range(struct drm_device *dev, int len,
  *	@dev: our DRM device
  *	@gt: a mapping created with psb_gtt_alloc_range
  *
- *	Release a resource that was allocated with psb_gtt_alloc_range. If the object
- *	has been pinned by mmap users we clean this up here currently.
+ *	Release a resource that was allocated with psb_gtt_alloc_range. If the
+ *	object has been pinned by mmap users we clean this up here currently.
  */
 void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt)
 {
@@ -386,7 +385,7 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	if (pg == NULL)
 		return -ENOMEM;
 
-        /* Enable the GTT */
+	/* Enable the GTT */
 	pci_read_config_word(dev->pdev, PSB_GMCH_CTRL, &dev_priv->gmch_ctrl);
 	pci_write_config_word(dev->pdev, PSB_GMCH_CTRL,
 			      dev_priv->gmch_ctrl | _PSB_GMCH_ENABLED);
@@ -402,18 +401,21 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
 
 	pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
-	/* 
+	/*
 	 *	FIXME: video mmu has hw bug to access 0x0D0000000,
 	 *	then make gatt start at 0x0e000,0000
 	 */
 	pg->mmu_gatt_start = 0xE0000000;
 
 	pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE);
-	gtt_pages = pci_resource_len(dev->pdev, PSB_GTT_RESOURCE) >> PAGE_SHIFT;
-	pg->gatt_pages = pci_resource_len(dev->pdev, PSB_GATT_RESOURCE) >> PAGE_SHIFT;
+	gtt_pages = pci_resource_len(dev->pdev, PSB_GTT_RESOURCE)
+								>> PAGE_SHIFT;
+	pg->gatt_pages = pci_resource_len(dev->pdev, PSB_GATT_RESOURCE)
+								>> PAGE_SHIFT;
 
 	pci_read_config_dword(dev->pdev, PSB_BSM, &dev_priv->stolen_base);
-	vram_stolen_size = pg->gtt_phys_start - dev_priv->stolen_base - PAGE_SIZE;
+	vram_stolen_size = pg->gtt_phys_start - dev_priv->stolen_base
+								- PAGE_SIZE;
 
 	stolen_size = vram_stolen_size;
 
@@ -439,7 +441,8 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	/*
 	 *	Map the GTT and the stolen memory area
 	 */
-	dev_priv->gtt_map = ioremap_nocache(pg->gtt_phys_start, gtt_pages << PAGE_SHIFT);
+	dev_priv->gtt_map = ioremap_nocache(pg->gtt_phys_start,
+						gtt_pages << PAGE_SHIFT);
 	if (!dev_priv->gtt_map) {
 		dev_err(dev->dev, "Failure to map gtt.\n");
 		ret = -ENOMEM;
drivers/staging/gma500/psb_intel_display.c +6 -6
index 6039a31..f28f5d6 100644
@@ -388,7 +388,7 @@ int psb_intel_pipe_set_base(struct drm_crtc *crtc,
 		dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
 		break;
 	default:
-                dev_err(dev->dev, "Unknown color depth\n");
+		dev_err(dev->dev, "Unknown color depth\n");
 		ret = -EINVAL;
 		psb_gtt_unpin(psbfb->gtt);
 		goto psb_intel_pipe_set_base_exit;
@@ -611,9 +611,9 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 
 	/* No scan out no play */
 	if (crtc->fb == NULL) {
-	        crtc_funcs->mode_set_base(crtc, x, y, old_fb);
-                return 0;
-        }
+		crtc_funcs->mode_set_base(crtc, x, y, old_fb);
+		return 0;
+	}
 
 	list_for_each_entry(connector, &mode_config->connector_list, head) {
 		struct psb_intel_output *psb_intel_output =
@@ -728,8 +728,8 @@ static int psb_intel_crtc_mode_set(struct drm_crtc *crtc,
 		u32 lvds = REG_READ(LVDS);
 
 		lvds &= ~LVDS_PIPEB_SELECT;
-                if (pipe == 1)
-                        lvds |= LVDS_PIPEB_SELECT;
+		if (pipe == 1)
+			lvds |= LVDS_PIPEB_SELECT;
 
 		lvds |= LVDS_PORT_EN | LVDS_A0A2_CLKA_POWER_UP;
 		/* Set the B0-B3 data pairs corresponding to
drivers/staging/gma500/psb_intel_opregion.c +4 -4
index 51cf1d6..97a8b00 100644
@@ -33,19 +33,19 @@ struct opregion_header {
 	u8 driver_ver[16];
 	u32 mboxes;
 	u8 reserved[164];
-} __attribute__((packed));
+} __packed;
 
 struct opregion_apci {
 	/*FIXME: add it later*/
-} __attribute__((packed));
+} __packed;
 
 struct opregion_swsci {
 	/*FIXME: add it later*/
-} __attribute__((packed));
+} __packed;
 
 struct opregion_acpi {
 	/*FIXME: add it later*/
-} __attribute__((packed));
+} __packed;
 
 int psb_intel_opregion_init(struct drm_device *dev)
 {
drivers/staging/gma500/psb_intel_reg.h +531 -524

1,433 lines not on this page · raw message

drivers/staging/gma500/psb_intel_sdvo.c +2 -1
index e313ce2..a4bad1a 100644
@@ -211,7 +211,8 @@ static void psb_intel_sdvo_write_cmd(struct psb_intel_output *psb_intel_output,
 		     sizeof(sdvo_cmd_names) / sizeof(sdvo_cmd_names[0]);
 		     i++) {
 			if (cmd == sdvo_cmd_names[i].cmd) {
-				printk(KERN_CONT "(%s)", sdvo_cmd_names[i].name);
+				printk(KERN_CONT
+					"(%s)", sdvo_cmd_names[i].name);
 				break;
 			}
 		}
drivers/staging/gma500/psb_intel_sdvo_regs.h +7 -7
index c7107a3..96862ea 100644
@@ -51,7 +51,7 @@ struct psb_intel_sdvo_caps {
 	unsigned int stall_support:1;
 	unsigned int pad:1;
 	u16 output_flags;
-} __attribute__ ((packed));
+} __packed;
 
 /** This matches the EDID DTD structure, more or less */
 struct psb_intel_sdvo_dtd {
@@ -82,18 +82,18 @@ struct psb_intel_sdvo_dtd {
 		u8 v_sync_off_high;
 		u8 reserved;
 	} part2;
-} __attribute__ ((packed));
+} __packed;
 
 struct psb_intel_sdvo_pixel_clock_range {
 	u16 min;		/**< pixel clock, in 10kHz units */
 	u16 max;		/**< pixel clock, in 10kHz units */
-} __attribute__ ((packed));
+} __packed;
 
 struct psb_intel_sdvo_preferred_input_timing_args {
 	u16 clock;
 	u16 width;
 	u16 height;
-} __attribute__ ((packed));
+} __packed;
 
 /* I2C registers for SDVO */
 #define SDVO_I2C_ARG_0				0x07
@@ -147,7 +147,7 @@ struct psb_intel_sdvo_get_trained_inputs_response {
 	unsigned int input0_trained:1;
 	unsigned int input1_trained:1;
 	unsigned int pad:6;
-} __attribute__ ((packed));
+} __packed;
 
 /** Returns a struct psb_intel_sdvo_output_flags of active outputs. */
 #define SDVO_CMD_GET_ACTIVE_OUTPUTS			0x04
@@ -201,7 +201,7 @@ struct psb_intel_sdvo_get_interrupt_event_source_response {
 	u16 interrupt_status;
 	unsigned int ambient_light_interrupt:1;
 	unsigned int pad:7;
-} __attribute__ ((packed));
+} __packed;
 
 /**
  * Selects which input is affected by future input commands.
@@ -214,7 +214,7 @@ struct psb_intel_sdvo_get_interrupt_event_source_response {
 struct psb_intel_sdvo_set_target_input_args {
 	unsigned int target_1:1;
 	unsigned int pad:7;
-} __attribute__ ((packed));
+} __packed;
 
 /**
  * Takes a struct psb_intel_sdvo_output_flags of which outputs are targeted by
drivers/staging/gma500/psb_reg.h +417 -423

609 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

author
#13 lore raw

PATCH 13/49 gma500: 2D polish

In reply to Alan Cox

From: Alan Cox <[email protected]>

Tidy up the 2D bits. For the fill case the CPU seems to be able to outperform the graphics engine for the cases we get, so don't bother fixing it but throw it out.

---

 drivers/staging/gma500/psb_2d.c  |  191 ++++++++++++++------------------------
 drivers/staging/gma500/psb_drv.h |    6 -
 drivers/staging/gma500/psb_fb.c  |    4 -
 3 files changed, 74 insertions(+), 127 deletions(-)
drivers/staging/gma500/psb_2d.c +72 -119
index dea4bc1..df4c519 100644
@@ -41,6 +41,14 @@
 #include "psb_drv.h"
 #include "psb_fb.h"
 
+/**
+ *	psb_spank		-	reset the 2D engine
+ *	@dev_priv: our PSB DRM device
+ *
+ *	Soft reset the graphics engine and then reload the necessary registers.
+ *	We use this at initialisation time but it will become relevant for
+ *	accelerated X later
+ */
 void psb_spank(struct drm_psb_private *dev_priv)
 {
 	PSB_WSGX32(_PSB_CS_RESET_BIF_RESET | _PSB_CS_RESET_DPM_RESET |
@@ -65,6 +73,14 @@ void psb_spank(struct drm_psb_private *dev_priv)
 	PSB_WSGX32(dev_priv->pg->gatt_start, PSB_CR_BIF_TWOD_REQ_BASE);
 }
 
+/**
+ *	psb2_2d_wait_available	-	wait for FIFO room
+ *	@dev_priv: our DRM device
+ *	@size: size (in dwords) of the command we want to issue
+ *
+ *	Wait until there is room to load the FIFO with our data. If the
+ *	device is not responding then reset it
+ */
 static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
 			  unsigned size)
 {
@@ -81,9 +97,15 @@ static int psb_2d_wait_available(struct drm_psb_private *dev_priv,
 	return 0;
 }
 
-/* FIXME: Remember if we expose the 2D engine to the DRM we need to serialize
-   it with console use */
-
+/**
+ *	psb_2d_submit		-	submit a 2D command
+ *	@dev_priv: our DRM device
+ *	@cmdbuf: command to issue
+ *	@size: length (in dwords)
+ *
+ *	Issue one or more 2D commands to the accelerator. This needs to be
+ *	serialized later when we add the GEM interfaces for acceleration
+ */
 int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
 								unsigned size)
 {
@@ -108,104 +130,15 @@ int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
 	return 0;
 }
 
-static int psb_accel_2d_fillrect(struct drm_psb_private *dev_priv,
-				 uint32_t dst_offset, uint32_t dst_stride,
-				 uint32_t dst_format, uint16_t dst_x,
-				 uint16_t dst_y, uint16_t size_x,
-				 uint16_t size_y, uint32_t fill)
-{
-	uint32_t buffer[10];
-	uint32_t *buf;
-
-	buf = buffer;
-
-	*buf++ = PSB_2D_FENCE_BH;
-
-	*buf++ =
-	    PSB_2D_DST_SURF_BH | dst_format | (dst_stride <<
-					       PSB_2D_DST_STRIDE_SHIFT);
-	*buf++ = dst_offset;
-
-	*buf++ =
-	    PSB_2D_BLIT_BH |
-	    PSB_2D_ROT_NONE |
-	    PSB_2D_COPYORDER_TL2BR |
-	    PSB_2D_DSTCK_DISABLE |
-	    PSB_2D_SRCCK_DISABLE | PSB_2D_USE_FILL | PSB_2D_ROP3_PATCOPY;
-
-	*buf++ = fill << PSB_2D_FILLCOLOUR_SHIFT;
-	*buf++ =
-	    (dst_x << PSB_2D_DST_XSTART_SHIFT) | (dst_y <<
-						  PSB_2D_DST_YSTART_SHIFT);
-	*buf++ =
-	    (size_x << PSB_2D_DST_XSIZE_SHIFT) | (size_y <<
-						  PSB_2D_DST_YSIZE_SHIFT);
-	*buf++ = PSB_2D_FLUSH_BH;
-
-	return psbfb_2d_submit(dev_priv, buffer, buf - buffer);
-}
-
-static void psbfb_fillrect_accel(struct fb_info *info,
-				 const struct fb_fillrect *r)
-{
-	struct psb_fbdev *fbdev = info->par;
-	struct psb_framebuffer *psbfb = &fbdev->pfb;
-	struct drm_device *dev = psbfb->base.dev;
-	struct drm_framebuffer *fb = fbdev->psb_fb_helper.fb;
-	struct drm_psb_private *dev_priv = dev->dev_private;
-
-	uint32_t offset;
-	uint32_t stride;
-	uint32_t format;
-
-	if (!fb)
-		return;
-
-	offset = psbfb->gtt->offset;
-	stride = fb->pitch;
-
-	switch (fb->depth) {
-	case 8:
-		format = PSB_2D_DST_332RGB;
-		break;
-	case 15:
-		format = PSB_2D_DST_555RGB;
-		break;
-	case 16:
-		format = PSB_2D_DST_565RGB;
-		break;
-	case 24:
-	case 32:
-		/* this is wrong but since we don't do blending its okay */
-		format = PSB_2D_DST_8888ARGB;
-		break;
-	default:
-		/* software fallback */
-		cfb_fillrect(info, r);
-		return;
-	}
-	if (!gma_power_begin(dev, false)) {
-		cfb_fillrect(info, r);
-		return;
-	}
-	psb_accel_2d_fillrect(dev_priv,
-			      offset, stride, format,
-			      r->dx, r->dy, r->width, r->height, r->color);
-	gma_power_end(dev);
-}
-
-void psbfb_fillrect(struct fb_info *info,
-			   const struct fb_fillrect *rect)
-{
-	if (unlikely(info->state != FBINFO_STATE_RUNNING))
-		return;
-
-	if (1 || (info->flags & FBINFO_HWACCEL_DISABLED))
-		return cfb_fillrect(info, rect);
-
-	psbfb_fillrect_accel(info, rect);
-}
 
+/**
+ *	psb_accel_2d_copy_direction	-	compute blit order
+ *	@xdir: X direction of move
+ *	@ydir: Y direction of move
+ *
+ *	Compute the correct order setings to ensure that an overlapping blit
+ *	correctly copies all the pixels.
+ */
 static u32 psb_accel_2d_copy_direction(int xdir, int ydir)
 {
 	if (xdir < 0)
@@ -216,19 +149,23 @@ static u32 psb_accel_2d_copy_direction(int xdir, int ydir)
 						PSB_2D_COPYORDER_TL2BR;
 }
 
-/*
- * @src_offset in bytes
- * @src_stride in bytes
- * @src_format psb 2D format defines
- * @dst_offset in bytes
- * @dst_stride in bytes
- * @dst_format psb 2D format defines
- * @src_x offset in pixels
- * @src_y offset in pixels
- * @dst_x offset in pixels
- * @dst_y offset in pixels
- * @size_x of the copied area
- * @size_y of the copied area
+/**
+ *	psb_accel_2d_copy		-	accelerated 2D copy
+ *	@dev_priv: our DRM device
+ *	@src_offset in bytes
+ *	@src_stride in bytes
+ *	@src_format psb 2D format defines
+ *	@dst_offset in bytes
+ *	@dst_stride in bytes
+ *	@dst_format psb 2D format defines
+ *	@src_x offset in pixels
+ *	@src_y offset in pixels
+ *	@dst_x offset in pixels
+ *	@dst_y offset in pixels
+ *	@size_x of the copied area
+ *	@size_y of the copied area
+ *
+ *	Format and issue a 2D accelerated copy command.
  */
 static int psb_accel_2d_copy(struct drm_psb_private *dev_priv,
 			     uint32_t src_offset, uint32_t src_stride,
@@ -290,6 +227,13 @@ static int psb_accel_2d_copy(struct drm_psb_private *dev_priv,
 	return psbfb_2d_submit(dev_priv, buffer, buf - buffer);
 }
 
+/**
+ *	psbfb_copyarea_accel	-	copyarea acceleration for /dev/fb
+ *	@info: our framebuffer
+ *	@a: copyarea parameters from the framebuffer core
+ *
+ *	Perform a 2D copy via the accelerator
+ */
 static void psbfb_copyarea_accel(struct fb_info *info,
 				 const struct fb_copyarea *a)
 {
@@ -345,6 +289,14 @@ static void psbfb_copyarea_accel(struct fb_info *info,
 	gma_power_end(dev);
 }
 
+/**
+ *	psbfb_copyarea	-	2D copy interface
+ *	@info: our framebuffer
+ *	@region: region to copy
+ *
+ *	Copy an area of the framebuffer console either by the accelerator
+ *	or directly using the cfb helpers according to the request
+ */
 void psbfb_copyarea(struct fb_info *info,
 			   const struct fb_copyarea *region)
 {
@@ -359,12 +311,13 @@ void psbfb_copyarea(struct fb_info *info,
 	psbfb_copyarea_accel(info, region);
 }
 
-void psbfb_imageblit(struct fb_info *info, const struct fb_image *image)
-{
-	/* For now */
-	cfb_imageblit(info, image);
-}
-
+/**
+ *	psbfb_sync	-	synchronize 2D
+ *	@info: our framebuffer
+ *
+ *	Wait for the 2D engine to quiesce so that we can do CPU
+ *	access to the framebuffer again
+ */
 int psbfb_sync(struct fb_info *info)
 {
 	struct psb_fbdev *fbdev = info->par;
drivers/staging/gma500/psb_drv.h +0 -6
index 1114021..cafbfcd 100644
@@ -587,16 +587,10 @@ extern void *psbfb_vdc_reg(struct drm_device* dev);
 /*
  * psb_2d.c
  */
-extern void psbfb_fillrect(struct fb_info *info,
-					const struct fb_fillrect *rect);
 extern void psbfb_copyarea(struct fb_info *info,
 					const struct fb_copyarea *region);
-extern void psbfb_imageblit(struct fb_info *info,
-					const struct fb_image *image);
 extern int psbfb_sync(struct fb_info *info);
-
 extern void psb_spank(struct drm_psb_private *dev_priv);
-
 extern int psbfb_2d_submit(struct drm_psb_private *dev_priv, uint32_t *cmdbuf,
 					unsigned size);
 
drivers/staging/gma500/psb_fb.c +2 -2
index f1a7e8d..c2d4b23 100644
@@ -289,9 +289,9 @@ static struct fb_ops psbfb_ops = {
 	.fb_set_par = drm_fb_helper_set_par,
 	.fb_blank = drm_fb_helper_blank,
 	.fb_setcolreg = psbfb_setcolreg,
-	.fb_fillrect = psbfb_fillrect,
+	.fb_fillrect = cfb_fillrect,
 	.fb_copyarea = psbfb_copyarea,
-	.fb_imageblit = psbfb_imageblit,
+	.fb_imageblit = cfb_imageblit,
 	.fb_mmap = psbfb_mmap,
 	.fb_sync = psbfb_sync,
 	.fb_ioctl = psbfb_ioctl,
author
#14 lore raw

PATCH 14/49 gma500: Medfield support

In reply to Alan Cox

From: Alan Cox <[email protected]>

This large patch adds all the basics for Medfield support. Lots of clean up needed in this area still.

---

 drivers/staging/gma500/Makefile               |   12 
 drivers/staging/gma500/displays/hdmi.h        |   33 +
 drivers/staging/gma500/displays/pyr_cmd.h     |   34 +
 drivers/staging/gma500/displays/pyr_vid.h     |   34 +
 drivers/staging/gma500/displays/tmd_cmd.h     |   34 +
 drivers/staging/gma500/displays/tmd_vid.h     |   34 +
 drivers/staging/gma500/displays/tpo_cmd.h     |   35 +
 drivers/staging/gma500/displays/tpo_vid.h     |   33 +
 drivers/staging/gma500/mdfld_dsi_dbi.c        |  872 ++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_dbi.h        |  188 +++
 drivers/staging/gma500/mdfld_dsi_dbi_dpu.h    |  157 +++
 drivers/staging/gma500/mdfld_dsi_dpi.c        |  991 ++++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_dpi.h        |   80 +
 drivers/staging/gma500/mdfld_dsi_output.c     |  977 ++++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_output.h     |  328 ++++++
 drivers/staging/gma500/mdfld_dsi_pkg_sender.c | 1097 ++++++++++++++++++++
 drivers/staging/gma500/mdfld_dsi_pkg_sender.h |  158 +++
 drivers/staging/gma500/mdfld_intel_display.c  | 1388 +++++++++++++++++++++++++
 drivers/staging/gma500/mdfld_msic.h           |   31 +
 drivers/staging/gma500/mdfld_output.c         |  135 ++
 drivers/staging/gma500/mdfld_output.h         |   77 +
 drivers/staging/gma500/mdfld_pyr_cmd.c        |  575 ++++++++++
 drivers/staging/gma500/mdfld_tmd_vid.c        |  144 +++
 drivers/staging/gma500/mdfld_tpo_cmd.c        |  495 +++++++++
 drivers/staging/gma500/mdfld_tpo_vid.c        |  140 +++
 drivers/staging/gma500/psb_bl.c               |   68 +
 drivers/staging/gma500/psb_drm.h              |    7 
 drivers/staging/gma500/psb_drv.c              |   25 
 drivers/staging/gma500/psb_drv.h              |  132 ++
 drivers/staging/gma500/psb_fb.c               |   28 -
 drivers/staging/gma500/psb_intel_display.c    |   18 
 drivers/staging/gma500/psb_intel_display.h    |    3 
 drivers/staging/gma500/psb_intel_drv.h        |    3 
 drivers/staging/gma500/psb_intel_lvds.c       |    1 
 drivers/staging/gma500/psb_irq.c              |   61 +
 drivers/staging/gma500/psb_powermgmt.c        |  626 +++++++++++
 36 files changed, 9005 insertions(+), 49 deletions(-)
 create mode 100644 drivers/staging/gma500/displays/hdmi.h
 create mode 100644 drivers/staging/gma500/displays/pyr_cmd.h
 create mode 100644 drivers/staging/gma500/displays/pyr_vid.h
 create mode 100644 drivers/staging/gma500/displays/tmd_cmd.h
 create mode 100644 drivers/staging/gma500/displays/tmd_vid.h
 create mode 100644 drivers/staging/gma500/displays/tpo_cmd.h
 create mode 100644 drivers/staging/gma500/displays/tpo_vid.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dbi_dpu.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dpi.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_dpi.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_output.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_output.h
 create mode 100644 drivers/staging/gma500/mdfld_dsi_pkg_sender.c
 create mode 100644 drivers/staging/gma500/mdfld_dsi_pkg_sender.h
 create mode 100644 drivers/staging/gma500/mdfld_intel_display.c
 create mode 100644 drivers/staging/gma500/mdfld_msic.h
 create mode 100644 drivers/staging/gma500/mdfld_output.c
 create mode 100644 drivers/staging/gma500/mdfld_output.h
 create mode 100644 drivers/staging/gma500/mdfld_pyr_cmd.c
 create mode 100644 drivers/staging/gma500/mdfld_tmd_vid.c
 create mode 100644 drivers/staging/gma500/mdfld_tpo_cmd.c
 create mode 100644 drivers/staging/gma500/mdfld_tpo_vid.c
drivers/staging/gma500/Makefile +11 -1
index 01aaa28..4c9c475 100644
@@ -22,6 +22,16 @@ psb_gfx-y += gem_glue.o \
 	  psb_powermgmt.o \
 	  psb_irq.o \
 	  mrst_crtc.o \
-	  mrst_lvds.o
+	  mrst_lvds.o \
+	  mdfld_output.o \
+	  mdfld_pyr_cmd.o \
+	  mdfld_tmd_vid.o \
+	  mdfld_tpo_cmd.o \
+	  mdfld_tpo_vid.o \
+	  mdfld_dsi_pkg_sender.o \
+	  mdfld_dsi_dpi.o \
+	  mdfld_dsi_output.o \
+	  mdfld_dsi_dbi.o \
+	  mdfld_intel_display.o
 
 obj-$(CONFIG_DRM_PSB) += psb_gfx.o
drivers/staging/gma500/displays/hdmi.h new file +33 -0
new file mode 100644
index 0000000..d58ba9b
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+ */
+
+#ifndef HDMI_H
+#define HDMI_H
+
+extern void hdmi_init(struct drm_device *dev);
+
+#endif
drivers/staging/gma500/displays/pyr_cmd.h new file +34 -0
new file mode 100644
index 0000000..84bae5c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+ */
+
+#ifndef PYR_CMD_H
+#define PYR_CMD_H
+
+extern void pyr_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+
+#endif
+
drivers/staging/gma500/displays/pyr_vid.h new file +34 -0
new file mode 100644
index 0000000..ce98860
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+*/
+
+#ifndef PYR_VID_H
+#define PYR_VID_H
+
+extern void pyr_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+extern struct drm_display_mode *pyr_vid_get_config_mode(struct drm_device* dev);
+
+#endif
drivers/staging/gma500/displays/tmd_cmd.h new file +34 -0
new file mode 100644
index 0000000..641e85e
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+ */
+
+#ifndef TMD_CMD_H
+#define TMD_CMD_H
+
+extern void tmd_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+extern struct drm_display_mode *tmd_cmd_get_config_mode(struct drm_device *dev);
+
+#endif
drivers/staging/gma500/displays/tmd_vid.h new file +34 -0
new file mode 100644
index 0000000..7a5fa3b
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+*/
+
+#ifndef TMD_VID_H
+#define TMD_VID_H
+
+extern void tmd_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+extern struct drm_display_mode *tmd_vid_get_config_mode(struct drm_device *dev);
+
+#endif
drivers/staging/gma500/displays/tpo_cmd.h new file +35 -0
new file mode 100644
index 0000000..6105527
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+*/
+
+#ifndef TPO_CMD_H
+#define TPO_CMD_H
+
+extern void tpo_cmd_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+/* extern struct drm_display_mode * */
+/* tpo_cmd_get_config_mode(struct drm_device *dev); */
+
+#endif
drivers/staging/gma500/displays/tpo_vid.h new file +33 -0
new file mode 100644
index 0000000..c24f057
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c)  2010 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicensen
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Thomas Eaton <[email protected]>
+ * Scott Rowe <[email protected]>
+ */
+
+#ifndef TPO_VID_H
+#define TPO_VID_H
+
+extern void tpo_vid_init(struct drm_device *dev, struct panel_funcs *p_funcs);
+
+#endif
drivers/staging/gma500/mdfld_dsi_dbi.c new file +872 -0

872 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_dbi.h new file +188 -0

188 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_dbi_dpu.h new file +157 -0

157 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_dpi.c new file +991 -0

991 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_dpi.h new file +80 -0

80 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_output.c new file +977 -0

458 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_output.h new file +328 -0

328 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_pkg_sender.c new file +1097 -0

1,097 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_pkg_sender.h new file +158 -0

158 lines not on this page · raw message

drivers/staging/gma500/mdfld_intel_display.c new file +1388 -0

1,388 lines not on this page · raw message

drivers/staging/gma500/mdfld_msic.h new file +31 -0
new file mode 100644
index 0000000..a7ad6547

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/mdfld_output.c new file +135 -0

135 lines not on this page · raw message

drivers/staging/gma500/mdfld_output.h new file +77 -0

77 lines not on this page · raw message

drivers/staging/gma500/mdfld_pyr_cmd.c new file +575 -0

575 lines not on this page · raw message

drivers/staging/gma500/mdfld_tmd_vid.c new file +144 -0

144 lines not on this page · raw message

drivers/staging/gma500/mdfld_tpo_cmd.c new file +495 -0

495 lines not on this page · raw message

drivers/staging/gma500/mdfld_tpo_vid.c new file +140 -0

140 lines not on this page · raw message

drivers/staging/gma500/psb_bl.c +65 -3

68 lines not on this page · raw message

drivers/staging/gma500/psb_drm.h +7 -0
index 8c259b8..c541137 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_drv.c +22 -3
index 3c2363a..8df9c58 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_drv.h +129 -3

132 lines not on this page · raw message

drivers/staging/gma500/psb_fb.c +26 -2
index c2d4b23..8377a99 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_intel_display.c +14 -4
index f28f5d6..ba10849 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_intel_display.h +3 -0
index 3724b97..535b49a 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_intel_drv.h +3 -0
index 75a95f7..9d7151a 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_intel_lvds.c +1 -0
index 1cbc9bc..850d07d 100644

Lines of this file are not shown. View the raw message.

drivers/staging/gma500/psb_irq.c +60 -1

61 lines not on this page · raw message

drivers/staging/gma500/psb_powermgmt.c +594 -32

626 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.

author
#15 lore raw

PATCH 15/49 gma500: Move our other GEM helper into the bits want to push into GEM

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/gem_glue.c |   54 ++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/gem_glue.h |    2 +
 drivers/staging/gma500/psb_gem.c  |   56 +------------------------------------
 3 files changed, 56 insertions(+), 56 deletions(-)
drivers/staging/gma500/gem_glue.c +54 -0
index 0817497..0e7364b 100644
@@ -45,3 +45,57 @@ void drm_gem_object_release_wrap(struct drm_gem_object *obj)
 	if (obj->filp)
 		drm_gem_object_release(obj);
 }
+
+/**
+ *	gem_create_mmap_offset		-	invent an mmap offset
+ *	@obj: our object
+ *
+ *	Standard implementation of offset generation for mmap as is
+ *	duplicated in several drivers. This belongs in GEM.
+ */
+int gem_create_mmap_offset(struct drm_gem_object *obj)
+{
+	struct drm_device *dev = obj->dev;
+	struct drm_gem_mm *mm = dev->mm_private;
+	struct drm_map_list *list;
+	struct drm_local_map *map;
+	int ret;
+
+	list = &obj->map_list;
+	list->map = kzalloc(sizeof(struct drm_map_list), GFP_KERNEL);
+	if (list->map == NULL)
+		return -ENOMEM;
+	map = list->map;
+	map->type = _DRM_GEM;
+	map->size = obj->size;
+	map->handle = obj;
+
+	list->file_offset_node = drm_mm_search_free(&mm->offset_manager,
+					obj->size / PAGE_SIZE, 0, 0);
+	if (!list->file_offset_node) {
+		dev_err(dev->dev, "failed to allocate offset for bo %d\n",
+								obj->name);
+		ret = -ENOSPC;
+		goto free_it;
+	}
+	list->file_offset_node = drm_mm_get_block(list->file_offset_node,
+					obj->size / PAGE_SIZE, 0);
+	if (!list->file_offset_node) {
+		ret = -ENOMEM;
+		goto free_it;
+	}
+	list->hash.key = list->file_offset_node->start;
+	ret = drm_ht_insert_item(&mm->offset_hash, &list->hash);
+	if (ret) {
+		dev_err(dev->dev, "failed to add to map hash\n");
+		goto free_mm;
+	}
+	return 0;
+
+free_mm:
+	drm_mm_put_block(list->file_offset_node);
+free_it:
+	kfree(list->map);
+	list->map = NULL;
+	return ret;
+}
drivers/staging/gma500/gem_glue.h +1 -1
index c38285b..a0f2bc4 100644
@@ -1,4 +1,4 @@
 extern void drm_gem_object_release_wrap(struct drm_gem_object *obj);
 extern int drm_gem_private_object_init(struct drm_device *dev,
 			struct drm_gem_object *obj, size_t size);
-
+extern int gem_create_mmap_offset(struct drm_gem_object *obj);
drivers/staging/gma500/psb_gem.c +1 -55

68 lines not on this page · raw message

author
#16 lore raw

PATCH 16/49 gma500: Extract BIOSisy stuff from psb_drv

In reply to Alan Cox

From: Alan Cox <[email protected]>

This is too big already so lets rip out more of the device specific crud. It also means we pull the ugly stuff that needs work out of our main line of cleanup.

---

 drivers/staging/gma500/Makefile    |    1 
 drivers/staging/gma500/mrst_bios.c |  236 ++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/mrst_bios.h |   22 +++
 drivers/staging/gma500/psb_drv.c   |  209 --------------------------------
 4 files changed, 260 insertions(+), 208 deletions(-)
 create mode 100644 drivers/staging/gma500/mrst_bios.c
 create mode 100644 drivers/staging/gma500/mrst_bios.h
drivers/staging/gma500/Makefile +1 -0
index 4c9c475..fdaac63 100644
@@ -23,6 +23,7 @@ psb_gfx-y += gem_glue.o \
 	  psb_irq.o \
 	  mrst_crtc.o \
 	  mrst_lvds.o \
+	  mrst_bios.o \
 	  mdfld_output.o \
 	  mdfld_pyr_cmd.o \
 	  mdfld_tmd_vid.o \
drivers/staging/gma500/mrst_bios.c new file +236 -0

236 lines not on this page · raw message

drivers/staging/gma500/mrst_bios.h new file +22 -0
new file mode 100644
index 0000000..a257306
@@ -0,0 +1,22 @@
+/**************************************************************************
+ * Copyright (c) 2011, Intel Corporation.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ **************************************************************************/
+
+extern void mrst_get_fuse_settings(struct drm_device *dev);
+extern void mid_get_pci_revID(struct drm_psb_private *dev_priv);
+extern void mrst_get_vbt_data(struct drm_psb_private *dev_priv);
drivers/staging/gma500/psb_drv.c +1 -208

221 lines not on this page · raw message

author
#17 lore raw

PATCH 17/49 gma500: psb_fb tidy/cleanup pass

In reply to Alan Cox

From: Alan Cox <[email protected]>

Eliminate unused stuff and clean up the code ordering.

---

 drivers/staging/gma500/psb_drm.h |    4 -
 drivers/staging/gma500/psb_drv.c |    9 ---
 drivers/staging/gma500/psb_drv.h |    6 --
 drivers/staging/gma500/psb_fb.c  |  135 ++++++++------------------------------
 4 files changed, 29 insertions(+), 125 deletions(-)
drivers/staging/gma500/psb_drm.h +1 -3
index c541137..5dcf045 100644
@@ -145,8 +145,6 @@ struct drm_psb_register_rw_arg {
 
 /* Controlling the kernel modesetting buffers */
 
-#define DRM_PSB_KMS_OFF		0x00
-#define DRM_PSB_KMS_ON		0x01
 #define DRM_PSB_SIZES           0x07
 #define DRM_PSB_FUSE_REG	0x08
 #define DRM_PSB_DC_STATE	0x0A
@@ -155,7 +153,7 @@ struct drm_psb_register_rw_arg {
 #define DRM_PSB_STOLEN_MEMORY	0x0D
 #define DRM_PSB_REGISTER_RW	0x0E
 
-/**
+/*
  * NOTE: Add new commands here, but increment
  * the values below and increment their
  * corresponding defines where they're
drivers/staging/gma500/psb_drv.c +0 -9
index cbdc02c..0d65f75 100644
@@ -75,10 +75,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
  * Standard IOCTLs.
  */
 
-#define DRM_IOCTL_PSB_KMS_OFF	\
-		DRM_IO(DRM_PSB_KMS_OFF + DRM_COMMAND_BASE)
-#define DRM_IOCTL_PSB_KMS_ON	\
-		DRM_IO(DRM_PSB_KMS_ON + DRM_COMMAND_BASE)
 #define DRM_IOCTL_PSB_SIZES	\
 		DRM_IOR(DRM_PSB_SIZES + DRM_COMMAND_BASE, \
 			struct drm_psb_sizes_arg)
@@ -134,11 +130,6 @@ static int psb_dpst_bl_ioctl(struct drm_device *dev, void *data,
 	[DRM_IOCTL_NR(ioctl) - DRM_COMMAND_BASE] = {ioctl, flags, func}
 
 static struct drm_ioctl_desc psb_ioctls[] = {
-	PSB_IOCTL_DEF(DRM_IOCTL_PSB_KMS_OFF, psbfb_kms_off_ioctl,
-		      DRM_ROOT_ONLY),
-	PSB_IOCTL_DEF(DRM_IOCTL_PSB_KMS_ON,
-			psbfb_kms_on_ioctl,
-			DRM_ROOT_ONLY),
 	PSB_IOCTL_DEF(DRM_IOCTL_PSB_SIZES, psb_sizes_ioctl, DRM_AUTH),
 	PSB_IOCTL_DEF(DRM_IOCTL_PSB_DC_STATE, psb_dc_state_ioctl, DRM_AUTH),
 	PSB_IOCTL_DEF(DRM_IOCTL_PSB_ADB, psb_adb_ioctl, DRM_AUTH),
drivers/staging/gma500/psb_drv.h +0 -6
index 86abf26..3b2ee08 100644
@@ -704,12 +704,6 @@ extern int psb_intel_opregion_init(struct drm_device *dev);
 extern int psbfb_probed(struct drm_device *dev);
 extern int psbfb_remove(struct drm_device *dev,
 			struct drm_framebuffer *fb);
-extern int psbfb_kms_off_ioctl(struct drm_device *dev, void *data,
-			       struct drm_file *file_priv);
-extern int psbfb_kms_on_ioctl(struct drm_device *dev, void *data,
-			      struct drm_file *file_priv);
-extern void *psbfb_vdc_reg(struct drm_device* dev);
-
 /*
  * psb_2d.c
  */
drivers/staging/gma500/psb_fb.c +28 -107

284 lines not on this page · raw message

author
#18 lore raw

PATCH 18/49 gma500: Update the GEM todo

In reply to Alan Cox

From: Alan Cox <[email protected]>

We also pull out the undo side of the mmap offset processing so we can later push it into GEM where it belongs

---

 drivers/staging/gma500/gem_glue.c |    9 +++++++++
 drivers/staging/gma500/psb_gem.c  |   15 +--------------
 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/staging/gma500/gem_glue.c +9 -0
index 0e7364b..779ac1a 100644
@@ -42,6 +42,15 @@ int drm_gem_private_object_init(struct drm_device *dev,
 
 void drm_gem_object_release_wrap(struct drm_gem_object *obj)
 {
+	/* Remove the list map if one is present */
+	if (obj->map_list.map) {
+		struct drm_gem_mm *mm = obj->dev->mm_private;
+		struct drm_map_list *list = &obj->map_list;
+		drm_ht_remove_item(&mm->offset_hash, &list->hash);
+		drm_mm_put_block(list->file_offset_node);
+		kfree(list->map);
+		list->map = NULL;
+	}
 	if (obj->filp)
 		drm_gem_object_release(obj);
 }
drivers/staging/gma500/psb_gem.c +1 -14
index 1e7faae..a63ad9e 100644
@@ -19,12 +19,8 @@
  * Authors: Alan Cox
  *
  * TODO:
- *	-	we don't actually put GEM objects into the GART yet
- *	-	we need to work out if the MMU is relevant as well (eg for
+ *	-	we need to work out if the MMU is relevant (eg for
  *		accelerated operations on a GEM object)
- *	-	cache coherency
- *
- * ie this is just an initial framework to get us going.
  */
 
 #include <drm/drmP.h>
@@ -40,15 +36,6 @@ int psb_gem_init_object(struct drm_gem_object *obj)
 void psb_gem_free_object(struct drm_gem_object *obj)
 {
 	struct gtt_range *gtt = container_of(obj, struct gtt_range, gem);
-	if (obj->map_list.map) {
-		/* Do things GEM should do for us */
-		struct drm_gem_mm *mm = obj->dev->mm_private;
-		struct drm_map_list *list = &obj->map_list;
-		drm_ht_remove_item(&mm->offset_hash, &list->hash);
-		drm_mm_put_block(list->file_offset_node);
-		kfree(list->map);
-		list->map = NULL;
-	}
 	drm_gem_object_release_wrap(obj);
 	/* This must occur last as it frees up the memory of the GEM object */
 	psb_gtt_free_range(obj->dev, gtt);
author
#19 lore raw

PATCH 19/49 gma500: Only fiddle with clock gating on PSB

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/psb_powermgmt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/gma500/psb_powermgmt.c +1 -1
index f837ab0..2253ecb 100644
@@ -64,7 +64,7 @@ void gma_power_init(struct drm_device *dev)
 	dev_priv->suspended = false;	/* And not suspended */
 	mutex_init(&power_mutex);
 
-	if (!IS_MRST(dev)) {
+	if (!IS_MRST(dev) && !IS_MFLD(dev)) {
 		/* FIXME: wants further review */
 		u32 gating = PSB_RSGX32(PSB_CR_CLKGATECTL);
 		/* Disable 2D clock gating */
author
#20 lore raw

PATCH 20/49 gma500: being abstracting out devices a bit more

In reply to Alan Cox

From: Alan Cox <[email protected]>

We really want to move towards a completely abstracted interface rather than having tons of per chip junk in the same files.

Begin with the power code which is probably the worst offender. Add a set of methods, initialise a dev_priv->ops pointer and rip the chip specifics out of the power code. While we are it pick up the display init bits.

So we know it's now chip specifics clean remove the psb_ naming from it.

---

 drivers/staging/gma500/Makefile        |    5 
 drivers/staging/gma500/mdfld_device.c  |  610 +++++++++++++++++++
 drivers/staging/gma500/mdfld_output.c  |   15 
 drivers/staging/gma500/mdfld_output.h  |    2 
 drivers/staging/gma500/mrst_device.c   |  230 +++++++
 drivers/staging/gma500/power.c         |  320 ++++++++++
 drivers/staging/gma500/psb_device.c    |  174 +++++
 drivers/staging/gma500/psb_drv.c       |   47 +
 drivers/staging/gma500/psb_drv.h       |   29 +
 drivers/staging/gma500/psb_fb.c        |   12 
 drivers/staging/gma500/psb_powermgmt.c | 1051 --------------------------------
 11 files changed, 1402 insertions(+), 1093 deletions(-)
 create mode 100644 drivers/staging/gma500/mdfld_device.c
 create mode 100644 drivers/staging/gma500/mrst_device.c
 create mode 100644 drivers/staging/gma500/power.c
 create mode 100644 drivers/staging/gma500/psb_device.c
 delete mode 100644 drivers/staging/gma500/psb_powermgmt.c
drivers/staging/gma500/Makefile +4 -1
index fdaac63..e93cbe3 100644
@@ -4,6 +4,7 @@
 ccflags-y += -Iinclude/drm
 
 psb_gfx-y += gem_glue.o \
+	  power.o \
 	  psb_bl.o \
 	  psb_drv.o \
 	  psb_gem.o \
@@ -19,11 +20,13 @@ psb_gfx-y += gem_glue.o \
 	  psb_intel_sdvo.o \
 	  psb_lid.o \
 	  psb_mmu.o \
-	  psb_powermgmt.o \
 	  psb_irq.o \
+	  psb_device.o \
+	  mrst_device.o \
 	  mrst_crtc.o \
 	  mrst_lvds.o \
 	  mrst_bios.o \
+	  mdfld_device.o \
 	  mdfld_output.o \
 	  mdfld_pyr_cmd.o \
 	  mdfld_tmd_vid.o \
drivers/staging/gma500/mdfld_device.c new file +610 -0

610 lines not on this page · raw message

drivers/staging/gma500/mdfld_output.c +12 -3
index b1fc765..7e11401 100644
@@ -63,14 +63,20 @@ int mdfld_panel_dpi(struct drm_device *dev)
 	}
 }
 
-static void init_panel(struct drm_device *dev, int mipi_pipe, int p_type)
+static int init_panel(struct drm_device *dev, int mipi_pipe, int p_type)
 {
 	struct panel_funcs *p_cmd_funcs;
 	struct panel_funcs *p_vid_funcs;
 
 	/* Oh boy ... FIXME */
 	p_cmd_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
+	if (p_cmd_funcs == NULL)
+		return -ENODEV;
 	p_vid_funcs = kzalloc(sizeof(struct panel_funcs), GFP_KERNEL);
+	if (p_vid_funcs == NULL) {
+		kfree(p_cmd_funcs);
+		return -ENODEV;
+	}
 
 	switch (p_type) {
 	case TPO_CMD:
@@ -115,11 +121,12 @@ static void init_panel(struct drm_device *dev, int mipi_pipe, int p_type)
 #endif
 	default:
 		dev_err(dev->dev, "Unsupported interface %d", p_type);
-		break;
+		return -ENODEV;
 	}
+	return 0;
 }
 
-void mdfld_output_init(struct drm_device *dev)
+int mdfld_output_init(struct drm_device *dev)
 {
 	int type;
 
@@ -132,4 +139,6 @@ void mdfld_output_init(struct drm_device *dev)
 	type = mdfld_get_panel_type(dev, 2);
 	dev_info(dev->dev, "panel 2: type is %d\n", type);
 	init_panel(dev, 2, type);
+
+	return 0;
 }
drivers/staging/gma500/mdfld_output.h +1 -1
index 36f43e1..53b57db 100644
@@ -69,7 +69,7 @@ struct panel_funcs {
 	int (*get_panel_info) (struct drm_device *, int, struct panel_info *);
 };
 
-void mdfld_output_init(struct drm_device *dev);
+int mdfld_output_init(struct drm_device *dev);
 int mdfld_panel_dpi(struct drm_device *dev);
 int mdfld_get_panel_type(struct drm_device *dev, int pipe);
 void mdfld_disable_crtc (struct drm_device *dev, int pipe);
drivers/staging/gma500/mrst_device.c new file +230 -0

230 lines not on this page · raw message

drivers/staging/gma500/power.c new file +320 -0

320 lines not on this page · raw message

drivers/staging/gma500/psb_device.c new file +174 -0

174 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +23 -24

71 lines not on this page · raw message

drivers/staging/gma500/psb_drv.h +27 -2
index 3b2ee08..d1c49e7 100644
@@ -258,11 +258,11 @@ struct psb_intel_opregion {
 	int enabled;
 };
 
+struct psb_ops;
 
 struct drm_psb_private {
 	struct drm_device *dev;
-
-	unsigned long chipset;
+	const struct psb_ops *ops;
 
 	struct psb_gtt *pg;
 
@@ -612,6 +612,23 @@ struct drm_psb_private {
 };
 
 
+/*
+ *	Operations for each board type
+ */
+ 
+struct psb_ops {
+	/* Display management hooks */
+	int (*output_init)(struct drm_device *dev);
+	/* Power management hooks */
+	void (*init_pm)(struct drm_device *dev);
+	int (*save_regs)(struct drm_device *dev);
+	int (*restore_regs)(struct drm_device *dev);
+	int (*power_up)(struct drm_device *dev);
+	int (*power_down)(struct drm_device *dev);
+};
+
+
+
 struct psb_mmu_driver;
 
 extern int drm_crtc_probe_output_modes(struct drm_device *dev, int, int);
@@ -761,6 +778,14 @@ extern int psb_gem_dumb_map_gtt(struct drm_file *file, struct drm_device *dev,
 			 uint32_t handle, uint64_t *offset);
 extern int psb_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf);
 
+/* psb_device.c */
+extern const struct psb_ops psb_chip_ops;
+
+/* mrst_device.c */
+extern const struct psb_ops mrst_chip_ops;
+
+/* mdfld_device.c */
+extern const struct psb_ops mdfld_chip_ops;
 
 /*
  * Debug print bits setting
drivers/staging/gma500/psb_fb.c +1 -11
index 83095fc..32d9016 100644
@@ -725,17 +725,7 @@ static void psb_setup_outputs(struct drm_device *dev)
 	drm_mode_create_scaling_mode_property(dev);
 	psb_create_backlight_property(dev);
 
-	if (IS_MRST(dev)) {
-		if (dev_priv->iLVDS_enable)
-			mrst_lvds_init(dev, &dev_priv->mode_dev);
-		else
-			dev_err(dev->dev, "DSI is not supported\n");
-	} else if (IS_MFLD(dev)) {
-		mdfld_output_init(dev);
-	} else {
-		psb_intel_lvds_init(dev, &dev_priv->mode_dev);
-		psb_intel_sdvo_init(dev, SDVOB);
-	}
+	dev_priv->ops->output_init(dev);
 
 	list_for_each_entry(connector, &dev->mode_config.connector_list,
 			    head) {
drivers/staging/gma500/psb_powermgmt.c deleted +0 -1051

1,051 lines not on this page · raw message

author
#21 lore raw

PATCH 21/49 gma500: continue abstracting platform specific code

In reply to Alan Cox

From: Alan Cox <[email protected]>

Next obvious target - backlight support

---

 drivers/staging/gma500/Makefile           |    2 
 drivers/staging/gma500/backlight.c        |   46 +++++
 drivers/staging/gma500/mdfld_device.c     |   94 ++++++++++
 drivers/staging/gma500/mdfld_dsi_output.c |   11 +
 drivers/staging/gma500/mrst_device.c      |  137 ++++++++++++++
 drivers/staging/gma500/psb_bl.c           |  283 -----------------------------
 drivers/staging/gma500/psb_device.c       |  125 +++++++++++++
 drivers/staging/gma500/psb_drv.c          |   20 +-
 drivers/staging/gma500/psb_drv.h          |   15 +-
 drivers/staging/gma500/psb_intel_lvds.c   |   31 ++-
 10 files changed, 445 insertions(+), 319 deletions(-)
 create mode 100644 drivers/staging/gma500/backlight.c
 delete mode 100644 drivers/staging/gma500/psb_bl.c
drivers/staging/gma500/Makefile +1 -1
index e93cbe3..dc02b2f 100644
@@ -4,8 +4,8 @@
 ccflags-y += -Iinclude/drm
 
 psb_gfx-y += gem_glue.o \
+	  backlight.o \
 	  power.o \
-	  psb_bl.o \
 	  psb_drv.o \
 	  psb_gem.o \
 	  psb_fb.o \
drivers/staging/gma500/backlight.c new file +46 -0

46 lines not on this page · raw message

drivers/staging/gma500/mdfld_device.c +93 -1

112 lines not on this page · raw message

drivers/staging/gma500/mdfld_dsi_output.c +7 -4
index 44ee3f6..b88dfc2 100644
@@ -468,6 +468,7 @@ static int mdfld_dsi_connector_set_property(struct drm_connector * connector,
 {
 	struct drm_encoder * encoder = connector->encoder;
 	struct backlight_device * psb_bd;
+	struct drm_psb_private * dev_priv = encoder->dev->dev_private;
 
 	if (!strcmp(property->name, "scaling mode") && encoder) {
 		struct psb_intel_crtc * psb_crtc = to_psb_intel_crtc(encoder->crtc);
@@ -512,6 +513,7 @@ static int mdfld_dsi_connector_set_property(struct drm_connector * connector,
 						     &psb_crtc->saved_adjusted_mode);
 			}
 		}
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
 	} else if (!strcmp(property->name, "backlight") && encoder) {
 		dev_dbg(encoder->dev->dev, "backlight level = %d\n", (int)value);
 		if (drm_connector_property_set_value(connector, property, value))
@@ -519,20 +521,21 @@ static int mdfld_dsi_connector_set_property(struct drm_connector * connector,
 		else {
 			dev_dbg(encoder->dev->dev,
 			                "set brightness to %d", (int)value);
-			psb_bd = psb_get_backlight_device();
-			if(psb_bd) {
+			psb_bd = dev_priv->backlight_device;
+			if (psb_bd) {
 				psb_bd->props.brightness = value;
-				psb_set_brightness(psb_bd);
+				backlight_update_status(psb_bd);
 			}
 		}
 	} 
+#endif
 set_prop_done:
     return 0;
 set_prop_error:
     return -1;
 }
 
-static void mdfld_dsi_connector_destroy(struct drm_connector * connector)
+static void mdfld_dsi_connector_destroy(struct drm_connector *connector)
 {
 	struct psb_intel_output * psb_output = to_psb_intel_output(connector);
 	struct mdfld_dsi_connector * dsi_connector = MDFLD_DSI_CONNECTOR(psb_output);
drivers/staging/gma500/mrst_device.c +137 -0

156 lines not on this page · raw message

drivers/staging/gma500/psb_bl.c deleted +0 -283

283 lines not on this page · raw message

drivers/staging/gma500/psb_device.c +124 -1

154 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +12 -8
index 6c57234..bb6b68f 100644
@@ -261,7 +261,7 @@ static int psb_driver_unload(struct drm_device *dev)
 
 	/* Kill vblank etc here */
 
-	psb_backlight_exit(); /*writes minimum value to backlight HW reg */
+	gma_backlight_exit(dev);
 
 	if (drm_psb_no_fb == 0)
 		psb_modeset_cleanup(dev);
@@ -455,7 +455,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 
 		switch (psb_intel_output->type) {
 		case INTEL_OUTPUT_LVDS:
-			ret = psb_backlight_init(dev);
+			ret = gma_backlight_init(dev);
 			break;
 		}
 	}
@@ -554,12 +554,14 @@ static int psb_dpst_bl_ioctl(struct drm_device *dev, void *data,
 {
 	struct drm_psb_private *dev_priv = psb_priv(dev);
 	uint32_t *arg = data;
-	struct backlight_device bd;
+	struct backlight_device *bd = dev_priv->backlight_device;
 	dev_priv->blc_adj2 = *arg;
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-	bd.props.brightness = psb_get_brightness(&bd);
-	psb_set_brightness(&bd);
+	if (bd) {
+		bd->props.brightness = bd->ops->get_brightness(bd);
+		backlight_update_status(bd);
+	}
 #endif
 	return 0;
 }
@@ -569,12 +571,14 @@ static int psb_adb_ioctl(struct drm_device *dev, void *data,
 {
 	struct drm_psb_private *dev_priv = psb_priv(dev);
 	uint32_t *arg = data;
-	struct backlight_device bd;
+	struct backlight_device *bd = dev_priv->backlight_device;
 	dev_priv->blc_adj1 = *arg;
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-	bd.props.brightness = psb_get_brightness(&bd);
-	psb_set_brightness(&bd);
+	if (bd) {
+		bd->props.brightness = bd->ops->get_brightness(bd);
+		backlight_update_status(bd);
+	}
 #endif
 	return 0;
 }
drivers/staging/gma500/psb_drv.h +8 -7
index d1c49e7..b0908f2 100644
@@ -588,12 +588,12 @@ struct drm_psb_private {
 	 * Used for modifying backlight from
 	 * xrandr -- consider removing and using HAL instead
 	 */
+	struct backlight_device *backlight_device;
 	struct drm_property *backlight_property;
 	uint32_t blc_adj1;
 	uint32_t blc_adj2;
 
 	void *fbdev;
-
 	/* DPST state */
 	uint32_t dsr_idle_count;
 	bool is_in_idle;
@@ -625,6 +625,10 @@ struct psb_ops {
 	int (*restore_regs)(struct drm_device *dev);
 	int (*power_up)(struct drm_device *dev);
 	int (*power_down)(struct drm_device *dev);
+#ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
+	/* Backlight */
+	int (*backlight_init)(struct drm_device *dev);
+#endif
 };
 
 
@@ -744,12 +748,9 @@ extern void psb_modeset_init(struct drm_device *dev);
 extern void psb_modeset_cleanup(struct drm_device *dev);
 extern int psb_fbdev_init(struct drm_device *dev);
 
-/* psb_bl.c */
-int psb_backlight_init(struct drm_device *dev);
-void psb_backlight_exit(void);
-int psb_set_brightness(struct backlight_device *bd);
-int psb_get_brightness(struct backlight_device *bd);
-struct backlight_device *psb_get_backlight_device(void);
+/* backlight.c */
+int gma_backlight_init(struct drm_device *dev);
+void gma_backlight_exit(struct drm_device *dev);
 
 /* mrst_crtc.c */
 extern const struct drm_crtc_helper_funcs mrst_helper_funcs;
drivers/staging/gma500/psb_intel_lvds.c +17 -14
index 850d07d..41b96d2 100644
@@ -575,11 +575,12 @@ int psb_intel_lvds_set_property(struct drm_connector *connector,
 				       struct drm_property *property,
 				       uint64_t value)
 {
-	struct drm_encoder *pEncoder = connector->encoder;
+	struct drm_encoder *encoder = connector->encoder;
+	struct drm_psb_private *dev_priv = encoder->dev->dev_private;
 
-	if (!strcmp(property->name, "scaling mode") && pEncoder) {
+	if (!strcmp(property->name, "scaling mode") && encoder) {
 		struct psb_intel_crtc *pPsbCrtc =
-					to_psb_intel_crtc(pEncoder->crtc);
+					to_psb_intel_crtc(encoder->crtc);
 		uint64_t curValue;
 
 		if (!pPsbCrtc)
@@ -611,29 +612,31 @@ int psb_intel_lvds_set_property(struct drm_connector *connector,
 
 		if (pPsbCrtc->saved_mode.hdisplay != 0 &&
 		    pPsbCrtc->saved_mode.vdisplay != 0) {
-			if (!drm_crtc_helper_set_mode(pEncoder->crtc,
+			if (!drm_crtc_helper_set_mode(encoder->crtc,
 						      &pPsbCrtc->saved_mode,
-						      pEncoder->crtc->x,
-						      pEncoder->crtc->y,
-						      pEncoder->crtc->fb))
+						      encoder->crtc->x,
+						      encoder->crtc->y,
+						      encoder->crtc->fb))
 				goto set_prop_error;
 		}
-	} else if (!strcmp(property->name, "backlight") && pEncoder) {
+	} else if (!strcmp(property->name, "backlight") && encoder) {
 		if (drm_connector_property_set_value(connector,
 							property,
 							value))
 			goto set_prop_error;
 		else {
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
-			struct backlight_device bd;
-			bd.props.brightness = value;
-			psb_set_brightness(&bd);
+			struct backlight_device *bd = dev_priv->backlight_device;
+			if (bd) {
+        			bd->props.brightness = value;
+	        		backlight_update_status(bd);
+                        }
 #endif
 		}
-	} else if (!strcmp(property->name, "DPMS") && pEncoder) {
+	} else if (!strcmp(property->name, "DPMS") && encoder) {
 		struct drm_encoder_helper_funcs *pEncHFuncs
-						= pEncoder->helper_private;
-		pEncHFuncs->dpms(pEncoder, value);
+						= encoder->helper_private;
+		pEncHFuncs->dpms(encoder, value);
 	}
 
 set_prop_done:
author
#22 lore raw

PATCH 22/49 gma500: Fix early Medfield crash

In reply to Alan Cox

From: Alan Cox <[email protected]>

We need to initialise the DBI interface and the code for it got missed in the original merge as it's in a daft place. This will need moving but lets get it added first.

---

 drivers/staging/gma500/psb_drv.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/staging/gma500/psb_drv.c +12 -0
index bb6b68f..dfb3f3a 100644
@@ -28,6 +28,7 @@
 #include "psb_intel_reg.h"
 #include "psb_intel_bios.h"
 #include "mrst_bios.h"
+#include "mdfld_dsi_dbi.h"
 #include <drm/drm_pciids.h>
 #include "psb_powermgmt.h"
 #include <linux/cpu.h>
@@ -442,6 +443,17 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 
 	dev->driver->get_vblank_counter = psb_get_vblank_counter;
 
+	/* FIXME: this is not the right place for this stuff ! */
+	if (IS_MFLD(dev)) {
+#ifdef CONFIG_MDFLD_DSI_DPU
+		/*init dpu info*/
+		mdfld_dbi_dpu_init(dev);
+#else 
+		mdfld_dbi_dsr_init(dev);
+#endif /*CONFIG_MDFLD_DSI_DPU*/
+		/* INIT_WORK(&dev_priv->te_work, mdfld_te_handler_work);*/
+	}
+
 	if (drm_psb_no_fb == 0) {
 		psb_modeset_init(dev);
 		psb_fbdev_init(dev);
author
#23 lore raw

PATCH 23/49 gma500: Read the GCT panel type information for Medfield

In reply to Alan Cox

From: Alan Cox <[email protected]>

Missed in the original merge work

---

 drivers/staging/gma500/mrst_bios.c |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
drivers/staging/gma500/mrst_bios.c +28 -1
index 0d944c4..103777b 100644
@@ -28,6 +28,12 @@
 #include "psb_drm.h"
 #include "psb_drv.h"
 #include "mrst_bios.h"
+#include "mdfld_output.h"
+
+static int panel_id;
+module_param_named(panel_id, panel_id, int, 0600);
+MODULE_PARM_DESC(panel_id, "Panel Identifier");
+
 
 void mrst_get_fuse_settings(struct drm_device *dev)
 {
@@ -231,6 +237,27 @@ void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
 		dev_err(dev->dev, "Unknown revision of GCT!\n");
 		vbt->size = 0;
 	}
-	/* FIXME: Need to sort out Medfield panel identifiers in future */
+	if (IS_MDFLD(dev_priv->dev)){
+		if (panel_id == GCT_DETECT) {
+			if (dev_priv->gct_data.bpi == 2) {
+				dev_info(dev->dev, "[GFX] PYR Panel Detected\n");
+				dev_priv->panel_id = PYR_CMD;
+				panel_id = PYR_CMD;
+			}
+			else if(dev_priv->gct_data.bpi == 0) {
+				dev_info(dev->dev, "[GFX] TMD Panel Detected.\n");
+				dev_priv->panel_id = TMD_VID;
+				panel_id = TMD_VID;
+			}
+			else {
+				dev_info(dev->dev, "[GFX] Default Panel (TPO)\n");
+				dev_priv->panel_id = TPO_CMD;
+				panel_id = TPO_CMD;
+			}
+		} else {
+			dev_info(dev->dev, "[GFX] Panel Parameter Passed in through cmd line\n");
+			dev_priv->panel_id = panel_id;
+		}
+	}
 }
 
author
#24 lore raw

PATCH 24/49 gma500: enable Medfield CRTC support

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/mdfld_intel_display.c |   33 ++++++++++++++++++++++++--
 drivers/staging/gma500/mdfld_output.h        |    3 ++
 drivers/staging/gma500/mrst_bios.c           |    4 ++-
 drivers/staging/gma500/psb_intel_display.c   |    9 +++----
 4 files changed, 39 insertions(+), 10 deletions(-)
drivers/staging/gma500/mdfld_intel_display.c +30 -3
index 26d7f80..0b619b6 100644
@@ -44,7 +44,6 @@
 /* Hardcoded currently */
 static int ksel = KSEL_CRYSTAL_19;
 
-extern struct drm_device *gpDrmDevice;
 extern void mdfld_save_display(struct drm_device *dev);
 extern bool gbgfxsuspended;
 
@@ -561,10 +560,10 @@ static void mdfld_crtc_dpms(struct drm_crtc *crtc, int mode)
 		return;
 
 	 /* Ignore if system is already in DSR and in suspended state. */
-	if(gbgfxsuspended && dev_priv->dispstatus == false && mode == 3){
+	if(/*gbgfxsuspended */0 && dev_priv->dispstatus == false && mode == 3){
 	    if(dev_priv->rpm_enabled && pipe == 1){
 	//          dev_priv->is_mipi_on = false;
-	            pm_request_idle(&gpDrmDevice->pdev->dev);
+	          pm_request_idle(&dev->pdev->dev);
 	    }
 	    return;
 	}else if(mode == 0) {
@@ -1386,3 +1385,31 @@ mrst_crtc_mode_set_exit:
 
 	return 0;
 }
+
+static void mdfld_crtc_prepare(struct drm_crtc *crtc)
+{
+	struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+	crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
+}
+
+static void mdfld_crtc_commit(struct drm_crtc *crtc)
+{
+	struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+	crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
+}
+
+static bool mdfld_crtc_mode_fixup(struct drm_crtc *crtc,
+				  struct drm_display_mode *mode,
+				  struct drm_display_mode *adjusted_mode)
+{
+	return true;
+}
+
+const struct drm_crtc_helper_funcs mdfld_helper_funcs = {
+	.dpms = mdfld_crtc_dpms,
+	.mode_fixup = mdfld_crtc_mode_fixup,
+	.mode_set = mdfld_crtc_mode_set,
+	.mode_set_base = mdfld__intel_pipe_set_base,
+	.prepare = mdfld_crtc_prepare,
+	.commit = mdfld_crtc_commit,
+};
drivers/staging/gma500/mdfld_output.h +3 -0
index 53b57db..70f2302a 100644
@@ -74,4 +74,7 @@ int mdfld_panel_dpi(struct drm_device *dev);
 int mdfld_get_panel_type(struct drm_device *dev, int pipe);
 void mdfld_disable_crtc (struct drm_device *dev, int pipe);
 
+extern const struct drm_crtc_helper_funcs mdfld_helper_funcs;
+extern const struct drm_crtc_funcs mdfld_intel_crtc_funcs;
+
 #endif
drivers/staging/gma500/mrst_bios.c +2 -2
index 103777b..c3707f4 100644
@@ -30,7 +30,7 @@
 #include "mrst_bios.h"
 #include "mdfld_output.h"
 
-static int panel_id;
+static int panel_id = GCT_DETECT;
 module_param_named(panel_id, panel_id, int, 0600);
 MODULE_PARM_DESC(panel_id, "Panel Identifier");
 
@@ -237,7 +237,7 @@ void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
 		dev_err(dev->dev, "Unknown revision of GCT!\n");
 		vbt->size = 0;
 	}
-	if (IS_MDFLD(dev_priv->dev)){
+	if (IS_MFLD(dev_priv->dev)){
 		if (panel_id == GCT_DETECT) {
 			if (dev_priv->gct_data.bpi == 2) {
 				dev_info(dev->dev, "[GFX] PYR Panel Detected\n");
drivers/staging/gma500/psb_intel_display.c +4 -5
index ba10849..0e9758a 100644
@@ -29,6 +29,7 @@
 #include "psb_intel_display.h"
 #include "psb_powermgmt.h"
 
+#include "mdfld_output.h"
 
 struct psb_intel_clock_t {
 	/* given values */
@@ -1303,12 +1304,10 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 		return;
 	}
 
-#if 0	/* FIXME */
 	if (IS_MFLD(dev))
 		drm_crtc_init(dev, &psb_intel_crtc->base,
-						&mfld_intel_crtc_funcs);
+						&mdfld_intel_crtc_funcs);
 	else
-#endif
         	drm_crtc_init(dev, &psb_intel_crtc->base,
 						&psb_intel_crtc_funcs);
 
@@ -1336,9 +1335,9 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 	if (IS_MRST(dev))
 		drm_crtc_helper_add(&psb_intel_crtc->base,
 				    &mrst_helper_funcs);
-/*	else if (IS_MDFLD(dev))
+	else if (IS_MFLD(dev))
 		drm_crtc_helper_add(&psb_intel_crtc->base,
-				    &mfld_helper_funcs); */
+				    &mdfld_helper_funcs);
 	else
 		drm_crtc_helper_add(&psb_intel_crtc->base,
 				    &psb_intel_helper_funcs);
author
#25 lore raw

PATCH 25/49 commit ee12661199b82934552c7636b10217a9aa42958a

In reply to Alan Cox

From: Jani Nikula <[email protected]>

gma500: fix build without backlight device support

Fix unmatched curly brackets when CONFIG_BACKLIGHT_CLASS_DEVICE is not defined.

---

 drivers/staging/gma500/mdfld_dsi_output.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/gma500/mdfld_dsi_output.c +1 -1
index b88dfc2..e911ef2 100644
@@ -527,8 +527,8 @@ static int mdfld_dsi_connector_set_property(struct drm_connector * connector,
 				backlight_update_status(psb_bd);
 			}
 		}
-	} 
 #endif
+	}
 set_prop_done:
     return 0;
 set_prop_error:
author
#27 lore raw

PATCH 26/49 gma500: add more ops

In reply to Alan Cox

From: Alan Cox <[email protected]>

Split the 2d properties, name, and various function vectors out so that we can get rid of more conditional gloop in favour of a per device structure.

---

 drivers/staging/gma500/mdfld_device.c      |    5 +++++
 drivers/staging/gma500/mrst_device.c       |    5 +++++
 drivers/staging/gma500/psb_device.c        |    5 +++++
 drivers/staging/gma500/psb_drv.h           |   11 +++++++++++
 drivers/staging/gma500/psb_fb.c            |    8 ++++----
 drivers/staging/gma500/psb_intel_display.c |   21 +++++----------------
 6 files changed, 35 insertions(+), 20 deletions(-)
drivers/staging/gma500/mdfld_device.c +5 -0
index e86e476..3955448 100644
@@ -687,6 +687,11 @@ static int mdfld_power_up(struct drm_device *dev)
 }
 
 const struct psb_ops mdfld_chip_ops = {
+	.name = "Medfield",
+	.accel_2d = 0,
+	.crtc_helper = &mdfld_helper_funcs,
+	.crtc_funcs = &mdfld_intel_crtc_funcs,
+
 	.output_init = mdfld_output_init,
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
drivers/staging/gma500/mrst_device.c +5 -0
index daeeb18..79cd784 100644
@@ -352,6 +352,11 @@ static int mrst_power_up(struct drm_device *dev)
 }
 
 const struct psb_ops mrst_chip_ops = {
+	.name = "Moorestown",
+	.accel_2d = 1,
+	.crtc_helper = &mrst_helper_funcs,
+	.crtc_funcs = &psb_intel_crtc_funcs,
+
 	.output_init = mrst_output_init,
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
drivers/staging/gma500/psb_device.c +5 -0
index 4a3c516..0402171 100644
@@ -282,6 +282,11 @@ int psb_power_up(struct drm_device *dev)
 }
 
 const struct psb_ops psb_chip_ops = {
+	.name = "Poulsbo",
+	.accel_2d = 1,
+	.crtc_helper = &psb_intel_helper_funcs,
+	.crtc_funcs = &psb_intel_crtc_funcs,
+
 	.output_init = psb_output_init,
 
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
drivers/staging/gma500/psb_drv.h +11 -0
index b0908f2..4bc5e8d 100644
@@ -617,6 +617,13 @@ struct drm_psb_private {
  */
  
 struct psb_ops {
+	const char *name;
+	unsigned int accel_2d:1;
+
+	/* Sub functions */
+	struct drm_crtc_helper_funcs const *crtc_helper;
+	struct drm_crtc_funcs const *crtc_funcs;
+
 	/* Display management hooks */
 	int (*output_init)(struct drm_device *dev);
 	/* Power management hooks */
@@ -759,6 +766,10 @@ extern const struct drm_crtc_helper_funcs mrst_helper_funcs;
 extern void mrst_lvds_init(struct drm_device *dev,
 		    struct psb_intel_mode_device *mode_dev);
 
+/* psb_intel_display.c */
+extern const struct drm_crtc_helper_funcs psb_intel_helper_funcs;
+extern const struct drm_crtc_funcs psb_intel_crtc_funcs;
+
 /* psb_intel_lvds.c */
 extern void psb_intel_lvds_prepare(struct drm_encoder *encoder);
 extern void psb_intel_lvds_commit(struct drm_encoder *encoder);
drivers/staging/gma500/psb_fb.c +4 -4
index 32d9016..349fff8 100644
@@ -211,7 +211,7 @@ static int psbfb_ioctl(struct fb_info *info, unsigned int cmd,
 	case 0x12345678:
 		if (!capable(CAP_SYS_RAWIO))
 			return -EPERM;
-		if (IS_MFLD(dev))
+		if (!dev_priv->ops->accel_2d)
 			return -EOPNOTSUPP;
 		if (get_user(l, p))
 			return -EFAULT;
@@ -240,7 +240,7 @@ static struct fb_ops psbfb_ops = {
 	.fb_ioctl = psbfb_ioctl,
 };
 
-static struct fb_ops psbfb_mfld_ops = {
+static struct fb_ops psbfb_unaccel_ops = {
 	.owner = THIS_MODULE,
 	.fb_check_var = drm_fb_helper_check_var,
 	.fb_set_par = drm_fb_helper_set_par,
@@ -426,8 +426,8 @@ static int psbfb_create(struct psb_fbdev *fbdev,
 
 	info->flags = FBINFO_DEFAULT;
 	/* No 2D engine */
-	if (IS_MFLD(dev))
-		info->fbops = &psbfb_mfld_ops;
+	if (!dev_priv->ops->accel_2d)
+		info->fbops = &psbfb_unaccel_ops;
 	else
 		info->fbops = &psbfb_ops;
 
drivers/staging/gma500/psb_intel_display.c +5 -16
index 0e9758a..c38e819 100644
@@ -1260,7 +1260,7 @@ void psb_intel_crtc_destroy(struct drm_crtc *crtc)
 	kfree(psb_intel_crtc);
 }
 
-static const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
+const struct drm_crtc_helper_funcs psb_intel_helper_funcs = {
 	.dpms = psb_intel_crtc_dpms,
 	.mode_fixup = psb_intel_crtc_mode_fixup,
 	.mode_set = psb_intel_crtc_mode_set,
@@ -1304,12 +1304,8 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 		return;
 	}
 
-	if (IS_MFLD(dev))
-		drm_crtc_init(dev, &psb_intel_crtc->base,
-						&mdfld_intel_crtc_funcs);
-	else
-        	drm_crtc_init(dev, &psb_intel_crtc->base,
-						&psb_intel_crtc_funcs);
+	/* Set the CRTC operations from the chip specific data */
+	drm_crtc_init(dev, &psb_intel_crtc->base, dev_priv->ops->crtc_funcs);
 
 	drm_mode_crtc_set_gamma_size(&psb_intel_crtc->base, 256);
 	psb_intel_crtc->pipe = pipe;
@@ -1332,15 +1328,8 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 	psb_intel_crtc->mode_dev = mode_dev;
 	psb_intel_crtc->cursor_addr = 0;
 
-	if (IS_MRST(dev))
-		drm_crtc_helper_add(&psb_intel_crtc->base,
-				    &mrst_helper_funcs);
-	else if (IS_MFLD(dev))
-		drm_crtc_helper_add(&psb_intel_crtc->base,
-				    &mdfld_helper_funcs);
-	else
-		drm_crtc_helper_add(&psb_intel_crtc->base,
-				    &psb_intel_helper_funcs);
+	drm_crtc_helper_add(&psb_intel_crtc->base,
+	                                dev_priv->ops->crtc_helper);
 
 	/* Setup the array of drm_connector pointer array */
 	psb_intel_crtc->mode_set.crtc = &psb_intel_crtc->base;
author
#28 lore raw

PATCH 27/49 gma500: remove an un-needed check

In reply to Alan Cox

From: Alan Cox <[email protected]>

This is a Medfield only path

---

 drivers/staging/gma500/mdfld_device.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/gma500/mdfld_device.c +1 -1
index 3955448..e66d04a 100644
@@ -589,7 +589,7 @@ static int mdfld_restore_display_registers(struct drm_device *dev, int pipe)
 		PSB_WVDC32(palette_val[i], palette_reg + (i<<2));
 	if (pipe == 1)
 		return 0;
-	if (IS_MFLD(dev) && !mdfld_panel_dpi(dev))
+	if (!mdfld_panel_dpi(dev))
 		mdfld_enable_te(dev, pipe);
 	return 0;
 }
author
#29 lore raw

PATCH 28/49 gma500: move configuration bits into the psb_ops structure

In reply to Alan Cox

From: Alan Cox <[email protected]>

We can stuff things like the number of pipes and the SGX offset away in here as well and clean up more conditional code.

---

 drivers/staging/gma500/mdfld_device.c |    6 +++
 drivers/staging/gma500/mrst_bios.c    |   14 ++++++-
 drivers/staging/gma500/mrst_bios.h    |    5 +--
 drivers/staging/gma500/mrst_device.c  |    5 +++
 drivers/staging/gma500/psb_device.c   |   54 ++++++++++++++++++++++++++-
 drivers/staging/gma500/psb_drv.c      |   65 +++------------------------------
 drivers/staging/gma500/psb_drv.h      |    5 +++
 7 files changed, 86 insertions(+), 68 deletions(-)
drivers/staging/gma500/mdfld_device.c +6 -0
index e66d04a..daa9487 100644
@@ -26,6 +26,7 @@
 #include "psb_drv.h"
 #include "mdfld_output.h"
 #include "mdfld_dsi_output.h"
+#include "mrst_bios.h"
 
 /*
  *	Provide the Medfield specific backlight management
@@ -689,6 +690,11 @@ static int mdfld_power_up(struct drm_device *dev)
 const struct psb_ops mdfld_chip_ops = {
 	.name = "Medfield",
 	.accel_2d = 0,
+	.pipes = 3,
+	.sgx_offset = MRST_SGX_OFFSET,
+
+	.chip_setup = mid_chip_setup,
+
 	.crtc_helper = &mdfld_helper_funcs,
 	.crtc_funcs = &mdfld_intel_crtc_funcs,
 
drivers/staging/gma500/mrst_bios.c +11 -3
index c3707f4..cf015df 100644
@@ -35,7 +35,7 @@ module_param_named(panel_id, panel_id, int, 0600);
 MODULE_PARM_DESC(panel_id, "Panel Identifier");
 
 
-void mrst_get_fuse_settings(struct drm_device *dev)
+static void mid_get_fuse_settings(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	struct pci_dev *pci_root = pci_get_bus_and_slot(0, 0);
@@ -102,7 +102,7 @@ void mrst_get_fuse_settings(struct drm_device *dev)
 /*
  *	Get the revison ID, B0:D2:F0;0x08
  */
-void mid_get_pci_revID(struct drm_psb_private *dev_priv)
+static void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 {
 	uint32_t platform_rev_id = 0;
 	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
@@ -114,7 +114,7 @@ void mid_get_pci_revID(struct drm_psb_private *dev_priv)
 					dev_priv->platform_rev_id);
 }
 
-void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
+static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 {
 	struct drm_device *dev = dev_priv->dev;
 	struct mrst_vbt *vbt = &dev_priv->vbt_data;
@@ -261,3 +261,11 @@ void mrst_get_vbt_data(struct drm_psb_private *dev_priv)
 	}
 }
 
+int mid_chip_setup(struct drm_device *dev)
+{
+	struct drm_psb_private *dev_priv = dev->dev_private;
+	mid_get_fuse_settings(dev);
+	mid_get_vbt_data(dev_priv);
+	mid_get_pci_revID(dev_priv);
+	return 0;
+}
\ No newline at end of file
drivers/staging/gma500/mrst_bios.h +2 -3
index a257306..00e7d56 100644
@@ -17,6 +17,5 @@
  *
  **************************************************************************/
 
-extern void mrst_get_fuse_settings(struct drm_device *dev);
-extern void mid_get_pci_revID(struct drm_psb_private *dev_priv);
-extern void mrst_get_vbt_data(struct drm_psb_private *dev_priv);
+extern int mid_chip_setup(struct drm_device *dev);
+
drivers/staging/gma500/mrst_device.c +5 -0
index 79cd784..d71e8d3 100644
@@ -25,6 +25,7 @@
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
 #include <asm/intel_scu_ipc.h>
+#include "mrst_bios.h"
 
 /* IPC message and command defines used to enable/disable mipi panel voltages */
 #define IPC_MSG_PANEL_ON_OFF    0xE9
@@ -354,6 +355,10 @@ static int mrst_power_up(struct drm_device *dev)
 const struct psb_ops mrst_chip_ops = {
 	.name = "Moorestown",
 	.accel_2d = 1,
+	.pipes = 1,
+	.sgx_offset = MRST_SGX_OFFSET,
+
+	.chip_setup = mid_chip_setup,
 	.crtc_helper = &mrst_helper_funcs,
 	.crtc_funcs = &psb_intel_crtc_funcs,
 
drivers/staging/gma500/psb_device.c +52 -2

71 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +5 -60

87 lines not on this page · raw message

drivers/staging/gma500/psb_drv.h +5 -0
index 4bc5e8d..7e6f178 100644
@@ -619,11 +619,16 @@ struct drm_psb_private {
 struct psb_ops {
 	const char *name;
 	unsigned int accel_2d:1;
+	int pipes;		/* Number of output pipes */
+	int sgx_offset;		/* Base offset of SGX device */
 
 	/* Sub functions */
 	struct drm_crtc_helper_funcs const *crtc_helper;
 	struct drm_crtc_funcs const *crtc_funcs;
 
+	/* Setup hooks */
+	int (*chip_setup)(struct drm_device *dev);
+
 	/* Display management hooks */
 	int (*output_init)(struct drm_device *dev);
 	/* Power management hooks */
author
#30 lore raw

PATCH 29/49 gma500: Add the beginnings of Cedarview support

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/Makefile     |    1 
 drivers/staging/gma500/cdv_device.c |  353 +++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_drv.c    |    8 +
 drivers/staging/gma500/psb_drv.h    |    3 
 4 files changed, 365 insertions(+), 0 deletions(-)
 create mode 100644 drivers/staging/gma500/cdv_device.c
drivers/staging/gma500/Makefile +1 -0
index dc02b2f..1b525ac 100644
@@ -22,6 +22,7 @@ psb_gfx-y += gem_glue.o \
 	  psb_mmu.o \
 	  psb_irq.o \
 	  psb_device.o \
+	  cdv_device.o \
 	  mrst_device.o \
 	  mrst_crtc.o \
 	  mrst_lvds.o \
drivers/staging/gma500/cdv_device.c new file +353 -0

353 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +8 -0
index b95d0a6..cf5fe91 100644
@@ -68,6 +68,14 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
+	{ 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+	{ 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
 	{ 0, 0, 0}
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
drivers/staging/gma500/psb_drv.h +3 -0
index 7e6f178..45035ec 100644
@@ -804,6 +804,9 @@ extern const struct psb_ops mrst_chip_ops;
 /* mdfld_device.c */
 extern const struct psb_ops mdfld_chip_ops;
 
+/* cdv_device.c */
+extern const struct psb_ops cdv_chip_ops;
+
 /*
  * Debug print bits setting
  */
author
#31 lore raw

PATCH 30/49 gma500: the 'mrst' BIOS is actually MID generic

In reply to Alan Cox

From: Alan Cox <[email protected]>

Shuffle the naming so this reflects better and we can try and build some sort of ordering to the naming scheme.

---

 drivers/staging/gma500/Makefile       |    2 
 drivers/staging/gma500/mdfld_device.c |    2 
 drivers/staging/gma500/mid_bios.c     |  271 +++++++++++++++++++++++++++++++++
 drivers/staging/gma500/mid_bios.h     |   21 +++
 drivers/staging/gma500/mrst_bios.c    |  271 ---------------------------------
 drivers/staging/gma500/mrst_bios.h    |   21 ---
 drivers/staging/gma500/mrst_device.c  |    2 
 drivers/staging/gma500/psb_drv.c      |    2 
 8 files changed, 296 insertions(+), 296 deletions(-)
 create mode 100644 drivers/staging/gma500/mid_bios.c
 create mode 100644 drivers/staging/gma500/mid_bios.h
 delete mode 100644 drivers/staging/gma500/mrst_bios.c
 delete mode 100644 drivers/staging/gma500/mrst_bios.h
drivers/staging/gma500/Makefile +1 -1
index 1b525ac..2ad6b1c 100644
@@ -23,10 +23,10 @@ psb_gfx-y += gem_glue.o \
 	  psb_irq.o \
 	  psb_device.o \
 	  cdv_device.o \
+	  mid_bios.o \
 	  mrst_device.o \
 	  mrst_crtc.o \
 	  mrst_lvds.o \
-	  mrst_bios.o \
 	  mdfld_device.o \
 	  mdfld_output.o \
 	  mdfld_pyr_cmd.o \
drivers/staging/gma500/mdfld_device.c +1 -1
index daa9487..f258b06 100644
@@ -26,7 +26,7 @@
 #include "psb_drv.h"
 #include "mdfld_output.h"
 #include "mdfld_dsi_output.h"
-#include "mrst_bios.h"
+#include "mid_bios.h"
 
 /*
  *	Provide the Medfield specific backlight management
drivers/staging/gma500/mid_bios.c new file +271 -0

272 lines not on this page · raw message

drivers/staging/gma500/mid_bios.h new file +21 -0
new file mode 100644
index 0000000..00e7d56
@@ -0,0 +1,21 @@
+/**************************************************************************
+ * Copyright (c) 2011, Intel Corporation.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ **************************************************************************/
+
+extern int mid_chip_setup(struct drm_device *dev);
+
drivers/staging/gma500/mrst_bios.c deleted +0 -271

272 lines not on this page · raw message

drivers/staging/gma500/mrst_bios.h deleted +0 -21
deleted file mode 100644
index 00e7d56..0000000
@@ -1,21 +0,0 @@
-/**************************************************************************
- * Copyright (c) 2011, Intel Corporation.
- * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- **************************************************************************/
-
-extern int mid_chip_setup(struct drm_device *dev);
-
drivers/staging/gma500/mrst_device.c +1 -1
index d71e8d3..195a25b 100644
@@ -25,7 +25,7 @@
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
 #include <asm/intel_scu_ipc.h>
-#include "mrst_bios.h"
+#include "mid_bios.h"
 
 /* IPC message and command defines used to enable/disable mipi panel voltages */
 #define IPC_MSG_PANEL_ON_OFF    0xE9
drivers/staging/gma500/psb_drv.c +1 -1
index cf5fe91..ba47178 100644
@@ -27,7 +27,7 @@
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_bios.h"
-#include "mrst_bios.h"
+#include "mid_bios.h"
 #include "mdfld_dsi_dbi.h"
 #include <drm/drm_pciids.h>
 #include "psb_powermgmt.h"
author
#32 lore raw

PATCH 31/49 gma500: tidy the framebuffer fixme and oddments

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/psb_fb.c |    6 +-----
 1 files changed, 1 insertions(+), 5 deletions(-)
drivers/staging/gma500/psb_fb.c +1 -5
index 349fff8..17c3cf6 100644
@@ -591,7 +591,6 @@ int psb_fbdev_init(struct drm_device *dev)
 {
 	struct psb_fbdev *fbdev;
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	int num_crtc;
 
 	fbdev = kzalloc(sizeof(struct psb_fbdev), GFP_KERNEL);
 	if (!fbdev) {
@@ -602,10 +601,7 @@ int psb_fbdev_init(struct drm_device *dev)
 	dev_priv->fbdev = fbdev;
 	fbdev->psb_fb_helper.funcs = &psb_fb_helper_funcs;
 
-	/* FIXME: check Medfield */
-	num_crtc = 2;
-
-	drm_fb_helper_init(dev, &fbdev->psb_fb_helper, num_crtc,
+	drm_fb_helper_init(dev, &fbdev->psb_fb_helper, 2,
 							INTELFB_CONN_LIMIT);
 
 	drm_fb_helper_single_add_all_connectors(&fbdev->psb_fb_helper);
author
#33 lore raw

PATCH 32/49 gma500: move framebuffer file

In reply to Alan Cox

From: Alan Cox <[email protected]>

The framebuffer code is now clean of device specific code, and passes checkpatch. Move it to its new name

---

 drivers/staging/gma500/Makefile              |    2 
 drivers/staging/gma500/framebuffer.c         |  803 ++++++++++++++++++++++++++
 drivers/staging/gma500/framebuffer.h         |   49 ++
 drivers/staging/gma500/mdfld_intel_display.c |    2 
 drivers/staging/gma500/mrst_crtc.c           |    2 
 drivers/staging/gma500/psb_2d.c              |    3 
 drivers/staging/gma500/psb_drv.c             |    2 
 drivers/staging/gma500/psb_fb.c              |  803 --------------------------
 drivers/staging/gma500/psb_fb.h              |   49 --
 drivers/staging/gma500/psb_intel_display.c   |    2 
 10 files changed, 858 insertions(+), 859 deletions(-)
 create mode 100644 drivers/staging/gma500/framebuffer.c
 create mode 100644 drivers/staging/gma500/framebuffer.h
 delete mode 100644 drivers/staging/gma500/psb_fb.c
 delete mode 100644 drivers/staging/gma500/psb_fb.h
drivers/staging/gma500/Makefile +1 -1
index 2ad6b1c..fb6040f0 100644
@@ -6,9 +6,9 @@ ccflags-y += -Iinclude/drm
 psb_gfx-y += gem_glue.o \
 	  backlight.o \
 	  power.o \
+	  framebuffer.o \
 	  psb_drv.o \
 	  psb_gem.o \
-	  psb_fb.o \
 	  psb_2d.o \
 	  psb_gtt.o \
 	  psb_intel_bios.o \
drivers/staging/gma500/framebuffer.c new file +803 -0

803 lines not on this page · raw message

drivers/staging/gma500/framebuffer.h new file +49 -0

49 lines not on this page · raw message

drivers/staging/gma500/mdfld_intel_display.c +1 -1
index 0b619b6..1447a5b 100644
@@ -24,7 +24,7 @@
  *	Eric Anholt <[email protected]>
  */
 
-#include "psb_fb.h"
+#include "framebuffer.h"
 #include "psb_intel_display.h"
 #include "mdfld_dsi_dbi.h"
 #include "mdfld_dsi_dpi.h"
drivers/staging/gma500/mrst_crtc.c +1 -1
index fb9f2a2..d12d1a6 100644
@@ -19,7 +19,7 @@
 #include <linux/pm_runtime.h>
 
 #include <drm/drmP.h>
-#include "psb_fb.h"
+#include "framebuffer.h"
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
drivers/staging/gma500/psb_2d.c +1 -2
index df4c519..5ca4c42 100644
@@ -38,8 +38,7 @@
 
 #include "psb_drv.h"
 #include "psb_reg.h"
-#include "psb_drv.h"
-#include "psb_fb.h"
+#include "framebuffer.h"
 
 /**
  *	psb_spank		-	reset the 2D engine
drivers/staging/gma500/psb_drv.c +1 -1
index ba47178..4114ffd 100644
@@ -23,7 +23,7 @@
 #include <drm/drm.h>
 #include "psb_drm.h"
 #include "psb_drv.h"
-#include "psb_fb.h"
+#include "framebuffer.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_bios.h"
drivers/staging/gma500/psb_fb.c deleted +0 -803

803 lines not on this page · raw message

drivers/staging/gma500/psb_fb.h deleted +0 -49

49 lines not on this page · raw message

drivers/staging/gma500/psb_intel_display.c +1 -1
index c38e819..0b650a0 100644
@@ -22,7 +22,7 @@
 #include <linux/pm_runtime.h>
 
 #include <drm/drmP.h>
-#include "psb_fb.h"
+#include "framebuffer.h"
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
author
#34 lore raw

PATCH 33/49 gma500: The 2D code is now also device independent

In reply to Alan Cox

From: Alan Cox <[email protected]>

Rename

---

 drivers/staging/gma500/Makefile   |    2 
 drivers/staging/gma500/accel_2d.c |  358 +++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_2d.c   |  358 -------------------------------------
 drivers/staging/gma500/psb_drv.h  |    4 
 4 files changed, 361 insertions(+), 361 deletions(-)
 create mode 100644 drivers/staging/gma500/accel_2d.c
 delete mode 100644 drivers/staging/gma500/psb_2d.c
drivers/staging/gma500/Makefile +1 -1
index fb6040f0..d2c0887 100644
@@ -4,12 +4,12 @@
 ccflags-y += -Iinclude/drm
 
 psb_gfx-y += gem_glue.o \
+	  accel_2d.o \
 	  backlight.o \
 	  power.o \
 	  framebuffer.o \
 	  psb_drv.o \
 	  psb_gem.o \
-	  psb_2d.o \
 	  psb_gtt.o \
 	  psb_intel_bios.o \
 	  psb_intel_opregion.o \
drivers/staging/gma500/accel_2d.c new file +358 -0

358 lines not on this page · raw message

drivers/staging/gma500/psb_2d.c deleted +0 -358

358 lines not on this page · raw message

drivers/staging/gma500/psb_drv.h +2 -2
index 45035ec..9c6aba5 100644
@@ -732,13 +732,13 @@ extern void mdfld_disable_te(struct drm_device *dev, int pipe);
 extern int psb_intel_opregion_init(struct drm_device *dev);
 
 /*
- *psb_fb.c
+ * framebuffer.c
  */
 extern int psbfb_probed(struct drm_device *dev);
 extern int psbfb_remove(struct drm_device *dev,
 			struct drm_framebuffer *fb);
 /*
- * psb_2d.c
+ * accel_2d.c
  */
 extern void psbfb_copyarea(struct fb_info *info,
 					const struct fb_copyarea *region);
author
#35 lore raw

PATCH 34/49 gma500: the GEM and GTT code is device independant

In reply to Alan Cox

From: Alan Cox <[email protected]>

Rename the gem and gtt files accordingly.

---

 drivers/staging/gma500/Makefile  |    6 
 drivers/staging/gma500/gem.c     |  252 ++++++++++++++++++++
 drivers/staging/gma500/gtt.c     |  487 ++++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/gtt.h     |   62 +++++
 drivers/staging/gma500/psb_drv.h |    2 
 drivers/staging/gma500/psb_gem.c |  252 --------------------
 drivers/staging/gma500/psb_gtt.c |  487 --------------------------------------
 drivers/staging/gma500/psb_gtt.h |   62 -----
 8 files changed, 805 insertions(+), 805 deletions(-)
 create mode 100644 drivers/staging/gma500/gem.c
 create mode 100644 drivers/staging/gma500/gtt.c
 create mode 100644 drivers/staging/gma500/gtt.h
 delete mode 100644 drivers/staging/gma500/psb_gem.c
 delete mode 100644 drivers/staging/gma500/psb_gtt.c
 delete mode 100644 drivers/staging/gma500/psb_gtt.h
drivers/staging/gma500/Makefile +3 -3
index d2c0887..0603949 100644
@@ -6,11 +6,11 @@ ccflags-y += -Iinclude/drm
 psb_gfx-y += gem_glue.o \
 	  accel_2d.o \
 	  backlight.o \
-	  power.o \
 	  framebuffer.o \
+	  gem.o \
+	  gtt.o \
+	  power.o \
 	  psb_drv.o \
-	  psb_gem.o \
-	  psb_gtt.o \
 	  psb_intel_bios.o \
 	  psb_intel_opregion.o \
 	  psb_intel_display.o \
drivers/staging/gma500/gem.c new file +252 -0

252 lines not on this page · raw message

drivers/staging/gma500/gtt.c new file +487 -0

487 lines not on this page · raw message

drivers/staging/gma500/gtt.h new file +62 -0

62 lines not on this page · raw message

drivers/staging/gma500/psb_drv.h +1 -1
index 9c6aba5..307ff9c 100644
@@ -29,7 +29,7 @@
 #include "psb_drm.h"
 #include "psb_reg.h"
 #include "psb_intel_drv.h"
-#include "psb_gtt.h"
+#include "gtt.h"
 #include "psb_powermgmt.h"
 #include "mrst.h"
 
drivers/staging/gma500/psb_gem.c deleted +0 -252

252 lines not on this page · raw message

drivers/staging/gma500/psb_gtt.c deleted +0 -487

487 lines not on this page · raw message

drivers/staging/gma500/psb_gtt.h deleted +0 -62

62 lines not on this page · raw message

#36 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Hi Alan,

Quoted 5 lines · Alan Cox

From: Alan Cox <[email protected]>

Rename the gem and gtt files accordingly.

This caught my eye, and I realize that I'm in the process of sabotaging your work, or vice versa: sorry!

Quoted 5 lines
(quoted diff) +5 -0
+
+	for (i = 0; i < pages; i++) {
+		/* FIXME: review flags later */
+		p = read_cache_page_gfp(mapping, i,
+					__GFP_COLD | GFP_KERNEL);

...

Review

Quoted 5 lines
(quoted diff) +0 -5
-
-	for (i = 0; i < pages; i++) {
-		/* FIXME: review flags later */
-		p = read_cache_page_gfp(mapping, i,
-					__GFP_COLD | GFP_KERNEL);

I've been eliminating drm/i915's calls to read_cache_page_gfp(), while you've been adding them to staging/gma500. It still works in 3.0-rc, but if my further changes go through from mmotm to 3.1-rc, then read_cache_page_gfp() on a shmem/tmpfs file will crash on the lack of a readpage method (we could easily make it error instead of crash, but you'd probably prefer something that actually works).

As example, below is the patch where I updated drm/i915 to be ready for the changeover. They set __GFP_RECLAIMABLE on the mapping because they've got a way to discard unpinned object pages when memory is tight; and sometimes add in __GFP_NORETRY|__GFP_NOWARN when allocating.

I'm guessing you'd just want to use shmem_read_mapping_page() throughout, after initializing mapping with the appropriate flags (GFP_HIGHUSER_MOVABLE is fs/inode.c's default: maybe your pages aren't easily movable and you'd better say GFP_HIGHUSER, or maybe you have reason to need GFP_KERNEL).

Hugh

commit 5949eac4d9b5bf936c12cb7ec3a09084c1326834

Author: Hugh Dickins <[email protected]>
Date:   Mon Jun 27 16:18:18 2011 -0700

drm/i915: use shmem_read_mapping_page

Soon tmpfs will stop supporting ->readpage and read_cache_page_gfp(): once "tmpfs: add shmem_read_mapping_page_gfp" has been applied, this patch can be applied to ease the transition.

Make i915_gem_object_get_pages_gtt() use shmem_read_mapping_page_gfp() in the one place it's needed; elsewhere use shmem_read_mapping_page(), with the mapping's gfp_mask properly initialized.

Forget about __GFP_COLD: since tmpfs initializes its pages with memset, asking for a cold page is counter-productive.

Include linux/shmem_fs.h also in drm_gem.c: with shmem_file_setup() now declared there too, we shall remove the prototype from linux/mm.h later.

Cc Christoph Hellwig <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Keith Packard <[email protected]>
Cc Dave Airlie <[email protected]>
drivers/gpu/drm/drm_gem.c +1 -0
index 74e4ff5..4012fe4 100644
@@ -34,6 +34,7 @@
 #include <linux/module.h>
 #include <linux/mman.h>
 #include <linux/pagemap.h>
+#include <linux/shmem_fs.h>
 #include "drmP.h"
 
 /** @file drm_gem.c
drivers/gpu/drm/i915/i915_gem.c +14 -17
index c6389de..fa560ce 100644
@@ -31,6 +31,7 @@
 #include "i915_drv.h"
 #include "i915_trace.h"
 #include "intel_drv.h"
+#include <linux/shmem_fs.h>
 #include <linux/slab.h>
 #include <linux/swap.h>
 #include <linux/pci.h>
@@ -359,8 +360,7 @@ i915_gem_shmem_pread_fast(struct drm_device *dev,
 		if ((page_offset + remain) > PAGE_SIZE)
 			page_length = PAGE_SIZE - page_offset;
 
-		page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT,
-					   GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
 		if (IS_ERR(page))
 			return PTR_ERR(page);
 
@@ -463,8 +463,7 @@ i915_gem_shmem_pread_slow(struct drm_device *dev,
 		if ((data_page_offset + page_length) > PAGE_SIZE)
 			page_length = PAGE_SIZE - data_page_offset;
 
-		page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT,
-					   GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
 			goto out;
@@ -797,8 +796,7 @@ i915_gem_shmem_pwrite_fast(struct drm_device *dev,
 		if ((page_offset + remain) > PAGE_SIZE)
 			page_length = PAGE_SIZE - page_offset;
 
-		page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT,
-					   GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
 		if (IS_ERR(page))
 			return PTR_ERR(page);
 
@@ -907,8 +905,7 @@ i915_gem_shmem_pwrite_slow(struct drm_device *dev,
 		if ((data_page_offset + page_length) > PAGE_SIZE)
 			page_length = PAGE_SIZE - data_page_offset;
 
-		page = read_cache_page_gfp(mapping, offset >> PAGE_SHIFT,
-					   GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		page = shmem_read_mapping_page(mapping, offset >> PAGE_SHIFT);
 		if (IS_ERR(page)) {
 			ret = PTR_ERR(page);
 			goto out;
@@ -1558,12 +1555,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj,
 
 	inode = obj->base.filp->f_path.dentry->d_inode;
 	mapping = inode->i_mapping;
+	gfpmask |= mapping_gfp_mask(mapping);
+
 	for (i = 0; i < page_count; i++) {
-		page = read_cache_page_gfp(mapping, i,
-					   GFP_HIGHUSER |
-					   __GFP_COLD |
-					   __GFP_RECLAIMABLE |
-					   gfpmask);
+		page = shmem_read_mapping_page_gfp(mapping, i, gfpmask);
 		if (IS_ERR(page))
 			goto err_pages;
 
@@ -3565,6 +3560,7 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_object *obj;
+	struct address_space *mapping;
 
 	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
 	if (obj == NULL)
@@ -3575,6 +3571,9 @@ struct drm_i915_gem_object *i915_gem_alloc_object(struct drm_device *dev,
 		return NULL;
 	}
 
+	mapping = obj->base.filp->f_path.dentry->d_inode->i_mapping;
+	mapping_set_gfp_mask(mapping, GFP_HIGHUSER | __GFP_RECLAIMABLE);
+
 	i915_gem_info_add_obj(dev_priv, size);
 
 	obj->base.write_domain = I915_GEM_DOMAIN_CPU;
@@ -3950,8 +3949,7 @@ void i915_gem_detach_phys_object(struct drm_device *dev,
 
 	page_count = obj->base.size / PAGE_SIZE;
 	for (i = 0; i < page_count; i++) {
-		struct page *page = read_cache_page_gfp(mapping, i,
-							GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		struct page *page = shmem_read_mapping_page(mapping, i);
 		if (!IS_ERR(page)) {
 			char *dst = kmap_atomic(page);
 			memcpy(dst, vaddr + i*PAGE_SIZE, PAGE_SIZE);
@@ -4012,8 +4010,7 @@ i915_gem_attach_phys_object(struct drm_device *dev,
 		struct page *page;
 		char *dst, *src;
 
-		page = read_cache_page_gfp(mapping, i,
-					   GFP_HIGHUSER | __GFP_RECLAIMABLE);
+		page = shmem_read_mapping_page(mapping, i);
 		if (IS_ERR(page))
 			return PTR_ERR(page);
 
author
#37 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 9 lines

As example, below is the patch where I updated drm/i915 to be ready for the changeover. They set __GFP_RECLAIMABLE on the mapping because they've got a way to discard unpinned object pages when memory is tight; and sometimes add in __GFP_NORETRY|__GFP_NOWARN when allocating.

I'm guessing you'd just want to use shmem_read_mapping_page() throughout, after initializing mapping with the appropriate flags (GFP_HIGHUSER_MOVABLE is fs/inode.c's default: maybe your pages aren't easily movable and you'd better say GFP_HIGHUSER, or maybe you have reason to need GFP_KERNEL).

I need the pages in the low 4GB ideally and have no way to release them if they are pinned. For the usage pattern I have that's not a problem.

At the moment the 4G isn't a problem either as you can't attach enough memory to cause problems to any of these devices.

What I don't entirely understand from your change is what stops another user task with the shmemfs file handle open from doing something else which changes the mapping flags, or is it guaranteed that only the mapping owner gets to play ?

Alan

#38 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 5 lines · Alan Cox
Quoted 5 lines

As example, below is the patch where I updated drm/i915 to be ready for the changeover. They set __GFP_RECLAIMABLE on the mapping because they've got a way to discard unpinned object pages when memory is tight; and sometimes add in __GFP_NORETRY|__GFP_NOWARN when allocating.

Quoted 7 lines
Quoted 4 lines

I'm guessing you'd just want to use shmem_read_mapping_page() throughout, after initializing mapping with the appropriate flags (GFP_HIGHUSER_MOVABLE is fs/inode.c's default: maybe your pages aren't easily movable and you'd better say GFP_HIGHUSER, or maybe you have reason to need GFP_KERNEL).

I need the pages in the low 4GB ideally and have no way to release them if they are pinned. For the usage pattern I have that's not a problem.

Maybe you'll want to use GFP_KERNEL | GFP_DMA32.

Quoted 9 lines

At the moment the 4G isn't a problem either as you can't attach enough memory to cause problems to any of these devices.

What I don't entirely understand from your change is what stops another user task with the shmemfs file handle open from doing something else which changes the mapping flags, or is it guaranteed that only the mapping owner gets to play ?

My changes (which were directed to eliminating shmem_readpage, which complicates shmem.c somewhat) haven't made any difference there: except that, like you, I'm wary of letting people mess with gfp flags all over, so preferred drm/i915 to set the right flags on the mapping initially, then add in the __GFP_NORETRY | __GFP_NOWARN in the one place needed, instead of using the _gfp()-modifying variant everywhere.

I don't think a user task has any interface to change the mapping flags, does it? But Linus freaked out a little 18 months ago when he noticed drm/i915 fiddling with mapping flags via mapping_set_gfp_mask() (whose declaration comments "This is non-atomic. Only to be used before the mapping is activated."), so gave them read_cache_page_gfp() instead.

I'd prefer we didn't have to support it, but i915 does have good use for it: so long as they only play with transient flags such as NORETRY (which will affect the allocation being made by the caller, but not affect mapping itself or concurrent allocations to it from elsewhere).

But your question does make me worry about when a page is brought back from swap. The swapin readahead code is liable to read in several pages with the same gfp mask as the page it's actually needing; but if adjacent swap locations have been used for pages of objects with different gfp needs, that could cause a problem. (NUMA mempolicy gets ignored by swapin in the same way.)

Your <4GB pages won't get swapped out while they're pinned. But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

I didn't care very deeply about the difference between __GFP_MOVABLE and __GFP_RECLAIMABLE in the i915 case, but your 4GB requirement sounds more important to get right (though you do say "ideally" above: if it's just a matter of slowdown, maybe we can ignore it for now).

Hugh

author
#39 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned. But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Alan

#40 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 7 lines · Alan Cox
Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned. But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Thanks, I won't worry about it at this moment, but we'd better not forget.

If it's easy for you to include a WARN_ON_ONCE check (perhaps on page_to_pfn(page)), that may be worth doing to remind us.

It's a bit sad to learn this requirement just after I'd completed removing the readpage copying code, and a bit strange to have shmem confined by hardware constraints; but I guess that's what we took on when we opened it up to GEM.

It will probably make sense for me to add synchronous migration when a shmem swap page is found not to match the contraints wanted by the mapping it goes into: mainly for NUMA, but covering your case too.

Hugh

#41 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 10 lines · Hugh Dickins
Quoted 7 lines · Alan Cox
Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned. But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Thanks, I won't worry about it at this moment, but we'd better not forget.

I recall seeing the GMA driver using the TTM at some point (but then those calls disappared), and I've written a patch to deal with a similar issue (where the DMA and the virtual address needed to be passed along to the code that programs the cards MMU).

It also survives suspend/resume, swap, etc.

https://lkml.org/lkml/2011/8/30/460

Don't know if it would be too complicated to make the GMA500 code use TTM, and the URL I posted still needs a review, but perhaps that could solve this problem in the future for you guys?

Quoted 19 lines

If it's easy for you to include a WARN_ON_ONCE check (perhaps on page_to_pfn(page)), that may be worth doing to remind us.

It's a bit sad to learn this requirement just after I'd completed removing the readpage copying code, and a bit strange to have shmem confined by hardware constraints; but I guess that's what we took on when we opened it up to GEM.

It will probably make sense for me to add synchronous migration when a shmem swap page is found not to match the contraints wanted by the mapping it goes into: mainly for NUMA, but covering your case too.

Hugh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

author
#42 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 2 lines

I recall seeing the GMA driver using the TTM at some point (but then those calls disappared),

The base code it came from still had bits of TTM stuff in that I was eliminating. The driver itself doesn't use TTM. It's GEM based and uses GEM extensively.

#43 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

In reply to Hugh Dickins
Quoted 19 lines · Hugh Dickins
Quoted 7 lines · Alan Cox
Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned.  But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Thanks, I won't worry about it at this moment, but we'd better not forget.

If it's easy for you to include a WARN_ON_ONCE check (perhaps on page_to_pfn(page)), that may be worth doing to remind us.

It's a bit sad to learn this requirement just after I'd completed removing the readpage copying code, and a bit strange to have shmem confined by hardware constraints; but I guess that's what we took on when we opened it up to GEM.

Quoted 5 lines

It will probably make sense for me to add synchronous migration when a shmem swap page is found not to match the contraints wanted by the mapping it goes into: mainly for NUMA, but covering your case too.

Hugh

I think we need to revisit this problem. On 3.1-rc4 with some of my own changes I've just triggered read_cache_page_gfp in psb_gtt_attach_pages when trying to set a resolution that doesn't fit in stolen memory. Replacing it with shmem_read_mapping_page seems to work but how do we go about solving the >4GB issue? Is it ok for now to just use shmem_read_mapping_page or did any of you have a better solution?

Thanks
Patrik

#44 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 24 lines · Patrik Jakobsson
Quoted 14 lines · Hugh Dickins
Quoted 7 lines · Alan Cox
Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned.  But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Thanks, I won't worry about it at this moment, but we'd better not forget.

If it's easy for you to include a WARN_ON_ONCE check (perhaps on page_to_pfn(page)), that may be worth doing to remind us.

Quoted 8 lines

It's a bit sad to learn this requirement just after I'd completed removing the readpage copying code, and a bit strange to have shmem confined by hardware constraints; but I guess that's what we took on when we opened it up to GEM.

It will probably make sense for me to add synchronous migration when a shmem swap page is found not to match the contraints wanted by the mapping it goes into: mainly for NUMA, but covering your case too.

Quoted 6 lines

I think we need to revisit this problem. On 3.1-rc4 with some of my own changes I've just triggered read_cache_page_gfp in psb_gtt_attach_pages when trying to set a resolution that doesn't fit in stolen memory. Replacing it with shmem_read_mapping_page seems to work but how do we go about solving the >4GB issue? Is it ok for now to just use shmem_read_mapping_page or did any of you have a better solution?

I was surprised to see drivers/staging/gma500 appearing still to use read_cache_page_gfp(). I assumed that since nobody was complaining, it must be on a currently unusable path. But you have code coming up, that now enables that path?

Am I right to think that your immediate problem is just the oops in __read_cache_page(), that you're not yet about to hit the 4GB issue?

I haven't rushed to address the 4GB issue, but what I have in mind is killing two-and-a-half birds with one stone, by putting a little cookie into the swapper_space radix_tree when we free a swapcache page, that specifies node/zone and hashes object/offset.

NUMA mempolicies are too complex to be encapsulated in a sizeof(long) cookie, but it should improve the common case after swapin; while solving your 4GB GEM case, and vastly speeding up swapoff.

Here's the kind of patch I imagined would be going in for gma500, that specifies __GFP_DMA32 on the mapping, so even swapoff can know that this object needs its pages below 4GB (even before my recent changes, swapoff would have broken you by inserting higher pages in the cache)
- once I implement that. But I've not tested this patch at all...

[PATCH] gma500: use shmem_read_mapping_page

In 3.1 onwards, read_cache_page_gfp() just oopses on GEM objects:
switch gma500 over to shmem_read_mapping_page() like i915. But when larger devices arrive, gma500 will need to keep its pages below 4GB, so specify __GFP_DMA32 (though that limit is not yet enforced in shmem.c).

---

 drivers/staging/gma500/framebuffer.c |    7 +++++++
 drivers/staging/gma500/gem.c         |    4 ++++
 drivers/staging/gma500/gtt.c         |    5 ++---
 3 files changed, 13 insertions(+), 3 deletions(-)
drivers/staging/gma500/framebuffer.c +7 -0
@@ -317,7 +317,9 @@ static struct drm_framebuffer *psb_frame
  */
 static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
 {
+	struct address_space *mapping;
 	struct gtt_range *backing;
+
 	/* Begin by trying to use stolen memory backing */
 	backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
 	if (backing) {
@@ -336,6 +338,11 @@ static struct gtt_range *psbfb_alloc(str
 		psb_gtt_free_range(dev, backing);
 		return NULL;
 	}
+
+	/* Specify that its pages be allocated below 4GB */
+	mapping = backing->gem.filp->f_path.dentry->d_inode->i_mapping;
+	mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
+
 	return backing;
 }
 
drivers/staging/gma500/gem.c +4 -0
@@ -104,6 +104,7 @@ unlock:
 static int psb_gem_create(struct drm_file *file,
 	struct drm_device *dev, uint64_t size, uint32_t *handlep)
 {
+	struct address_space *mapping;
 	struct gtt_range *r;
 	int ret;
 	u32 handle;
@@ -125,6 +126,9 @@ static int psb_gem_create(struct drm_fil
 		dev_err(dev->dev, "GEM init failed for %lld\n", size);
 		return -ENOMEM;
 	}
+	/* Specify that its pages be allocated below 4GB */
+	mapping = r->gem.filp->f_path.dentry->d_inode->i_mapping;
+	mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
 	/* Give the object a handle so we can carry it more easily */
 	ret = drm_gem_handle_create(file, &r->gem, &handle);
 	if (ret) {
drivers/staging/gma500/gtt.c +2 -3
@@ -20,6 +20,7 @@
  */
 
 #include <drm/drmP.h>
+#include <linux/shmem_fs.h>
 #include "psb_drv.h"
 
 
@@ -158,9 +159,7 @@ static int psb_gtt_attach_pages(struct g
 	gt->npage = pages;
 
 	for (i = 0; i < pages; i++) {
-		/* FIXME: review flags later */
-		p = read_cache_page_gfp(mapping, i,
-					__GFP_COLD | GFP_KERNEL);
+		p = shmem_read_mapping_page(mapping, i);
 		if (IS_ERR(p))
 			goto err;
 		gt->pages[i] = p;
#45 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 4 lines · Hugh Dickins

I was surprised to see drivers/staging/gma500 appearing still to use read_cache_page_gfp().  I assumed that since nobody was complaining, it must be on a currently unusable path.  But you have code coming up, that now enables that path?

Yes, I have a couple of patches for getting SDVO to properly set up DDC. It seems we hit that path when framebuffer size exceeds a certain limit.

Quoted 2 lines

Am I right to think that your immediate problem is just the oops in __read_cache_page(), that you're not yet about to hit the 4GB issue?

Correct, I have only seen 1GB and 2GB platforms so far. But the driver does support platforms that I haven't got my hands on yet.

Quoted 9 lines

I haven't rushed to address the 4GB issue, but what I have in mind is killing two-and-a-half birds with one stone, by putting a little cookie into the swapper_space radix_tree when we free a swapcache page, that specifies node/zone and hashes object/offset.

NUMA mempolicies are too complex to be encapsulated in a sizeof(long) cookie, but it should improve the common case after swapin; while solving your 4GB GEM case, and vastly speeding up swapoff.

Quoted 5 lines

Here's the kind of patch I imagined would be going in for gma500, that specifies __GFP_DMA32 on the mapping, so even swapoff can know that this object needs its pages below 4GB (even before my recent changes, swapoff would have broken you by inserting higher pages in the cache)
- once I implement that.  But I've not tested this patch at all...

There are some other issues with SDVO when running at higher resolutions that triggers the path. Will test your patch as soon as I get those things sorted out, though it looks ok to me.

Thanks
Patrik

#46 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

In reply to Hugh Dickins
Quoted 37 lines · Hugh Dickins
Quoted 24 lines · Patrik Jakobsson
Quoted 14 lines · Hugh Dickins
Quoted 7 lines · Alan Cox
Quoted 3 lines

Your <4GB pages won't get swapped out while they're pinned.  But can it happen that they'd be unpinned, swapped out, swapped back in >4GB pages, then cause trouble for you when needed again?

It does look that way, in which case that will eventually need fixing. At the moment you can't put enough memory into a device using these chips but that won't always be true I imagine.

Thanks, I won't worry about it at this moment, but we'd better not forget.

If it's easy for you to include a WARN_ON_ONCE check (perhaps on page_to_pfn(page)), that may be worth doing to remind us.

Quoted 8 lines

It's a bit sad to learn this requirement just after I'd completed removing the readpage copying code, and a bit strange to have shmem confined by hardware constraints; but I guess that's what we took on when we opened it up to GEM.

It will probably make sense for me to add synchronous migration when a shmem swap page is found not to match the contraints wanted by the mapping it goes into: mainly for NUMA, but covering your case too.

Quoted 6 lines

I think we need to revisit this problem. On 3.1-rc4 with some of my own changes I've just triggered read_cache_page_gfp in psb_gtt_attach_pages when trying to set a resolution that doesn't fit in stolen memory. Replacing it with shmem_read_mapping_page seems to work but how do we go about solving the >4GB issue? Is it ok for now to just use shmem_read_mapping_page or did any of you have a better solution?

I was surprised to see drivers/staging/gma500 appearing still to use read_cache_page_gfp().  I assumed that since nobody was complaining, it must be on a currently unusable path.  But you have code coming up, that now enables that path?

Quoted 7 lines

Am I right to think that your immediate problem is just the oops in __read_cache_page(), that you're not yet about to hit the 4GB issue?

I haven't rushed to address the 4GB issue, but what I have in mind is killing two-and-a-half birds with one stone, by putting a little cookie into the swapper_space radix_tree when we free a swapcache page, that specifies node/zone and hashes object/offset.

Without really knowing the details about how hard it would be to implement, it would solve one additional problem if we could have a per-mapping callback fxn for allocating pages.

At least on ARM (but I guess probably some other architectures too), we really want to avoid having a page mapped cachable in the kernel, and uncached/writecombine in userspace. With a per-mapping page allocation fxn, we could do something like dma_alloc_coherant/writecombine (for example) to allocate backing pages for GEM buffers which are mmap'd to userspace as something other than cachable.

BR,
-R

Quoted 91 lines

NUMA mempolicies are too complex to be encapsulated in a sizeof(long) cookie, but it should improve the common case after swapin; while solving your 4GB GEM case, and vastly speeding up swapoff.

Here's the kind of patch I imagined would be going in for gma500, that specifies __GFP_DMA32 on the mapping, so even swapoff can know that this object needs its pages below 4GB (even before my recent changes, swapoff would have broken you by inserting higher pages in the cache)
- once I implement that.  But I've not tested this patch at all...

[PATCH] gma500: use shmem_read_mapping_page

In 3.1 onwards, read_cache_page_gfp() just oopses on GEM objects:
switch gma500 over to shmem_read_mapping_page() like i915.  But when larger devices arrive, gma500 will need to keep its pages below 4GB, so specify __GFP_DMA32 (though that limit is not yet enforced in shmem.c).

---

 drivers/staging/gma500/framebuffer.c |    7 +++++++ drivers/staging/gma500/gem.c         |    4 ++++ drivers/staging/gma500/gtt.c         |    5 ++---

 3 files changed, 13 insertions(+), 3 deletions(-)
drivers/staging/gma500/framebuffer.c  2011-10-10 10:40:06.422389114 -0700 renamed from drivers/staging/gma500/framebuffer.c        2011-08-07 23:44:38.587914954 -0700 +7 -0
@@ -317,7 +317,9 @@ static struct drm_framebuffer *psb_frame
  */
  static struct gtt_range *psbfb_alloc(struct drm_device *dev, int aligned_size)
  {
+       struct address_space *mapping;
        struct gtt_range *backing;
+
        /* Begin by trying to use stolen memory backing */
        backing = psb_gtt_alloc_range(dev, aligned_size, "fb", 1);
        if (backing) {
@@ -336,6 +338,11 @@ static struct gtt_range *psbfb_alloc(str
                psb_gtt_free_range(dev, backing);
                return NULL;
        }
+
+       /* Specify that its pages be allocated below 4GB */
+       mapping = backing->gem.filp->f_path.dentry->d_inode->i_mapping;
+       mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
+
        return backing;
  }
 
drivers/staging/gma500/gem.c  2011-10-10 10:39:31.974219007 -0700 renamed from drivers/staging/gma500/gem.c        2011-08-07 23:44:38.587914954 -0700 +4 -0
@@ -104,6 +104,7 @@ unlock:
  static int psb_gem_create(struct drm_file *file,
        struct drm_device *dev, uint64_t size, uint32_t *handlep)
  {
+       struct address_space *mapping;
        struct gtt_range *r;
        int ret;
        u32 handle;
@@ -125,6 +126,9 @@ static int psb_gem_create(struct drm_fil
                dev_err(dev->dev, "GEM init failed for %lld\n", size);
                return -ENOMEM;
        }
+       /* Specify that its pages be allocated below 4GB */
+       mapping = r->gem.filp->f_path.dentry->d_inode->i_mapping;
+       mapping_set_gfp_mask(mapping, GFP_USER | __GFP_DMA32);
        /* Give the object a handle so we can carry it more easily */
        ret = drm_gem_handle_create(file, &r->gem, &handle);
        if (ret) {
drivers/staging/gma500/gtt.c  2011-10-10 10:19:31.424265313 -0700 renamed from drivers/staging/gma500/gtt.c        2011-08-07 23:44:38.591914970 -0700 +2 -3
@@ -20,6 +20,7 @@
  */
 
  #include <drm/drmP.h>
+#include <linux/shmem_fs.h>
  #include "psb_drv.h"
 
 
@@ -158,9 +159,7 @@ static int psb_gtt_attach_pages(struct g
        gt->npage = pages;
 
        for (i = 0; i < pages; i++) {
-               /* FIXME: review flags later */
-               p = read_cache_page_gfp(mapping, i,
-                                       __GFP_COLD | GFP_KERNEL);
+               p = shmem_read_mapping_page(mapping, i);
                if (IS_ERR(p))
                        goto err;
                gt->pages[i] = p;
#47 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 11 lines · Rob Clark
Quoted 5 lines · Hugh Dickins

I haven't rushed to address the 4GB issue, but what I have in mind is killing two-and-a-half birds with one stone, by putting a little cookie into the swapper_space radix_tree when we free a swapcache page, that specifies node/zone and hashes object/offset.

Without really knowing the details about how hard it would be to implement, it would solve one additional problem if we could have a per-mapping callback fxn for allocating pages.

Quoted 7 lines

At least on ARM (but I guess probably some other architectures too), we really want to avoid having a page mapped cachable in the kernel, and uncached/writecombine in userspace. With a per-mapping page allocation fxn, we could do something like dma_alloc_coherant/writecombine (for example) to allocate backing pages for GEM buffers which are mmap'd to userspace as something other than cachable.

It feels to me like GEM is pulling shmem in an ever more alien direction:
these device constraints are so foreign to the nature of tmpfs; and beyond my expertise, so that I'd be ever more likely to make the wrong decisions (mixing swap and uncached pages? hmmm).

We ought to re-examine whether GEM should be using tmpfs at all, whether it would be better served by its own filesystem or other infrastructure.

Really, the one reason for wanting tmpfs is to have the benefit of offload to swap (and that is indeed a feature I wouldn't care to distribute around to drivers).

Hugh

author
#48 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 4 lines

It feels to me like GEM is pulling shmem in an ever more alien direction:
these device constraints are so foreign to the nature of tmpfs; and beyond my expertise, so that I'd be ever more likely to make the wrong decisions (mixing swap and uncached pages? hmmm).

For the most part we fixed that. You can now have a GEM object that is backed by a private memory object rather than having to be tmpfs. GMA500 uses it to attach 'stolen' memory to GEM handles, and at least one other pending submission uses it with a private CMA style allocator.

The gma500 report seems an odd one - no GMA500 box has >4GB memory so how did the test code get a page that was unsuitable - is the test buggy ?

Alan

#49 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 9 lines · Alan Cox
Quoted 4 lines

It feels to me like GEM is pulling shmem in an ever more alien direction:
these device constraints are so foreign to the nature of tmpfs; and beyond my expertise, so that I'd be ever more likely to make the wrong decisions (mixing swap and uncached pages? hmmm).

For the most part we fixed that. You can now have a GEM object that is backed by a private memory object rather than having to be tmpfs. GMA500 uses it to attach 'stolen' memory to GEM handles, and at least one other pending submission uses it with a private CMA style allocator.

Sounds good.

Quoted 3 lines

The gma500 report seems an odd one - no GMA500 box has >4GB memory so how did the test code get a page that was unsuitable - is the test buggy ?

This is the first I heard of some gma500 test seeing a problem with >4GB.

In this thread we have Patrik hitting the oops in read_cache_page_gfp() because of some changes he is preparing, but I thought he and Rob were just thinking ahead when they raise the 4GB issue.

Can you point us to another thread on a another list?

Hugh

#50 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 6 lines · Hugh Dickins
Quoted 5 lines · Alan Cox
Quoted 4 lines

It feels to me like GEM is pulling shmem in an ever more alien direction:
these device constraints are so foreign to the nature of tmpfs; and beyond my expertise, so that I'd be ever more likely to make the wrong decisions (mixing swap and uncached pages? hmmm).

Quoted 6 lines
Quoted 4 lines

For the most part we fixed that. You can now have a GEM object that is backed by a private memory object rather than having to be tmpfs. GMA500 uses it to attach 'stolen' memory to GEM handles, and at least one other pending submission uses it with a private CMA style allocator.

Sounds good.

Well, that means we could implement our own shmem/tmpfs.. although I'm not entirely sure that I would want to.. a couple drm drivers are using private memory objects, but I think primarily for scanout buffers (which can't really be swapped out anyways). I don't think we'd want to use this for everything.

What troubles could you see for swap+uncached (or more likely, writecombine) pages?

BR,
-R

Quoted 14 lines
Quoted 3 lines

The gma500 report seems an odd one - no GMA500 box has >4GB memory so how did the test code get a page that was unsuitable - is the test buggy ?

This is the first I heard of some gma500 test seeing a problem with >4GB.

In this thread we have Patrik hitting the oops in read_cache_page_gfp() because of some changes he is preparing, but I thought he and Rob were just thinking ahead when they raise the 4GB issue.

Can you point us to another thread on a another list?

Hugh

author
#51 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 2 lines

What troubles could you see for swap+uncached (or more likely, writecombine) pages?

That should never occur. I would argue the driver is responsible for putting the cache state of the page back sensibly before it unpins it. That's a simple enough rule and one I think all the drivers follow at this point.

Alan

#52 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 7 lines · Alan Cox
Quoted 2 lines

What troubles could you see for swap+uncached (or more likely, writecombine) pages?

That should never occur. I would argue the driver is responsible for putting the cache state of the page back sensibly before it unpins it. That's a simple enough rule and one I think all the drivers follow at this point.

no, what I'm trying to avoid is having two virtual mappings to the same physical page with different cache attributes. This is not allowed on some architectures (like ARM)

BR,
-R

author
#53 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 4 lines · On Tue, 18 Oct 2011 06:59:28 -0500 Rob Clark <[email protected]> wrote:
Quoted 3 lines · Alan Cox
Quoted 2 lines

What troubles could you see for swap+uncached (or more likely, writecombine) pages?

Quoted 8 lines
Quoted 4 lines

That should never occur. I would argue the driver is responsible for putting the cache state of the page back sensibly before it unpins it. That's a simple enough rule and one I think all the drivers follow at this point.

no, what I'm trying to avoid is having two virtual mappings to the same physical page with different cache attributes. This is not allowed on some architectures (like ARM)

Nor x86... that's a matter for the core architecture code to deal with not the drivers.

Alan

#54 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

Quoted 12 lines · Alan Cox
Quoted 9 lines · On Tue, 18 Oct 2011 06:59:28 -0500 Rob Clark <[email protected]> wrote:
Quoted 7 lines · Alan Cox
Quoted 2 lines

What troubles could you see for swap+uncached (or more likely, writecombine) pages?

That should never occur. I would argue the driver is responsible for putting the cache state of the page back sensibly before it unpins it. That's a simple enough rule and one I think all the drivers follow at this point.

Quoted 7 lines
Quoted 3 lines

no, what I'm trying to avoid is having two virtual mappings to the same physical page with different cache attributes.  This is not allowed on some architectures (like ARM)

Nor x86... that's a matter for the core architecture code to deal with not the drivers.

hmm, maybe I'm missing something, but how is this ensured on x86? Default drm_gem_mmap() maps pages to userspace as writecombine.. but if page comes from kernel linear map (not highmem), that will be a cached kernel virtual mapping in addition to the wc userspace mapping.

BR,
-R

Quoted 2 lines

Alan

#55 lore raw

Re: [PATCH 34/49] gma500: the GEM and GTT code is device independant

In reply to Alan Cox
Quoted 5 lines · Alan Cox
Quoted 4 lines

It feels to me like GEM is pulling shmem in an ever more alien direction:
these device constraints are so foreign to the nature of tmpfs; and beyond my expertise, so that I'd be ever more likely to make the wrong decisions (mixing swap and uncached pages? hmmm).

Quoted 7 lines

For the most part we fixed that. You can now have a GEM object that is backed by a private memory object rather than having to be tmpfs. GMA500 uses it to attach 'stolen' memory to GEM handles, and at least one other pending submission uses it with a private CMA style allocator.

The gma500 report seems an odd one - no GMA500 box has >4GB memory so how did the test code get a page that was unsuitable - is the test buggy ?

Hi Alan

I didn't hit any >4GB issues but when I got SDVO working I tried setting 1920x1080 which needs more then the ~8MB that BIOS sets aside as stolen memory.

What happens is that a gem object outside stolen mem is created and when we try to pin it we go down the path:

psb_gtt_pin -> psb_gtt_attach_pages -> read_cache_page_gfp

This triggers the following oops:

-----

[   43.604167] BUG: unable to handle kernel NULL pointer dereference at   (null)
[   43.604349] IP: [<  (null)>]   (null)
[   43.604477] *pde = 00000000
[   43.604603] Oops: 0000 [#1] SMP
[   43.604778] Modules linked in: psb_gfx(C+) drm_kms_helper drm
agpgart i2c_algo_bit psmouse i2c_isch gpio_sch video coretemp lpc_sch
serio_raw usbhid hid r8169 mii
[   43.605746]
[   43.605825] Pid: 1255, comm: modprobe Tainted: G         C
3.1.0-rc4+ #13 CompuLab SBC-FITPC2/SBC-FITPC2
[   43.606089] EIP: 0060:[<00000000>] EFLAGS: 00010246 CPU: 1
[   43.606180] EIP is at 0x0
[   43.606261] EAX: 00000000 EBX: f62ea340 ECX: f5e04020 EDX: f62ea340
[   43.606351] ESI: f683f288 EDI: 00000000 EBP: f698bbb8 ESP: f698bb9c
[   43.606441]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[   43.606531] Process modprobe (pid: 1255, ti=f698a000 task=f4bb6500
task.ti=f698a000)
[   43.606641] Stack:
[   43.606718]  c10dbe31 000000d0 00000014 00000000 000001d0 00000000
f683f288 f698bbcc
[   43.607153]  c10dbf34 00000000 000001d0 f686f9c0 f698bbf4 f85afcee
f85aeb7a f6caf400
[   43.607582]  f683f288 f6f5205c 000007e9 fffffff4 f53cc600 f698bc7c
f698bc54 f85af0b2
[   43.608017] Call Trace:
[   43.608032]  [<c10dbe31>] ? do_read_cache_page+0x71/0x150
[   43.608032]  [<c10dbf34>] read_cache_page_gfp+0x24/0x30
[   43.608032]  [<f85afcee>] psb_gtt_pin+0xbe/0x220 [psb_gfx]
[   43.608032]  [<f85aeb7a>] ? psb_framebuffer_init+0x6a/0xa0 [psb_gfx]
[   43.608032]  [<f85af0b2>] psbfb_probe+0x3f2/0x460 [psb_gfx]
[   43.608032]  [<f80ccae7>] drm_fb_helper_single_fb_probe+0x127/0x2c0
[drm_kms_helper]
[   43.608032]  [<f80cce32>] drm_fb_helper_initial_config+0x1b2/0x210
[drm_kms_helper]
[   43.608032]  [<c1113ebe>] ? __kmalloc+0x13e/0x1d0
[   43.608032]  [<c1113c8d>] ? kmem_cache_alloc_trace+0xbd/0x120
[   43.608032]  [<f85af3e0>] psb_fbdev_init+0x70/0xb0 [psb_gfx]
[   43.608032]  [<f85b4c8e>] psb_driver_load+0x4ae/0x4c0 [psb_gfx]
[   43.608032]  [<f80a65a4>] drm_get_pci_dev+0x144/0x270 [drm]
[   43.608032]  [<c14a47cf>] ? _raw_spin_lock_irqsave+0x2f/0x50
[   43.608032]  [<f85b4642>] psb_probe+0x12/0x20 [psb_gfx]
[   43.608032]  [<c12609c7>] local_pci_probe+0x47/0xb0
[   43.608032]  [<c1261f08>] pci_device_probe+0x68/0x90
[   43.608032]  [<c12f0def>] driver_probe_device+0x7f/0x190
[   43.608032]  [<c1261e73>] ? pci_match_device+0xb3/0xc0
[   43.608032]  [<c12f0f81>] __driver_attach+0x81/0x90
[   43.608032]  [<c12f0f00>] ? driver_probe_device+0x190/0x190
[   43.608032]  [<c12f0048>] bus_for_each_dev+0x48/0x70
[   43.608032]  [<c1261920>] ? pci_pm_suspend+0x100/0x100
[   43.608032]  [<c12f0afe>] driver_attach+0x1e/0x20
[   43.608032]  [<c12f0f00>] ? driver_probe_device+0x190/0x190
[   43.608032]  [<c12f0718>] bus_add_driver+0xb8/0x250
[   43.608032]  [<c1261920>] ? pci_pm_suspend+0x100/0x100
[   43.608032]  [<c12f14d6>] driver_register+0x66/0x110
[   43.608032]  [<c1261035>] __pci_register_driver+0x45/0xb0
[   43.608032]  [<f80a67b1>] drm_pci_init+0xe1/0x110 [drm]
[   43.608032]  [<f8078012>] psb_init+0x12/0x1000 [psb_gfx]
[   43.608032]  [<c1001245>] do_one_initcall+0x35/0x170
[   43.608032]  [<f8078000>] ? 0xf8077fff
[   43.608032]  [<c107fcbb>] sys_init_module+0x13b/0x1aa0
[   43.608032]  [<c14ab21f>] sysenter_do_call+0x12/0x28
[   43.608032] Code:  Bad EIP value.
[   43.608032] EIP: [<00000000>] 0x0 SS:ESP 0068:f698bb9c
[   43.608032] CR2: 0000000000000000
[   43.612492] ---[ end trace 7c48b83f43438436 ]---
author
#56 lore raw

PATCH 35/49 gma500: begin the config based split

In reply to Alan Cox

From: Alan Cox <[email protected]>

We don't want to carry all the extra gunk around on every device so use the splitting work so far to tidy this up. Poulsbo is still mandatory as it is used in bits by the other drivers and not neatly modularised.

---

 drivers/staging/gma500/Kconfig   |   27 ++++++++++++++++++++++++---
 drivers/staging/gma500/Makefile  |   13 ++++++++-----
 drivers/staging/gma500/psb_drv.c |    9 ++++++++-
 drivers/staging/gma500/psb_irq.c |    5 ++++-
 4 files changed, 44 insertions(+), 10 deletions(-)
drivers/staging/gma500/Kconfig +24 -3
index ce8beda..bfe2166 100644
@@ -1,5 +1,5 @@
 config DRM_PSB
-	tristate "Intel GMA500 KMS Framebuffer"
+	tristate "Intel GMA5/600 KMS Framebuffer"
 	depends on DRM && PCI && X86
 	select FB_CFB_COPYAREA
         select FB_CFB_FILLRECT
@@ -7,6 +7,27 @@ config DRM_PSB
         select DRM_KMS_HELPER
         select DRM_TTM
 	help
-	  Say yes for an experimental KMS framebuffer driver for the
-	  Intel GMA500 ('Poulsbo') graphics support.
+	  Say yes for an experimental 2D KMS framebuffer driver for the
+	  Intel GMA500 ('Poulsbo') and other Intel IMG based graphics
+	  devices.
 
+config DRM_PSB_MRST
+	bool "Intel GMA600 support (Experimental)"
+	depends on DRM_PSB
+	help
+	  Say yes to include support for GMA600 (Intel Moorestown/Oaktrail)
+	  platforms with LVDS ports. HDMI and MIPI are not currently
+	  supported.
+
+config DRM_PSB_MFLD
+	bool "Intel Medfield support (Experimental)"
+	depends on DRM_PSB
+	help
+	  Say yes to include support for Intel Medfield platforms with MIPI
+	  interfaces.
+	
+config DRM_PSB_CDV
+	bool "Intel Cedarview support (Experimental)"
+	depends on DRM_PSB
+	help
+	  Say yes to include support for Intel Cedarview platforms
drivers/staging/gma500/Makefile +8 -5
index 0603949..aa60926 100644
@@ -22,12 +22,15 @@ psb_gfx-y += gem_glue.o \
 	  psb_mmu.o \
 	  psb_irq.o \
 	  psb_device.o \
-	  cdv_device.o \
-	  mid_bios.o \
-	  mrst_device.o \
+	  mid_bios.o
+
+psb_gfx-$(CONFIG_DRM_PSB_CDV) +=  cdv_device.o
+
+psb_gfx-$(CONFIG_DRM_PSB_MRST) += mrst_device.o \
 	  mrst_crtc.o \
-	  mrst_lvds.o \
-	  mdfld_device.o \
+	  mrst_lvds.o
+
+psb_gfx-$(CONFIG_DRM_PSB_MFLD) += mdfld_device.o \
 	  mdfld_output.o \
 	  mdfld_pyr_cmd.o \
 	  mdfld_tmd_vid.o \
drivers/staging/gma500/psb_drv.c +8 -1
index 4114ffd..69ab61b 100644
@@ -52,6 +52,7 @@ module_param_named(trap_pagefaults, drm_psb_trap_pagefaults, int, 0600);
 static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x8108, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
 	{ 0x8086, 0x8109, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &psb_chip_ops },
+#if defined(CONFIG_DRM_PSB_MRST)	
 	{ 0x8086, 0x4100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
 	{ 0x8086, 0x4101, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
 	{ 0x8086, 0x4102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
@@ -60,6 +61,8 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x4105, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
 	{ 0x8086, 0x4106, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
 	{ 0x8086, 0x4107, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mrst_chip_ops},
+#endif
+#if defined(CONFIG_DRM_PSB_MFLD)
 	{ 0x8086, 0x0130, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0131, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
@@ -68,6 +71,8 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x0135, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0136, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
 	{ 0x8086, 0x0137, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &mdfld_chip_ops},
+#endif
+#if defined(CONFIG_DRM_PSB_CDV)	
 	{ 0x8086, 0x0be0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
 	{ 0x8086, 0x0be1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
 	{ 0x8086, 0x0be2, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
@@ -76,6 +81,7 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 	{ 0x8086, 0x0be5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
 	{ 0x8086, 0x0be6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
 	{ 0x8086, 0x0be7, PCI_ANY_ID, PCI_ANY_ID, 0, 0, (long) &cdv_chip_ops},
+#endif	
 	{ 0, 0, 0}
 };
 MODULE_DEVICE_TABLE(pci, pciidlist);
@@ -396,6 +402,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 
 	dev->driver->get_vblank_counter = psb_get_vblank_counter;
 
+#if defined(CONFIG_DRM_PSB_MFLD)
 	/* FIXME: this is not the right place for this stuff ! */
 	if (IS_MFLD(dev)) {
 #ifdef CONFIG_MDFLD_DSI_DPU
@@ -406,7 +413,7 @@ static int psb_driver_load(struct drm_device *dev, unsigned long chipset)
 #endif /*CONFIG_MDFLD_DSI_DPU*/
 		/* INIT_WORK(&dev_priv->te_work, mdfld_te_handler_work);*/
 	}
-
+#endif
 	if (drm_psb_no_fb == 0) {
 		psb_modeset_init(dev);
 		psb_fbdev_init(dev);
drivers/staging/gma500/psb_irq.c +4 -1
index 3768cf1..8fc7070 100644
@@ -455,11 +455,12 @@ int psb_enable_vblank(struct drm_device *dev, int pipe)
 	uint32_t reg_val = 0;
 	uint32_t pipeconf_reg = mid_pipeconf(pipe);
 
+#if defined(CONFIG_DRM_PSB_MFLD)
 	/* Medfield is different - we should perhaps extract out vblank
 	   and blacklight etc ops */
 	if (IS_MFLD(dev) && !mdfld_panel_dpi(dev))
 		return mdfld_enable_te(dev, pipe);
-
+#endif
 	if (gma_power_begin(dev, false)) {
 		reg_val = REG_READ(pipeconf_reg);
 		gma_power_end(dev);
@@ -486,8 +487,10 @@ void psb_disable_vblank(struct drm_device *dev, int pipe)
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	unsigned long irqflags;
 
+#if defined(CONFIG_DRM_PSB_MFLD)
 	if (IS_MFLD(dev) && !mdfld_panel_dpi(dev))
 		mdfld_disable_te(dev, pipe);
+#endif
 	spin_lock_irqsave(&dev_priv->irqmask_lock, irqflags);
 
 	mid_disable_pipe_event(dev_priv, pipe);
author
#57 lore raw

PATCH 36/49 gma500: Rename the psb_intel_bios code

In reply to Alan Cox

From: Alan Cox <[email protected]>

This is generic for the PC class devices and also very similar to the i915 intel_bios.c so rename it. That way the commonality will be obvious and we can look at merging them one day, or at least synching them up.

---

 drivers/staging/gma500/Makefile         |    2 
 drivers/staging/gma500/intel_bios.c     |  299 +++++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_intel_bios.c |  299 -------------------------------
 3 files changed, 300 insertions(+), 300 deletions(-)
 create mode 100644 drivers/staging/gma500/intel_bios.c
 delete mode 100644 drivers/staging/gma500/psb_intel_bios.c
drivers/staging/gma500/Makefile +1 -1
index aa60926..7f76a19 100644
@@ -9,9 +9,9 @@ psb_gfx-y += gem_glue.o \
 	  framebuffer.o \
 	  gem.o \
 	  gtt.o \
+	  intel_bios.o \
 	  power.o \
 	  psb_drv.o \
-	  psb_intel_bios.o \
 	  psb_intel_opregion.o \
 	  psb_intel_display.o \
 	  psb_intel_i2c.o \
drivers/staging/gma500/intel_bios.c new file +299 -0

299 lines not on this page · raw message

drivers/staging/gma500/psb_intel_bios.c deleted +0 -299

299 lines not on this page · raw message

author
#58 lore raw

PATCH 37/49 gma500: tidy up the opregion and lid code

In reply to Alan Cox

From: Alan Cox <[email protected]>

This is leaking an io mapping and also referencing stuff directly that should not be directly accessed. Sort it out

---

 drivers/staging/gma500/cdv_device.c         |    2 +-
 drivers/staging/gma500/psb_device.c         |    2 +-
 drivers/staging/gma500/psb_drv.c            |    1 +
 drivers/staging/gma500/psb_drv.h            |    5 +++--
 drivers/staging/gma500/psb_intel_opregion.c |   14 +++++++++++---
 drivers/staging/gma500/psb_lid.c            |    6 +++---
 6 files changed, 20 insertions(+), 10 deletions(-)
drivers/staging/gma500/cdv_device.c +1 -1
index bb0b3f9..5131106 100644
@@ -321,7 +321,7 @@ static void cdv_get_core_freq(struct drm_device *dev)
 static int cdv_chip_setup(struct drm_device *dev)
 {
 	cdv_get_core_freq(dev);
-	psb_intel_opregion_init(dev);
+	intel_opregion_init(dev);
 	psb_intel_init_bios(dev);
 	return 0;
 }
drivers/staging/gma500/psb_device.c +1 -1
index 1be6434..8ac9de7 100644
@@ -322,7 +322,7 @@ static void psb_get_core_freq(struct drm_device *dev)
 static int psb_chip_setup(struct drm_device *dev)
 {
 	psb_get_core_freq(dev);
-	psb_intel_opregion_init(dev);
+	intel_opregion_init(dev);
 	psb_intel_init_bios(dev);
 	return 0;
 }
drivers/staging/gma500/psb_drv.c +1 -0
index 69ab61b..e9772ab 100644
@@ -245,6 +245,7 @@ static int psb_driver_unload(struct drm_device *dev)
 
 	if (dev_priv) {
 		psb_lid_timer_takedown(dev_priv);
+		intel_opregion_exit(dev);
 
 		psb_do_takedown(dev);
 
drivers/staging/gma500/psb_drv.h +3 -2
index 307ff9c..ee782fa 100644
@@ -727,9 +727,10 @@ extern int mdfld_enable_te(struct drm_device *dev, int pipe);
 extern void mdfld_disable_te(struct drm_device *dev, int pipe);
 
 /*
- * psb_opregion.c
+ * intel_opregion.c
  */
-extern int psb_intel_opregion_init(struct drm_device *dev);
+extern int intel_opregion_init(struct drm_device *dev);
+extern int intel_opregion_exit(struct drm_device *dev);
 
 /*
  * framebuffer.c
drivers/staging/gma500/psb_intel_opregion.c +11 -3
index 97a8b00..a586f3d 100644
@@ -47,10 +47,9 @@ struct opregion_acpi {
 	/*FIXME: add it later*/
 } __packed;
 
-int psb_intel_opregion_init(struct drm_device *dev)
+int intel_opregion_init(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	/*struct psb_intel_opregion * opregion = &dev_priv->opregion;*/
 	u32 opregion_phy;
 	void *base;
 	u32 *lid_state;
@@ -68,6 +67,15 @@ int psb_intel_opregion_init(struct drm_device *dev)
 	lid_state = base + 0x01ac;
 
 	dev_priv->lid_state = lid_state;
-	dev_priv->lid_last_state = *lid_state;
+	dev_priv->lid_last_state = readl(lid_state);
 	return 0;
 }
+
+int intel_opregion_exit(struct drm_device *dev)
+{
+	struct drm_psb_private *dev_priv = dev->dev_private;
+	if (dev_priv->lid_state)
+		iounmap(dev_priv->lid_state);
+	return 0;
+}
+	
\ No newline at end of file
drivers/staging/gma500/psb_lid.c +3 -3
index 21fd202..af32851 100644
@@ -32,10 +32,10 @@ static void psb_lid_timer_func(unsigned long data)
 	u32 *lid_state = dev_priv->lid_state;
 	u32 pp_status;
 
-	if (*lid_state == dev_priv->lid_last_state)
+	if (readl(lid_state) == dev_priv->lid_last_state)
 		goto lid_timer_schedule;
 
-	if ((*lid_state) & 0x01) {
+	if ((readl(lid_state)) & 0x01) {
 		/*lid state is open*/
 		REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON);
 		do {
@@ -54,7 +54,7 @@ static void psb_lid_timer_func(unsigned long data)
 	}
 		/* printk(KERN_INFO"%s: lid: closed\n", __FUNCTION__); */
 
-	dev_priv->lid_last_state =  *lid_state;
+	dev_priv->lid_last_state =  readl(lid_state);
 
 lid_timer_schedule:
 	spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
author
#59 lore raw

PATCH 38/49 gma500: move opregion files

In reply to Alan Cox

From: Alan Cox <[email protected]>

We've now sorted them out so they can go into the generic code. In actual fact only the non MID devices use the functions but they are small and having the name match i915 is going to help any future merging type work.

---

 drivers/staging/gma500/Makefile             |    2 -
 drivers/staging/gma500/intel_opregion.c     |   80 +++++++++++++++++++++++++++
 drivers/staging/gma500/psb_intel_opregion.c |   81 ---------------------------
 3 files changed, 81 insertions(+), 82 deletions(-)
 create mode 100644 drivers/staging/gma500/intel_opregion.c
 delete mode 100644 drivers/staging/gma500/psb_intel_opregion.c
drivers/staging/gma500/Makefile +1 -1
index 7f76a19..c014373 100644
@@ -10,9 +10,9 @@ psb_gfx-y += gem_glue.o \
 	  gem.o \
 	  gtt.o \
 	  intel_bios.o \
+	  intel_opregion.o \
 	  power.o \
 	  psb_drv.o \
-	  psb_intel_opregion.o \
 	  psb_intel_display.o \
 	  psb_intel_i2c.o \
 	  psb_intel_lvds.o \
drivers/staging/gma500/intel_opregion.c new file +80 -0

80 lines not on this page · raw message

drivers/staging/gma500/psb_intel_opregion.c deleted +0 -81

82 lines not on this page · raw message

author
#60 lore raw

PATCH 39/49 gma500: the MMU code is also generic

In reply to Alan Cox

From: Alan Cox <[email protected]>

Move this over. In actual fact there are some underlying differences as some devices have more MMU contexts, but for our 2D purposes we don't actually care.

---

 drivers/staging/gma500/Makefile  |    2 
 drivers/staging/gma500/mmu.c     |  858 ++++++++++++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_mmu.c |  858 --------------------------------------
 3 files changed, 859 insertions(+), 859 deletions(-)
 create mode 100644 drivers/staging/gma500/mmu.c
 delete mode 100644 drivers/staging/gma500/psb_mmu.c
drivers/staging/gma500/Makefile +1 -1
index c014373..d4a87c0 100644
@@ -11,6 +11,7 @@ psb_gfx-y += gem_glue.o \
 	  gtt.o \
 	  intel_bios.o \
 	  intel_opregion.o \
+	  mmu.o \
 	  power.o \
 	  psb_drv.o \
 	  psb_intel_display.o \
@@ -19,7 +20,6 @@ psb_gfx-y += gem_glue.o \
 	  psb_intel_modes.o \
 	  psb_intel_sdvo.o \
 	  psb_lid.o \
-	  psb_mmu.o \
 	  psb_irq.o \
 	  psb_device.o \
 	  mid_bios.o
drivers/staging/gma500/mmu.c new file +858 -0

858 lines not on this page · raw message

drivers/staging/gma500/psb_mmu.c deleted +0 -858

858 lines not on this page · raw message

author
#61 lore raw

PATCH 40/49 gma500: move the i2c code

In reply to Alan Cox

From: Alan Cox <[email protected]>

This again is similar to upstream so give it a sensible name ready to look at any merging or synchronization

---

 drivers/staging/gma500/Makefile        |    2 
 drivers/staging/gma500/intel_i2c.c     |  169 ++++++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_intel_i2c.c |  169 --------------------------------
 3 files changed, 170 insertions(+), 170 deletions(-)
 create mode 100644 drivers/staging/gma500/intel_i2c.c
 delete mode 100644 drivers/staging/gma500/psb_intel_i2c.c
drivers/staging/gma500/Makefile +1 -1
index d4a87c0..961a60c 100644
@@ -10,12 +10,12 @@ psb_gfx-y += gem_glue.o \
 	  gem.o \
 	  gtt.o \
 	  intel_bios.o \
+	  intel_i2c.o \
 	  intel_opregion.o \
 	  mmu.o \
 	  power.o \
 	  psb_drv.o \
 	  psb_intel_display.o \
-	  psb_intel_i2c.o \
 	  psb_intel_lvds.o \
 	  psb_intel_modes.o \
 	  psb_intel_sdvo.o \
drivers/staging/gma500/intel_i2c.c new file +169 -0

169 lines not on this page · raw message

drivers/staging/gma500/psb_intel_i2c.c deleted +0 -169

169 lines not on this page · raw message

author
#62 lore raw

PATCH 41/49 gma500: tidying up the power stuff a spot

In reply to Alan Cox

From: Alan Cox <[email protected]>

In particular don't destroy static mutexes, it upsets things

---

 drivers/staging/gma500/power.c |   33 +++++++++++++--------------------
 1 files changed, 13 insertions(+), 20 deletions(-)
drivers/staging/gma500/power.c +13 -20
index fc2324e..0eee7fb 100644
@@ -27,6 +27,7 @@
  * Massively reworked
  *    Alan Cox <[email protected]>
  */
+
 #include "psb_powermgmt.h"
 #include "psb_drv.h"
 #include "psb_reg.h"
@@ -34,7 +35,8 @@
 #include <linux/mutex.h>
 #include <linux/pm_runtime.h>
 
-static struct mutex power_mutex;
+static struct mutex power_mutex;	/* Serialize power ops */
+static struct mutex power_ctrl_mutex;	/* Serialize power claim */
 
 /**
  *	gma_power_init		-	initialise power manager
@@ -46,8 +48,7 @@ void gma_power_init(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 
-	/* FIXME: need to sort out fetching apm_reg for both platforms ?? */
-
+	/* FIXME: Move APM/OSPM base into relevant device code */
 	dev_priv->apm_base = dev_priv->apm_reg & 0xffff;
 	dev_priv->ospm_base &= 0xffff;
 
@@ -55,6 +56,7 @@ void gma_power_init(struct drm_device *dev)
 	dev_priv->display_count = 0;	/* Currently no users */
 	dev_priv->suspended = false;	/* And not suspended */
 	mutex_init(&power_mutex);
+	mutex_init(&power_ctrl_mutex);
 
 	dev_priv->ops->init_pm(dev);
 }
@@ -67,23 +69,15 @@ void gma_power_init(struct drm_device *dev)
  */
 void gma_power_uninit(struct drm_device *dev)
 {
-	mutex_destroy(&power_mutex);
 	pm_runtime_disable(&dev->pdev->dev);
 	pm_runtime_set_suspended(&dev->pdev->dev);
 }
 
-
-
-
 /**
  *	gma_suspend_display	-	suspend the display logic
  *	@dev: our DRM device
  *
  *	Suspend the display logic of the graphics interface
- *
- *	FIXME: This ought to be replaced by a dev_priv-> ops interface
- *	where the various platforms register their save/restore methods
- *	and keep them in their own support files.
  */
 static void gma_suspend_display(struct drm_device *dev)
 {
@@ -210,7 +204,6 @@ int gma_power_suspend(struct pci_dev *pdev, pm_message_t state)
 	return 0;
 }
 
-
 /**
  *	gma_power_resume		-	resume power
  *	@pdev: PCI device
@@ -230,8 +223,6 @@ int gma_power_resume(struct pci_dev *pdev)
 	return 0;
 }
 
-
-
 /**
  *	gma_power_is_on		-	returne true if power is on
  *	@dev: our DRM device
@@ -244,7 +235,6 @@ bool gma_power_is_on(struct drm_device *dev)
 	return dev_priv->display_power;
 }
 
-
 /**
  *	gma_power_begin		-	begin requiring power
  *	@dev: our DRM device
@@ -252,22 +242,22 @@ bool gma_power_is_on(struct drm_device *dev)
  *
  *	Begin an action that requires the display power island is enabled.
  *	We refcount the islands.
- *
- *	FIXME: locking
  */
 bool gma_power_begin(struct drm_device *dev, bool force_on)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	int ret;
 
+	mutex_lock(&power_ctrl_mutex);
 	/* Power already on ? */
 	if (dev_priv->display_power) {
 		dev_priv->display_count++;
 		pm_runtime_get(&dev->pdev->dev);
+		mutex_unlock(&power_ctrl_mutex);
 		return true;
 	}
 	if (force_on == false)
-		return false;
+		goto out_false;
 
 	/* Ok power up needed */
 	ret = gma_resume_pci(dev->pdev);
@@ -276,12 +266,14 @@ bool gma_power_begin(struct drm_device *dev, bool force_on)
 		psb_irq_postinstall(dev);
 		pm_runtime_get(&dev->pdev->dev);
 		dev_priv->display_count++;
+		mutex_unlock(&power_ctrl_mutex);
 		return true;
 	}
+out_false:
+	mutex_unlock(&power_ctrl_mutex);
 	return false;
 }
 
-
 /**
  *	gma_power_end		-	end use of power
  *	@dev: Our DRM device
@@ -292,8 +284,10 @@ bool gma_power_begin(struct drm_device *dev, bool force_on)
 void gma_power_end(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
+	mutex_lock(&power_ctrl_mutex);
 	dev_priv->display_count--;
 	WARN_ON(dev_priv->display_count < 0);
+	mutex_unlock(&power_ctrl_mutex);
 	pm_runtime_put(&dev->pdev->dev);
 }
 
@@ -317,4 +311,3 @@ int psb_runtime_idle(struct device *dev)
 	else
 		return 1;
 }
-
author
#63 lore raw

PATCH 42/49 gma500: move the BIOS header

In reply to Alan Cox

From: Alan Cox <[email protected]>

We can move this to patch up as well. Shuffle the relevant includes as we go

---

 drivers/staging/gma500/backlight.c      |    2 
 drivers/staging/gma500/cdv_device.c     |    2 
 drivers/staging/gma500/intel_bios.c     |    2 
 drivers/staging/gma500/intel_bios.h     |  430 +++++++++++++++++++++++++++++++
 drivers/staging/gma500/mrst_lvds.c      |    2 
 drivers/staging/gma500/psb_device.c     |    2 
 drivers/staging/gma500/psb_drv.c        |    2 
 drivers/staging/gma500/psb_intel_bios.h |  430 -------------------------------
 drivers/staging/gma500/psb_intel_lvds.c |    4 
 9 files changed, 437 insertions(+), 439 deletions(-)
 create mode 100644 drivers/staging/gma500/intel_bios.h
 delete mode 100644 drivers/staging/gma500/psb_intel_bios.h
drivers/staging/gma500/backlight.c +1 -1
index 47681c9..117649b 100644
@@ -23,7 +23,7 @@
 #include "psb_drv.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_drv.h"
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 #include "psb_powermgmt.h"
 
 int gma_backlight_init(struct drm_device *dev)
drivers/staging/gma500/cdv_device.c +1 -1
index 5131106..530e8a2 100644
@@ -24,7 +24,7 @@
 #include "psb_drv.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 
 
 static int cdv_output_init(struct drm_device *dev)
drivers/staging/gma500/intel_bios.c +1 -1
index 5b3e88c..1c4714d 100644
@@ -24,7 +24,7 @@
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 
 
 static void *find_section(struct bdb_header *bdb, int section_id)
drivers/staging/gma500/intel_bios.h new file +430 -0

430 lines not on this page · raw message

drivers/staging/gma500/mrst_lvds.c +1 -1
index a746571..9ecb99b 100644
@@ -24,7 +24,7 @@
 #include <drm/drmP.h>
 #include <asm/mrst.h>
 
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
drivers/staging/gma500/psb_device.c +1 -1
index 8ac9de7..0774c06 100644
@@ -24,7 +24,7 @@
 #include "psb_drv.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 
 
 static int psb_output_init(struct drm_device *dev)
drivers/staging/gma500/psb_drv.c +1 -1
index e9772ab..a7f3c08 100644
@@ -26,7 +26,7 @@
 #include "framebuffer.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 #include "mid_bios.h"
 #include "mdfld_dsi_dbi.h"
 #include <drm/drm_pciids.h>
drivers/staging/gma500/psb_intel_bios.h deleted +0 -430

430 lines not on this page · raw message

drivers/staging/gma500/psb_intel_lvds.c +1 -3
index 41b96d2..c9a13a4 100644
@@ -21,11 +21,9 @@
  */
 
 #include <linux/i2c.h>
-/* #include <drm/drm_crtc.h> */
-/* #include <drm/drm_edid.h> */
 #include <drm/drmP.h>
 
-#include "psb_intel_bios.h"
+#include "intel_bios.h"
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
author
#64 lore raw

PATCH 43/49 gma500: move the power header

In reply to Alan Cox

From: Alan Cox <[email protected]>

At this point we now have the file naming making somewhat more sense although the dependancies are not as clean as would be ideal

---

 drivers/staging/gma500/backlight.c         |    2 -
 drivers/staging/gma500/mdfld_dsi_dbi.c     |    2 -
 drivers/staging/gma500/mdfld_dsi_dbi.h     |    2 -
 drivers/staging/gma500/mdfld_dsi_output.h  |    2 -
 drivers/staging/gma500/mrst_crtc.c         |    2 -
 drivers/staging/gma500/mrst_lvds.c         |    2 -
 drivers/staging/gma500/power.c             |    2 -
 drivers/staging/gma500/power.h             |   67 ++++++++++++++++++++++++++++
 drivers/staging/gma500/psb_drv.c           |    2 -
 drivers/staging/gma500/psb_drv.h           |    2 -
 drivers/staging/gma500/psb_intel_display.c |    2 -
 drivers/staging/gma500/psb_intel_lvds.c    |    2 -
 drivers/staging/gma500/psb_irq.c           |    2 -
 drivers/staging/gma500/psb_powermgmt.h     |   67 ----------------------------
 14 files changed, 79 insertions(+), 79 deletions(-)
 create mode 100644 drivers/staging/gma500/power.h
 delete mode 100644 drivers/staging/gma500/psb_powermgmt.h
drivers/staging/gma500/backlight.c +1 -1
index 117649b..4027e70 100644
@@ -24,7 +24,7 @@
 #include "psb_intel_reg.h"
 #include "psb_intel_drv.h"
 #include "intel_bios.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 
 int gma_backlight_init(struct drm_device *dev)
 {
drivers/staging/gma500/mdfld_dsi_dbi.c +1 -1
index 15055c8..9d2d97d 100644
@@ -29,7 +29,7 @@
 #include "mdfld_dsi_dbi_dpu.h"
 #include "mdfld_dsi_pkg_sender.h"
 
-#include "psb_powermgmt.h"
+#include "power.h"
 #include <linux/pm_runtime.h>
 
 int enable_gfx_rtpm;
drivers/staging/gma500/mdfld_dsi_dbi.h +1 -1
index 5b04951..a76813e 100644
@@ -38,7 +38,7 @@
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 
 #include "mdfld_dsi_output.h"
 #include "mdfld_output.h"
drivers/staging/gma500/mdfld_dsi_output.h +1 -1
index ac25e55..0bf00ea 100644
@@ -38,7 +38,7 @@
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 #include "mdfld_output.h"
 
 #include <asm/mrst.h>
drivers/staging/gma500/mrst_crtc.c +1 -1
index d12d1a6..72464dd 100644
@@ -24,7 +24,7 @@
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_display.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 
 struct psb_intel_range_t {
 	int min, max;
drivers/staging/gma500/mrst_lvds.c +1 -1
index 9ecb99b..127b200 100644
@@ -28,7 +28,7 @@
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 #include <linux/pm_runtime.h>
 
 /* The max/min PWM frequency in BPCR[31:17] - */
drivers/staging/gma500/power.c +1 -1
index 0eee7fb..79eb670 100644
@@ -28,7 +28,7 @@
  *    Alan Cox <[email protected]>
  */
 
-#include "psb_powermgmt.h"
+#include "power.h"
 #include "psb_drv.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
drivers/staging/gma500/power.h new file +67 -0

67 lines not on this page · raw message

drivers/staging/gma500/psb_drv.c +1 -1
index a7f3c08..264fdf4 100644
@@ -30,7 +30,7 @@
 #include "mid_bios.h"
 #include "mdfld_dsi_dbi.h"
 #include <drm/drm_pciids.h>
-#include "psb_powermgmt.h"
+#include "power.h"
 #include <linux/cpu.h>
 #include <linux/notifier.h>
 #include <linux/spinlock.h>
drivers/staging/gma500/psb_drv.h +1 -1
index ee782fa..9e4f361 100644
@@ -30,7 +30,7 @@
 #include "psb_reg.h"
 #include "psb_intel_drv.h"
 #include "gtt.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 #include "mrst.h"
 
 /* Append new drm mode definition here, align with libdrm definition */
drivers/staging/gma500/psb_intel_display.c +1 -1
index 0b650a0..8f503d9 100644
@@ -27,7 +27,7 @@
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
 #include "psb_intel_display.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 
 #include "mdfld_output.h"
 
drivers/staging/gma500/psb_intel_lvds.c +1 -1
index c9a13a4..4a0d234 100644
@@ -27,7 +27,7 @@
 #include "psb_drv.h"
 #include "psb_intel_drv.h"
 #include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 #include <linux/pm_runtime.h>
 
 u32 CoreClock;
drivers/staging/gma500/psb_irq.c +1 -1
index 8fc7070..4a0fa42 100644
@@ -26,7 +26,7 @@
 #include "psb_drv.h"
 #include "psb_reg.h"
 #include "psb_intel_reg.h"
-#include "psb_powermgmt.h"
+#include "power.h"
 #include "mdfld_output.h"
 
 /*
drivers/staging/gma500/psb_powermgmt.h deleted +0 -67

67 lines not on this page · raw message

author
#65 lore raw

PATCH 44/49 gma500: begin adding CDV specific code

In reply to Alan Cox

From: Alan Cox <[email protected]>

A lot of the intel_display stuff is duplicated, but we will add it first, clean it up and then investigate the best way to merge stuff.

This first block integrates the various basic chunks of the CDV display setup.

---

 drivers/staging/gma500/Makefile            |    5 
 drivers/staging/gma500/cdv_device.c        |  195 ++--
 drivers/staging/gma500/cdv_intel_display.c | 1513 ++++++++++++++++++++++++++++
 drivers/staging/gma500/cdv_intel_lvds.c    |  718 +++++++++++++
 drivers/staging/gma500/framebuffer.c       |    9 
 drivers/staging/gma500/gtt.c               |   33 +
 drivers/staging/gma500/psb_intel_display.c |    3 
 drivers/staging/gma500/psb_intel_reg.h     |   91 ++
 8 files changed, 2459 insertions(+), 108 deletions(-)
 create mode 100644 drivers/staging/gma500/cdv_intel_display.c
 create mode 100644 drivers/staging/gma500/cdv_intel_lvds.c
drivers/staging/gma500/Makefile +4 -1
index 961a60c..507aaaf 100644
@@ -24,7 +24,10 @@ psb_gfx-y += gem_glue.o \
 	  psb_device.o \
 	  mid_bios.o
 
-psb_gfx-$(CONFIG_DRM_PSB_CDV) +=  cdv_device.o
+psb_gfx-$(CONFIG_DRM_PSB_CDV) +=  cdv_device.o \
+	  cdv_intel_display.o \
+	  cdv_intel_crt.o \
+	  cdv_intel_lvds.o
 
 psb_gfx-$(CONFIG_DRM_PSB_MRST) += mrst_device.o \
 	  mrst_crtc.o \
drivers/staging/gma500/cdv_device.c +96 -99

257 lines not on this page · raw message

drivers/staging/gma500/cdv_intel_display.c new file +1513 -0

1,513 lines not on this page · raw message

drivers/staging/gma500/cdv_intel_lvds.c new file +718 -0

718 lines not on this page · raw message

drivers/staging/gma500/framebuffer.c +8 -1
index 716a7b9..c6dd4d8 100644
@@ -732,6 +732,10 @@ static void psb_setup_outputs(struct drm_device *dev)
 
 		/* valid crtcs */
 		switch (psb_intel_output->type) {
+		case INTEL_OUTPUT_ANALOG:
+			crtc_mask = (1 << 0);
+			clone_mask = (1 << INTEL_OUTPUT_ANALOG);
+			break;
 		case INTEL_OUTPUT_SDVO:
 			crtc_mask = ((1 << 0) | (1 << 1));
 			clone_mask = (1 << INTEL_OUTPUT_SDVO);
@@ -752,7 +756,10 @@ static void psb_setup_outputs(struct drm_device *dev)
 			clone_mask = (1 << INTEL_OUTPUT_MIPI2);
 			break;
 		case INTEL_OUTPUT_HDMI:
-			crtc_mask = (1 << 1);
+		        if (IS_MFLD(dev))
+        			crtc_mask = (1 << 1);
+                        else	/* FIXME: review Oaktrail */
+                                crtc_mask = (1 << 0);	/* Cedarview */
 			clone_mask = (1 << INTEL_OUTPUT_HDMI);
 			break;
 		}
drivers/staging/gma500/gtt.c +28 -5
index 6cfa59b..28f2261 100644
@@ -395,12 +395,10 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	(void) PSB_RVDC32(PSB_PGETBL_CTL);
 
 	/* The root resource we allocate address space from */
-	dev_priv->gtt_mem = &dev->pdev->resource[PSB_GATT_RESOURCE];
 	dev_priv->gtt_initialized = 1;
 
-	pg->gtt_phys_start = dev_priv->pge_ctl & PAGE_MASK;
-
-	pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
+	pg->gtt_phys_start = dev_priv->pge_ctl;
+	
 	/*
 	 *	FIXME: video mmu has hw bug to access 0x0D0000000,
 	 *	then make gatt start at 0x0e000,0000
@@ -410,8 +408,33 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	pg->gtt_start = pci_resource_start(dev->pdev, PSB_GTT_RESOURCE);
 	gtt_pages = pci_resource_len(dev->pdev, PSB_GTT_RESOURCE)
 								>> PAGE_SHIFT;
+	/* CDV workaround */
+	if (pg->gtt_start == 0 || gtt_pages == 0) {
+		dev_err(dev->dev, "GTT PCI BAR not initialized.\n");
+		gtt_pages = 64;
+		pg->gtt_start = dev_priv->pge_ctl;
+	}
+
+	pg->gatt_start = pci_resource_start(dev->pdev, PSB_GATT_RESOURCE);
 	pg->gatt_pages = pci_resource_len(dev->pdev, PSB_GATT_RESOURCE)
 								>> PAGE_SHIFT;
+	dev_priv->gtt_mem = &dev->pdev->resource[PSB_GATT_RESOURCE];
+
+	if (pg->gatt_pages == 0 || pg->gatt_start == 0) {
+		static struct resource fudge;	/* Preferably peppermint */
+
+		/* This can occur on CDV SDV systems. Fudge it in this case.
+		   We really don't care what imaginary space is being allocated
+		   at this point */
+		dev_err(dev->dev, "GATT PCI BAR not initialized.\n");
+		pg->gatt_start = 0x40000000;
+		pg->gatt_pages = (128 * 1024 * 1024) >> PAGE_SHIFT;
+		fudge.start = 0x40000000;
+		fudge.end = 0x40000000 + 128 * 1024 * 1024 - 1;
+		fudge.name = "fudge";
+		fudge.flags = IORESOURCE_MEM;
+		dev_priv->gtt_mem = &fudge;
+	}
 
 	pci_read_config_dword(dev->pdev, PSB_BSM, &dev_priv->stolen_base);
 	vram_stolen_size = pg->gtt_phys_start - dev_priv->stolen_base
@@ -463,7 +486,7 @@ int psb_gtt_init(struct drm_device *dev, int resume)
 	pfn_base = dev_priv->stolen_base >> PAGE_SHIFT;
 	vram_pages = num_pages = vram_stolen_size >> PAGE_SHIFT;
 	printk(KERN_INFO"Set up %d stolen pages starting at 0x%08x, GTT offset %dK\n",
-		num_pages, pfn_base, 0);
+		num_pages, pfn_base << PAGE_SHIFT, 0);
 	for (i = 0; i < num_pages; ++i) {
 		pte = psb_gtt_mask_pte(pfn_base + i, 0);
 		iowrite32(pte, dev_priv->gtt_map + i);
drivers/staging/gma500/psb_intel_display.c +1 -2
index 8f503d9..bd0a4bc 100644
@@ -1039,14 +1039,13 @@ static int psb_intel_crtc_cursor_set(struct drm_crtc *crtc,
 	}
 
 	/* unpin the old bo */
-	if (psb_intel_crtc->cursor_obj && psb_intel_crtc->cursor_obj != obj) {
+	if (psb_intel_crtc->cursor_obj) {
 		gt = container_of(psb_intel_crtc->cursor_obj,
 							struct gtt_range, gem);
 		psb_gtt_unpin(gt);
 		drm_gem_object_unreference(psb_intel_crtc->cursor_obj);
 		psb_intel_crtc->cursor_obj = obj;
 	}
-
 	return 0;
 }
 
drivers/staging/gma500/psb_intel_reg.h +91 -0

107 lines not on this page · raw message

author
#66 lore raw

PATCH 45/49 gma500: Add the HDMI bits

In reply to Alan Cox

From: Alan Cox <[email protected]>

This adds the basic HDMI support for Cedarview.

---

 drivers/staging/gma500/Makefile        |    3 ++-
 drivers/staging/gma500/cdv_device.c    |    4 ++--
 drivers/staging/gma500/psb_intel_drv.h |    2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)
drivers/staging/gma500/Makefile +2 -1
index 507aaaf..e515edf 100644
@@ -25,8 +25,9 @@ psb_gfx-y += gem_glue.o \
 	  mid_bios.o
 
 psb_gfx-$(CONFIG_DRM_PSB_CDV) +=  cdv_device.o \
-	  cdv_intel_display.o \
 	  cdv_intel_crt.o \
+	  cdv_intel_display.o \
+	  cdv_intel_hdmi.o \
 	  cdv_intel_lvds.o
 
 psb_gfx-$(CONFIG_DRM_PSB_MRST) += mrst_device.o \
drivers/staging/gma500/cdv_device.c +2 -2
index 622c955..680f1bb 100644
@@ -58,9 +58,9 @@ static int cdv_output_init(struct drm_device *dev)
 	/* These bits indicate HDMI not SDVO on CDV, but we don't yet support
 	   the HDMI interface */
 	if (REG_READ(SDVOB) & SDVO_DETECTED)
-		DRM_ERROR("HDMI not supported yet\n");
+		cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOB);
 	if (REG_READ(SDVOC) & SDVO_DETECTED)
-		DRM_ERROR("HDMI not supported yet\n");
+		cdv_hdmi_init(dev, &dev_priv->mode_dev, SDVOC);
 	return 0;
 }
 
drivers/staging/gma500/psb_intel_drv.h +1 -1
index 9d7151a..36b554b 100644
@@ -105,7 +105,7 @@ struct psb_intel_output {
 	void *dev_priv;
 
 	struct psb_intel_mode_device *mode_dev;
-
+	struct i2c_adapter *hdmi_i2c_adapter;	/* for control functions */
 };
 
 struct psb_intel_crtc_state {
author
#67 lore raw

PATCH 46/49 gma500: Fix backlight crash

In reply to Alan Cox

From: Alan Cox <[email protected]>

We need to check the NULL case earlier.

---

 drivers/staging/gma500/backlight.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/staging/gma500/backlight.c +4 -3
index 4027e70..d3e698b 100644
@@ -38,9 +38,10 @@ void gma_backlight_exit(struct drm_device *dev)
 {
 #ifdef CONFIG_BACKLIGHT_CLASS_DEVICE
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	dev_priv->backlight_device->props.brightness = 0;
-	backlight_update_status(dev_priv->backlight_device);
-	if (dev_priv->backlight_device)
+	if (dev_priv->backlight_device) {
+		dev_priv->backlight_device->props.brightness = 0;
+		backlight_update_status(dev_priv->backlight_device);
 		backlight_device_unregister(dev_priv->backlight_device);
+	}
 #endif
 }
author
#68 lore raw

PATCH 47/49 gma500: Workaround for Medfield/Cedarview cursor bug

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/psb_intel_display.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
drivers/staging/gma500/psb_intel_display.c +14 -0
index bd0a4bc..8b84462 100644
@@ -1278,6 +1278,19 @@ const struct drm_crtc_funcs psb_intel_crtc_funcs = {
 	.destroy = psb_intel_crtc_destroy,
 };
 
+/*
+ * Set the default value of cursor control and base register
+ * to zero. This is a workaround for h/w defect on Oaktrail
+ */
+static void psb_intel_cursor_init(struct drm_device *dev, int pipe)
+{
+        u32 control[3] = { CURACNTR, CURBCNTR, CURCCNTR };
+        u32 base[3] = { CURABASE, CURBBASE, CURCBASE };
+        
+	REG_WRITE(control[pipe], 0);
+	REG_WRITE(base[pipe], 0);
+}
+
 void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 		     struct psb_intel_mode_device *mode_dev)
 {
@@ -1341,6 +1354,7 @@ void psb_intel_crtc_init(struct drm_device *dev, int pipe,
 	psb_intel_crtc->mode_set.connectors =
 	    (struct drm_connector **) (psb_intel_crtc + 1);
 	psb_intel_crtc->mode_set.num_connectors = 0;
+	psb_intel_cursor_init(dev, pipe);
 }
 
 int psb_intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data,
author
#69 lore raw

PATCH 48/49 gma500: Fix missing memory check

In reply to Alan Cox

From: Alan Cox <[email protected]>

---

 drivers/staging/gma500/intel_bios.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/staging/gma500/intel_bios.c +5 -1
index 1c4714d..096757f 100644
@@ -139,14 +139,18 @@ static void parse_lfp_panel_data(struct drm_psb_private *dev_priv,
 	if (!lvds_lfp_data)
 		return;
 
-	dev_priv->lvds_vbt = 1;
 
 	entry = &lvds_lfp_data->data[lvds_options->panel_type];
 	dvo_timing = &entry->dvo_timing;
 
 	panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode),
 				      GFP_KERNEL);
+	if (panel_fixed_mode == NULL) {
+		dev_err(dev_priv->dev->dev, "out of memory for fixed panel mode\n");
+		return;
+	}
 
+	dev_priv->lvds_vbt = 1;
 	fill_detail_timing_data(panel_fixed_mode, dvo_timing);
 
 	if (panel_fixed_mode->htotal > 0 && panel_fixed_mode->vtotal > 0) {
author
#70 lore raw

PATCH 49/49 gma500: power can be touched in IRQ state

In reply to Alan Cox

From: Alan Cox <[email protected]>

So we need to use a spinlock here

---

 drivers/staging/gma500/power.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
drivers/staging/gma500/power.c +10 -8
index 79eb670..5cd5023 100644
@@ -36,7 +36,7 @@
 #include <linux/pm_runtime.h>
 
 static struct mutex power_mutex;	/* Serialize power ops */
-static struct mutex power_ctrl_mutex;	/* Serialize power claim */
+static spinlock_t power_ctrl_lock;	/* Serialize power claim */
 
 /**
  *	gma_power_init		-	initialise power manager
@@ -55,8 +55,8 @@ void gma_power_init(struct drm_device *dev)
 	dev_priv->display_power = true;	/* We start active */
 	dev_priv->display_count = 0;	/* Currently no users */
 	dev_priv->suspended = false;	/* And not suspended */
+	spin_lock_init(&power_ctrl_lock);
 	mutex_init(&power_mutex);
-	mutex_init(&power_ctrl_mutex);
 
 	dev_priv->ops->init_pm(dev);
 }
@@ -247,13 +247,14 @@ bool gma_power_begin(struct drm_device *dev, bool force_on)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
 	int ret;
+	unsigned long flags;
 
-	mutex_lock(&power_ctrl_mutex);
+	spin_lock_irqsave(&power_ctrl_lock, flags);
 	/* Power already on ? */
 	if (dev_priv->display_power) {
 		dev_priv->display_count++;
 		pm_runtime_get(&dev->pdev->dev);
-		mutex_unlock(&power_ctrl_mutex);
+		spin_unlock_irqrestore(&power_ctrl_lock, flags);
 		return true;
 	}
 	if (force_on == false)
@@ -266,11 +267,11 @@ bool gma_power_begin(struct drm_device *dev, bool force_on)
 		psb_irq_postinstall(dev);
 		pm_runtime_get(&dev->pdev->dev);
 		dev_priv->display_count++;
-		mutex_unlock(&power_ctrl_mutex);
+		spin_unlock_irqrestore(&power_ctrl_lock, flags);
 		return true;
 	}
 out_false:
-	mutex_unlock(&power_ctrl_mutex);
+	spin_unlock_irqrestore(&power_ctrl_lock, flags);
 	return false;
 }
 
@@ -284,10 +285,11 @@ out_false:
 void gma_power_end(struct drm_device *dev)
 {
 	struct drm_psb_private *dev_priv = dev->dev_private;
-	mutex_lock(&power_ctrl_mutex);
+	unsigned long flags;
+	spin_lock_irqsave(&power_ctrl_lock, flags);
 	dev_priv->display_count--;
 	WARN_ON(dev_priv->display_count < 0);
-	mutex_unlock(&power_ctrl_mutex);
+	spin_unlock_irqrestore(&power_ctrl_lock, flags);
 	pm_runtime_put(&dev->pdev->dev);
 }
 
#71 lore raw
In reply to Alan Cox
Quoted 6 lines · Alan Cox

(Rebased versus the patches Greg took earlier)

The main things here are modularisation and support for Cedarview (this is unaccelerated as it has no 2D acceleration). I have some crazy ideas about using the GTT to do 2D console acceleration however but not much can be done for X.

Quoted 8 lines

At this point I think the Poulsbo (GMA500) and Cedarview code are probably ready to move out of staging - hence the modularisation work. The MID platforms need more cleaning up.

HDMI support at this point is pretty basic with no HDMI audio support. I'm hoping that will be something that can be addressed in future and now the basic bits are there I need to take a look at Oaktrail (Atom Z760/GMA600) and see if the same code can be used to bring up HDMI on that device too.

I've applied this series, but I get the following error when building:

make[2]: *** No rule to make target drivers/staging/gma500/cdv_intel_crt.o', needed by drivers/staging/gma500/psb_gfx.o'. Stop.

Care to send a follow-on patch fixing this?

Also, should I be able to select all of the different platforms even though I'm only building for a x86-64 platform?

thanks,

greg k-h

#72 lore raw
Quoted 16 lines · Greg KH
Quoted 6 lines · Alan Cox

(Rebased versus the patches Greg took earlier)

The main things here are modularisation and support for Cedarview (this is unaccelerated as it has no 2D acceleration). I have some crazy ideas about using the GTT to do 2D console acceleration however but not much can be done for X.

Quoted 8 lines

At this point I think the Poulsbo (GMA500) and Cedarview code are probably ready to move out of staging - hence the modularisation work. The MID platforms need more cleaning up.

HDMI support at this point is pretty basic with no HDMI audio support. I'm hoping that will be something that can be addressed in future and now the basic bits are there I need to take a look at Oaktrail (Atom Z760/GMA600) and see if the same code can be used to bring up HDMI on that device too.

Quoted 8 lines

I've applied this series, but I get the following error when building:

make[2]: *** No rule to make target drivers/staging/gma500/cdv_intel_crt.o', needed by drivers/staging/gma500/psb_gfx.o'. Stop.

Care to send a follow-on patch fixing this?

Also, should I be able to select all of the different platforms even though I'm only building for a x86-64 platform?

And I get the following error as well:
drivers/staging/gma500/cdv_device.c:28:24: fatal error: cdv_device.h: No such file or directory

author
#73 lore raw
In reply to Greg KH
Quoted 6 lines

I've applied this series, but I get the following error when building:

make[2]: *** No rule to make target drivers/staging/gma500/cdv_intel_crt.o', needed by drivers/staging/gma500/psb_gfx.o'. Stop.

Care to send a follow-on patch fixing this?

Done

Quoted 3 lines

Also, should I be able to select all of the different platforms even though I'm only building for a x86-64 platform?

They should all build. I thought Linus wanted stuff that would build to be buildable where it could so that it got build testing done.

#74 lore raw
Quoted 7 lines · Alan Cox
Quoted 6 lines

I've applied this series, but I get the following error when building:

make[2]: *** No rule to make target drivers/staging/gma500/cdv_intel_crt.o', needed by drivers/staging/gma500/psb_gfx.o'. Stop.

Care to send a follow-on patch fixing this?

Quoted 8 lines

Done

Quoted 3 lines

Also, should I be able to select all of the different platforms even though I'm only building for a x86-64 platform?

They should all build. I thought Linus wanted stuff that would build to be buildable where it could so that it got build testing done.

Ok, that's great, hopefully after your next patches, it will build :)