Skip to contentSkip to conversation

drm/omap: Add PM and OMAP5 support

PATCH New Andy Gross 1 participant 3 messages Dec 19, 2012 Staging

lore
Share & tools
lore

Andy Gross

author
#0 lore raw

v2 cover drm/omap: Add PM and OMAP5 support

First patch adds PM capabilities for omapdrm. Second patch adds OMAP5 support to DMM driver component.

Series was build tested and based on linux-next.

v2: Updated commit msg for PM patch

Andy Gross (2):
drm/omap: Add PM capabilities
drm/omap: Add OMAP5 support

 drivers/staging/omapdrm/omap_dmm_priv.h  |    5 +
 drivers/staging/omapdrm/omap_dmm_tiler.c |  159 ++++++++++++++++++++++--------
 drivers/staging/omapdrm/omap_drv.c       |   14 +++
 drivers/staging/omapdrm/omap_drv.h       |    4 +
 drivers/staging/omapdrm/omap_gem.c       |   28 +++++
 drivers/staging/omapdrm/tcm.h            |    2 +
 6 files changed, 169 insertions(+), 43 deletions(-)
Signature · 1 line
1.7.5.4
author
#1 lore raw

PATCH v2 1/2 drm/omap: Add PM capabilities

Added power management capabilities into the omapdrm and DMM drivers. During suspend, we don't need to do anything to maintain the state of the LUT. We have all the necessary information to recreate the mappings of the GEM object list maintained by the omapdrm driver.

On resume, the DMM resume handler will first reprogram the LUT to point to the dummy page. The subsequent resume handler in the omapdrm will call into the DMM and reprogram each of the buffer objects. This will ensure that all of the necessary objects will be pinned into the DMM properly.

Order of suspend/resume handlers is done by device creation. We create the DMM device before the omapdrm, so the correct order is maintained.

---
 drivers/staging/omapdrm/omap_dmm_tiler.c |   34 ++++++++++++++++++++++++++++++
 drivers/staging/omapdrm/omap_drv.c       |   14 ++++++++++++
 drivers/staging/omapdrm/omap_drv.h       |    4 +++
 drivers/staging/omapdrm/omap_gem.c       |   28 ++++++++++++++++++++++++
 4 files changed, 80 insertions(+), 0 deletions(-)
drivers/staging/omapdrm/omap_dmm_tiler.c +34 -0
index 59bf438..c42c5e5 100644
@@ -903,12 +903,46 @@ error:
 }
 #endif
 
+#ifdef CONFIG_PM
+static int omap_dmm_resume(struct device *dev)
+{
+	struct tcm_area area;
+	int i;
+
+	if (!omap_dmm)
+		return -ENODEV;
+
+	area = (struct tcm_area) {
+		.is2d = true,
+		.tcm = NULL,
+		.p1.x = omap_dmm->container_width - 1,
+		.p1.y = omap_dmm->container_height - 1,
+	};
+
+	/* initialize all LUTs to dummy page entries */
+	for (i = 0; i < omap_dmm->num_lut; i++) {
+		area.tcm = omap_dmm->tcm[i];
+		if (fill(&area, NULL, 0, 0, true))
+			dev_err(dev, "refill failed");
+	}
+
+	return 0;
+}
+
+static const struct dev_pm_ops omap_dmm_pm_ops = {
+	.resume = omap_dmm_resume,
+};
+#endif
+
 struct platform_driver omap_dmm_driver = {
 	.probe = omap_dmm_probe,
 	.remove = omap_dmm_remove,
 	.driver = {
 		.owner = THIS_MODULE,
 		.name = DMM_DRIVER_NAME,
+#ifdef CONFIG_PM
+		.pm = &omap_dmm_pm_ops,
+#endif
 	},
 };
 
drivers/staging/omapdrm/omap_drv.c +14 -0
index ae5ecc2..d246f85 100644
@@ -368,6 +368,9 @@ static int dev_load(struct drm_device *dev, unsigned long flags)
 		/* well, limp along without an fbdev.. maybe X11 will work? */
 	}
 
+	/* store off drm_device for use in pm ops */
+	dev_set_drvdata(dev->dev, dev);
+
 	drm_kms_helper_poll_init(dev);
 
 	return 0;
@@ -393,6 +396,8 @@ static int dev_unload(struct drm_device *dev)
 	kfree(dev->dev_private);
 	dev->dev_private = NULL;
 
+	dev_set_drvdata(dev->dev, NULL);
+
 	return 0;
 }
 
@@ -558,10 +563,19 @@ static int pdev_remove(struct platform_device *device)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+static const struct dev_pm_ops omapdrm_pm_ops = {
+	.resume = omap_gem_resume,
+};
+#endif
+
 struct platform_driver pdev = {
 		.driver = {
 			.name = DRIVER_NAME,
 			.owner = THIS_MODULE,
+#ifdef CONFIG_PM
+			.pm = &omapdrm_pm_ops,
+#endif
 		},
 		.probe = pdev_probe,
 		.remove = pdev_remove,
drivers/staging/omapdrm/omap_drv.h +4 -0
index cd1f22b..f921027 100644
@@ -135,6 +135,10 @@ void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m);
 void omap_gem_describe_objects(struct list_head *list, struct seq_file *m);
 #endif
 
+#ifdef CONFIG_PM
+int omap_gem_resume(struct device *dev);
+#endif
+
 int omap_irq_enable_vblank(struct drm_device *dev, int crtc);
 void omap_irq_disable_vblank(struct drm_device *dev, int crtc);
 irqreturn_t omap_irq_handler(DRM_IRQ_ARGS);
drivers/staging/omapdrm/omap_gem.c +28 -0
index c38992b..08f1e292 100644
@@ -964,6 +964,34 @@ void *omap_gem_vaddr(struct drm_gem_object *obj)
 	return omap_obj->vaddr;
 }
 
+#ifdef CONFIG_PM
+/* re-pin objects in DMM in resume path: */
+int omap_gem_resume(struct device *dev)
+{
+	struct drm_device *drm_dev = dev_get_drvdata(dev);
+	struct omap_drm_private *priv = drm_dev->dev_private;
+	struct omap_gem_object *omap_obj;
+	int ret = 0;
+
+	list_for_each_entry(omap_obj, &priv->obj_list, mm_list) {
+		if (omap_obj->block) {
+			struct drm_gem_object *obj = &omap_obj->base;
+			uint32_t npages = obj->size >> PAGE_SHIFT;
+			WARN_ON(!omap_obj->pages);  /* this can't happen */
+			ret = tiler_pin(omap_obj->block,
+					omap_obj->pages, npages,
+					omap_obj->roll, true);
+			if (ret) {
+				dev_err(dev, "could not repin: %d\n", ret);
+				return ret;
+			}
+		}
+	}
+
+	return 0;
+}
+#endif
+
 #ifdef CONFIG_DEBUG_FS
 void omap_gem_describe(struct drm_gem_object *obj, struct seq_file *m)
 {
Signature · 1 line
1.7.5.4
author
#2 lore raw

PATCH v2 2/2 drm/omap: Add OMAP5 support

In reply to Andy Gross

Add support for OMAP5 processor. The main differences are that the OMAP5 has 2 containers, one for 1D and one for 2D. Each container is 128MiB in size.

---
 drivers/staging/omapdrm/omap_dmm_priv.h  |    5 +
 drivers/staging/omapdrm/omap_dmm_tiler.c |  127 +++++++++++++++++++----------
 drivers/staging/omapdrm/tcm.h            |    2 +
 3 files changed, 90 insertions(+), 44 deletions(-)
drivers/staging/omapdrm/omap_dmm_priv.h +5 -0
index 273ec12..58bcd6a 100644
@@ -118,6 +118,11 @@ struct pat {
 #define DESCR_SIZE 128
 #define REFILL_BUFFER_SIZE ((4 * 128 * 256) + (3 * DESCR_SIZE))
 
+/* For OMAP5, a fixed offset is added to all Y coordinates for 1D buffers.
+ * This is used in programming to address the upper portion of the LUT
+*/
+#define OMAP5_LUT_OFFSET       128
+
 struct dmm;
 
 struct dmm_txn {
drivers/staging/omapdrm/omap_dmm_tiler.c +83 -44

185 lines not on this page · raw message

drivers/staging/omapdrm/tcm.h +2 -0
index d273e3e..a8d5ce4 100644
@@ -59,6 +59,8 @@ struct tcm {
 	u16 width, height;	/* container dimensions */
 	int lut_id;		/* Lookup table identifier */
 
+	unsigned int y_offset;	/* offset to use for y coordinates */
+
 	/* 'pvt' structure shall contain any tcm details (attr) along with
 	linked list of allocated areas and mutex for mutually exclusive access
 	to the list.  It may also contain copies of width and height to notice
Signature · 1 line
1.7.5.4