[PATCH] drm/komeda: Add runtime_pm support

2019-12-11 Thread james qian wang (Arm Technology China)
- Add pm_runtime_get/put to crtc_enable/disable along with the real
  display usage
- Add runtime_get/put to register_show, since register_show() will
  access register, need to wakeup HW.
- For the case that PM is not enabled or configured, manually wakeup HW

Signed-off-by: james qian wang (Arm Technology China) 
---
 .../gpu/drm/arm/display/komeda/komeda_crtc.c  |  3 +
 .../gpu/drm/arm/display/komeda/komeda_dev.c   | 55 +--
 .../gpu/drm/arm/display/komeda/komeda_drv.c   | 42 --
 .../gpu/drm/arm/display/komeda/komeda_kms.c   |  6 --
 4 files changed, 53 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
index 1c452ea75999..56bd938961ee 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_crtc.c
@@ -5,6 +5,7 @@
  *
  */
 #include 
+#include 
 #include 
 
 #include 
@@ -274,6 +275,7 @@ static void
 komeda_crtc_atomic_enable(struct drm_crtc *crtc,
  struct drm_crtc_state *old)
 {
+   pm_runtime_get_sync(crtc->dev->dev);
komeda_crtc_prepare(to_kcrtc(crtc));
drm_crtc_vblank_on(crtc);
WARN_ON(drm_crtc_vblank_get(crtc));
@@ -372,6 +374,7 @@ komeda_crtc_atomic_disable(struct drm_crtc *crtc,
drm_crtc_vblank_put(crtc);
drm_crtc_vblank_off(crtc);
komeda_crtc_unprepare(kcrtc);
+   pm_runtime_put(crtc->dev->dev);
 }
 
 static void
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
index 38b832804bad..1d767473ba8a 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.c
@@ -10,6 +10,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #ifdef CONFIG_DEBUG_FS
 #include 
@@ -27,12 +28,16 @@ static int komeda_register_show(struct seq_file *sf, void 
*x)
 
seq_puts(sf, "\n== Komeda register dump =\n");
 
+   pm_runtime_get_sync(mdev->dev);
+
if (mdev->funcs->dump_register)
mdev->funcs->dump_register(mdev, sf);
 
for (i = 0; i < mdev->n_pipelines; i++)
komeda_pipeline_dump_register(mdev->pipelines[i], sf);
 
+   pm_runtime_put(mdev->dev);
+
return 0;
 }
 
@@ -263,15 +268,6 @@ struct komeda_dev *komeda_dev_create(struct device *dev)
if (!mdev->iommu)
DRM_INFO("continue without IOMMU support!\n");
 
-   if (mdev->iommu && mdev->funcs->connect_iommu) {
-   err = mdev->funcs->connect_iommu(mdev);
-   if (err) {
-   DRM_ERROR("connect iommu failed.\n");
-   mdev->iommu = NULL;
-   goto disable_clk;
-   }
-   }
-
clk_disable_unprepare(mdev->aclk);
 
err = sysfs_create_group(>kobj, _sysfs_attr_group);
@@ -310,11 +306,6 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
if (mdev->aclk)
clk_prepare_enable(mdev->aclk);
 
-   if (mdev->iommu && mdev->funcs->disconnect_iommu)
-   if (mdev->funcs->disconnect_iommu(mdev))
-   DRM_ERROR("disconnect iommu failed.\n");
-   mdev->iommu = NULL;
-
for (i = 0; i < mdev->n_pipelines; i++) {
komeda_pipeline_destroy(mdev, mdev->pipelines[i]);
mdev->pipelines[i] = NULL;
@@ -343,44 +334,26 @@ void komeda_dev_destroy(struct komeda_dev *mdev)
 
 int komeda_dev_resume(struct komeda_dev *mdev)
 {
-   int ret = 0;
-
clk_prepare_enable(mdev->aclk);
 
-   if (mdev->iommu && mdev->funcs->connect_iommu) {
-   ret = mdev->funcs->connect_iommu(mdev);
-   if (ret < 0) {
-   DRM_ERROR("connect iommu failed.\n");
-   goto disable_clk;
-   }
-   }
-
-   ret = mdev->funcs->enable_irq(mdev);
+   mdev->funcs->enable_irq(mdev);
 
-disable_clk:
-   clk_disable_unprepare(mdev->aclk);
+   if (mdev->iommu && mdev->funcs->connect_iommu)
+   if (mdev->funcs->connect_iommu(mdev))
+   DRM_ERROR("connect iommu failed.\n");
 
-   return ret;
+   return 0;
 }
 
 int komeda_dev_suspend(struct komeda_dev *mdev)
 {
-   int ret = 0;
-
-   clk_prepare_enable(mdev->aclk);
-
-   if (mdev->iommu && mdev->funcs->disconnect_iommu) {
-   ret = mdev->funcs->disconnect_iommu(mdev);
-   if (ret < 0) {
+   if (mdev->iommu && mdev->funcs->disconnect_iommu)
+   if (mdev->funcs->disconnect_iommu(mdev))
DRM_ERROR("disconnect iommu failed.\n");
-   goto disable_clk;
-   }
-   }
 
-   ret = mdev->funcs->disable_irq(mdev);
+   mdev->funcs->disable_irq(mdev);
 
-disable_clk:
clk_disable_unprepare(mdev->aclk);
 
-   return ret;
+   return 0;
 }
diff --git 

[PATCH v2 1/3] drm/vram-helper: Remove interruptible flag from public interface

2019-12-11 Thread Thomas Zimmermann
The flag 'interruptible', which is passed to various functions,
is always set to be false. Remove it and hard-code the value.

Signed-off-by: Thomas Zimmermann 
Suggested-by: Daniel Vetter 
---
 drivers/gpu/drm/ast/ast_mode.c  |  2 +-
 drivers/gpu/drm/drm_gem_vram_helper.c   | 17 ++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  2 +-
 include/drm/drm_gem_vram_helper.h   |  4 +---
 6 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index b879bd666e35..26336642dd59 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1145,7 +1145,7 @@ static int ast_cursor_init(struct drm_device *dev)
 
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
gbo = drm_gem_vram_create(dev, >vram_mm->bdev,
- size, 0, false);
+ size, 0);
if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put;
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 666cb4c22bb9..4908f1281002 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -94,8 +94,7 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object 
*gbo,
 static int drm_gem_vram_init(struct drm_device *dev,
 struct ttm_bo_device *bdev,
 struct drm_gem_vram_object *gbo,
-size_t size, unsigned long pg_align,
-bool interruptible)
+size_t size, unsigned long pg_align)
 {
int ret;
size_t acc_size;
@@ -112,7 +111,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
drm_gem_vram_placement(gbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
 
ret = ttm_bo_init(bdev, >bo, size, ttm_bo_type_device,
- >placement, pg_align, interruptible, acc_size,
+ >placement, pg_align, false, acc_size,
  NULL, NULL, ttm_buffer_object_destroy);
if (ret)
goto err_drm_gem_object_release;
@@ -130,7 +129,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
  * @bdev:  the TTM BO device backing the object
  * @size:  the buffer size in bytes
  * @pg_align:  the buffer's alignment in multiples of the page size
- * @interruptible: sleep interruptible if waiting for memory
  *
  * Returns:
  * A new instance of  drm_gem_vram_object on success, or
@@ -139,8 +137,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
 struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
struct ttm_bo_device *bdev,
size_t size,
-   unsigned long pg_align,
-   bool interruptible)
+   unsigned long pg_align)
 {
struct drm_gem_vram_object *gbo;
int ret;
@@ -149,7 +146,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
if (!gbo)
return ERR_PTR(-ENOMEM);
 
-   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align, interruptible);
+   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align);
if (ret < 0)
goto err_kfree;
 
@@ -485,7 +482,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
  * @dev:   the DRM device
  * @bdev:  the TTM BO device managing the buffer object
  * @pg_align:  the buffer's alignment in multiples of the page size
- * @interruptible: sleep interruptible if waiting for memory
  * @args:  the arguments as provided to \
 drm_driver.dumb_create
  *
@@ -502,7 +498,6 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
  struct ttm_bo_device *bdev,
  unsigned long pg_align,
- bool interruptible,
  struct drm_mode_create_dumb *args)
 {
size_t pitch, size;
@@ -517,7 +512,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
if (!size)
return -EINVAL;
 
-   gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible);
+   gbo = drm_gem_vram_create(dev, bdev, size, pg_align);
if (IS_ERR(gbo))
return PTR_ERR(gbo);
 
@@ -613,7 +608,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
return -EINVAL;
 

[PATCH v2 2/3] drm/vram-helper: Remove BO device from public interface

2019-12-11 Thread Thomas Zimmermann
TTM is an implementation detail of the VRAM helpers and therefore
shouldn't be exposed to the callers. There's only one correct value
for the BO device anyway, which is the one stored in the DRM device.

So remove struct ttm_bo_device from the VRAM-helper interface and
use the device's VRAM manager unconditionally. The GEM initializer
function fails if the VRAM manager has not been initialized.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ast/ast_mode.c  |  3 +--
 drivers/gpu/drm/drm_gem_vram_helper.c   | 21 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  3 +--
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  3 +--
 include/drm/drm_gem_vram_helper.h   |  2 --
 6 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 26336642dd59..f4fbdab29bb7 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1144,8 +1144,7 @@ static int ast_cursor_init(struct drm_device *dev)
size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
 
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
-   gbo = drm_gem_vram_create(dev, >vram_mm->bdev,
- size, 0);
+   gbo = drm_gem_vram_create(dev, size, 0);
if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put;
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 4908f1281002..b760fd27f3c0 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -92,13 +92,18 @@ static void drm_gem_vram_placement(struct 
drm_gem_vram_object *gbo,
 }
 
 static int drm_gem_vram_init(struct drm_device *dev,
-struct ttm_bo_device *bdev,
 struct drm_gem_vram_object *gbo,
 size_t size, unsigned long pg_align)
 {
+   struct drm_vram_mm *vmm = dev->vram_mm;
+   struct ttm_bo_device *bdev;
int ret;
size_t acc_size;
 
+   if (WARN_ONCE(!vmm, "VRAM MM not initialized"))
+   return -EINVAL;
+   bdev = >bdev;
+
gbo->bo.base.funcs = _gem_vram_object_funcs;
 
ret = drm_gem_object_init(dev, >bo.base, size);
@@ -126,7 +131,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
 /**
  * drm_gem_vram_create() - Creates a VRAM-backed GEM object
  * @dev:   the DRM device
- * @bdev:  the TTM BO device backing the object
  * @size:  the buffer size in bytes
  * @pg_align:  the buffer's alignment in multiples of the page size
  *
@@ -135,7 +139,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
  * an ERR_PTR()-encoded error code otherwise.
  */
 struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
-   struct ttm_bo_device *bdev,
size_t size,
unsigned long pg_align)
 {
@@ -146,7 +149,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
if (!gbo)
return ERR_PTR(-ENOMEM);
 
-   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align);
+   ret = drm_gem_vram_init(dev, gbo, size, pg_align);
if (ret < 0)
goto err_kfree;
 
@@ -480,7 +483,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
Helper for implementing  drm_driver.dumb_create
  * @file:  the DRM file
  * @dev:   the DRM device
- * @bdev:  the TTM BO device managing the buffer object
  * @pg_align:  the buffer's alignment in multiples of the page size
  * @args:  the arguments as provided to \
 drm_driver.dumb_create
@@ -496,7 +498,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
  */
 int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
- struct ttm_bo_device *bdev,
  unsigned long pg_align,
  struct drm_mode_create_dumb *args)
 {
@@ -512,7 +513,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
if (!size)
return -EINVAL;
 
-   gbo = drm_gem_vram_create(dev, bdev, size, pg_align);
+   gbo = drm_gem_vram_create(dev, size, pg_align);
if (IS_ERR(gbo))
return PTR_ERR(gbo);
 
@@ -604,11 +605,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
 {
-   if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
-   return -EINVAL;
-
-   

[PATCH v2 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object

2019-12-11 Thread Thomas Zimmermann
Drivers that what to allocate VRAM GEM objects with additional fields
can now do this by implementing struct drm_driver.gem_create_object.

v2:
* only cast to gbo within if branch; set gbo directly
  in else branch

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index b760fd27f3c0..baa49d1e9538 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -2,6 +2,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -145,7 +146,13 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
struct drm_gem_vram_object *gbo;
int ret;
 
-   gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
+   if (dev->driver->gem_create_object) {
+   struct drm_gem_object *gem =
+   dev->driver->gem_create_object(dev, size);
+   gbo = drm_gem_vram_of_gem(gem);
+   } else {
+   gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
+   }
if (!gbo)
return ERR_PTR(-ENOMEM);
 
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/3] drm/vram-helper: Various cleanups

2019-12-11 Thread Thomas Zimmermann
A number of cleanups that I wanted to apply for some time. The first
two patches simplify the public interface. The third patch adds support
for struct drm_driver.gem_create_object. All tested by running fbdev,
X11 and Weston on ast HW.

v2:
* make drm_gem_vram_create() still work if GEM object is not
  first in struct

Thomas Zimmermann (3):
  drm/vram-helper: Remove interruptible flag from public interface
  drm/vram-helper: Remove BO device from public interface
  drm/vram-helper: Support struct drm_driver.gem_create_object

 drivers/gpu/drm/ast/ast_mode.c  |  3 +-
 drivers/gpu/drm/drm_gem_vram_helper.c   | 41 ++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  3 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  3 +-
 include/drm/drm_gem_vram_helper.h   |  6 +--
 6 files changed, 25 insertions(+), 33 deletions(-)

--
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm/komeda: Add event handling for EMPTY/FULL

2019-12-11 Thread james qian wang (Arm Technology China)
EMPTY/FULL are HW input/output FIFO condition identifer, which are
useful information for addressing the problem, so expose them.

Signed-off-by: james qian wang (Arm Technology China) 
---
 drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c  | 13 -
 drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h |  3 +++
 drivers/gpu/drm/arm/display/komeda/komeda_dev.h   |  5 -
 drivers/gpu/drm/arm/display/komeda/komeda_event.c |  2 ++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c 
b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
index dd1ecf4276d3..00fa56c29b3e 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
@@ -20,8 +20,10 @@ static u64 get_lpu_event(struct d71_pipeline *d71_pipeline)
evts |= KOMEDA_EVENT_IBSY;
if (raw_status & LPU_IRQ_EOW)
evts |= KOMEDA_EVENT_EOW;
+   if (raw_status & LPU_IRQ_OVR)
+   evts |= KOMEDA_EVENT_OVR;
 
-   if (raw_status & (LPU_IRQ_ERR | LPU_IRQ_IBSY)) {
+   if (raw_status & (LPU_IRQ_ERR | LPU_IRQ_IBSY | LPU_IRQ_OVR)) {
u32 restore = 0, tbu_status;
/* Check error of LPU status */
status = malidp_read32(reg, BLK_STATUS);
@@ -45,6 +47,15 @@ static u64 get_lpu_event(struct d71_pipeline *d71_pipeline)
restore |= LPU_STATUS_ACE3;
evts |= KOMEDA_ERR_ACE3;
}
+   if (status & LPU_STATUS_FEMPTY) {
+   restore |= LPU_STATUS_FEMPTY;
+   evts |= KOMEDA_EVENT_EMPTY;
+   }
+   if (status & LPU_STATUS_FFULL) {
+   restore |= LPU_STATUS_FFULL;
+   evts |= KOMEDA_EVENT_FULL;
+   }
+
if (restore != 0)
malidp_write32_mask(reg, BLK_STATUS, restore, 0);
 
diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h 
b/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
index 81de6a23e7f3..e80172a0b320 100644
--- a/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
+++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
@@ -175,6 +175,7 @@
 #define TBU_DOUTSTDCAPB_MASK   0x3F
 
 /* LPU_IRQ_BITS */
+#define LPU_IRQ_OVRBIT(9)
 #define LPU_IRQ_IBSY   BIT(10)
 #define LPU_IRQ_ERRBIT(11)
 #define LPU_IRQ_EOWBIT(12)
@@ -185,6 +186,8 @@
 #define LPU_STATUS_AXIEBIT(4)
 #define LPU_STATUS_AXIRP   BIT(5)
 #define LPU_STATUS_AXIWP   BIT(6)
+#define LPU_STATUS_FEMPTY  BIT(11)
+#define LPU_STATUS_FFULL   BIT(14)
 #define LPU_STATUS_ACE0BIT(16)
 #define LPU_STATUS_ACE1BIT(17)
 #define LPU_STATUS_ACE2BIT(18)
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h 
b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
index 4a67a80d5fcf..ce27f2f27c24 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_dev.h
@@ -20,6 +20,8 @@
 #define KOMEDA_EVENT_OVR   BIT_ULL(4)
 #define KOMEDA_EVENT_EOW   BIT_ULL(5)
 #define KOMEDA_EVENT_MODE  BIT_ULL(6)
+#define KOMEDA_EVENT_FULL  BIT_ULL(7)
+#define KOMEDA_EVENT_EMPTY BIT_ULL(8)
 
 #define KOMEDA_ERR_TETOBIT_ULL(14)
 #define KOMEDA_ERR_TEMRBIT_ULL(15)
@@ -49,7 +51,8 @@
KOMEDA_ERR_ZME  | KOMEDA_ERR_MERR   | KOMEDA_ERR_TCF |\
KOMEDA_ERR_TTNG | KOMEDA_ERR_TTF)
 
-#define KOMEDA_WARN_EVENTS KOMEDA_ERR_CSCE
+#define KOMEDA_WARN_EVENTS \
+   (KOMEDA_ERR_CSCE | KOMEDA_EVENT_FULL | KOMEDA_EVENT_EMPTY)
 
 #define KOMEDA_INFO_EVENTS (0 \
| KOMEDA_EVENT_VSYNC \
diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_event.c 
b/drivers/gpu/drm/arm/display/komeda/komeda_event.c
index 977c38d516da..53f944e66dfc 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_event.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_event.c
@@ -78,6 +78,8 @@ static void evt_str(struct komeda_str *str, u64 events)
 
/* LPU errors or events */
evt_sprintf(str, events & KOMEDA_EVENT_IBSY, "IBSY|");
+   evt_sprintf(str, events & KOMEDA_EVENT_EMPTY, "EMPTY|");
+   evt_sprintf(str, events & KOMEDA_EVENT_FULL, "FULL|");
evt_sprintf(str, events & KOMEDA_ERR_AXIE, "AXIE|");
evt_sprintf(str, events & KOMEDA_ERR_ACE0, "ACE0|");
evt_sprintf(str, events & KOMEDA_ERR_ACE1, "ACE1|");
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v9 23/25] mm/gup: track FOLL_PIN pages

2019-12-11 Thread John Hubbard

On 12/11/19 3:28 AM, Jan Kara wrote:
...


The patch looks mostly good to me now. Just a few smaller comments below.


Suggested-by: Jan Kara 
Suggested-by: Jérôme Glisse 
Reviewed-by: Jan Kara 
Reviewed-by: Jérôme Glisse 
Reviewed-by: Ira Weiny 


I think you inherited here the Reviewed-by tags from the "add flags" patch
you've merged into this one but that's not really fair since this patch
does much more... In particular I didn't give my Reviewed-by tag for this
patch yet.


OK, I've removed those reviewed-by's. (I felt bad about dropping them, after
people had devoted time to reviewing, but I do see that it's wrong to imply
that they've reviewed this much much larger thing.)

...


I somewhat wonder about the asymmetry of try_grab_compound_head() vs
try_grab_page() in the treatment of 'flags'. How costly would it be to make
them symmetric (i.e., either set FOLL_GET for try_grab_compound_head()
callers or make sure one of FOLL_GET, FOLL_PIN is set for try_grab_page())?

Because this difference looks like a subtle catch in the long run...


Done. It is only a modest code-level change, at least the way I've done it, 
which is
setting FOLL_GET for try_grab_compound_head(). In order to do that, I set
it at the top of the internal gup fast calling stacks, which is actually a good
design anyway: gup fast is logically doing FOLL_GET in all cases. So setting
the flag internally is accurate and consistent with the overall design.



...


@@ -1522,8 +1536,8 @@ struct page *follow_trans_huge_pmd(struct vm_area_struct 
*vma,
  skip_mlock:
page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page);
-   if (flags & FOLL_GET)
-   get_page(page);
+   if (!try_grab_page(page, flags))
+   page = ERR_PTR(-EFAULT);


I think you need to also move the try_grab_page() earlier in the function.
At this point the page may be marked as mlocked and you'd need to undo that
in case try_grab_page() fails.



OK, I've moved it up, adding a "subpage" variable in order to make that work.




diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index ac65bb5e38ac..0aab6fe0072f 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4356,7 +4356,13 @@ long follow_hugetlb_page(struct mm_struct *mm, struct 
vm_area_struct *vma,
  same_page:
if (pages) {
pages[i] = mem_map_offset(page, pfn_offset);
-   get_page(pages[i]);
+   if (!try_grab_page(pages[i], flags)) {
+   spin_unlock(ptl);
+   remainder = 0;
+   err = -ENOMEM;
+   WARN_ON_ONCE(1);
+   break;
+   }
}


This function does a refcount overflow check early so that it doesn't have
to do try_get_page() here. So that check can be now removed when you do
try_grab_page() here anyway since that early check seems to be just a tiny
optimization AFAICT.

Honza



Yes. I've removed it, good spot.


thanks,
--
John Hubbard
NVIDIA
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object

2019-12-11 Thread Thomas Zimmermann
Hi Sam

Am 11.12.19 um 20:11 schrieb Sam Ravnborg:
> Hi Thomas,
> 
> On Wed, Dec 11, 2019 at 07:08:32PM +0100, Thomas Zimmermann wrote:
>> Drivers that what to allocate VRAM GEM objects with additional fields
>> can now do this by implementing struct drm_driver.gem_create_object.
>>
>> Signed-off-by: Thomas Zimmermann 
>> ---
>>  drivers/gpu/drm/drm_gem_vram_helper.c | 11 +--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
>> b/drivers/gpu/drm/drm_gem_vram_helper.c
>> index b760fd27f3c0..d475d94e2e3e 100644
>> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
>> @@ -2,6 +2,7 @@
>>  
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -142,13 +143,19 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
>> drm_device *dev,
>>  size_t size,
>>  unsigned long pg_align)
>>  {
>> +struct drm_gem_object *gem;
>>  struct drm_gem_vram_object *gbo;
>>  int ret;
>>  
>> -gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
>> -if (!gbo)
>> +if (dev->driver->gem_create_object)
>> +gem = dev->driver->gem_create_object(dev, size);
>> +else
>> +gem = kzalloc(sizeof(*gbo), GFP_KERNEL);
> The size is (*gbo) but you assume it is a gem.
> Looks wrong at first glance???

The conversion to gbo is...

> 
>   Sam
> 
> 
>> +if (!gem)
>>  return ERR_PTR(-ENOMEM);
>>  
>> +gbo = drm_gem_vram_of_gem(gem);
>> +

...here. This could be pushed into the if branch, but I found it more
readable to put the statement here. For the else branch, it doesn't
matter as 'gem' goes first in the structure.

I'll move it into the if branch, so it's more obvious what's going on
and doesn't break accidentally.

Best regards
Thomas

>>  ret = drm_gem_vram_init(dev, gbo, size, pg_align);
>>  if (ret < 0)
>>  goto err_kfree;
>> -- 
>> 2.24.0

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 204241] amdgpu fails to resume from suspend

2019-12-11 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=204241

--- Comment #45 from crab2...@gmail.com ---
Kernel 5.4.2 and kernel 5.3 is affected. I switch to kernel 5.2.19 and do not
have this issue.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/mediatek: Fix can't get component for external display plane.

2019-12-11 Thread CK Hu
Hi, Pi-Hsun:

On Mon, 2019-12-02 at 13:24 +0800, CK Hu wrote:
> Hi, Pi-Hsun:
> 
> 
> On Wed, 2019-11-27 at 18:04 +0800, Pi-Hsun Shih wrote:
> > From: Yongqiang Niu 
> > 
> > The original logic is ok for primary display, but will not find out
> > component for external display.
> > 
> > For example, plane->index is 6 for external display, but there are only
> > 2 layer nr in external display, and this condition will never happen:
> > if (plane->index < (count + mtk_ddp_comp_layer_nr(comp)))
> > 
> > Fix this by using the offset of the plane to mtk_crtc->planes as index,
> > instead of plane->index.
> 
> Reviewed-by: CK Hu 
> 

Applied to mediatek-drm-fixes-5.5 [1], thanks.

[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.5


Regards,
CK

> Regards,
> CK
> 
> > 
> > Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a 
> > plane")
> > Signed-off-by: Yongqiang Niu 
> > Signed-off-by: Pi-Hsun Shih 
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 5 +++--
> >  1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
> > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index f80a8ba75977..b34e7d70702a 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -215,11 +215,12 @@ struct mtk_ddp_comp 
> > *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
> > struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
> > struct mtk_ddp_comp *comp;
> > int i, count = 0;
> > +   unsigned int local_index = plane - mtk_crtc->planes;
> >  
> > for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
> > comp = mtk_crtc->ddp_comp[i];
> > -   if (plane->index < (count + mtk_ddp_comp_layer_nr(comp))) {
> > -   *local_layer = plane->index - count;
> > +   if (local_index < (count + mtk_ddp_comp_layer_nr(comp))) {
> > +   *local_layer = local_index - count;
> > return comp;
> > }
> > count += mtk_ddp_comp_layer_nr(comp);
> > 
> > base-commit: 1875ff320f14afe21731a6e4c7b46dd33e45dfaa
> 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/mediatek: Check return value of mtk_drm_ddp_comp_for_plane.

2019-12-11 Thread CK Hu
Hi, Pi-Hsun:

On Fri, 2019-11-22 at 15:58 +0800, CK Hu wrote:
> Hi, Pi-Hsun:
> 
> On Mon, 2019-11-18 at 14:18 +0800, Pi-Hsun Shih wrote:
> > The mtk_drm_ddp_comp_for_plane can return NULL, but the usage doesn't
> > check for it. Add check for it.
> 
> Reviewed-by: CK Hu 
> 

Applied to mediatek-drm-fixes-5.5 [1], thanks.

[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-fixes-5.5

Regards,
CK

> > 
> > Fixes: d6b53f68356f ("drm/mediatek: Add helper to get component for a 
> > plane")
> > Signed-off-by: Pi-Hsun Shih 
> > ---
> >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 13 +
> >  1 file changed, 9 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c 
> > b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > index f80a8ba75977..4c4f976c994e 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> > @@ -310,7 +310,9 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc 
> > *mtk_crtc)
> >  
> > plane_state = to_mtk_plane_state(plane->state);
> > comp = mtk_drm_ddp_comp_for_plane(crtc, plane, _layer);
> > -   mtk_ddp_comp_layer_config(comp, local_layer, plane_state);
> > +   if (comp)
> > +   mtk_ddp_comp_layer_config(comp, local_layer,
> > + plane_state);
> > }
> >  
> > return 0;
> > @@ -386,8 +388,9 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)
> > comp = mtk_drm_ddp_comp_for_plane(crtc, plane,
> >   _layer);
> >  
> > -   mtk_ddp_comp_layer_config(comp, local_layer,
> > - plane_state);
> > +   if (comp)
> > +   mtk_ddp_comp_layer_config(comp, local_layer,
> > + plane_state);
> > plane_state->pending.config = false;
> > }
> > mtk_crtc->pending_planes = false;
> > @@ -401,7 +404,9 @@ int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, 
> > struct drm_plane *plane,
> > struct mtk_ddp_comp *comp;
> >  
> > comp = mtk_drm_ddp_comp_for_plane(crtc, plane, _layer);
> > -   return mtk_ddp_comp_layer_check(comp, local_layer, state);
> > +   if (comp)
> > +   return mtk_ddp_comp_layer_check(comp, local_layer, state);
> > +   return 0;
> >  }
> >  
> >  static void mtk_drm_crtc_atomic_enable(struct drm_crtc *crtc,
> > 
> > base-commit: 5a6fcbeabe3e20459ed8504690b2515dacc5246f
> 

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] Return from mtk_ovl_layer_config after mtk_ovl_layer_off

2019-12-11 Thread CK Hu
Hi, Mark:

On Wed, 2019-12-11 at 10:49 -0500, Mark Yacoub wrote:
> drm/mediatek: return if plane pending state is disabled.
> 
> If the plane pending state is disabled, call mtk_ovl_layer_off then
> return.
> This guarantees that that the state is valid for all operations when the
> pending state is enabled.

Reviewed-by: CK Hu 

> 
> Suggested-by: Sean Paul 
> To: CK Hu 
> To: dri-devel@lists.freedesktop.org
> Cc: Daniele Castagna 
> Cc: Philipp Zabel 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Matthias Brugger 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-media...@lists.infradead.org
> Signed-off-by: Mark Yacoub 
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 4a55bb6e2213..526b595eeff9 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -260,8 +260,10 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp 
> *comp, unsigned int idx,
>   unsigned int src_size = (pending->height << 16) | pending->width;
>   unsigned int con;
>  
> - if (!pending->enable)
> + if (!pending->enable) {
>   mtk_ovl_layer_off(comp, idx);
> + return;
> + }
>  
>   con = ovl_fmt_convert(ovl, fmt);
>   if (idx != 0)
> @@ -283,8 +285,7 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp 
> *comp, unsigned int idx,
>   writel_relaxed(offset, comp->regs + DISP_REG_OVL_OFFSET(idx));
>   writel_relaxed(addr, comp->regs + DISP_REG_OVL_ADDR(ovl, idx));
>  
> - if (pending->enable)
> - mtk_ovl_layer_on(comp, idx);
> + mtk_ovl_layer_on(comp, idx);
>  }
>  
>  static void mtk_ovl_bgclr_in_on(struct mtk_ddp_comp *comp)

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2] Turn off Alpha bit when plane format has no alpha

2019-12-11 Thread CK Hu
Hi, Mark:

On Wed, 2019-12-11 at 10:49 -0500, Mark Yacoub wrote:
> drm/mediatek: Add OVL_CON_ALPHA only when the plane format has_alpha.
> 
> This change enables XR24 format to be displayed as an overlay on top of
> the primary plane.

Reviewed-by: CK Hu 

> 
> Suggested-by: Sean Paul 
> To: CK Hu 
> To: dri-devel@lists.freedesktop.org
> Cc: Daniele Castagna 
> Cc: Philipp Zabel 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Matthias Brugger 
> Cc: linux-arm-ker...@lists.infradead.org
> Cc: linux-media...@lists.infradead.org
> Signed-off-by: Mark Yacoub 
> ---
>  drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c 
> b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> index 526b595eeff9..a7851756dddf 100644
> --- a/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> +++ b/drivers/gpu/drm/mediatek/mtk_disp_ovl.c
> @@ -266,7 +266,7 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp 
> *comp, unsigned int idx,
>   }
>  
>   con = ovl_fmt_convert(ovl, fmt);
> - if (idx != 0)
> + if (state->base.fb->format->has_alpha)
>   con |= OVL_CON_AEN | OVL_CON_ALPHA;
>  
>   if (pending->rotation & DRM_MODE_REFLECT_Y) {

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [RESEND PATCH 5/5] drm/amdgpu: Switch from system_highpri_wq to system_unbound_wq

2019-12-11 Thread Ma, Le
[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Le Ma 

Regards,
Ma Le

-Original Message-
From: Andrey Grodzovsky  
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
Cc: Deucher, Alexander ; Ma, Le ; 
Zhang, Hawking ; Quan, Evan ; 
Grodzovsky, Andrey 
Subject: [RESEND PATCH 5/5] drm/amdgpu: Switch from system_highpri_wq to 
system_unbound_wq

This is to avoid queueing jobs to same CPU during XGMI hive reset because there 
is a strict timeline for when the reset commands must reach all the GPUs in the 
hive.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e4089a0..1518565 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3842,7 +3842,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info 
*hive,
list_for_each_entry(tmp_adev, device_list_handle, 
gmc.xgmi.head) {
/* For XGMI run all resets in parallel to speed up the 
process */
if (tmp_adev->gmc.xgmi.num_physical_nodes > 1) {
-   if (!queue_work(system_highpri_wq, 
_adev->xgmi_reset_work))
+   if (!queue_work(system_unbound_wq, 
_adev->xgmi_reset_work))
r = -EALREADY;
} else
r = amdgpu_asic_reset(tmp_adev);
--
2.7.4
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset synchronization.

2019-12-11 Thread Ma, Le
[AMD Official Use Only - Internal Distribution Only]






-Original Message-
From: Andrey Grodzovsky 
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
Cc: Deucher, Alexander ; Ma, Le ; 
Zhang, Hawking ; Quan, Evan ; 
Grodzovsky, Andrey 
Subject: [RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset 
synchronization.



Use task barrier in XGMI hive to synchronize ASIC resets across devices in XGMI 
hive.



Signed-off-by: Andrey Grodzovsky 
mailto:andrey.grodzov...@amd.com>>

---

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 42 +-

1 file changed, 36 insertions(+), 6 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 1d19edfa..e4089a0 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

@@ -67,6 +67,7 @@

#include "amdgpu_tmz.h"



 #include 

+#include 



 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");

MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");

@@ -2663,14 +2664,43 @@ static void amdgpu_device_xgmi_reset_func(struct 
work_struct *__work)  {

   struct amdgpu_device *adev =

   container_of(__work, struct amdgpu_device, 
xgmi_reset_work);

+  struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0);



-   if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)

-   adev->asic_reset_res = (adev->in_baco == false) ?

-   
amdgpu_device_baco_enter(adev->ddev) :

-   
qamdgpu_device_baco_exit(adev->ddev);

-   else

-   adev->asic_reset_res = amdgpu_asic_reset(adev);

+  /*

+  * Use task barrier to synchronize all xgmi reset works across the

+  * hive.

+  * task_barrier_enter and task_barrier_exit will block untill all the

+  * threads running the xgmi reset works reach those points. I assume

+  * guarantee of progress here for all the threads as the workqueue 
code

+  * creates new worker threads as needed by amount of work items in 
queue

+  * (see worker_thread) and also each thread sleeps in the barrir and 
by

+  * this yielding the CPU for other work threads to make progress.

+  */

[Le]: This comments can be adjusted since we switch to system_unbound_wq in 
patch #5.

+  if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {

+

+  if (hive)

+  task_barrier_enter(>tb);

[Le]: The multiple hive condition can be checked only once and moved to the 
location right after the assignment.

+

+  adev->asic_reset_res = 
amdgpu_device_baco_enter(adev->ddev);

+

+  if (adev->asic_reset_res)

+  goto fail;

+

+  if (hive)

+  task_barrier_exit(>tb);

[Le]: Same as above.

+

+  adev->asic_reset_res = 
amdgpu_device_baco_exit(adev->ddev);

+

+  if (adev->asic_reset_res)

+  goto fail;

+  } else {

+  if (hive)

+  task_barrier_full(>tb);

[Le]: Same as above.



With above addressed, Reviewed-by: Le Ma mailto:le...@amd.com>>



Regards,

Ma Le

+

+  adev->asic_reset_res =  amdgpu_asic_reset(adev);

+  }



+fail:

   if (adev->asic_reset_res)

   DRM_WARN("ASIC reset failed with error, %d for drm dev, 
%s",

adev->asic_reset_res, adev->ddev->unique);

--

2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [RESEND PATCH 3/5] drm/amdgpu: Add task barrier to XGMI hive.

2019-12-11 Thread Ma, Le
[AMD Official Use Only - Internal Distribution Only]

Reviewed-by: Le Ma 

Regards,
Ma Le

-Original Message-
From: Andrey Grodzovsky  
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
Cc: Deucher, Alexander ; Ma, Le ; 
Zhang, Hawking ; Quan, Evan ; 
Grodzovsky, Andrey 
Subject: [RESEND PATCH 3/5] drm/amdgpu: Add task barrier to XGMI hive.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 4   
drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 61d13d8..5cf920d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -261,6 +261,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct 
amdgpu_device *adev, int lo
INIT_LIST_HEAD(>device_list);
mutex_init(>hive_lock);
mutex_init(>reset_lock);
+   task_barrier_init(>tb);
 
if (lock)
mutex_lock(>hive_lock);
@@ -408,6 +409,8 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
top_info->num_nodes = count;
hive->number_devices = count;
 
+   task_barrier_add_task(>tb);
+
if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP)) {
list_for_each_entry(tmp_adev, >device_list, 
gmc.xgmi.head) {
/* update node list for other device in the hive */ @@ 
-470,6 +473,7 @@ void amdgpu_xgmi_remove_device(struct amdgpu_device *adev)
mutex_destroy(>hive_lock);
mutex_destroy(>reset_lock);
} else {
+   task_barrier_rem_task(>tb);
amdgpu_xgmi_sysfs_rem_dev_info(adev, hive);
mutex_unlock(>hive_lock);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
index bbf504f..74011fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
@@ -22,6 +22,7 @@
 #ifndef __AMDGPU_XGMI_H__
 #define __AMDGPU_XGMI_H__
 
+#include 
 #include "amdgpu_psp.h"
 
 struct amdgpu_hive_info {
@@ -33,6 +34,7 @@ struct amdgpu_hive_info {
struct device_attribute dev_attr;
struct amdgpu_device *adev;
int pstate; /*0 -- low , 1 -- high , -1 unknown*/
+   struct task_barrier tb;
 };
 
 struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev, int 
lock);
--
2.7.4
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [RESEND PATCH 1/5] drm/amdgpu: reverts commit b01245ff54db66073b104ac9d9fbefb7b264b36d.

2019-12-11 Thread Ma, Le
[AMD Official Use Only - Internal Distribution Only]




-Original Message-
From: Andrey Grodzovsky 
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
Cc: Deucher, Alexander ; Ma, Le ; 
Zhang, Hawking ; Quan, Evan ; 
Grodzovsky, Andrey 
Subject: [RESEND PATCH 1/5] drm/amdgpu: reverts commit 
b01245ff54db66073b104ac9d9fbefb7b264b36d.



In preparation for doing XGMI reset synchronization using task barrier.



Signed-off-by: Andrey Grodzovsky 

---

drivers/gpu/drm/amd/amdgpu/amdgpu.h|  2 -

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 76 +-

2 files changed, 12 insertions(+), 66 deletions(-)



diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

index a78a363..50bab33 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h

@@ -1001,8 +1001,6 @@ struct amdgpu_device {



boolpm_sysfs_en;

   boolucode_sysfs_en;

-

-   boolin_baco;

};



 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device 
*bdev) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

index 7324a5f..1d19edfa 100644

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

@@ -2667,7 +2667,7 @@ static void amdgpu_device_xgmi_reset_func(struct 
work_struct *__work)

   if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)

   adev->asic_reset_res = (adev->in_baco == false) ?

   
amdgpu_device_baco_enter(adev->ddev) :

-   
amdgpu_device_baco_exit(adev->ddev);

+  
qamdgpu_device_baco_exit(adev->ddev);

[Le]: Typo here. With it fixed, Reviewed-by: Le Ma 
mailto:le...@amd.com>>



Regards,

Ma Le

   else

   adev->asic_reset_res = amdgpu_asic_reset(adev);



@@ -3796,18 +3796,13 @@ static int amdgpu_device_pre_asic_reset(struct 
amdgpu_device *adev,

   return r;

}



-static int amdgpu_do_asic_reset(struct amdgpu_device *adev,

-  struct amdgpu_hive_info *hive,

+static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,

  struct list_head *device_list_handle,

  bool *need_full_reset_arg)

{

   struct amdgpu_device *tmp_adev = NULL;

   bool need_full_reset = *need_full_reset_arg, vram_lost = false;

   int r = 0;

-   int cpu = smp_processor_id();

-   bool use_baco =

-   (amdgpu_asic_reset_method(adev) == 
AMD_RESET_METHOD_BACO) ?

-   true : false;



/*

* ASIC reset has to be done on all HGMI hive nodes ASAP @@ -3815,62 
+3810,22 @@ static int amdgpu_do_asic_reset(struct amdgpu_device *adev,

*/

   if (need_full_reset) {

   list_for_each_entry(tmp_adev, device_list_handle, 
gmc.xgmi.head) {

-   /*

-   * For XGMI run all resets in parallel to 
speed up the

-   * process by scheduling the highpri wq on 
different

-   * cpus. For XGMI with baco reset, all nodes 
must enter

-   * baco within close proximity before anyone 
exit.

-   */

+  /* For XGMI run all resets in parallel to 
speed up the process */

   if (tmp_adev->gmc.xgmi.num_physical_nodes > 
1) {

-   if (!queue_work_on(cpu, 
system_highpri_wq,

-  
_adev->xgmi_reset_work))

+  if 
(!queue_work(system_highpri_wq, _adev->xgmi_reset_work))

   r = -EALREADY;

-   cpu = cpumask_next(cpu, 
cpu_online_mask);

   } else

   r = amdgpu_asic_reset(tmp_adev);

-   if (r)

-   break;

-   }

-

-   /* For XGMI wait for all work to complete before 
proceed */

-   if (!r) {

-   list_for_each_entry(tmp_adev, 
device_list_handle,

-   gmc.xgmi.head) {

-   if 

RE: [RESEND PATCH 2/5] drm: Add Reusable task barrier.

2019-12-11 Thread Ma, Le
[AMD Official Use Only - Internal Distribution Only]






-Original Message-
From: Andrey Grodzovsky 
Sent: Thursday, December 12, 2019 4:39 AM
To: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
Cc: Deucher, Alexander ; Ma, Le ; 
Zhang, Hawking ; Quan, Evan ; 
Grodzovsky, Andrey 
Subject: [RESEND PATCH 2/5] drm: Add Reusable task barrier.



It is used to synchronize N threads at a rendevouz point before execution of 
critical code that has to be started by all the threads at approximatly the 
same time.



Signed-off-by: Andrey Grodzovsky 
mailto:andrey.grodzov...@amd.com>>

---

include/drm/task_barrier.h | 106 +

1 file changed, 106 insertions(+)

create mode 100644 include/drm/task_barrier.h



diff --git a/include/drm/task_barrier.h b/include/drm/task_barrier.h new file 
mode 100644 index 000..81fb0f7

--- /dev/null

+++ b/include/drm/task_barrier.h

@@ -0,0 +1,106 @@

+/*

+ * Copyright 2019 Advanced Micro Devices, Inc.

+ *

+ * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.

+ *

+ */

+#include 

+#include 

+

+/*

+ * Reusable 2 PHASE task barrier (randevouz point) implementation for N tasks.

+ * Based on the Little book of sempahores -

+https://greenteapress.com/wp/semaphores/

+ */

+

+

+

+#ifndef DRM_TASK_BARRIER_H_

+#define DRM_TASK_BARRIER_H_

+



[Le]: It might be better to prefix "drm_" to the functions and structure below, 
even this header file name.



+/*

+ * Represents an instance of a task barrier.

+ */

+struct task_barrier {

+  unsigned int n;

[Le]: We can define it as signed type here for more common use.

+  atomic_t count;

+  struct semaphore enter_turnstile;

+  struct semaphore exit_turnstile;

+};

+

+static inline void task_barrier_signal_turnstile(struct semaphore *turnstile,

+  unsigned 
int n)

+{

+  int i;

+

+  for (i = 0 ; i < n; i++)

+  up(turnstile);

+}

+

+static inline void task_barrier_init(struct task_barrier *tb) {

+  tb->n = 0;

+  atomic_set(>count, 0);

+  sema_init(>enter_turnstile, 0);

+  sema_init(>exit_turnstile, 0);

+}

+

+static inline void task_barrier_add_task(struct task_barrier *tb) {

+  tb->n++;

+}

+

+static inline void task_barrier_rem_task(struct task_barrier *tb) {

+  tb->n--;

+}

+

+/*

+ * Lines up all the threads BEFORE the critical point.

+ *

+ * When all thread passed this code the entry barrier is back to locked state.

+ */

+static inline void task_barrier_enter(struct task_barrier *tb) {

+  if (atomic_inc_return(>count) == tb->n)

+  task_barrier_signal_turnstile(>enter_turnstile, 
tb->n);

+

+  down(>enter_turnstile);

+}

+

+/*

+ * Lines up all the threads AFTER the critical point.

+ *

+ * This function is used to avoid any one thread running ahead of the

+reset if

[Le]: No need to mention "reset" here.



With the above addressed, Acked-by: Le Ma le...@amd.com



Regards,

Ma Le

+ * the barrier is used in a loop (repeatedly) .

+ */

+static inline void task_barrier_exit(struct task_barrier *tb) {

+  if (atomic_dec_return(>count) == 0)

+  task_barrier_signal_turnstile(>exit_turnstile, 
tb->n);

+

+  down(>exit_turnstile);

+}

+

+static inline void task_barrier_full(struct task_barrier *tb) {

+  task_barrier_enter(tb);

+  task_barrier_exit(tb);

+}

+

+#endif

--

2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/1] drm/dp: get/set phy compliance pattern

2019-12-11 Thread Manasi Navare
Did you look at the build failure here?
The build fails for amdgpu that uses the old #define of DP_TEST_PHY_PATTERN
So you will have to send a patch for the amdgpu wherever they are using the 
older #define
along with this with correct explanation that name changed to match the spec.

Manasi

On Mon, Nov 18, 2019 at 11:55:55PM +0530, Animesh Manna wrote:
> During phy compliance auto test mode source need to read
> requested test pattern from sink through DPCD. After processing
> the request source need to set the pattern. So set/get method
> added in drm layer as it is DP protocol.
> 
> v1: As per review feedback from Manasi on RFC version,
> - added dp revision as function argument in set_phy_pattern api.
> - used int for link_rate and u8 for lane_count to align with existing code.
> 
> Signed-off-by: Animesh Manna 
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 93 +
>  include/drm/drm_dp_helper.h | 33 +++-
>  2 files changed, 125 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 2c7870aef469..91c80973aa83 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -1371,3 +1371,96 @@ int drm_dp_dsc_sink_supported_input_bpcs(const u8 
> dsc_dpcd[DP_DSC_RECEIVER_CAP_S
>   return num_bpc;
>  }
>  EXPORT_SYMBOL(drm_dp_dsc_sink_supported_input_bpcs);
> +
> +/**
> + * drm_dp_get_phy_test_pattern() - get the requested pattern from the sink.
> + * @aux: DisplayPort AUX channel
> + * @data: DP phy compliance test parameters.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux,
> + struct drm_dp_phy_test_params *data)
> +{
> + int err;
> + u8 rate, lanes;
> +
> + err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, );
> + if (err < 0)
> + return err;
> + data->link_rate = drm_dp_bw_code_to_link_rate(rate);
> +
> + err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, );
> + if (err < 0)
> + return err;
> + data->num_lanes = lanes & DP_MAX_LANE_COUNT_MASK;
> +
> + if (lanes & DP_ENHANCED_FRAME_CAP)
> + data->enahanced_frame_cap = true;
> +
> + err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, >phy_pattern);
> + if (err < 0)
> + return err;
> +
> + switch (data->phy_pattern) {
> + case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
> + err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0,
> +>custom80, 10);
> + if (err < 0)
> + return err;
> +
> + break;
> + case DP_PHY_TEST_PATTERN_CP2520:
> + err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET,
> +>hbr2_reset, 2);
> + if (err < 0)
> + return err;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_dp_get_phy_test_pattern);
> +
> +/**
> + * drm_dp_set_phy_test_pattern() - set the pattern to the sink.
> + * @aux: DisplayPort AUX channel
> + * @data: DP phy compliance test parameters.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux,
> + struct drm_dp_phy_test_params *data, u8 dp_rev)
> +{
> + int err, i;
> + u8 link_config[2];
> + u8 test_pattern;
> +
> + link_config[0] = drm_dp_link_rate_to_bw_code(data->link_rate);
> + link_config[1] = data->num_lanes;
> + if (data->enahanced_frame_cap)
> + link_config[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
> + err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, link_config, 2);
> + if (err < 0)
> + return err;
> +
> + test_pattern = data->phy_pattern;
> + if (dp_rev < 0x12) {
> + test_pattern = (test_pattern << 2) &
> +DP_LINK_QUAL_PATTERN_11_MASK;
> + err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET,
> +  test_pattern);
> + if (err < 0)
> + return err;
> + } else {
> + for (i = 0; i < data->num_lanes; i++) {
> + err = drm_dp_dpcd_writeb(aux,
> +  DP_LINK_QUAL_LANE0_SET + i,
> +  test_pattern);
> + if (err < 0)
> + return err;
> + }
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_dp_set_phy_test_pattern);
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 51ecb5112ef8..a64267d197d0 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -699,7 +699,16 @@
>  # define DP_TEST_CRC_SUPPORTED   (1 << 5)
>  # define DP_TEST_COUNT_MASK  0xf
>  
> 

Re: [Intel-gfx] [PATCH] drm/i915/display: cleanup intel_bw_state on i915 module removal

2019-12-11 Thread Lucas De Marchi

On Wed, Dec 11, 2019 at 12:10:41PM +0530, Bharadiya,Pankaj wrote:

On Tue, Dec 10, 2019 at 09:57:39PM -0800, Lucas De Marchi wrote:

On Mon, Dec 09, 2019 at 08:09:02PM +0530, Pankaj Bharadiya wrote:
>intel_bw_state allocated memory is not getting freed even after
>module removal.
>
>kmemleak reported backtrace:
>
>   [<79019739>] kmemdup+0x17/0x40
>   [] intel_bw_duplicate_state+0x1b/0x40 [i915]
>   [<7423ed0c>] drm_atomic_get_private_obj_state+0xca/0x140
>   [<100e3533>] intel_bw_atomic_check+0x133/0x350 [i915]
>   [<126d0e0c>] intel_atomic_check+0x1ab7/0x20d0 [i915]
>   [] drm_atomic_check_only+0x563/0x810
>   [] drm_atomic_commit+0xe/0x50
>   [] drm_atomic_helper_disable_all+0x133/0x160
>   [<3c44760c>] drm_atomic_helper_shutdown+0x65/0xc0
>   [<414e3e5c>] i915_driver_remove+0xcb/0x130 [i915]
>   [] i915_pci_remove+0x19/0x40 [i915]
>   [<2dcbd148>] pci_device_remove+0x36/0xb0
>   [<3c8c6b0a>] device_release_driver_internal+0xe0/0x1c0
>   [<580e9566>] unbind_store+0xc3/0x120
>   [<869d0df5>] kernfs_fop_write+0x104/0x190
>   [<4dc1a355>] vfs_write+0xb9/0x1d0

what I find strange in this is that the last state was allocated by the
"driver remove" code path.

>
>Call the drm_atomic_private_obj_fini(), which inturn calls the
>intel_bw_destroy_state() to make sure the intel_bw_state memory is
>freed properly.
>
>Signed-off-by: Pankaj Bharadiya 
>---
>drivers/gpu/drm/i915/display/intel_bw.c  | 5 +
>drivers/gpu/drm/i915/display/intel_bw.h  | 1 +
>drivers/gpu/drm/i915/display/intel_display.c | 2 ++
>3 files changed, 8 insertions(+)
>
>diff --git a/drivers/gpu/drm/i915/display/intel_bw.c 
b/drivers/gpu/drm/i915/display/intel_bw.c
>index dcb66a33be9b..b228671d5a5d 100644
>--- a/drivers/gpu/drm/i915/display/intel_bw.c
>+++ b/drivers/gpu/drm/i915/display/intel_bw.c
>@@ -486,3 +486,8 @@ int intel_bw_init(struct drm_i915_private *dev_priv)
>
>return 0;
>}
>+
>+void intel_bw_cleanup(struct drm_i915_private *dev_priv)
>+{
>+   drm_atomic_private_obj_fini(_priv->bw_obj);
>+}
>diff --git a/drivers/gpu/drm/i915/display/intel_bw.h 
b/drivers/gpu/drm/i915/display/intel_bw.h
>index 9db10af012f4..20b9ad241802 100644
>--- a/drivers/gpu/drm/i915/display/intel_bw.h
>+++ b/drivers/gpu/drm/i915/display/intel_bw.h
>@@ -25,6 +25,7 @@ struct intel_bw_state {
>
>void intel_bw_init_hw(struct drm_i915_private *dev_priv);
>int intel_bw_init(struct drm_i915_private *dev_priv);
>+void intel_bw_cleanup(struct drm_i915_private *dev_priv);
>int intel_bw_atomic_check(struct intel_atomic_state *state);
>void intel_bw_crtc_update(struct intel_bw_state *bw_state,
>  const struct intel_crtc_state *crtc_state);
>diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
b/drivers/gpu/drm/i915/display/intel_display.c
>index 3190aa27ffdc..756eb90b1bb1 100644
>--- a/drivers/gpu/drm/i915/display/intel_display.c
>+++ b/drivers/gpu/drm/i915/display/intel_display.c
>@@ -17912,6 +17912,8 @@ void intel_modeset_driver_remove(struct 
drm_i915_private *i915)
>
>intel_gmbus_teardown(i915);
>
>+   intel_bw_cleanup(i915);

This doesn't seem to match the (reverse) order of
intel_modeset_init()... but it's actually the gmbus_teardown() that is
out of place. Did you check if it's not a wrong shutdown ordering?



In intel_modeset_init(), intel_gmbus_setup() happens after
intel_bw_init().
I think the patch follows the reverse ordering properly.
Am I missing anything?


I said it seems that it's the gmbus_teardown() that is out of place.
Have you seen my comment above? Why are we duplicating the bw_state on
the module-remove code path?

Lucas De Marchi



Thanks,
Pankaj


thanks
Lucas De Marchi

>+
>destroy_workqueue(i915->flip_wq);
>destroy_workqueue(i915->modeset_wq);
>
>--
>2.23.0
>
>___
>Intel-gfx mailing list
>intel-...@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/intel-gfx

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 06/50] drm/bridge: dumb-vga-dac: Rename internal symbols to simple-bridge

2019-12-11 Thread Laurent Pinchart
Hi Sam,

(CC'ing Maxime)

On Wed, Dec 11, 2019 at 10:13:18PM +0100, Sam Ravnborg wrote:
> On Wed, Dec 11, 2019 at 12:57:06AM +0200, Laurent Pinchart wrote:
> > The dumb-vga-dac driver is a simple DRM bridge driver for simple VGA
> > DACs that don't require configuration. Other non-VGA bridges fall in a
> > similar category, and would benefit from a common driver. Prepare for
> > this by renaming the internal symbols from dumb-vga-dac to
> > simple-bridge.
> > 
> > Signed-off-by: Laurent Pinchart 
> > Reviewed-by: Andrzej Hajda 
> > Reviewed-by: Boris Brezillon 
> > Reviewed-by: Maxime Ripard 
>
> Maxime has a new email address today.
> The one used here bounces.

I know, but his Reviewed-by tag was given with the bootlin.com e-mail
address, so I haven't changed it. Maxime, should I update your tags in
this series ?

-- 
Regards,

Laurent Pinchart
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/1] drm/dp: get/set phy compliance pattern

2019-12-11 Thread Manasi Navare
On Mon, Nov 18, 2019 at 11:55:55PM +0530, Animesh Manna wrote:
> During phy compliance auto test mode source need to read
> requested test pattern from sink through DPCD. After processing
> the request source need to set the pattern. So set/get method
> added in drm layer as it is DP protocol.

You need to always make the changes, up the rev but still always include
this as part of the whole series before sending it out so that the reviewer 
gets a full context.

Also this was not sent to intel-gfx and only to dri-devel, these patches that 
are used in i915
but changes in DRM need to be sent to both the M-Ls.

Could you send this v1 along with the new revisions of other patches together 
as a series
to both intel-gfx and dri-devel? That would also make it easier for the review
since I see the patches 5-7 sent with new revisions but not others (1-4) which 
proobably have a r-b or ack,
but new revision of the wnetire series would be great.

Manasi

> 
> v1: As per review feedback from Manasi on RFC version,
> - added dp revision as function argument in set_phy_pattern api.
> - used int for link_rate and u8 for lane_count to align with existing code.
> 
> Signed-off-by: Animesh Manna 
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 93 +
>  include/drm/drm_dp_helper.h | 33 +++-
>  2 files changed, 125 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 2c7870aef469..91c80973aa83 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -1371,3 +1371,96 @@ int drm_dp_dsc_sink_supported_input_bpcs(const u8 
> dsc_dpcd[DP_DSC_RECEIVER_CAP_S
>   return num_bpc;
>  }
>  EXPORT_SYMBOL(drm_dp_dsc_sink_supported_input_bpcs);
> +
> +/**
> + * drm_dp_get_phy_test_pattern() - get the requested pattern from the sink.
> + * @aux: DisplayPort AUX channel
> + * @data: DP phy compliance test parameters.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +int drm_dp_get_phy_test_pattern(struct drm_dp_aux *aux,
> + struct drm_dp_phy_test_params *data)
> +{
> + int err;
> + u8 rate, lanes;
> +
> + err = drm_dp_dpcd_readb(aux, DP_TEST_LINK_RATE, );
> + if (err < 0)
> + return err;
> + data->link_rate = drm_dp_bw_code_to_link_rate(rate);
> +
> + err = drm_dp_dpcd_readb(aux, DP_TEST_LANE_COUNT, );
> + if (err < 0)
> + return err;
> + data->num_lanes = lanes & DP_MAX_LANE_COUNT_MASK;
> +
> + if (lanes & DP_ENHANCED_FRAME_CAP)
> + data->enahanced_frame_cap = true;
> +
> + err = drm_dp_dpcd_readb(aux, DP_PHY_TEST_PATTERN, >phy_pattern);
> + if (err < 0)
> + return err;
> +
> + switch (data->phy_pattern) {
> + case DP_PHY_TEST_PATTERN_80BIT_CUSTOM:
> + err = drm_dp_dpcd_read(aux, DP_TEST_80BIT_CUSTOM_PATTERN_7_0,
> +>custom80, 10);
> + if (err < 0)
> + return err;
> +
> + break;
> + case DP_PHY_TEST_PATTERN_CP2520:
> + err = drm_dp_dpcd_read(aux, DP_TEST_HBR2_SCRAMBLER_RESET,
> +>hbr2_reset, 2);
> + if (err < 0)
> + return err;
> + }
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_dp_get_phy_test_pattern);
> +
> +/**
> + * drm_dp_set_phy_test_pattern() - set the pattern to the sink.
> + * @aux: DisplayPort AUX channel
> + * @data: DP phy compliance test parameters.
> + *
> + * Returns 0 on success or a negative error code on failure.
> + */
> +int drm_dp_set_phy_test_pattern(struct drm_dp_aux *aux,
> + struct drm_dp_phy_test_params *data, u8 dp_rev)
> +{
> + int err, i;
> + u8 link_config[2];
> + u8 test_pattern;
> +
> + link_config[0] = drm_dp_link_rate_to_bw_code(data->link_rate);
> + link_config[1] = data->num_lanes;
> + if (data->enahanced_frame_cap)
> + link_config[1] |= DP_LANE_COUNT_ENHANCED_FRAME_EN;
> + err = drm_dp_dpcd_write(aux, DP_LINK_BW_SET, link_config, 2);
> + if (err < 0)
> + return err;
> +
> + test_pattern = data->phy_pattern;
> + if (dp_rev < 0x12) {
> + test_pattern = (test_pattern << 2) &
> +DP_LINK_QUAL_PATTERN_11_MASK;
> + err = drm_dp_dpcd_writeb(aux, DP_TRAINING_PATTERN_SET,
> +  test_pattern);
> + if (err < 0)
> + return err;
> + } else {
> + for (i = 0; i < data->num_lanes; i++) {
> + err = drm_dp_dpcd_writeb(aux,
> +  DP_LINK_QUAL_LANE0_SET + i,
> +  test_pattern);
> + if (err < 0)
> + return err;
> + }
> + }
> +
> + return 0;
> +}
> 

[pull] amdgpu, amdkfd, radeon drm-next-5.6

2019-12-11 Thread Alex Deucher
Hi Dave, Daniel,

Kicking off 5.6 with new stuff from AMD.  There is a UAPI addition.  We
added a new firmware for display, and this just adds the version query
to our existing firmware query interface.  UMDs like mesa use this interface to
query things like CP or UVD firmware versions to see what features are
supported.

The following changes since commit 622b2a0ab647d2755f2c1f1000d3403e86a69763:

  drm/amdgpu/vcn: finish delay work before release resources (2019-11-13 
15:29:42 -0500)

are available in the Git repository at:

  git://people.freedesktop.org/~agd5f/linux tags/drm-next-5.6-2019-12-11

for you to fetch changes up to ad808910be68dcf8da5d837d4511d00ad5d3678a:

  drm/amdgpu: fix license on Kconfig and Makefiles (2019-12-11 15:22:08 -0500)


drm-next-5.6-2019-12-11:

amdgpu:
- Add MST atomic routines
- Add support for DMCUB (new helper microengine for displays)
- Add OEM i2c support in DC
- Use vstartup for vblank events on DCN
- Simplify Kconfig for DC
- Renoir fixes for DC
- Clean up function pointers in DC
- Initial support for HDCP 2.x
- Misc code cleanups
- GFX10 fixes
- Rework JPEG engine handling for VCN
- Add clock and power gating support for JPEG
- BACO support for Arcturus
- Cleanup PSP ring handling
- Add framework for using BACO with runtime pm to save power
- Move core pci state handling out of the driver for pm ops
- Allow guest power control in 1 VF case with SR-IOV
- SR-IOV fixes
- RAS fixes
- Support for power metrics on renoir
- Golden settings updates for gfx10
- Enable gfxoff on supported navi10 skus
- Update MAINTAINERS

amdkfd:
- Clean up generational gfx code
- Fixes for gfx10
- DIQ fixes
- Share more code with amdgpu

radeon:
- PPC DMA fix
- Register checker fixes for r1xx/r2xx
- Misc cleanups


Alex Deucher (34):
  drm/amdgpu/display: fix the build when CONFIG_DRM_AMD_DC_DCN is not set
  drm/amdgpu/display: fix warning when CONFIG_DRM_AMD_DC_DCN is not set
  drm/amdgpu/soc15: move struct definition around to align with other soc15 
asics
  drm/amdgpu/nv: add asic func for fetching vbios from rom directly
  drm/amdgpu/powerplay: properly set PP_GFXOFF_MASK (v2)
  drm/amdgpu: disable gfxoff when using register read interface
  drm/amdgpu: remove experimental flag for Navi14
  drm/amdgpu: disable gfxoff on original raven
  Revert "drm/amd/display: enable S/G for RAVEN chip"
  drm/amdgpu: add asic callback for BACO support
  drm/amdgpu: add supports_baco callback for soc15 asics. (v2)
  drm/amdgpu: add supports_baco callback for SI asics.
  drm/amdgpu: add supports_baco callback for CIK asics.
  drm/amdgpu: add supports_baco callback for VI asics.
  drm/amdgpu: add supports_baco callback for NV asics.
  drm/amdgpu: add a amdgpu_device_supports_baco helper
  drm/amdgpu: rename amdgpu_device_is_px to amdgpu_device_supports_boco (v2)
  drm/amdgpu: add additional boco checks to runtime suspend/resume (v2)
  drm/amdgpu: split swSMU baco_reset into enter and exit
  drm/amdgpu: add helpers for baco entry and exit
  drm/amdgpu: add baco support to runtime suspend/resume
  drm/amdgpu: start to disentangle boco from runtime pm
  drm/amdgpu: disentangle runtime pm and vga_switcheroo
  drm/amdgpu: enable runtime pm on BACO capable boards if runpm=1
  drm/amdgpu: simplify runtime suspend
  drm/amd/display: add default clocks if not able to fetch them
  MAINTAINERS: Drop Rex Zhu for amdgpu powerplay
  drm/amdgpu: move pci handling out of pm ops
  drm/amdgpu: flag vram lost on baco reset for VI/CIK
  drm/amd/display: re-enable wait in pipelock, but add timeout
  drm/radeon: fix r1xx/r2xx register checker for POT textures
  drm/amdgpu: add header line for power profile on Arcturus
  drm/amdgpu/display: add fallthrough comment
  drm/amdgpu: fix license on Kconfig and Makefiles

Alex Sierra (2):
  drm/amdgpu: add flag to indicate amdgpu vm context
  amd/amdgpu: force to trigger a no-retry-fault after a retry-fault

Alvin Lee (1):
  drm/amd/display: Changes in dc to allow full update in some cases

Amanda Liu (1):
  drm/amd/display: Fix screen tearing on vrr tests

Andrey Grodzovsky (1):
  drm/amdgpu: Fix BACO entry failure in NAVI10.

Anthony Koo (8):
  drm/amd/display: set MSA MISC1 bit 6 while sending colorimetry in VSC SDP
  drm/amd/display: Clean up some code with unused registers
  drm/amd/display: cleanup of construct and destruct funcs
  drm/amd/display: cleanup of function pointer tables
  drm/amd/display: rename core_dc to dc
  drm/amd/display: add separate of private hwss functions
  drm/amd/display: add DP protocol version
  drm/amd/display: Limit NV12 chroma workaround

Aric Cyr (7):
  drm/amd/display: 3.2.57
  drm/amd/display: 3.2.58
  drm/amd/display: 

Re: [PATCH v9 10/25] mm/gup: introduce pin_user_pages*() and FOLL_PIN

2019-12-11 Thread John Hubbard
On 12/11/19 12:57 PM, Jonathan Corbet wrote:
> On Tue, 10 Dec 2019 18:53:03 -0800
> John Hubbard  wrote:
> 
>> Introduce pin_user_pages*() variations of get_user_pages*() calls,
>> and also pin_longterm_pages*() variations.
> 
> Just a couple of nits on the documentation patch
> 
>> +++ b/Documentation/core-api/pin_user_pages.rst
>> @@ -0,0 +1,232 @@
>> +.. SPDX-License-Identifier: GPL-2.0
>> +
>> +
>> +pin_user_pages() and related calls
>> +
>> +
>> +.. contents:: :local:
>> +
>> +Overview
>> +
>> +
>> +This document describes the following functions: ::
>> +
>> + pin_user_pages
>> + pin_user_pages_fast
>> + pin_user_pages_remote
> 
> You could just say "the following functions::" and get the result you're
> after with a slightly less alien plain-text reading experience.

I see. That works nicely: same result with fewer :'s. 

> 
> Of course, you could also just say "This document describes
> pin_user_pages(), pin_user_pages_fast(), and pin_user_pages_remote()." But
> that's a matter of personal taste, I guess.  Using the function() notation
> will cause the docs system to automatically link to the kerneldoc info,
> though.  

OK. I did try the single-sentence approach just now, but to me the one-per-line
seems to make both the text and the generated HTML slightly easier to look at. 
Of course, like you say, different people will have different preferences. So 
in the end I've combined the tips, like this:

+Overview
+
+
+This document describes the following functions::
+
+ pin_user_pages()
+ pin_user_pages_fast()
+ pin_user_pages_remote()


> 
>> +Basic description of FOLL_PIN
>> +=
>> +
>> +FOLL_PIN and FOLL_LONGTERM are flags that can be passed to the 
>> get_user_pages*()
>> +("gup") family of functions. FOLL_PIN has significant interactions and
>> +interdependencies with FOLL_LONGTERM, so both are covered here.
>> +
>> +FOLL_PIN is internal to gup, meaning that it should not appear at the gup 
>> call
>> +sites. This allows the associated wrapper functions  (pin_user_pages*() and
>> +others) to set the correct combination of these flags, and to check for 
>> problems
>> +as well.
>> +
>> +FOLL_LONGTERM, on the other hand, *is* allowed to be set at the gup call 
>> sites.
>> +This is in order to avoid creating a large number of wrapper functions to 
>> cover
>> +all combinations of get*(), pin*(), FOLL_LONGTERM, and more. Also, the
>> +pin_user_pages*() APIs are clearly distinct from the get_user_pages*() 
>> APIs, so
>> +that's a natural dividing line, and a good point to make separate wrapper 
>> calls.
>> +In other words, use pin_user_pages*() for DMA-pinned pages, and
>> +get_user_pages*() for other cases. There are four cases described later on 
>> in
>> +this document, to further clarify that concept.
>> +
>> +FOLL_PIN and FOLL_GET are mutually exclusive for a given gup call. However,
>> +multiple threads and call sites are free to pin the same struct pages, via 
>> both
>> +FOLL_PIN and FOLL_GET. It's just the call site that needs to choose one or 
>> the
>> +other, not the struct page(s).
>> +
>> +The FOLL_PIN implementation is nearly the same as FOLL_GET, except that 
>> FOLL_PIN
>> +uses a different reference counting technique.
>> +
>> +FOLL_PIN is a prerequisite to FOLL_LONGTGERM. Another way of saying that is,
> 
> FOLL_LONGTERM typoed there.
> 

Good catch. Fixed.

thanks,
-- 
John Hubbard
NVIDIA


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/2] drm: Handle connector tile support only for modes that match tile size

2019-12-11 Thread Manasi Navare
DRM Fb driver expects multiple CRTCs if it sees connector->has_tile
is set, but we need to handle tile support and look for multiple CRTCs
only for the modes that match the tile size. The other modes should
be able to be displayed without tile support or uisng single CRTC.

This patch adds the check to match the tile size with requested mode
to handle the tile support.

Cc: Ville Syrjälä 
Cc: Maarten Lankhorst 
Cc: Jani Nikula 
Cc: Dave Airlie 
Signed-off-by: Manasi Navare 
---
 drivers/gpu/drm/drm_fb_helper.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index fb9bff0f4581..4978363714a9 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1558,7 +1558,9 @@ static int drm_fb_helper_single_fb_probe(struct 
drm_fb_helper *fb_helper,
for (j = 0; j < mode_set->num_connectors; j++) {
struct drm_connector *connector = 
mode_set->connectors[j];
 
-   if (connector->has_tile) {
+   if (connector->has_tile &&
+   desired_mode->hdisplay == connector->tile_h_size &&
+   desired_mode->vdisplay == connector->tile_v_size) {
lasth = (connector->tile_h_loc == 
(connector->num_h_tile - 1));
lastv = (connector->tile_v_loc == 
(connector->num_v_tile - 1));
/* cloning to multiple tiles is just 
crazy-talk, so: */
-- 
2.19.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/2] drm/fbdev: Fallback to non tiled mode if all tiles not present

2019-12-11 Thread Manasi Navare
In case of tiled displays, if we hotplug just one connector,
fbcon currently just selects the preferred mode and if it is
tiled mode then that becomes a problem if rest of the tiles are
not present.
So in the fbdev driver on hotplug when we probe the client modeset,
if we dont find all the connectors for all tiles, then on a connector
with one tile, just fallback to the first available non tiled mode
to display over a single connector.
On the hotplug of the consecutive tiled connectors, if the tiled mode
no longer exists because of fbcon size limitation, then return
no modes for consecutive tiles but retain the non tiled mode
on the 0th tile.
Use the same logic in case of connected boot case as well.
This has been tested with Dell UP328K tiled monitor.

v3:
* Check Num tiled conns that are connected (Manasi)
v2:
* Set the modes on consecutive hotplugged tiles to no mode
if tiled mode is pruned (Dave)
v1:
* Just handle the 1st connector hotplug case
* v1 Reviewed-by: Dave Airlie 

Bugzilla: https://gitlab.freedesktop.org/drm/intel/issues/5
Suggested-by: Ville Syrjälä 
Suggested-by: Dave Airlie 
Cc: Ville Syrjälä 
Cc: Dave Airlie 
Signed-off-by: Manasi Navare 
Reviewed-by: Dave Airlie  (v2)
---
 drivers/gpu/drm/drm_client_modeset.c | 72 
 1 file changed, 72 insertions(+)

diff --git a/drivers/gpu/drm/drm_client_modeset.c 
b/drivers/gpu/drm/drm_client_modeset.c
index 895b73f23079..6d4a29e99ae2 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -114,6 +114,33 @@ drm_client_find_modeset(struct drm_client_dev *client, 
struct drm_crtc *crtc)
return NULL;
 }
 
+static struct drm_display_mode *
+drm_connector_get_tiled_mode(struct drm_connector *connector)
+{
+   struct drm_display_mode *mode;
+
+   list_for_each_entry(mode, >modes, head) {
+   if (mode->hdisplay == connector->tile_h_size &&
+   mode->vdisplay == connector->tile_v_size)
+   return mode;
+   }
+   return NULL;
+}
+
+static struct drm_display_mode *
+drm_connector_fallback_non_tiled_mode(struct drm_connector *connector)
+{
+   struct drm_display_mode *mode;
+
+   list_for_each_entry(mode, >modes, head) {
+   if (mode->hdisplay == connector->tile_h_size &&
+   mode->vdisplay == connector->tile_v_size)
+   continue;
+   return mode;
+   }
+   return NULL;
+}
+
 static struct drm_display_mode *
 drm_connector_has_preferred_mode(struct drm_connector *connector, int width, 
int height)
 {
@@ -348,8 +375,15 @@ static bool drm_client_target_preferred(struct 
drm_connector **connectors,
struct drm_connector *connector;
u64 conn_configured = 0;
int tile_pass = 0;
+   int num_tiled_conns = 0;
int i;
 
+   for (i = 0; i < connector_count; i++) {
+   if (connectors[i]->has_tile &&
+   connectors[i]->status == connector_status_connected)
+   num_tiled_conns++;
+   }
+
 retry:
for (i = 0; i < connector_count; i++) {
connector = connectors[i];
@@ -399,6 +433,28 @@ static bool drm_client_target_preferred(struct 
drm_connector **connectors,
list_for_each_entry(modes[i], >modes, head)
break;
}
+   /*
+* In case of tiled mode if all tiles not present fallback to
+* first available non tiled mode.
+* After all tiles are present, try to find the tiled mode
+* for all and if tiled mode not present due to fbcon size
+* limitations, use first non tiled mode only for
+* tile 0,0 and set to no mode for all other tiles.
+*/
+   if (connector->has_tile) {
+   if (num_tiled_conns <
+   connector->num_h_tile * connector->num_v_tile ||
+   (connector->tile_h_loc == 0 &&
+connector->tile_v_loc == 0 &&
+!drm_connector_get_tiled_mode(connector))) {
+   DRM_DEBUG_KMS("Falling back to non tiled mode 
on Connector %d\n",
+ connector->base.id);
+   modes[i] = 
drm_connector_fallback_non_tiled_mode(connector);
+   } else {
+   modes[i] = 
drm_connector_get_tiled_mode(connector);
+   }
+   }
+
DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name :
  "none");
conn_configured |= BIT_ULL(i);
@@ -515,6 +571,7 @@ static bool drm_client_firmware_config(struct 
drm_client_dev *client,
bool fallback = true, ret = true;
int num_connectors_enabled = 0;
int num_connectors_detected 

[PULL] drm-misc-fixes

2019-12-11 Thread Sean Paul


Hi Dave and Daniel,
A couple patches from -misc-fixes.


drm-misc-fixes-2019-12-11:
- Expand dma-buf MAINTAINER scope
- Fix mode matching for drivers not using picture_aspect_ratio

Cheers, Sean


The following changes since commit 6645d42d79d33e8a9fe262660a75d5f4556bbea9:

  dma-buf: Fix memory leak in sync_file_merge() (2019-11-25 10:21:33 +0100)

are available in the Git repository at:

  git://anongit.freedesktop.org/drm/drm-misc tags/drm-misc-fixes-2019-12-11

for you to fetch changes up to 78baee8d3b976a6a6a2c208e3a36d3f1e6297e6c:

  MAINTAINERS: Match on dma_buf|fence|resv anywhere (2019-12-10 11:26:19 +0100)


- Expand dma-buf MAINTAINER scope
- Fix mode matching for drivers not using picture_aspect_ratio


Daniel Vetter (1):
  MAINTAINERS: Match on dma_buf|fence|resv anywhere

Martin Blumenstingl (1):
  drm: meson: venc: cvbs: fix CVBS mode matching

 MAINTAINERS |  1 +
 drivers/gpu/drm/meson/meson_venc_cvbs.c | 48 ++---
 2 files changed, 28 insertions(+), 21 deletions(-)

-- 
Sean Paul, Software Engineer, Google / Chromium OS
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Nouveau] [PATCH 3/3] drm/nouveau: Support NVIDIA format modifiers

2019-12-11 Thread Ilia Mirkin
On Wed, Dec 11, 2019 at 4:04 PM James Jones  wrote:
>
> Allow setting the block layout of a nouveau FB
> object using DRM format modifiers.  When
> specified, the format modifier block layout and
> kind overrides the GEM buffer's implicit layout
> and kind.  The specified format modifier is
> validated against he list of modifiers supported
> by the target display hardware.
>
> Signed-off-by: James Jones 
> ---
>  drivers/gpu/drm/nouveau/dispnv50/wndw.c   |  8 +--
>  drivers/gpu/drm/nouveau/nouveau_display.c | 65 ++-
>  drivers/gpu/drm/nouveau/nouveau_display.h |  2 +
>  3 files changed, 69 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c 
> b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> index 70ad64cb2d34..06c1b18479c1 100644
> --- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> +++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
> @@ -43,7 +43,7 @@ nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct 
> nouveau_framebuffer *fb)
>  {
> struct nouveau_drm *drm = nouveau_drm(fb->base.dev);
> struct nv50_wndw_ctxdma *ctxdma;
> -   const u8kind = fb->nvbo->kind;
> +   const u8kind = fb->kind;
> const u32 handle = 0xfb00 | kind;
> struct {
> struct nv_dma_v0 base;
> @@ -243,7 +243,7 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, 
> bool modeset,
> if (asyw->state.fb != armw->state.fb || !armw->visible || modeset) {
> asyw->image.w = fb->base.width;
> asyw->image.h = fb->base.height;
> -   asyw->image.kind = fb->nvbo->kind;
> +   asyw->image.kind = fb->kind;
>
> ret = nv50_wndw_atomic_check_acquire_rgb(asyw);
> if (ret) {
> @@ -255,9 +255,9 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, 
> bool modeset,
> if (asyw->image.kind) {
> asyw->image.layout = 0;
> if (drm->client.device.info.chipset >= 0xc0)
> -   asyw->image.blockh = fb->nvbo->mode >> 4;
> +   asyw->image.blockh = fb->tile_mode >> 4;
> else
> -   asyw->image.blockh = fb->nvbo->mode;
> +   asyw->image.blockh = fb->tile_mode;
> asyw->image.blocks[0] = fb->base.pitches[0] / 64;
> asyw->image.pitch[0] = 0;
> } else {
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
> b/drivers/gpu/drm/nouveau/nouveau_display.c
> index f1509392d7b7..351b58410e1a 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -224,6 +224,50 @@ static const struct drm_framebuffer_funcs 
> nouveau_framebuffer_funcs = {
> .create_handle = nouveau_user_framebuffer_create_handle,
>  };
>
> +static int
> +nouveau_decode_mod(struct nouveau_drm *drm,
> +  uint64_t modifier,
> +  uint32_t *tile_mode,
> +  uint8_t *kind)
> +{
> +   struct nouveau_display *disp = nouveau_display(drm->dev);
> +   int mod;
> +
> +   BUG_ON(!tile_mode || !kind);
> +
> +   if (drm->client.device.info.chipset < 0x50) {

Not a full review, but you want to go off the family (chip_class iirc?
something like that, should be obvious). Sadly 0x67/0x68 are higher
than 0x50 numerically, but are logically part of the nv4x generation.

> +   return -EINVAL;
> +   }
> +
> +   BUG_ON(!disp->format_modifiers);
> +
> +   for (mod = 0;
> +(disp->format_modifiers[mod] != DRM_FORMAT_MOD_INVALID) &&
> +(disp->format_modifiers[mod] != modifier);
> +mod++);
> +
> +   if (disp->format_modifiers[mod] == DRM_FORMAT_MOD_INVALID)
> +   return -EINVAL;
> +
> +   if (modifier == DRM_FORMAT_MOD_LINEAR) {
> +   /* tile_mode will not be used in this case */
> +   *tile_mode = 0;
> +   *kind = 0;
> +   } else {
> +   /*
> +* Extract the block height and kind from the corresponding
> +* modifier fields.  See drm_fourcc.h for details.
> +*/
> +   *tile_mode = (uint32_t)(modifier & 0xF);
> +   *kind = (uint8_t)((modifier >> 12) & 0xFF);
> +
> +   if (drm->client.device.info.chipset >= 0xc0)
> +   *tile_mode <<= 4;
> +   }
> +
> +   return 0;
> +}
> +
>  static inline uint32_t
>  nouveau_get_width_in_blocks(uint32_t stride)
>  {
> @@ -300,6 +344,8 @@ nouveau_framebuffer_new(struct drm_device *dev,
> struct nouveau_framebuffer *fb;
> const struct drm_format_info *info;
> unsigned int width, height, i;
> +   uint32_t tile_mode;
> +   uint8_t kind;
> int ret;
>
>  /* YUV overlays have special requirements pre-NV50 */
> @@ -322,6 +368,18 @@ 

Re: [PATCH v3 06/50] drm/bridge: dumb-vga-dac: Rename internal symbols to simple-bridge

2019-12-11 Thread Sam Ravnborg
On Wed, Dec 11, 2019 at 12:57:06AM +0200, Laurent Pinchart wrote:
> The dumb-vga-dac driver is a simple DRM bridge driver for simple VGA
> DACs that don't require configuration. Other non-VGA bridges fall in a
> similar category, and would benefit from a common driver. Prepare for
> this by renaming the internal symbols from dumb-vga-dac to
> simple-bridge.
> 
> Signed-off-by: Laurent Pinchart 
> Reviewed-by: Andrzej Hajda 
> Reviewed-by: Boris Brezillon 
> Reviewed-by: Maxime Ripard 
Maxime has a new email address today.
The one used here bounces.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/nouveau: Support NVIDIA format modifiers

2019-12-11 Thread James Jones
Allow setting the block layout of a nouveau FB
object using DRM format modifiers.  When
specified, the format modifier block layout and
kind overrides the GEM buffer's implicit layout
and kind.  The specified format modifier is
validated against he list of modifiers supported
by the target display hardware.

Signed-off-by: James Jones 
---
 drivers/gpu/drm/nouveau/dispnv50/wndw.c   |  8 +--
 drivers/gpu/drm/nouveau/nouveau_display.c | 65 ++-
 drivers/gpu/drm/nouveau/nouveau_display.h |  2 +
 3 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/wndw.c 
b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
index 70ad64cb2d34..06c1b18479c1 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/wndw.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/wndw.c
@@ -43,7 +43,7 @@ nv50_wndw_ctxdma_new(struct nv50_wndw *wndw, struct 
nouveau_framebuffer *fb)
 {
struct nouveau_drm *drm = nouveau_drm(fb->base.dev);
struct nv50_wndw_ctxdma *ctxdma;
-   const u8kind = fb->nvbo->kind;
+   const u8kind = fb->kind;
const u32 handle = 0xfb00 | kind;
struct {
struct nv_dma_v0 base;
@@ -243,7 +243,7 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, bool 
modeset,
if (asyw->state.fb != armw->state.fb || !armw->visible || modeset) {
asyw->image.w = fb->base.width;
asyw->image.h = fb->base.height;
-   asyw->image.kind = fb->nvbo->kind;
+   asyw->image.kind = fb->kind;
 
ret = nv50_wndw_atomic_check_acquire_rgb(asyw);
if (ret) {
@@ -255,9 +255,9 @@ nv50_wndw_atomic_check_acquire(struct nv50_wndw *wndw, bool 
modeset,
if (asyw->image.kind) {
asyw->image.layout = 0;
if (drm->client.device.info.chipset >= 0xc0)
-   asyw->image.blockh = fb->nvbo->mode >> 4;
+   asyw->image.blockh = fb->tile_mode >> 4;
else
-   asyw->image.blockh = fb->nvbo->mode;
+   asyw->image.blockh = fb->tile_mode;
asyw->image.blocks[0] = fb->base.pitches[0] / 64;
asyw->image.pitch[0] = 0;
} else {
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index f1509392d7b7..351b58410e1a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -224,6 +224,50 @@ static const struct drm_framebuffer_funcs 
nouveau_framebuffer_funcs = {
.create_handle = nouveau_user_framebuffer_create_handle,
 };
 
+static int
+nouveau_decode_mod(struct nouveau_drm *drm,
+  uint64_t modifier,
+  uint32_t *tile_mode,
+  uint8_t *kind)
+{
+   struct nouveau_display *disp = nouveau_display(drm->dev);
+   int mod;
+
+   BUG_ON(!tile_mode || !kind);
+
+   if (drm->client.device.info.chipset < 0x50) {
+   return -EINVAL;
+   }
+
+   BUG_ON(!disp->format_modifiers);
+
+   for (mod = 0;
+(disp->format_modifiers[mod] != DRM_FORMAT_MOD_INVALID) &&
+(disp->format_modifiers[mod] != modifier);
+mod++);
+
+   if (disp->format_modifiers[mod] == DRM_FORMAT_MOD_INVALID)
+   return -EINVAL;
+
+   if (modifier == DRM_FORMAT_MOD_LINEAR) {
+   /* tile_mode will not be used in this case */
+   *tile_mode = 0;
+   *kind = 0;
+   } else {
+   /*
+* Extract the block height and kind from the corresponding
+* modifier fields.  See drm_fourcc.h for details.
+*/
+   *tile_mode = (uint32_t)(modifier & 0xF);
+   *kind = (uint8_t)((modifier >> 12) & 0xFF);
+
+   if (drm->client.device.info.chipset >= 0xc0)
+   *tile_mode <<= 4;
+   }
+
+   return 0;
+}
+
 static inline uint32_t
 nouveau_get_width_in_blocks(uint32_t stride)
 {
@@ -300,6 +344,8 @@ nouveau_framebuffer_new(struct drm_device *dev,
struct nouveau_framebuffer *fb;
const struct drm_format_info *info;
unsigned int width, height, i;
+   uint32_t tile_mode;
+   uint8_t kind;
int ret;
 
 /* YUV overlays have special requirements pre-NV50 */
@@ -322,6 +368,18 @@ nouveau_framebuffer_new(struct drm_device *dev,
return -EINVAL;
}
 
+   if (mode_cmd->flags & DRM_MODE_FB_MODIFIERS) {
+   if (nouveau_decode_mod(drm, mode_cmd->modifier[0], _mode,
+  )) {
+   DRM_DEBUG_KMS("Unsupported modifier: 0x%llx\n",
+ mode_cmd->modifier[0]);
+   return -EINVAL;
+   }
+   } else {
+   tile_mode = 

[PATCH 2/3] drm/nouveau: Check framebuffer size against bo

2019-12-11 Thread James Jones
Make sure framebuffer dimensions and tiling
parameters will not result in accesses beyond the
end of the GEM buffer they are bound to.

Signed-off-by: James Jones 
---
 drivers/gpu/drm/nouveau/nouveau_display.c | 93 +++
 1 file changed, 93 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c 
b/drivers/gpu/drm/nouveau/nouveau_display.c
index 6f038511a03a..f1509392d7b7 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -224,6 +224,72 @@ static const struct drm_framebuffer_funcs 
nouveau_framebuffer_funcs = {
.create_handle = nouveau_user_framebuffer_create_handle,
 };
 
+static inline uint32_t
+nouveau_get_width_in_blocks(uint32_t stride)
+{
+   /* GOBs per block in the x direction is always one, and GOBs are
+* 64 bytes wide
+*/
+   static const uint32_t log_block_width = 6;
+
+   return (stride + (1 << log_block_width) - 1) >> log_block_width;
+}
+
+static inline uint32_t
+nouveau_get_height_in_blocks(struct nouveau_drm *drm,
+uint32_t height,
+uint32_t log_block_height_in_gobs)
+{
+   uint32_t log_gob_height;
+   uint32_t log_block_height;
+
+   BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA);
+
+   if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI)
+   log_gob_height = 2;
+   else
+   log_gob_height = 3;
+
+   log_block_height = log_block_height_in_gobs + log_gob_height;
+
+   return (height + (1 << log_block_height) - 1) >> log_block_height;
+}
+
+static int
+nouveau_check_bl_size(struct nouveau_drm *drm, struct nouveau_bo *nvbo,
+ uint32_t offset, uint32_t stride, uint32_t h,
+ uint32_t tile_mode)
+{
+   uint32_t gob_size, bw, bh;
+   uint64_t bl_size;
+
+   BUG_ON(drm->client.device.info.family < NV_DEVICE_INFO_V0_TESLA);
+
+   if (drm->client.device.info.chipset >= 0xc0)
+   tile_mode >>= 4;
+
+   BUG_ON(tile_mode & 0xFFF0);
+
+   if (drm->client.device.info.family < NV_DEVICE_INFO_V0_FERMI)
+   gob_size = 256;
+   else
+   gob_size = 512;
+
+   bw = nouveau_get_width_in_blocks(stride);
+   bh = nouveau_get_height_in_blocks(drm, h, tile_mode);
+
+   bl_size = bw * bh * (1 << tile_mode) * gob_size;
+
+   DRM_DEBUG_KMS("offset=%u stride=%u h=%u tile_mode=0x%02x bw=%u bh=%u 
gob_size=%u bl_size=%llu size=%lu\n",
+ offset, stride, h, tile_mode, bw, bh, gob_size, bl_size,
+ nvbo->bo.mem.size);
+
+   if (bl_size + offset > nvbo->bo.mem.size)
+   return -ERANGE;
+
+   return 0;
+}
+
 int
 nouveau_framebuffer_new(struct drm_device *dev,
const struct drm_mode_fb_cmd2 *mode_cmd,
@@ -232,6 +298,8 @@ nouveau_framebuffer_new(struct drm_device *dev,
 {
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_framebuffer *fb;
+   const struct drm_format_info *info;
+   unsigned int width, height, i;
int ret;
 
 /* YUV overlays have special requirements pre-NV50 */
@@ -254,6 +322,31 @@ nouveau_framebuffer_new(struct drm_device *dev,
return -EINVAL;
}
 
+   info = drm_get_format_info(dev, mode_cmd);
+
+   for (i = 0; i < info->num_planes; i++) {
+   width = drm_format_info_plane_width(info,
+   mode_cmd->width,
+   i);
+   height = drm_format_info_plane_height(info,
+ mode_cmd->height,
+ i);
+
+   if (nvbo->kind) {
+   ret = nouveau_check_bl_size(drm, nvbo,
+   mode_cmd->offsets[i],
+   mode_cmd->pitches[i],
+   height, nvbo->mode);
+   if (ret)
+   return ret;
+   } else {
+   uint32_t size = mode_cmd->pitches[i] * height;
+
+   if (size + mode_cmd->offsets[i] > nvbo->bo.mem.size)
+   return -ERANGE;
+   }
+   }
+
if (!(fb = *pfb = kzalloc(sizeof(*fb), GFP_KERNEL)))
return -ENOMEM;
 
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 0/3] drm/nouveau: Support NVIDIA format modifiers

2019-12-11 Thread James Jones
This series modifies the NV5x+ nouveau display backends to advertise
appropriate format modifiers on their display planes in atomic mode
setting blobs.

Corresponding modifications to Mesa/userspace are available here:

https://gitlab.freedesktop.org/cubanismo/mesa/tree/nouveau_work

But those need a bit of cleanup before they're ready to submit.

I've tested this on Tesla, Kepler, Pascal, and Turing-class hardware
using various formats and all the exposed format modifiers, plus some
negative testing with invalid ones.

NOTE: this series depends on the "[PATCH v3] drm: Generalized NV Block
Linear DRM format mod" patch submitted to dri-devel.

Signed-off-by: James Jones 
---
 drivers/gpu/drm/tegra/dc.c  | 10 ++
 drivers/gpu/drm/tegra/fb.c  | 14 +++---
 drivers/gpu/drm/tegra/hub.c | 10 ++
 3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index fbf57bc3cdab..a2cc687dc2d8 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -588,6 +588,16 @@ static const u32 tegra124_primary_formats[] = {
 
 static const u64 tegra124_modifiers[] = {
DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5),
+   /*
+* For backwards compatibility with older userspace that may have
+* baked in usage of the less-descriptive modifiers
+*/
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0),
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1),
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2),
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index e34325c83d28..d04e0b1c61ea 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -44,7 +44,7 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
 {
uint64_t modifier = framebuffer->modifier;
 
-   switch (modifier) {
+   switch (drm_fourcc_canonicalize_nvidia_format_mod(modifier)) {
case DRM_FORMAT_MOD_LINEAR:
tiling->mode = TEGRA_BO_TILING_MODE_PITCH;
tiling->value = 0;
@@ -55,32 +55,32 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
tiling->value = 0;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 0;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 1;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 2;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 3;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 4;
break;
 
-   case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5):
+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 5;
break;
diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c
index 839b49c40e51..03c97b10b122 100644
--- a/drivers/gpu/drm/tegra/hub.c
+++ b/drivers/gpu/drm/tegra/hub.c
@@ -49,6 +49,16 @@ static const u32 tegra_shared_plane_formats[] = {
 
 static const u64 tegra_shared_plane_modifiers[] = {
DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5),
+   /*
+* For backwards compatibility with older userspace that may have
+* baked in usage of the less-descriptive modifiers
+*/
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0),
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1),

[PATCH 1/3] drm/nouveau: Add format mod prop to base/ovly/nvdisp

2019-12-11 Thread James Jones
Advertise support for the full list of format
modifiers supported by each class of NVIDIA
desktop GPU display hardware.  Stash the array
of modifiers in the nouveau_display struct for
use when validating userspace framebuffer
creation requests, which will be supportd in
a subsequent change.

Signed-off-by: James Jones 
---
 drivers/gpu/drm/nouveau/dispnv50/base507c.c |  7 +--
 drivers/gpu/drm/nouveau/dispnv50/disp.c | 59 +
 drivers/gpu/drm/nouveau/dispnv50/disp.h |  4 ++
 drivers/gpu/drm/nouveau/dispnv50/wndw.c | 27 +-
 drivers/gpu/drm/nouveau/dispnv50/wndwc57e.c | 17 ++
 drivers/gpu/drm/nouveau/nouveau_display.h   |  2 +
 6 files changed, 112 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/dispnv50/base507c.c 
b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
index 00a85f1e1a4a..025b8f996a0a 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/base507c.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/base507c.c
@@ -262,7 +262,8 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 
*format,
struct nv50_disp_base_channel_dma_v0 args = {
.head = head,
};
-   struct nv50_disp *disp = nv50_disp(drm->dev);
+   struct nouveau_display *disp = nouveau_display(drm->dev);
+   struct nv50_disp *disp50 = nv50_disp(drm->dev);
struct nv50_wndw *wndw;
int ret;
 
@@ -272,9 +273,9 @@ base507c_new_(const struct nv50_wndw_func *func, const u32 
*format,
if (*pwndw = wndw, ret)
return ret;
 
-   ret = nv50_dmac_create(>client.device, >disp->object,
+   ret = nv50_dmac_create(>client.device, >disp.object,
   , head, , sizeof(args),
-  disp->sync->bo.offset, >wndw);
+  disp50->sync->bo.offset, >wndw);
if (ret) {
NV_ERROR(drm, "base%04x allocation failed: %d\n", oclass, ret);
return ret;
diff --git a/drivers/gpu/drm/nouveau/dispnv50/disp.c 
b/drivers/gpu/drm/nouveau/dispnv50/disp.c
index 064a69d161e3..0956367d27a2 100644
--- a/drivers/gpu/drm/nouveau/dispnv50/disp.c
+++ b/drivers/gpu/drm/nouveau/dispnv50/disp.c
@@ -2337,6 +2337,15 @@ nv50_display_create(struct drm_device *dev)
if (ret)
goto out;
 
+   /* Assign the correct format modifiers */
+   if (disp->disp->object.oclass >= TU102_DISP)
+   nouveau_display(dev)->format_modifiers = wndwc57e_modifiers;
+   else
+   if (disp->disp->object.oclass >= GF110_DISP)
+   nouveau_display(dev)->format_modifiers = disp90xx_modifiers;
+   else
+   nouveau_display(dev)->format_modifiers = disp50xx_modifiers;
+
/* create crtc objects to represent the hw heads */
if (disp->disp->object.oclass >= GV100_DISP)
crtcs = nvif_rd32(>object, 0x610060) & 0xff;
@@ -2404,3 +2413,53 @@ nv50_display_create(struct drm_device *dev)
nv50_display_destroy(dev);
return ret;
 }
+
+/**
+ * Format modifiers
+ */
+
+/
+ *Log2(block height) +  *
+ *Page Kind --+  |  *
+ *Gob Height/Page Kind Generation --+ |  |  *
+ *  Sector layout ---+  | |  |  *
+ *  Compression --+  |  | |  |  */
+const u64 disp50xx_modifiers[] = { /* |  |  | |  |  */
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x7a, 5),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x78, 5),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 1, 1, 0x70, 5),
+   DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_INVALID
+};
+
+/
+ *   

Re: [PATCH 0/3] drm/nouveau: Support NVIDIA format modifiers

2019-12-11 Thread James Jones
Please ignore the tegra diff on the bottom of this.  I never fail to 
find a way to mess up git-send-email.


-James

On 12/11/19 12:59 PM, James Jones wrote:

This series modifies the NV5x+ nouveau display backends to advertise
appropriate format modifiers on their display planes in atomic mode
setting blobs.

Corresponding modifications to Mesa/userspace are available here:

https://gitlab.freedesktop.org/cubanismo/mesa/tree/nouveau_work

But those need a bit of cleanup before they're ready to submit.

I've tested this on Tesla, Kepler, Pascal, and Turing-class hardware
using various formats and all the exposed format modifiers, plus some
negative testing with invalid ones.

NOTE: this series depends on the "[PATCH v3] drm: Generalized NV Block
Linear DRM format mod" patch submitted to dri-devel.

Signed-off-by: James Jones 
---
  drivers/gpu/drm/tegra/dc.c  | 10 ++
  drivers/gpu/drm/tegra/fb.c  | 14 +++---
  drivers/gpu/drm/tegra/hub.c | 10 ++
  3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index fbf57bc3cdab..a2cc687dc2d8 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -588,6 +588,16 @@ static const u32 tegra124_primary_formats[] = {
  
  static const u64 tegra124_modifiers[] = {

DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5),
+   /*
+* For backwards compatibility with older userspace that may have
+* baked in usage of the less-descriptive modifiers
+*/
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0),
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1),
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2),
diff --git a/drivers/gpu/drm/tegra/fb.c b/drivers/gpu/drm/tegra/fb.c
index e34325c83d28..d04e0b1c61ea 100644
--- a/drivers/gpu/drm/tegra/fb.c
+++ b/drivers/gpu/drm/tegra/fb.c
@@ -44,7 +44,7 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
  {
uint64_t modifier = framebuffer->modifier;
  
-	switch (modifier) {

+   switch (drm_fourcc_canonicalize_nvidia_format_mod(modifier)) {
case DRM_FORMAT_MOD_LINEAR:
tiling->mode = TEGRA_BO_TILING_MODE_PITCH;
tiling->value = 0;
@@ -55,32 +55,32 @@ int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer,
tiling->value = 0;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(0):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 0;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(1):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 1;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(2):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 2;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(3):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 3;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(4):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 4;
break;
  
-	case DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK(5):

+   case DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5):
tiling->mode = TEGRA_BO_TILING_MODE_BLOCK;
tiling->value = 5;
break;
diff --git a/drivers/gpu/drm/tegra/hub.c b/drivers/gpu/drm/tegra/hub.c
index 839b49c40e51..03c97b10b122 100644
--- a/drivers/gpu/drm/tegra/hub.c
+++ b/drivers/gpu/drm/tegra/hub.c
@@ -49,6 +49,16 @@ static const u32 tegra_shared_plane_formats[] = {
  
  static const u64 tegra_shared_plane_modifiers[] = {

DRM_FORMAT_MOD_LINEAR,
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 0),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 1),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 2),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 3),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 4),
+   DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D(0, 0, 0, 0xfe, 5),
+   /*
+* For backwards compatibility with older userspace that may have
+* baked in usage of the less-descriptive 

[PATCH v3] drm: Generalized NV Block Linear DRM format mod

2019-12-11 Thread James Jones
Builds upon the existing NVIDIA 16Bx2 block linear
format modifiers by adding more "fields" to the
existing parameterized
DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK format modifier
macro that allow fully defining a unique-across-
all-NVIDIA-hardware bit layout using a minimal
set of fields and values.  The new modifier macro
DRM_FORMAT_MOD_NVIDIA_BLOCK_LINEAR_2D is
effectively backwards compatible with the existing
macro, introducing a superset of the previously
definable format modifiers.

Backwards compatibility has two quirks.  First,
the zero value for the "kind" field, which is
implied by the DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK
macro, must be special cased in drivers and
assumed to map to the pre-Turing generic kind of
0xfe, since a kind of "zero" is reserved for
linear buffer layouts on all GPUs.

Second, it is assumed backwards compatibility
is only needed when running on Tegra GPUs, and
specifically Tegra GPUs prior to Xavier.  This
is based on two assertions:

-Tegra GPUs prior to Xavier used a slightly
 different raw bit layout than desktop GPUs,
 making it impossible to directly share block
 linear buffers between the two.

-Support for the existing block linear modifiers
 was incomplete, making them useful only for
 exporting buffers created by nouveau and
 importing them to Tegra DRM as framebuffers for
 scan out.  There was no support for adding
 framebuffers using format modifiers in nouveau,
 nor importing dma-buf/PRIME GEM objects into
 nouveau userspace drivers with modifiers in Mesa.

Hence it is assumed the prior modifiers were not
intended for use on desktop GPUs, and as a
corollary, were not intended to support sharing
block linear buffers across two different NVIDIA
GPUs.

v2:
  - Added canonicalize helper function

v3:
  - Added additional bit to compression field to
support Tesla (NV5x,G8x,G9x,GT1xx,GT2xx) class
chips.

Signed-off-by: James Jones 
---
 include/uapi/drm/drm_fourcc.h | 122 +++---
 1 file changed, 114 insertions(+), 8 deletions(-)

diff --git a/include/uapi/drm/drm_fourcc.h b/include/uapi/drm/drm_fourcc.h
index 3feeaa3f987a..4330d930bdbb 100644
--- a/include/uapi/drm/drm_fourcc.h
+++ b/include/uapi/drm/drm_fourcc.h
@@ -497,7 +497,113 @@ extern "C" {
 #define DRM_FORMAT_MOD_NVIDIA_TEGRA_TILED fourcc_mod_code(NVIDIA, 1)
 
 /*
- * 16Bx2 Block Linear layout, used by desktop GPUs, and Tegra K1 and later
+ * Generalized Block Linear layout, used by desktop GPUs starting with 
NV50/G80,
+ * and Tegra GPUs starting with Tegra K1.
+ *
+ * Pixels are arranged in Groups of Bytes (GOBs).  GOB size and layout varies
+ * based on the architecture generation.  GOBs themselves are then arranged in
+ * 3D blocks, with the block dimensions (in terms of GOBs) always being a power
+ * of two, and hence expressible as their log2 equivalent (E.g., "2" represents
+ * a block depth or height of "4").
+ *
+ * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format
+ * in full detail.
+ *
+ *   Macro
+ * Bits  Param Description
+ *   - 
-
+ *
+ *  3:0  h log2(height) of each block, in GOBs.  Placed here for
+ * compatibility with the existing
+ * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers.
+ *
+ *  4:4  - Must be 1, to indicate block-linear layout.  Necessary for
+ * compatibility with the existing
+ * DRM_FORMAT_MOD_NVIDIA_16BX2_BLOCK()-based modifiers.
+ *
+ *  8:5  - Reserved (To support 3D-surfaces with variable log2(depth) block
+ * size).  Must be zero.
+ *
+ * Note there is no log2(width) parameter.  Some portions of the
+ * hardware support a block width of two gobs, but it is 
impractical
+ * to use due to lack of support elsewhere, and has no known
+ * benefits.
+ *
+ * 11:9  - Reserved (To support 2D-array textures with variable array 
stride
+ * in blocks, specified via log2(tile width in blocks)).  Must be
+ * zero.
+ *
+ * 19:12 k Page Kind.  This value directly maps to a field in the page
+ * tables of all GPUs >= NV50.  It affects the exact layout of bits
+ * in memory and can be derived from the tuple
+ *
+ *   (format, GPU model, compression type, samples per pixel)
+ *
+ * Where compression type is defined below.  If GPU model were
+ * implied by the format modifier, format, or memory buffer, page
+ * kind would not need to be included in the modifier itself, but
+ * since the modifier should define the layout of the associated
+ * memory buffer independent from any device or other context, it
+ * must be included here.
+ *
+ * 21:20 g GOB Height and Page Kind Generation.  The height of a GOB 
changed
+ * starting with Fermi GPUs.  Additionally, the mapping between 
page
+ *  

Re: [PATCH v9 10/25] mm/gup: introduce pin_user_pages*() and FOLL_PIN

2019-12-11 Thread Jonathan Corbet
On Tue, 10 Dec 2019 18:53:03 -0800
John Hubbard  wrote:

> Introduce pin_user_pages*() variations of get_user_pages*() calls,
> and also pin_longterm_pages*() variations.

Just a couple of nits on the documentation patch

> +++ b/Documentation/core-api/pin_user_pages.rst
> @@ -0,0 +1,232 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +
> +
> +pin_user_pages() and related calls
> +
> +
> +.. contents:: :local:
> +
> +Overview
> +
> +
> +This document describes the following functions: ::
> +
> + pin_user_pages
> + pin_user_pages_fast
> + pin_user_pages_remote

You could just say "the following functions::" and get the result you're
after with a slightly less alien plain-text reading experience.

Of course, you could also just say "This document describes
pin_user_pages(), pin_user_pages_fast(), and pin_user_pages_remote()." But
that's a matter of personal taste, I guess.  Using the function() notation
will cause the docs system to automatically link to the kerneldoc info,
though.  

> +Basic description of FOLL_PIN
> +=
> +
> +FOLL_PIN and FOLL_LONGTERM are flags that can be passed to the 
> get_user_pages*()
> +("gup") family of functions. FOLL_PIN has significant interactions and
> +interdependencies with FOLL_LONGTERM, so both are covered here.
> +
> +FOLL_PIN is internal to gup, meaning that it should not appear at the gup 
> call
> +sites. This allows the associated wrapper functions  (pin_user_pages*() and
> +others) to set the correct combination of these flags, and to check for 
> problems
> +as well.
> +
> +FOLL_LONGTERM, on the other hand, *is* allowed to be set at the gup call 
> sites.
> +This is in order to avoid creating a large number of wrapper functions to 
> cover
> +all combinations of get*(), pin*(), FOLL_LONGTERM, and more. Also, the
> +pin_user_pages*() APIs are clearly distinct from the get_user_pages*() APIs, 
> so
> +that's a natural dividing line, and a good point to make separate wrapper 
> calls.
> +In other words, use pin_user_pages*() for DMA-pinned pages, and
> +get_user_pages*() for other cases. There are four cases described later on in
> +this document, to further clarify that concept.
> +
> +FOLL_PIN and FOLL_GET are mutually exclusive for a given gup call. However,
> +multiple threads and call sites are free to pin the same struct pages, via 
> both
> +FOLL_PIN and FOLL_GET. It's just the call site that needs to choose one or 
> the
> +other, not the struct page(s).
> +
> +The FOLL_PIN implementation is nearly the same as FOLL_GET, except that 
> FOLL_PIN
> +uses a different reference counting technique.
> +
> +FOLL_PIN is a prerequisite to FOLL_LONGTGERM. Another way of saying that is,

FOLL_LONGTERM typoed there.

Thanks,

jon
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RESEND PATCH 5/5] drm/amdgpu: Switch from system_highpri_wq to system_unbound_wq

2019-12-11 Thread Andrey Grodzovsky
This is to avoid queueing jobs to same CPU during XGMI hive reset
because there is a strict timeline for when the reset commands
must reach all the GPUs in the hive.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e4089a0..1518565 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3842,7 +3842,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info 
*hive,
list_for_each_entry(tmp_adev, device_list_handle, 
gmc.xgmi.head) {
/* For XGMI run all resets in parallel to speed up the 
process */
if (tmp_adev->gmc.xgmi.num_physical_nodes > 1) {
-   if (!queue_work(system_highpri_wq, 
_adev->xgmi_reset_work))
+   if (!queue_work(system_unbound_wq, 
_adev->xgmi_reset_work))
r = -EALREADY;
} else
r = amdgpu_asic_reset(tmp_adev);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RESEND PATCH 2/5] drm: Add Reusable task barrier.

2019-12-11 Thread Andrey Grodzovsky
It is used to synchronize N threads at a rendevouz point before execution
of critical code that has to be started by all the threads at approximatly
the same time.

Signed-off-by: Andrey Grodzovsky 
---
 include/drm/task_barrier.h | 106 +
 1 file changed, 106 insertions(+)
 create mode 100644 include/drm/task_barrier.h

diff --git a/include/drm/task_barrier.h b/include/drm/task_barrier.h
new file mode 100644
index 000..81fb0f7
--- /dev/null
+++ b/include/drm/task_barrier.h
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2019 Advanced Micro Devices, Inc.
+ *
+ * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ */
+#include 
+#include 
+
+/*
+ * Reusable 2 PHASE task barrier (randevouz point) implementation for N tasks.
+ * Based on the Little book of sempahores - 
https://greenteapress.com/wp/semaphores/
+ */
+
+
+
+#ifndef DRM_TASK_BARRIER_H_
+#define DRM_TASK_BARRIER_H_
+
+/*
+ * Represents an instance of a task barrier.
+ */
+struct task_barrier {
+   unsigned int n;
+   atomic_t count;
+   struct semaphore enter_turnstile;
+   struct semaphore exit_turnstile;
+};
+
+static inline void task_barrier_signal_turnstile(struct semaphore *turnstile,
+unsigned int n)
+{
+   int i;
+
+   for (i = 0 ; i < n; i++)
+   up(turnstile);
+}
+
+static inline void task_barrier_init(struct task_barrier *tb)
+{
+   tb->n = 0;
+   atomic_set(>count, 0);
+   sema_init(>enter_turnstile, 0);
+   sema_init(>exit_turnstile, 0);
+}
+
+static inline void task_barrier_add_task(struct task_barrier *tb)
+{
+   tb->n++;
+}
+
+static inline void task_barrier_rem_task(struct task_barrier *tb)
+{
+   tb->n--;
+}
+
+/*
+ * Lines up all the threads BEFORE the critical point.
+ *
+ * When all thread passed this code the entry barrier is back to locked state.
+ */
+static inline void task_barrier_enter(struct task_barrier *tb)
+{
+   if (atomic_inc_return(>count) == tb->n)
+   task_barrier_signal_turnstile(>enter_turnstile, tb->n);
+
+   down(>enter_turnstile);
+}
+
+/*
+ * Lines up all the threads AFTER the critical point.
+ *
+ * This function is used to avoid any one thread running ahead of the reset if
+ * the barrier is used in a loop (repeatedly) .
+ */
+static inline void task_barrier_exit(struct task_barrier *tb)
+{
+   if (atomic_dec_return(>count) == 0)
+   task_barrier_signal_turnstile(>exit_turnstile, tb->n);
+
+   down(>exit_turnstile);
+}
+
+static inline void task_barrier_full(struct task_barrier *tb)
+{
+   task_barrier_enter(tb);
+   task_barrier_exit(tb);
+}
+
+#endif
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RESEND PATCH 4/5] Subject: drm/amdgpu: Redo XGMI reset synchronization.

2019-12-11 Thread Andrey Grodzovsky
Use task barrier in XGMI hive to synchronize ASIC resets
across devices in XGMI hive.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 42 +-
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 1d19edfa..e4089a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -67,6 +67,7 @@
 #include "amdgpu_tmz.h"
 
 #include 
+#include 
 
 MODULE_FIRMWARE("amdgpu/vega10_gpu_info.bin");
 MODULE_FIRMWARE("amdgpu/vega12_gpu_info.bin");
@@ -2663,14 +2664,43 @@ static void amdgpu_device_xgmi_reset_func(struct 
work_struct *__work)
 {
struct amdgpu_device *adev =
container_of(__work, struct amdgpu_device, xgmi_reset_work);
+   struct amdgpu_hive_info *hive = amdgpu_get_xgmi_hive(adev, 0);
 
-   if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
-   adev->asic_reset_res = (adev->in_baco == false) ?
-   amdgpu_device_baco_enter(adev->ddev) :
-   qamdgpu_device_baco_exit(adev->ddev);
-   else
-   adev->asic_reset_res = amdgpu_asic_reset(adev);
+   /*
+* Use task barrier to synchronize all xgmi reset works across the
+* hive.
+* task_barrier_enter and task_barrier_exit will block untill all the
+* threads running the xgmi reset works reach those points. I assume
+* guarantee of progress here for all the threads as the workqueue code
+* creates new worker threads as needed by amount of work items in queue
+* (see worker_thread) and also each thread sleeps in the barrir and by
+* this yielding the CPU for other work threads to make progress.
+*/
+   if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) {
+
+   if (hive)
+   task_barrier_enter(>tb);
+
+   adev->asic_reset_res = amdgpu_device_baco_enter(adev->ddev);
+
+   if (adev->asic_reset_res)
+   goto fail;
+
+   if (hive)
+   task_barrier_exit(>tb);
+
+   adev->asic_reset_res = amdgpu_device_baco_exit(adev->ddev);
+
+   if (adev->asic_reset_res)
+   goto fail;
+   } else {
+   if (hive)
+   task_barrier_full(>tb);
+
+   adev->asic_reset_res =  amdgpu_asic_reset(adev);
+   }
 
+fail:
if (adev->asic_reset_res)
DRM_WARN("ASIC reset failed with error, %d for drm dev, %s",
 adev->asic_reset_res, adev->ddev->unique);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RESEND PATCH 3/5] drm/amdgpu: Add task barrier to XGMI hive.

2019-12-11 Thread Andrey Grodzovsky
Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c | 4 
 drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
index 61d13d8..5cf920d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.c
@@ -261,6 +261,7 @@ struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct 
amdgpu_device *adev, int lo
INIT_LIST_HEAD(>device_list);
mutex_init(>hive_lock);
mutex_init(>reset_lock);
+   task_barrier_init(>tb);
 
if (lock)
mutex_lock(>hive_lock);
@@ -408,6 +409,8 @@ int amdgpu_xgmi_add_device(struct amdgpu_device *adev)
top_info->num_nodes = count;
hive->number_devices = count;
 
+   task_barrier_add_task(>tb);
+
if (amdgpu_device_ip_get_ip_block(adev, AMD_IP_BLOCK_TYPE_PSP)) {
list_for_each_entry(tmp_adev, >device_list, 
gmc.xgmi.head) {
/* update node list for other device in the hive */
@@ -470,6 +473,7 @@ void amdgpu_xgmi_remove_device(struct amdgpu_device *adev)
mutex_destroy(>hive_lock);
mutex_destroy(>reset_lock);
} else {
+   task_barrier_rem_task(>tb);
amdgpu_xgmi_sysfs_rem_dev_info(adev, hive);
mutex_unlock(>hive_lock);
}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
index bbf504f..74011fb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_xgmi.h
@@ -22,6 +22,7 @@
 #ifndef __AMDGPU_XGMI_H__
 #define __AMDGPU_XGMI_H__
 
+#include 
 #include "amdgpu_psp.h"
 
 struct amdgpu_hive_info {
@@ -33,6 +34,7 @@ struct amdgpu_hive_info {
struct device_attribute dev_attr;
struct amdgpu_device *adev;
int pstate; /*0 -- low , 1 -- high , -1 unknown*/
+   struct task_barrier tb;
 };
 
 struct amdgpu_hive_info *amdgpu_get_xgmi_hive(struct amdgpu_device *adev, int 
lock);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RESEND PATCH 1/5] drm/amdgpu: reverts commit b01245ff54db66073b104ac9d9fbefb7b264b36d.

2019-12-11 Thread Andrey Grodzovsky
In preparation for doing XGMI reset synchronization using task barrier.

Signed-off-by: Andrey Grodzovsky 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu.h|  2 -
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 76 +-
 2 files changed, 12 insertions(+), 66 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index a78a363..50bab33 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -1001,8 +1001,6 @@ struct amdgpu_device {
 
boolpm_sysfs_en;
boolucode_sysfs_en;
-
-   boolin_baco;
 };
 
 static inline struct amdgpu_device *amdgpu_ttm_adev(struct ttm_bo_device *bdev)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 7324a5f..1d19edfa 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2667,7 +2667,7 @@ static void amdgpu_device_xgmi_reset_func(struct 
work_struct *__work)
if (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO)
adev->asic_reset_res = (adev->in_baco == false) ?
amdgpu_device_baco_enter(adev->ddev) :
-   amdgpu_device_baco_exit(adev->ddev);
+   qamdgpu_device_baco_exit(adev->ddev);
else
adev->asic_reset_res = amdgpu_asic_reset(adev);
 
@@ -3796,18 +3796,13 @@ static int amdgpu_device_pre_asic_reset(struct 
amdgpu_device *adev,
return r;
 }
 
-static int amdgpu_do_asic_reset(struct amdgpu_device *adev,
-  struct amdgpu_hive_info *hive,
+static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,
   struct list_head *device_list_handle,
   bool *need_full_reset_arg)
 {
struct amdgpu_device *tmp_adev = NULL;
bool need_full_reset = *need_full_reset_arg, vram_lost = false;
int r = 0;
-   int cpu = smp_processor_id();
-   bool use_baco =
-   (amdgpu_asic_reset_method(adev) == AMD_RESET_METHOD_BACO) ?
-   true : false;
 
/*
 * ASIC reset has to be done on all HGMI hive nodes ASAP
@@ -3815,62 +3810,22 @@ static int amdgpu_do_asic_reset(struct amdgpu_device 
*adev,
 */
if (need_full_reset) {
list_for_each_entry(tmp_adev, device_list_handle, 
gmc.xgmi.head) {
-   /*
-* For XGMI run all resets in parallel to speed up the
-* process by scheduling the highpri wq on different
-* cpus. For XGMI with baco reset, all nodes must enter
-* baco within close proximity before anyone exit.
-*/
+   /* For XGMI run all resets in parallel to speed up the 
process */
if (tmp_adev->gmc.xgmi.num_physical_nodes > 1) {
-   if (!queue_work_on(cpu, system_highpri_wq,
-  _adev->xgmi_reset_work))
+   if (!queue_work(system_highpri_wq, 
_adev->xgmi_reset_work))
r = -EALREADY;
-   cpu = cpumask_next(cpu, cpu_online_mask);
} else
r = amdgpu_asic_reset(tmp_adev);
-   if (r)
-   break;
-   }
-
-   /* For XGMI wait for all work to complete before proceed */
-   if (!r) {
-   list_for_each_entry(tmp_adev, device_list_handle,
-   gmc.xgmi.head) {
-   if (tmp_adev->gmc.xgmi.num_physical_nodes > 1) {
-   flush_work(_adev->xgmi_reset_work);
-   r = tmp_adev->asic_reset_res;
-   if (r)
-   break;
-   if (use_baco)
-   tmp_adev->in_baco = true;
-   }
-   }
-   }
 
-   /*
-* For XGMI with baco reset, need exit baco phase by scheduling
-* xgmi_reset_work one more time. PSP reset and sGPU skips this
-* phase. Not assume the situation that PSP reset and baco reset
-* coexist within an XGMI hive.
-*/
-
-   if (!r && use_baco) {
-   cpu = smp_processor_id();
-   list_for_each_entry(tmp_adev, device_list_handle,
-   gmc.xgmi.head) {
-  

Re: [PATCH] drm/panel: Add Boe Himax8279d MIPI-DSI LCD panel

2019-12-11 Thread Sam Ravnborg
Hi Jerry.


> Support Boe Himax8279d 8.0" 1200x1920 TFT LCD panel, it is a MIPI DSI
> panel.

Thanks for your persistence with this driver.


Unfortunately the driver no longer builds after the drm_panel
work we committed earlier this week to drm-misc-next.

> 
> V9:
> - Adjust init code, make the format more concise
> - kill off default_off_cmds (Emil)
> - use mipi_dsi_dcs_set_display_{on,off} in their enable/disable
> callbacks. (Emil)
> - Adjusting the delay function (Emil)

...
> +
> +struct panel_info {
> + struct drm_panel base;
> + struct mipi_dsi_device *link;
> + const struct panel_desc *desc;
> +
> + struct backlight_device *backlight;

We have included backlight support in drm_panel.
Can you please introduce this and post a patch updating the driver to
use this.
See other panle patches what is required to use it.
(Mostly deleting code)

I took a look at the rest of the driver and everything looks good.

Sorry for causing you this extra trouble due to the drm_panel changes.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object

2019-12-11 Thread Sam Ravnborg
Hi Thomas,

On Wed, Dec 11, 2019 at 07:08:32PM +0100, Thomas Zimmermann wrote:
> Drivers that what to allocate VRAM GEM objects with additional fields
> can now do this by implementing struct drm_driver.gem_create_object.
> 
> Signed-off-by: Thomas Zimmermann 
> ---
>  drivers/gpu/drm/drm_gem_vram_helper.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
> b/drivers/gpu/drm/drm_gem_vram_helper.c
> index b760fd27f3c0..d475d94e2e3e 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -2,6 +2,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -142,13 +143,19 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
> drm_device *dev,
>   size_t size,
>   unsigned long pg_align)
>  {
> + struct drm_gem_object *gem;
>   struct drm_gem_vram_object *gbo;
>   int ret;
>  
> - gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
> - if (!gbo)
> + if (dev->driver->gem_create_object)
> + gem = dev->driver->gem_create_object(dev, size);
> + else
> + gem = kzalloc(sizeof(*gbo), GFP_KERNEL);
The size is (*gbo) but you assume it is a gem.
Looks wrong at first glance???

Sam


> + if (!gem)
>   return ERR_PTR(-ENOMEM);
>  
> + gbo = drm_gem_vram_of_gem(gem);
> +
>   ret = drm_gem_vram_init(dev, gbo, size, pg_align);
>   if (ret < 0)
>   goto err_kfree;
> -- 
> 2.24.0
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/modes: Support video parameters with only reflect option

2019-12-11 Thread Stephan Gerhold
On Wed, Dec 11, 2019 at 07:10:46PM +0100, Maxime Ripard wrote:
> Hi Stephan,
> 
> On Tue, Dec 10, 2019 at 11:42:37AM +0100, Stephan Gerhold wrote:
> > On Tue, Dec 10, 2019 at 11:20:46AM +0100, Maxime Ripard wrote:
> > > Hi,
> > >
> > > On Mon, Dec 09, 2019 at 07:32:54PM +0100, Stephan Gerhold wrote:
> > > > At the moment, video mode parameters like video=540x960,reflect_x,
> > > > (without rotation set) are silently ignored.
> > > >
> > > > One of the reasons for this is that the calculation that
> > > > combines the panel_orientation with cmdline->rotation_reflection
> > > > does not handle the case when cmdline->rotation_reflection does
> > > > not have any rotation set.
> > > > (i.e. cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK == 0)
> > > >
> > > > Example:
> > > >   *rotation = DRM_MODE_ROTATE_0 (no panel_orientation)
> > > >   cmdline->rotation_reflection = DRM_MODE_REFLECT_X 
> > > > (video=MODE,reflect_x)
> > > >
> > > > The current code does:
> > > >   panel_rot = ilog2(*rotation & DRM_MODE_ROTATE_MASK);
> > > >   cmdline_rot = ilog2(cmdline->rotation_reflection & 
> > > > DRM_MODE_ROTATE_MASK);
> > > >   sum_rot = (panel_rot + cmdline_rot) % 4;
> > > >
> > > > and therefore:
> > > >   panel_rot = ilog2(DRM_MODE_ROTATE_0) = ilog2(1) = 0
> > > >   cmdline_rot = ilog2(0) = -1
> > > >   sum_rot = (0 + -1) % 4 = -1 % 4 = 3
> > > >...
> > > >   *rotation = DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X
> > > >
> > > > So we incorrectly generate DRM_MODE_ROTATE_270 in this case.
> > > > To prevent cmdline_rot from becoming -1, we need to treat
> > > > the rotation as DRM_MODE_ROTATE_0.
> > > >
> > > > On the other hand, there is no need to go through that calculation
> > > > at all if no rotation is set in rotation_reflection.
> > > > A simple XOR is enough to combine the reflections.
> > > >
> > > > Finally, also allow DRM_MODE_ROTATE_0 in the if statement below.
> > > > DRM_MODE_ROTATE_0 means "no rotation" and should therefore not
> > > > require any special handling (e.g. specific tiling format).
> > > >
> > > > This makes video parameters with only reflect option work correctly.
> > > >
> > > > Signed-off-by: Stephan Gerhold 
> > >
> > > Thanks for that commit message.
> > >
> > > Can you also add a selftest to make sure we don't get a regression in
> > > the future?
> >
> > Can you explain how/where I would add a test for drm_client_rotation()
> > in drm_client_modeset.c? I'm not familiar with selftests to be honest.
> >
> > I found test-drm_cmdline_parser.c but that seems to cover only the
> > cmdline parsing (which is working correctly already).
> 
> The cmdline here is the kernel command line. You were mentionning in
> your commit log that video=540x960,reflect_x was broken?
> 

The parameter is parsed correctly and placed into connector->cmdline_mode.
Therefore, not the *parsing* is broken, only the way we try to apply
and merge them with the panel orientation in drm_client_modeset.c.

There are existing test cases for the parsing of parameters similar to
video=540x960,reflect_x, see drm_cmdline_test_hmirror()
in the aforementioned test file.

Maybe my commit message was not as clear as I hoped :)

Thanks,
Stephan
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 3/3] virtio-gpu: use damage info for display updates.

2019-12-11 Thread Chia-I Wu
On Wed, Dec 11, 2019 at 12:42 AM Gerd Hoffmann  wrote:
>
> Signed-off-by: Gerd Hoffmann 
> ---
>  drivers/gpu/drm/virtio/virtgpu_plane.c | 41 +++---
>  1 file changed, 24 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
> b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index 2e0d14e005db..1a0fbbb91ec7 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -24,6 +24,7 @@
>   */
>
>  #include 
> +#include 
>  #include 
>  #include 
>
> @@ -103,22 +104,26 @@ static int virtio_gpu_plane_atomic_check(struct 
> drm_plane *plane,
>  }
>
>  static void virtio_gpu_update_dumb_bo(struct virtio_gpu_device *vgdev,
> - struct virtio_gpu_object *bo,
> - struct drm_plane_state *state)
> + struct drm_plane_state *state,
> + struct drm_rect *rect)
>  {
> +   struct virtio_gpu_object *bo =
> +   gem_to_virtio_gpu_obj(state->fb->obj[0]);
> struct virtio_gpu_object_array *objs;
> +   uint32_t w = rect->x2 - rect->x1;
> +   uint32_t h = rect->y2 - rect->y1;
> +   uint32_t x = rect->x1 + (state->src_x >> 16);
> +   uint32_t y = rect->y1 + (state->src_y >> 16);
> +   uint32_t off = x * state->fb->format->cpp[0] +
> +   y * state->fb->pitches[0];
>
> objs = virtio_gpu_array_alloc(1);
> if (!objs)
> return;
> virtio_gpu_array_add_obj(objs, >base.base);
> -   virtio_gpu_cmd_transfer_to_host_2d
> -   (vgdev, 0,
> -state->src_w >> 16,
> -state->src_h >> 16,
> -state->src_x >> 16,
> -state->src_y >> 16,
> -objs, NULL);
> +
> +   virtio_gpu_cmd_transfer_to_host_2d(vgdev, off, w, h, x, y,
> +  objs, NULL);
>  }
>
>  static void virtio_gpu_primary_plane_update(struct drm_plane *plane,
> @@ -127,8 +132,8 @@ static void virtio_gpu_primary_plane_update(struct 
> drm_plane *plane,
> struct drm_device *dev = plane->dev;
> struct virtio_gpu_device *vgdev = dev->dev_private;
> struct virtio_gpu_output *output = NULL;
> -   struct virtio_gpu_framebuffer *vgfb;
> struct virtio_gpu_object *bo;
> +   struct drm_rect rect;
>
> if (plane->state->crtc)
> output = drm_crtc_to_virtio_gpu_output(plane->state->crtc);
> @@ -146,12 +151,14 @@ static void virtio_gpu_primary_plane_update(struct 
> drm_plane *plane,
> return;
> }
>
> +   if (!drm_atomic_helper_damage_merged(old_state, plane->state, ))
> +   return;
> +
> virtio_gpu_disable_notify(vgdev);
>
> -   vgfb = to_virtio_gpu_framebuffer(plane->state->fb);
> -   bo = gem_to_virtio_gpu_obj(vgfb->base.obj[0]);
> +   bo = gem_to_virtio_gpu_obj(plane->state->fb->obj[0]);
> if (bo->dumb)
> -   virtio_gpu_update_dumb_bo(vgdev, bo, plane->state);
> +   virtio_gpu_update_dumb_bo(vgdev, plane->state, );
>
> if (plane->state->fb != old_state->fb) {
> DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
> @@ -171,10 +178,10 @@ static void virtio_gpu_primary_plane_update(struct 
> drm_plane *plane,
> }
>
> virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
> - plane->state->src_x >> 16,
> - plane->state->src_y >> 16,
> - plane->state->src_w >> 16,
> - plane->state->src_h >> 16);
> + (plane->state->src_x >> 16) + rect.x1,
> + (plane->state->src_y >> 16) + rect.y1,
Digging into drm_atomic_helper_damage_merged, it seems rect uses
absolute values and is not relative to src_{x,y}.

> + rect.x2 - rect.x1,
> + rect.y2 - rect.y1);
>
> virtio_gpu_enable_notify(vgdev);
>  }
> --
> 2.18.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/3] drm/virtio: skip set_scanout if framebuffer didn't change

2019-12-11 Thread Chia-I Wu
On Wed, Dec 11, 2019 at 12:42 AM Gerd Hoffmann  wrote:
>
> Signed-off-by: Gerd Hoffmann 
> ---
>  drivers/gpu/drm/virtio/virtgpu_plane.c | 31 ++
>  1 file changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
> b/drivers/gpu/drm/virtio/virtgpu_plane.c
> index bc4bc4475a8c..a0f91658c2bc 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
> @@ -151,20 +151,23 @@ static void virtio_gpu_primary_plane_update(struct 
> drm_plane *plane,
> if (bo->dumb)
> virtio_gpu_update_dumb_bo(vgdev, bo, plane->state);
>
> -   DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
> - bo->hw_res_handle,
> - plane->state->crtc_w, plane->state->crtc_h,
> - plane->state->crtc_x, plane->state->crtc_y,
> - plane->state->src_w >> 16,
> - plane->state->src_h >> 16,
> - plane->state->src_x >> 16,
> - plane->state->src_y >> 16);
> -   virtio_gpu_cmd_set_scanout(vgdev, output->index,
> -  bo->hw_res_handle,
> -  plane->state->src_w >> 16,
> -  plane->state->src_h >> 16,
> -  plane->state->src_x >> 16,
> -  plane->state->src_y >> 16);
> +   if (plane->state->fb != old_state->fb) {
Should we check src_{w,h,x,y} as well?
> +   DRM_DEBUG("handle 0x%x, crtc %dx%d+%d+%d, src %dx%d+%d+%d\n",
> + bo->hw_res_handle,
> + plane->state->crtc_w, plane->state->crtc_h,
> + plane->state->crtc_x, plane->state->crtc_y,
> + plane->state->src_w >> 16,
> + plane->state->src_h >> 16,
> + plane->state->src_x >> 16,
> + plane->state->src_y >> 16);
> +   virtio_gpu_cmd_set_scanout(vgdev, output->index,
> +  bo->hw_res_handle,
> +  plane->state->src_w >> 16,
> +  plane->state->src_h >> 16,
> +  plane->state->src_x >> 16,
> +  plane->state->src_y >> 16);
> +   }
> +
> virtio_gpu_cmd_resource_flush(vgdev, bo->hw_res_handle,
>   plane->state->src_x >> 16,
>   plane->state->src_y >> 16,
> --
> 2.18.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/modes: Support video parameters with only reflect option

2019-12-11 Thread Maxime Ripard
Hi Stephan,

On Tue, Dec 10, 2019 at 11:42:37AM +0100, Stephan Gerhold wrote:
> On Tue, Dec 10, 2019 at 11:20:46AM +0100, Maxime Ripard wrote:
> > Hi,
> >
> > On Mon, Dec 09, 2019 at 07:32:54PM +0100, Stephan Gerhold wrote:
> > > At the moment, video mode parameters like video=540x960,reflect_x,
> > > (without rotation set) are silently ignored.
> > >
> > > One of the reasons for this is that the calculation that
> > > combines the panel_orientation with cmdline->rotation_reflection
> > > does not handle the case when cmdline->rotation_reflection does
> > > not have any rotation set.
> > > (i.e. cmdline->rotation_reflection & DRM_MODE_ROTATE_MASK == 0)
> > >
> > > Example:
> > >   *rotation = DRM_MODE_ROTATE_0 (no panel_orientation)
> > >   cmdline->rotation_reflection = DRM_MODE_REFLECT_X (video=MODE,reflect_x)
> > >
> > > The current code does:
> > >   panel_rot = ilog2(*rotation & DRM_MODE_ROTATE_MASK);
> > >   cmdline_rot = ilog2(cmdline->rotation_reflection & 
> > > DRM_MODE_ROTATE_MASK);
> > >   sum_rot = (panel_rot + cmdline_rot) % 4;
> > >
> > > and therefore:
> > >   panel_rot = ilog2(DRM_MODE_ROTATE_0) = ilog2(1) = 0
> > >   cmdline_rot = ilog2(0) = -1
> > >   sum_rot = (0 + -1) % 4 = -1 % 4 = 3
> > >...
> > >   *rotation = DRM_MODE_ROTATE_270 | DRM_MODE_REFLECT_X
> > >
> > > So we incorrectly generate DRM_MODE_ROTATE_270 in this case.
> > > To prevent cmdline_rot from becoming -1, we need to treat
> > > the rotation as DRM_MODE_ROTATE_0.
> > >
> > > On the other hand, there is no need to go through that calculation
> > > at all if no rotation is set in rotation_reflection.
> > > A simple XOR is enough to combine the reflections.
> > >
> > > Finally, also allow DRM_MODE_ROTATE_0 in the if statement below.
> > > DRM_MODE_ROTATE_0 means "no rotation" and should therefore not
> > > require any special handling (e.g. specific tiling format).
> > >
> > > This makes video parameters with only reflect option work correctly.
> > >
> > > Signed-off-by: Stephan Gerhold 
> >
> > Thanks for that commit message.
> >
> > Can you also add a selftest to make sure we don't get a regression in
> > the future?
>
> Can you explain how/where I would add a test for drm_client_rotation()
> in drm_client_modeset.c? I'm not familiar with selftests to be honest.
>
> I found test-drm_cmdline_parser.c but that seems to cover only the
> cmdline parsing (which is working correctly already).

The cmdline here is the kernel command line. You were mentionning in
your commit log that video=540x960,reflect_x was broken?

But yeah, I meant this one.

Maxime
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/3] drm/vram-helper: Remove BO device from public interface

2019-12-11 Thread Thomas Zimmermann
TTM is an implementation detail of the VRAM helpers and therefore
shouldn't be exposed to the callers. There's only one correct value
for the BO device anyway, which is the one stored in the DRM device.

So remove struct ttm_bo_device from the VRAM-helper interface and
use the device's VRAM manager unconditionally. The GEM initializer
function fails if the VRAM manager has not been initialized.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/ast/ast_mode.c  |  3 +--
 drivers/gpu/drm/drm_gem_vram_helper.c   | 21 +
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  3 +--
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  3 +--
 include/drm/drm_gem_vram_helper.h   |  2 --
 6 files changed, 13 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index 26336642dd59..f4fbdab29bb7 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1144,8 +1144,7 @@ static int ast_cursor_init(struct drm_device *dev)
size = roundup(AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE, PAGE_SIZE);
 
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
-   gbo = drm_gem_vram_create(dev, >vram_mm->bdev,
- size, 0);
+   gbo = drm_gem_vram_create(dev, size, 0);
if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put;
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 4908f1281002..b760fd27f3c0 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -92,13 +92,18 @@ static void drm_gem_vram_placement(struct 
drm_gem_vram_object *gbo,
 }
 
 static int drm_gem_vram_init(struct drm_device *dev,
-struct ttm_bo_device *bdev,
 struct drm_gem_vram_object *gbo,
 size_t size, unsigned long pg_align)
 {
+   struct drm_vram_mm *vmm = dev->vram_mm;
+   struct ttm_bo_device *bdev;
int ret;
size_t acc_size;
 
+   if (WARN_ONCE(!vmm, "VRAM MM not initialized"))
+   return -EINVAL;
+   bdev = >bdev;
+
gbo->bo.base.funcs = _gem_vram_object_funcs;
 
ret = drm_gem_object_init(dev, >bo.base, size);
@@ -126,7 +131,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
 /**
  * drm_gem_vram_create() - Creates a VRAM-backed GEM object
  * @dev:   the DRM device
- * @bdev:  the TTM BO device backing the object
  * @size:  the buffer size in bytes
  * @pg_align:  the buffer's alignment in multiples of the page size
  *
@@ -135,7 +139,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
  * an ERR_PTR()-encoded error code otherwise.
  */
 struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
-   struct ttm_bo_device *bdev,
size_t size,
unsigned long pg_align)
 {
@@ -146,7 +149,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
if (!gbo)
return ERR_PTR(-ENOMEM);
 
-   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align);
+   ret = drm_gem_vram_init(dev, gbo, size, pg_align);
if (ret < 0)
goto err_kfree;
 
@@ -480,7 +483,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
Helper for implementing  drm_driver.dumb_create
  * @file:  the DRM file
  * @dev:   the DRM device
- * @bdev:  the TTM BO device managing the buffer object
  * @pg_align:  the buffer's alignment in multiples of the page size
  * @args:  the arguments as provided to \
 drm_driver.dumb_create
@@ -496,7 +498,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
  */
 int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
- struct ttm_bo_device *bdev,
  unsigned long pg_align,
  struct drm_mode_create_dumb *args)
 {
@@ -512,7 +513,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
if (!size)
return -EINVAL;
 
-   gbo = drm_gem_vram_create(dev, bdev, size, pg_align);
+   gbo = drm_gem_vram_create(dev, size, pg_align);
if (IS_ERR(gbo))
return PTR_ERR(gbo);
 
@@ -604,11 +605,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
 {
-   if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized"))
-   return -EINVAL;
-
-   

[PATCH 0/3] drm/vram-helper: Various cleanups

2019-12-11 Thread Thomas Zimmermann
A number of cleanups that I wanted to apply for some time. The first
two patches simplify the public interface. The third patch adds support
for struct drm_driver.gem_create_object. All tested by running fbdev,
X11 and Weston on ast HW.

Thomas Zimmermann (3):
  drm/vram-helper: Remove interruptible flag from public interface
  drm/vram-helper: Remove BO device from public interface
  drm/vram-helper: Support struct drm_driver.gem_create_object

 drivers/gpu/drm/ast/ast_mode.c  |  3 +-
 drivers/gpu/drm/drm_gem_vram_helper.c   | 43 ++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  3 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  3 +-
 include/drm/drm_gem_vram_helper.h   |  6 +--
 6 files changed, 26 insertions(+), 34 deletions(-)

--
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drm/vram-helper: Remove interruptible flag from public interface

2019-12-11 Thread Thomas Zimmermann
The flag 'interruptible', which is passed to various functions,
is always set to be false. Remove it and hard-code the value.

Signed-off-by: Thomas Zimmermann 
Suggested-by: Daniel Vetter 
---
 drivers/gpu/drm/ast/ast_mode.c  |  2 +-
 drivers/gpu/drm/drm_gem_vram_helper.c   | 17 ++---
 drivers/gpu/drm/hisilicon/hibmc/hibmc_ttm.c |  2 +-
 drivers/gpu/drm/mgag200/mgag200_cursor.c|  2 +-
 drivers/gpu/drm/mgag200/mgag200_drv.c   |  2 +-
 include/drm/drm_gem_vram_helper.h   |  4 +---
 6 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c
index b879bd666e35..26336642dd59 100644
--- a/drivers/gpu/drm/ast/ast_mode.c
+++ b/drivers/gpu/drm/ast/ast_mode.c
@@ -1145,7 +1145,7 @@ static int ast_cursor_init(struct drm_device *dev)
 
for (i = 0; i < ARRAY_SIZE(ast->cursor.gbo); ++i) {
gbo = drm_gem_vram_create(dev, >vram_mm->bdev,
- size, 0, false);
+ size, 0);
if (IS_ERR(gbo)) {
ret = PTR_ERR(gbo);
goto err_drm_gem_vram_put;
diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 666cb4c22bb9..4908f1281002 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -94,8 +94,7 @@ static void drm_gem_vram_placement(struct drm_gem_vram_object 
*gbo,
 static int drm_gem_vram_init(struct drm_device *dev,
 struct ttm_bo_device *bdev,
 struct drm_gem_vram_object *gbo,
-size_t size, unsigned long pg_align,
-bool interruptible)
+size_t size, unsigned long pg_align)
 {
int ret;
size_t acc_size;
@@ -112,7 +111,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
drm_gem_vram_placement(gbo, TTM_PL_FLAG_VRAM | TTM_PL_FLAG_SYSTEM);
 
ret = ttm_bo_init(bdev, >bo, size, ttm_bo_type_device,
- >placement, pg_align, interruptible, acc_size,
+ >placement, pg_align, false, acc_size,
  NULL, NULL, ttm_buffer_object_destroy);
if (ret)
goto err_drm_gem_object_release;
@@ -130,7 +129,6 @@ static int drm_gem_vram_init(struct drm_device *dev,
  * @bdev:  the TTM BO device backing the object
  * @size:  the buffer size in bytes
  * @pg_align:  the buffer's alignment in multiples of the page size
- * @interruptible: sleep interruptible if waiting for memory
  *
  * Returns:
  * A new instance of  drm_gem_vram_object on success, or
@@ -139,8 +137,7 @@ static int drm_gem_vram_init(struct drm_device *dev,
 struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev,
struct ttm_bo_device *bdev,
size_t size,
-   unsigned long pg_align,
-   bool interruptible)
+   unsigned long pg_align)
 {
struct drm_gem_vram_object *gbo;
int ret;
@@ -149,7 +146,7 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
if (!gbo)
return ERR_PTR(-ENOMEM);
 
-   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align, interruptible);
+   ret = drm_gem_vram_init(dev, bdev, gbo, size, pg_align);
if (ret < 0)
goto err_kfree;
 
@@ -485,7 +482,6 @@ EXPORT_SYMBOL(drm_gem_vram_vunmap);
  * @dev:   the DRM device
  * @bdev:  the TTM BO device managing the buffer object
  * @pg_align:  the buffer's alignment in multiples of the page size
- * @interruptible: sleep interruptible if waiting for memory
  * @args:  the arguments as provided to \
 drm_driver.dumb_create
  *
@@ -502,7 +498,6 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
  struct drm_device *dev,
  struct ttm_bo_device *bdev,
  unsigned long pg_align,
- bool interruptible,
  struct drm_mode_create_dumb *args)
 {
size_t pitch, size;
@@ -517,7 +512,7 @@ int drm_gem_vram_fill_create_dumb(struct drm_file *file,
if (!size)
return -EINVAL;
 
-   gbo = drm_gem_vram_create(dev, bdev, size, pg_align, interruptible);
+   gbo = drm_gem_vram_create(dev, bdev, size, pg_align);
if (IS_ERR(gbo))
return PTR_ERR(gbo);
 
@@ -613,7 +608,7 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file,
return -EINVAL;
 

[PATCH 3/3] drm/vram-helper: Support struct drm_driver.gem_create_object

2019-12-11 Thread Thomas Zimmermann
Drivers that what to allocate VRAM GEM objects with additional fields
can now do this by implementing struct drm_driver.gem_create_object.

Signed-off-by: Thomas Zimmermann 
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index b760fd27f3c0..d475d94e2e3e 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -2,6 +2,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -142,13 +143,19 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct 
drm_device *dev,
size_t size,
unsigned long pg_align)
 {
+   struct drm_gem_object *gem;
struct drm_gem_vram_object *gbo;
int ret;
 
-   gbo = kzalloc(sizeof(*gbo), GFP_KERNEL);
-   if (!gbo)
+   if (dev->driver->gem_create_object)
+   gem = dev->driver->gem_create_object(dev, size);
+   else
+   gem = kzalloc(sizeof(*gbo), GFP_KERNEL);
+   if (!gem)
return ERR_PTR(-ENOMEM);
 
+   gbo = drm_gem_vram_of_gem(gem);
+
ret = drm_gem_vram_init(dev, gbo, size, pg_align);
if (ret < 0)
goto err_kfree;
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Question about MSM Driver

2019-12-11 Thread Rob Clark
On Wed, Dec 11, 2019 at 6:22 AM ggermanres  wrote:
>
> Hello.
>
> I have question about MSM Driver.
>
> I using Dragonboard 410 with ili9881 display. This is hobby project. This 
> display from xiaomi redmi 3x/4x. I made PCB board for connect them. I changed 
> dts, created panel driver (this all on buildroot with my config). All ok. Run 
> platform. I saw linux console. Freedreno (opengl test app) is working fine. 
> But I saw flickering like on old monitor I saw from phone. I tried changing 
> timings, but this helped a little bit (I used it from dtsi from xiaomi 
> repository).
>
> I think this is with vsync problem. Your driver support DSI_VSYNC input? In 
> panel driver I sent command for vblank, on oscilloscope I saw pulse on this 
> pin 60Hz. I tried find path in your driver code, added some debug output in 
> code with sync. I saw MDSS_DSI_0_TRIG_CTRL configured with support TE. But 
> Its not helped for me.
>
> If you know something, tell me. Or how change driver to support DSI_VSYNC 
> input.
>

I guess this is a command mode panel?  So you'd be caring about the TE
signal?  As far as I understand (from, iirc, jhugo) this was handled
by the hardware and not exposed to the driver on older devices.

If it is a video mode panel, the problem could be different (userspace
not waiting for pageflip event?)

BR,
-R
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 2/2] drm/i915/vlv_dsi: Control panel and backlight enable GPIOs on BYT

2019-12-11 Thread Hans de Goede

Hi,

On 11-12-2019 01:24, Linus Walleij wrote:

On Mon, Dec 2, 2019 at 4:49 PM Hans de Goede  wrote:


There is only one problem, currently is is not possible to
unregister a mapping added with pinctrl_register_mappings
and the i915 driver is typically a module which can be unloaded
and I believe actually is unloaded as part of the i915 CI.

pinctrl_register_mappings copies the passed in mapping, but
it is a shallow copy, so it contains pointers to the modules
const segment and we do not want to re-add another copy of
the mapping when the module loads a second time.

Fixing this is easy though, there already is a pinctrl_unregister_map()
function, we just need to export it so that the i915 driver can
remove the mapping when it is unbound.

Linus would exporting this function be ok with you?


Yep!


Linus, question what is the purpose of the "dupping" / shallow
copying of the argument passed to pinctrl_register_map ?


The initial commit contained this comment later removed:

+   /*
+* Make a copy of the map array - string pointers will end up in the
+* kernel const section anyway so these do not need to be deep copied.
+*/

The use was to free up memory for platforms using boardfiles
with a gazillion variants and huge pin control tables, so these
could be marked  __initdata and discarded after boot.
As the strings would anyway stay around we didn't need to
deep copy.

See for example in arch/arm/mach-u300/core.c
static struct pinctrl_map __initdata u300_pinmux_map[]


Since
it is shallow the mem for any pointers contained within there need
to be kept around by the caller, so why not let the caller keep
the pinctrl_map struct itself around too?


So the strings will be kept around because the kernel can't get
rid of strings. (Yeah it is silly, should haven been fixed ages
ago, but not by me, haha :)


If we are going to export pinctrl_unregister_map() we need to make it
do the right thing for dupped maps too, we can just store the dup flag
in struct pinctrl_maps. So this is easy, but I wonder if we cannot
get rid of the dupping all together ?


Maybe ... I don't know. What do you think? I suppose you could
make u300 crash if you do that.


I've prepared a patch which makes pinctrl_register_mappings remember
if the mapping is dupped or not (store the dup value in struct pinctrl_maps);
and which modifies pinctrl_unregister_map() to do the right thing
depending on the stored dup value.

I still need to test the new series and then I will post it.

Regards,

Hans

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: panel-orientation-quirks: Add quirk for Teclast X89 tablet

2019-12-11 Thread Hans de Goede

Hi,

I know these kinda patches are sorta trivial, still I prefer to get an
Acked-by before pushing this to drm-misc-next. Can someone review this please?

Alternative I guess we could agree that pushing patches which just add a dmi
quirk to drm_panel_orientation_quirks.c is ok when the patch has sat on the
list without any response for a week ?

Regards,

Hans



On 02-12-2019 11:50, Hans de Goede wrote:

The Teclast X89 uses an upside-down mounted eDP panel, add a
panel-orientation quirk for this.

Signed-off-by: Hans de Goede 
---
  drivers/gpu/drm/drm_panel_orientation_quirks.c | 13 +
  1 file changed, 13 insertions(+)

diff --git a/drivers/gpu/drm/drm_panel_orientation_quirks.c 
b/drivers/gpu/drm/drm_panel_orientation_quirks.c
index ffd95bfeaa94..9f2d12f28a73 100644
--- a/drivers/gpu/drm/drm_panel_orientation_quirks.c
+++ b/drivers/gpu/drm/drm_panel_orientation_quirks.c
@@ -108,6 +108,13 @@ static const struct drm_dmi_panel_orientation_data 
lcd1200x1920_rightside_up = {
.orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
  };
  
+static const struct drm_dmi_panel_orientation_data teclast_x89 = {

+   .width = 1536,
+   .height = 2048,
+   .bios_dates = (const char * const []){ "12/19/2014", NULL },
+   .orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
+};
+
  static const struct dmi_system_id orientation_data[] = {
{   /* Acer One 10 (S1003) */
.matches = {
@@ -205,6 +212,12 @@ static const struct dmi_system_id orientation_data[] = {
  DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad 
D330-10IGM"),
},
.driver_data = (void *)_rightside_up,
+   }, {/* Teclast X89 (tPAD is too generic, also match on bios date) */
+   .matches = {
+ DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
+ DMI_EXACT_MATCH(DMI_BOARD_NAME, "tPAD"),
+   },
+   .driver_data = (void *)_x89,
}, {/* VIOS LTH17 */
.matches = {
  DMI_EXACT_MATCH(DMI_SYS_VENDOR, "VIOS"),



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 12/13] drm/connector: Split out orientation quirk detection (v2)

2019-12-11 Thread Hans de Goede

Hi All,

Can I get a review or Acked-by from someone for this patch please?

The other patches in this series all have acks and it would be nice if
I can push this to drm-misc-next...

Regards,

Hans

On 18-11-2019 16:51, Hans de Goede wrote:

From: Derek Basehore 

Not every platform needs quirk detection for panel orientation, so
split the drm_connector_init_panel_orientation_property into two
functions. One for platforms without the need for quirks, and the
other for platforms that need quirks.

Hans de Goede (changes in v2):

Rename the function from drm_connector_init_panel_orientation_property
to drm_connector_set_panel_orientation[_with_quirk] and pass in the
panel-orientation to set.

Beside the rename, also make the function set the passed in value
only once, if the value was set before (to a value other then
DRM_MODE_PANEL_ORIENTATION_UNKNOWN) make any further set calls a no-op.

This change is preparation for allowing the user to override the
panel-orientation for any connector from the kernel commandline.
When the panel-orientation is overridden this way, then we must ignore
the panel-orientation detection done by the driver.

Signed-off-by: Derek Basehore 
Signed-off-by: Hans de Goede 
---
  drivers/gpu/drm/drm_connector.c | 74 ++---
  drivers/gpu/drm/i915/display/icl_dsi.c  |  5 +-
  drivers/gpu/drm/i915/display/intel_dp.c |  9 ++-
  drivers/gpu/drm/i915/display/vlv_dsi.c  |  5 +-
  include/drm/drm_connector.h |  9 ++-
  5 files changed, 71 insertions(+), 31 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 4c766624b20d..40a985c411a6 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -1114,7 +1114,8 @@ static const struct drm_prop_enum_list hdmi_colorspaces[] 
= {
   *coordinates, so if userspace rotates the picture to adjust for
   *the orientation it must also apply the same transformation to the
   *touchscreen input coordinates. This property is initialized by calling
- * drm_connector_init_panel_orientation_property().
+ * drm_connector_set_panel_orientation() or
+ * drm_connector_set_panel_orientation_with_quirk()
   *
   * scaling mode:
   *This property defines how a non-native mode is upscaled to the native
@@ -1986,38 +1987,41 @@ void drm_connector_set_vrr_capable_property(
  EXPORT_SYMBOL(drm_connector_set_vrr_capable_property);
  
  /**

- * drm_connector_init_panel_orientation_property -
- * initialize the connecters panel_orientation property
- * @connector: connector for which to init the panel-orientation property.
- * @width: width in pixels of the panel, used for panel quirk detection
- * @height: height in pixels of the panel, used for panel quirk detection
+ * drm_connector_set_panel_orientation - sets the connecter's panel_orientation
+ * @connector: connector for which to set the panel-orientation property.
+ * @panel_orientation: drm_panel_orientation value to set
+ *
+ * This function sets the connector's panel_orientation and attaches
+ * a "panel orientation" property to the connector.
   *
- * This function should only be called for built-in panels, after setting
- * connector->display_info.panel_orientation first (if known).
+ * Calling this function on a connector where the panel_orientation has
+ * already been set is a no-op (e.g. the orientation has been overridden with
+ * a kernel commandline option).
   *
- * This function will check for platform specific (e.g. DMI based) quirks
- * overriding display_info.panel_orientation first, then if panel_orientation
- * is not DRM_MODE_PANEL_ORIENTATION_UNKNOWN it will attach the
- * "panel orientation" property to the connector.
+ * It is allowed to call this function with a panel_orientation of
+ * DRM_MODE_PANEL_ORIENTATION_UNKNOWN, in which case it is a no-op.
   *
   * Returns:
   * Zero on success, negative errno on failure.
   */
-int drm_connector_init_panel_orientation_property(
-   struct drm_connector *connector, int width, int height)
+int drm_connector_set_panel_orientation(
+   struct drm_connector *connector,
+   enum drm_panel_orientation panel_orientation)
  {
struct drm_device *dev = connector->dev;
struct drm_display_info *info = >display_info;
struct drm_property *prop;
-   int orientation_quirk;
  
-	orientation_quirk = drm_get_panel_orientation_quirk(width, height);

-   if (orientation_quirk != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
-   info->panel_orientation = orientation_quirk;
+   /* Already set? */
+   if (info->panel_orientation != DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
+   return 0;
  
-	if (info->panel_orientation == DRM_MODE_PANEL_ORIENTATION_UNKNOWN)

+   /* Don't attach the property if the orientation is unknown */
+   if (panel_orientation == DRM_MODE_PANEL_ORIENTATION_UNKNOWN)
return 0;
  
+	info->panel_orientation = panel_orientation;

Re: [PATCH 2/3] mfd: intel_soc_pmic: Rename pwm_backlight pwm-lookup to pwm_pmic_backlight

2019-12-11 Thread Hans de Goede

Hi Lee,

On 10-12-2019 09:51, Lee Jones wrote:

On Tue, 19 Nov 2019, Hans de Goede wrote:


At least Bay Trail (BYT) and Cherry Trail (CHT) devices can use 1 of 2
different PWM controllers for controlling the LCD's backlight brightness.

Either the one integrated into the PMIC or the one integrated into the
SoC (the 1st LPSS PWM controller).

So far in the LPSS code on BYT we have skipped registering the LPSS PWM
controller "pwm_backlight" lookup entry when a Crystal Cove PMIC is
present, assuming that in this case the PMIC PWM controller will be used.

On CHT we have been relying on only 1 of the 2 PWM controllers being
enabled in the DSDT at the same time; and always registered the lookup.

So far this has been working, but the correct way to determine which PWM
controller needs to be used is by checking a bit in the VBT table and
recently I've learned about 2 different BYT devices:
Point of View MOBII TAB-P800W
Acer Switch 10 SW5-012

Which use a Crystal Cove PMIC, yet the LCD is connected to the SoC/LPSS
PWM controller (and the VBT correctly indicates this), so here our old
heuristics fail.

Since only the i915 driver has access to the VBT, this commit renames
the "pwm_backlight" lookup entries for the Crystal Cove PMIC's PWM
controller to "pwm_pmic_backlight" so that the i915 driver can do a
pwm_get() for the right controller depending on the VBT bit, instead of
the i915 driver relying on a "pwm_backlight" lookup getting registered
which magically points to the right controller.

Signed-off-by: Hans de Goede 
---
  drivers/mfd/intel_soc_pmic_core.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


For my own reference:
   Acked-for-MFD-by: Lee Jones 


As mentioned in the cover-letter, to avoid breaking bi-sectability
as well as to avoid breaking the intel-gfx CI we need to merge this series
in one go through one tree. Specifically through the drm-intel tree.
Is that ok with you ?

If this is ok with you, then you do not have to do anything, I will just push
the entire series to drm-intel. drivers/mfd/intel_soc_pmic_core.c
does not see much changes so I do not expect this to lead to any conflicts.

Regards,

Hans

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/2] drm/komeda: Add basic support for D77

2019-12-11 Thread Mihail Atanassov
Hi Tiannan,

Thanks for the patch.

On Wednesday, 11 December 2019 10:30:09 GMT Tiannan Zhu (Arm Technology China) 
wrote:
> Make komeda driver can recongise D77, D77 is arm latest display
> product, compare with D71, D77 support some new features:
> 1. Crossbar: adjust every plane's zorder
> 2. ATU: Asynchronous Timewarp Unit, which is used to support VR/AR

I don't think the new features listing is relevant for this patch. I'd just
put a simple wording along the lines of:

Add D77 support via a new DT compatible string. The existing code is
sufficient for basic bring-up.

> 
> Signed-off-by: Tiannan Zhu (Arm Technology China) 
> ---
>  .../gpu/drm/arm/display/include/malidp_product.h  |  1 +
>  .../drm/arm/display/komeda/d71/d71_component.c| 15 +++
>  drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c  |  1 +
>  drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h |  4 
>  drivers/gpu/drm/arm/display/komeda/komeda_drv.c   |  1 +
>  5 files changed, 22 insertions(+)
> 
> diff --git a/drivers/gpu/drm/arm/display/include/malidp_product.h 
> b/drivers/gpu/drm/arm/display/include/malidp_product.h
> index dbd3d4765065..cbde47f06c9f 100644
> --- a/drivers/gpu/drm/arm/display/include/malidp_product.h
> +++ b/drivers/gpu/drm/arm/display/include/malidp_product.h
> @@ -19,6 +19,7 @@
>  
>  /* Mali-display product IDs */
>  #define MALIDP_D71_PRODUCT_ID0x0071
> +#define MALIDP_D77_PRODUCT_ID0x0072
>  #define MALIDP_D32_PRODUCT_ID0x0032
>  
>  union komeda_config_id {
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> index c7f7e9c545c7..ec96b69a5ade 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -1347,6 +1347,21 @@ int d71_probe_block(struct d71_dev *d71,
>   d71->glb_scl_coeff_addr[blk_id] = reg;
>   break;
>  
> + case D71_BLK_TYPE_GLB_SC_COEFF:
> + break;
> +
> + case D77_BLK_TYPE_CBU:
> + break;
> +
> + case D77_BLK_TYPE_ATU:
> + break;
> +
> + case D77_BLK_TYPE_ATU_VP:
> + break;
> +
> + case D77_BLK_TYPE_LPU_PERF:
> + break;
> +

I'd omit this from the basic enablement patch since it's effectively dead
code. Add it when you need it.

>   default:
>   DRM_ERROR("Unknown block (block_info: 0x%x) is found\n",
> blk->block_info);
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> index 2d429e310e5b..7598e4856e0c 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> @@ -614,6 +614,7 @@ d71_identify(u32 __iomem *reg_base, struct 
> komeda_chip_info *chip)
>   switch (product_id) {
>   case MALIDP_D71_PRODUCT_ID:
>   case MALIDP_D32_PRODUCT_ID:
> + case MALIDP_D77_PRODUCT_ID:
>   funcs = _chip_funcs;
>   break;
>   default:
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
> index 81de6a23e7f3..01ea53918cf1 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h
> @@ -477,8 +477,11 @@ enum d71_blk_type {
>   D71_BLK_TYPE_PERIPH = 0x08,
>   D71_BLK_TYPE_LPU_TRUSTED= 0x09,
>   D71_BLK_TYPE_AEU_TRUSTED= 0x0A,
> + D77_BLK_TYPE_CBU= 0x0B,
> + D77_BLK_TYPE_ATU= 0x0C,
>   D71_BLK_TYPE_LPU_LAYER  = 0x10,
>   D71_BLK_TYPE_LPU_WB_LAYER   = 0x11,
> + D77_BLK_TYPE_LPU_PERF   = 0x12,
>   D71_BLK_TYPE_CU_SPLITTER= 0x20,
>   D71_BLK_TYPE_CU_SCALER  = 0x21,
>   D71_BLK_TYPE_CU_MERGER  = 0x22,
> @@ -487,6 +490,7 @@ enum d71_blk_type {
>   D71_BLK_TYPE_DOU_FT_COEFF   = 0x32,
>   D71_BLK_TYPE_AEU_DS = 0x40,
>   D71_BLK_TYPE_AEU_AES= 0x41,
> + D77_BLK_TYPE_ATU_VP = 0xC0,

Same for all these block types.

>   D71_BLK_TYPE_RESERVED   = 0xFF
>  };
>  
> diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c 
> b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> index ad38bbc7431e..3ac6b43beb2c 100644
> --- a/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> +++ b/drivers/gpu/drm/arm/display/komeda/komeda_drv.c
> @@ -126,6 +126,7 @@ static int komeda_platform_remove(struct platform_device 
> *pdev)
>  static const struct of_device_id komeda_of_match[] = {
>   { .compatible = "arm,mali-d71", .data = d71_identify, },
>   { .compatible = "arm,mali-d32", .data = d71_identify, },
> + { .compatible = "arm,mali-d77", .data = d71_identify, },
>   {},
>  };
>  
> 


-- 
Mihail



___
dri-devel mailing list

Re: [PATCH] drm/komeda: Correct d71 register block counting

2019-12-11 Thread Mihail Atanassov
On Tuesday, 10 December 2019 06:10:34 GMT james qian wang (Arm Technology 
China) wrote:
> Per HW, d71->num_blocks includes reserved blocks but no PERIPH block,
> correct the block counting accordingly.
> D71 happens to only have one reserved block and periph block, which
> hides this counting error.
> 
> Signed-off-by: james qian wang (Arm Technology China) 
> 
> ---
>  drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> index 822b23a1ce75..d53f95dea0a1 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> @@ -414,8 +414,11 @@ static int d71_enum_resources(struct komeda_dev *mdev)
>   d71->pipes[i] = to_d71_pipeline(pipe);
>   }
>  
> - /* loop the register blks and probe */
> - i = 2; /* exclude GCU and PERIPH */
> + /* loop the register blks and probe.
> +  * NOTE: d71->num_blocks includes reserved blocks.
> +  * d71->num_blocks = GCU + valid blocks + reserved blocks
> +  */
> + i = 1; /* exclude GCU */
>   offset = D71_BLOCK_SIZE; /* skip GCU */
>   while (i < d71->num_blocks) {
>   blk_base = mdev->reg_base + (offset >> 2);
> @@ -425,9 +428,9 @@ static int d71_enum_resources(struct komeda_dev *mdev)
>   err = d71_probe_block(d71, , blk_base);
>   if (err)
>   goto err_cleanup;
> - i++;
>   }
>  
> + i++;
>   offset += D71_BLOCK_SIZE;
>   }
>  
> 

Reviewed-by: Mihail Atanassov 

-- 
Mihail



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 2/2] drm/komeda: Enable new product D32 support

2019-12-11 Thread Mihail Atanassov
On Tuesday, 10 December 2019 08:48:51 GMT james qian wang (Arm Technology 
China) wrote:
> D32 is simple version of D71, the difference is:
> - Only has one pipeline
> - Drop the periph block and merge it to GCU
> 
> v2: Rebase.
> v3: Isolate the block counting fix to a new patch

I would've expected the fix to be a part of this series as 2/3 and this
patch as 3/3.

Otherwise, this patch is
Reviewed-by: Mihail Atanassov 

> 
> Signed-off-by: James Qian Wang (Arm Technology China) 
> 
> ---
>  .../drm/arm/display/include/malidp_product.h  |  3 +-
>  .../arm/display/komeda/d71/d71_component.c|  2 +-
>  .../gpu/drm/arm/display/komeda/d71/d71_dev.c  | 39 ---
>  .../gpu/drm/arm/display/komeda/d71/d71_regs.h | 13 +++
>  .../gpu/drm/arm/display/komeda/komeda_drv.c   |  1 +
>  5 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/gpu/drm/arm/display/include/malidp_product.h 
> b/drivers/gpu/drm/arm/display/include/malidp_product.h
> index 1053b11352eb..16a8a2c22c42 100644
> --- a/drivers/gpu/drm/arm/display/include/malidp_product.h
> +++ b/drivers/gpu/drm/arm/display/include/malidp_product.h
> @@ -18,7 +18,8 @@
>  #define MALIDP_CORE_ID_STATUS(__core_id) (((__u32)(__core_id)) & 0xFF)
>  
>  /* Mali-display product IDs */
> -#define MALIDP_D71_PRODUCT_ID   0x0071
> +#define MALIDP_D71_PRODUCT_ID0x0071
> +#define MALIDP_D32_PRODUCT_ID0x0032
>  
>  union komeda_config_id {
>   struct {
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> index b6517c46e670..8a02ade369db 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_component.c
> @@ -1270,7 +1270,7 @@ static int d71_timing_ctrlr_init(struct d71_dev *d71,
>  
>   ctrlr = to_ctrlr(c);
>  
> - ctrlr->supports_dual_link = true;
> + ctrlr->supports_dual_link = d71->supports_dual_link;
>  
>   return 0;
>  }
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c 
> b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> index 7e79c2e88421..dd1ecf4276d3 100644
> --- a/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> +++ b/drivers/gpu/drm/arm/display/komeda/d71/d71_dev.c
> @@ -371,23 +371,33 @@ static int d71_enum_resources(struct komeda_dev *mdev)
>   goto err_cleanup;
>   }
>  
> - /* probe PERIPH */
> + /* Only the legacy HW has the periph block, the newer merges the periph
> +  * into GCU
> +  */
>   value = malidp_read32(d71->periph_addr, BLK_BLOCK_INFO);
> - if (BLOCK_INFO_BLK_TYPE(value) != D71_BLK_TYPE_PERIPH) {
> - DRM_ERROR("access blk periph but got blk: %d.\n",
> -   BLOCK_INFO_BLK_TYPE(value));
> - err = -EINVAL;
> - goto err_cleanup;
> + if (BLOCK_INFO_BLK_TYPE(value) != D71_BLK_TYPE_PERIPH)
> + d71->periph_addr = NULL;
> +
> + if (d71->periph_addr) {
> + /* probe PERIPHERAL in legacy HW */
> + value = malidp_read32(d71->periph_addr, 
> PERIPH_CONFIGURATION_ID);
> +
> + d71->max_line_size  = value & PERIPH_MAX_LINE_SIZE ? 4096 : 
> 2048;
> + d71->max_vsize  = 4096;
> + d71->num_rich_layers= value & PERIPH_NUM_RICH_LAYERS ? 2 : 
> 1;
> + d71->supports_dual_link = !!(value & PERIPH_SPLIT_EN);
> + d71->integrates_tbu = !!(value & PERIPH_TBU_EN);
> + } else {
> + value = malidp_read32(d71->gcu_addr, GCU_CONFIGURATION_ID0);
> + d71->max_line_size  = GCU_MAX_LINE_SIZE(value);
> + d71->max_vsize  = GCU_MAX_NUM_LINES(value);
> +
> + value = malidp_read32(d71->gcu_addr, GCU_CONFIGURATION_ID1);
> + d71->num_rich_layers= GCU_NUM_RICH_LAYERS(value);
> + d71->supports_dual_link = GCU_DISPLAY_SPLIT_EN(value);
> + d71->integrates_tbu = GCU_DISPLAY_TBU_EN(value);
>   }
>  
> - value = malidp_read32(d71->periph_addr, PERIPH_CONFIGURATION_ID);
> -
> - d71->max_line_size  = value & PERIPH_MAX_LINE_SIZE ? 4096 : 2048;
> - d71->max_vsize  = 4096;
> - d71->num_rich_layers= value & PERIPH_NUM_RICH_LAYERS ? 2 : 1;
> - d71->supports_dual_link = value & PERIPH_SPLIT_EN ? true : false;
> - d71->integrates_tbu = value & PERIPH_TBU_EN ? true : false;
> -
>   for (i = 0; i < d71->num_pipelines; i++) {
>   pipe = komeda_pipeline_add(mdev, sizeof(struct d71_pipeline),
>  _pipeline_funcs);
> @@ -606,6 +616,7 @@ d71_identify(u32 __iomem *reg_base, struct 
> komeda_chip_info *chip)
>  
>   switch (product_id) {
>   case MALIDP_D71_PRODUCT_ID:
> + case MALIDP_D32_PRODUCT_ID:
>   funcs = _chip_funcs;
>   break;
>   default:
> diff --git a/drivers/gpu/drm/arm/display/komeda/d71/d71_regs.h 
> 

Re: [PATCH] drm/dp_mst: clear time slots for ports invalid

2019-12-11 Thread Sasha Levin
Hi,

[This is an automated email]

This commit has been processed because it contains a -stable tag.
The stable tag indicates that it's relevant for the following trees: all

The bot has tested the following trees: v5.4.2, v5.3.15, v4.19.88, v4.14.158, 
v4.9.206, v4.4.206.

v5.4.2: Failed to apply! Possible dependencies:
14692a3637d4 ("drm/dp_mst: Add probe_lock")
37dfdc55ffeb ("drm/dp_mst: Cleanup drm_dp_send_link_address() a bit")
3f9b3f02dda5 ("drm/dp_mst: Protect drm_dp_mst_port members with locking")
50094b5dcd32 ("drm/dp_mst: Destroy topology_mgr mutexes")
5950f0b797fc ("drm/dp_mst: Move link address dumping into a function")
60f9ae9d0d3d ("drm/dp_mst: Remove huge conditional in 
drm_dp_mst_handle_up_req()")
7cb12d48314e ("drm/dp_mst: Destroy MSTBs asynchronously")
9408cc94eb04 ("drm/dp_mst: Handle UP requests asynchronously")
a29d881875fc ("drm/dp_mst: Refactor drm_dp_mst_handle_up_req()")
c485e2c97dae ("drm/dp_mst: Refactor pdt setup/teardown, add more locking")
caf81ec6cd72 ("drm: Destroy the correct mutex name in 
drm_dp_mst_topology_mgr_destroy")
dad7d84f8835 ("drm/dp_mst: Don't forget to update port->input in 
drm_dp_mst_handle_conn_stat()")
e2839ff692c6 ("drm/dp_mst: Rename drm_dp_add_port and drm_dp_update_port")

v5.3.15: Failed to apply! Possible dependencies:
14692a3637d4 ("drm/dp_mst: Add probe_lock")
37dfdc55ffeb ("drm/dp_mst: Cleanup drm_dp_send_link_address() a bit")
3f9b3f02dda5 ("drm/dp_mst: Protect drm_dp_mst_port members with locking")
50094b5dcd32 ("drm/dp_mst: Destroy topology_mgr mutexes")
562836a269e3 ("drm/dp_mst: Enable registration of AUX devices for MST 
ports")
5950f0b797fc ("drm/dp_mst: Move link address dumping into a function")
60f9ae9d0d3d ("drm/dp_mst: Remove huge conditional in 
drm_dp_mst_handle_up_req()")
7cb12d48314e ("drm/dp_mst: Destroy MSTBs asynchronously")
9408cc94eb04 ("drm/dp_mst: Handle UP requests asynchronously")
a29d881875fc ("drm/dp_mst: Refactor drm_dp_mst_handle_up_req()")
c485e2c97dae ("drm/dp_mst: Refactor pdt setup/teardown, add more locking")
caf81ec6cd72 ("drm: Destroy the correct mutex name in 
drm_dp_mst_topology_mgr_destroy")
dad7d84f8835 ("drm/dp_mst: Don't forget to update port->input in 
drm_dp_mst_handle_conn_stat()")
e2839ff692c6 ("drm/dp_mst: Rename drm_dp_add_port and drm_dp_update_port")

v4.19.88: Failed to apply! Possible dependencies:
1e55a53a28d3 ("drm: Trivial comment grammar cleanups")
706246c761dd ("drm/dp_mst: Refactor drm_dp_update_payload_part1()")
72fdb40c1a4b ("drm: extract drm_atomic_uapi.c")
7f4de521001f ("drm/atomic: Add __drm_atomic_helper_plane_reset")
a5ec8332d428 ("drm: Add per-plane pixel blend mode property")
c485e2c97dae ("drm/dp_mst: Refactor pdt setup/teardown, add more locking")
d0757afd00d7 ("drm/dp_mst: Rename drm_dp_mst_get_validated_(port|mstb)_ref 
and friends")
d86552efe10a ("drm/atomic: trim driver interface/docs")
dad7d84f8835 ("drm/dp_mst: Don't forget to update port->input in 
drm_dp_mst_handle_conn_stat()")
de9f8eea5a44 ("drm/atomic_helper: Stop modesets on unregistered connectors 
harder")
ebcc0e6b5091 ("drm/dp_mst: Introduce new refcounting scheme for mstbs and 
ports")
fc63668656bd ("drm/dp_mst: Remove bogus conditional in 
drm_dp_update_payload_part1()")

v4.14.158: Failed to apply! Possible dependencies:
0bb9c2b27f5e ("drm/dp/mst: Sideband message transaction to power up/down 
nodes")
163bcc2c74a2 ("drm/atomic: Move drm_crtc_commit to drm_crtc_state, v4.")
179c02fe90a4 ("drm/tve200: Add new driver for TVE200")
1e55a53a28d3 ("drm: Trivial comment grammar cleanups")
21a01abbe32a ("drm/atomic: Fix freeing connector/plane state too early by 
tracking commits, v3.")
22a07038c0ea ("drm: NULL pointer dereference [null-pointer-deref] (CWE 476) 
problem")
24557865c8b1 ("drm: Add Content Protection property")
2ed077e467ee ("drm: Add drm_object lease infrastructure [v5]")
34ca26a98ad6 ("drm/atomic_helper: Allow DPMS On<->Off changes for 
unregistered connectors")
0d4cf21b ("drm: add connector info/property for non-desktop displays 
[v2]")
6d544fd6f4e1 ("drm/doc: Put all driver docs into a separate chapter")
706246c761dd ("drm/dp_mst: Refactor drm_dp_update_payload_part1()")
72fdb40c1a4b ("drm: extract drm_atomic_uapi.c")
8d70f395e6cb ("drm: Add support for a panel-orientation connector property, 
v6")
935774cd71fe ("drm: Add writeback connector type")
c485e2c97dae ("drm/dp_mst: Refactor pdt setup/teardown, add more locking")
c76f0f7cb546 ("drm: Begin an API for in-kernel clients")
d0757afd00d7 ("drm/dp_mst: Rename drm_dp_mst_get_validated_(port|mstb)_ref 
and friends")
dad7d84f8835 ("drm/dp_mst: Don't forget to update port->input in 
drm_dp_mst_handle_conn_stat()")
de9f8eea5a44 ("drm/atomic_helper: Stop modesets on unregistered connectors 
harder")
e96550956fbc 

Re: [PATCH][next] drm/i915/display: remove duplicated assignment to pointer crtc_state

2019-12-11 Thread Ville Syrjälä
On Tue, Dec 10, 2019 at 02:45:35PM +, Colin King wrote:
> From: Colin Ian King 
> 
> Pointer crtc_state is being assigned twice, one of these is redundant
> and can be removed.
> 
> Addresses-Coverity: ("Evaluation order violation")
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c 
> b/drivers/gpu/drm/i915/display/intel_display.c
> index 5c50b7d2db25..f3389d315b19 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -17751,7 +17751,7 @@ intel_modeset_setup_hw_state(struct drm_device *dev,
>  
>   for_each_intel_crtc(_priv->drm, crtc) {
>   struct intel_crtc_state *crtc_state =
> - crtc_state = to_intel_crtc_state(crtc->base.state);
> + to_intel_crtc_state(crtc->base.state);

Thanks.

Pushed to drm-intel-next-queued.

>  
>   intel_sanitize_crtc(crtc, ctx);
>   intel_dump_pipe_config(crtc_state, NULL, "[setup_hw_state]");
> -- 
> 2.24.0

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH][next] drm/i915: remove redundant checks for a null fb pointer

2019-12-11 Thread Ville Syrjälä
On Tue, Dec 10, 2019 at 02:23:49PM +, Colin King wrote:
> From: Colin Ian King 
> 
> A prior check and return when pointer fb is null makes
> subsequent null checks on fb redundant.  Remove the redundant
> null checks.
> 
> Addresses-Coverity: ("Logically dead code")
> Signed-off-by: Colin Ian King 
> ---
>  drivers/gpu/drm/i915/i915_debugfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
> b/drivers/gpu/drm/i915/i915_debugfs.c
> index 062e5bef637a..a48478be6e8f 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -2600,8 +2600,8 @@ static void intel_plane_hw_info(struct seq_file *m, 
> struct intel_plane *plane)
>  plane_state->hw.rotation);
>  
>   seq_printf(m, "\t\thw: fb=%d,%s,%dx%d, visible=%s, src=" 
> DRM_RECT_FP_FMT ", dst=" DRM_RECT_FMT ", rotation=%s\n",
> -fb ? fb->base.id : 0, fb ? format_name.str : "n/a",
> -fb ? fb->width : 0, fb ? fb->height : 0,
> +fb->base.id, format_name.str,
> +fb->width, fb->height,

Thanks.

Pushed to drm-intel-next-queued.

>  yesno(plane_state->uapi.visible),
>  DRM_RECT_FP_ARG(_state->uapi.src),
>  DRM_RECT_ARG(_state->uapi.dst),
> -- 
> 2.24.0
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] video: hdmi: indicate applicability in avi infoframe log

2019-12-11 Thread Ville Syrjälä
On Wed, Dec 11, 2019 at 10:48:42AM +0100, Johan Korsnes wrote:
> When logging the AVI InfoFrame, clearly indicate whether or not
> attributes are active/"in effect". The specification is given in
> CTA-861-G Section 6.4: Format of Version 2, 3 & 4 AVI InfoFrames.
> 
> Attribute BytesRequirement
> Ext. Colorimetry  EC0..EC2 Colorimetry (C0,C1) set to Extended.
> IT Contents Type  CN0,CN1  IT Content (ITC) set to True.
> RGB Quant. Range  Q0,Q1Color Space (Y0..Y2) set to RGB.
> YCC Quant. Range  YQ0,YQ1  Color space (Y0..Y2) set to YCbCr.
> 
> Example log output with patch applied:
> HDMI infoframe: Auxiliary Video Information (AVI), version 2, length 13
> colorspace: RGB
> scan mode: No Data
> colorimetry: ITU709
> picture aspect: 16:9
> active aspect: Same as Picture
> itc: IT Content
> extended colorimetry: N/A (0x0)
> quantization range: Full
> nups: Unknown Non-uniform Scaling
> video code: 16
> ycc quantization range: N/A (0x0)
> hdmi content type: Graphics
> pixel repeat: 0
> bar top 0, bottom 0, left 0, right 0
> 
> Signed-off-by: Johan Korsnes 
> Cc: Hans Verkuil 
> Cc: Martin Bugge 
> 
> ---
> v1 -> v2:
>  * Indicate applicability not only for ext. colorimetry
> ---
>  drivers/video/hdmi.c | 40 
>  1 file changed, 32 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
> index 9c82e2a0a411..491a77b28a9b 100644
> --- a/drivers/video/hdmi.c
> +++ b/drivers/video/hdmi.c
> @@ -1209,16 +1209,40 @@ static void hdmi_avi_infoframe_log(const char *level,
>   hdmi_log("active aspect: %s\n",
>   hdmi_active_aspect_get_name(frame->active_aspect));
>   hdmi_log("itc: %s\n", frame->itc ? "IT Content" : "No Data");
> - hdmi_log("extended colorimetry: %s\n",
> - 
> hdmi_extended_colorimetry_get_name(frame->extended_colorimetry));
> - hdmi_log("quantization range: %s\n",
> - 
> hdmi_quantization_range_get_name(frame->quantization_range));
> +
> + if (frame->colorimetry == HDMI_COLORIMETRY_EXTENDED)
> + hdmi_log("extended colorimetry: %s\n",
> +  
> hdmi_extended_colorimetry_get_name(frame->extended_colorimetry));
> + else
> + hdmi_log("extended colorimetry: N/A (0x%x)\n",
> +  frame->extended_colorimetry);
> +
> + if (frame->colorspace == HDMI_COLORSPACE_RGB)
> + hdmi_log("quantization range: %s\n",
> +  
> hdmi_quantization_range_get_name(frame->quantization_range));
> + else
> + hdmi_log("quantization range: N/A (0x%x)\n",
> +  frame->quantization_range);
> +
>   hdmi_log("nups: %s\n", hdmi_nups_get_name(frame->nups));
>   hdmi_log("video code: %u\n", frame->video_code);
> - hdmi_log("ycc quantization range: %s\n",
> - 
> hdmi_ycc_quantization_range_get_name(frame->ycc_quantization_range));
> - hdmi_log("hdmi content type: %s\n",
> - hdmi_content_type_get_name(frame->content_type));
> +
> + if (frame->colorspace == HDMI_COLORSPACE_YUV422 ||
> + frame->colorspace == HDMI_COLORSPACE_YUV444 ||
> + frame->colorspace == HDMI_COLORSPACE_YUV420)

ocd nit: order 444||422||420 or 420||422||444

> + hdmi_log("ycc quantization range: %s\n",
> +  
> hdmi_ycc_quantization_range_get_name(frame->ycc_quantization_range));
> + else
> + hdmi_log("ycc quantization range: N/A (0x%x)\n",
> +  frame->ycc_quantization_range);

CTA-861-G does recommend that we set YQ to match Q when trasmitting
RGB. So not sure "N/A" is entirely accurate here. However we also
found out that following that recommendation did break some crappy
sinks which get confused when they see RGB + YQ!=0. So now we follow
that recommendation only for HDMI 2.0+ sinks. Anyways, as long as the
raw value is present I guess we can stil spot such cases from the logs.

Reviewed-by: Ville Syrjälä 

> +
> + if (frame->itc)
> + hdmi_log("hdmi content type: %s\n",
> +  hdmi_content_type_get_name(frame->content_type));
> + else
> + hdmi_log("hdmi content type: N/A (0x%x)\n",
> +  frame->content_type);
> +
>   hdmi_log("pixel repeat: %u\n", frame->pixel_repeat);
>   hdmi_log("bar top %u, bottom %u, left %u, right %u\n",
>   frame->top_bar, frame->bottom_bar,
> -- 
> 2.23.0
> 
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org

Re: [PATCH libdrm v4] modetest: Use floating vrefresh while dumping mode

2019-12-11 Thread Ville Syrjälä
On Tue, Dec 03, 2019 at 06:37:36AM -0800, Devarsh Thakkar wrote:
> Add function to derive floating value of vertical
> refresh rate from drm mode using pixel clock,
> horizontal total size and vertical total size.
> 
> Use this function to find suitable mode having vrefresh
> value which is matching with user provided vrefresh value.
> 
> If user doesn't provide any vrefresh value in args then
> update vertical refresh rate value in pipe args using this
> function.
> 
> Also use this function for printing floating vrefresh while
> dumping all available modes.
> 
> This will give more accurate picture to user for available modes
> differentiated by floating vertical refresh rate and help user
> select more appropriate mode using suitable refresh rate value.
> 
> V4:
> 1) While setting mode, print mode name and vrefresh using struct
>drmModeModeInfo instead of struct pipe_args.
> 2) Revert back to using a float value instead of float *
>for vrefresh arg in connector_find_mode().
> 
> V3:
> 1) Change name of function used to derive refresh rate.
> 
> V2:
> 1) Don't use inline function for deriving refresh rate from mode.
> 2) If requested mode not found, print refresh rate only
>if user had provided it in args.
> 
> Signed-off-by: Devarsh Thakkar 
> Reviewed-by: Neil Armstrong 

Thanks. lgtm -> pushed to master.

> ---
>  tests/modetest/modetest.c | 35 +++
>  1 file changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
> index b4edfcb..e998e8e 100644
> --- a/tests/modetest/modetest.c
> +++ b/tests/modetest/modetest.c
> @@ -133,6 +133,12 @@ static inline int64_t U642I64(uint64_t val)
>   return (int64_t)*((int64_t *));
>  }
>  
> +static float mode_vrefresh(drmModeModeInfo *mode)
> +{
> + return  mode->clock * 1000.00
> + / (mode->htotal * mode->vtotal);
> +}
> +
>  #define bit_name_fn(res) \
>  const char * res##_str(int type) {   \
>   unsigned int i; \
> @@ -210,9 +216,9 @@ static void dump_encoders(struct device *dev)
>  
>  static void dump_mode(drmModeModeInfo *mode)
>  {
> - printf("  %s %d %d %d %d %d %d %d %d %d %d",
> + printf("  %s %.2f %d %d %d %d %d %d %d %d %d",
>  mode->name,
> -mode->vrefresh,
> +mode_vrefresh(mode),
>  mode->hdisplay,
>  mode->hsync_start,
>  mode->hsync_end,
> @@ -828,7 +834,6 @@ connector_find_mode(struct device *dev, uint32_t con_id, 
> const char *mode_str,
>   drmModeConnector *connector;
>   drmModeModeInfo *mode;
>   int i;
> - float mode_vrefresh;
>  
>   connector = get_connector_by_id(dev, con_id);
>   if (!connector || !connector->count_modes)
> @@ -837,15 +842,14 @@ connector_find_mode(struct device *dev, uint32_t 
> con_id, const char *mode_str,
>   for (i = 0; i < connector->count_modes; i++) {
>   mode = >modes[i];
>   if (!strcmp(mode->name, mode_str)) {
> - /* If the vertical refresh frequency is not specified 
> then return the
> -  * first mode that match with the name. Else, return 
> the mode that match
> -  * the name and the specified vertical refresh 
> frequency.
> + /* If the vertical refresh frequency is not specified
> +  * then return the first mode that match with the name.
> +  * Else, return the mode that match the name and
> +  * the specified vertical refresh frequency.
>*/
> - mode_vrefresh = mode->clock * 1000.00
> - / (mode->htotal * mode->vtotal);
>   if (vrefresh == 0)
>   return mode;
> - else if (fabs(mode_vrefresh - vrefresh) < 0.005)
> + else if (fabs(mode_vrefresh(mode) - vrefresh) < 0.005)
>   return mode;
>   }
>   }
> @@ -911,7 +915,13 @@ static int pipe_find_crtc_and_mode(struct device *dev, 
> struct pipe_arg *pipe)
>   mode = connector_find_mode(dev, pipe->con_ids[i],
>  pipe->mode_str, pipe->vrefresh);
>   if (mode == NULL) {
> - fprintf(stderr,
> + if (pipe->vrefresh)
> + fprintf(stderr,
> + "failed to find mode "
> + "\"%s-%.2fHz\" for connector %s\n",
> + pipe->mode_str, pipe->vrefresh, pipe->cons[i]);
> + else
> + fprintf(stderr,
>   "failed to find mode \"%s\" for connector %s\n",
>   pipe->mode_str, 

Re: [PATCH] drm/edid: Increase size of VDB and CMDB bitmaps to 256 bits

2019-12-11 Thread Ville Syrjälä
On Tue, Dec 10, 2019 at 02:10:48PM -0800, Thomas Anderson wrote:
> CEA-861-G adds modes up to 219, so increase the size of the
> maps in preparation for adding the new modes to drm_edid.c.
> 
> Signed-off-by: Thomas Anderson 

Thanks. lgtm. Pushed to drm-misc-next.

PS. I do wonder a bit if we should consider a more economical way to
track this stuff. Not really sure how many bits we can realistically
expect to be set in these bitmasks...

> ---
>  include/drm/drm_connector.h | 16 
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 5f8c3389d46f..17b728d9c73d 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -188,19 +188,19 @@ struct drm_hdmi_info {
>  
>   /**
>* @y420_vdb_modes: bitmap of modes which can support ycbcr420
> -  * output only (not normal RGB/YCBCR444/422 outputs). There are total
> -  * 107 VICs defined by CEA-861-F spec, so the size is 128 bits to map
> -  * upto 128 VICs;
> +  * output only (not normal RGB/YCBCR444/422 outputs). The max VIC
> +  * defined by the CEA-861-G spec is 219, so the size is 256 bits to map
> +  * up to 256 VICs.
>*/
> - unsigned long y420_vdb_modes[BITS_TO_LONGS(128)];
> + unsigned long y420_vdb_modes[BITS_TO_LONGS(256)];
>  
>   /**
>* @y420_cmdb_modes: bitmap of modes which can support ycbcr420
> -  * output also, along with normal HDMI outputs. There are total 107
> -  * VICs defined by CEA-861-F spec, so the size is 128 bits to map upto
> -  * 128 VICs;
> +  * output also, along with normal HDMI outputs. The max VIC defined by
> +  * the CEA-861-G spec is 219, so the size is 256 bits to map up to 256
> +  * VICs.
>*/
> - unsigned long y420_cmdb_modes[BITS_TO_LONGS(128)];
> + unsigned long y420_cmdb_modes[BITS_TO_LONGS(256)];
>  
>   /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
>   u64 y420_cmdb_map;
> -- 
> 2.24.0.525.g8f36a354ae-goog

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.4 109/134] drm/amdgpu: Call find_vma under mmap_sem

2019-12-11 Thread Sasha Levin
From: Jason Gunthorpe 

[ Upstream commit a9ae8731e6e52829a935d81a65d7f925cb95dbac ]

find_vma() must be called under the mmap_sem, reorganize this code to
do the vma check after entering the lock.

Further, fix the unlocked use of struct task_struct's mm, instead use
the mm from hmm_mirror which has an active mm_grab. Also the mm_grab
must be converted to a mm_get before acquiring mmap_sem or calling
find_vma().

Fixes: 66c45500bfdc ("drm/amdgpu: use new HMM APIs and helpers")
Fixes: 0919195f2b0d ("drm/amdgpu: Enable amdgpu_ttm_tt_get_user_pages in worker 
threads")
Link: https://lore.kernel.org/r/20191112202231.3856-11-...@ziepe.ca
Acked-by: Christian König 
Reviewed-by: Felix Kuehling 
Reviewed-by: Philip Yang 
Tested-by: Philip Yang 
Signed-off-by: Jason Gunthorpe 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 37 ++---
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index dff41d0a85fe9..c0e41f1f0c236 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -788,7 +789,7 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, 
struct page **pages)
struct hmm_mirror *mirror = bo->mn ? >mn->mirror : NULL;
struct ttm_tt *ttm = bo->tbo.ttm;
struct amdgpu_ttm_tt *gtt = (void *)ttm;
-   struct mm_struct *mm = gtt->usertask->mm;
+   struct mm_struct *mm;
unsigned long start = gtt->userptr;
struct vm_area_struct *vma;
struct hmm_range *range;
@@ -796,25 +797,14 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, 
struct page **pages)
uint64_t *pfns;
int r = 0;
 
-   if (!mm) /* Happens during process shutdown */
-   return -ESRCH;
-
if (unlikely(!mirror)) {
DRM_DEBUG_DRIVER("Failed to get hmm_mirror\n");
-   r = -EFAULT;
-   goto out;
+   return -EFAULT;
}
 
-   vma = find_vma(mm, start);
-   if (unlikely(!vma || start < vma->vm_start)) {
-   r = -EFAULT;
-   goto out;
-   }
-   if (unlikely((gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) &&
-   vma->vm_file)) {
-   r = -EPERM;
-   goto out;
-   }
+   mm = mirror->hmm->mmu_notifier.mm;
+   if (!mmget_not_zero(mm)) /* Happens during process shutdown */
+   return -ESRCH;
 
range = kzalloc(sizeof(*range), GFP_KERNEL);
if (unlikely(!range)) {
@@ -847,6 +837,17 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, 
struct page **pages)
hmm_range_wait_until_valid(range, HMM_RANGE_DEFAULT_TIMEOUT);
 
down_read(>mmap_sem);
+   vma = find_vma(mm, start);
+   if (unlikely(!vma || start < vma->vm_start)) {
+   r = -EFAULT;
+   goto out_unlock;
+   }
+   if (unlikely((gtt->userflags & AMDGPU_GEM_USERPTR_ANONONLY) &&
+   vma->vm_file)) {
+   r = -EPERM;
+   goto out_unlock;
+   }
+
r = hmm_range_fault(range, 0);
up_read(>mmap_sem);
 
@@ -865,15 +866,19 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, 
struct page **pages)
}
 
gtt->range = range;
+   mmput(mm);
 
return 0;
 
+out_unlock:
+   up_read(>mmap_sem);
 out_free_pfns:
hmm_range_unregister(range);
kvfree(pfns);
 out_free_ranges:
kfree(range);
 out:
+   mmput(mm);
return r;
 }
 
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5.3 073/105] drm: damage_helper: Fix race checking plane->state->fb

2019-12-11 Thread Greg Kroah-Hartman
From: Sean Paul 

commit 354c2d310082d1c384213ba76c3757dd3cd8755d upstream.

Since the dirtyfb ioctl doesn't give us any hints as to which plane is
scanning out the fb it's marking as damaged, we need to loop through
planes to find it.

Currently we just reach into plane state and check, but that can race
with another commit changing the fb out from under us. This patch locks
the plane before checking the fb and will release the lock if the plane
is not displaying the dirty fb.

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Cc: Rob Clark 
Cc: Deepak Rawat 
Cc: Daniel Vetter 
Cc: Thomas Hellstrom 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Sean Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v5.0+
Reported-by: Daniel Vetter 
Reviewed-by: Daniel Vetter 
Signed-off-by: Sean Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20190904202938.110207-1-s...@poorly.run
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_damage_helper.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -212,8 +212,14 @@ retry:
drm_for_each_plane(plane, fb->dev) {
struct drm_plane_state *plane_state;
 
-   if (plane->state->fb != fb)
+   ret = drm_modeset_lock(>mutex, state->acquire_ctx);
+   if (ret)
+   goto out;
+
+   if (plane->state->fb != fb) {
+   drm_modeset_unlock(>mutex);
continue;
+   }
 
plane_state = drm_atomic_get_plane_state(state, plane);
if (IS_ERR(plane_state)) {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 5.4 55/92] drm: damage_helper: Fix race checking plane->state->fb

2019-12-11 Thread Greg Kroah-Hartman
From: Sean Paul 

commit 354c2d310082d1c384213ba76c3757dd3cd8755d upstream.

Since the dirtyfb ioctl doesn't give us any hints as to which plane is
scanning out the fb it's marking as damaged, we need to loop through
planes to find it.

Currently we just reach into plane state and check, but that can race
with another commit changing the fb out from under us. This patch locks
the plane before checking the fb and will release the lock if the plane
is not displaying the dirty fb.

Fixes: b9fc5e01d1ce ("drm: Add helper to implement legacy dirtyfb")
Cc: Rob Clark 
Cc: Deepak Rawat 
Cc: Daniel Vetter 
Cc: Thomas Hellstrom 
Cc: Maarten Lankhorst 
Cc: Maxime Ripard 
Cc: Sean Paul 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: dri-devel@lists.freedesktop.org
Cc:  # v5.0+
Reported-by: Daniel Vetter 
Reviewed-by: Daniel Vetter 
Signed-off-by: Sean Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20190904202938.110207-1-s...@poorly.run
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_damage_helper.c |8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -212,8 +212,14 @@ retry:
drm_for_each_plane(plane, fb->dev) {
struct drm_plane_state *plane_state;
 
-   if (plane->state->fb != fb)
+   ret = drm_modeset_lock(>mutex, state->acquire_ctx);
+   if (ret)
+   goto out;
+
+   if (plane->state->fb != fb) {
+   drm_modeset_unlock(>mutex);
continue;
+   }
 
plane_state = drm_atomic_get_plane_state(state, plane);
if (IS_ERR(plane_state)) {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/gma500: globle no more!

2019-12-11 Thread Jani Nikula
On Wed, 11 Dec 2019, Daniel Vetter  wrote:
> globle, goblin, moblin?
>
> It's dead code, we lucked out.

Oh, sad to see it go. The oldest reference to globle_dev I could find
was from 2011.

Acked-by: Jani Nikula 

>
> Cc: Ville Syrjälä 
> Cc: Jani Nikula 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/gma500/mdfld_intel_display.c | 23 
>  1 file changed, 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c 
> b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> index b8bfb96008b8..4fff110c4921 100644
> --- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
> +++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
> @@ -113,27 +113,6 @@ static int psb_intel_panel_fitter_pipe(struct drm_device 
> *dev)
>   return (pfit_control >> 29) & 0x3;
>  }
>  
> -static struct drm_device globle_dev;
> -
> -void mdfld__intel_plane_set_alpha(int enable)
> -{
> - struct drm_device *dev = _dev;
> - int dspcntr_reg = DSPACNTR;
> - u32 dspcntr;
> -
> - dspcntr = REG_READ(dspcntr_reg);
> -
> - if (enable) {
> - dspcntr &= ~DISPPLANE_32BPP_NO_ALPHA;
> - dspcntr |= DISPPLANE_32BPP;
> - } else {
> - dspcntr &= ~DISPPLANE_32BPP;
> - dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
> - }
> -
> - REG_WRITE(dspcntr_reg, dspcntr);
> -}
> -
>  static int check_fb(struct drm_framebuffer *fb)
>  {
>   if (!fb)
> @@ -164,8 +143,6 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc 
> *crtc, int x, int y,
>   u32 dspcntr;
>   int ret;
>  
> - memcpy(_dev, dev, sizeof(struct drm_device));
> -
>   dev_dbg(dev->dev, "pipe = 0x%x.\n", pipe);
>  
>   /* no fb bound */

-- 
Jani Nikula, Intel Open Source Graphics Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/panfrost: Add the panfrost_gem_mapping concept

2019-12-11 Thread Rob Herring
On Wed, Dec 11, 2019 at 6:38 AM Steven Price  wrote:
>
> On 10/12/2019 23:08, Rob Herring wrote:
> > From: Boris Brezillon 
> >
> > With the introduction of per-FD address space, the same BO can be mapped
> > in different address space if the BO is globally visible (GEM_FLINK)
> > and opened in different context or if the dmabuf is self-imported. The
> > current implementation does not take that case into account, and
> > attaches the mapping directly to the panfrost_gem_object.
> >
> > Let's create a panfrost_gem_mapping struct and allow multiple mappings
> > per BO.
> >
> > The mappings are refcounted which helps solve another problem where
> > mappings were torn down (GEM handle closed by userspace) while GPU
> > jobs accessing those BOs were still in-flight. Jobs now keep a
> > reference on the mappings they use.
> >
> > v2 (robh):
> > - Minor review comment clean-ups from Steven
> > - Use list_is_singular helper
> > - Just WARN if we add a mapping when madvise state is not WILLNEED.
> >   With that, drop the use of object_name_lock.
> >
> > Fixes: a5efb4c9a562 ("drm/panfrost: Restructure the GEM object creation")
> > Fixes: 7282f7645d06 ("drm/panfrost: Implement per FD address spaces")
> > Cc: 
> > Signed-off-by: Boris Brezillon 
> > Signed-off-by: Rob Herring 
> > ---
> > I've hacked up IGT prime_self_import test to run on panfrost other than
> > the 2 test which depend on i915 debugfs files (export-vs-gem_close-race,
> > reimport-vs-gem_close-race). With this patch, they now pass.
> >
> > I'm not adding the test to IGT which is just a copy-n-paste of the
> > original except for different wrappers for BO alloc and mmap. That
> > should be fixed first IMO.
> >
> > Rob
> >
> >  drivers/gpu/drm/panfrost/panfrost_drv.c   |  91 +++--
> >  drivers/gpu/drm/panfrost/panfrost_gem.c   | 123 +++---
> >  drivers/gpu/drm/panfrost/panfrost_gem.h   |  41 +-
> >  .../gpu/drm/panfrost/panfrost_gem_shrinker.c  |   3 +-
> >  drivers/gpu/drm/panfrost/panfrost_job.c   |  13 +-
> >  drivers/gpu/drm/panfrost/panfrost_job.h   |   1 +
> >  drivers/gpu/drm/panfrost/panfrost_mmu.c   |  61 +
> >  drivers/gpu/drm/panfrost/panfrost_mmu.h   |   6 +-
> >  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  34 +++--
> >  9 files changed, 299 insertions(+), 74 deletions(-)
> >
>
> 
>
> > diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c 
> > b/drivers/gpu/drm/panfrost/panfrost_gem.c
> > index fd766b1395fb..3a7862e3e775 100644
> > --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> > +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> > @@ -29,6 +29,12 @@ static void panfrost_gem_free_object(struct 
> > drm_gem_object *obj)
> >   list_del_init(>base.madv_list);
> >   mutex_unlock(>shrinker_lock);
> >
> > + /*
> > +  * If we still have mappings attached to the BO, there's a problem in
> > +  * our refcounting.
> > +  */
> > + WARN_ON_ONCE(!list_empty(>mappings.list));
> > +
> >   if (bo->sgts) {
> >   int i;
> >   int n_sgt = bo->base.base.size / SZ_2M;
> > @@ -46,6 +52,68 @@ static void panfrost_gem_free_object(struct 
> > drm_gem_object *obj)
> >   drm_gem_shmem_free_object(obj);
> >  }
> >
> > +struct panfrost_gem_mapping *
> > +panfrost_gem_mapping_get(struct panfrost_gem_object *bo,
> > +  struct panfrost_file_priv *priv)
> > +{
> > + struct panfrost_gem_mapping *iter;
> > +
> > + mutex_lock(>mappings.lock);
> > + list_for_each_entry(iter, >mappings.list, node) {
> > + if (iter->mmu == >mmu) {
> > + kref_get(>refcount);
> > + break;
> > + }
> > + }
> > + mutex_unlock(>mappings.lock);
> > +
> > + return iter;
>
> If the entry isn't found then iter will equal
> container_of(>mappings.list, struct panfrost_gem_mapping, node) -
> but you actually want a NULL return in this case.

Ugg, yes. I knew that...

> I also think the previous version with a "member" variable being
> returned was clearer.

I over interpreted what you were suggesting. Will change it back and
*just* add the break.

Rob
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/4] drm: add pgprot callback to drm_gem_object_funcs

2019-12-11 Thread Thomas Zimmermann
Hi

Am 11.12.19 um 13:38 schrieb Daniel Vetter:
> On Wed, Dec 11, 2019 at 01:19:53PM +0100, Gerd Hoffmann wrote:
>> The callback allows drivers and helpers to tweak pgprot for mappings.
>> This is especially helpful when using shmem helpers.  It allows drivers
>> to switch mappings from writecombine (default) to something else (cached
>> for example) on a per-object base without having to supply their own
>> mmap() and vmap() functions.
>>
>> The patch also adds two implementations for the callback, for cached and
>> writecombine mappings, and the drm_gem_pgprot() function to update
>> pgprot for a given object, using the new _gem_object_funcs.pgprot
>> callback if available.
>>
>> Signed-off-by: Gerd Hoffmann 
>> ---
>>  include/drm/drm_gem.h | 15 +
>>  drivers/gpu/drm/drm_gem.c | 46 ++-
>>  2 files changed, 60 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
>> index 0b375069cd48..5beef7226e69 100644
>> --- a/include/drm/drm_gem.h
>> +++ b/include/drm/drm_gem.h
>> @@ -163,6 +163,17 @@ struct drm_gem_object_funcs {
>>   */
>>  int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
>>  
>> +/**
>> + * @pgprot:
>> + *
>> + * Tweak pgprot as needed, typically used to set cache bits.
>> + *
>> + * This callback is optional.
>> + *
>> + * If unset drm_gem_pgprot_wc() will be used.
>> + */
>> +pgprot_t (*pgprot)(struct drm_gem_object *obj, pgprot_t prot);
> 
> I kinda prefer v1, mostly because this is a huge can of worms, and solving
> this properly is going to be real hard (and will necessarily involve
> dma-buf and dma-api and probably more). Charging ahead here just risks
> that we dig ourselves into a corner. You're v1 is maybe not the most
> clean, but just a few code bits here should be more flexible and
> easier to hack on and experiment around with.
> -Daniel

I agree; at least patch v1 is known to be a sound approach. The others
might fall on our feet at some point. Sorry, Gerd, if my proposals added
lots of work for you.

Best regards
Thomas

> 
>> +
>>  /**
>>   * @vm_ops:
>>   *
>> @@ -350,6 +361,10 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, 
>> unsigned long obj_size,
>>   struct vm_area_struct *vma);
>>  int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>>  
>> +pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot);
>> +pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot);
>> +pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot);
>> +
>>  /**
>>   * drm_gem_object_get - acquire a GEM buffer object reference
>>   * @obj: GEM buffer object
>> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
>> index 56f42e0f2584..1c468fe8e342 100644
>> --- a/drivers/gpu/drm/drm_gem.c
>> +++ b/drivers/gpu/drm/drm_gem.c
>> @@ -1119,7 +1119,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, 
>> unsigned long obj_size,
>>  return -EINVAL;
>>  
>>  vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | 
>> VM_DONTDUMP;
>> -vma->vm_page_prot = 
>> pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
>> +vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
>> +vma->vm_page_prot = drm_gem_pgprot(obj, vma->vm_page_prot);
>>  vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>>  }
>>  
>> @@ -1210,6 +1211,49 @@ int drm_gem_mmap(struct file *filp, struct 
>> vm_area_struct *vma)
>>  }
>>  EXPORT_SYMBOL(drm_gem_mmap);
>>  
>> +/**
>> + * drm_gem_mmap - update pgprot for objects needing a cachable mapping.
>> + * @obj: the GEM object.
>> + * @prot: page attributes.
>> + *
>> + * This function can be used as _gem_object_funcs.pgprot callback.
>> + */
>> +pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot)
>> +{
>> +return prot;
>> +}
>> +EXPORT_SYMBOL(drm_gem_pgprot_cached);
>> +
>> +/**
>> + * drm_gem_mmap - update pgprot for objects needing a wc mapping.
>> + * @obj: the GEM object.
>> + * @prot: page attributes.
>> + *
>> + * This function can be used as _gem_object_funcs.pgprot callback.
>> + */
>> +pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot)
>> +{
>> +return pgprot_writecombine(prot);
>> +}
>> +EXPORT_SYMBOL(drm_gem_pgprot_wc);
>> +
>> +/**
>> + * drm_gem_mmap - update pgprot for a given gem object.
>> + * @obj: the GEM object.
>> + * @prot: page attributes.
>> + *
>> + * This function updates pgprot according to the needs of the given
>> + * object.  If present _gem_object_funcs.pgprot callback will be
>> + * used, otherwise drm_gem_pgprot_wc() is called.
>> + */
>> +pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot)
>> +{
>> +if (obj->funcs->pgprot)
>> +return obj->funcs->pgprot(obj, prot);
>> +return drm_gem_pgprot_wc(obj, prot);
>> +}
>> 

Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Gerd Hoffmann
  Hi,

> btw on why udl does this: Imported bo are usually rendered by real hw, and
> reading it uncached/wc is the more defensive setting. It would be kinda
> nice if dma-buf would expose this, but I fear dma-api maintainers would
> murder us if we even just propose that ... so it's a mess right now.

I suspect for imported dma-bufs we should leave the mmap() to the
exporter instead of pulling the pages out of the sgt and map them
ourself.

> btw the issue extends to dma access by devices too, e.g. both i915 and
> amdgpu can select the coherency mode at runtime (using e.g. the pcie
> no-snoop transaction mode), and we have similar uncoordinated hacks in
> there too, like in udl.

Hmm.  Ok.  I guess I'm not going to try solve all that properly just for
the little virtio fix.

Just curious:  How do you tell your hardware?  Are there bits for that
in the gtt, simliar to the caching bits in the x86 page tables?

cheers,
  Gerd

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Thomas Zimmermann
Hi

Am 11.12.19 um 13:36 schrieb Daniel Vetter:
> 
> The udl use-case should be covered already, simply set the flag correctly
> at create/import time? It's per-object ...

The original udl gem code did this. It was additional state for
something that was detectable from the value of import_attach. So udl
now overrides vmap and mmap.


> btw on why udl does this: Imported bo are usually rendered by real hw, and
> reading it uncached/wc is the more defensive setting. It would be kinda
> nice if dma-buf would expose this, but I fear dma-api maintainers would
> murder us if we even just propose that ... so it's a mess right now.

Yeah, in some way it's a variation of the discussion around fbdev memory
access that we had before.

Best regards
Thomas

> 
> btw the issue extends to dma access by devices too, e.g. both i915 and
> amdgpu can select the coherency mode at runtime (using e.g. the pcie
> no-snoop transaction mode), and we have similar uncoordinated hacks in
> there too, like in udl.
> -Daniel
> 
>>
>> Acked-by: Thomas Zimmermann 
>>
>> if you prefer to merge v1.
>>
>>>
>>> Best regards
>>> Thomas
>>>

>>>
>>
>> -- 
>> Thomas Zimmermann
>> Graphics Driver Developer
>> SUSE Software Solutions Germany GmbH
>> Maxfeldstr. 5, 90409 Nürnberg, Germany
>> (HRB 36809, AG Nürnberg)
>> Geschäftsführer: Felix Imendörffer
>>
> 
> 
> 
> 
>> ___
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/4] drm: add pgprot callback to drm_gem_object_funcs

2019-12-11 Thread Gerd Hoffmann
> > +   /**
> > +* @pgprot:
> > +*
> > +* Tweak pgprot as needed, typically used to set cache bits.
> > +*
> > +* This callback is optional.
> > +*
> > +* If unset drm_gem_pgprot_wc() will be used.
> > +*/
> > +   pgprot_t (*pgprot)(struct drm_gem_object *obj, pgprot_t prot);
> 
> I kinda prefer v1, mostly because this is a huge can of worms, and solving
> this properly is going to be real hard (and will necessarily involve
> dma-buf and dma-api and probably more). Charging ahead here just risks
> that we dig ourselves into a corner. You're v1 is maybe not the most
> clean, but just a few code bits here should be more flexible and
> easier to hack on and experiment around with.

Hmm.  Second vote for v1.

Problem with v1 is that it covers mmap() only, not vmap() ...

cheers,
  Gerd

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2] drm/panfrost: Add the panfrost_gem_mapping concept

2019-12-11 Thread Steven Price
On 10/12/2019 23:08, Rob Herring wrote:
> From: Boris Brezillon 
> 
> With the introduction of per-FD address space, the same BO can be mapped
> in different address space if the BO is globally visible (GEM_FLINK)
> and opened in different context or if the dmabuf is self-imported. The
> current implementation does not take that case into account, and 
> attaches the mapping directly to the panfrost_gem_object.
> 
> Let's create a panfrost_gem_mapping struct and allow multiple mappings
> per BO.
> 
> The mappings are refcounted which helps solve another problem where
> mappings were torn down (GEM handle closed by userspace) while GPU
> jobs accessing those BOs were still in-flight. Jobs now keep a
> reference on the mappings they use.
> 
> v2 (robh):
> - Minor review comment clean-ups from Steven
> - Use list_is_singular helper
> - Just WARN if we add a mapping when madvise state is not WILLNEED.
>   With that, drop the use of object_name_lock.
> 
> Fixes: a5efb4c9a562 ("drm/panfrost: Restructure the GEM object creation")
> Fixes: 7282f7645d06 ("drm/panfrost: Implement per FD address spaces")
> Cc: 
> Signed-off-by: Boris Brezillon 
> Signed-off-by: Rob Herring 
> ---
> I've hacked up IGT prime_self_import test to run on panfrost other than 
> the 2 test which depend on i915 debugfs files (export-vs-gem_close-race, 
> reimport-vs-gem_close-race). With this patch, they now pass.
> 
> I'm not adding the test to IGT which is just a copy-n-paste of the 
> original except for different wrappers for BO alloc and mmap. That 
> should be fixed first IMO.
> 
> Rob
> 
>  drivers/gpu/drm/panfrost/panfrost_drv.c   |  91 +++--
>  drivers/gpu/drm/panfrost/panfrost_gem.c   | 123 +++---
>  drivers/gpu/drm/panfrost/panfrost_gem.h   |  41 +-
>  .../gpu/drm/panfrost/panfrost_gem_shrinker.c  |   3 +-
>  drivers/gpu/drm/panfrost/panfrost_job.c   |  13 +-
>  drivers/gpu/drm/panfrost/panfrost_job.h   |   1 +
>  drivers/gpu/drm/panfrost/panfrost_mmu.c   |  61 +
>  drivers/gpu/drm/panfrost/panfrost_mmu.h   |   6 +-
>  drivers/gpu/drm/panfrost/panfrost_perfcnt.c   |  34 +++--
>  9 files changed, 299 insertions(+), 74 deletions(-)
> 



> diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c 
> b/drivers/gpu/drm/panfrost/panfrost_gem.c
> index fd766b1395fb..3a7862e3e775 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_gem.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
> @@ -29,6 +29,12 @@ static void panfrost_gem_free_object(struct drm_gem_object 
> *obj)
>   list_del_init(>base.madv_list);
>   mutex_unlock(>shrinker_lock);
>  
> + /*
> +  * If we still have mappings attached to the BO, there's a problem in
> +  * our refcounting.
> +  */
> + WARN_ON_ONCE(!list_empty(>mappings.list));
> +
>   if (bo->sgts) {
>   int i;
>   int n_sgt = bo->base.base.size / SZ_2M;
> @@ -46,6 +52,68 @@ static void panfrost_gem_free_object(struct drm_gem_object 
> *obj)
>   drm_gem_shmem_free_object(obj);
>  }
>  
> +struct panfrost_gem_mapping *
> +panfrost_gem_mapping_get(struct panfrost_gem_object *bo,
> +  struct panfrost_file_priv *priv)
> +{
> + struct panfrost_gem_mapping *iter;
> +
> + mutex_lock(>mappings.lock);
> + list_for_each_entry(iter, >mappings.list, node) {
> + if (iter->mmu == >mmu) {
> + kref_get(>refcount);
> + break;
> + }
> + }
> + mutex_unlock(>mappings.lock);
> +
> + return iter;

If the entry isn't found then iter will equal
container_of(>mappings.list, struct panfrost_gem_mapping, node) -
but you actually want a NULL return in this case.

I also think the previous version with a "member" variable being
returned was clearer.

Thanks,

Steve
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 1/4] drm: add pgprot callback to drm_gem_object_funcs

2019-12-11 Thread Daniel Vetter
On Wed, Dec 11, 2019 at 01:19:53PM +0100, Gerd Hoffmann wrote:
> The callback allows drivers and helpers to tweak pgprot for mappings.
> This is especially helpful when using shmem helpers.  It allows drivers
> to switch mappings from writecombine (default) to something else (cached
> for example) on a per-object base without having to supply their own
> mmap() and vmap() functions.
> 
> The patch also adds two implementations for the callback, for cached and
> writecombine mappings, and the drm_gem_pgprot() function to update
> pgprot for a given object, using the new _gem_object_funcs.pgprot
> callback if available.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/drm/drm_gem.h | 15 +
>  drivers/gpu/drm/drm_gem.c | 46 ++-
>  2 files changed, 60 insertions(+), 1 deletion(-)
> 
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 0b375069cd48..5beef7226e69 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -163,6 +163,17 @@ struct drm_gem_object_funcs {
>*/
>   int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
>  
> + /**
> +  * @pgprot:
> +  *
> +  * Tweak pgprot as needed, typically used to set cache bits.
> +  *
> +  * This callback is optional.
> +  *
> +  * If unset drm_gem_pgprot_wc() will be used.
> +  */
> + pgprot_t (*pgprot)(struct drm_gem_object *obj, pgprot_t prot);

I kinda prefer v1, mostly because this is a huge can of worms, and solving
this properly is going to be real hard (and will necessarily involve
dma-buf and dma-api and probably more). Charging ahead here just risks
that we dig ourselves into a corner. You're v1 is maybe not the most
clean, but just a few code bits here should be more flexible and
easier to hack on and experiment around with.
-Daniel

> +
>   /**
>* @vm_ops:
>*
> @@ -350,6 +361,10 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, 
> unsigned long obj_size,
>struct vm_area_struct *vma);
>  int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
>  
> +pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot);
> +pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot);
> +pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot);
> +
>  /**
>   * drm_gem_object_get - acquire a GEM buffer object reference
>   * @obj: GEM buffer object
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 56f42e0f2584..1c468fe8e342 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -1119,7 +1119,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, 
> unsigned long obj_size,
>   return -EINVAL;
>  
>   vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | 
> VM_DONTDUMP;
> - vma->vm_page_prot = 
> pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
> + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> + vma->vm_page_prot = drm_gem_pgprot(obj, vma->vm_page_prot);
>   vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>   }
>  
> @@ -1210,6 +1211,49 @@ int drm_gem_mmap(struct file *filp, struct 
> vm_area_struct *vma)
>  }
>  EXPORT_SYMBOL(drm_gem_mmap);
>  
> +/**
> + * drm_gem_mmap - update pgprot for objects needing a cachable mapping.
> + * @obj: the GEM object.
> + * @prot: page attributes.
> + *
> + * This function can be used as _gem_object_funcs.pgprot callback.
> + */
> +pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot)
> +{
> + return prot;
> +}
> +EXPORT_SYMBOL(drm_gem_pgprot_cached);
> +
> +/**
> + * drm_gem_mmap - update pgprot for objects needing a wc mapping.
> + * @obj: the GEM object.
> + * @prot: page attributes.
> + *
> + * This function can be used as _gem_object_funcs.pgprot callback.
> + */
> +pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot)
> +{
> + return pgprot_writecombine(prot);
> +}
> +EXPORT_SYMBOL(drm_gem_pgprot_wc);
> +
> +/**
> + * drm_gem_mmap - update pgprot for a given gem object.
> + * @obj: the GEM object.
> + * @prot: page attributes.
> + *
> + * This function updates pgprot according to the needs of the given
> + * object.  If present _gem_object_funcs.pgprot callback will be
> + * used, otherwise drm_gem_pgprot_wc() is called.
> + */
> +pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot)
> +{
> + if (obj->funcs->pgprot)
> + return obj->funcs->pgprot(obj, prot);
> + return drm_gem_pgprot_wc(obj, prot);
> +}
> +EXPORT_SYMBOL(drm_gem_pgprot);
> +
>  void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
>   const struct drm_gem_object *obj)
>  {
> -- 
> 2.18.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org

Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Daniel Vetter
On Wed, Dec 11, 2019 at 11:07:25AM +0100, Thomas Zimmermann wrote:
> 
> 
> Am 11.12.19 um 10:58 schrieb Thomas Zimmermann:
> > Hi Gerd
> > 
> > Am 11.12.19 um 09:18 schrieb Gerd Hoffmann:
> >> Add caching field to drm_gem_shmem_object to specify the cachine
> >> attributes for mappings.  Add helper function to tweak pgprot
> >> accordingly.  Switch vmap and mmap functions to the new helper.
> >>
> >> Set caching to write-combine when creating the object so behavior
> >> doesn't change by default.  Drivers can override that later if
> >> needed.
> >>
> >> Signed-off-by: Gerd Hoffmann 
> > 
> > If you want to merge this patch, you have my
> > 
> > Reviewed-by: Thomas Zimmermann 
> > 
> > Please see my comment below.
> > 
> >> ---
> >>  include/drm/drm_gem_shmem_helper.h | 12 
> >>  drivers/gpu/drm/drm_gem_shmem_helper.c | 24 +---
> >>  2 files changed, 33 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/drm/drm_gem_shmem_helper.h 
> >> b/include/drm/drm_gem_shmem_helper.h
> >> index 6748379a0b44..9d6e02c6205f 100644
> >> --- a/include/drm/drm_gem_shmem_helper.h
> >> +++ b/include/drm/drm_gem_shmem_helper.h
> >> @@ -17,6 +17,11 @@ struct drm_mode_create_dumb;
> >>  struct drm_printer;
> >>  struct sg_table;
> >>  
> >> +enum drm_gem_shmem_caching {
> >> +  DRM_GEM_SHMEM_CACHED = 1,
> >> +  DRM_GEM_SHMEM_WC,
> >> +};
> >> +
> >>  /**
> >>   * struct drm_gem_shmem_object - GEM object backed by shmem
> >>   */
> >> @@ -83,6 +88,11 @@ struct drm_gem_shmem_object {
> >> * The address are un-mapped when the count reaches zero.
> >> */
> >>unsigned int vmap_use_count;
> >> +
> >> +  /**
> >> +   * @caching: caching attributes for mappings.
> >> +   */
> >> +  enum drm_gem_shmem_caching caching;
> >>  };
> >>  
> >>  #define to_drm_gem_shmem_obj(obj) \
> >> @@ -130,6 +140,8 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
> >> *dev,
> >>  
> >>  struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj);
> >>  
> >> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, 
> >> pgprot_t prot);
> >> +
> >>  /**
> >>   * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
> >>   *
> >> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c 
> >> b/drivers/gpu/drm/drm_gem_shmem_helper.c
> >> index a421a2eed48a..5bb94e130a50 100644
> >> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> >> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> >> @@ -76,6 +76,7 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct 
> >> drm_device *dev, size_t
> >>mutex_init(>pages_lock);
> >>mutex_init(>vmap_lock);
> >>INIT_LIST_HEAD(>madv_list);
> >> +  shmem->caching = DRM_GEM_SHMEM_WC;
> >>  
> >>/*
> >> * Our buffers are kept pinned, so allocating them
> >> @@ -256,9 +257,11 @@ static void *drm_gem_shmem_vmap_locked(struct 
> >> drm_gem_shmem_object *shmem)
> >>  
> >>if (obj->import_attach)
> >>shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
> >> -  else
> >> +  else {
> >> +  pgprot_t prot = drm_gem_shmem_caching(shmem, PAGE_KERNEL);
> >>shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
> >> -  VM_MAP, pgprot_writecombine(PAGE_KERNEL));
> >> +  VM_MAP, prot);
> >> +  }
> >>  
> >>if (!shmem->vaddr) {
> >>DRM_DEBUG_KMS("Failed to vmap pages\n");
> >> @@ -540,7 +543,8 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, 
> >> struct vm_area_struct *vma)
> >>}
> >>  
> >>vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
> >> -  vma->vm_page_prot = 
> >> pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
> >> +  vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> >> +  vma->vm_page_prot = drm_gem_shmem_caching(shmem, vma->vm_page_prot);
> >>vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
> >>vma->vm_ops = _gem_shmem_vm_ops;
> >>  
> >> @@ -683,3 +687,17 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
> >> *dev,
> >>return ERR_PTR(ret);
> >>  }
> >>  EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table);
> >> +
> >> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, 
> >> pgprot_t prot)
> >> +{
> >> +  switch (shmem->caching) {
> >> +  case DRM_GEM_SHMEM_CACHED:
> >> +  return prot;
> >> +  case DRM_GEM_SHMEM_WC:
> >> +  return pgprot_writecombine(prot);
> >> +  default:
> >> +  WARN_ON_ONCE(1);
> >> +  return prot;
> >> +  }
> >> +}
> >> +EXPORT_SYMBOL_GPL(drm_gem_shmem_caching);
> > 
> > Two reason why I'd reconsider this design.
> > 
> > I don't like switch statements new the bottom of the call graph. The
> > code ends up with default warnings, such as this one.
> > 
> > Udl has different caching flags for imported and 'native' buffers. This
> > would require a new constant and additional code here.
> > 
> > What do you think about turning this function into a callback in struct
> > shmem_funcs? The default 

[PATCH v3 1/4] drm: add pgprot callback to drm_gem_object_funcs

2019-12-11 Thread Gerd Hoffmann
The callback allows drivers and helpers to tweak pgprot for mappings.
This is especially helpful when using shmem helpers.  It allows drivers
to switch mappings from writecombine (default) to something else (cached
for example) on a per-object base without having to supply their own
mmap() and vmap() functions.

The patch also adds two implementations for the callback, for cached and
writecombine mappings, and the drm_gem_pgprot() function to update
pgprot for a given object, using the new _gem_object_funcs.pgprot
callback if available.

Signed-off-by: Gerd Hoffmann 
---
 include/drm/drm_gem.h | 15 +
 drivers/gpu/drm/drm_gem.c | 46 ++-
 2 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 0b375069cd48..5beef7226e69 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -163,6 +163,17 @@ struct drm_gem_object_funcs {
 */
int (*mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
 
+   /**
+* @pgprot:
+*
+* Tweak pgprot as needed, typically used to set cache bits.
+*
+* This callback is optional.
+*
+* If unset drm_gem_pgprot_wc() will be used.
+*/
+   pgprot_t (*pgprot)(struct drm_gem_object *obj, pgprot_t prot);
+
/**
 * @vm_ops:
 *
@@ -350,6 +361,10 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned 
long obj_size,
 struct vm_area_struct *vma);
 int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma);
 
+pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot);
+pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot);
+pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot);
+
 /**
  * drm_gem_object_get - acquire a GEM buffer object reference
  * @obj: GEM buffer object
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 56f42e0f2584..1c468fe8e342 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1119,7 +1119,8 @@ int drm_gem_mmap_obj(struct drm_gem_object *obj, unsigned 
long obj_size,
return -EINVAL;
 
vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | 
VM_DONTDUMP;
-   vma->vm_page_prot = 
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+   vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+   vma->vm_page_prot = drm_gem_pgprot(obj, vma->vm_page_prot);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
}
 
@@ -1210,6 +1211,49 @@ int drm_gem_mmap(struct file *filp, struct 
vm_area_struct *vma)
 }
 EXPORT_SYMBOL(drm_gem_mmap);
 
+/**
+ * drm_gem_mmap - update pgprot for objects needing a cachable mapping.
+ * @obj: the GEM object.
+ * @prot: page attributes.
+ *
+ * This function can be used as _gem_object_funcs.pgprot callback.
+ */
+pgprot_t drm_gem_pgprot_cached(struct drm_gem_object *obj, pgprot_t prot)
+{
+   return prot;
+}
+EXPORT_SYMBOL(drm_gem_pgprot_cached);
+
+/**
+ * drm_gem_mmap - update pgprot for objects needing a wc mapping.
+ * @obj: the GEM object.
+ * @prot: page attributes.
+ *
+ * This function can be used as _gem_object_funcs.pgprot callback.
+ */
+pgprot_t drm_gem_pgprot_wc(struct drm_gem_object *obj, pgprot_t prot)
+{
+   return pgprot_writecombine(prot);
+}
+EXPORT_SYMBOL(drm_gem_pgprot_wc);
+
+/**
+ * drm_gem_mmap - update pgprot for a given gem object.
+ * @obj: the GEM object.
+ * @prot: page attributes.
+ *
+ * This function updates pgprot according to the needs of the given
+ * object.  If present _gem_object_funcs.pgprot callback will be
+ * used, otherwise drm_gem_pgprot_wc() is called.
+ */
+pgprot_t drm_gem_pgprot(struct drm_gem_object *obj, pgprot_t prot)
+{
+   if (obj->funcs->pgprot)
+   return obj->funcs->pgprot(obj, prot);
+   return drm_gem_pgprot_wc(obj, prot);
+}
+EXPORT_SYMBOL(drm_gem_pgprot);
+
 void drm_gem_print_info(struct drm_printer *p, unsigned int indent,
const struct drm_gem_object *obj)
 {
-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 2/4] drm/shmem: add support for per object caching flags.

2019-12-11 Thread Gerd Hoffmann
Use drm_gem_pgprot_wc() as pgprot callback in drm_gem_shmem_funcs.
Use drm_gem_pgprot() to update pgprot caching flags.

Signed-off-by: Gerd Hoffmann 
---
 drivers/gpu/drm/drm_gem_shmem_helper.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c 
b/drivers/gpu/drm/drm_gem_shmem_helper.c
index a421a2eed48a..2a662ed77115 100644
--- a/drivers/gpu/drm/drm_gem_shmem_helper.c
+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
@@ -33,6 +33,7 @@ static const struct drm_gem_object_funcs drm_gem_shmem_funcs 
= {
.vmap = drm_gem_shmem_vmap,
.vunmap = drm_gem_shmem_vunmap,
.mmap = drm_gem_shmem_mmap,
+   .pgprot = drm_gem_pgprot_wc,
 };
 
 /**
@@ -258,7 +259,7 @@ static void *drm_gem_shmem_vmap_locked(struct 
drm_gem_shmem_object *shmem)
shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
else
shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
-   VM_MAP, pgprot_writecombine(PAGE_KERNEL));
+   VM_MAP, drm_gem_pgprot(obj, PAGE_KERNEL));
 
if (!shmem->vaddr) {
DRM_DEBUG_KMS("Failed to vmap pages\n");
@@ -540,7 +541,8 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct 
vm_area_struct *vma)
}
 
vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
-   vma->vm_page_prot = 
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
+   vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+   vma->vm_page_prot = drm_gem_pgprot(obj, vma->vm_page_prot);
vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
vma->vm_ops = _gem_shmem_vm_ops;
 
-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 3/4] drm/virtio: fix mmap page attributes

2019-12-11 Thread Gerd Hoffmann
virtio-gpu uses cached mappings, set virtio_gpu_gem_funcs.pgprot
accordingly.

Reported-by: Gurchetan Singh 
Signed-off-by: Gerd Hoffmann 
---
 drivers/gpu/drm/virtio/virtgpu_object.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c 
b/drivers/gpu/drm/virtio/virtgpu_object.c
index 017a9e0fc3bb..0b754c5bbcce 100644
--- a/drivers/gpu/drm/virtio/virtgpu_object.c
+++ b/drivers/gpu/drm/virtio/virtgpu_object.c
@@ -87,6 +87,7 @@ static const struct drm_gem_object_funcs virtio_gpu_gem_funcs 
= {
.vmap = drm_gem_shmem_vmap,
.vunmap = drm_gem_shmem_vunmap,
.mmap = _gem_shmem_mmap,
+   .pgprot = _gem_pgprot_cached,
 };
 
 struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev,
-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 0/4] drm/virtio: fix mmap page attributes

2019-12-11 Thread Gerd Hoffmann
v3: switch to drm_gem_object_funcs callback.
v2: make shmem helper caching configurable.

Gerd Hoffmann (4):
  drm: add pgprot callback to drm_gem_object_funcs
  drm/shmem: add support for per object caching flags.
  drm/virtio: fix mmap page attributes
  drm/udl: simplify gem object mapping.

 include/drm/drm_gem.h   | 15 ++
 drivers/gpu/drm/drm_gem.c   | 46 +-
 drivers/gpu/drm/drm_gem_shmem_helper.c  |  6 ++-
 drivers/gpu/drm/udl/udl_gem.c   | 62 +++--
 drivers/gpu/drm/virtio/virtgpu_object.c |  1 +
 5 files changed, 72 insertions(+), 58 deletions(-)

-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v3 4/4] drm/udl: simplify gem object mapping.

2019-12-11 Thread Gerd Hoffmann
With shmem helpers allowing to update pgprot caching flags via
drm_gem_object_funcs.pgprot we can just use that and ditch our own
implementations of mmap() and vmap().

Signed-off-by: Gerd Hoffmann 
---
 drivers/gpu/drm/udl/udl_gem.c | 62 ---
 1 file changed, 7 insertions(+), 55 deletions(-)

diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c
index b6e26f98aa0a..b82a4a921f1b 100644
--- a/drivers/gpu/drm/udl/udl_gem.c
+++ b/drivers/gpu/drm/udl/udl_gem.c
@@ -17,61 +17,12 @@
  * GEM object funcs
  */
 
-static int udl_gem_object_mmap(struct drm_gem_object *obj,
-  struct vm_area_struct *vma)
+static pgprot_t udl_gem_object_pgprot(struct drm_gem_object *obj,
+ pgprot_t pgprot)
 {
-   int ret;
-
-   ret = drm_gem_shmem_mmap(obj, vma);
-   if (ret)
-   return ret;
-
-   vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
if (obj->import_attach)
-   vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
-   vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
-
-   return 0;
-}
-
-static void *udl_gem_object_vmap(struct drm_gem_object *obj)
-{
-   struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
-   int ret;
-
-   ret = mutex_lock_interruptible(>vmap_lock);
-   if (ret)
-   return ERR_PTR(ret);
-
-   if (shmem->vmap_use_count++ > 0)
-   goto out;
-
-   ret = drm_gem_shmem_get_pages(shmem);
-   if (ret)
-   goto err_zero_use;
-
-   if (obj->import_attach)
-   shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
-   else
-   shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
-   VM_MAP, PAGE_KERNEL);
-
-   if (!shmem->vaddr) {
-   DRM_DEBUG_KMS("Failed to vmap pages\n");
-   ret = -ENOMEM;
-   goto err_put_pages;
-   }
-
-out:
-   mutex_unlock(>vmap_lock);
-   return shmem->vaddr;
-
-err_put_pages:
-   drm_gem_shmem_put_pages(shmem);
-err_zero_use:
-   shmem->vmap_use_count = 0;
-   mutex_unlock(>vmap_lock);
-   return ERR_PTR(ret);
+   pgprot = pgprot_writecombine(pgprot);
+   return pgprot;
 }
 
 static const struct drm_gem_object_funcs udl_gem_object_funcs = {
@@ -80,9 +31,10 @@ static const struct drm_gem_object_funcs 
udl_gem_object_funcs = {
.pin = drm_gem_shmem_pin,
.unpin = drm_gem_shmem_unpin,
.get_sg_table = drm_gem_shmem_get_sg_table,
-   .vmap = udl_gem_object_vmap,
+   .vmap = drm_gem_shmem_vmap,
.vunmap = drm_gem_shmem_vunmap,
-   .mmap = udl_gem_object_mmap,
+   .mmap = drm_gem_shmem_mmap,
+   .pgprot = udl_gem_object_pgprot,
 };
 
 /*
-- 
2.18.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2] drm: Remove drm_bridge->dev

2019-12-11 Thread Mihail Atanassov
As suggested in [1], the 'dev' field is a bit repetitive, since it 1:1
follows the setting and NULLing of the 'encoder' field. Therefore, use
drm_bridge->encoder->dev in place of drm_bridge->dev.

[1] https://patchwork.freedesktop.org/patch/343824/

v2:
 - fix checkpatch complaint about unnecessary parentheses in
 drm_bridge.c. I've left the other two in since they're in the patch
 context rather than in a touched line.

Cc: Daniel Vetter 
Suggested-by: Thomas Zimmermann 
Acked-by: Thomas Zimmermann 
Signed-off-by: Mihail Atanassov 
---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   |  2 +-
 drivers/gpu/drm/bridge/analogix/analogix-anx6345.c |  2 +-
 drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c |  2 +-
 drivers/gpu/drm/bridge/cdns-dsi.c  |  2 +-
 drivers/gpu/drm/bridge/dumb-vga-dac.c  |  2 +-
 .../gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c   |  2 +-
 drivers/gpu/drm/bridge/nxp-ptn3460.c   |  2 +-
 drivers/gpu/drm/bridge/panel.c |  2 +-
 drivers/gpu/drm/bridge/parade-ps8622.c |  2 +-
 drivers/gpu/drm/bridge/sii902x.c   |  6 +++---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c  |  6 +++---
 drivers/gpu/drm/bridge/tc358764.c  |  4 ++--
 drivers/gpu/drm/bridge/tc358767.c  |  6 +++---
 drivers/gpu/drm/bridge/ti-sn65dsi86.c  |  2 +-
 drivers/gpu/drm/bridge/ti-tfp410.c |  6 +++---
 drivers/gpu/drm/drm_bridge.c   | 10 --
 drivers/gpu/drm/i2c/tda998x_drv.c  |  2 +-
 drivers/gpu/drm/mcde/mcde_dsi.c|  2 +-
 drivers/gpu/drm/msm/edp/edp_bridge.c   |  2 +-
 drivers/gpu/drm/msm/hdmi/hdmi_bridge.c |  4 ++--
 drivers/gpu/drm/rcar-du/rcar_lvds.c|  3 ++-
 include/drm/drm_bridge.h   |  2 --
 22 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 9e13e466e72c..009cf1fef8d4 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -863,7 +863,7 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
adv->connector.polled = DRM_CONNECTOR_POLL_CONNECT |
DRM_CONNECTOR_POLL_DISCONNECT;
 
-   ret = drm_connector_init(bridge->dev, >connector,
+   ret = drm_connector_init(bridge->encoder->dev, >connector,
 _connector_funcs,
 DRM_MODE_CONNECTOR_HDMIA);
if (ret) {
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
index 9917ce0d86a0..5b806d23fcb3 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
@@ -541,7 +541,7 @@ static int anx6345_bridge_attach(struct drm_bridge *bridge)
return err;
}
 
-   err = drm_connector_init(bridge->dev, >connector,
+   err = drm_connector_init(bridge->encoder->dev, >connector,
 _connector_funcs,
 DRM_MODE_CONNECTOR_eDP);
if (err) {
diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
index 41867be03751..7463537950cb 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
@@ -908,7 +908,7 @@ static int anx78xx_bridge_attach(struct drm_bridge *bridge)
return err;
}
 
-   err = drm_connector_init(bridge->dev, >connector,
+   err = drm_connector_init(bridge->encoder->dev, >connector,
 _connector_funcs,
 DRM_MODE_CONNECTOR_DisplayPort);
if (err) {
diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c 
b/drivers/gpu/drm/bridge/cdns-dsi.c
index 3a5bd4e7fd1e..32863e3ad537 100644
--- a/drivers/gpu/drm/bridge/cdns-dsi.c
+++ b/drivers/gpu/drm/bridge/cdns-dsi.c
@@ -651,7 +651,7 @@ static int cdns_dsi_bridge_attach(struct drm_bridge *bridge)
struct cdns_dsi *dsi = input_to_dsi(input);
struct cdns_dsi_output *output = >output;
 
-   if (!drm_core_check_feature(bridge->dev, DRIVER_ATOMIC)) {
+   if (!drm_core_check_feature(bridge->encoder->dev, DRIVER_ATOMIC)) {
dev_err(dsi->base.dev,
"cdns-dsi driver is only compatible with DRM devices 
supporting atomic updates");
return -ENOTSUPP;
diff --git a/drivers/gpu/drm/bridge/dumb-vga-dac.c 
b/drivers/gpu/drm/bridge/dumb-vga-dac.c
index cc33dc411b9e..67ad6cecf68d 100644
--- a/drivers/gpu/drm/bridge/dumb-vga-dac.c
+++ b/drivers/gpu/drm/bridge/dumb-vga-dac.c
@@ -112,7 +112,7 

[PATCH] drm/gma500: globle no more!

2019-12-11 Thread Daniel Vetter
globle, goblin, moblin?

It's dead code, we lucked out.

Cc: Ville Syrjälä 
Cc: Jani Nikula 
Signed-off-by: Daniel Vetter 
---
 drivers/gpu/drm/gma500/mdfld_intel_display.c | 23 
 1 file changed, 23 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mdfld_intel_display.c 
b/drivers/gpu/drm/gma500/mdfld_intel_display.c
index b8bfb96008b8..4fff110c4921 100644
--- a/drivers/gpu/drm/gma500/mdfld_intel_display.c
+++ b/drivers/gpu/drm/gma500/mdfld_intel_display.c
@@ -113,27 +113,6 @@ static int psb_intel_panel_fitter_pipe(struct drm_device 
*dev)
return (pfit_control >> 29) & 0x3;
 }
 
-static struct drm_device globle_dev;
-
-void mdfld__intel_plane_set_alpha(int enable)
-{
-   struct drm_device *dev = _dev;
-   int dspcntr_reg = DSPACNTR;
-   u32 dspcntr;
-
-   dspcntr = REG_READ(dspcntr_reg);
-
-   if (enable) {
-   dspcntr &= ~DISPPLANE_32BPP_NO_ALPHA;
-   dspcntr |= DISPPLANE_32BPP;
-   } else {
-   dspcntr &= ~DISPPLANE_32BPP;
-   dspcntr |= DISPPLANE_32BPP_NO_ALPHA;
-   }
-
-   REG_WRITE(dspcntr_reg, dspcntr);
-}
-
 static int check_fb(struct drm_framebuffer *fb)
 {
if (!fb)
@@ -164,8 +143,6 @@ static int mdfld__intel_pipe_set_base(struct drm_crtc 
*crtc, int x, int y,
u32 dspcntr;
int ret;
 
-   memcpy(_dev, dev, sizeof(struct drm_device));
-
dev_dbg(dev->dev, "pipe = 0x%x.\n", pipe);
 
/* no fb bound */
-- 
2.24.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH RFC 4/8] drm/sprd: add Unisoc's drm display controller driver

2019-12-11 Thread Emil Velikov
On Wed, 11 Dec 2019 at 09:18, tang pengchuan  wrote:
>
> Hi
>
> Emil Velikov  于2019年12月11日周三 上午1:14写道:
>>
>> Hi Kevin,
>>
>> On Tue, 10 Dec 2019 at 08:41, Kevin Tang  wrote:
>> >
>> > From: Kevin Tang 
>> >
>> > Adds DPU(Display Processor Unit) support for the Unisoc's display 
>> > subsystem.
>> > It's support multi planes, scaler, rotation, PQ(Picture Quality) and more.
>> >
>> > Cc: Orson Zhai 
>> > Cc: Baolin Wang 
>> > Cc: Chunyan Zhang 
>> > Signed-off-by: Kevin Tang 
>> > ---
>> >  drivers/gpu/drm/sprd/Makefile   |6 +-
>> >  drivers/gpu/drm/sprd/disp_lib.c |  290 +++
>> >  drivers/gpu/drm/sprd/disp_lib.h |   40 +
>> >  drivers/gpu/drm/sprd/dpu/Makefile   |8 +
>> >  drivers/gpu/drm/sprd/dpu/dpu_r2p0.c | 1464 
>> > +++
>> >  drivers/gpu/drm/sprd/sprd_dpu.c | 1152 +++
>> >  drivers/gpu/drm/sprd/sprd_dpu.h |  217 ++
>> >  7 files changed, 3176 insertions(+), 1 deletion(-)
>>
>> As we can see from the diff stat this patch is huge. So it would be fairly 
>> hard
>> to provide meaningful review as-is.
>>
>> One can combine my earlier suggestion (to keep modeset/atomic out of 2/8), 
>> with
>> the following split:
>>  - 4/8 add basic atomic modeset support - one format, one rotation 0, no 
>> extra
>>  attributes
>>  - 5/8 add extra formats
>>  - 6/8 add extra rotation support
>>  - ... add custom attributes
>
> Ok, i will split this patch, upstream modeset and atomic at first. clock, 
> gloabl, enhance, extra
> attributes  and so on will be upload later.

Amazing thank you. Please apply the similar logic and split patch 6/8
- that patch is twice larger than this one.

Some small general requests - please use plain text emails (see [1])
and trim unrelated fragments when replying.
Otherwise it is very easy to miss the comment that you and others have made.

HTH
Emil

[1] 
https://www.lifewire.com/how-to-send-a-message-in-plain-text-from-gmail-1171963
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v9 23/25] mm/gup: track FOLL_PIN pages

2019-12-11 Thread Jan Kara
On Tue 10-12-19 18:53:16, John Hubbard wrote:
> Add tracking of pages that were pinned via FOLL_PIN.
> 
> As mentioned in the FOLL_PIN documentation, callers who effectively set
> FOLL_PIN are required to ultimately free such pages via unpin_user_page().
> The effect is similar to FOLL_GET, and may be thought of as "FOLL_GET
> for DIO and/or RDMA use".
> 
> Pages that have been pinned via FOLL_PIN are identifiable via a
> new function call:
> 
>bool page_dma_pinned(struct page *page);
> 
> What to do in response to encountering such a page, is left to later
> patchsets. There is discussion about this in [1], [2], and [3].
> 
> This also changes a BUG_ON(), to a WARN_ON(), in follow_page_mask().
> 
> [1] Some slow progress on get_user_pages() (Apr 2, 2019):
> https://lwn.net/Articles/784574/
> [2] DMA and get_user_pages() (LPC: Dec 12, 2018):
> https://lwn.net/Articles/774411/
> [3] The trouble with get_user_pages() (Apr 30, 2018):
> https://lwn.net/Articles/753027/

The patch looks mostly good to me now. Just a few smaller comments below.

> Suggested-by: Jan Kara 
> Suggested-by: Jérôme Glisse 
> Reviewed-by: Jan Kara 
> Reviewed-by: Jérôme Glisse 
> Reviewed-by: Ira Weiny 

I think you inherited here the Reviewed-by tags from the "add flags" patch
you've merged into this one but that's not really fair since this patch
does much more... In particular I didn't give my Reviewed-by tag for this
patch yet.

> +/*
> + * try_grab_compound_head() - attempt to elevate a page's refcount, by a
> + * flags-dependent amount.
> + *
> + * This has a default assumption of "use FOLL_GET behavior, if FOLL_PIN is 
> not
> + * set".
> + *
> + * "grab" names in this file mean, "look at flags to decide whether to use
> + * FOLL_PIN or FOLL_GET behavior, when incrementing the page's refcount.
> + */
> +static __maybe_unused struct page *try_grab_compound_head(struct page *page,
> +   int refs,
> +   unsigned int flags)
> +{
> + if (flags & FOLL_PIN)
> + return try_pin_compound_head(page, refs);
> +
> + return try_get_compound_head(page, refs);
> +}

I somewhat wonder about the asymmetry of try_grab_compound_head() vs
try_grab_page() in the treatment of 'flags'. How costly would it be to make
them symmetric (i.e., either set FOLL_GET for try_grab_compound_head()
callers or make sure one of FOLL_GET, FOLL_PIN is set for try_grab_page())?

Because this difference looks like a subtle catch in the long run...

> +
> +/**
> + * try_grab_page() - elevate a page's refcount by a flag-dependent amount
> + *
> + * This might not do anything at all, depending on the flags argument.
> + *
> + * "grab" names in this file mean, "look at flags to decide whether to use
> + * FOLL_PIN or FOLL_GET behavior, when incrementing the page's refcount.
> + *
> + * @page:pointer to page to be grabbed
> + * @flags:   gup flags: these are the FOLL_* flag values.
> + *
> + * Either FOLL_PIN or FOLL_GET (or neither) may be set, but not both at the 
> same
> + * time. (That's true throughout the get_user_pages*() and pin_user_pages*()
> + * APIs.) Cases:
> + *
> + *   FOLL_GET: page's refcount will be incremented by 1.
> + *  FOLL_PIN: page's refcount will be incremented by 
> GUP_PIN_COUNTING_BIAS.
> + *
> + * Return: true for success, or if no action was required (if neither 
> FOLL_PIN
> + * nor FOLL_GET was set, nothing is done). False for failure: FOLL_GET or
> + * FOLL_PIN was set, but the page could not be grabbed.
> + */
> +bool __must_check try_grab_page(struct page *page, unsigned int flags)
> +{
> + if (flags & FOLL_GET)
> + return try_get_page(page);
> + else if (flags & FOLL_PIN) {
> + page = compound_head(page);
> + WARN_ON_ONCE(flags & FOLL_GET);
> +
> + if (WARN_ON_ONCE(page_ref_zero_or_close_to_bias_overflow(page)))
> + return false;
> +
> + page_ref_add(page, GUP_PIN_COUNTING_BIAS);
> + __update_proc_vmstat(page, NR_FOLL_PIN_REQUESTED, 1);
> + }
> +
> + return true;
> +}

...

> @@ -1522,8 +1536,8 @@ struct page *follow_trans_huge_pmd(struct 
> vm_area_struct *vma,
>  skip_mlock:
>   page += (addr & ~HPAGE_PMD_MASK) >> PAGE_SHIFT;
>   VM_BUG_ON_PAGE(!PageCompound(page) && !is_zone_device_page(page), page);
> - if (flags & FOLL_GET)
> - get_page(page);
> + if (!try_grab_page(page, flags))
> + page = ERR_PTR(-EFAULT);

I think you need to also move the try_grab_page() earlier in the function.
At this point the page may be marked as mlocked and you'd need to undo that
in case try_grab_page() fails.

> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index ac65bb5e38ac..0aab6fe0072f 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4356,7 +4356,13 @@ long follow_hugetlb_page(struct mm_struct *mm, struct 
> vm_area_struct *vma,
>  same_page:
> 

Re: [PATCH v3 12/12] auxdisplay: constify fb ops

2019-12-11 Thread Jani Nikula
On Tue, 10 Dec 2019, Miguel Ojeda  wrote:
> On Mon, Dec 9, 2019 at 3:04 PM Jani Nikula  wrote:
>>
>> On Tue, 03 Dec 2019, Jani Nikula  wrote:
>> > Now that the fbops member of struct fb_info is const, we can start
>> > making the ops const as well.
>> >
>> > Cc: Miguel Ojeda Sandonis 
>> > Cc: Robin van der Gracht 
>> > Reviewed-by: Daniel Vetter 
>> > Reviewed-by: Miguel Ojeda 
>> > Acked-by: Robin van der Gracht 
>> > Signed-off-by: Jani Nikula 
>>
>> Miguel, Robin, just to err on the safe side, were you both okay with me
>> merging this through drm-misc? Not very likely to conflict badly.
>
> I think that is fine, go ahead! :)

Thanks, pushed to drm-misc-next!

BR,
Jani.

-- 
Jani Nikula, Intel Open Source Graphics Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [v3,3/4] drm/edid: Throw away the dummy VIC 0 cea mode

2019-12-11 Thread Ville Syrjälä
On Tue, Dec 10, 2019 at 03:18:54PM -0800, Tom Anderson wrote:
> On Wed, Sep 25, 2019 at 04:55:01PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä 
> > 
> > Now that the cea mode handling is not 100% tied to the single
> > array the dummy VIC 0 mode is pretty much pointles. Throw it
> > out.
> > 
> > Cc: Hans Verkuil 
> > Cc: Shashank Sharma 
> > Signed-off-by: Ville Syrjälä 
> > ---
> >  drivers/gpu/drm/drm_edid.c | 14 +-
> >  1 file changed, 5 insertions(+), 9 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 9f6996323efa..0007004d3221 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -709,11 +709,9 @@ static const struct minimode extra_modes[] = {
> >  /*
> >   * From CEA/CTA-861 spec.
> >   *
> > - * Index with VIC.
> > + * Index with VIC-1.
> 
> Since we shouldn't be indexing into this array directly any more, this comment
> should instead be changed to say which functions should be used.

Seems reasonable.

> 
> >   */
> > -static const struct drm_display_mode edid_cea_modes_0[] = {
> > -   /* 0 - dummy, VICs start at 1 */
> > -   { },
> > +static const struct drm_display_mode edid_cea_modes_1[] = {
> > /* 1 - 640x480@60Hz 4:3 */
> > { DRM_MODE("640x480", DRM_MODE_TYPE_DRIVER, 25175, 640, 656,
> >752, 800, 0, 480, 490, 492, 525, 0,
> > @@ -3211,10 +3209,8 @@ static u8 *drm_find_cea_extension(const struct edid 
> > *edid)
> >  
> >  static const struct drm_display_mode *cea_mode_for_vic(u8 vic)
> >  {
> > -   if (!vic)
> > -   return NULL;
> > -   if (vic < ARRAY_SIZE(edid_cea_modes_0))
> > -   return _cea_modes_0[vic];
> > +   if (vic >= 1 && vic < 1 + ARRAY_SIZE(edid_cea_modes_1))
> > +   return _cea_modes_1[vic - 1];
> > if (vic >= 193 && vic < 193 + ARRAY_SIZE(edid_cea_modes_193))
> > return _cea_modes_193[vic - 193];
> > return NULL;
> > @@ -3227,7 +3223,7 @@ static u8 cea_num_vics(void)
> >  
> >  static u8 cea_next_vic(u8 vic)
> >  {
> > -   if (++vic == ARRAY_SIZE(edid_cea_modes_0))
> > +   if (++vic == 1 + ARRAY_SIZE(edid_cea_modes_1))
> > vic = 193;
> > return vic;
> >  }

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm: remove drm_bridge->dev

2019-12-11 Thread Mihail Atanassov
Hi,

On Wednesday, 11 December 2019 07:38:29 GMT Thomas Zimmermann wrote:
> Hi
> 
> Am 10.12.19 um 16:11 schrieb Mihail Atanassov:
> > As suggested in [1], the 'dev' field is a bit repetitive, since it 1:1
> > follows the setting and NULLing of the 'encoder' field. Therefore, use
> > drm_bridge->encoder->dev in place of drm_bridge->dev.
> > 
> > [1] https://patchwork.freedesktop.org/patch/343824/
> > 
> > Cc: Daniel Vetter 
> > Suggested-by: Thomas Zimmermann 
> > Signed-off-by: Mihail Atanassov 
> 
> Do you need help with merging the patch?

I've push rights to drm-misc-next, I'll handle it Soon(tm)/today. Thanks for
the offer, though :).

> 
> Best regards
> Thomas
> 
> > ---
> >  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   |  2 +-
> >  drivers/gpu/drm/bridge/analogix/analogix-anx6345.c |  2 +-
> >  drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c |  2 +-
> >  drivers/gpu/drm/bridge/cdns-dsi.c  |  2 +-
> >  drivers/gpu/drm/bridge/dumb-vga-dac.c  |  2 +-
> >  .../gpu/drm/bridge/megachips-stdp-ge-b850v3-fw.c   |  2 +-
> >  drivers/gpu/drm/bridge/nxp-ptn3460.c   |  2 +-
> >  drivers/gpu/drm/bridge/panel.c |  2 +-
> >  drivers/gpu/drm/bridge/parade-ps8622.c |  2 +-
> >  drivers/gpu/drm/bridge/sii902x.c   |  6 +++---
> >  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c  |  6 +++---
> >  drivers/gpu/drm/bridge/tc358764.c  |  4 ++--
> >  drivers/gpu/drm/bridge/tc358767.c  |  6 +++---
> >  drivers/gpu/drm/bridge/ti-sn65dsi86.c  |  2 +-
> >  drivers/gpu/drm/bridge/ti-tfp410.c |  6 +++---
> >  drivers/gpu/drm/drm_bridge.c   | 10 --
> >  drivers/gpu/drm/i2c/tda998x_drv.c  |  2 +-
> >  drivers/gpu/drm/mcde/mcde_dsi.c|  2 +-
> >  drivers/gpu/drm/msm/edp/edp_bridge.c   |  2 +-
> >  drivers/gpu/drm/msm/hdmi/hdmi_bridge.c |  4 ++--
> >  drivers/gpu/drm/rcar-du/rcar_lvds.c|  3 ++-
> >  include/drm/drm_bridge.h   |  2 --
> >  22 files changed, 35 insertions(+), 38 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
> > b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > index 9e13e466e72c..009cf1fef8d4 100644
> > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
> > @@ -863,7 +863,7 @@ static int adv7511_bridge_attach(struct drm_bridge 
> > *bridge)
> > adv->connector.polled = DRM_CONNECTOR_POLL_CONNECT |
> > DRM_CONNECTOR_POLL_DISCONNECT;
> >  
> > -   ret = drm_connector_init(bridge->dev, >connector,
> > +   ret = drm_connector_init(bridge->encoder->dev, >connector,
> >  _connector_funcs,
> >  DRM_MODE_CONNECTOR_HDMIA);
> > if (ret) {
> > diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c 
> > b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > index 9917ce0d86a0..5b806d23fcb3 100644
> > --- a/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx6345.c
> > @@ -541,7 +541,7 @@ static int anx6345_bridge_attach(struct drm_bridge 
> > *bridge)
> > return err;
> > }
> >  
> > -   err = drm_connector_init(bridge->dev, >connector,
> > +   err = drm_connector_init(bridge->encoder->dev, >connector,
> >  _connector_funcs,
> >  DRM_MODE_CONNECTOR_eDP);
> > if (err) {
> > diff --git a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c 
> > b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> > index 41867be03751..7463537950cb 100644
> > --- a/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> > +++ b/drivers/gpu/drm/bridge/analogix/analogix-anx78xx.c
> > @@ -908,7 +908,7 @@ static int anx78xx_bridge_attach(struct drm_bridge 
> > *bridge)
> > return err;
> > }
> >  
> > -   err = drm_connector_init(bridge->dev, >connector,
> > +   err = drm_connector_init(bridge->encoder->dev, >connector,
> >  _connector_funcs,
> >  DRM_MODE_CONNECTOR_DisplayPort);
> > if (err) {
> > diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c 
> > b/drivers/gpu/drm/bridge/cdns-dsi.c
> > index 3a5bd4e7fd1e..32863e3ad537 100644
> > --- a/drivers/gpu/drm/bridge/cdns-dsi.c
> > +++ b/drivers/gpu/drm/bridge/cdns-dsi.c
> > @@ -651,7 +651,7 @@ static int cdns_dsi_bridge_attach(struct drm_bridge 
> > *bridge)
> > struct cdns_dsi *dsi = input_to_dsi(input);
> > struct cdns_dsi_output *output = >output;
> >  
> > -   if (!drm_core_check_feature(bridge->dev, DRIVER_ATOMIC)) {
> > +   if (!drm_core_check_feature(bridge->encoder->dev, DRIVER_ATOMIC)) {
> > dev_err(dsi->base.dev,
> >

Re: [PATCH v3 04/50] drm/bridge: Add connector-related bridge operations and data

2019-12-11 Thread Mihail Atanassov
Hi Laurent,

On Tuesday, 10 December 2019 22:57:04 GMT Laurent Pinchart wrote:
> To support implementation of DRM connectors on top of DRM bridges
> instead of by bridges, the drm_bridge needs to expose new operations and
> data:
> 
> - Output detection, hot-plug notification, mode retrieval and EDID
>   retrieval operations
> - Bitmask of supported operations
> - Bridge output type
> - I2C adapter for DDC access
> 
> Add and document these.
> 
> Three new bridge helper functions are also added to handle hot plug
> notification in a way that is as transparent as possible for the
> bridges.
> 
> Signed-off-by: Laurent Pinchart 
> Reviewed-by: Boris Brezillon 
> ---
> Changes since v2:
> 
> - Add wrappers around the .detect(), .get_modes() and .get_edid()
>   operations
> - Warn bridge drivers about valid usage of the connector argument to
>   .get_modes() and .get_edid()
> 
> Changes since v1:
> 
> - Make .hpd_enable() and .hpd_disable() optional
> - Rename .lost_hotplug() to .hpd_notify()
> - Add ddc field to drm_bridge
> ---
>  drivers/gpu/drm/drm_bridge.c | 162 +
>  include/drm/drm_bridge.h | 193 ++-
>  2 files changed, 354 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
> index c2cf0c90fa26..473353bd762f 100644
> --- a/drivers/gpu/drm/drm_bridge.c
> +++ b/drivers/gpu/drm/drm_bridge.c
> @@ -70,6 +70,8 @@ static LIST_HEAD(bridge_list);
>   */
>  void drm_bridge_add(struct drm_bridge *bridge)
>  {
> + mutex_init(>hpd_mutex);
> +
>   mutex_lock(_lock);
>   list_add_tail(>list, _list);
>   mutex_unlock(_lock);
> @@ -86,6 +88,8 @@ void drm_bridge_remove(struct drm_bridge *bridge)
>   mutex_lock(_lock);
>   list_del_init(>list);
>   mutex_unlock(_lock);
> +
> + mutex_destroy(>hpd_mutex);
>  }
>  EXPORT_SYMBOL(drm_bridge_remove);
>  
> @@ -516,6 +520,164 @@ void drm_atomic_bridge_chain_enable(struct drm_bridge 
> *bridge,
>  }
>  EXPORT_SYMBOL(drm_atomic_bridge_chain_enable);
>  
> +/**
> + * drm_bridge_detect - check if anything is attached to the bridge output
> + * @bridge: bridge control structure
> + *
> + * If the bridge supports output detection, as reported by the
> + * DRM_BRIDGE_OP_DETECT bridge ops flag, call _bridge_funcs.detect for 
> the
> + * bridge and return the connection status. Otherwise return
> + * connector_status_unknown.
> + *
> + * RETURNS:
> + * The detection status on success, or connector_status_unknown if the bridge
> + * doesn't support output detection.
> + */
> +enum drm_connector_status drm_bridge_detect(struct drm_bridge *bridge)
> +{
> + if (!(bridge->ops & DRM_BRIDGE_OP_DETECT))
> + return connector_status_unknown;
> +
> + return bridge->funcs->detect(bridge);
> +}
> +EXPORT_SYMBOL_GPL(drm_bridge_detect);
> +
> +/**
> + * drm_bridge_get_modes - fill all modes currently valid for the sink into 
> the
> + * @connector
> + * @bridge: bridge control structure
> + * @connector: the connector to fill with modes
> + *
> + * If the bridge supports output modes retrieval, as reported by the
> + * DRM_BRIDGE_OP_MODES bridge ops flag, call _bridge_funcs.get_modes to
> + * fill the connector with all valid modes and return the number of modes
> + * added. Otherwise return 0.
> + *
> + * RETURNS:
> + * The number of modes added to the connector.
> + */
> +int drm_bridge_get_modes(struct drm_bridge *bridge,
> +  struct drm_connector *connector)
> +{
> + if (!(bridge->ops & DRM_BRIDGE_OP_MODES))
> + return 0;
> +
> + return bridge->funcs->get_modes(bridge, connector);
> +}
> +EXPORT_SYMBOL_GPL(drm_bridge_get_modes);
> +
> +/**
> + * drm_bridge_get_edid - get the EDID data of the connected display
> + * @bridge: bridge control structure
> + * @connector: the connector to read EDID for
> + *
> + * If the bridge supports output EDID retrieval, as reported by the
> + * DRM_BRIDGE_OP_EDID bridge ops flag, call _bridge_funcs.get_edid to
> + * get the EDID and return it. Otherwise return ERR_PTR(-ENOTSUPP).
> + *
> + * RETURNS:
> + * The retrieved EDID on success, or an error pointer otherwise.
> + */
> +struct edid *drm_bridge_get_edid(struct drm_bridge *bridge,
> +  struct drm_connector *connector)
> +{
> + if (!(bridge->ops & DRM_BRIDGE_OP_EDID))
> + return ERR_PTR(-ENOTSUPP);
> +
> + return bridge->funcs->get_edid(bridge, connector);
> +}
> +EXPORT_SYMBOL_GPL(drm_bridge_get_edid);
> +
> +/**
> + * drm_bridge_hpd_enable - enable hot plug detection for the bridge
> + * @bridge: bridge control structure
> + * @cb: hot-plug detection callback
> + * @data: data to be passed to the hot-plug detection callback
> + *
> + * Call _bridge_funcs.hpd_enable if implemented and register the given 
> @cb
> + * and @data as hot plug notification callback. From now on the @cb will be
> + * called with @data when an output status change is detected by 

Re: [PATCH v9 20/25] powerpc: book3s64: convert to pin_user_pages() and put_user_page()

2019-12-11 Thread Jan Kara
On Tue 10-12-19 18:53:13, John Hubbard wrote:
> 1. Convert from get_user_pages() to pin_user_pages().
> 
> 2. As required by pin_user_pages(), release these pages via
> put_user_page().
> 
> Cc: Jan Kara 
> Signed-off-by: John Hubbard 

The patch looks good to me. You can add:

Reviewed-by: Jan Kara 

I'd just note that mm_iommu_do_alloc() has a pre-existing bug that the last
jump to 'free_exit' (at line 157) happens already after converting page
pointers to physical addresses so put_page() calls there will just crash.
But that's completely unrelated to your change. I'll send a fix separately.

Honza

> ---
>  arch/powerpc/mm/book3s64/iommu_api.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/powerpc/mm/book3s64/iommu_api.c 
> b/arch/powerpc/mm/book3s64/iommu_api.c
> index 56cc84520577..a86547822034 100644
> --- a/arch/powerpc/mm/book3s64/iommu_api.c
> +++ b/arch/powerpc/mm/book3s64/iommu_api.c
> @@ -103,7 +103,7 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, 
> unsigned long ua,
>   for (entry = 0; entry < entries; entry += chunk) {
>   unsigned long n = min(entries - entry, chunk);
>  
> - ret = get_user_pages(ua + (entry << PAGE_SHIFT), n,
> + ret = pin_user_pages(ua + (entry << PAGE_SHIFT), n,
>   FOLL_WRITE | FOLL_LONGTERM,
>   mem->hpages + entry, NULL);
>   if (ret == n) {
> @@ -167,9 +167,8 @@ static long mm_iommu_do_alloc(struct mm_struct *mm, 
> unsigned long ua,
>   return 0;
>  
>  free_exit:
> - /* free the reference taken */
> - for (i = 0; i < pinned; i++)
> - put_page(mem->hpages[i]);
> + /* free the references taken */
> + put_user_pages(mem->hpages, pinned);
>  
>   vfree(mem->hpas);
>   kfree(mem);
> @@ -215,7 +214,8 @@ static void mm_iommu_unpin(struct 
> mm_iommu_table_group_mem_t *mem)
>   if (mem->hpas[i] & MM_IOMMU_TABLE_GROUP_PAGE_DIRTY)
>   SetPageDirty(page);
>  
> - put_page(page);
> + put_user_page(page);
> +
>   mem->hpas[i] = 0;
>   }
>  }
> -- 
> 2.24.0
> 
-- 
Jan Kara 
SUSE Labs, CR
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/vmwgfx: prevent memory leak in vmw_context_define

2019-12-11 Thread Thomas Hellstrom
On 9/25/19 6:46 AM, Navid Emamdoost wrote:
> In vmw_context_define if vmw_context_init fails the allocated resource
> should be unreferenced. The goto label was fixed.
>
> Signed-off-by: Navid Emamdoost 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> index a56c9d802382..ac42f8a6acf0 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
> @@ -773,7 +773,7 @@ static int vmw_context_define(struct drm_device *dev, 
> void *data,
>  
>   ret = vmw_context_init(dev_priv, res, vmw_user_context_free, dx);
>   if (unlikely(ret != 0))
> - goto out_unlock;
> + goto out_err;
>  
>   tmp = vmw_resource_reference(>res);
>   ret = ttm_base_object_init(tfile, >base, false, VMW_RES_CONTEXT,

This patch doesn't look correct. vmw_context_init should free up all
resources if failing.

Thanks,

Thomas


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/vmwgfx: prevent memory leak in vmw_cmdbuf_res_add

2019-12-11 Thread Thomas Hellstrom
On 9/25/19 6:38 AM, Navid Emamdoost wrote:
> In vmw_cmdbuf_res_add if drm_ht_insert_item fails the allocated memory
> for cres should be released.
>
> Signed-off-by: Navid Emamdoost 
> ---
>  drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c 
> b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> index 4ac55fc2bf97..44d858ce4ce7 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c
> @@ -209,8 +209,10 @@ int vmw_cmdbuf_res_add(struct vmw_cmdbuf_res_manager 
> *man,
>  
>   cres->hash.key = user_key | (res_type << 24);
>   ret = drm_ht_insert_item(>resources, >hash);
> - if (unlikely(ret != 0))
> + if (unlikely(ret != 0)) {
> + kfree(cres);
>   goto out_invalid_key;
> + }
>  
>   cres->state = VMW_CMDBUF_RES_ADD;
>   cres->res = vmw_resource_reference(res);

Reviewed-by: Thomas Hellstrom 

Will be part of next vmwgfx-next pull.

Thanks,

Thomas


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Thomas Zimmermann


Am 11.12.19 um 10:58 schrieb Thomas Zimmermann:
> Hi Gerd
> 
> Am 11.12.19 um 09:18 schrieb Gerd Hoffmann:
>> Add caching field to drm_gem_shmem_object to specify the cachine
>> attributes for mappings.  Add helper function to tweak pgprot
>> accordingly.  Switch vmap and mmap functions to the new helper.
>>
>> Set caching to write-combine when creating the object so behavior
>> doesn't change by default.  Drivers can override that later if
>> needed.
>>
>> Signed-off-by: Gerd Hoffmann 
> 
> If you want to merge this patch, you have my
> 
> Reviewed-by: Thomas Zimmermann 
> 
> Please see my comment below.
> 
>> ---
>>  include/drm/drm_gem_shmem_helper.h | 12 
>>  drivers/gpu/drm/drm_gem_shmem_helper.c | 24 +---
>>  2 files changed, 33 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/drm/drm_gem_shmem_helper.h 
>> b/include/drm/drm_gem_shmem_helper.h
>> index 6748379a0b44..9d6e02c6205f 100644
>> --- a/include/drm/drm_gem_shmem_helper.h
>> +++ b/include/drm/drm_gem_shmem_helper.h
>> @@ -17,6 +17,11 @@ struct drm_mode_create_dumb;
>>  struct drm_printer;
>>  struct sg_table;
>>  
>> +enum drm_gem_shmem_caching {
>> +DRM_GEM_SHMEM_CACHED = 1,
>> +DRM_GEM_SHMEM_WC,
>> +};
>> +
>>  /**
>>   * struct drm_gem_shmem_object - GEM object backed by shmem
>>   */
>> @@ -83,6 +88,11 @@ struct drm_gem_shmem_object {
>>   * The address are un-mapped when the count reaches zero.
>>   */
>>  unsigned int vmap_use_count;
>> +
>> +/**
>> + * @caching: caching attributes for mappings.
>> + */
>> +enum drm_gem_shmem_caching caching;
>>  };
>>  
>>  #define to_drm_gem_shmem_obj(obj) \
>> @@ -130,6 +140,8 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
>> *dev,
>>  
>>  struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj);
>>  
>> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, pgprot_t 
>> prot);
>> +
>>  /**
>>   * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
>>   *
>> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c 
>> b/drivers/gpu/drm/drm_gem_shmem_helper.c
>> index a421a2eed48a..5bb94e130a50 100644
>> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
>> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
>> @@ -76,6 +76,7 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct 
>> drm_device *dev, size_t
>>  mutex_init(>pages_lock);
>>  mutex_init(>vmap_lock);
>>  INIT_LIST_HEAD(>madv_list);
>> +shmem->caching = DRM_GEM_SHMEM_WC;
>>  
>>  /*
>>   * Our buffers are kept pinned, so allocating them
>> @@ -256,9 +257,11 @@ static void *drm_gem_shmem_vmap_locked(struct 
>> drm_gem_shmem_object *shmem)
>>  
>>  if (obj->import_attach)
>>  shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
>> -else
>> +else {
>> +pgprot_t prot = drm_gem_shmem_caching(shmem, PAGE_KERNEL);
>>  shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
>> -VM_MAP, pgprot_writecombine(PAGE_KERNEL));
>> +VM_MAP, prot);
>> +}
>>  
>>  if (!shmem->vaddr) {
>>  DRM_DEBUG_KMS("Failed to vmap pages\n");
>> @@ -540,7 +543,8 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, 
>> struct vm_area_struct *vma)
>>  }
>>  
>>  vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
>> -vma->vm_page_prot = 
>> pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
>> +vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
>> +vma->vm_page_prot = drm_gem_shmem_caching(shmem, vma->vm_page_prot);
>>  vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>>  vma->vm_ops = _gem_shmem_vm_ops;
>>  
>> @@ -683,3 +687,17 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
>> *dev,
>>  return ERR_PTR(ret);
>>  }
>>  EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table);
>> +
>> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, pgprot_t 
>> prot)
>> +{
>> +switch (shmem->caching) {
>> +case DRM_GEM_SHMEM_CACHED:
>> +return prot;
>> +case DRM_GEM_SHMEM_WC:
>> +return pgprot_writecombine(prot);
>> +default:
>> +WARN_ON_ONCE(1);
>> +return prot;
>> +}
>> +}
>> +EXPORT_SYMBOL_GPL(drm_gem_shmem_caching);
> 
> Two reason why I'd reconsider this design.
> 
> I don't like switch statements new the bottom of the call graph. The
> code ends up with default warnings, such as this one.
> 
> Udl has different caching flags for imported and 'native' buffers. This
> would require a new constant and additional code here.
> 
> What do you think about turning this function into a callback in struct
> shmem_funcs? The default implementation would be for WC, virtio would
> use CACHED. The individual implementations could still be located in the
> shmem code. Udl would later provide its own code.

On a second thought, all this might be over-engineered and v1 of the
patchset was the 

Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Thomas Zimmermann


Am 11.12.19 um 10:58 schrieb Thomas Zimmermann:
> 
> What do you think about turning this function into a callback in struct
> shmem_funcs? The default implementation would be for WC, virtio would

s/shmem_funcs/drm_gem_object_funcs

> use CACHED. The individual implementations could still be located in the
> shmem code. Udl would later provide its own code.
> 
> Best regards
> Thomas
> 
>>
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm/shmem: add support for per object caching attributes

2019-12-11 Thread Thomas Zimmermann
Hi Gerd

Am 11.12.19 um 09:18 schrieb Gerd Hoffmann:
> Add caching field to drm_gem_shmem_object to specify the cachine
> attributes for mappings.  Add helper function to tweak pgprot
> accordingly.  Switch vmap and mmap functions to the new helper.
> 
> Set caching to write-combine when creating the object so behavior
> doesn't change by default.  Drivers can override that later if
> needed.
> 
> Signed-off-by: Gerd Hoffmann 

If you want to merge this patch, you have my

Reviewed-by: Thomas Zimmermann 

Please see my comment below.

> ---
>  include/drm/drm_gem_shmem_helper.h | 12 
>  drivers/gpu/drm/drm_gem_shmem_helper.c | 24 +---
>  2 files changed, 33 insertions(+), 3 deletions(-)
> 
> diff --git a/include/drm/drm_gem_shmem_helper.h 
> b/include/drm/drm_gem_shmem_helper.h
> index 6748379a0b44..9d6e02c6205f 100644
> --- a/include/drm/drm_gem_shmem_helper.h
> +++ b/include/drm/drm_gem_shmem_helper.h
> @@ -17,6 +17,11 @@ struct drm_mode_create_dumb;
>  struct drm_printer;
>  struct sg_table;
>  
> +enum drm_gem_shmem_caching {
> + DRM_GEM_SHMEM_CACHED = 1,
> + DRM_GEM_SHMEM_WC,
> +};
> +
>  /**
>   * struct drm_gem_shmem_object - GEM object backed by shmem
>   */
> @@ -83,6 +88,11 @@ struct drm_gem_shmem_object {
>* The address are un-mapped when the count reaches zero.
>*/
>   unsigned int vmap_use_count;
> +
> + /**
> +  * @caching: caching attributes for mappings.
> +  */
> + enum drm_gem_shmem_caching caching;
>  };
>  
>  #define to_drm_gem_shmem_obj(obj) \
> @@ -130,6 +140,8 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
> *dev,
>  
>  struct sg_table *drm_gem_shmem_get_pages_sgt(struct drm_gem_object *obj);
>  
> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, pgprot_t 
> prot);
> +
>  /**
>   * DRM_GEM_SHMEM_DRIVER_OPS - Default shmem GEM operations
>   *
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c 
> b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index a421a2eed48a..5bb94e130a50 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -76,6 +76,7 @@ struct drm_gem_shmem_object *drm_gem_shmem_create(struct 
> drm_device *dev, size_t
>   mutex_init(>pages_lock);
>   mutex_init(>vmap_lock);
>   INIT_LIST_HEAD(>madv_list);
> + shmem->caching = DRM_GEM_SHMEM_WC;
>  
>   /*
>* Our buffers are kept pinned, so allocating them
> @@ -256,9 +257,11 @@ static void *drm_gem_shmem_vmap_locked(struct 
> drm_gem_shmem_object *shmem)
>  
>   if (obj->import_attach)
>   shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf);
> - else
> + else {
> + pgprot_t prot = drm_gem_shmem_caching(shmem, PAGE_KERNEL);
>   shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT,
> - VM_MAP, pgprot_writecombine(PAGE_KERNEL));
> + VM_MAP, prot);
> + }
>  
>   if (!shmem->vaddr) {
>   DRM_DEBUG_KMS("Failed to vmap pages\n");
> @@ -540,7 +543,8 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj, struct 
> vm_area_struct *vma)
>   }
>  
>   vma->vm_flags |= VM_MIXEDMAP | VM_DONTEXPAND;
> - vma->vm_page_prot = 
> pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
> + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
> + vma->vm_page_prot = drm_gem_shmem_caching(shmem, vma->vm_page_prot);
>   vma->vm_page_prot = pgprot_decrypted(vma->vm_page_prot);
>   vma->vm_ops = _gem_shmem_vm_ops;
>  
> @@ -683,3 +687,17 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device 
> *dev,
>   return ERR_PTR(ret);
>  }
>  EXPORT_SYMBOL_GPL(drm_gem_shmem_prime_import_sg_table);
> +
> +pgprot_t drm_gem_shmem_caching(struct drm_gem_shmem_object *shmem, pgprot_t 
> prot)
> +{
> + switch (shmem->caching) {
> + case DRM_GEM_SHMEM_CACHED:
> + return prot;
> + case DRM_GEM_SHMEM_WC:
> + return pgprot_writecombine(prot);
> + default:
> + WARN_ON_ONCE(1);
> + return prot;
> + }
> +}
> +EXPORT_SYMBOL_GPL(drm_gem_shmem_caching);

Two reason why I'd reconsider this design.

I don't like switch statements new the bottom of the call graph. The
code ends up with default warnings, such as this one.

Udl has different caching flags for imported and 'native' buffers. This
would require a new constant and additional code here.

What do you think about turning this function into a callback in struct
shmem_funcs? The default implementation would be for WC, virtio would
use CACHED. The individual implementations could still be located in the
shmem code. Udl would later provide its own code.

Best regards
Thomas

> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer



signature.asc
Description: OpenPGP digital 

[PATCH v2] video: hdmi: indicate applicability in avi infoframe log

2019-12-11 Thread Johan Korsnes
When logging the AVI InfoFrame, clearly indicate whether or not
attributes are active/"in effect". The specification is given in
CTA-861-G Section 6.4: Format of Version 2, 3 & 4 AVI InfoFrames.

Attribute BytesRequirement
Ext. Colorimetry  EC0..EC2 Colorimetry (C0,C1) set to Extended.
IT Contents Type  CN0,CN1  IT Content (ITC) set to True.
RGB Quant. Range  Q0,Q1Color Space (Y0..Y2) set to RGB.
YCC Quant. Range  YQ0,YQ1  Color space (Y0..Y2) set to YCbCr.

Example log output with patch applied:
HDMI infoframe: Auxiliary Video Information (AVI), version 2, length 13
colorspace: RGB
scan mode: No Data
colorimetry: ITU709
picture aspect: 16:9
active aspect: Same as Picture
itc: IT Content
extended colorimetry: N/A (0x0)
quantization range: Full
nups: Unknown Non-uniform Scaling
video code: 16
ycc quantization range: N/A (0x0)
hdmi content type: Graphics
pixel repeat: 0
bar top 0, bottom 0, left 0, right 0

Signed-off-by: Johan Korsnes 
Cc: Hans Verkuil 
Cc: Martin Bugge 

---
v1 -> v2:
 * Indicate applicability not only for ext. colorimetry
---
 drivers/video/hdmi.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c
index 9c82e2a0a411..491a77b28a9b 100644
--- a/drivers/video/hdmi.c
+++ b/drivers/video/hdmi.c
@@ -1209,16 +1209,40 @@ static void hdmi_avi_infoframe_log(const char *level,
hdmi_log("active aspect: %s\n",
hdmi_active_aspect_get_name(frame->active_aspect));
hdmi_log("itc: %s\n", frame->itc ? "IT Content" : "No Data");
-   hdmi_log("extended colorimetry: %s\n",
-   
hdmi_extended_colorimetry_get_name(frame->extended_colorimetry));
-   hdmi_log("quantization range: %s\n",
-   
hdmi_quantization_range_get_name(frame->quantization_range));
+
+   if (frame->colorimetry == HDMI_COLORIMETRY_EXTENDED)
+   hdmi_log("extended colorimetry: %s\n",
+
hdmi_extended_colorimetry_get_name(frame->extended_colorimetry));
+   else
+   hdmi_log("extended colorimetry: N/A (0x%x)\n",
+frame->extended_colorimetry);
+
+   if (frame->colorspace == HDMI_COLORSPACE_RGB)
+   hdmi_log("quantization range: %s\n",
+
hdmi_quantization_range_get_name(frame->quantization_range));
+   else
+   hdmi_log("quantization range: N/A (0x%x)\n",
+frame->quantization_range);
+
hdmi_log("nups: %s\n", hdmi_nups_get_name(frame->nups));
hdmi_log("video code: %u\n", frame->video_code);
-   hdmi_log("ycc quantization range: %s\n",
-   
hdmi_ycc_quantization_range_get_name(frame->ycc_quantization_range));
-   hdmi_log("hdmi content type: %s\n",
-   hdmi_content_type_get_name(frame->content_type));
+
+   if (frame->colorspace == HDMI_COLORSPACE_YUV422 ||
+   frame->colorspace == HDMI_COLORSPACE_YUV444 ||
+   frame->colorspace == HDMI_COLORSPACE_YUV420)
+   hdmi_log("ycc quantization range: %s\n",
+
hdmi_ycc_quantization_range_get_name(frame->ycc_quantization_range));
+   else
+   hdmi_log("ycc quantization range: N/A (0x%x)\n",
+frame->ycc_quantization_range);
+
+   if (frame->itc)
+   hdmi_log("hdmi content type: %s\n",
+hdmi_content_type_get_name(frame->content_type));
+   else
+   hdmi_log("hdmi content type: N/A (0x%x)\n",
+frame->content_type);
+
hdmi_log("pixel repeat: %u\n", frame->pixel_repeat);
hdmi_log("bar top %u, bottom %u, left %u, right %u\n",
frame->top_bar, frame->bottom_bar,
-- 
2.23.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: linux-next: build failure after merge of the drm-intel tree

2019-12-11 Thread Jani Nikula
On Tue, 10 Dec 2019, Stephen Rothwell  wrote:
> Hi all,
>
> [Just adding Dave Airlie to the cc list]
>
> On Tue, 10 Dec 2019 09:39:57 +1100 Stephen Rothwell  
> wrote:
>>
>> After merging the drm-intel tree, today's linux-next build (x86_64
>> allmodconfig) failed like this:

FYI, I've now backmerged drm-next and thus v5.5-rc1 to
drm-intel-next-queued, resolving the conflict.

BR,
Jani.


>> 
>> In file included from include/linux/spinlock_types.h:18,
>>  from include/linux/mutex.h:16,
>>  from include/linux/kernfs.h:12,
>>  from include/linux/sysfs.h:16,
>>  from include/linux/kobject.h:20,
>>  from include/linux/of.h:17,
>>  from include/linux/irqdomain.h:35,
>>  from include/linux/acpi.h:13,
>>  from drivers/gpu/drm/i915/i915_drv.c:30:
>> drivers/gpu/drm/i915/gem/i915_gem_object.h: In function 
>> 'i915_gem_object_pin_pages':
>> include/linux/lockdep.h:635:2: error: too many arguments to function 
>> 'lock_release'
>>   635 |  lock_release(&(lock)->dep_map, 0, _THIS_IP_);  \
>>   |  ^~~~
>> drivers/gpu/drm/i915/gem/i915_gem_object.h:294:2: note: in expansion of 
>> macro 'might_lock_nested'
>>   294 |  might_lock_nested(>mm.lock, I915_MM_GET_PAGES);
>>   |  ^
>> include/linux/lockdep.h:352:13: note: declared here
>>   352 | extern void lock_release(struct lockdep_map *lock, unsigned long ip);
>>   | ^~~~
>> In file included from include/linux/spinlock_types.h:18,
>>  from include/linux/spinlock.h:83,
>>  from include/linux/mmzone.h:8,
>>  from include/linux/gfp.h:6,
>>  from include/linux/slab.h:15,
>>  from drivers/gpu/drm/i915/i915_irq.c:32:
>> drivers/gpu/drm/i915/gem/i915_gem_object.h: In function 
>> 'i915_gem_object_pin_pages':
>> include/linux/lockdep.h:635:2: error: too many arguments to function 
>> 'lock_release'
>>   635 |  lock_release(&(lock)->dep_map, 0, _THIS_IP_);  \
>>   |  ^~~~
>> drivers/gpu/drm/i915/gem/i915_gem_object.h:294:2: note: in expansion of 
>> macro 'might_lock_nested'
>>   294 |  might_lock_nested(>mm.lock, I915_MM_GET_PAGES);
>>   |  ^
>> include/linux/lockdep.h:352:13: note: declared here
>>   352 | extern void lock_release(struct lockdep_map *lock, unsigned long ip);
>>   | ^~~~
>> 
>> Caused by commit
>> 
>>   e692b4021a2e ("lockdep: add might_lock_nested()")
>> 
>> interacting with commit
>> 
>>   5facae4f3549 ("locking/lockdep: Remove unused @nested argument from 
>> lock_release()")
>> 
>> from Linus' tree.
>> 
>> I have applied the following merge fix patch for today:
>> 
>> From: Stephen Rothwell 
>> Date: Tue, 10 Dec 2019 09:37:07 +1100
>> Subject: [PATCH] lockdep: fix up for lock_release API change
>> 
>> ---
>>  include/linux/lockdep.h | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
>> index 5bbfd5866081..664f52c6dd4c 100644
>> --- a/include/linux/lockdep.h
>> +++ b/include/linux/lockdep.h
>> @@ -632,7 +632,7 @@ do { 
>> \
>>  typecheck(struct lockdep_map *, &(lock)->dep_map);  \
>>  lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \
>>   _THIS_IP_);\
>> -lock_release(&(lock)->dep_map, 0, _THIS_IP_);   \
>> +lock_release(&(lock)->dep_map, _THIS_IP_);  \
>>  } while (0)
>>  
>>  #define lockdep_assert_irqs_enabled()   do {
>> \

-- 
Jani Nikula, Intel Open Source Graphics Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 4/5] Revert "drm/atmel-hlcdc: allow selecting a higher pixel-clock than requested"

2019-12-11 Thread Peter Rosin
On 2019-12-10 15:59, claudiu.bez...@microchip.com wrote:
> 
> 
> On 10.12.2019 16:11, Peter Rosin wrote:
>> On 2019-12-10 14:24, Claudiu Beznea wrote:
>>> This reverts commit f6f7ad3234613f6f7f27c25036aaf078de07e9b0.
>>> ("drm/atmel-hlcdc: allow selecting a higher pixel-clock than requested")
>>> because allowing selecting a higher pixel clock may overclock
>>> LCD devices, not all of them being capable of this.
>>
>> Without this patch, there are panels that are *severly* underclocked (on the
>> magnitude of 40MHz instead of 65MHz or something like that, I don't remember
>> the exact figures). 
> 
> With patch that switches by default to 2xsystem clock for pixel clock, if
> using 133MHz system clock (as you specified in the patch I proposed for
> revert here) that would go, without this patch at 53MHz if 65MHz is
> requested. Correct me if I'm wrong.

It might have been 53MHz, whatever it was it was too low for things to work.

>> And they are of course not capable of that. All panels
>> have *some* slack as to what frequencies are supported, and the patch was
>> written under the assumption that the preferred frequency of the panel was
>> requested, which should leave at least a *little* headroom.
> 
> I see, but from my point of view, the upper layers should decide what
> frequency settings should be done on the LCD controller and not let this at
>  the driver's latitude.

Right, but the upper layers do not support negotiating a frequency from
ranges. At least the didn't when the patch was written, and implementing
*that* seemed like a huge undertaking.

>>
>> So, I'm curious as to what panel regressed. Or rather, what pixel-clock it 
>> needs
>> and what it gets with/without the patch?
> 
> I have 2 use cases:
> 1/ system clock = 200MHz and requested pixel clock (mode_rate) ~71MHz. With
> the reverted patch the resulted computed pixel clock would be 80MHz.
> Previously it was at 66MHz

I don't see how that's possible.

[doing some calculation by hand]

Arrgh. *blush*

The code does not do what I intended for it to do.
Can you please try this instead of reverting?

Cheers,
Peter

>From b3e86d55b8d107a5c07e98f879c67f67120c87a6 Mon Sep 17 00:00:00 2001
From: Peter Rosin 
Date: Tue, 10 Dec 2019 18:11:28 +0100
Subject: [PATCH] drm/atmel-hlcdc: prefer a lower pixel-clock than requested

The intention was to only select a higher pixel-clock rate than the
requested, if a slight overclocking would result in a rate significantly
closer to the requested rate than if the conservative lower pixel-clock
rate is selected. The fixed patch has the logic the other way around and
actually prefers the higher frequency. Fix that.

Fixes: f6f7ad323461 ("drm/atmel-hlcdc: allow selecting a higher pixel-clock 
than requested")
Reported-by: Claudiu Beznea 
Signed-off-by: Peter Rosin 
---
 drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c 
b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
index 9e34bce089d0..03691845d37a 100644
--- a/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
+++ b/drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_crtc.c
@@ -120,8 +120,8 @@ static void atmel_hlcdc_crtc_mode_set_nofb(struct drm_crtc 
*c)
int div_low = prate / mode_rate;
 
if (div_low >= 2 &&
-   ((prate / div_low - mode_rate) <
-10 * (mode_rate - prate / div)))
+   (10 * (prate / div_low - mode_rate) <
+(mode_rate - prate / div)))
/*
 * At least 10 times better when using a higher
 * frequency than requested, instead of a lower.
-- 
2.20.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v3 12/12] auxdisplay: constify fb ops

2019-12-11 Thread Miguel Ojeda
On Mon, Dec 9, 2019 at 3:04 PM Jani Nikula  wrote:
>
> On Tue, 03 Dec 2019, Jani Nikula  wrote:
> > Now that the fbops member of struct fb_info is const, we can start
> > making the ops const as well.
> >
> > Cc: Miguel Ojeda Sandonis 
> > Cc: Robin van der Gracht 
> > Reviewed-by: Daniel Vetter 
> > Reviewed-by: Miguel Ojeda 
> > Acked-by: Robin van der Gracht 
> > Signed-off-by: Jani Nikula 
>
> Miguel, Robin, just to err on the safe side, were you both okay with me
> merging this through drm-misc? Not very likely to conflict badly.

I think that is fine, go ahead! :)

Cheers,
Miguel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


  1   2   >