Re: [PATCH] drm/msm/dsi: fix msm_dsi_phy_get_clk_provider return code

2021-04-23 Thread Jonathan Marek

Tested-by: Jonathan Marek 

On 4/11/21 8:01 PM, Dmitry Baryshkov wrote:

msm_dsi_phy_get_clk_provider() always returns two provided clocks, so
return 0 instead of returning incorrect -EINVAL error code.

Fixes: 5d13459650b3 ("drm/msm/dsi: push provided clocks handling into a generic 
code")
Signed-off-by: Dmitry Baryshkov 
---
  drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index f0a2ddf96a4b..ff7f2ec42030 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -843,7 +843,7 @@ int msm_dsi_phy_get_clk_provider(struct msm_dsi_phy *phy,
if (pixel_clk_provider)
*pixel_clk_provider = 
phy->provided_clocks->hws[DSI_PIXEL_PLL_CLK]->clk;
  
-	return -EINVAL;

+   return 0;
  }
  
  void msm_dsi_phy_pll_save_state(struct msm_dsi_phy *phy)



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


[PATCH v2 0/2] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-04-23 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

v2:
 - rebased on DSI PHY reworks
 - reworked getting cphy_mode in dsi_host.c
 - documentation change in separate patch

Jonathan Marek (2):
  drm/msm/dsi: support CPHY mode for 7nm pll/phy
  dt-bindings: display: msm/dsi: add qcom,dsi-phy-cphy-mode option

 .../devicetree/bindings/display/msm/dsi.txt   |   1 +
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 +++-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  47 ++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 147 --
 6 files changed, 186 insertions(+), 48 deletions(-)

-- 
2.26.1

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


[PATCH v2 2/2] dt-bindings: display: msm/dsi: add qcom, dsi-phy-cphy-mode option

2021-04-23 Thread Jonathan Marek
Document qcom,dsi-phy-cphy-mode option, which can be used to control
whether DSI will operate in D-PHY (default) or C-PHY mode.

Signed-off-by: Jonathan Marek 
---
 Documentation/devicetree/bindings/display/msm/dsi.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt 
b/Documentation/devicetree/bindings/display/msm/dsi.txt
index b9a64d3ff184..7ffc86a9816b 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -124,6 +124,7 @@ Required properties:
 Optional properties:
 - qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode PHY
   regulator is wanted.
+- qcom,dsi-phy-cphy-mode: Boolean value indicating if CPHY mode is wanted.
 - qcom,mdss-mdp-transfer-time-us:  Specifies the dsi transfer time for 
command mode
panels in microseconds. Driver uses 
this number to adjust
the clock rate according to the 
expected transfer time.
-- 
2.26.1

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


[PATCH v2 1/2] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-04-23 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 -
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  47 +++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 147 +++---
 5 files changed, 185 insertions(+), 48 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.xml.h 
b/drivers/gpu/drm/msm/dsi/dsi.xml.h
index 50eb4d1b8fdd..5087a65d3e11 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.xml.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.xml.h
@@ -621,6 +621,8 @@ static inline uint32_t DSI_VERSION_MAJOR(uint32_t val)
return ((val) << DSI_VERSION_MAJOR__SHIFT) & DSI_VERSION_MAJOR__MASK;
 }
 
+#define REG_DSI_CPHY_MODE_CTRL 0x02d4
+
 #define REG_DSI_PHY_PLL_CTRL_0 0x0200
 #define DSI_PHY_PLL_CTRL_0_ENABLE  0x0001
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 8a10e4343281..ab8a8d408d50 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -27,6 +27,7 @@
 #include "dsi_cfg.h"
 #include "msm_kms.h"
 #include "msm_gem.h"
+#include "phy/dsi_phy.h"
 
 #define DSI_RESET_TOGGLE_DELAY_MS 20
 
@@ -168,6 +169,9 @@ struct msm_dsi_host {
int dlane_swap;
int num_data_lanes;
 
+   /* from phy DT */
+   bool cphy_mode;
+
u32 dma_cmd_ctrl_restore;
 
bool registered;
@@ -511,6 +515,7 @@ int msm_dsi_runtime_resume(struct device *dev)
 
 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
 {
+   u32 byte_intf_rate;
int ret;
 
DBG("Set clk rates: pclk=%d, byteclk=%d",
@@ -530,8 +535,13 @@ int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
}
 
if (msm_host->byte_intf_clk) {
-   ret = clk_set_rate(msm_host->byte_intf_clk,
-  msm_host->byte_clk_rate / 2);
+   /* For CPHY, byte_intf_clk is same as byte_clk */
+   if (msm_host->cphy_mode)
+   byte_intf_rate = msm_host->byte_clk_rate;
+   else
+   byte_intf_rate = msm_host->byte_clk_rate / 2;
+
+   ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate);
if (ret) {
pr_err("%s: Failed to set rate byte intf clk, %d\n",
   __func__, ret);
@@ -711,7 +721,11 @@ static void dsi_calc_pclk(struct msm_dsi_host *msm_host, 
bool is_dual_dsi)
lanes = 1;
}
 
-   do_div(pclk_bpp, (8 * lanes));
+   /* CPHY "byte_clk" is in units of 16 bits */
+   if (msm_host->cphy_mode)
+   do_div(pclk_bpp, (16 * lanes));
+   else
+   do_div(pclk_bpp, (8 * lanes));
 
msm_host->pixel_clk_rate = pclk_rate;
msm_host->byte_clk_rate = pclk_bpp;
@@ -937,6 +951,9 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, 
bool enable,
data |= DSI_CTRL_ENABLE;
 
dsi_write(msm_host, REG_DSI_CTRL, data);
+
+   if (msm_host->cphy_mode)
+   dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0));
 }
 
 static void dsi_timing_setup(struct msm_dsi_host *msm_host, bool is_dual_dsi)
@@ -2230,6 +2247,8 @@ int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
struct clk *byte_clk_provider, *pixel_clk_provider;
int ret;
 
+   msm_host->cphy_mode = src_phy->cphy_mode;
+
ret = msm_dsi_phy_get_clk_provider(src_phy,
&byte_clk_provider, &pixel_clk_provider);
if (ret) {
@@ -2301,7 +2320,14 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host 
*host,
return;
}
 
-   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
+   /* CPHY transmits 16 bits over 7 clock cycles
+* "byte_clk" is in units of 16-bits (see dsi_calc_pclk),
+* so multiply by 7 to get the "bitclk rate"
+*/
+   if (msm_host->cphy_mode)
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 7;
+   else
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
clk_req->escclk_rate = msm_host->esc_clk_rate;
 }
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index ff7f2ec42030..5dd9dc4d81e2 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -461,6 +461,51 @@ int msm_dsi_dphy_timing_calc_v4(struct msm_dsi_dphy_timing 
*timing,
return 0;
 }
 
+int msm_dsi_cphy_ti

[PATCH] drm/msm: fix minor version to indicate MSM_PARAM_SUSPENDS support

2021-04-23 Thread Jonathan Marek
Increase the minor version to indicate that MSM_PARAM_SUSPENDS is supported.

Fixes: 3ab1c5cc3939 ("drm/msm: Add param for userspace to query suspend count")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 7bb34ae95037..a63e969e5efb 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -42,7 +42,7 @@
  * - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count
  */
 #define MSM_VERSION_MAJOR  1
-#define MSM_VERSION_MINOR  6
+#define MSM_VERSION_MINOR  7
 #define MSM_VERSION_PATCHLEVEL 0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.26.1

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


[PATCH 1/5] drm/msm: remove unnecessary mmap logic for cached BOs

2021-04-23 Thread Jonathan Marek
No one knows what this is for anymore, so just remove it.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_gem.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index b199942266a2..09abda42d764 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -207,21 +207,12 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj,
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
 
-   if (msm_obj->flags & MSM_BO_WC) {
+   if (msm_obj->flags & MSM_BO_WC)
vma->vm_page_prot = 
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
-   } else if (msm_obj->flags & MSM_BO_UNCACHED) {
+   else if (msm_obj->flags & MSM_BO_UNCACHED)
vma->vm_page_prot = 
pgprot_noncached(vm_get_page_prot(vma->vm_flags));
-   } else {
-   /*
-* Shunt off cached objs to shmem file so they have their own
-* address_space (so unmap_mapping_range does what we want,
-* in particular in the case of mmap'd dmabufs)
-*/
-   vma->vm_pgoff = 0;
-   vma_set_file(vma, obj->filp);
-
+   else
vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
-   }
 
return 0;
 }
-- 
2.26.1

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


[PATCH 0/5] drm/msm: add MSM_BO_CACHED_COHERENT (and related changes)

2021-04-23 Thread Jonathan Marek
Add support for MSM_BO_CACHED_COHERENT, a coherent version of MSM_BO_CACHED
which is implemented by setting the IOMMU_CACHE flag.

Jonathan Marek (5):
  drm/msm: remove unnecessary mmap logic for cached BOs
  drm/msm: replace MSM_BO_UNCACHED with MSM_BO_WC for internal objects
  drm/msm: use the right pgprot when mapping BOs in the kernel
  drm/msm: add MSM_BO_CACHED_COHERENT
  drm/msm: deprecate MSM_BO_UNCACHED (map as writecombine instead)

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   |  4 +--
 drivers/gpu/drm/msm/adreno/a5xx_power.c |  2 +-
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c   |  4 +--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c   |  2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c |  2 +-
 drivers/gpu/drm/msm/adreno/adreno_device.c  |  1 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.c |  2 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c  |  2 +-
 drivers/gpu/drm/msm/msm_drv.c   |  3 +-
 drivers/gpu/drm/msm/msm_drv.h   |  1 +
 drivers/gpu/drm/msm/msm_gem.c   | 34 ++---
 include/uapi/drm/msm_drm.h  |  7 ++---
 12 files changed, 33 insertions(+), 31 deletions(-)

-- 
2.26.1

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


[PATCH 2/5] drm/msm: replace MSM_BO_UNCACHED with MSM_BO_WC for internal objects

2021-04-23 Thread Jonathan Marek
msm_gem_get_vaddr() currently always maps as writecombine, so use the right
flag instead of relying on broken behavior (things don't actually work if
they are mapped as uncached).

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   | 4 ++--
 drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +-
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c   | 4 ++--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c   | 2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c | 2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +-
 drivers/gpu/drm/msm/dsi/dsi_host.c  | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index ce13d49e615b..eb0f884eaf30 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -902,7 +902,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
if (!a5xx_gpu->shadow_bo) {
a5xx_gpu->shadow = msm_gem_kernel_new(gpu->dev,
sizeof(u32) * gpu->nr_rings,
-   MSM_BO_UNCACHED | MSM_BO_MAP_PRIV,
+   MSM_BO_WC | MSM_BO_MAP_PRIV,
gpu->aspace, &a5xx_gpu->shadow_bo,
&a5xx_gpu->shadow_iova);
 
@@ -1407,7 +1407,7 @@ static int a5xx_crashdumper_init(struct msm_gpu *gpu,
struct a5xx_crashdumper *dumper)
 {
dumper->ptr = msm_gem_kernel_new_locked(gpu->dev,
-   SZ_1M, MSM_BO_UNCACHED, gpu->aspace,
+   SZ_1M, MSM_BO_WC, gpu->aspace,
&dumper->bo, &dumper->iova);
 
if (!IS_ERR(dumper->ptr))
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_power.c 
b/drivers/gpu/drm/msm/adreno/a5xx_power.c
index c35b06b46fcc..cdb165236a88 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_power.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_power.c
@@ -363,7 +363,7 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu)
bosize = (cmds_size + (cmds_size / TYPE4_MAX_PAYLOAD) + 1) << 2;
 
ptr = msm_gem_kernel_new_locked(drm, bosize,
-   MSM_BO_UNCACHED | MSM_BO_GPU_READONLY, gpu->aspace,
+   MSM_BO_WC | MSM_BO_GPU_READONLY, gpu->aspace,
&a5xx_gpu->gpmu_bo, &a5xx_gpu->gpmu_iova);
if (IS_ERR(ptr))
return;
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c 
b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
index 42eaef7ad7c7..ee72510ff8ce 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_preempt.c
@@ -230,7 +230,7 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,
 
ptr = msm_gem_kernel_new(gpu->dev,
A5XX_PREEMPT_RECORD_SIZE + A5XX_PREEMPT_COUNTER_SIZE,
-   MSM_BO_UNCACHED | MSM_BO_MAP_PRIV, gpu->aspace, &bo, &iova);
+   MSM_BO_WC | MSM_BO_MAP_PRIV, gpu->aspace, &bo, &iova);
 
if (IS_ERR(ptr))
return PTR_ERR(ptr);
@@ -238,7 +238,7 @@ static int preempt_init_ring(struct a5xx_gpu *a5xx_gpu,
/* The buffer to store counters needs to be unprivileged */
counters = msm_gem_kernel_new(gpu->dev,
A5XX_PREEMPT_COUNTER_SIZE,
-   MSM_BO_UNCACHED, gpu->aspace, &counters_bo, &counters_iova);
+   MSM_BO_WC, gpu->aspace, &counters_bo, &counters_iova);
if (IS_ERR(counters)) {
msm_gem_kernel_put(bo, gpu->aspace, true);
return PTR_ERR(counters);
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 5214a15db95f..1716984c68a8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -852,7 +852,7 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
if (!a6xx_gpu->shadow_bo) {
a6xx_gpu->shadow = msm_gem_kernel_new_locked(gpu->dev,
sizeof(u32) * gpu->nr_rings,
-   MSM_BO_UNCACHED | MSM_BO_MAP_PRIV,
+   MSM_BO_WC | MSM_BO_MAP_PRIV,
gpu->aspace, &a6xx_gpu->shadow_bo,
&a6xx_gpu->shadow_iova);
 
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
index c1699b4f9a89..21c49c5b4519 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c
@@ -113,7 +113,7 @@ static int a6xx_crashdumper_init(struct msm_gpu *gpu,
struct a6xx_crashdumper *dumper)
 {
dumper->ptr = msm_gem_kernel_new_locked(gpu->dev,
-   SZ_1M, MSM_BO_UNCACHED, gpu->aspace,
+   SZ_1M, MSM_BO_WC, gpu->aspace,
&dumpe

[PATCH 3/5] drm/msm: use the right pgprot when mapping BOs in the kernel

2021-04-23 Thread Jonathan Marek
Use the same logic as the userspace mapping.

This fixes msm_rd with cached BOs.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_gem.c | 19 +++
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 09abda42d764..0f58937be0a9 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -199,6 +199,15 @@ void msm_gem_put_pages(struct drm_gem_object *obj)
/* when we start tracking the pin count, then do something here */
 }
 
+static pgprot_t msm_gem_pgprot(struct msm_gem_object *msm_obj, pgprot_t prot)
+{
+   if (msm_obj->flags & MSM_BO_WC)
+   return pgprot_writecombine(prot);
+   if (msm_obj->flags & MSM_BO_UNCACHED)
+   return pgprot_noncached(prot);
+   return prot;
+}
+
 int msm_gem_mmap_obj(struct drm_gem_object *obj,
struct vm_area_struct *vma)
 {
@@ -206,13 +215,7 @@ int msm_gem_mmap_obj(struct drm_gem_object *obj,
 
vma->vm_flags &= ~VM_PFNMAP;
vma->vm_flags |= VM_MIXEDMAP;
-
-   if (msm_obj->flags & MSM_BO_WC)
-   vma->vm_page_prot = 
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
-   else if (msm_obj->flags & MSM_BO_UNCACHED)
-   vma->vm_page_prot = 
pgprot_noncached(vm_get_page_prot(vma->vm_flags));
-   else
-   vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+   vma->vm_page_prot = msm_gem_pgprot(msm_obj, 
vm_get_page_prot(vma->vm_flags));
 
return 0;
 }
@@ -632,7 +635,7 @@ static void *get_vaddr(struct drm_gem_object *obj, unsigned 
madv)
goto fail;
}
msm_obj->vaddr = vmap(pages, obj->size >> PAGE_SHIFT,
-   VM_MAP, pgprot_writecombine(PAGE_KERNEL));
+   VM_MAP, msm_gem_pgprot(msm_obj, PAGE_KERNEL));
if (msm_obj->vaddr == NULL) {
ret = -ENOMEM;
goto fail;
-- 
2.26.1

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


[PATCH 4/5] drm/msm: add MSM_BO_CACHED_COHERENT

2021-04-23 Thread Jonathan Marek
Add a new cache mode for creating coherent host-cached BOs.

Signed-off-by: Jonathan Marek 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 1 +
 drivers/gpu/drm/msm/msm_drv.c  | 3 ++-
 drivers/gpu/drm/msm/msm_drv.h  | 1 +
 drivers/gpu/drm/msm/msm_gem.c  | 8 
 include/uapi/drm/msm_drm.h | 5 ++---
 5 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 9770fd81c614..155c10ffda6e 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -469,6 +469,7 @@ static int adreno_bind(struct device *dev, struct device 
*master, void *data)
config.rev.minor, config.rev.patchid);
 
priv->is_a2xx = config.rev.core == 2;
+   priv->has_cached_coherent = config.rev.core >= 6;
 
gpu = info->init(drm);
if (IS_ERR(gpu)) {
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index a63e969e5efb..7576a987dccc 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -40,9 +40,10 @@
  * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
  * - 1.6.0 - Syncobj support
  * - 1.7.0 - Add MSM_PARAM_SUSPENDS to access suspend count
+ * - 1.8.0 - Add MSM_BO_CACHED_COHERENT for supported GPUs (a6xx)
  */
 #define MSM_VERSION_MAJOR  1
-#define MSM_VERSION_MINOR  7
+#define MSM_VERSION_MINOR  8
 #define MSM_VERSION_PATCHLEVEL 0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index ea78154c3c24..ffc9092b87b2 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -168,6 +168,7 @@ struct msm_drm_private {
struct msm_file_private *lastctx;
/* gpu is only set on open(), but we need this info earlier */
bool is_a2xx;
+   bool has_cached_coherent;
 
struct drm_fb_helper *fbdev;
 
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 0f58937be0a9..2e92e80009c8 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -433,6 +433,9 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
if (msm_obj->flags & MSM_BO_MAP_PRIV)
prot |= IOMMU_PRIV;
 
+   if (msm_obj->flags & MSM_BO_CACHED_COHERENT)
+   prot |= IOMMU_CACHE;
+
GEM_WARN_ON(!msm_gem_is_locked(obj));
 
if (GEM_WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED))
@@ -1144,6 +1147,7 @@ static int msm_gem_new_impl(struct drm_device *dev,
uint32_t size, uint32_t flags,
struct drm_gem_object **obj)
 {
+   struct msm_drm_private *priv = dev->dev_private;
struct msm_gem_object *msm_obj;
 
switch (flags & MSM_BO_CACHE_MASK) {
@@ -1151,6 +1155,10 @@ static int msm_gem_new_impl(struct drm_device *dev,
case MSM_BO_CACHED:
case MSM_BO_WC:
break;
+   case MSM_BO_CACHED_COHERENT:
+   if (priv->has_cached_coherent)
+   break;
+   /* fallthrough */
default:
DRM_DEV_ERROR(dev->dev, "invalid cache flag: %x\n",
(flags & MSM_BO_CACHE_MASK));
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index 5596d7c37f9e..a92d90a6d96f 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -95,12 +95,11 @@ struct drm_msm_param {
 #define MSM_BO_CACHED0x0001
 #define MSM_BO_WC0x0002
 #define MSM_BO_UNCACHED  0x0004
+#define MSM_BO_CACHED_COHERENT 0x08
 
 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \
   MSM_BO_GPU_READONLY | \
-  MSM_BO_CACHED | \
-  MSM_BO_WC | \
-  MSM_BO_UNCACHED)
+  MSM_BO_CACHE_MASK)
 
 struct drm_msm_gem_new {
__u64 size;   /* in */
-- 
2.26.1

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


[PATCH 5/5] drm/msm: deprecate MSM_BO_UNCACHED (map as writecombine instead)

2021-04-23 Thread Jonathan Marek
There shouldn't be any reason to ever use uncached over writecombine,
so just use writecombine for MSM_BO_UNCACHED.

Note: userspace never used MSM_BO_UNCACHED anyway

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_gem.c | 4 +---
 include/uapi/drm/msm_drm.h| 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 2e92e80009c8..56bca9178253 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -201,10 +201,8 @@ void msm_gem_put_pages(struct drm_gem_object *obj)
 
 static pgprot_t msm_gem_pgprot(struct msm_gem_object *msm_obj, pgprot_t prot)
 {
-   if (msm_obj->flags & MSM_BO_WC)
+   if (msm_obj->flags & (MSM_BO_WC|MSM_BO_UNCACHED))
return pgprot_writecombine(prot);
-   if (msm_obj->flags & MSM_BO_UNCACHED)
-   return pgprot_noncached(prot);
return prot;
 }
 
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index a92d90a6d96f..f075851021c3 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -94,7 +94,7 @@ struct drm_msm_param {
 /* cache modes */
 #define MSM_BO_CACHED0x0001
 #define MSM_BO_WC0x0002
-#define MSM_BO_UNCACHED  0x0004
+#define MSM_BO_UNCACHED  0x0004 /* deprecated, use MSM_BO_WC */
 #define MSM_BO_CACHED_COHERENT 0x08
 
 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \
-- 
2.26.1

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


[PATCH] drm/msm: fix LLC not being enabled for mmu500 targets

2021-04-23 Thread Jonathan Marek
mmu500 targets don't have a "cx_mem" region, set llc_mmio to NULL in that
case to avoid the IS_ERR() condition in a6xx_llc_activate().

Fixes: 3d247123b5a1 ("drm/msm/a6xx: Add support for using system cache on 
MMU500 based targets")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 1716984c68a8..727d111a413f 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1153,10 +1153,6 @@ static void a6xx_llc_slices_init(struct platform_device 
*pdev,
 {
struct device_node *phandle;
 
-   a6xx_gpu->llc_mmio = msm_ioremap(pdev, "cx_mem", "gpu_cx");
-   if (IS_ERR(a6xx_gpu->llc_mmio))
-   return;
-
/*
 * There is a different programming path for targets with an mmu500
 * attached, so detect if that is the case
@@ -1166,6 +1162,11 @@ static void a6xx_llc_slices_init(struct platform_device 
*pdev,
of_device_is_compatible(phandle, "arm,mmu-500"));
of_node_put(phandle);
 
+   if (a6xx_gpu->have_mmu500)
+   a6xx_gpu->llc_mmio = NULL;
+   else
+   a6xx_gpu->llc_mmio = msm_ioremap(pdev, "cx_mem", "gpu_cx");
+
a6xx_gpu->llc_slice = llcc_slice_getd(LLCC_GPU);
a6xx_gpu->htw_llc_slice = llcc_slice_getd(LLCC_GPUHTW);
 
-- 
2.26.1

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


[PATCH] drm/msm: fix a6xx_gmu_clear_oob

2021-02-08 Thread Jonathan Marek
The cleanup patch broke a6xx_gmu_clear_oob, fix it by adding the missing
bitshift operation.

Fixes: 555c50a4a19b ("drm/msm: Clean up GMU OOB set/clear handling")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 71c917f909af..91cf46f84025 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -339,7 +339,7 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum 
a6xx_gmu_oob_state state)
else
bit = a6xx_gmu_oob_bits[state].ack_new;
 
-   gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, bit);
+   gmu_write(gmu, REG_A6XX_GMU_HOST2GMU_INTR_SET, 1 << bit);
 }
 
 /* Enable CPU control of SPTP power power collapse */
-- 
2.26.1

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


[PATCH 0/2] arm64: dts: qcom: sm8250: fix display nodes

2021-02-11 Thread Jonathan Marek
Add sm8150/sm8250 compatibles to drm/msm and fix the sm8250
display nodes.

Jonathan Marek (2):
  drm/msm: add compatibles for sm8150/sm8250 display
  arm64: dts: qcom: sm8250: fix display nodes

 .../devicetree/bindings/display/msm/dpu.txt   |  4 +--
 arch/arm64/boot/dts/qcom/sm8250.dtsi  | 34 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  2 ++
 drivers/gpu/drm/msm/msm_drv.c |  6 ++--
 4 files changed, 16 insertions(+), 30 deletions(-)

-- 
2.26.1

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


[PATCH 1/2] drm/msm: add compatibles for sm8150/sm8250 display

2021-02-11 Thread Jonathan Marek
The driver already has support for sm8150/sm8250, but the compatibles were
never added.

Also inverse the non-mdp4 condition in add_display_components() to avoid
having to check every new compatible in the condition.

Signed-off-by: Jonathan Marek 
---
 Documentation/devicetree/bindings/display/msm/dpu.txt | 4 ++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   | 2 ++
 drivers/gpu/drm/msm/msm_drv.c | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt 
b/Documentation/devicetree/bindings/display/msm/dpu.txt
index 551ae26f60da..5763f43200a0 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -8,7 +8,7 @@ The DPU display controller is found in SDM845 SoC.
 
 MDSS:
 Required properties:
-- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss"
+- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss", "qcom,sm8150-mdss", 
"qcom,sm8250-mdss"
 - reg: physical base address and length of contoller's registers.
 - reg-names: register region names. The following region is required:
   * "mdss"
@@ -41,7 +41,7 @@ Optional properties:
 
 MDP:
 Required properties:
-- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu"
+- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu", "qcom,sm8150-dpu", 
"qcom,sm8250-dpu"
 - reg: physical base address and length of controller's registers.
 - reg-names : register region names. The following region is required:
   * "mdp"
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 5a8e3e1fc48c..fff12a4c8bfc 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1219,6 +1219,8 @@ static const struct dev_pm_ops dpu_pm_ops = {
 static const struct of_device_id dpu_dt_match[] = {
{ .compatible = "qcom,sdm845-dpu", },
{ .compatible = "qcom,sc7180-dpu", },
+   { .compatible = "qcom,sm8150-dpu", },
+   { .compatible = "qcom,sm8250-dpu", },
{}
 };
 MODULE_DEVICE_TABLE(of, dpu_dt_match);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 94525ac76d4e..928f13d4bfbc 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1185,9 +1185,7 @@ static int add_display_components(struct device *dev,
 * Populate the children devices, find the MDP5/DPU node, and then add
 * the interfaces to our components list.
 */
-   if (of_device_is_compatible(dev->of_node, "qcom,mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sdm845-mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sc7180-mdss")) {
+   if (!of_device_is_compatible(dev->of_node, "qcom,mdp4")) {
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
if (ret) {
DRM_DEV_ERROR(dev, "failed to populate children 
devices\n");
@@ -1320,6 +1318,8 @@ static const struct of_device_id dt_match[] = {
{ .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
{ .compatible = "qcom,sdm845-mdss", .data = (void *)KMS_DPU },
{ .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU },
{}
 };
 MODULE_DEVICE_TABLE(of, dt_match);
-- 
2.26.1

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


[PATCH v2 0/2] arm64: dts: qcom: sm8250: fix display nodes

2021-02-15 Thread Jonathan Marek
Add sm8150/sm8250 compatibles to drm/msm and fix the sm8250
display nodes.

v2: do not remove mmcx-supply from dispcc node

Jonathan Marek (2):
  drm/msm: add compatibles for sm8150/sm8250 display
  arm64: dts: qcom: sm8250: fix display nodes

 .../devicetree/bindings/display/msm/dpu.txt   |  4 +--
 arch/arm64/boot/dts/qcom/sm8250.dtsi  | 33 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  2 ++
 drivers/gpu/drm/msm/msm_drv.c |  6 ++--
 4 files changed, 16 insertions(+), 29 deletions(-)

-- 
2.26.1

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


[PATCH v2 1/2] drm/msm: add compatibles for sm8150/sm8250 display

2021-02-15 Thread Jonathan Marek
The driver already has support for sm8150/sm8250, but the compatibles were
never added.

Also inverse the non-mdp4 condition in add_display_components() to avoid
having to check every new compatible in the condition.

Signed-off-by: Jonathan Marek 
---
 Documentation/devicetree/bindings/display/msm/dpu.txt | 4 ++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   | 2 ++
 drivers/gpu/drm/msm/msm_drv.c | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt 
b/Documentation/devicetree/bindings/display/msm/dpu.txt
index 551ae26f60da..5763f43200a0 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -8,7 +8,7 @@ The DPU display controller is found in SDM845 SoC.
 
 MDSS:
 Required properties:
-- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss"
+- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss", "qcom,sm8150-mdss", 
"qcom,sm8250-mdss"
 - reg: physical base address and length of contoller's registers.
 - reg-names: register region names. The following region is required:
   * "mdss"
@@ -41,7 +41,7 @@ Optional properties:
 
 MDP:
 Required properties:
-- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu"
+- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu", "qcom,sm8150-dpu", 
"qcom,sm8250-dpu"
 - reg: physical base address and length of controller's registers.
 - reg-names : register region names. The following region is required:
   * "mdp"
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 5a8e3e1fc48c..fff12a4c8bfc 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1219,6 +1219,8 @@ static const struct dev_pm_ops dpu_pm_ops = {
 static const struct of_device_id dpu_dt_match[] = {
{ .compatible = "qcom,sdm845-dpu", },
{ .compatible = "qcom,sc7180-dpu", },
+   { .compatible = "qcom,sm8150-dpu", },
+   { .compatible = "qcom,sm8250-dpu", },
{}
 };
 MODULE_DEVICE_TABLE(of, dpu_dt_match);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 94525ac76d4e..928f13d4bfbc 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1185,9 +1185,7 @@ static int add_display_components(struct device *dev,
 * Populate the children devices, find the MDP5/DPU node, and then add
 * the interfaces to our components list.
 */
-   if (of_device_is_compatible(dev->of_node, "qcom,mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sdm845-mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sc7180-mdss")) {
+   if (!of_device_is_compatible(dev->of_node, "qcom,mdp4")) {
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
if (ret) {
DRM_DEV_ERROR(dev, "failed to populate children 
devices\n");
@@ -1320,6 +1318,8 @@ static const struct of_device_id dt_match[] = {
{ .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
{ .compatible = "qcom,sdm845-mdss", .data = (void *)KMS_DPU },
{ .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU },
{}
 };
 MODULE_DEVICE_TABLE(of, dt_match);
-- 
2.26.1

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


[PATCH v3 0/2] arm64: dts: qcom: sm8250: fix display nodes

2021-02-15 Thread Jonathan Marek
Add sm8150/sm8250 compatibles to drm/msm and fix the sm8250
display nodes.

v2: do not remove mmcx-supply from dispcc node
v3: remove references to dp_phy (missed this in v2, sorry for the spam)

Jonathan Marek (2):
  drm/msm: add compatibles for sm8150/sm8250 display
  arm64: dts: qcom: sm8250: fix display nodes

 .../devicetree/bindings/display/msm/dpu.txt   |  4 +--
 arch/arm64/boot/dts/qcom/sm8250.dtsi  | 31 +--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   |  2 ++
 drivers/gpu/drm/msm/msm_drv.c |  6 ++--
 4 files changed, 15 insertions(+), 28 deletions(-)

-- 
2.26.1

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


[PATCH v3 1/2] drm/msm: add compatibles for sm8150/sm8250 display

2021-02-15 Thread Jonathan Marek
The driver already has support for sm8150/sm8250, but the compatibles were
never added.

Also inverse the non-mdp4 condition in add_display_components() to avoid
having to check every new compatible in the condition.

Signed-off-by: Jonathan Marek 
---
 Documentation/devicetree/bindings/display/msm/dpu.txt | 4 ++--
 drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   | 2 ++
 drivers/gpu/drm/msm/msm_drv.c | 6 +++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt 
b/Documentation/devicetree/bindings/display/msm/dpu.txt
index 551ae26f60da..5763f43200a0 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -8,7 +8,7 @@ The DPU display controller is found in SDM845 SoC.
 
 MDSS:
 Required properties:
-- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss"
+- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss", "qcom,sm8150-mdss", 
"qcom,sm8250-mdss"
 - reg: physical base address and length of contoller's registers.
 - reg-names: register region names. The following region is required:
   * "mdss"
@@ -41,7 +41,7 @@ Optional properties:
 
 MDP:
 Required properties:
-- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu"
+- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu", "qcom,sm8150-dpu", 
"qcom,sm8250-dpu"
 - reg: physical base address and length of controller's registers.
 - reg-names : register region names. The following region is required:
   * "mdp"
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 5a8e3e1fc48c..fff12a4c8bfc 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1219,6 +1219,8 @@ static const struct dev_pm_ops dpu_pm_ops = {
 static const struct of_device_id dpu_dt_match[] = {
{ .compatible = "qcom,sdm845-dpu", },
{ .compatible = "qcom,sc7180-dpu", },
+   { .compatible = "qcom,sm8150-dpu", },
+   { .compatible = "qcom,sm8250-dpu", },
{}
 };
 MODULE_DEVICE_TABLE(of, dpu_dt_match);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 94525ac76d4e..928f13d4bfbc 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1185,9 +1185,7 @@ static int add_display_components(struct device *dev,
 * Populate the children devices, find the MDP5/DPU node, and then add
 * the interfaces to our components list.
 */
-   if (of_device_is_compatible(dev->of_node, "qcom,mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sdm845-mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sc7180-mdss")) {
+   if (!of_device_is_compatible(dev->of_node, "qcom,mdp4")) {
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
if (ret) {
DRM_DEV_ERROR(dev, "failed to populate children 
devices\n");
@@ -1320,6 +1318,8 @@ static const struct of_device_id dt_match[] = {
{ .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
{ .compatible = "qcom,sdm845-mdss", .data = (void *)KMS_DPU },
{ .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU },
{}
 };
 MODULE_DEVICE_TABLE(of, dt_match);
-- 
2.26.1

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


[PATCH] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-02-15 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 
---
 .../devicetree/bindings/display/msm/dsi.txt   |  1 +
 drivers/gpu/drm/msm/dsi/dsi.c | 12 +--
 drivers/gpu/drm/msm/dsi/dsi.h |  6 +-
 drivers/gpu/drm/msm/dsi/dsi.xml.h |  2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c| 34 +--
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 49 +-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |  3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 89 ++-
 drivers/gpu/drm/msm/dsi/pll/dsi_pll.c |  4 +-
 drivers/gpu/drm/msm/dsi/pll/dsi_pll.h |  5 +-
 drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c | 71 +--
 11 files changed, 210 insertions(+), 66 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt 
b/Documentation/devicetree/bindings/display/msm/dsi.txt
index b9a64d3ff184..7ffc86a9816b 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -124,6 +124,7 @@ Required properties:
 Optional properties:
 - qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode PHY
   regulator is wanted.
+- qcom,dsi-phy-cphy-mode: Boolean value indicating if CPHY mode is wanted.
 - qcom,mdss-mdp-transfer-time-us:  Specifies the dsi transfer time for 
command mode
panels in microseconds. Driver uses 
this number to adjust
the clock rate according to the 
expected transfer time.
diff --git a/drivers/gpu/drm/msm/dsi/dsi.c b/drivers/gpu/drm/msm/dsi/dsi.c
index 627048851d99..68d8547f7264 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -13,7 +13,7 @@ struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi 
*msm_dsi)
return msm_dsi->encoder;
 }
 
-static int dsi_get_phy(struct msm_dsi *msm_dsi)
+static int dsi_get_phy(struct msm_dsi *msm_dsi, bool *cphy_mode)
 {
struct platform_device *pdev = msm_dsi->pdev;
struct platform_device *phy_pdev;
@@ -29,6 +29,7 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
if (phy_pdev)
msm_dsi->phy = platform_get_drvdata(phy_pdev);
 
+   *cphy_mode = of_property_read_bool(phy_node, "qcom,dsi-phy-cphy-mode");
of_node_put(phy_node);
 
if (!phy_pdev || !msm_dsi->phy) {
@@ -65,6 +66,7 @@ static void dsi_destroy(struct msm_dsi *msm_dsi)
 static struct msm_dsi *dsi_init(struct platform_device *pdev)
 {
struct msm_dsi *msm_dsi;
+   bool cphy_mode;
int ret;
 
if (!pdev)
@@ -79,13 +81,13 @@ static struct msm_dsi *dsi_init(struct platform_device 
*pdev)
msm_dsi->pdev = pdev;
platform_set_drvdata(pdev, msm_dsi);
 
-   /* Init dsi host */
-   ret = msm_dsi_host_init(msm_dsi);
+   /* GET dsi PHY */
+   ret = dsi_get_phy(msm_dsi, &cphy_mode);
if (ret)
goto destroy_dsi;
 
-   /* GET dsi PHY */
-   ret = dsi_get_phy(msm_dsi);
+   /* Init dsi host */
+   ret = msm_dsi_host_init(msm_dsi, cphy_mode);
if (ret)
goto destroy_dsi;
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi.h b/drivers/gpu/drm/msm/dsi/dsi.h
index 78ef5d4ed922..8db4edc286ee 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.h
@@ -108,7 +108,7 @@ struct drm_encoder *msm_dsi_get_encoder(struct msm_dsi 
*msm_dsi);
 struct msm_dsi_pll;
 #ifdef CONFIG_DRM_MSM_DSI_PLL
 struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device *pdev,
-   enum msm_dsi_phy_type type, int dsi_id);
+   enum msm_dsi_phy_type type, bool cphy_mode, int id);
 void msm_dsi_pll_destroy(struct msm_dsi_pll *pll);
 int msm_dsi_pll_get_clk_provider(struct msm_dsi_pll *pll,
struct clk **byte_clk_provider, struct clk **pixel_clk_provider);
@@ -118,7 +118,7 @@ int msm_dsi_pll_set_usecase(struct msm_dsi_pll *pll,
enum msm_dsi_phy_usecase uc);
 #else
 static inline struct msm_dsi_pll *msm_dsi_pll_init(struct platform_device 
*pdev,
-enum msm_dsi_phy_type type, int id) {
+enum msm_dsi_phy_type type, bool cphy_mode, int id) {
return ERR_PTR(-ENODEV);
 }
 static inline void msm_dsi_pll_destroy(struct msm_dsi_pll *pll)
@@ -177,7 +177,7 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host 
*host,
 void msm_dsi_host_destroy(struct mipi_dsi_host *host);
 int msm_dsi_host_modeset_init(struct mipi_dsi_host *host,
struct drm_device *dev);
-int msm_dsi_host_init(struct msm_dsi *msm_dsi);
+int msm_dsi_host_init(struct msm_dsi *msm_dsi, bool cphy_mode);
 int msm_dsi_runtime_suspend(struct device *dev);
 int msm_dsi_r

Re: [PATCH v2 1/2] drm/msm: add compatibles for sm8150/sm8250 display

2021-02-16 Thread Jonathan Marek

On 2/16/21 11:54 AM, Dmitry Baryshkov wrote:

On Mon, 15 Feb 2021 at 19:25, Jonathan Marek  wrote:


The driver already has support for sm8150/sm8250, but the compatibles were
never added.

Also inverse the non-mdp4 condition in add_display_components() to avoid
having to check every new compatible in the condition.

Signed-off-by: Jonathan Marek 
---
  Documentation/devicetree/bindings/display/msm/dpu.txt | 4 ++--
  drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c   | 2 ++
  drivers/gpu/drm/msm/msm_drv.c | 6 +++---
  3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dpu.txt 
b/Documentation/devicetree/bindings/display/msm/dpu.txt
index 551ae26f60da..5763f43200a0 100644
--- a/Documentation/devicetree/bindings/display/msm/dpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/dpu.txt
@@ -8,7 +8,7 @@ The DPU display controller is found in SDM845 SoC.

  MDSS:
  Required properties:
-- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss"
+- compatible:  "qcom,sdm845-mdss", "qcom,sc7180-mdss", "qcom,sm8150-mdss", 
"qcom,sm8250-mdss"
  - reg: physical base address and length of contoller's registers.
  - reg-names: register region names. The following region is required:
* "mdss"
@@ -41,7 +41,7 @@ Optional properties:

  MDP:
  Required properties:
-- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu"
+- compatible: "qcom,sdm845-dpu", "qcom,sc7180-dpu", "qcom,sm8150-dpu", 
"qcom,sm8250-dpu"
  - reg: physical base address and length of controller's registers.
  - reg-names : register region names. The following region is required:
* "mdp"


These two chunks should probably go to the separate patch 'dt-bindings:...'.



In this case I think its better to have this change in the same patch, 
but maybe one of the Robs will disagree.



Also, could you please pinpoint the reason for adding more
compatibility strings, while they map to the same internal data?
I think we might want instead to use some generic name for the dpu
block, like "qcom,dpu" or "qcom,mdp-dpu" instead of specifying the
platform name.



sdm845 and sc7180 aren't using generic compatibles, this is just being 
consistent with that.





diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
index 5a8e3e1fc48c..fff12a4c8bfc 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c
@@ -1219,6 +1219,8 @@ static const struct dev_pm_ops dpu_pm_ops = {
  static const struct of_device_id dpu_dt_match[] = {
 { .compatible = "qcom,sdm845-dpu", },
 { .compatible = "qcom,sc7180-dpu", },
+   { .compatible = "qcom,sm8150-dpu", },
+   { .compatible = "qcom,sm8250-dpu", },
 {}
  };
  MODULE_DEVICE_TABLE(of, dpu_dt_match);
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 94525ac76d4e..928f13d4bfbc 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -1185,9 +1185,7 @@ static int add_display_components(struct device *dev,
  * Populate the children devices, find the MDP5/DPU node, and then add
  * the interfaces to our components list.
  */
-   if (of_device_is_compatible(dev->of_node, "qcom,mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sdm845-mdss") ||
-   of_device_is_compatible(dev->of_node, "qcom,sc7180-mdss")) {
+   if (!of_device_is_compatible(dev->of_node, "qcom,mdp4")) {
 ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 if (ret) {
 DRM_DEV_ERROR(dev, "failed to populate children 
devices\n");
@@ -1320,6 +1318,8 @@ static const struct of_device_id dt_match[] = {
 { .compatible = "qcom,mdss", .data = (void *)KMS_MDP5 },
 { .compatible = "qcom,sdm845-mdss", .data = (void *)KMS_DPU },
 { .compatible = "qcom,sc7180-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8150-mdss", .data = (void *)KMS_DPU },
+   { .compatible = "qcom,sm8250-mdss", .data = (void *)KMS_DPU },
 {}
  };
  MODULE_DEVICE_TABLE(of, dt_match);
--
2.26.1





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


[PATCH] drm/msm/a6xx: fix for kernels without CONFIG_NVMEM

2021-02-16 Thread Jonathan Marek
Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
to fix the case where the kernel was compiled without CONFIG_NVMEM.

Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index ba8e9d3cf0fe..7fe5d97606aa 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, 
struct a6xx_gpu *a6xx_gpu,
 
cell = nvmem_cell_get(dev, "speed_bin");
/*
-* -ENOENT means that the platform doesn't support speedbin which is
-* fine
+* -ENOENT means no speed bin in device tree,
+* -EOPNOTSUPP means kernel was built without CONFIG_NVMEM
 */
-   if (PTR_ERR(cell) == -ENOENT)
+   if (PTR_ERR(cell) == -ENOENT || PTR_ERR(cell) == -EOPNOTSUPP)
return 0;
else if (IS_ERR(cell)) {
DRM_DEV_ERROR(dev,
-- 
2.26.1

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


Re: [PATCH] drm/msm/a6xx: fix for kernels without CONFIG_NVMEM

2021-02-17 Thread Jonathan Marek

On 2/17/21 3:18 PM, Rob Clark wrote:

On Wed, Feb 17, 2021 at 11:08 AM Jordan Crouse  wrote:


On Wed, Feb 17, 2021 at 07:14:16PM +0530, Akhil P Oommen wrote:

On 2/17/2021 8:36 AM, Rob Clark wrote:

On Tue, Feb 16, 2021 at 12:10 PM Jonathan Marek  wrote:


Ignore nvmem_cell_get() EOPNOTSUPP error in the same way as a ENOENT error,
to fix the case where the kernel was compiled without CONFIG_NVMEM.

Fixes: fe7952c629da ("drm/msm: Add speed-bin support to a618 gpu")
Signed-off-by: Jonathan Marek 
---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index ba8e9d3cf0fe..7fe5d97606aa 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1356,10 +1356,10 @@ static int a6xx_set_supported_hw(struct device *dev, 
struct a6xx_gpu *a6xx_gpu,

 cell = nvmem_cell_get(dev, "speed_bin");
 /*
-* -ENOENT means that the platform doesn't support speedbin which is
-* fine
+* -ENOENT means no speed bin in device tree,
+* -EOPNOTSUPP means kernel was built without CONFIG_NVMEM


very minor nit, it would be nice to at least preserve the gist of the
"which is fine" (ie. some variation of "this is an optional thing and
things won't catch fire without it" ;-))

(which is, I believe, is true, hopefully Akhil could confirm.. if not
we should have a harder dependency on CONFIG_NVMEM..)

IIRC, if the gpu opp table in the DT uses the 'opp-supported-hw' property,
we will see some error during boot up if we don't call
dev_pm_opp_set_supported_hw(). So calling "nvmem_cell_get(dev, "speed_bin")"
is a way to test this.

If there is no other harm, we can put a hard dependency on CONFIG_NVMEM.


I'm not sure if we want to go this far given the squishiness about module
dependencies. As far as I know we are the only driver that uses this seriously
on QCOM SoCs and this is only needed for certain targets. I don't know if we
want to force every target to build NVMEM and QFPROM on our behalf. But maybe
I'm just saying that because Kconfig dependencies tend to break my brain (and
then Arnd has to send a patch to fix it).



Hmm, good point.. looks like CONFIG_NVMEM itself doesn't have any
other dependencies, so I suppose it wouldn't be the end of the world
to select that.. but I guess we don't want to require QFPROM

I guess at the end of the day, what is the failure mode if you have a
speed-bin device, but your kernel config misses QFPROM (and possibly
NVMEM)?  If the result is just not having the highest clk rate(s)
available, that isn't the end of the world.  But if it makes things
not-work, that is sub-optimal.  Generally, especially on ARM, kconfig
seems to be way harder than it should be to build a kernel that works,
if we could somehow not add to that problem (for both people with a6xx
and older gens) that would be nice ;-)



There is a "imply" kconfig option which solves exactly this problem. 
(you would "imply NVMEM" instead of "select NVMEM". then it would be 
possible to disable NVMEM but it would get enabled by default)



BR,
-R


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


Re: [PATCH] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-03-05 Thread Jonathan Marek

On 3/5/21 4:48 PM, Rob Herring wrote:

On Mon, Feb 15, 2021 at 11:27:44AM -0500, Jonathan Marek wrote:

Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 
---
  .../devicetree/bindings/display/msm/dsi.txt   |  1 +
  drivers/gpu/drm/msm/dsi/dsi.c | 12 +--
  drivers/gpu/drm/msm/dsi/dsi.h |  6 +-
  drivers/gpu/drm/msm/dsi/dsi.xml.h |  2 +
  drivers/gpu/drm/msm/dsi/dsi_host.c| 34 +--
  drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 49 +-
  drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |  3 +
  drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 89 ++-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll.c |  4 +-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll.h |  5 +-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c | 71 +--
  11 files changed, 210 insertions(+), 66 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt 
b/Documentation/devicetree/bindings/display/msm/dsi.txt
index b9a64d3ff184..7ffc86a9816b 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -124,6 +124,7 @@ Required properties:
  Optional properties:
  - qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the LDO mode 
PHY
regulator is wanted.
+- qcom,dsi-phy-cphy-mode: Boolean value indicating if CPHY mode is wanted.


This is board or SoC dependent? The latter should be implied by an SoC
specific compatible.



It is board specific, 7nm dsi phy can operate in either D-PHY or C-PHY mode.

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


Re: [PATCH] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-03-05 Thread Jonathan Marek

On 3/5/21 5:45 PM, Dmitry Baryshkov wrote:

On 15/02/2021 19:27, Jonathan Marek wrote:

Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 


Other that few comments bellow:

Reviewed-by: Dmitry Baryshkov 


---
  .../devicetree/bindings/display/msm/dsi.txt   |  1 +
  drivers/gpu/drm/msm/dsi/dsi.c | 12 +--
  drivers/gpu/drm/msm/dsi/dsi.h |  6 +-
  drivers/gpu/drm/msm/dsi/dsi.xml.h |  2 +
  drivers/gpu/drm/msm/dsi/dsi_host.c    | 34 +--
  drivers/gpu/drm/msm/dsi/phy/dsi_phy.c | 49 +-
  drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |  3 +
  drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 89 ++-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll.c |  4 +-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll.h |  5 +-
  drivers/gpu/drm/msm/dsi/pll/dsi_pll_7nm.c | 71 +--
  11 files changed, 210 insertions(+), 66 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi.txt 
b/Documentation/devicetree/bindings/display/msm/dsi.txt

index b9a64d3ff184..7ffc86a9816b 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi.txt
+++ b/Documentation/devicetree/bindings/display/msm/dsi.txt
@@ -124,6 +124,7 @@ Required properties:
  Optional properties:
  - qcom,dsi-phy-regulator-ldo-mode: Boolean value indicating if the 
LDO mode PHY

    regulator is wanted.
+- qcom,dsi-phy-cphy-mode: Boolean value indicating if CPHY mode is 
wanted.
  - qcom,mdss-mdp-transfer-time-us:    Specifies the dsi transfer time 
for command mode
  panels in microseconds. Driver uses this number 
to adjust
  the clock rate according to the expected 
transfer time.


This should go in a separate patch, shan't it?

diff --git a/drivers/gpu/drm/msm/dsi/dsi.c 
b/drivers/gpu/drm/msm/dsi/dsi.c

index 627048851d99..68d8547f7264 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.c
+++ b/drivers/gpu/drm/msm/dsi/dsi.c
@@ -13,7 +13,7 @@ struct drm_encoder *msm_dsi_get_encoder(struct 
msm_dsi *msm_dsi)

  return msm_dsi->encoder;
  }
-static int dsi_get_phy(struct msm_dsi *msm_dsi)
+static int dsi_get_phy(struct msm_dsi *msm_dsi, bool *cphy_mode)


I see no need to pass the 'cphy_mode' through the bool pointer and back 
to msm_dsi_host_init. What about just putting it into struct msm_dsi?




Because it doesn't need to be stored in msm_dsi (need it in msm_dsi_host 
which doesn't have access to msm_dsi). But I suppose it doesn't hurt to 
also have it in msm_dsi and make things a bit cleaner.



  {
  struct platform_device *pdev = msm_dsi->pdev;
  struct platform_device *phy_pdev;
@@ -29,6 +29,7 @@ static int dsi_get_phy(struct msm_dsi *msm_dsi)
  if (phy_pdev)
  msm_dsi->phy = platform_get_drvdata(phy_pdev);
+    *cphy_mode = of_property_read_bool(phy_node, 
"qcom,dsi-phy-cphy-mode");

  of_node_put(phy_node);
  if (!phy_pdev || !msm_dsi->phy) {
@@ -65,6 +66,7 @@ static void dsi_destroy(struct msm_dsi *msm_dsi)
  static struct msm_dsi *dsi_init(struct platform_device *pdev)
  {
  struct msm_dsi *msm_dsi;
+    bool cphy_mode;
  int ret;
  if (!pdev)
@@ -79,13 +81,13 @@ static struct msm_dsi *dsi_init(struct 
platform_device *pdev)

  msm_dsi->pdev = pdev;
  platform_set_drvdata(pdev, msm_dsi);
-    /* Init dsi host */
-    ret = msm_dsi_host_init(msm_dsi);
+    /* GET dsi PHY */
+    ret = dsi_get_phy(msm_dsi, &cphy_mode);
  if (ret)
  goto destroy_dsi;
-    /* GET dsi PHY */
-    ret = dsi_get_phy(msm_dsi);
+    /* Init dsi host */
+    ret = msm_dsi_host_init(msm_dsi, cphy_mode);
  if (ret)
  goto destroy_dsi;




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


[PATCH 0/5] drm/msm/a6xx: add support for Adreno 660 GPU

2021-05-12 Thread Jonathan Marek
Add support for Adreno 660 to the drm/msm driver. Very similar to A650
on the kernel side.

Jonathan Marek (5):
  drm/msm: remove unused icc_path/ocmem_icc_path
  drm/msm/a6xx: avoid shadow NULL reference in failure path
  drm/msm/a6xx: add support for Adreno 660 GPU
  drm/msm/a6xx: update a6xx_ucode_check_version for a660
  drm/msm/a6xx: add a660 hwcg table

 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |   4 +
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  |  32 --
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 115 -
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  |  33 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c |  13 +++
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|   5 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  14 ++-
 drivers/gpu/drm/msm/msm_gpu.h  |   9 --
 8 files changed, 176 insertions(+), 49 deletions(-)

-- 
2.26.1



[PATCH 1/5] drm/msm: remove unused icc_path/ocmem_icc_path

2021-05-12 Thread Jonathan Marek
These aren't used by anything anymore.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ---
 drivers/gpu/drm/msm/msm_gpu.h   | 9 -
 2 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 8fd0777f2dc9..009f4c560f16 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -946,7 +946,4 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
pm_runtime_disable(&priv->gpu_pdev->dev);
 
msm_gpu_cleanup(&adreno_gpu->base);
-
-   icc_put(gpu->icc_path);
-   icc_put(gpu->ocmem_icc_path);
 }
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 18baf935e143..c302ab7ffb06 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -118,15 +118,6 @@ struct msm_gpu {
struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk;
uint32_t fast_rate;
 
-   /* The gfx-mem interconnect path that's used by all GPU types. */
-   struct icc_path *icc_path;
-
-   /*
-* Second interconnect path for some A3xx and all A4xx GPUs to the
-* On Chip MEMory (OCMEM).
-*/
-   struct icc_path *ocmem_icc_path;
-
/* Hang and Inactivity Detection:
 */
 #define DRM_MSM_INACTIVE_PERIOD   66 /* in ms (roughly four frames) */
-- 
2.26.1



[PATCH 2/5] drm/msm/a6xx: avoid shadow NULL reference in failure path

2021-05-12 Thread Jonathan Marek
If a6xx_hw_init() fails before creating the shadow_bo, the a6xx_pm_suspend
code referencing it will crash. Change the condition to one that avoids
this problem (note: creation of shadow_bo is behind this same condition)

Fixes: e8b0b994c3a5 ("drm/msm/a6xx: Clear shadow on suspend")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 727d111a413f..01bd31b3c504 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1211,7 +1211,7 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)
if (ret)
return ret;
 
-   if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami)
+   if (a6xx_gpu->shadow_bo)
for (i = 0; i < gpu->nr_rings; i++)
a6xx_gpu->shadow[i] = 0;
 
-- 
2.26.1



[PATCH 3/5] drm/msm/a6xx: add support for Adreno 660 GPU

2021-05-12 Thread Jonathan Marek
Add adreno_is_{a660,a650_family} helpers and convert update existing
adreno_is_a650 usage based on downstream driver's logic (changing into
adreno_is_a650_family or adding adreno_is_a660).

And add the remaining changes required for A660, again based on
the downstream driver: missing GMU allocations, additional register init,
dummy hfi BW table, entry in gpulist table.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |  4 +++
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  | 32 +++--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 24 +++-
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  | 33 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c | 12 
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|  2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h| 12 
 7 files changed, 103 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
index 920c5e6b8e96..631c36672560 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
@@ -2240,6 +2240,8 @@ static inline uint32_t 
A6XX_DBGC_CFG_DBGBUS_BYTEL_1_BYTEL15(uint32_t val)
 
 #define REG_A6XX_DBGC_CFG_DBGBUS_TRACE_BUF20x0630
 
+#define REG_A6XX_CP_LPAC_PROG_FIFO_SIZE0x0b34
+
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_0 0x0cd8
 
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_1 0x0cd9
@@ -2340,6 +2342,8 @@ static inline uint32_t 
A6XX_UCHE_CLIENT_PF_PERFSEL(uint32_t val)
 
 #define REG_A6XX_UCHE_PERFCTR_UCHE_SEL_11  0x0e27
 
+#define REG_A6XX_UCHE_CMDQ_CONFIG  0x0e3c
+
 #define REG_A6XX_SP_ADDR_MODE_CNTL 0xae01
 
 #define REG_A6XX_SP_NC_MODE_CNTL   0xae02
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 3d55e153fa9c..e25c41984336 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -520,7 +520,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 
if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
pdc_address_offset = 0x30090;
-   else if (adreno_is_a650(adreno_gpu))
+   else if (adreno_is_a650_family(adreno_gpu))
pdc_address_offset = 0x300a0;
else
pdc_address_offset = 0x30080;
@@ -542,7 +542,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
gmu_write_rscc(gmu, REG_A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
 
/* Load RSC sequencer uCode for sleep and wakeup */
-   if (adreno_is_a650(adreno_gpu)) {
+   if (adreno_is_a650_family(adreno_gpu)) {
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0, 0xeaaae5a0);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 
0xe1a1ebab);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 
0xa2e0a581);
@@ -587,7 +587,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID + 4, 0x10108);
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR + 4, 0x3);
-   if (adreno_is_a618(adreno_gpu) || adreno_is_a650(adreno_gpu))
+   if (adreno_is_a618(adreno_gpu) || adreno_is_a650_family(adreno_gpu))
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x2);
else
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x3);
@@ -687,7 +687,7 @@ static int a6xx_gmu_fw_load(struct a6xx_gmu *gmu)
u32 itcm_base = 0x;
u32 dtcm_base = 0x0004;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650_family(adreno_gpu))
dtcm_base = 0x10004000;
 
if (gmu->legacy) {
@@ -740,7 +740,7 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned 
int state)
int ret;
u32 chipid;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
 
if (state == GMU_WARM_BOOT) {
@@ -1483,12 +1483,28 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct 
device_node *node)
if (ret)
goto err_put_device;
 
+
+   /* A660 now requires handling "prealloc requests" in GMU firmware
+* For now just hardcode allocations based on the known firmware.
+* note: there is no indication that these correspond to "dummy" or
+* "debug" regions, but this "guess" allows reusing these BOs which
+* are otherwise unused by a660.
+*/
+   gmu->dummy.size = SZ_4K;
+   if (adreno_is_a660(adreno_gpu)) {
+   ret = a6xx_gmu_memory_alloc(gmu, &gmu->debug, SZ_4K * 7, 
0x6040);
+ 

[PATCH 4/5] drm/msm/a6xx: update a6xx_ucode_check_version for a660

2021-05-12 Thread Jonathan Marek
Accept all SQE firmware versions for A660.

Re-organize the function a bit and print an error message for unexpected
GPU IDs instead of failing silently.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 36 +--
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 4467273e66c0..261a20076f9d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -541,6 +541,11 @@ static bool a6xx_ucode_check_version(struct a6xx_gpu 
*a6xx_gpu,
 * Targets up to a640 (a618, a630 and a640) need to check for a
 * microcode version that is patched to support the whereami opcode or
 * one that is new enough to include it by default.
+*
+* a650 tier targets don't need whereami but still need to be
+* equal to or newer than 0.95 for other security fixes
+*
+* a660 targets have all the critical security fixes from the start
 */
if (adreno_is_a618(adreno_gpu) || adreno_is_a630(adreno_gpu) ||
adreno_is_a640(adreno_gpu)) {
@@ -564,27 +569,20 @@ static bool a6xx_ucode_check_version(struct a6xx_gpu 
*a6xx_gpu,
DRM_DEV_ERROR(&gpu->pdev->dev,
"a630 SQE ucode is too old. Have version %x need at 
least %x\n",
buf[0] & 0xfff, 0x190);
-   }  else {
-   /*
-* a650 tier targets don't need whereami but still need to be
-* equal to or newer than 0.95 for other security fixes
-*/
-   if (adreno_is_a650(adreno_gpu)) {
-   if ((buf[0] & 0xfff) >= 0x095) {
-   ret = true;
-   goto out;
-   }
-
-   DRM_DEV_ERROR(&gpu->pdev->dev,
-   "a650 SQE ucode is too old. Have version %x 
need at least %x\n",
-   buf[0] & 0xfff, 0x095);
+   } else if (adreno_is_a650(adreno_gpu)) {
+   if ((buf[0] & 0xfff) >= 0x095) {
+   ret = true;
+   goto out;
}
 
-   /*
-* When a660 is added those targets should return true here
-* since those have all the critical security fixes built in
-* from the start
-*/
+   DRM_DEV_ERROR(&gpu->pdev->dev,
+   "a650 SQE ucode is too old. Have version %x need at 
least %x\n",
+   buf[0] & 0xfff, 0x095);
+   } else if (adreno_is_a660(adreno_gpu)) {
+   ret = true;
+   } else {
+   DRM_DEV_ERROR(&gpu->pdev->dev,
+   "unknown GPU, add it to 
a6xx_ucode_check_version()!!\n");
}
 out:
msm_gem_put_vaddr(obj);
-- 
2.26.1



[PATCH 5/5] drm/msm/a6xx: add a660 hwcg table

2021-05-12 Thread Jonathan Marek
Add a660 hwcg table, ported over from downstream.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 53 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  2 +-
 3 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 261a20076f9d..d9753c62035c 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -427,6 +427,59 @@ const struct adreno_reglist a650_hwcg[] = {
{},
 };
 
+const struct adreno_reglist a660_hwcg[] = {
+   {REG_A6XX_RBBM_CLOCK_CNTL_SP0, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_SP0, 0x0220},
+   {REG_A6XX_RBBM_CLOCK_DELAY_SP0, 0x0080},
+   {REG_A6XX_RBBM_CLOCK_HYST_SP0, 0xF3CF},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL4_TP0, 0x0002},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY4_TP0, 0x0001},
+   {REG_A6XX_RBBM_CLOCK_HYST_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST4_TP0, 0x0007},
+   {REG_A6XX_RBBM_CLOCK_CNTL_RB0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_RB0, 0x0100},
+   {REG_A6XX_RBBM_CLOCK_CNTL_CCU0, 0x2220},
+   {REG_A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00},
+   {REG_A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_RAC, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_RAC, 0x0011},
+   {REG_A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x0422},
+   {REG_A6XX_RBBM_CLOCK_MODE_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_MODE_GPC, 0x0022},
+   {REG_A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x0002},
+   {REG_A6XX_RBBM_CLOCK_MODE_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x4000},
+   {REG_A6XX_RBBM_CLOCK_DELAY_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_GPC, 0x0200},
+   {REG_A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004},
+   {REG_A6XX_RBBM_CLOCK_HYST_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x0111},
+   {REG_A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_UCHE, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_UCHE, 0x0004},
+   {REG_A6XX_RBBM_CLOCK_DELAY_UCHE, 0x0002},
+   {REG_A6XX_RBBM_ISDB_CNT, 0x0182},
+   {REG_A6XX_RBBM_RAC_THRESHOLD_CNT, 0x},
+   {REG_A6XX_RBBM_SP_HYST_CNT, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x0111},
+   {REG_A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x0555},
+   {},
+};
+
 static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
 {
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index e4db0683d381..6dad8015c9a1 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -299,6 +299,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a6xx_gpu_init,
.zapfw = "a660_zap.mdt",
+   .hwcg = a660_hwcg,
},
 };
 
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index 63c050919d85..e6b11e6ec82d 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -55,7 +55,7 @@ struct adreno_reglist {
u32 value;
 };
 
-extern const struct adreno_reglist a630_hwcg[], a640_hwcg[], a650_hwcg[];
+extern const struct adreno_reglist a630_hwcg[], a640_hwcg[], a650_hwcg[], 
a660_hwcg[];
 
 struct adreno_info {
struct adreno_rev rev;
-- 
2.26.1



[PATCH v2 0/8] drm/msm/a6xx: add support for Adreno 660 GPU

2021-05-13 Thread Jonathan Marek
Add support for Adreno 660 to the drm/msm driver. Very similar to A650
on the kernel side.

v2:
 - added AOP PDC path for a650 and use it for a660 too
 - fix UBWC config for a650 (also affects a660)
 - add CP_PROTECT update, and corresponding a660 settings in A660 patch

Jonathan Marek (8):
  drm/msm: remove unused icc_path/ocmem_icc_path
  drm/msm/a6xx: use AOP-initialized PDC for a650
  drm/msm/a6xx: fix incorrectly set uavflagprd_inv field for A650
  drm/msm/a6xx: update/fix CP_PROTECT initialization
  drm/msm/a6xx: avoid shadow NULL reference in failure path
  drm/msm/a6xx: add support for Adreno 660 GPU
  drm/msm/a6xx: update a6xx_ucode_check_version for a660
  drm/msm/a6xx: add a660 hwcg table

 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |   4 +
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  |  51 +++-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 309 -
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h  |   2 +-
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  |  33 +++
 drivers/gpu/drm/msm/adreno/adreno_device.c |  13 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|   5 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  14 +-
 drivers/gpu/drm/msm/msm_gpu.h  |   9 -
 9 files changed, 350 insertions(+), 90 deletions(-)

-- 
2.26.1



[PATCH v2 1/8] drm/msm: remove unused icc_path/ocmem_icc_path

2021-05-13 Thread Jonathan Marek
These aren't used by anything anymore.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ---
 drivers/gpu/drm/msm/msm_gpu.h   | 9 -
 2 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 8fd0777f2dc9..009f4c560f16 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -946,7 +946,4 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
pm_runtime_disable(&priv->gpu_pdev->dev);
 
msm_gpu_cleanup(&adreno_gpu->base);
-
-   icc_put(gpu->icc_path);
-   icc_put(gpu->ocmem_icc_path);
 }
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 18baf935e143..c302ab7ffb06 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -118,15 +118,6 @@ struct msm_gpu {
struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk;
uint32_t fast_rate;
 
-   /* The gfx-mem interconnect path that's used by all GPU types. */
-   struct icc_path *icc_path;
-
-   /*
-* Second interconnect path for some A3xx and all A4xx GPUs to the
-* On Chip MEMory (OCMEM).
-*/
-   struct icc_path *ocmem_icc_path;
-
/* Hang and Inactivity Detection:
 */
 #define DRM_MSM_INACTIVE_PERIOD   66 /* in ms (roughly four frames) */
-- 
2.26.1



[PATCH v2 2/8] drm/msm/a6xx: use AOP-initialized PDC for a650

2021-05-13 Thread Jonathan Marek
SM8250 AOP firmware already sets up PDC registers for us, and it only needs
to be enabled. This path will be used for other newer GPUs.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 3d55e153fa9c..c1ee02d6371d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -512,19 +512,26 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
struct platform_device *pdev = to_platform_device(gmu->dev);
void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc");
-   void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+   void __iomem *seqptr;
uint32_t pdc_address_offset;
+   bool pdc_in_aop = false;
 
-   if (!pdcptr || !seqptr)
+   if (!pdcptr)
goto err;
 
-   if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu))
+   pdc_in_aop = true;
+   else if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
pdc_address_offset = 0x30090;
-   else if (adreno_is_a650(adreno_gpu))
-   pdc_address_offset = 0x300a0;
else
pdc_address_offset = 0x30080;
 
+   if (!pdc_in_aop) {
+   seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+   if (!seqptr)
+   goto err;
+   }
+
/* Disable SDE clock gating */
gmu_write_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
 
@@ -556,6 +563,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 
0x0020e8a8);
}
 
+   if (pdc_in_aop)
+   goto setup_pdc;
+
/* Load PDC sequencer uCode for power up and power down sequence */
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0, 0xfebea1e1);
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 1, 0xa5a4a3a2);
@@ -596,6 +606,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 8, 0x3);
 
/* Setup GPU PDC */
+setup_pdc:
pdc_write(pdcptr, REG_A6XX_PDC_GPU_SEQ_START_ADDR, 0);
pdc_write(pdcptr, REG_A6XX_PDC_GPU_ENABLE_PDC, 0x8001);
 
-- 
2.26.1



[PATCH v2 3/8] drm/msm/a6xx: fix incorrectly set uavflagprd_inv field for A650

2021-05-13 Thread Jonathan Marek
Value was shifted in the wrong direction, resulting in the field always
being zero, which is incorrect for A650.

Fixes: d0bac4e9cd66 ("drm/msm/a6xx: set ubwc config for A640 and A650")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 727d111a413f..45a6a0fce7d7 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -489,7 +489,7 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu)
rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1);
gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1);
gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL,
-   uavflagprd_inv >> 4 | lower_bit << 1);
+   uavflagprd_inv << 4 | lower_bit << 1);
gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21);
 }
 
-- 
2.26.1



[PATCH v2 4/8] drm/msm/a6xx: update/fix CP_PROTECT initialization

2021-05-13 Thread Jonathan Marek
Update CP_PROTECT register programming based on downstream.

A6XX_PROTECT_RW is renamed to A6XX_PROTECT_NORDWR to make things aligned
and also be more clear about what it does.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 143 +++---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h |   2 +-
 2 files changed, 109 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 45a6a0fce7d7..909e3ff08f89 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -462,6 +462,113 @@ static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
gpu_write(gpu, REG_A6XX_RBBM_CLOCK_CNTL, state ? clock_cntl_on : 0);
 }
 
+/* For a615, a616, a618, A619, a630, a640 and a680 */
+static const u32 a6xx_protect[] = {
+   A6XX_PROTECT_RDONLY(0x0, 0x04ff),
+   A6XX_PROTECT_RDONLY(0x00501, 0x0005),
+   A6XX_PROTECT_RDONLY(0x0050b, 0x02f4),
+   A6XX_PROTECT_NORDWR(0x0050e, 0x),
+   A6XX_PROTECT_NORDWR(0x00510, 0x),
+   A6XX_PROTECT_NORDWR(0x00534, 0x),
+   A6XX_PROTECT_NORDWR(0x00800, 0x0082),
+   A6XX_PROTECT_NORDWR(0x008a0, 0x0008),
+   A6XX_PROTECT_NORDWR(0x008ab, 0x0024),
+   A6XX_PROTECT_RDONLY(0x008d0, 0x00bc),
+   A6XX_PROTECT_NORDWR(0x00900, 0x004d),
+   A6XX_PROTECT_NORDWR(0x0098d, 0x0272),
+   A6XX_PROTECT_NORDWR(0x00e00, 0x0001),
+   A6XX_PROTECT_NORDWR(0x00e03, 0x000c),
+   A6XX_PROTECT_NORDWR(0x03c00, 0x00c3),
+   A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x08630, 0x01cf),
+   A6XX_PROTECT_NORDWR(0x08e00, 0x),
+   A6XX_PROTECT_NORDWR(0x08e08, 0x),
+   A6XX_PROTECT_NORDWR(0x08e50, 0x001f),
+   A6XX_PROTECT_NORDWR(0x09624, 0x01db),
+   A6XX_PROTECT_NORDWR(0x09e70, 0x0001),
+   A6XX_PROTECT_NORDWR(0x09e78, 0x0187),
+   A6XX_PROTECT_NORDWR(0x0a630, 0x01cf),
+   A6XX_PROTECT_NORDWR(0x0ae02, 0x),
+   A6XX_PROTECT_NORDWR(0x0ae50, 0x032f),
+   A6XX_PROTECT_NORDWR(0x0b604, 0x),
+   A6XX_PROTECT_NORDWR(0x0be02, 0x0001),
+   A6XX_PROTECT_NORDWR(0x0be20, 0x17df),
+   A6XX_PROTECT_NORDWR(0x0f000, 0x0bff),
+   A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x11c00, 0x), /* note: infinite range */
+};
+
+/* These are for a620 and a650 */
+static const u32 a650_protect[] = {
+   A6XX_PROTECT_RDONLY(0x0, 0x04ff),
+   A6XX_PROTECT_RDONLY(0x00501, 0x0005),
+   A6XX_PROTECT_RDONLY(0x0050b, 0x02f4),
+   A6XX_PROTECT_NORDWR(0x0050e, 0x),
+   A6XX_PROTECT_NORDWR(0x00510, 0x),
+   A6XX_PROTECT_NORDWR(0x00534, 0x),
+   A6XX_PROTECT_NORDWR(0x00800, 0x0082),
+   A6XX_PROTECT_NORDWR(0x008a0, 0x0008),
+   A6XX_PROTECT_NORDWR(0x008ab, 0x0024),
+   A6XX_PROTECT_RDONLY(0x008d0, 0x00bc),
+   A6XX_PROTECT_NORDWR(0x00900, 0x004d),
+   A6XX_PROTECT_NORDWR(0x0098d, 0x0272),
+   A6XX_PROTECT_NORDWR(0x00e00, 0x0001),
+   A6XX_PROTECT_NORDWR(0x00e03, 0x000c),
+   A6XX_PROTECT_NORDWR(0x03c00, 0x00c3),
+   A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x08630, 0x01cf),
+   A6XX_PROTECT_NORDWR(0x08e00, 0x),
+   A6XX_PROTECT_NORDWR(0x08e08, 0x),
+   A6XX_PROTECT_NORDWR(0x08e50, 0x001f),
+   A6XX_PROTECT_NORDWR(0x08e80, 0x027f),
+   A6XX_PROTECT_NORDWR(0x09624, 0x01db),
+   A6XX_PROTECT_NORDWR(0x09e60, 0x0011),
+   A6XX_PROTECT_NORDWR(0x09e78, 0x0187),
+   A6XX_PROTECT_NORDWR(0x0a630, 0x01cf),
+   A6XX_PROTECT_NORDWR(0x0ae02, 0x),
+   A6XX_PROTECT_NORDWR(0x0ae50, 0x032f),
+   A6XX_PROTECT_NORDWR(0x0b604, 0x),
+   A6XX_PROTECT_NORDWR(0x0b608, 0x0007),
+   A6XX_PROTECT_NORDWR(0x0be02, 0x0001),
+   A6XX_PROTECT_NORDWR(0x0be20, 0x17df),
+   A6XX_PROTECT_NORDWR(0x0f000, 0x0bff),
+   A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x18400, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x1a800, 0x1fff),
+   A6XX_PROTECT_NORDWR(0x1f400, 0x0443),
+   A6XX_PROTECT_RDONLY(0x1f844, 0x007b),
+   A6XX_PROTECT_NORDWR(0x1f887, 0x001b),
+   A6XX_PROTECT_NORDWR(0x1f8c0, 0x), /* note: infinite range */
+};
+
+static void a6xx_set_cp_protect(struct msm_gpu *gpu)
+{
+   struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
+   const u32 *regs = a6xx_protect;
+   unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32;
+
+   BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32);
+   BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48);
+
+   if (adreno_is_a650(adreno_gpu)) {
+   regs = a650_protect;
+   count = ARRAY_SIZE(a650_protect);
+   count_max = 48;
+   }
+
+   /*
+* Enable access protection to privileged registers, fault on an access
+* protect violation and select the last span to protect from the start
+* address all the way to the end 

[PATCH v2 5/8] drm/msm/a6xx: avoid shadow NULL reference in failure path

2021-05-13 Thread Jonathan Marek
If a6xx_hw_init() fails before creating the shadow_bo, the a6xx_pm_suspend
code referencing it will crash. Change the condition to one that avoids
this problem (note: creation of shadow_bo is behind this same condition)

Fixes: e8b0b994c3a5 ("drm/msm/a6xx: Clear shadow on suspend")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 909e3ff08f89..ff3c328604f8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1284,7 +1284,7 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)
if (ret)
return ret;
 
-   if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami)
+   if (a6xx_gpu->shadow_bo)
for (i = 0; i < gpu->nr_rings; i++)
a6xx_gpu->shadow[i] = 0;
 
-- 
2.26.1



[PATCH v2 6/8] drm/msm/a6xx: add support for Adreno 660 GPU

2021-05-13 Thread Jonathan Marek
Add adreno_is_{a660,a650_family} helpers and convert update existing
adreno_is_a650 usage based on downstream driver's logic (changing into
adreno_is_a650_family or adding adreno_is_a660).

And add the remaining changes required for A660, again based on
the downstream driver: missing GMU allocations, additional register init,
dummy hfi BW table, cp protect list, entry in gpulist table.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |  4 ++
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  | 32 +++---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 73 +++---
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  | 33 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c | 12 
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|  2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h| 12 
 7 files changed, 152 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
index 920c5e6b8e96..631c36672560 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
@@ -2240,6 +2240,8 @@ static inline uint32_t 
A6XX_DBGC_CFG_DBGBUS_BYTEL_1_BYTEL15(uint32_t val)
 
 #define REG_A6XX_DBGC_CFG_DBGBUS_TRACE_BUF20x0630
 
+#define REG_A6XX_CP_LPAC_PROG_FIFO_SIZE0x0b34
+
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_0 0x0cd8
 
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_1 0x0cd9
@@ -2340,6 +2342,8 @@ static inline uint32_t 
A6XX_UCHE_CLIENT_PF_PERFSEL(uint32_t val)
 
 #define REG_A6XX_UCHE_PERFCTR_UCHE_SEL_11  0x0e27
 
+#define REG_A6XX_UCHE_CMDQ_CONFIG  0x0e3c
+
 #define REG_A6XX_SP_ADDR_MODE_CNTL 0xae01
 
 #define REG_A6XX_SP_NC_MODE_CNTL   0xae02
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index c1ee02d6371d..91052a661c6e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -519,7 +519,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
if (!pdcptr)
goto err;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))
pdc_in_aop = true;
else if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
pdc_address_offset = 0x30090;
@@ -549,7 +549,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
gmu_write_rscc(gmu, REG_A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
 
/* Load RSC sequencer uCode for sleep and wakeup */
-   if (adreno_is_a650(adreno_gpu)) {
+   if (adreno_is_a650_family(adreno_gpu)) {
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0, 0xeaaae5a0);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 
0xe1a1ebab);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 
0xa2e0a581);
@@ -597,7 +597,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID + 4, 0x10108);
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR + 4, 0x3);
-   if (adreno_is_a618(adreno_gpu) || adreno_is_a650(adreno_gpu))
+   if (adreno_is_a618(adreno_gpu) || adreno_is_a650_family(adreno_gpu))
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x2);
else
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x3);
@@ -698,7 +698,7 @@ static int a6xx_gmu_fw_load(struct a6xx_gmu *gmu)
u32 itcm_base = 0x;
u32 dtcm_base = 0x0004;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650_family(adreno_gpu))
dtcm_base = 0x10004000;
 
if (gmu->legacy) {
@@ -751,7 +751,7 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned 
int state)
int ret;
u32 chipid;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
 
if (state == GMU_WARM_BOOT) {
@@ -1494,12 +1494,28 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct 
device_node *node)
if (ret)
goto err_put_device;
 
+
+   /* A660 now requires handling "prealloc requests" in GMU firmware
+* For now just hardcode allocations based on the known firmware.
+* note: there is no indication that these correspond to "dummy" or
+* "debug" regions, but this "guess" allows reusing these BOs which
+* are otherwise unused by a660.
+*/
+   gmu->dummy.size = SZ_4K;
+   if (adreno_is_a660(adreno_gpu)) {
+   ret = a6xx_gmu_memory_alloc(gmu, &gmu->debug, SZ_4K * 7, 
0x6040);
+ 

[PATCH v2 7/8] drm/msm/a6xx: update a6xx_ucode_check_version for a660

2021-05-13 Thread Jonathan Marek
Accept all SQE firmware versions for A660.

Re-organize the function a bit and print an error message for unexpected
GPU IDs instead of failing silently.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 36 +--
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 3cc23057b11d..ec66a24fc37e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -697,6 +697,11 @@ static bool a6xx_ucode_check_version(struct a6xx_gpu 
*a6xx_gpu,
 * Targets up to a640 (a618, a630 and a640) need to check for a
 * microcode version that is patched to support the whereami opcode or
 * one that is new enough to include it by default.
+*
+* a650 tier targets don't need whereami but still need to be
+* equal to or newer than 0.95 for other security fixes
+*
+* a660 targets have all the critical security fixes from the start
 */
if (adreno_is_a618(adreno_gpu) || adreno_is_a630(adreno_gpu) ||
adreno_is_a640(adreno_gpu)) {
@@ -720,27 +725,20 @@ static bool a6xx_ucode_check_version(struct a6xx_gpu 
*a6xx_gpu,
DRM_DEV_ERROR(&gpu->pdev->dev,
"a630 SQE ucode is too old. Have version %x need at 
least %x\n",
buf[0] & 0xfff, 0x190);
-   }  else {
-   /*
-* a650 tier targets don't need whereami but still need to be
-* equal to or newer than 0.95 for other security fixes
-*/
-   if (adreno_is_a650(adreno_gpu)) {
-   if ((buf[0] & 0xfff) >= 0x095) {
-   ret = true;
-   goto out;
-   }
-
-   DRM_DEV_ERROR(&gpu->pdev->dev,
-   "a650 SQE ucode is too old. Have version %x 
need at least %x\n",
-   buf[0] & 0xfff, 0x095);
+   } else if (adreno_is_a650(adreno_gpu)) {
+   if ((buf[0] & 0xfff) >= 0x095) {
+   ret = true;
+   goto out;
}
 
-   /*
-* When a660 is added those targets should return true here
-* since those have all the critical security fixes built in
-* from the start
-*/
+   DRM_DEV_ERROR(&gpu->pdev->dev,
+   "a650 SQE ucode is too old. Have version %x need at 
least %x\n",
+   buf[0] & 0xfff, 0x095);
+   } else if (adreno_is_a660(adreno_gpu)) {
+   ret = true;
+   } else {
+   DRM_DEV_ERROR(&gpu->pdev->dev,
+   "unknown GPU, add it to 
a6xx_ucode_check_version()!!\n");
}
 out:
msm_gem_put_vaddr(obj);
-- 
2.26.1



[PATCH v2 8/8] drm/msm/a6xx: add a660 hwcg table

2021-05-13 Thread Jonathan Marek
Add a660 hwcg table, ported over from downstream.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 53 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  2 +-
 3 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index ec66a24fc37e..2713f69e916d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -427,6 +427,59 @@ const struct adreno_reglist a650_hwcg[] = {
{},
 };
 
+const struct adreno_reglist a660_hwcg[] = {
+   {REG_A6XX_RBBM_CLOCK_CNTL_SP0, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_SP0, 0x0220},
+   {REG_A6XX_RBBM_CLOCK_DELAY_SP0, 0x0080},
+   {REG_A6XX_RBBM_CLOCK_HYST_SP0, 0xF3CF},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL4_TP0, 0x0002},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY4_TP0, 0x0001},
+   {REG_A6XX_RBBM_CLOCK_HYST_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST2_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST3_TP0, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST4_TP0, 0x0007},
+   {REG_A6XX_RBBM_CLOCK_CNTL_RB0, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_RB0, 0x0100},
+   {REG_A6XX_RBBM_CLOCK_CNTL_CCU0, 0x2220},
+   {REG_A6XX_RBBM_CLOCK_HYST_RB_CCU0, 0x00040F00},
+   {REG_A6XX_RBBM_CLOCK_CNTL_RAC, 0x25222022},
+   {REG_A6XX_RBBM_CLOCK_CNTL2_RAC, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_RAC, 0x0011},
+   {REG_A6XX_RBBM_CLOCK_HYST_RAC, 0x00445044},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TSE_RAS_RBBM, 0x0422},
+   {REG_A6XX_RBBM_CLOCK_MODE_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_MODE_GPC, 0x0022},
+   {REG_A6XX_RBBM_CLOCK_DELAY_HLSQ_2, 0x0002},
+   {REG_A6XX_RBBM_CLOCK_MODE_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TSE_RAS_RBBM, 0x4000},
+   {REG_A6XX_RBBM_CLOCK_DELAY_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_DELAY_GPC, 0x0200},
+   {REG_A6XX_RBBM_CLOCK_DELAY_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_TSE_RAS_RBBM, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_VFD, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_GPC, 0x04104004},
+   {REG_A6XX_RBBM_CLOCK_HYST_HLSQ, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_TEX_FCHE, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_DELAY_TEX_FCHE, 0x0111},
+   {REG_A6XX_RBBM_CLOCK_HYST_TEX_FCHE, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_UCHE, 0x},
+   {REG_A6XX_RBBM_CLOCK_HYST_UCHE, 0x0004},
+   {REG_A6XX_RBBM_CLOCK_DELAY_UCHE, 0x0002},
+   {REG_A6XX_RBBM_ISDB_CNT, 0x0182},
+   {REG_A6XX_RBBM_RAC_THRESHOLD_CNT, 0x},
+   {REG_A6XX_RBBM_SP_HYST_CNT, 0x},
+   {REG_A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x0222},
+   {REG_A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x0111},
+   {REG_A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x0555},
+   {},
+};
+
 static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
 {
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index e4db0683d381..6dad8015c9a1 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -299,6 +299,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a6xx_gpu_init,
.zapfw = "a660_zap.mdt",
+   .hwcg = a660_hwcg,
},
 };
 
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index 63c050919d85..e6b11e6ec82d 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -55,7 +55,7 @@ struct adreno_reglist {
u32 value;
 };
 
-extern const struct adreno_reglist a630_hwcg[], a640_hwcg[], a650_hwcg[];
+extern const struct adreno_reglist a630_hwcg[], a640_hwcg[], a650_hwcg[], 
a660_hwcg[];
 
 struct adreno_info {
struct adreno_rev rev;
-- 
2.26.1



[PATCH v2 1/5] drm/msm: add MSM_BO_CACHED_COHERENT

2020-11-08 Thread Jonathan Marek
Add a new cache mode for creating coherent host-cached BOs.

Signed-off-by: Jonathan Marek 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 1 +
 drivers/gpu/drm/msm/msm_drv.h  | 1 +
 drivers/gpu/drm/msm/msm_gem.c  | 8 
 include/uapi/drm/msm_drm.h | 5 ++---
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 58e03b20e1c7..21c9bc954f38 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -410,6 +410,7 @@ static int adreno_bind(struct device *dev, struct device 
*master, void *data)
config.rev.minor, config.rev.patchid);
 
priv->is_a2xx = config.rev.core == 2;
+   priv->has_cached_coherent = config.rev.core >= 6;
 
gpu = info->init(drm);
if (IS_ERR(gpu)) {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index f33281ac7913..22ebecb28349 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -168,6 +168,7 @@ struct msm_drm_private {
struct msm_file_private *lastctx;
/* gpu is only set on open(), but we need this info earlier */
bool is_a2xx;
+   bool has_cached_coherent;
 
struct drm_fb_helper *fbdev;
 
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 04be4cf1..3d8254b5de16 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -420,6 +420,9 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
if (msm_obj->flags & MSM_BO_MAP_PRIV)
prot |= IOMMU_PRIV;
 
+   if (msm_obj->flags & MSM_BO_CACHED_COHERENT)
+   prot |= IOMMU_CACHE;
+
WARN_ON(!mutex_is_locked(&msm_obj->lock));
 
if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED))
@@ -1004,6 +1007,7 @@ static int msm_gem_new_impl(struct drm_device *dev,
uint32_t size, uint32_t flags,
struct drm_gem_object **obj)
 {
+   struct msm_drm_private *priv = dev->dev_private;
struct msm_gem_object *msm_obj;
 
switch (flags & MSM_BO_CACHE_MASK) {
@@ -1011,6 +1015,10 @@ static int msm_gem_new_impl(struct drm_device *dev,
case MSM_BO_CACHED:
case MSM_BO_WC:
break;
+   case MSM_BO_CACHED_COHERENT:
+   if (priv->has_cached_coherent)
+   break;
+   /* fallthrough */
default:
DRM_DEV_ERROR(dev->dev, "invalid cache flag: %x\n",
(flags & MSM_BO_CACHE_MASK));
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index a6c1f3eb2623..474497e8743a 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -94,12 +94,11 @@ struct drm_msm_param {
 #define MSM_BO_CACHED0x0001
 #define MSM_BO_WC0x0002
 #define MSM_BO_UNCACHED  0x0004
+#define MSM_BO_CACHED_COHERENT 0x08
 
 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \
   MSM_BO_GPU_READONLY | \
-  MSM_BO_CACHED | \
-  MSM_BO_WC | \
-  MSM_BO_UNCACHED)
+  MSM_BO_CACHE_MASK)
 
 struct drm_msm_gem_new {
__u64 size;   /* in */
-- 
2.26.1

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


[PATCH v2 0/5] drm/msm: support for host-cached BOs

2020-11-08 Thread Jonathan Marek
This is to support cached and cached-coherent memory types in vulkan.

v2:
 - added patches 2/3 to enable using dma_ops_bypass
 - changed DRM_MSM_GEM_SYNC_CACHE patch to use dma_sync_sg_for_device()
   and dma_sync_sg_for_cpu(), and renamed sync flags.

Not sure I did the right thing with for the dma_ops_bypass part,
this is what I came up with reading the emails.

Jonathan Marek (5):
  drm/msm: add MSM_BO_CACHED_COHERENT
  dma-direct: add dma_direct_bypass() to force direct ops
  drm/msm: call dma_direct_bypass()
  drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance
  drm/msm: bump up the uapi version

 drivers/gpu/drm/msm/Kconfig|  1 +
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/msm_drv.c  | 32 +++---
 drivers/gpu/drm/msm/msm_drv.h  |  3 ++
 drivers/gpu/drm/msm/msm_gem.c  | 31 +
 include/linux/dma-direct.h |  9 ++
 include/uapi/drm/msm_drm.h | 25 +++--
 kernel/dma/direct.c| 23 
 8 files changed, 118 insertions(+), 7 deletions(-)

-- 
2.26.1

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


[PATCH v2 3/5] drm/msm: call dma_direct_bypass()

2020-11-08 Thread Jonathan Marek
Always use direct dma ops and no swiotlb.

Note: arm-smmu-qcom already avoids creating iommu dma ops, but not
everything uses arm-smmu-qcom and this also sets the dma mask.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/Kconfig   | 1 +
 drivers/gpu/drm/msm/msm_drv.c | 8 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
index e5816b498494..07c50405970a 100644
--- a/drivers/gpu/drm/msm/Kconfig
+++ b/drivers/gpu/drm/msm/Kconfig
@@ -20,6 +20,7 @@ config DRM_MSM
select SND_SOC_HDMI_CODEC if SND_SOC
select SYNC_FILE
select PM_OPP
+   select DMA_OPS_BYPASS
help
  DRM/KMS driver for MSM/snapdragon.
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 49685571dc0e..bae48afca82e 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1288,10 +1289,11 @@ static int msm_pdev_probe(struct platform_device *pdev)
if (ret)
goto fail;
 
-   /* on all devices that I am aware of, iommu's which can map
-* any address the cpu can see are used:
+   /* always use direct dma ops and no swiotlb
+* note: arm-smmu-qcom already avoids creating iommu dma ops, but
+* not everything uses arm-smmu-qcom and this also sets the dma mask
 */
-   ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
+   ret = dma_direct_bypass(&pdev->dev);
if (ret)
goto fail;
 
-- 
2.26.1

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


[PATCH v2 5/5] drm/msm: bump up the uapi version

2020-11-08 Thread Jonathan Marek
Increase the minor version to indicate the presence of new features.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 3f17acdf6594..7230d3c0eee5 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -39,9 +39,10 @@
  *   GEM object's debug name
  * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
  * - 1.6.0 - Syncobj support
+ * - 1.7.0 - MSM_BO_CACHED_COHERENT and DRM_IOCTL_MSM_GEM_SYNC_CACHE
  */
 #define MSM_VERSION_MAJOR  1
-#define MSM_VERSION_MINOR  6
+#define MSM_VERSION_MINOR  7
 #define MSM_VERSION_PATCHLEVEL 0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.26.1

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


[PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-11-08 Thread Jonathan Marek
This makes it possible to use the non-coherent cached MSM_BO_CACHED mode,
which otherwise doesn't provide any method for cleaning/invalidating the
cache to sync with the device.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_drv.c | 21 +
 drivers/gpu/drm/msm/msm_drv.h |  2 ++
 drivers/gpu/drm/msm/msm_gem.c | 23 +++
 include/uapi/drm/msm_drm.h| 20 
 4 files changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index bae48afca82e..3f17acdf6594 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -959,6 +959,26 @@ static int msm_ioctl_submitqueue_close(struct drm_device 
*dev, void *data,
return msm_submitqueue_remove(file->driver_priv, id);
 }
 
+static int msm_ioctl_gem_sync_cache(struct drm_device *dev, void *data,
+   struct drm_file *file)
+{
+   struct drm_msm_gem_sync_cache *args = data;
+   struct drm_gem_object *obj;
+
+   if (args->flags & ~MSM_GEM_SYNC_CACHE_FLAGS)
+   return -EINVAL;
+
+   obj = drm_gem_object_lookup(file, args->handle);
+   if (!obj)
+   return -ENOENT;
+
+   msm_gem_sync_cache(obj, args->flags, args->offset, args->end);
+
+   drm_gem_object_put(obj);
+
+   return 0;
+}
+
 static const struct drm_ioctl_desc msm_ioctls[] = {
DRM_IOCTL_DEF_DRV(MSM_GET_PARAM,msm_ioctl_get_param,
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_GEM_NEW,  msm_ioctl_gem_new,  
DRM_RENDER_ALLOW),
@@ -971,6 +991,7 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_NEW,   msm_ioctl_submitqueue_new,   
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, 
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, 
DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(MSM_GEM_SYNC_CACHE,msm_ioctl_gem_sync_cache,
DRM_RENDER_ALLOW),
 };
 
 static const struct vm_operations_struct vm_ops = {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 22ebecb28349..f170f843010e 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -318,6 +318,8 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct 
msm_gpu *gpu);
 void msm_gem_active_put(struct drm_gem_object *obj);
 int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t 
*timeout);
 int msm_gem_cpu_fini(struct drm_gem_object *obj);
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+   size_t range_start, size_t range_end);
 void msm_gem_free_object(struct drm_gem_object *obj);
 int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
uint32_t size, uint32_t flags, uint32_t *handle, char *name);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 3d8254b5de16..039738696f9a 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -797,6 +797,29 @@ int msm_gem_cpu_fini(struct drm_gem_object *obj)
return 0;
 }
 
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+   size_t range_start, size_t range_end)
+{
+   struct msm_gem_object *msm_obj = to_msm_bo(obj);
+   struct device *dev = msm_obj->base.dev->dev;
+
+   /* exit early if get_pages() hasn't been called yet */
+   if (!msm_obj->pages)
+   return;
+
+   /* TODO: sync only the specified range */
+
+   if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+   dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_TO_DEVICE);
+   }
+
+   if (flags & MSM_GEM_SYNC_FOR_CPU) {
+   dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_FROM_DEVICE);
+   }
+}
+
 #ifdef CONFIG_DEBUG_FS
 static void describe_fence(struct dma_fence *fence, const char *type,
struct seq_file *m)
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index 474497e8743a..c8288f328528 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -319,6 +319,24 @@ struct drm_msm_submitqueue_query {
__u32 pad;
 };
 
+/*
+ * Host cache maintenance (relevant for MSM_BO_CACHED)
+ * driver may both clean/invalidate (flush) for clean
+ */
+
+#define MSM_GEM_SYNC_FOR_DEVICE0x1
+#define MSM_GEM_SYNC_FOR_CPU   0x2
+
+#define MSM_GEM_SYNC_CACHE_FLAGS   (MSM_GEM_SYNC_FOR_DEVICE | \
+MSM_GEM_SYNC_FOR_CPU)
+
+struct drm_msm_gem_sync_cache {
+   __u32 handle;
+   __u32 flags;
+   __u64 offset;
+   __u64 end;  /* offset + size */
+};
+
 #define DRM_MSM_GET_PARAM  0x00
 /* placeholder

[RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-11-15 Thread Jonathan Marek
This makes it possible to use the non-coherent cached MSM_BO_CACHED mode,
which otherwise doesn't provide any method for cleaning/invalidating the
cache to sync with the device.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_drv.c | 21 +
 drivers/gpu/drm/msm/msm_drv.h |  2 ++
 drivers/gpu/drm/msm/msm_gem.c | 23 +++
 include/uapi/drm/msm_drm.h| 20 
 4 files changed, 66 insertions(+)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index bae48afca82e..3f17acdf6594 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -959,6 +959,26 @@ static int msm_ioctl_submitqueue_close(struct drm_device 
*dev, void *data,
return msm_submitqueue_remove(file->driver_priv, id);
 }
 
+static int msm_ioctl_gem_sync_cache(struct drm_device *dev, void *data,
+   struct drm_file *file)
+{
+   struct drm_msm_gem_sync_cache *args = data;
+   struct drm_gem_object *obj;
+
+   if (args->flags & ~MSM_GEM_SYNC_CACHE_FLAGS)
+   return -EINVAL;
+
+   obj = drm_gem_object_lookup(file, args->handle);
+   if (!obj)
+   return -ENOENT;
+
+   msm_gem_sync_cache(obj, args->flags, args->offset, args->end);
+
+   drm_gem_object_put(obj);
+
+   return 0;
+}
+
 static const struct drm_ioctl_desc msm_ioctls[] = {
DRM_IOCTL_DEF_DRV(MSM_GET_PARAM,msm_ioctl_get_param,
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_GEM_NEW,  msm_ioctl_gem_new,  
DRM_RENDER_ALLOW),
@@ -971,6 +991,7 @@ static const struct drm_ioctl_desc msm_ioctls[] = {
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_NEW,   msm_ioctl_submitqueue_new,   
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, 
DRM_RENDER_ALLOW),
DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, 
DRM_RENDER_ALLOW),
+   DRM_IOCTL_DEF_DRV(MSM_GEM_SYNC_CACHE,msm_ioctl_gem_sync_cache,
DRM_RENDER_ALLOW),
 };
 
 static const struct vm_operations_struct vm_ops = {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index 22ebecb28349..f170f843010e 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -318,6 +318,8 @@ void msm_gem_active_get(struct drm_gem_object *obj, struct 
msm_gpu *gpu);
 void msm_gem_active_put(struct drm_gem_object *obj);
 int msm_gem_cpu_prep(struct drm_gem_object *obj, uint32_t op, ktime_t 
*timeout);
 int msm_gem_cpu_fini(struct drm_gem_object *obj);
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+   size_t range_start, size_t range_end);
 void msm_gem_free_object(struct drm_gem_object *obj);
 int msm_gem_new_handle(struct drm_device *dev, struct drm_file *file,
uint32_t size, uint32_t flags, uint32_t *handle, char *name);
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 3d8254b5de16..039738696f9a 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -797,6 +797,29 @@ int msm_gem_cpu_fini(struct drm_gem_object *obj)
return 0;
 }
 
+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+   size_t range_start, size_t range_end)
+{
+   struct msm_gem_object *msm_obj = to_msm_bo(obj);
+   struct device *dev = msm_obj->base.dev->dev;
+
+   /* exit early if get_pages() hasn't been called yet */
+   if (!msm_obj->pages)
+   return;
+
+   /* TODO: sync only the specified range */
+
+   if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+   dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_TO_DEVICE);
+   }
+
+   if (flags & MSM_GEM_SYNC_FOR_CPU) {
+   dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+   msm_obj->sgt->nents, DMA_FROM_DEVICE);
+   }
+}
+
 #ifdef CONFIG_DEBUG_FS
 static void describe_fence(struct dma_fence *fence, const char *type,
struct seq_file *m)
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index 474497e8743a..c8288f328528 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -319,6 +319,24 @@ struct drm_msm_submitqueue_query {
__u32 pad;
 };
 
+/*
+ * Host cache maintenance (relevant for MSM_BO_CACHED)
+ * driver may both clean/invalidate (flush) for clean
+ */
+
+#define MSM_GEM_SYNC_FOR_DEVICE0x1
+#define MSM_GEM_SYNC_FOR_CPU   0x2
+
+#define MSM_GEM_SYNC_CACHE_FLAGS   (MSM_GEM_SYNC_FOR_DEVICE | \
+MSM_GEM_SYNC_FOR_CPU)
+
+struct drm_msm_gem_sync_cache {
+   __u32 handle;
+   __u32 flags;
+   __u64 offset;
+   __u64 end;  /* offset + size */
+};
+
 #define DRM_MSM_GET_PARAM  0x00
 /* placeholder

[RESEND PATCH v2 5/5] drm/msm: bump up the uapi version

2020-11-15 Thread Jonathan Marek
Increase the minor version to indicate the presence of new features.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_drv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 3f17acdf6594..7230d3c0eee5 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -39,9 +39,10 @@
  *   GEM object's debug name
  * - 1.5.0 - Add SUBMITQUERY_QUERY ioctl
  * - 1.6.0 - Syncobj support
+ * - 1.7.0 - MSM_BO_CACHED_COHERENT and DRM_IOCTL_MSM_GEM_SYNC_CACHE
  */
 #define MSM_VERSION_MAJOR  1
-#define MSM_VERSION_MINOR  6
+#define MSM_VERSION_MINOR  7
 #define MSM_VERSION_PATCHLEVEL 0
 
 static const struct drm_mode_config_funcs mode_config_funcs = {
-- 
2.26.1

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


Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-11-15 Thread Jonathan Marek

On 11/14/20 2:39 PM, Rob Clark wrote:

On Sat, Nov 14, 2020 at 10:58 AM Jonathan Marek  wrote:


On 11/14/20 1:46 PM, Rob Clark wrote:

On Sat, Nov 14, 2020 at 8:24 AM Christoph Hellwig  wrote:


On Sat, Nov 14, 2020 at 10:17:12AM -0500, Jonathan Marek wrote:

+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+ size_t range_start, size_t range_end)
+{
+ struct msm_gem_object *msm_obj = to_msm_bo(obj);
+ struct device *dev = msm_obj->base.dev->dev;
+
+ /* exit early if get_pages() hasn't been called yet */
+ if (!msm_obj->pages)
+ return;
+
+ /* TODO: sync only the specified range */
+
+ if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+ dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+ msm_obj->sgt->nents, DMA_TO_DEVICE);
+ }
+
+ if (flags & MSM_GEM_SYNC_FOR_CPU) {
+ dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+ msm_obj->sgt->nents, DMA_FROM_DEVICE);
+ }


Splitting this helper from the only caller is rather strange, epecially
with the two unused arguments.  And I think the way this is specified
to take a range, but ignoring it is actively dangerous.  User space will
rely on it syncing everything sooner or later and then you are stuck.
So just define a sync all primitive for now, and if you really need a
range sync and have actually implemented it add a new ioctl for that.


We do already have a split of ioctl "layer" which enforces valid ioctl
params, etc, and gem (or other) module code which is called by the
ioctl func.  So I think it is fine to keep this split here.  (Also, I
think at some point there will be a uring type of ioctl alternative
which would re-use the same gem func.)

But I do agree that the range should be respected or added later..
drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned
to cache-line?  Or can we flush a partial cache line?



The range is intended to be "sync at least this range", so that
userspace doesn't have to worry about details like that.



I don't think userspace can *not* worry about details like that.
Consider a case where the cpu and gpu are simultaneously accessing
different parts of a buffer (for ex, sub-allocation).  There needs to
be cache-line separation between the two.



Right.. and it also seems like we can't get away with just 
flushing/invalidating the whole thing.


qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like 
dma_sync_single_for_cpu() does deal in some way with the partial cache 
line case, although I'm not sure that means we can have a 
nonCoherentAtomSize=1.



BR,
-R


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


[RESEND PATCH v2 1/5] drm/msm: add MSM_BO_CACHED_COHERENT

2020-11-15 Thread Jonathan Marek
Add a new cache mode for creating coherent host-cached BOs.

Signed-off-by: Jonathan Marek 
Reviewed-by: Jordan Crouse 
---
 drivers/gpu/drm/msm/adreno/adreno_device.c | 1 +
 drivers/gpu/drm/msm/msm_drv.h  | 1 +
 drivers/gpu/drm/msm/msm_gem.c  | 8 
 include/uapi/drm/msm_drm.h | 5 ++---
 4 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 58e03b20e1c7..21c9bc954f38 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -410,6 +410,7 @@ static int adreno_bind(struct device *dev, struct device 
*master, void *data)
config.rev.minor, config.rev.patchid);
 
priv->is_a2xx = config.rev.core == 2;
+   priv->has_cached_coherent = config.rev.core >= 6;
 
gpu = info->init(drm);
if (IS_ERR(gpu)) {
diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
index f33281ac7913..22ebecb28349 100644
--- a/drivers/gpu/drm/msm/msm_drv.h
+++ b/drivers/gpu/drm/msm/msm_drv.h
@@ -168,6 +168,7 @@ struct msm_drm_private {
struct msm_file_private *lastctx;
/* gpu is only set on open(), but we need this info earlier */
bool is_a2xx;
+   bool has_cached_coherent;
 
struct drm_fb_helper *fbdev;
 
diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 04be4cf1..3d8254b5de16 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -420,6 +420,9 @@ static int msm_gem_pin_iova(struct drm_gem_object *obj,
if (msm_obj->flags & MSM_BO_MAP_PRIV)
prot |= IOMMU_PRIV;
 
+   if (msm_obj->flags & MSM_BO_CACHED_COHERENT)
+   prot |= IOMMU_CACHE;
+
WARN_ON(!mutex_is_locked(&msm_obj->lock));
 
if (WARN_ON(msm_obj->madv != MSM_MADV_WILLNEED))
@@ -1004,6 +1007,7 @@ static int msm_gem_new_impl(struct drm_device *dev,
uint32_t size, uint32_t flags,
struct drm_gem_object **obj)
 {
+   struct msm_drm_private *priv = dev->dev_private;
struct msm_gem_object *msm_obj;
 
switch (flags & MSM_BO_CACHE_MASK) {
@@ -1011,6 +1015,10 @@ static int msm_gem_new_impl(struct drm_device *dev,
case MSM_BO_CACHED:
case MSM_BO_WC:
break;
+   case MSM_BO_CACHED_COHERENT:
+   if (priv->has_cached_coherent)
+   break;
+   /* fallthrough */
default:
DRM_DEV_ERROR(dev->dev, "invalid cache flag: %x\n",
(flags & MSM_BO_CACHE_MASK));
diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h
index a6c1f3eb2623..474497e8743a 100644
--- a/include/uapi/drm/msm_drm.h
+++ b/include/uapi/drm/msm_drm.h
@@ -94,12 +94,11 @@ struct drm_msm_param {
 #define MSM_BO_CACHED0x0001
 #define MSM_BO_WC0x0002
 #define MSM_BO_UNCACHED  0x0004
+#define MSM_BO_CACHED_COHERENT 0x08
 
 #define MSM_BO_FLAGS (MSM_BO_SCANOUT | \
   MSM_BO_GPU_READONLY | \
-  MSM_BO_CACHED | \
-  MSM_BO_WC | \
-  MSM_BO_UNCACHED)
+  MSM_BO_CACHE_MASK)
 
 struct drm_msm_gem_new {
__u64 size;   /* in */
-- 
2.26.1

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


[RESEND PATCH v2 0/5] drm/msm: support for host-cached BOs

2020-11-15 Thread Jonathan Marek
v2:
 - added patches 2/3 to enable using dma_ops_bypass
 - changed DRM_MSM_GEM_SYNC_CACHE patch to use dma_sync_sg_for_device()
   and dma_sync_sg_for_cpu(), and renamed sync flags.

Not sure I did the right thing with for the dma_ops_bypass part,
this is what I came up with reading the emails.

Jonathan Marek (5):
  drm/msm: add MSM_BO_CACHED_COHERENT
  dma-direct: add dma_direct_bypass() to force direct ops
  drm/msm: call dma_direct_bypass()
  drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance
  drm/msm: bump up the uapi version

 drivers/gpu/drm/msm/Kconfig|  1 +
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/msm_drv.c  | 32 +++---
 drivers/gpu/drm/msm/msm_drv.h  |  3 ++
 drivers/gpu/drm/msm/msm_gem.c  | 31 +
 include/linux/dma-direct.h |  9 ++
 include/uapi/drm/msm_drm.h | 25 +++--
 kernel/dma/direct.c| 23 
 8 files changed, 118 insertions(+), 7 deletions(-)

-- 
2.26.1

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


[RESEND PATCH v2 3/5] drm/msm: call dma_direct_bypass()

2020-11-15 Thread Jonathan Marek
Always use direct dma ops and no swiotlb.

Note: arm-smmu-qcom already avoids creating iommu dma ops, but not
everything uses arm-smmu-qcom and this also sets the dma mask.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/Kconfig   | 1 +
 drivers/gpu/drm/msm/msm_drv.c | 8 +---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/Kconfig b/drivers/gpu/drm/msm/Kconfig
index e5816b498494..07c50405970a 100644
--- a/drivers/gpu/drm/msm/Kconfig
+++ b/drivers/gpu/drm/msm/Kconfig
@@ -20,6 +20,7 @@ config DRM_MSM
select SND_SOC_HDMI_CODEC if SND_SOC
select SYNC_FILE
select PM_OPP
+   select DMA_OPS_BYPASS
help
  DRM/KMS driver for MSM/snapdragon.
 
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index 49685571dc0e..bae48afca82e 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -6,6 +6,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -1288,10 +1289,11 @@ static int msm_pdev_probe(struct platform_device *pdev)
if (ret)
goto fail;
 
-   /* on all devices that I am aware of, iommu's which can map
-* any address the cpu can see are used:
+   /* always use direct dma ops and no swiotlb
+* note: arm-smmu-qcom already avoids creating iommu dma ops, but
+* not everything uses arm-smmu-qcom and this also sets the dma mask
 */
-   ret = dma_set_mask_and_coherent(&pdev->dev, ~0);
+   ret = dma_direct_bypass(&pdev->dev);
if (ret)
goto fail;
 
-- 
2.26.1

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


Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-11-15 Thread Jonathan Marek

On 11/14/20 1:46 PM, Rob Clark wrote:

On Sat, Nov 14, 2020 at 8:24 AM Christoph Hellwig  wrote:


On Sat, Nov 14, 2020 at 10:17:12AM -0500, Jonathan Marek wrote:

+void msm_gem_sync_cache(struct drm_gem_object *obj, uint32_t flags,
+ size_t range_start, size_t range_end)
+{
+ struct msm_gem_object *msm_obj = to_msm_bo(obj);
+ struct device *dev = msm_obj->base.dev->dev;
+
+ /* exit early if get_pages() hasn't been called yet */
+ if (!msm_obj->pages)
+ return;
+
+ /* TODO: sync only the specified range */
+
+ if (flags & MSM_GEM_SYNC_FOR_DEVICE) {
+ dma_sync_sg_for_device(dev, msm_obj->sgt->sgl,
+ msm_obj->sgt->nents, DMA_TO_DEVICE);
+ }
+
+ if (flags & MSM_GEM_SYNC_FOR_CPU) {
+ dma_sync_sg_for_cpu(dev, msm_obj->sgt->sgl,
+ msm_obj->sgt->nents, DMA_FROM_DEVICE);
+ }


Splitting this helper from the only caller is rather strange, epecially
with the two unused arguments.  And I think the way this is specified
to take a range, but ignoring it is actively dangerous.  User space will
rely on it syncing everything sooner or later and then you are stuck.
So just define a sync all primitive for now, and if you really need a
range sync and have actually implemented it add a new ioctl for that.


We do already have a split of ioctl "layer" which enforces valid ioctl
params, etc, and gem (or other) module code which is called by the
ioctl func.  So I think it is fine to keep this split here.  (Also, I
think at some point there will be a uring type of ioctl alternative
which would re-use the same gem func.)

But I do agree that the range should be respected or added later..
drm_ioctl() dispatch is well prepared for extending ioctls.

And I assume there should be some validation that the range is aligned
to cache-line?  Or can we flush a partial cache line?



The range is intended to be "sync at least this range", so that 
userspace doesn't have to worry about details like that.



BR,
-R


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


Re: [RESEND PATCH v2 4/5] drm/msm: add DRM_MSM_GEM_SYNC_CACHE for non-coherent cache maintenance

2020-11-17 Thread Jonathan Marek

On 11/16/20 12:50 PM, Rob Clark wrote:

On Mon, Nov 16, 2020 at 9:33 AM Christoph Hellwig  wrote:


On Sat, Nov 14, 2020 at 03:07:20PM -0500, Jonathan Marek wrote:

qcom's vulkan driver has nonCoherentAtomSize=1, and it looks like
dma_sync_single_for_cpu() does deal in some way with the partial cache line
case, although I'm not sure that means we can have a nonCoherentAtomSize=1.


No, it doesn't.  You need to ensure ownership is managed at
dma_get_cache_alignment() granularity.


my guess is nonCoherentAtomSize=1 only works in the case of cache
coherent buffers



nonCoherentAtomSize doesn't apply to coherent memory (as the name 
implies), I guess qcom's driver is just wrong about having 
nonCoherentAtomSize=1.


Jordan just mentioned there is at least one conformance test for this, I 
wonder if it just doesn't test it well enough, or just doesn't test the 
non-coherent memory type?

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


[PATCH 0/4] drm/msm/adreno: add support for a730

2022-03-27 Thread Jonathan Marek
Based on a6xx_gpu.c, stripped down and updated for a7xx based on the
downstream driver. Implements the minimum to be able to submit commands to
the GPU and use it for userspace driver development. Notably this doesn't
implement support for the GMU (this means that the clock driver needs to
support the GPU core clock and turning on the GX rail, which is normally
offloaded to the GMU).

Register updates: 
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15602

Jonathan Marek (4):
  drm/msm/adreno: move a6xx CP_PROTECT macros to common code
  drm/msm/adreno: use a single register offset for
gpu_read64/gpu_write64
  drm/msm/adreno: update headers
  drm/msm/adreno: add support for a730

 drivers/gpu/drm/msm/Makefile|   1 +
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c   |   3 +-
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   |  27 +-
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c   |   4 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c   |  25 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h   |  17 -
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c |   3 +-
 drivers/gpu/drm/msm/adreno/a7xx.xml.h   | 666 +
 drivers/gpu/drm/msm/adreno/a7xx_gpu.c   | 777 
 drivers/gpu/drm/msm/adreno/a7xx_gpu.h   |  26 +
 drivers/gpu/drm/msm/adreno/adreno_device.c  |  12 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.h |   9 +-
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h |  45 +-
 drivers/gpu/drm/msm/msm_gpu.h   |  12 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h|   1 +
 15 files changed, 1550 insertions(+), 78 deletions(-)
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx.xml.h
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx_gpu.c
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx_gpu.h

-- 
2.26.1



[PATCH 1/4] drm/msm/adreno: move a6xx CP_PROTECT macros to common code

2022-03-27 Thread Jonathan Marek
These will be used by a7xx, so move them to common code. A6XX_ prefix is
kept because the generic ADRENO_ is already in use.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.h   | 17 -
 drivers/gpu/drm/msm/adreno/adreno_gpu.h |  6 ++
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
index 86e0a7c3fe6df..d117c1589f2af 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h
@@ -36,23 +36,6 @@ struct a6xx_gpu {
 
 #define to_a6xx_gpu(x) container_of(x, struct a6xx_gpu, base)
 
-/*
- * Given a register and a count, return a value to program into
- * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len
- * registers starting at _reg.
- */
-#define A6XX_PROTECT_NORDWR(_reg, _len) \
-   ((1 << 31) | \
-   (((_len) & 0x3FFF) << 18) | ((_reg) & 0x3))
-
-/*
- * Same as above, but allow reads over the range. For areas of mixed use (such
- * as performance counters) this allows us to protect a much larger range with 
a
- * single register
- */
-#define A6XX_PROTECT_RDONLY(_reg, _len) \
-   _len) & 0x3FFF) << 18) | ((_reg) & 0x3))
-
 static inline bool a6xx_has_gbif(struct adreno_gpu *gpu)
 {
if(adreno_is_a630(gpu))
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index 0490c5fbb7803..55c5433a4ea18 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -416,6 +416,10 @@ static inline uint32_t get_wptr(struct msm_ringbuffer 
*ring)
((1 << 30) | (1 << 29) | \
((ilog2((_len)) & 0x1F) << 24) | (((_reg) << 2) & 0xF))
 
+#define A6XX_PROTECT_NORDWR(_reg, _len) \
+   ((1 << 31) | \
+   (((_len) & 0x3FFF) << 18) | ((_reg) & 0x3))
+
 /*
  * Same as above, but allow reads over the range. For areas of mixed use (such
  * as performance counters) this allows us to protect a much larger range with 
a
@@ -425,6 +429,8 @@ static inline uint32_t get_wptr(struct msm_ringbuffer *ring)
((1 << 29) \
((ilog2((_len)) & 0x1F) << 24) | (((_reg) << 2) & 0xF))
 
+#define A6XX_PROTECT_RDONLY(_reg, _len) \
+   _len) & 0x3FFF) << 18) | ((_reg) & 0x3))
 
 #define gpu_poll_timeout(gpu, addr, val, cond, interval, timeout) \
readl_poll_timeout((gpu)->mmio + ((addr) << 2), val, cond, \
-- 
2.26.1



[PATCH 2/4] drm/msm/adreno: use a single register offset for gpu_read64/gpu_write64

2022-03-27 Thread Jonathan Marek
The high half of 64-bit registers is always at +1 offset, so change these
helpers to be more convenient by removing the unnecessary argument.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a4xx_gpu.c   |  3 +--
 drivers/gpu/drm/msm/adreno/a5xx_gpu.c   | 27 -
 drivers/gpu/drm/msm/adreno/a5xx_preempt.c   |  4 +--
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c   | 25 ++-
 drivers/gpu/drm/msm/adreno/a6xx_gpu_state.c |  3 +--
 drivers/gpu/drm/msm/msm_gpu.h   | 12 -
 6 files changed, 27 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
index 0c6b2a6d0b4c9..da5e18bd74a45 100644
--- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c
@@ -606,8 +606,7 @@ static int a4xx_pm_suspend(struct msm_gpu *gpu) {
 
 static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)
 {
-   *value = gpu_read64(gpu, REG_A4XX_RBBM_PERFCTR_CP_0_LO,
-   REG_A4XX_RBBM_PERFCTR_CP_0_HI);
+   *value = gpu_read64(gpu, REG_A4XX_RBBM_PERFCTR_CP_0_LO);
 
return 0;
 }
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index 407f50a15faa4..1916cb759cd5c 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -605,11 +605,9 @@ static int a5xx_ucode_init(struct msm_gpu *gpu)
a5xx_ucode_check_version(a5xx_gpu, a5xx_gpu->pfp_bo);
}
 
-   gpu_write64(gpu, REG_A5XX_CP_ME_INSTR_BASE_LO,
-   REG_A5XX_CP_ME_INSTR_BASE_HI, a5xx_gpu->pm4_iova);
+   gpu_write64(gpu, REG_A5XX_CP_ME_INSTR_BASE_LO, a5xx_gpu->pm4_iova);
 
-   gpu_write64(gpu, REG_A5XX_CP_PFP_INSTR_BASE_LO,
-   REG_A5XX_CP_PFP_INSTR_BASE_HI, a5xx_gpu->pfp_iova);
+   gpu_write64(gpu, REG_A5XX_CP_PFP_INSTR_BASE_LO, a5xx_gpu->pfp_iova);
 
return 0;
 }
@@ -868,8 +866,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
 * memory rendering at this point in time and we don't want to block off
 * part of the virtual memory space.
 */
-   gpu_write64(gpu, REG_A5XX_RBBM_SECVID_TSB_TRUSTED_BASE_LO,
-   REG_A5XX_RBBM_SECVID_TSB_TRUSTED_BASE_HI, 0x);
+   gpu_write64(gpu, REG_A5XX_RBBM_SECVID_TSB_TRUSTED_BASE_LO, 0x);
gpu_write(gpu, REG_A5XX_RBBM_SECVID_TSB_TRUSTED_SIZE, 0x);
 
/* Put the GPU into 64 bit by default */
@@ -908,8 +905,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
return ret;
 
/* Set the ringbuffer address */
-   gpu_write64(gpu, REG_A5XX_CP_RB_BASE, REG_A5XX_CP_RB_BASE_HI,
-   gpu->rb[0]->iova);
+   gpu_write64(gpu, REG_A5XX_CP_RB_BASE, gpu->rb[0]->iova);
 
/*
 * If the microcode supports the WHERE_AM_I opcode then we can use that
@@ -936,7 +932,7 @@ static int a5xx_hw_init(struct msm_gpu *gpu)
}
 
gpu_write64(gpu, REG_A5XX_CP_RB_RPTR_ADDR,
-   REG_A5XX_CP_RB_RPTR_ADDR_HI, shadowptr(a5xx_gpu, 
gpu->rb[0]));
+   shadowptr(a5xx_gpu, gpu->rb[0]));
} else if (gpu->nr_rings > 1) {
/* Disable preemption if WHERE_AM_I isn't available */
a5xx_preempt_fini(gpu);
@@ -1239,9 +1235,9 @@ static void a5xx_fault_detect_irq(struct msm_gpu *gpu)
gpu_read(gpu, REG_A5XX_RBBM_STATUS),
gpu_read(gpu, REG_A5XX_CP_RB_RPTR),
gpu_read(gpu, REG_A5XX_CP_RB_WPTR),
-   gpu_read64(gpu, REG_A5XX_CP_IB1_BASE, REG_A5XX_CP_IB1_BASE_HI),
+   gpu_read64(gpu, REG_A5XX_CP_IB1_BASE),
gpu_read(gpu, REG_A5XX_CP_IB1_BUFSZ),
-   gpu_read64(gpu, REG_A5XX_CP_IB2_BASE, REG_A5XX_CP_IB2_BASE_HI),
+   gpu_read64(gpu, REG_A5XX_CP_IB2_BASE),
gpu_read(gpu, REG_A5XX_CP_IB2_BUFSZ));
 
/* Turn off the hangcheck timer to keep it from bothering us */
@@ -1427,8 +1423,7 @@ static int a5xx_pm_suspend(struct msm_gpu *gpu)
 
 static int a5xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)
 {
-   *value = gpu_read64(gpu, REG_A5XX_RBBM_ALWAYSON_COUNTER_LO,
-   REG_A5XX_RBBM_ALWAYSON_COUNTER_HI);
+   *value = gpu_read64(gpu, REG_A5XX_RBBM_ALWAYSON_COUNTER_LO);
 
return 0;
 }
@@ -1465,8 +1460,7 @@ static int a5xx_crashdumper_run(struct msm_gpu *gpu,
if (IS_ERR_OR_NULL(dumper->ptr))
return -EINVAL;
 
-   gpu_write64(gpu, REG_A5XX_CP_CRASH_SCRIPT_BASE_LO,
-   REG_A5XX_CP_CRASH_SCRIPT_BASE_HI, dumper->iova);
+   gpu_write64(gpu, REG_A5XX_CP_CRASH_SCRIPT_BASE_LO, dumper->iova);
 
gpu_write(gpu, REG_A5XX_CP_CRASH_DUMP_CNTL, 1);
 
@@ -1670,8 +1664,7 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu)
if (pm_runtime_get_if_in_use(&gpu->pdev->dev) ==

[PATCH 3/4] drm/msm/adreno: update headers

2022-03-27 Thread Jonathan Marek
Adds a7xx changes for the kernel driver.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a7xx.xml.h   | 666 
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h |  63 +-
 2 files changed, 716 insertions(+), 13 deletions(-)
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx.xml.h

diff --git a/drivers/gpu/drm/msm/adreno/a7xx.xml.h 
b/drivers/gpu/drm/msm/adreno/a7xx.xml.h
new file mode 100644
index 0..45ef4289ac52b
--- /dev/null
+++ b/drivers/gpu/drm/msm/adreno/a7xx.xml.h
@@ -0,0 +1,666 @@
+#ifndef A7XX_XML
+#define A7XX_XML
+
+/* Autogenerated file, DO NOT EDIT manually!
+
+This file was generated by the rules-ng-ng headergen tool in this git 
repository:
+http://github.com/freedreno/envytools/
+git clone https://github.com/freedreno/envytools.git
+
+The rules-ng-ng source files this header was generated from are:
+- freedreno/registers/adreno.xml (627 bytes, from 
2022-03-27 15:04:47)
+- freedreno/registers/freedreno_copyright.xml(   1572 bytes, from 
2020-11-18 00:17:12)
+- freedreno/registers/adreno/a2xx.xml(  90810 bytes, from 
2021-08-06 17:44:41)
+- freedreno/registers/adreno/adreno_common.xml   (  14631 bytes, from 
2022-03-27 14:52:08)
+- freedreno/registers/adreno/adreno_pm4.xml  (  70334 bytes, from 
2022-03-27 20:01:26)
+- freedreno/registers/adreno/a3xx.xml(  84231 bytes, from 
2021-08-27 13:03:56)
+- freedreno/registers/adreno/a4xx.xml( 113474 bytes, from 
2022-03-22 19:23:46)
+- freedreno/registers/adreno/a5xx.xml( 149512 bytes, from 
2022-03-21 16:05:18)
+- freedreno/registers/adreno/a6xx.xml( 184954 bytes, from 
2022-03-22 19:23:46)
+- freedreno/registers/adreno/a6xx_gmu.xml(  11331 bytes, from 
2021-08-06 17:44:41)
+- freedreno/registers/adreno/a7xx.xml(  20004 bytes, from 
2022-03-27 20:01:42)
+- freedreno/registers/adreno/ocmem.xml   (   1773 bytes, from 
2020-11-18 00:17:12)
+- freedreno/registers/adreno/adreno_control_regs.xml (   6038 bytes, from 
2022-03-22 19:23:46)
+- freedreno/registers/adreno/adreno_pipe_regs.xml(   2924 bytes, from 
2022-03-22 19:23:46)
+
+Copyright (C) 2013-2022 by the following authors:
+- Rob Clark  (robclark)
+- Ilia Mirkin  (imirkin)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial
+portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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.
+*/
+
+
+enum a7xx_event {
+   CCU_INVALIDATE_DEPTH = 24,
+   CCU_INVALIDATE_COLOR = 25,
+   CCU_RESOLVE_CLEAN = 26,
+   CCU_FLUSH_DEPTH = 28,
+   CCU_FLUSH_COLOR = 29,
+   CCU_RESOLVE = 30,
+   CCU_END_RESOLVE_GROUP = 31,
+   CCU_CLEAN_DEPTH = 32,
+   CCU_CLEAN_COLOR = 33,
+   CACHE_RESET = 48,
+   CACHE_CLEAN = 49,
+   CACHE_FLUSH7 = 50,
+   CACHE_INVALIDATE7 = 51,
+};
+
+#define REG_A7XX_RBBM_GBIF_CLIENT_QOS_CNTL 0x0011
+
+#define REG_A7XX_RBBM_GBIF_HALT
0x0016
+
+#define REG_A7XX_RBBM_GBIF_HALT_ACK0x0017
+
+#define REG_A7XX_RBBM_INTERFACE_HANG_INT_CNTL  0x001f
+
+#define REG_A7XX_RBBM_INT_CLEAR_CMD0x0037
+
+#define REG_A7XX_RBBM_INT_0_MASK   0x0038
+#define A7XX_RBBM_INT_0_MASK_GPUIDLE   0x0001
+#define A7XX_RBBM_INT_0_MASK_AHBERROR  0x0002
+#define A7XX_RBBM_INT_0_MASK_CPIPCINT0 0x0010
+#define A7XX_RBBM_INT_0_MASK_CPIPCINT1 0x0020
+#define A7XX_RBBM_INT_0_MASK_ATBASYNCFIFOOVERFLOW  0x0040
+#define A7XX_RBBM_INT_0_MASK_GPCERROR  0x0080
+#define A7XX_RBBM_INT_0_MASK_SWINTERRUPT   0x0100
+#define A7XX_RBBM_INT_0_MASK_HWERROR   0x0200
+#define A7XX_RBBM_INT_0_MAS

[PATCH 4/4] drm/msm/adreno: add support for a730

2022-03-27 Thread Jonathan Marek
Based on a6xx_gpu.c, stripped down and updated for a7xx based on the
downstream driver. Implements the minimum to be able to submit commands to
the GPU and use it for userspace driver development. Notably this doesn't
implement support for the GMU (this means that the clock driver needs to
support the GPU core clock and turning on the GX rail, which is normally
offloaded to the GMU).

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/Makefile|   1 +
 drivers/gpu/drm/msm/adreno/a7xx_gpu.c   | 777 
 drivers/gpu/drm/msm/adreno/a7xx_gpu.h   |  26 +
 drivers/gpu/drm/msm/adreno/adreno_device.c  |  12 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.h |   3 +-
 drivers/gpu/drm/msm/adreno/adreno_pm4.xml.h |  20 +-
 drivers/gpu/drm/msm/msm_ringbuffer.h|   1 +
 7 files changed, 820 insertions(+), 20 deletions(-)
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx_gpu.c
 create mode 100644 drivers/gpu/drm/msm/adreno/a7xx_gpu.h

diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile
index e9cc7d8ac301e..b91e543e42265 100644
--- a/drivers/gpu/drm/msm/Makefile
+++ b/drivers/gpu/drm/msm/Makefile
@@ -16,6 +16,7 @@ msm-y := \
adreno/a6xx_gpu.o \
adreno/a6xx_gmu.o \
adreno/a6xx_hfi.o \
+   adreno/a7xx_gpu.o \
hdmi/hdmi.o \
hdmi/hdmi_audio.o \
hdmi/hdmi_bridge.o \
diff --git a/drivers/gpu/drm/msm/adreno/a7xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a7xx_gpu.c
new file mode 100644
index 0..16bdce21b06f2
--- /dev/null
+++ b/drivers/gpu/drm/msm/adreno/a7xx_gpu.c
@@ -0,0 +1,777 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2017-2022 The Linux Foundation. All rights reserved. */
+
+#include "msm_gem.h"
+#include "msm_mmu.h"
+#include "msm_gpu_trace.h"
+#include "a7xx_gpu.h"
+
+#include 
+
+extern bool hang_debug;
+
+#define GPU_PAS_ID 13
+
+static inline bool _a7xx_check_idle(struct msm_gpu *gpu)
+{
+   /* Check that the CX master is idle */
+   if (gpu_read(gpu, REG_A7XX_RBBM_STATUS) & 
~A7XX_RBBM_STATUS_CPAHBBUSYCXMASTER)
+   return false;
+
+   return !(gpu_read(gpu, REG_A7XX_RBBM_INT_0_STATUS) & 
A7XX_RBBM_INT_0_MASK_HANGDETECTINTERRUPT);
+}
+
+static bool a7xx_idle(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
+{
+   /* wait for CP to drain ringbuffer: */
+   if (!adreno_idle(gpu, ring))
+   return false;
+
+   if (spin_until(_a7xx_check_idle(gpu))) {
+   DRM_ERROR("%s: %ps: timeout waiting for GPU to idle: status 
%8.8X irq %8.8X rptr/wptr %d/%d\n",
+   gpu->name, __builtin_return_address(0),
+   gpu_read(gpu, REG_A7XX_RBBM_STATUS),
+   gpu_read(gpu, REG_A7XX_RBBM_INT_0_STATUS),
+   gpu_read(gpu, REG_A7XX_CP_RB_RPTR),
+   gpu_read(gpu, REG_A7XX_CP_RB_WPTR));
+   return false;
+   }
+
+   return true;
+}
+
+static void a7xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit)
+{
+   struct msm_ringbuffer *ring = submit->ring;
+   unsigned int i;
+
+   OUT_PKT7(ring, CP_THREAD_CONTROL, 1);
+   OUT_RING(ring, CP_SET_THREAD_BOTH);
+
+   OUT_PKT7(ring, CP_SET_MARKER, 1);
+   OUT_RING(ring, 0x101); /* IFPC disable */
+
+   OUT_PKT7(ring, CP_SET_MARKER, 1);
+   OUT_RING(ring, 0x00d); /* IB1LIST start */
+
+   /* Submit the commands */
+   for (i = 0; i < submit->nr_cmds; i++) {
+   switch (submit->cmd[i].type) {
+   case MSM_SUBMIT_CMD_IB_TARGET_BUF:
+   break;
+   case MSM_SUBMIT_CMD_CTX_RESTORE_BUF:
+   if (gpu->cur_ctx_seqno == submit->queue->ctx->seqno)
+   break;
+   fallthrough;
+   case MSM_SUBMIT_CMD_BUF:
+   OUT_PKT7(ring, CP_INDIRECT_BUFFER_PFE, 3);
+   OUT_RING(ring, lower_32_bits(submit->cmd[i].iova));
+   OUT_RING(ring, upper_32_bits(submit->cmd[i].iova));
+   OUT_RING(ring, submit->cmd[i].size);
+   break;
+   }
+   }
+
+   OUT_PKT7(ring, CP_SET_MARKER, 1);
+   OUT_RING(ring, 0x00e); /* IB1LIST end */
+
+   OUT_PKT7(ring, CP_THREAD_CONTROL, 1);
+   OUT_RING(ring, CP_SET_THREAD_BR);
+
+   OUT_PKT7(ring, CP_EVENT_WRITE, 1);
+   OUT_RING(ring, CCU_INVALIDATE_DEPTH);
+
+   OUT_PKT7(ring, CP_EVENT_WRITE, 1);
+   OUT_RING(ring, CCU_INVALIDATE_COLOR);
+
+   OUT_PKT7(ring, CP_THREAD_CONTROL, 1);
+   OUT_RING(ring, CP_SET_THREAD_BV);
+
+   /*
+* Make sure the timestamp is committed once BV pipe is
+* completely done with this submission.
+*/
+   OUT_PKT7(ring, CP_EVENT_WRITE, 4);
+   OUT_RING(ring, CACHE_CLEAN | BIT(27));
+   OUT_RING

[PATCH] drm/msm: use orig_nents to iterate over scatterlist with per-process tables

2022-03-28 Thread Jonathan Marek
This matches the implementation of iommu_map_sgtable() used for the
non-per-process page tables path.

This works around the dma_map_sgtable() call (used to invalidate cache)
overwriting sgt->nents with 1 (which is probably a separate issue).

Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/msm_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index bcaddbba564df..22935ef26a3a1 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 
iova,
u64 addr = iova;
unsigned int i;
 
-   for_each_sg(sgt->sgl, sg, sgt->nents, i) {
+   for_each_sg(sgt->sgl, sg, sgt->orig_nents, i) {
size_t size = sg->length;
phys_addr_t phys = sg_phys(sg);
 
-- 
2.26.1



Re: [PATCH] qcom-scm: Include header

2019-01-01 Thread Jonathan marek
FYI, I already had a patch fixing this error (it is in linux-next: 
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/include/linux/qcom_scm.h). 
This one is probably better though.


On 12/28/2018 02:31 PM, Bjorn Andersson wrote:

On Wed 26 Dec 04:06 PST 2018, Fabio Estevam wrote:


Since commit e6f6d63ed14c ("drm/msm: add headless gpu device for imx5")
the DRM_MSM symbol can be selected by SOC_IMX5 causing the following
error when building imx_v6_v7_defconfig:

In file included from ../drivers/gpu/drm/msm/adreno/a5xx_gpu.c:17:0:
../include/linux/qcom_scm.h: In function 'qcom_scm_set_cold_boot_addr':
../include/linux/qcom_scm.h:73:10: error: 'ENODEV' undeclared (first use in 
this function)
   return -ENODEV;

Include the  header file to fix this problem.



Reviewed-by: Bjorn Andersson 

Andy, please pick up for inclusion in -rc

Fabio, please use get_maintainers, so your patches hits the appropriate
mailing lists (linux-arm-msm@ in this case)

Regards,
Bjorn


Reported-by: kernelci.org bot 
Fixes: e6f6d63ed14c ("drm/msm: add headless gpu device for imx5")
Signed-off-by: Fabio Estevam 
---
  include/linux/qcom_scm.h | 1 +
  1 file changed, 1 insertion(+)

diff --git a/include/linux/qcom_scm.h b/include/linux/qcom_scm.h
index 06996ad4f2bc..ce5a476fd733 100644
--- a/include/linux/qcom_scm.h
+++ b/include/linux/qcom_scm.h
@@ -13,6 +13,7 @@
  #ifndef __QCOM_SCM_H
  #define __QCOM_SCM_H
  
+#include 

  #include 
  #include 
  
--

2.17.1


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


Re: [RFC PATCH v1 09/15] drm/msm/gpu: Move address space setup to the GPU targets

2019-03-03 Thread Jonathan Marek
There is an error in the a2xx part of this patch: 0xfff in adreno_gpu.c 
became 0xff in a2xx_gpu.c


On 3/1/19 2:38 PM, Jordan Crouse wrote:

Move the address space steup code out of the generic msm GPU code to
to the individual GPU targets. This allows us to do target specific
setup such as gpummu for a2xx or split pagetables and per-instance
pagetables for newer a5xx and a6xx targets. All this is at the
expense of duplicated code in some of the target files but I think
it pays for itself in improved code flow and flexibility.

Signed-off-by: Jordan Crouse 
---

  drivers/gpu/drm/msm/adreno/a2xx_gpu.c   | 37 --
  drivers/gpu/drm/msm/adreno/a3xx_gpu.c   | 50 ++
  drivers/gpu/drm/msm/adreno/a4xx_gpu.c   | 51 +++
  drivers/gpu/drm/msm/adreno/a5xx_gpu.c   | 37 +++---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c   | 37 +++---
  drivers/gpu/drm/msm/adreno/adreno_gpu.c |  7 -
  drivers/gpu/drm/msm/msm_gem.h   |  1 +
  drivers/gpu/drm/msm/msm_gpu.c   | 54 ++---
  drivers/gpu/drm/msm/msm_gpu.h   |  2 ++
  9 files changed, 173 insertions(+), 103 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index 1f83bc1..49241d0 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -401,6 +401,30 @@ static struct msm_gpu_state *a2xx_gpu_state_get(struct 
msm_gpu *gpu)
return state;
  }
  
+static struct msm_gem_address_space *

+a2xx_create_address_space(struct msm_gpu *gpu)
+{
+   struct msm_gem_address_space *aspace;
+   int ret;
+
+   aspace = msm_gem_address_space_create_a2xx(&gpu->pdev->dev, gpu,
+   "gpu", SZ_16M, SZ_16M + 0xff * SZ_64K);
+   if (IS_ERR(aspace)) {
+   DRM_DEV_ERROR(gpu->dev->dev,
+   "No memory protection without MMU\n");
+   return ERR_PTR(-ENXIO);
+   }
+
+   ret = aspace->mmu->funcs->attach(aspace->mmu, NULL, 0);
+   if (ret) {
+   msm_gem_address_space_put(aspace);
+   return ERR_PTR(ret);
+   }
+
+   return aspace;
+}
+
+
  /* Register offset defines for A2XX - copy of A3XX */
  static const unsigned int a2xx_register_offsets[REG_ADRENO_REGISTER_MAX] = {
REG_ADRENO_DEFINE(REG_ADRENO_CP_RB_BASE, REG_AXXX_CP_RB_BASE),
@@ -429,6 +453,7 @@ static const struct adreno_gpu_funcs funcs = {
  #endif
.gpu_state_get = a2xx_gpu_state_get,
.gpu_state_put = adreno_gpu_state_put,
+   .create_address_space = a2xx_create_address_space,
},
  };
  
@@ -473,16 +498,8 @@ struct msm_gpu *a2xx_gpu_init(struct drm_device *dev)

adreno_gpu->reg_offsets = a2xx_register_offsets;
  
  	ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs, 1);

-   if (ret)
-   goto fail;
-
-   if (!gpu->aspace) {
-   dev_err(dev->dev, "No memory protection without MMU\n");
-   ret = -ENXIO;
-   goto fail;
-   }
-
-   return gpu;
+   if (!ret)
+   return gpu;
  
  fail:

if (a2xx_gpu)
diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
index c3b4bc6..33ab5e8 100644
--- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c
@@ -21,6 +21,7 @@
  #  include 
  #endif
  
+#include "msm_gem.h"

  #include "a3xx_gpu.h"
  
  #define A3XX_INT0_MASK \

@@ -433,6 +434,41 @@ static struct msm_gpu_state *a3xx_gpu_state_get(struct 
msm_gpu *gpu)
return state;
  }
  
+static struct msm_gem_address_space *

+a3xx_create_address_space(struct msm_gpu *gpu)
+{
+   struct msm_gem_address_space *aspace;
+   struct iommu_domain *iommu;
+   int ret;
+
+   iommu = iommu_domain_alloc(&platform_bus_type);
+   if (!iommu) {
+   DRM_DEV_ERROR(gpu->dev->dev,
+   "No memory protection without IOMMU\n");
+   return ERR_PTR(-ENXIO);
+   }
+
+   iommu->geometry.aperture_start = SZ_16M;
+   iommu->geometry.aperture_end = 0x;
+
+   aspace = msm_gem_address_space_create(&gpu->pdev->dev, iommu, "gpu");
+   if (IS_ERR(aspace)) {
+   iommu_domain_free(iommu);
+   DRM_DEV_ERROR(gpu->dev->dev, "failed to init mmu: %ld\n",
+   PTR_ERR(aspace));
+   return aspace;
+   }
+
+   ret = aspace->mmu->funcs->attach(aspace->mmu, NULL, 0);
+   if (ret) {
+   msm_gem_address_space_put(aspace);
+   return ERR_PTR(ret);
+   }
+
+   return aspace;
+}
+
+
  /* Register offset defines for A3XX */
  static const unsigned int a3xx_register_offsets[REG_ADRENO_REGISTER_MAX] = {
REG_ADRENO_DEFINE(REG_ADRENO_CP_RB_BASE, REG_AXXX_CP_RB_BASE),
@@ -461,6 +497,7 @@ static const struct adreno_gpu_funcs funcs = {

[PATCH v2] drm/msm: use for_each_sgtable_sg to iterate over scatterlist

2022-06-13 Thread Jonathan Marek
The dma_map_sgtable() call (used to invalidate cache) overwrites sgt->nents
with 1, so msm_iommu_pagetable_map maps only the first physical segment.

To fix this problem use for_each_sgtable_sg(), which uses orig_nents.

Fixes: b145c6e65eb0 ("drm/msm: Add support to create a local pagetable")
Signed-off-by: Jonathan Marek 
---
v2: use for_each_sgtable_sg and update commit message

 drivers/gpu/drm/msm/msm_iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
index bcaddbba564df..a54ed354578b5 100644
--- a/drivers/gpu/drm/msm/msm_iommu.c
+++ b/drivers/gpu/drm/msm/msm_iommu.c
@@ -58,7 +58,7 @@ static int msm_iommu_pagetable_map(struct msm_mmu *mmu, u64 
iova,
u64 addr = iova;
unsigned int i;
 
-   for_each_sg(sgt->sgl, sg, sgt->nents, i) {
+   for_each_sgtable_sg(sgt, sg, i) {
size_t size = sg->length;
phys_addr_t phys = sg_phys(sg);
 
-- 
2.26.1



Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek
Another thing: did you verify that the panel still runs at 60hz (and not 
dropping frames to 30hz)? IIRC that was the behavior with lower clock.


On 3/2/20 10:28 PM, Jonathan Marek wrote:


On 3/2/20 10:13 PM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 03:48:22PM -0500, Jonathan Marek wrote:

Hi,

This is a command mode panel and the the msm/mdp5 driver uses the 
vrefresh
field for the actual refresh rate, while the dotclock field is used 
for the
DSI clocks. The dotclock needed to be a bit higher than necessary 
otherwise

the panel would not work.

If you want to get rid of the separate clock/vrefresh fields there would
need to be some changes to msm driver.

(note I hadn't made the patch with upstreaming in mind, the 15 
value is

likely not optimal, just something that worked, this is something that
should have been checked with the downstream driver)


Is this the right clock frequency in the downstream MSM 3.4 kernel that
you're talking about?

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/mach-msm/clock-8974.c#L3326 





No, I'm talking about the DSI clock (the driver for it is in 
drm/msm/dsi/). For a command mode panel the front/back porches aren't 
relevant, but the dsi pixel/byte clock need to be a bit higher than 
1920x1080x60. Since 125498 is a little higher than 124416 that might be 
enough (there is also rounding of the clock values to consider).



I don't see any obvious clock values in the downstream command mode
panel configuration:

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/boot/dts/msm8974-hammerhead/msm8974-hammerhead-panel.dtsi#L591 



Anyways, I tried Ville's patch with the framebuffer, kmscube, and X11
and everything appears to be working fine. You can add my Tested-by if
you end up applying this.

Tested-by: Brian Masney 

Brian



On 3/2/20 3:34 PM, Ville Syrjala wrote:

From: Ville Syrjälä 

The currently listed dotclock disagrees with the currently
listed vrefresh rate. Change the dotclock to match the vrefresh.

Someone tell me which (if either) of the dotclock or vreresh is
correct?

Cc: Jonathan Marek 
Cc: Brian Masney 
Cc: Linus Walleij 
Signed-off-by: Ville Syrjälä 
---
   drivers/gpu/drm/panel/panel-simple.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c

index b24fdf239440..f958d8dfd760 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -3996,7 +3996,7 @@ static const struct panel_desc_dsi 
panasonic_vvx10f004b00 = {

   };
   static const struct drm_display_mode lg_acx467akm_7_mode = {
-    .clock = 15,
+    .clock = 125498,
   .hdisplay = 1080,
   .hsync_start = 1080 + 2,
   .hsync_end = 1080 + 2 + 2,


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


Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek

Hi,

This is a command mode panel and the the msm/mdp5 driver uses the 
vrefresh field for the actual refresh rate, while the dotclock field is 
used for the DSI clocks. The dotclock needed to be a bit higher than 
necessary otherwise the panel would not work.


If you want to get rid of the separate clock/vrefresh fields there would 
need to be some changes to msm driver.


(note I hadn't made the patch with upstreaming in mind, the 15 value 
is likely not optimal, just something that worked, this is something 
that should have been checked with the downstream driver)


-Jonathan

On 3/2/20 3:34 PM, Ville Syrjala wrote:

From: Ville Syrjälä 

The currently listed dotclock disagrees with the currently
listed vrefresh rate. Change the dotclock to match the vrefresh.

Someone tell me which (if either) of the dotclock or vreresh is
correct?

Cc: Jonathan Marek 
Cc: Brian Masney 
Cc: Linus Walleij 
Signed-off-by: Ville Syrjälä 
---
  drivers/gpu/drm/panel/panel-simple.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index b24fdf239440..f958d8dfd760 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -3996,7 +3996,7 @@ static const struct panel_desc_dsi panasonic_vvx10f004b00 
= {
  };
  
  static const struct drm_display_mode lg_acx467akm_7_mode = {

-   .clock = 15,
+   .clock = 125498,
.hdisplay = 1080,
.hsync_start = 1080 + 2,
.hsync_end = 1080 + 2 + 2,


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


Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek


On 3/2/20 10:13 PM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 03:48:22PM -0500, Jonathan Marek wrote:

Hi,

This is a command mode panel and the the msm/mdp5 driver uses the vrefresh
field for the actual refresh rate, while the dotclock field is used for the
DSI clocks. The dotclock needed to be a bit higher than necessary otherwise
the panel would not work.

If you want to get rid of the separate clock/vrefresh fields there would
need to be some changes to msm driver.

(note I hadn't made the patch with upstreaming in mind, the 15 value is
likely not optimal, just something that worked, this is something that
should have been checked with the downstream driver)


Is this the right clock frequency in the downstream MSM 3.4 kernel that
you're talking about?

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/mach-msm/clock-8974.c#L3326



No, I'm talking about the DSI clock (the driver for it is in 
drm/msm/dsi/). For a command mode panel the front/back porches aren't 
relevant, but the dsi pixel/byte clock need to be a bit higher than 
1920x1080x60. Since 125498 is a little higher than 124416 that might be 
enough (there is also rounding of the clock values to consider).



I don't see any obvious clock values in the downstream command mode
panel configuration:

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/boot/dts/msm8974-hammerhead/msm8974-hammerhead-panel.dtsi#L591

Anyways, I tried Ville's patch with the framebuffer, kmscube, and X11
and everything appears to be working fine. You can add my Tested-by if
you end up applying this.

Tested-by: Brian Masney 

Brian



On 3/2/20 3:34 PM, Ville Syrjala wrote:

From: Ville Syrjälä 

The currently listed dotclock disagrees with the currently
listed vrefresh rate. Change the dotclock to match the vrefresh.

Someone tell me which (if either) of the dotclock or vreresh is
correct?

Cc: Jonathan Marek 
Cc: Brian Masney 
Cc: Linus Walleij 
Signed-off-by: Ville Syrjälä 
---
   drivers/gpu/drm/panel/panel-simple.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index b24fdf239440..f958d8dfd760 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -3996,7 +3996,7 @@ static const struct panel_desc_dsi panasonic_vvx10f004b00 
= {
   };
   static const struct drm_display_mode lg_acx467akm_7_mode = {
-   .clock = 15,
+   .clock = 125498,
.hdisplay = 1080,
.hsync_start = 1080 + 2,
.hsync_end = 1080 + 2 + 2,


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


Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek
modetest should be printing "freq: 60.0Hz", so definitely something 
wrong there. Though I guess you have another problem since I would 
expect the patch to drop it to 30 and not 13.5.


(FYI glmark-x11 isn't vsynced which is why I specifically mentioned 
glmark-drm)


On 3/3/20 9:16 PM, Brian Masney wrote:

On Tue, Mar 03, 2020 at 08:04:05AM -0500, Jonathan Marek wrote:

What Xorg prints doesn't mean anything. I don't think there will be errors
in dmesg, you need to run something that does pageflips as fast as possible
and see that the refresh rate is still 60. (modetest with -v, glmark-drm are
examples)


I assume that you mean modetest from
https://gitlab.freedesktop.org/mesa/drm/tree/master/tests/modetest ?
Here's the modeset connector information:

id   encoder status  namesize (mm)  modes   encoders
32   31  connected   DSI-1   62x110 1   31
   modes:
 index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
   #0 1080x1920 71.71 1080 1082 1084 1086 1920 1922 1924 1926 15
   flags: ; type: preferred, driver

And the page flip results...

$ modetest -v -s 32:1080x1920
trying to open device 'msm'...done
setting mode 1080x1920-71.71Hz@XR24 on connectors 32, crtc 50
failed to set gamma: Function not implemented
freq: 13.50Hz
freq: 13.51Hz
freq: 13.51Hz

It's the same results with and without Ville's patch.

Here's the beginning of the glmark2 results with the x11-gl flavor:

===
 glmark2 2017.07
===
 OpenGL Information
 GL_VENDOR: freedreno
 GL_RENDERER:   FD330
 GL_VERSION:3.1 Mesa 20.0.0-devel
===
[build] use-vbo=false: FPS: 26 FrameTime: 38.462 ms
[build] use-vbo=true: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=nearest: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=linear: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=mipmap: FPS: 27 FrameTime: 37.037 ms
[shading] shading=gouraud: FPS: 27 FrameTime: 37.037 ms
[shading] shading=blinn-phong-inf: FPS: 27 FrameTime: 37.037 ms
[shading] shading=phong: FPS: 27 FrameTime: 37.037 ms
[shading] shading=cel: FPS: 26 FrameTime: 38.462 ms
[bump] bump-render=high-poly: FPS: 27 FrameTime: 37.037 ms
[bump] bump-render=normals: FPS: 27 FrameTime: 37.037 ms
[bump] bump-render=height: FPS: 27 FrameTime: 37.037 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 25 FrameTime: 40.000 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 26 FrameTime:
  38.462 ms
[pulsar] light=false:quads=5:texture=false: FPS: 26 FrameTime: 38.462 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:
  FPS: 26 FrameTime: 38.462 ms
[desktop] effect=shadow:windows=4: FPS: 27 FrameTime: 37.037 ms
...

Brian




On 3/3/20 7:26 AM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 10:36:54PM -0500, Jonathan Marek wrote:

Another thing: did you verify that the panel still runs at 60hz (and not
dropping frames to 30hz)? IIRC that was the behavior with lower clock.


Yes, the panel is running at 60 HZ according to the Xorg log with
Ville's patch applied:

  modeset(0): Modeline "1080x1920"x60.0  125.50  1080 1082 1084 1086
  1920 1922 1924 1926 (115.6 kHz eP)

I verified there's no underflow errors in dmesg.

If I recall correctly, the clock speeds that was in your tree was set
too low for the gpu_opp_table (that wouldn't cause this issue), but I
seem to recall there were some other clock speed mismatches. The
bandwidth requests weren't set on the RPM as well, so maybe that
contributed to the problem. That's done upstream with the msm8974
interconnect driver:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/interconnect/qcom/msm8974.c

There's a separate known issue with 'pp done time out' errors that
occur on the framebuffer that started upstream several months ago with
the introduction of async commit support in the MSM driver. I tried
working around this by enabling the autorefresh feature but it's not
fully working yet and I hit a dead end since there's no docs available
publicly for this. The grim details are at:

https://lore.kernel.org/lkml/20191230020053.26016-2-masn...@onstation.org/

So I'm still OK with Ville's patch going in.

Brian




On 3/2/20 10:28 PM, Jonathan Marek wrote:


On 3/2/20 10:13 PM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 03:48:22PM -0500, Jonathan Marek wrote:

Hi,

This is a command mode panel and the the msm/mdp5 driver uses
the vrefresh
field for the actual refresh rate, while the dotclock field is
used for the
DSI clocks. The dotclock needed to be a bit higher than
necessary otherwise
the panel would not work.

If you want to get rid of the separate clock/vrefresh fields there would
need to be some changes to msm driver.

(note 

Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek
What Xorg prints doesn't mean anything. I don't think there will be 
errors in dmesg, you need to run something that does pageflips as fast 
as possible and see that the refresh rate is still 60. (modetest with 
-v, glmark-drm are examples)


On 3/3/20 7:26 AM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 10:36:54PM -0500, Jonathan Marek wrote:

Another thing: did you verify that the panel still runs at 60hz (and not
dropping frames to 30hz)? IIRC that was the behavior with lower clock.


Yes, the panel is running at 60 HZ according to the Xorg log with
Ville's patch applied:

 modeset(0): Modeline "1080x1920"x60.0  125.50  1080 1082 1084 1086
 1920 1922 1924 1926 (115.6 kHz eP)

I verified there's no underflow errors in dmesg.

If I recall correctly, the clock speeds that was in your tree was set
too low for the gpu_opp_table (that wouldn't cause this issue), but I
seem to recall there were some other clock speed mismatches. The
bandwidth requests weren't set on the RPM as well, so maybe that
contributed to the problem. That's done upstream with the msm8974
interconnect driver:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/interconnect/qcom/msm8974.c

There's a separate known issue with 'pp done time out' errors that
occur on the framebuffer that started upstream several months ago with
the introduction of async commit support in the MSM driver. I tried
working around this by enabling the autorefresh feature but it's not
fully working yet and I hit a dead end since there's no docs available
publicly for this. The grim details are at:

https://lore.kernel.org/lkml/20191230020053.26016-2-masn...@onstation.org/

So I'm still OK with Ville's patch going in.

Brian




On 3/2/20 10:28 PM, Jonathan Marek wrote:


On 3/2/20 10:13 PM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 03:48:22PM -0500, Jonathan Marek wrote:

Hi,

This is a command mode panel and the the msm/mdp5 driver uses
the vrefresh
field for the actual refresh rate, while the dotclock field is
used for the
DSI clocks. The dotclock needed to be a bit higher than
necessary otherwise
the panel would not work.

If you want to get rid of the separate clock/vrefresh fields there would
need to be some changes to msm driver.

(note I hadn't made the patch with upstreaming in mind, the
15 value is
likely not optimal, just something that worked, this is something that
should have been checked with the downstream driver)


Is this the right clock frequency in the downstream MSM 3.4 kernel that
you're talking about?

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/mach-msm/clock-8974.c#L3326




No, I'm talking about the DSI clock (the driver for it is in
drm/msm/dsi/). For a command mode panel the front/back porches aren't
relevant, but the dsi pixel/byte clock need to be a bit higher than
1920x1080x60. Since 125498 is a little higher than 124416 that might be
enough (there is also rounding of the clock values to consider).


I don't see any obvious clock values in the downstream command mode
panel configuration:

https://github.com/AICP/kernel_lge_hammerhead/blob/n7.1/arch/arm/boot/dts/msm8974-hammerhead/msm8974-hammerhead-panel.dtsi#L591


Anyways, I tried Ville's patch with the framebuffer, kmscube, and X11
and everything appears to be working fine. You can add my Tested-by if
you end up applying this.

Tested-by: Brian Masney 

Brian



On 3/2/20 3:34 PM, Ville Syrjala wrote:

From: Ville Syrjälä 

The currently listed dotclock disagrees with the currently
listed vrefresh rate. Change the dotclock to match the vrefresh.

Someone tell me which (if either) of the dotclock or vreresh is
correct?

Cc: Jonathan Marek 
Cc: Brian Masney 
Cc: Linus Walleij 
Signed-off-by: Ville Syrjälä 
---
    drivers/gpu/drm/panel/panel-simple.c | 2 +-
    1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c
b/drivers/gpu/drm/panel/panel-simple.c
index b24fdf239440..f958d8dfd760 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -3996,7 +3996,7 @@ static const struct panel_desc_dsi
panasonic_vvx10f004b00 = {
    };
    static const struct drm_display_mode lg_acx467akm_7_mode = {
-    .clock = 15,
+    .clock = 125498,
    .hdisplay = 1080,
    .hsync_start = 1080 + 2,
    .hsync_end = 1080 + 2 + 2,


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


Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-03 Thread Jonathan Marek
If I have time to kill over the weekend I'll do a new rebase of my Nexus 
5 patches (my last rebase was back in August on 5.2, and the panel was 
working correctly at 60Hz back then).


Looked at it again and it does look like your glmark was vsynced (glmark 
explicitly disables vsync so I guess you have it force-enabled) since 
the results are all 26-27 (X works a bit differently and gets double the 
framerate somehow?)


On 3/3/20 9:53 PM, Brian Masney wrote:

On Tue, Mar 03, 2020 at 09:27:50PM -0500, Jonathan Marek wrote:

modetest should be printing "freq: 60.0Hz", so definitely something wrong
there. Though I guess you have another problem since I would expect the
patch to drop it to 30 and not 13.5.

(FYI glmark-x11 isn't vsynced which is why I specifically mentioned
glmark-drm)


I tried compiling the drm variant and it was complaining about some
missing dependencies that I didn't see in Alpine Linux. I didn't try too
hard since I'm a bit short on time at this point since I'm starting a
new job on Monday and I have another side project that I want to finish
before then.

I suspect that the issue is caused by the introduction of the async
commit support in the MSM driver that introduced the ping/pong timeouts.
I'll try in a few weeks or so reverting those patches and see if that
affects the speed.

I'm still ok with Ville's patch going in given the existing slow state.
There's no clear path forward right now for the autocommit patch that I
linked to earlier in this thread. :(

Brian



On 3/3/20 9:16 PM, Brian Masney wrote:

On Tue, Mar 03, 2020 at 08:04:05AM -0500, Jonathan Marek wrote:

What Xorg prints doesn't mean anything. I don't think there will be errors
in dmesg, you need to run something that does pageflips as fast as possible
and see that the refresh rate is still 60. (modetest with -v, glmark-drm are
examples)


I assume that you mean modetest from
https://gitlab.freedesktop.org/mesa/drm/tree/master/tests/modetest ?
Here's the modeset connector information:

id   encoder status  namesize (mm)  modes   encoders
32   31  connected   DSI-1   62x110 1   31
modes:
  index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
#0 1080x1920 71.71 1080 1082 1084 1086 1920 1922 1924 1926 15
flags: ; type: preferred, driver

And the page flip results...

$ modetest -v -s 32:1080x1920
trying to open device 'msm'...done
setting mode 1080x1920-71.71Hz@XR24 on connectors 32, crtc 50
failed to set gamma: Function not implemented
freq: 13.50Hz
freq: 13.51Hz
freq: 13.51Hz

It's the same results with and without Ville's patch.

Here's the beginning of the glmark2 results with the x11-gl flavor:

===
  glmark2 2017.07
===
  OpenGL Information
  GL_VENDOR: freedreno
  GL_RENDERER:   FD330
  GL_VERSION:3.1 Mesa 20.0.0-devel
===
[build] use-vbo=false: FPS: 26 FrameTime: 38.462 ms
[build] use-vbo=true: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=nearest: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=linear: FPS: 26 FrameTime: 38.462 ms
[texture] texture-filter=mipmap: FPS: 27 FrameTime: 37.037 ms
[shading] shading=gouraud: FPS: 27 FrameTime: 37.037 ms
[shading] shading=blinn-phong-inf: FPS: 27 FrameTime: 37.037 ms
[shading] shading=phong: FPS: 27 FrameTime: 37.037 ms
[shading] shading=cel: FPS: 26 FrameTime: 38.462 ms
[bump] bump-render=high-poly: FPS: 27 FrameTime: 37.037 ms
[bump] bump-render=normals: FPS: 27 FrameTime: 37.037 ms
[bump] bump-render=height: FPS: 27 FrameTime: 37.037 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 25 FrameTime: 40.000 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 26 FrameTime:
   38.462 ms
[pulsar] light=false:quads=5:texture=false: FPS: 26 FrameTime: 38.462 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4:
   FPS: 26 FrameTime: 38.462 ms
[desktop] effect=shadow:windows=4: FPS: 27 FrameTime: 37.037 ms
...

Brian




On 3/3/20 7:26 AM, Brian Masney wrote:

On Mon, Mar 02, 2020 at 10:36:54PM -0500, Jonathan Marek wrote:

Another thing: did you verify that the panel still runs at 60hz (and not
dropping frames to 30hz)? IIRC that was the behavior with lower clock.


Yes, the panel is running at 60 HZ according to the Xorg log with
Ville's patch applied:

   modeset(0): Modeline "1080x1920"x60.0  125.50  1080 1082 1084 1086
   1920 1922 1924 1926 (115.6 kHz eP)

I verified there's no underflow errors in dmesg.

If I recall correctly, the clock speeds that was in your tree was set
too low for the gpu_opp_table (that wouldn't cause this issue), but I
seem to recall there were some other clock speed mismatches. The
bandwidth requests weren't set on the RPM as well, so

Re: [PATCH 33/33] drm/panel-simple: Fix dotclock for LG ACX467AKM-7

2020-03-05 Thread Jonathan Marek
The msm DSI driver does predate the addition of those fields and doesn't 
use them at all.


Seems like it would be a bit of a hack too, since the frequency we want 
to use is not the "real limits of the hardware"..


On 3/4/20 4:10 AM, Linus Walleij wrote:

On Mon, Mar 2, 2020 at 9:49 PM Jonathan Marek  wrote:


This is a command mode panel and the the msm/mdp5 driver uses the
vrefresh field for the actual refresh rate, while the dotclock field is
used for the DSI clocks. The dotclock needed to be a bit higher than
necessary otherwise the panel would not work.


I don't know if this predates the support for defining DSI clocks
but for what we have in the kernel right now this is wrong.

struct mipi_dsi_device contains:

  * @hs_rate: maximum lane frequency for high speed mode in hertz, this should
  * be set to the real limits of the hardware, zero is only accepted for
  * legacy drivers
  * @lp_rate: maximum lane frequency for low power mode in hertz, this should
  * be set to the real limits of the hardware, zero is only accepted for
  * legacy drivers

The MDP driver should use these frequencies for a DSI command
mode panel, and the panel driver should define them.

These two clocks are/can be/should be completely orthogonal to
the dotclock/pixelclock inside the panel, which is likely driven from
its own crystal directly from the panel-internal framebuffer.

Yours,
Linus Walleij


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


Re: Adreno crash on i.MX53 running 5.3-rc6

2019-09-04 Thread Jonathan Marek

Hi,

I tried this and it works with patches 4+5 from Rob's series and 
changing gpummu to use sg_phys(sg) instead of sg->dma_address 
(dma_address isn't set now that dma_map_sg isn't used).


Jonathan

On 9/3/19 11:22 AM, Rob Clark wrote:

On Mon, Sep 2, 2019 at 11:03 AM Fabio Estevam  wrote:


Hi Robin,

On Mon, Sep 2, 2019 at 11:45 AM Robin Murphy  wrote:


Try 0036bc73ccbe - that looks like something that CONFIG_DMA_API_DEBUG
should have been screaming about anyway.


Thanks for your suggestion.

I can successfully boot after reverting the following commits:

commit 141db5703c887f46957615cd6616ca28fe4691e0 (HEAD)
Author: Fabio Estevam 
Date:   Mon Sep 2 14:58:18 2019 -0300

 Revert "drm/msm: stop abusing dma_map/unmap for cache"

 This reverts commit 0036bc73ccbe7e600a3468bf8e8879b122252274.

commit fa5b1f620f2984c254877d6049214c39c24c8207
Author: Fabio Estevam 
Date:   Mon Sep 2 14:56:01 2019 -0300

 Revert "drm/msm: Use the correct dma_sync calls in msm_gem"

 This reverts commit 3de433c5b38af49a5fc7602721e2ab5d39f1e69c.

Rob,

What would be the recommended approach for fixing this?



We need a direct way to handle cache, so we can stop trying to trick
DMA API into doing what we want.

Something like this is what I had in mind:

https://patchwork.freedesktop.org/series/65211/

I guess I could respin that.  I'm not really sure of any other way to
have things working on the different combinations of archs and dma_ops
that we have.  Lately fixing one has been breaking another.

BR,
-R


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

Re: [Freedreno] [PATCH v2 2/2] dt-bindings: display: msm/dsi: add qcom, dsi-phy-cphy-mode option

2021-05-28 Thread Jonathan Marek

On 5/3/21 1:11 PM, Rob Herring wrote:

On Fri, Apr 23, 2021 at 01:24:40PM -0400, Jonathan Marek wrote:

Document qcom,dsi-phy-cphy-mode option, which can be used to control
whether DSI will operate in D-PHY (default) or C-PHY mode.


Given this is a standard MIPI thing, I think this needs to be a common
property. We already have phy bindings that use the phy cells to set the
phy type which I think you should use here. See
include/dt-bindings/phy/phy.h.



Is it OK to simply change the option to something like "phy-mode = 
;"?


(using phy-cells would be annoying to implement, with no benefit IMO)


Re: [PATCH v2 2/8] drm/msm/a6xx: use AOP-initialized PDC for a650

2021-06-08 Thread Jonathan Marek

On 5/31/21 3:24 AM, Akhil P Oommen wrote:

On 5/13/2021 10:43 PM, Jonathan Marek wrote:
SM8250 AOP firmware already sets up PDC registers for us, and it only 
needs

to be enabled. This path will be used for other newer GPUs.

Signed-off-by: Jonathan Marek 
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 21 -
  1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c

index 3d55e153fa9c..c1ee02d6371d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -512,19 +512,26 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu 
*gmu)

  struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
  struct platform_device *pdev = to_platform_device(gmu->dev);
  void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc");
-    void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+    void __iomem *seqptr;
  uint32_t pdc_address_offset;
+    bool pdc_in_aop = false;
-    if (!pdcptr || !seqptr)
+    if (!pdcptr)
  goto err;
-    if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
+    if (adreno_is_a650(adreno_gpu))
+    pdc_in_aop = true;
+    else if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
  pdc_address_offset = 0x30090;
-    else if (adreno_is_a650(adreno_gpu))
-    pdc_address_offset = 0x300a0;
  else
  pdc_address_offset = 0x30080;
+    if (!pdc_in_aop) {
+    seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+    if (!seqptr)
+    goto err;
+    }
+
  /* Disable SDE clock gating */
  gmu_write_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
@@ -556,6 +563,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 
0x0020e8a8);

  }
+    if (pdc_in_aop)
+    goto setup_pdc;
+
  /* Load PDC sequencer uCode for power up and power down sequence */
  pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0, 0xfebea1e1);
  pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 1, 0xa5a4a3a2);
@@ -596,6 +606,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 8, 0x3);
  /* Setup GPU PDC */
+setup_pdc:
  pdc_write(pdcptr, REG_A6XX_PDC_GPU_SEQ_START_ADDR, 0);
  pdc_write(pdcptr, REG_A6XX_PDC_GPU_ENABLE_PDC, 0x8001);



We can simply swap the order of PDC and rsc programming here and skip 
pdc sequence to jump to the rscc programming for a650. This is the order 
followed in the downstream driver anyway.


-Akhil.


The order is the same as the msm-4.19 kernel (msm-4.19 is what a650 
hardware are using).


Looks like the order was swapped for the msm-5.4 kernel, but if the 
order isn't important, I think it is preferable to keep the current 
order (to avoid a large diff mainly).


Re: [PATCH v2 6/8] drm/msm/a6xx: add support for Adreno 660 GPU

2021-06-08 Thread Jonathan Marek

On 5/31/21 11:05 AM, Akhil P Oommen wrote:

On 5/13/2021 10:44 PM, Jonathan Marek wrote:


...


@@ -519,7 +519,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
  if (!pdcptr)
  goto err;
-    if (adreno_is_a650(adreno_gpu))
+    if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))


why not adreno_is_a650_family() here?



Based on downstream, a620 is part of a650_family but does not have 
pdc_in_aop flag.


@@ -751,7 +751,7 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, 
unsigned int state)

  int ret;
  u32 chipid;

We need to program this register here:
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 1);



msm-4.19 does not have this write for a650, but msm-5.4 then adds it. 
Will make it a separate change since it affects a650 and not just a660.



-    if (adreno_is_a650(adreno_gpu))
+    if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))
  gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
  if (state == GMU_WARM_BOOT) {
@@ -1494,12 +1494,28 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, 
struct device_node *node)

  if (ret)
  goto err_put_device;
+
+    /* A660 now requires handling "prealloc requests" in GMU firmware
+ * For now just hardcode allocations based on the known firmware.
+ * note: there is no indication that these correspond to "dummy" or
+ * "debug" regions, but this "guess" allows reusing these BOs which
+ * are otherwise unused by a660.
+ */
+    gmu->dummy.size = SZ_4K;
+    if (adreno_is_a660(adreno_gpu)) {
+    ret = a6xx_gmu_memory_alloc(gmu, &gmu->debug, SZ_4K * 7, 
0x6040);

+    if (ret)
+    goto err_memory;


I think we can simply ignore this allocation for a660 because it was 
required for an unused feature. Do you see any issue if you ignore this 
allocation?




Yes, without it there will be an error:

arm-smmu 3da.iommu: Unhandled context fault: fsr=0x402, 
iova=0x6040, fsynr=0x32, cbfrsynra=0x5, cb=2



+
+    gmu->dummy.size = SZ_8K;
+    }
+
  /* Allocate memory for the GMU dummy page */
-    ret = a6xx_gmu_memory_alloc(gmu, &gmu->dummy, SZ_4K, 0x6000);
+    ret = a6xx_gmu_memory_alloc(gmu, &gmu->dummy, gmu->dummy.size, 
0x6000);

  if (ret)
  goto err_memory;
-    if (adreno_is_a650(adreno_gpu)) {
+    if (adreno_is_a650_family(adreno_gpu)) {
  ret = a6xx_gmu_memory_alloc(gmu, &gmu->icache,
  SZ_16M - SZ_16K, 0x04000);
  if (ret)
@@ -885,6 +937,13 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
  /* Protect registers from the CP */
  a6xx_set_cp_protect(gpu);
+    if (adreno_is_a660(adreno_gpu)) {
+    gpu_write(gpu, REG_A6XX_CP_CHICKEN_DBG, 0x1);
+    gpu_write(gpu, REG_A6XX_RBBM_GBIF_CLIENT_QOS_CNTL, 0x0);
+    /* Set dualQ + disable afull for A660 GPU but not for A635 */
+    gpu_write(gpu, REG_A6XX_UCHE_CMDQ_CONFIG, 0x66906);
+    }
+

gpu_rmw(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0, (1 << 9));
We need this for a640, a650 and a660.



Will make this a separate patch too, since it affects non-a660 GPUs too.


  /* Enable expanded apriv for targets that support it */
  if (gpu->hw_apriv) {
  gpu_write(gpu, REG_A6XX_CP_APRIV_CNTL,
+/* check for a650, a660, or any derivatives */
+static inline int adreno_is_a650_family(struct adreno_gpu *gpu)
+{
+   return gpu->revn == 650 || gpu->revn == 620 ||
+  gpu->revn == 660 || gpu->revn == 635;
We can remove 635 references throughout since that is not a valid adreno 
chipid anymore.


-Akhil


I will remove it for my patch (it can discussed when adding 635 support, 
but I think you will need to have a 6xx ID for the GPU)



+}
+
  int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t 
*value);

  const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu,
  const char *fwname);



[PATCH v3 0/5] drm/msm/a6xx: add support for Adreno 660 GPU

2021-06-08 Thread Jonathan Marek
Add support for Adreno 660 to the drm/msm driver. Very similar to A650
on the kernel side.

v2:
 - added AOP PDC path for a650 and use it for a660 too
 - fix UBWC config for a650 (also affects a660)
 - add CP_PROTECT update, and corresponding a660 settings in A660 patch

v3:
 - removed patches already picked up by robclark
 - added patches for missing PC_DBG_ECO_CNTL/GMU_CX_FALNEXT_INTF settings
 - changed a660_protect to exclude CP_PERFCTR_CP_SEL
 - removed 635 id from adreno_is_a650_family
 - squashed a660 patches

Jonathan Marek (5):
  drm/msm: remove unused icc_path/ocmem_icc_path
  drm/msm/a6xx: use AOP-initialized PDC for a650
  drm/msm/a6xx: add GMU_CX_GMU_CX_FALNEXT_INTF write for a650
  drm/msm/a6xx: add missing PC_DBG_ECO_CNTL bit for a640/a650
  drm/msm/a6xx: add support for Adreno 660 GPU

 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |   4 +
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  |  53 +--
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h  |   2 +
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 172 +
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  |  33 
 drivers/gpu/drm/msm/adreno/adreno_device.c |  13 ++
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|   5 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  13 +-
 drivers/gpu/drm/msm/msm_gpu.h  |   9 --
 9 files changed, 248 insertions(+), 56 deletions(-)

-- 
2.26.1



[PATCH v3 1/5] drm/msm: remove unused icc_path/ocmem_icc_path

2021-06-08 Thread Jonathan Marek
These aren't used by anything anymore.

Signed-off-by: Jonathan Marek 
Reviewed-by: Akhil P Oommen 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 3 ---
 drivers/gpu/drm/msm/msm_gpu.h   | 9 -
 2 files changed, 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 8fd0777f2dc9..009f4c560f16 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -946,7 +946,4 @@ void adreno_gpu_cleanup(struct adreno_gpu *adreno_gpu)
pm_runtime_disable(&priv->gpu_pdev->dev);
 
msm_gpu_cleanup(&adreno_gpu->base);
-
-   icc_put(gpu->icc_path);
-   icc_put(gpu->ocmem_icc_path);
 }
diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h
index 18baf935e143..c302ab7ffb06 100644
--- a/drivers/gpu/drm/msm/msm_gpu.h
+++ b/drivers/gpu/drm/msm/msm_gpu.h
@@ -118,15 +118,6 @@ struct msm_gpu {
struct clk *ebi1_clk, *core_clk, *rbbmtimer_clk;
uint32_t fast_rate;
 
-   /* The gfx-mem interconnect path that's used by all GPU types. */
-   struct icc_path *icc_path;
-
-   /*
-* Second interconnect path for some A3xx and all A4xx GPUs to the
-* On Chip MEMory (OCMEM).
-*/
-   struct icc_path *ocmem_icc_path;
-
/* Hang and Inactivity Detection:
 */
 #define DRM_MSM_INACTIVE_PERIOD   66 /* in ms (roughly four frames) */
-- 
2.26.1



[PATCH v3 2/5] drm/msm/a6xx: use AOP-initialized PDC for a650

2021-06-08 Thread Jonathan Marek
SM8250 AOP firmware already sets up PDC registers for us, and it only needs
to be enabled. This path will be used for other newer GPUs.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 3d55e153fa9c..c1ee02d6371d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -512,19 +512,26 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
struct adreno_gpu *adreno_gpu = &a6xx_gpu->base;
struct platform_device *pdev = to_platform_device(gmu->dev);
void __iomem *pdcptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc");
-   void __iomem *seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+   void __iomem *seqptr;
uint32_t pdc_address_offset;
+   bool pdc_in_aop = false;
 
-   if (!pdcptr || !seqptr)
+   if (!pdcptr)
goto err;
 
-   if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu))
+   pdc_in_aop = true;
+   else if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
pdc_address_offset = 0x30090;
-   else if (adreno_is_a650(adreno_gpu))
-   pdc_address_offset = 0x300a0;
else
pdc_address_offset = 0x30080;
 
+   if (!pdc_in_aop) {
+   seqptr = a6xx_gmu_get_mmio(pdev, "gmu_pdc_seq");
+   if (!seqptr)
+   goto err;
+   }
+
/* Disable SDE clock gating */
gmu_write_rscc(gmu, REG_A6XX_GPU_RSCC_RSC_STATUS0_DRV0, BIT(24));
 
@@ -556,6 +563,9 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 4, 
0x0020e8a8);
}
 
+   if (pdc_in_aop)
+   goto setup_pdc;
+
/* Load PDC sequencer uCode for power up and power down sequence */
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0, 0xfebea1e1);
pdc_write(seqptr, REG_A6XX_PDC_GPU_SEQ_MEM_0 + 1, 0xa5a4a3a2);
@@ -596,6 +606,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 8, 0x3);
 
/* Setup GPU PDC */
+setup_pdc:
pdc_write(pdcptr, REG_A6XX_PDC_GPU_SEQ_START_ADDR, 0);
pdc_write(pdcptr, REG_A6XX_PDC_GPU_ENABLE_PDC, 0x8001);
 
-- 
2.26.1



[PATCH v3 3/5] drm/msm/a6xx: add GMU_CX_GMU_CX_FALNEXT_INTF write for a650

2021-06-08 Thread Jonathan Marek
downstream msm-5.14 kernel added a write to this register, so match that.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 +++-
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index c1ee02d6371d..0f3390eab55e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -751,8 +751,10 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, 
unsigned int state)
int ret;
u32 chipid;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu)) {
+   gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 1);
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
+   }
 
if (state == GMU_WARM_BOOT) {
ret = a6xx_rpmh_start(gmu);
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
index 5a43d3090b0c..eeef3d6d89b8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
@@ -292,6 +292,8 @@ static inline uint32_t A6XX_GMU_GPU_NAP_CTRL_SID(uint32_t 
val)
 
 #define REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF0x50f0
 
+#define REF_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF0x50f1
+
 #define REG_A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_MSG 0x5100
 
 #define REG_A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP
0x5101
-- 
2.26.1



[PATCH v3 4/5] drm/msm/a6xx: add missing PC_DBG_ECO_CNTL bit for a640/a650

2021-06-08 Thread Jonathan Marek
See downstream's "disable_tseskip" flag.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 853be7651623..bbbf90d86828 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -844,13 +844,15 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
/* Setting the mem pool size */
gpu_write(gpu, REG_A6XX_CP_MEM_POOL_SIZE, 128);
 
-   /* Setting the primFifo thresholds default values */
+   /* Setting the primFifo thresholds default values,
+* and vccCacheSkipDis=1 bit (0x200) for A640 and newer
+   */
if (adreno_is_a650(adreno_gpu))
-   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0x0030);
+   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0x00300200);
else if (adreno_is_a640(adreno_gpu))
-   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0x0020);
+   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0x00200200);
else
-   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, (0x300 << 11));
+   gpu_write(gpu, REG_A6XX_PC_DBG_ECO_CNTL, 0x0018);
 
/* Set the AHB default slave response to "ERROR" */
gpu_write(gpu, REG_A6XX_CP_AHB_CNTL, 0x1);
-- 
2.26.1



[PATCH v3 5/5] drm/msm/a6xx: add support for Adreno 660 GPU

2021-06-08 Thread Jonathan Marek
Add adreno_is_{a660,a650_family} helpers and convert update existing
adreno_is_a650 usage based on downstream driver's logic (changing into
adreno_is_a650_family or adding adreno_is_a660).

And add the remaining changes required for A660, again based on
the downstream driver: missing GMU allocations, additional register init,
dummy hfi BW table, cp protect list, entry in gpulist table, hwcg table,
updated a6xx_ucode_check_version check.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx.xml.h  |   4 +
 drivers/gpu/drm/msm/adreno/a6xx_gmu.c  |  32 +++-
 drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h  |   2 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 162 +
 drivers/gpu/drm/msm/adreno/a6xx_hfi.c  |  33 +
 drivers/gpu/drm/msm/adreno/adreno_device.c |  13 ++
 drivers/gpu/drm/msm/adreno/adreno_gpu.c|   2 +-
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  13 +-
 8 files changed, 224 insertions(+), 37 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
index 920c5e6b8e96..631c36672560 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx.xml.h
@@ -2240,6 +2240,8 @@ static inline uint32_t 
A6XX_DBGC_CFG_DBGBUS_BYTEL_1_BYTEL15(uint32_t val)
 
 #define REG_A6XX_DBGC_CFG_DBGBUS_TRACE_BUF20x0630
 
+#define REG_A6XX_CP_LPAC_PROG_FIFO_SIZE0x0b34
+
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_0 0x0cd8
 
 #define REG_A6XX_VSC_PERFCTR_VSC_SEL_1 0x0cd9
@@ -2340,6 +2342,8 @@ static inline uint32_t 
A6XX_UCHE_CLIENT_PF_PERFSEL(uint32_t val)
 
 #define REG_A6XX_UCHE_PERFCTR_UCHE_SEL_11  0x0e27
 
+#define REG_A6XX_UCHE_CMDQ_CONFIG  0x0e3c
+
 #define REG_A6XX_SP_ADDR_MODE_CNTL 0xae01
 
 #define REG_A6XX_SP_NC_MODE_CNTL   0xae02
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 0f3390eab55e..bf95221c64a2 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -519,7 +519,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
if (!pdcptr)
goto err;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650(adreno_gpu) || adreno_is_a660(adreno_gpu))
pdc_in_aop = true;
else if (adreno_is_a618(adreno_gpu) || adreno_is_a640(adreno_gpu))
pdc_address_offset = 0x30090;
@@ -549,7 +549,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
gmu_write_rscc(gmu, REG_A6XX_RSCC_PDC_MATCH_VALUE_HI, 0x4514);
 
/* Load RSC sequencer uCode for sleep and wakeup */
-   if (adreno_is_a650(adreno_gpu)) {
+   if (adreno_is_a650_family(adreno_gpu)) {
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0, 0xeaaae5a0);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 1, 
0xe1a1ebab);
gmu_write_rscc(gmu, REG_A6XX_RSCC_SEQ_MEM_0_DRV0 + 2, 
0xa2e0a581);
@@ -597,7 +597,7 @@ static void a6xx_gmu_rpmh_init(struct a6xx_gmu *gmu)
 
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_MSGID + 4, 0x10108);
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_ADDR + 4, 0x3);
-   if (adreno_is_a618(adreno_gpu) || adreno_is_a650(adreno_gpu))
+   if (adreno_is_a618(adreno_gpu) || adreno_is_a650_family(adreno_gpu))
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x2);
else
pdc_write(pdcptr, REG_A6XX_PDC_GPU_TCS3_CMD0_DATA + 4, 0x3);
@@ -698,7 +698,7 @@ static int a6xx_gmu_fw_load(struct a6xx_gmu *gmu)
u32 itcm_base = 0x;
u32 dtcm_base = 0x0004;
 
-   if (adreno_is_a650(adreno_gpu))
+   if (adreno_is_a650_family(adreno_gpu))
dtcm_base = 0x10004000;
 
if (gmu->legacy) {
@@ -751,7 +751,7 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, unsigned 
int state)
int ret;
u32 chipid;
 
-   if (adreno_is_a650(adreno_gpu)) {
+   if (adreno_is_a650_family(adreno_gpu)) {
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 1);
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
}
@@ -1496,12 +1496,28 @@ int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct 
device_node *node)
if (ret)
goto err_put_device;
 
+
+   /* A660 now requires handling "prealloc requests" in GMU firmware
+* For now just hardcode allocations based on the known firmware.
+* note: there is no indication that these correspond to "dummy" or
+* "debug" regions, but this "guess" allows reusing these BOs which
+* are otherwise unused by a660.
+*/
+   gmu->dummy.size = SZ_4K;
+   if (adreno_is_a660(adreno_gpu)

Re: [PATCH v3 3/5] drm/msm/a6xx: add GMU_CX_GMU_CX_FALNEXT_INTF write for a650

2021-06-08 Thread Jonathan Marek

On 6/8/21 1:27 PM, Jonathan Marek wrote:

downstream msm-5.14 kernel added a write to this register, so match that.



Note: this should say msm-5.4 (msm-5.14 is not a thing)


Signed-off-by: Jonathan Marek 
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 +++-
  drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h | 2 ++
  2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index c1ee02d6371d..0f3390eab55e 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -751,8 +751,10 @@ static int a6xx_gmu_fw_start(struct a6xx_gmu *gmu, 
unsigned int state)
int ret;
u32 chipid;
  
-	if (adreno_is_a650(adreno_gpu))

+   if (adreno_is_a650(adreno_gpu)) {
+   gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF, 1);
gmu_write(gmu, REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF, 1);
+   }
  
  	if (state == GMU_WARM_BOOT) {

ret = a6xx_rpmh_start(gmu);
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
index 5a43d3090b0c..eeef3d6d89b8 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.xml.h
@@ -292,6 +292,8 @@ static inline uint32_t A6XX_GMU_GPU_NAP_CTRL_SID(uint32_t 
val)
  
  #define REG_A6XX_GPU_GMU_CX_GMU_CX_FAL_INTF			0x50f0
  
+#define REF_A6XX_GPU_GMU_CX_GMU_CX_FALNEXT_INTF		0x50f1

+
  #define REG_A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_MSG
0x5100
  
  #define REG_A6XX_GPU_GMU_CX_GMU_PWR_COL_CP_RESP			0x5101




[PATCH v3 0/3] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-06-08 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

v2:
 - rebased on DSI PHY reworks
 - reworked getting cphy_mode in dsi_host.c
 - documentation change in separate patch

v3:
 - yaml bindings
 - changed binding to "phy-mode = ;"

Jonathan Marek (3):
  dt-bindings: msm: dsi: add missing 7nm bindings
  dt-bindings: msm: dsi: document phy-type property for 7nm dsi phy
  drm/msm/dsi: support CPHY mode for 7nm pll/phy

 .../bindings/display/msm/dsi-phy-7nm.yaml |  70 +
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 +++-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  49 ++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 145 --
 include/dt-bindings/phy/phy.h |   2 +
 7 files changed, 258 insertions(+), 47 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml

-- 
2.26.1



[PATCH v3 1/3] dt-bindings: msm: dsi: add missing 7nm bindings

2021-06-08 Thread Jonathan Marek
These got lost when going from .txt to .yaml bindings, add them back.

Signed-off-by: Jonathan Marek 
---
 .../bindings/display/msm/dsi-phy-7nm.yaml | 66 +++
 1 file changed, 66 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml 
b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
new file mode 100644
index ..bf16b1c65e10
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/msm/dsi-phy-7nm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Display DSI 7nm PHY
+
+maintainers:
+  - Jonathan Marek 
+
+allOf:
+  - $ref: dsi-phy-common.yaml#
+
+properties:
+  compatible:
+oneOf:
+  - const: qcom,dsi-phy-7nm
+  - const: qcom,dsi-phy-7nm-8150
+
+  reg:
+items:
+  - description: dsi phy register set
+  - description: dsi phy lane register set
+  - description: dsi pll register set
+
+  reg-names:
+items:
+  - const: dsi_phy
+  - const: dsi_phy_lane
+  - const: dsi_pll
+
+  vdds-supply:
+description: |
+  Connected to VDD_A_DSI_PLL_0P9 pin (or VDDA_DSI{0,1}_PLL_0P9 for sm8150)
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - vdds-supply
+
+unevaluatedProperties: false
+
+examples:
+  - |
+ #include 
+ #include 
+
+ dsi-phy@ae94400 {
+ compatible = "qcom,dsi-phy-7nm";
+ reg = <0x0ae94400 0x200>,
+   <0x0ae94600 0x280>,
+   <0x0ae94900 0x260>;;
+ reg-names = "dsi_phy",
+ "dsi_phy_lane",
+ "dsi_pll";
+
+ #clock-cells = <1>;
+ #phy-cells = <0>;
+
+ vdds-supply = <&vreg_l5a_0p88>;
+ clocks = <&dispcc DISP_CC_MDSS_AHB_CLK>,
+  <&rpmhcc RPMH_CXO_CLK>;
+ clock-names = "iface", "ref";
+ };
-- 
2.26.1



[PATCH v3 2/3] dt-bindings: msm: dsi: document phy-type property for 7nm dsi phy

2021-06-08 Thread Jonathan Marek
Document a new phy-type property which will be used to determine whether
the phy should operate in D-PHY or C-PHY mode.

Signed-off-by: Jonathan Marek 
---
 .../devicetree/bindings/display/msm/dsi-phy-7nm.yaml  | 4 
 include/dt-bindings/phy/phy.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml 
b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
index bf16b1c65e10..d447b517ea19 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
+++ b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
@@ -34,6 +34,10 @@ properties:
 description: |
   Connected to VDD_A_DSI_PLL_0P9 pin (or VDDA_DSI{0,1}_PLL_0P9 for sm8150)
 
+  phy-type:
+description: |
+  D-PHY (default) or C-PHY mode: PHY_TYPE_DSI_DPHY or PHY_TYPE_DSI_CPHY
+
 required:
   - compatible
   - reg
diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h
index 887a31b250a8..b978dac16bb8 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -20,5 +20,7 @@
 #define PHY_TYPE_XPCS  7
 #define PHY_TYPE_SGMII 8
 #define PHY_TYPE_QSGMII9
+#define PHY_TYPE_DSI_DPHY  10
+#define PHY_TYPE_DSI_CPHY  11
 
 #endif /* _DT_BINDINGS_PHY */
-- 
2.26.1



[PATCH v3 3/3] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-06-08 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 -
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  49 
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 145 +++---
 5 files changed, 186 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.xml.h 
b/drivers/gpu/drm/msm/dsi/dsi.xml.h
index b8e9e608abfc..a59a9bd3f5d1 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.xml.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.xml.h
@@ -621,6 +621,8 @@ static inline uint32_t DSI_VERSION_MAJOR(uint32_t val)
return ((val) << DSI_VERSION_MAJOR__SHIFT) & DSI_VERSION_MAJOR__MASK;
 }
 
+#define REG_DSI_CPHY_MODE_CTRL 0x02d4
+
 #define REG_DSI_PHY_PLL_CTRL_0 0x0200
 #define DSI_PHY_PLL_CTRL_0_ENABLE  0x0001
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 809997f870f6..262d6d3b9c4b 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -27,6 +27,7 @@
 #include "dsi_cfg.h"
 #include "msm_kms.h"
 #include "msm_gem.h"
+#include "phy/dsi_phy.h"
 
 #define DSI_RESET_TOGGLE_DELAY_MS 20
 
@@ -170,6 +171,9 @@ struct msm_dsi_host {
int dlane_swap;
int num_data_lanes;
 
+   /* from phy DT */
+   bool cphy_mode;
+
u32 dma_cmd_ctrl_restore;
 
bool registered;
@@ -513,6 +517,7 @@ int msm_dsi_runtime_resume(struct device *dev)
 
 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
 {
+   u32 byte_intf_rate;
int ret;
 
DBG("Set clk rates: pclk=%d, byteclk=%d",
@@ -532,8 +537,13 @@ int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
}
 
if (msm_host->byte_intf_clk) {
-   ret = clk_set_rate(msm_host->byte_intf_clk,
-  msm_host->byte_clk_rate / 2);
+   /* For CPHY, byte_intf_clk is same as byte_clk */
+   if (msm_host->cphy_mode)
+   byte_intf_rate = msm_host->byte_clk_rate;
+   else
+   byte_intf_rate = msm_host->byte_clk_rate / 2;
+
+   ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate);
if (ret) {
pr_err("%s: Failed to set rate byte intf clk, %d\n",
   __func__, ret);
@@ -721,7 +731,11 @@ static void dsi_calc_pclk(struct msm_dsi_host *msm_host, 
bool is_dual_dsi)
lanes = 1;
}
 
-   do_div(pclk_bpp, (8 * lanes));
+   /* CPHY "byte_clk" is in units of 16 bits */
+   if (msm_host->cphy_mode)
+   do_div(pclk_bpp, (16 * lanes));
+   else
+   do_div(pclk_bpp, (8 * lanes));
 
msm_host->pixel_clk_rate = pclk_rate;
msm_host->byte_clk_rate = pclk_bpp;
@@ -947,6 +961,9 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, 
bool enable,
data |= DSI_CTRL_ENABLE;
 
dsi_write(msm_host, REG_DSI_CTRL, data);
+
+   if (msm_host->cphy_mode)
+   dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0));
 }
 
 static void dsi_set_video_dsc(struct msm_dsi_host *msm_host,
@@ -2278,6 +2295,8 @@ int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
struct clk *byte_clk_provider, *pixel_clk_provider;
int ret;
 
+   msm_host->cphy_mode = src_phy->cphy_mode;
+
ret = msm_dsi_phy_get_clk_provider(src_phy,
&byte_clk_provider, &pixel_clk_provider);
if (ret) {
@@ -2349,7 +2368,14 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host 
*host,
return;
}
 
-   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
+   /* CPHY transmits 16 bits over 7 clock cycles
+* "byte_clk" is in units of 16-bits (see dsi_calc_pclk),
+* so multiply by 7 to get the "bitclk rate"
+*/
+   if (msm_host->cphy_mode)
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 7;
+   else
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
clk_req->escclk_rate = msm_host->esc_clk_rate;
 }
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index 6ca6bfd4809b..145331480e74 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 
 #include "dsi_phy.h"
 
@@ -461,6 +462,51 @@ int m

Re: [v1 1/3] dt-bindings: msm/dsi: Add yaml schema for 7nm DSI PHY

2021-06-17 Thread Jonathan Marek

On 6/16/21 1:50 AM, rajee...@codeaurora.org wrote:

On 03-06-2021 01:32, rajee...@codeaurora.org wrote:

On 02-06-2021 02:28, Rob Herring wrote:

On Mon, May 31, 2021 at 07:03:53PM +0530, Rajeev Nandan wrote:



+
+properties:
+  compatible:
+    oneOf:
+  - const: qcom,dsi-phy-7nm


When would one use this?

This is for SM8250.




+  - const: qcom,dsi-phy-7nm-7280
+  - const: qcom,dsi-phy-7nm-8150


These don't look like full SoC names (sm8150?) and it's
,-.


Thanks, Rob, for the review.

I just took the `compatible` property currently used in the DSI PHY 
driver
(drivers/gpu/drm/msm/dsi/phy/dsi_phy.c), and added a new entry for 
sc7280.

A similar pattern of `compatible` names are used in other variants of the
DSI PHY driver e.g. qcom,qcom,dsi-phy-10nm-8998, qcom,dsi-phy-14nm-660 
etc.


The existing compatible names "qcom,dsi-phy-7nm-8150" (SoC at the end) 
make

some sense, if we look at the organization of the dsi phy driver code.
I am new to this and don't know the reason behind the current code
organization and this naming.

Yes, I agree with you, we should use full SoC names. Adding
the SoC name at the end does not feel very convincing, so I will 
change this
to the suggested format e.g. "qcom,sm8250-dsi-phy-7nm", and will 
rename the

occurrences in the driver and device tree accordingly.
Do I need to make changes for 10nm, 14nm, 20nm, and 28nm DSI PHY too?
Bindings doc for these PHYs recently got merged to msm-next [1]


[1]
https://gitlab.freedesktop.org/drm/msm/-/commit/8fc939e72ff80116c090aaf03952253a124d2a8e 





Hi Rob,

I missed adding "robh...@kernel.org" earlier in this thread.

Please check my response to your review comments. Regarding your 
suggestion to use ,- format for compatible property, 
should I also upload a new patch to make changes in 10nm, 14nm, 20nm, 
and 28nm DSI PHY DT bindings?


Thanks,
Rajeev



Hi,

I missed this and ended up sending a similar patch a week later (as part 
of my cphy series, because I needed it to add a "phy-type" property).


"qcom,dsi-phy-7nm" and "qcom,dsi-phy-7nm-8150" aren't new compatibles, 
they were previously documented in the .txt bindings, which are getting 
removed, but the new .yaml bindings didn't include them. Documenting 
them is just a fixup to that patch [1] which is already R-B'd by RobH 
(and has similar compatibles such as "qcom,dsi-phy-10nm" and 
"qcom,dsi-phy-10nm-8998

").

You can use a different/better naming scheme for sc7280, but changing 
the others has nothing to do with adding support for sc7280.


[1] 
https://gitlab.freedesktop.org/drm/msm/-/commit/8fc939e72ff80116c090aaf03952253a124d2a8e 







[PATCH v4 0/3] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-06-17 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

v2:
 - rebased on DSI PHY reworks
 - reworked getting cphy_mode in dsi_host.c
 - documentation change in separate patch

v3:
 - yaml bindings
 - changed binding to "phy-type = ;"

v4:
 - PHY_TYPE_{DPHY,CPHY} instead of PHY_TYPE_DSI_{DPHY,CPHY}
 - use enum/default for phy-type property
 - remove a stray semicolon in dts example

Jonathan Marek (3):
  dt-bindings: msm: dsi: add missing 7nm bindings
  dt-bindings: msm: dsi: document phy-type property for 7nm dsi phy
  drm/msm/dsi: support CPHY mode for 7nm pll/phy

 .../bindings/display/msm/dsi-phy-7nm.yaml |  71 +
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 +++-
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  49 ++
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 145 --
 include/dt-bindings/phy/phy.h |   2 +
 7 files changed, 259 insertions(+), 47 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml

-- 
2.26.1



[PATCH v4 1/3] dt-bindings: msm: dsi: add missing 7nm bindings

2021-06-17 Thread Jonathan Marek
These got lost when going from .txt to .yaml bindings, add them back.

Signed-off-by: Jonathan Marek 
---
 .../bindings/display/msm/dsi-phy-7nm.yaml | 66 +++
 1 file changed, 66 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml 
b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
new file mode 100644
index ..c0077ca7e9e7
--- /dev/null
+++ b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
@@ -0,0 +1,66 @@
+# SPDX-License-Identifier: GPL-2.0-only or BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/display/msm/dsi-phy-7nm.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Qualcomm Display DSI 7nm PHY
+
+maintainers:
+  - Jonathan Marek 
+
+allOf:
+  - $ref: dsi-phy-common.yaml#
+
+properties:
+  compatible:
+oneOf:
+  - const: qcom,dsi-phy-7nm
+  - const: qcom,dsi-phy-7nm-8150
+
+  reg:
+items:
+  - description: dsi phy register set
+  - description: dsi phy lane register set
+  - description: dsi pll register set
+
+  reg-names:
+items:
+  - const: dsi_phy
+  - const: dsi_phy_lane
+  - const: dsi_pll
+
+  vdds-supply:
+description: |
+  Connected to VDD_A_DSI_PLL_0P9 pin (or VDDA_DSI{0,1}_PLL_0P9 for sm8150)
+
+required:
+  - compatible
+  - reg
+  - reg-names
+  - vdds-supply
+
+unevaluatedProperties: false
+
+examples:
+  - |
+ #include 
+ #include 
+
+ dsi-phy@ae94400 {
+ compatible = "qcom,dsi-phy-7nm";
+ reg = <0x0ae94400 0x200>,
+   <0x0ae94600 0x280>,
+   <0x0ae94900 0x260>;
+ reg-names = "dsi_phy",
+ "dsi_phy_lane",
+ "dsi_pll";
+
+ #clock-cells = <1>;
+ #phy-cells = <0>;
+
+ vdds-supply = <&vreg_l5a_0p88>;
+ clocks = <&dispcc DISP_CC_MDSS_AHB_CLK>,
+  <&rpmhcc RPMH_CXO_CLK>;
+ clock-names = "iface", "ref";
+ };
-- 
2.26.1



[PATCH v4 2/3] dt-bindings: msm: dsi: document phy-type property for 7nm dsi phy

2021-06-17 Thread Jonathan Marek
Document a new phy-type property which will be used to determine whether
the phy should operate in D-PHY or C-PHY mode.

Signed-off-by: Jonathan Marek 
Reviewed-by: Laurent Pinchart 
---
 .../devicetree/bindings/display/msm/dsi-phy-7nm.yaml | 5 +
 include/dt-bindings/phy/phy.h| 2 ++
 2 files changed, 7 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml 
b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
index c0077ca7e9e7..70809d1cac54 100644
--- a/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
+++ b/Documentation/devicetree/bindings/display/msm/dsi-phy-7nm.yaml
@@ -34,6 +34,11 @@ properties:
 description: |
   Connected to VDD_A_DSI_PLL_0P9 pin (or VDDA_DSI{0,1}_PLL_0P9 for sm8150)
 
+  phy-type:
+description: D-PHY (default) or C-PHY mode
+enum: [ 10, 11 ]
+default: 10
+
 required:
   - compatible
   - reg
diff --git a/include/dt-bindings/phy/phy.h b/include/dt-bindings/phy/phy.h
index 887a31b250a8..f48c9acf251e 100644
--- a/include/dt-bindings/phy/phy.h
+++ b/include/dt-bindings/phy/phy.h
@@ -20,5 +20,7 @@
 #define PHY_TYPE_XPCS  7
 #define PHY_TYPE_SGMII 8
 #define PHY_TYPE_QSGMII9
+#define PHY_TYPE_DPHY  10
+#define PHY_TYPE_CPHY  11
 
 #endif /* _DT_BINDINGS_PHY */
-- 
2.26.1



[PATCH v4 3/3] drm/msm/dsi: support CPHY mode for 7nm pll/phy

2021-06-17 Thread Jonathan Marek
Add the required changes to support 7nm pll/phy in CPHY mode.

This adds a "qcom,dsi-phy-cphy-mode" property for the PHY node to enable
the CPHY mode.

Signed-off-by: Jonathan Marek 
Reviewed-by: Dmitry Baryshkov 
---
 drivers/gpu/drm/msm/dsi/dsi.xml.h |   2 +
 drivers/gpu/drm/msm/dsi/dsi_host.c|  34 -
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.c |  49 
 drivers/gpu/drm/msm/dsi/phy/dsi_phy.h |   3 +
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 145 +++---
 5 files changed, 186 insertions(+), 47 deletions(-)

diff --git a/drivers/gpu/drm/msm/dsi/dsi.xml.h 
b/drivers/gpu/drm/msm/dsi/dsi.xml.h
index b8e9e608abfc..a59a9bd3f5d1 100644
--- a/drivers/gpu/drm/msm/dsi/dsi.xml.h
+++ b/drivers/gpu/drm/msm/dsi/dsi.xml.h
@@ -621,6 +621,8 @@ static inline uint32_t DSI_VERSION_MAJOR(uint32_t val)
return ((val) << DSI_VERSION_MAJOR__SHIFT) & DSI_VERSION_MAJOR__MASK;
 }
 
+#define REG_DSI_CPHY_MODE_CTRL 0x02d4
+
 #define REG_DSI_PHY_PLL_CTRL_0 0x0200
 #define DSI_PHY_PLL_CTRL_0_ENABLE  0x0001
 
diff --git a/drivers/gpu/drm/msm/dsi/dsi_host.c 
b/drivers/gpu/drm/msm/dsi/dsi_host.c
index 809997f870f6..262d6d3b9c4b 100644
--- a/drivers/gpu/drm/msm/dsi/dsi_host.c
+++ b/drivers/gpu/drm/msm/dsi/dsi_host.c
@@ -27,6 +27,7 @@
 #include "dsi_cfg.h"
 #include "msm_kms.h"
 #include "msm_gem.h"
+#include "phy/dsi_phy.h"
 
 #define DSI_RESET_TOGGLE_DELAY_MS 20
 
@@ -170,6 +171,9 @@ struct msm_dsi_host {
int dlane_swap;
int num_data_lanes;
 
+   /* from phy DT */
+   bool cphy_mode;
+
u32 dma_cmd_ctrl_restore;
 
bool registered;
@@ -513,6 +517,7 @@ int msm_dsi_runtime_resume(struct device *dev)
 
 int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
 {
+   u32 byte_intf_rate;
int ret;
 
DBG("Set clk rates: pclk=%d, byteclk=%d",
@@ -532,8 +537,13 @@ int dsi_link_clk_set_rate_6g(struct msm_dsi_host *msm_host)
}
 
if (msm_host->byte_intf_clk) {
-   ret = clk_set_rate(msm_host->byte_intf_clk,
-  msm_host->byte_clk_rate / 2);
+   /* For CPHY, byte_intf_clk is same as byte_clk */
+   if (msm_host->cphy_mode)
+   byte_intf_rate = msm_host->byte_clk_rate;
+   else
+   byte_intf_rate = msm_host->byte_clk_rate / 2;
+
+   ret = clk_set_rate(msm_host->byte_intf_clk, byte_intf_rate);
if (ret) {
pr_err("%s: Failed to set rate byte intf clk, %d\n",
   __func__, ret);
@@ -721,7 +731,11 @@ static void dsi_calc_pclk(struct msm_dsi_host *msm_host, 
bool is_dual_dsi)
lanes = 1;
}
 
-   do_div(pclk_bpp, (8 * lanes));
+   /* CPHY "byte_clk" is in units of 16 bits */
+   if (msm_host->cphy_mode)
+   do_div(pclk_bpp, (16 * lanes));
+   else
+   do_div(pclk_bpp, (8 * lanes));
 
msm_host->pixel_clk_rate = pclk_rate;
msm_host->byte_clk_rate = pclk_bpp;
@@ -947,6 +961,9 @@ static void dsi_ctrl_config(struct msm_dsi_host *msm_host, 
bool enable,
data |= DSI_CTRL_ENABLE;
 
dsi_write(msm_host, REG_DSI_CTRL, data);
+
+   if (msm_host->cphy_mode)
+   dsi_write(msm_host, REG_DSI_CPHY_MODE_CTRL, BIT(0));
 }
 
 static void dsi_set_video_dsc(struct msm_dsi_host *msm_host,
@@ -2278,6 +2295,8 @@ int msm_dsi_host_set_src_pll(struct mipi_dsi_host *host,
struct clk *byte_clk_provider, *pixel_clk_provider;
int ret;
 
+   msm_host->cphy_mode = src_phy->cphy_mode;
+
ret = msm_dsi_phy_get_clk_provider(src_phy,
&byte_clk_provider, &pixel_clk_provider);
if (ret) {
@@ -2349,7 +2368,14 @@ void msm_dsi_host_get_phy_clk_req(struct mipi_dsi_host 
*host,
return;
}
 
-   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
+   /* CPHY transmits 16 bits over 7 clock cycles
+* "byte_clk" is in units of 16-bits (see dsi_calc_pclk),
+* so multiply by 7 to get the "bitclk rate"
+*/
+   if (msm_host->cphy_mode)
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 7;
+   else
+   clk_req->bitclk_rate = msm_host->byte_clk_rate * 8;
clk_req->escclk_rate = msm_host->esc_clk_rate;
 }
 
diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c 
b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
index 6ca6bfd4809b..3e64f1840672 100644
--- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy.c
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 
 #include "dsi_phy.h"
 
@@ -461,6 +462,51 @@ int m

Re: [Freedreno] [PATCH v3 4/7] drm/msm/a2xx: Implement .gpu_busy

2023-02-24 Thread Jonathan Marek
This won't work because a2xx freedreno userspace expects to own all the 
perfcounters.


This will break perfcounters for userspace, and when userspace isn't 
using perfcounters, this won't count correctly because userspace writes 
0 to CP_PERFMON_CNTL at the start of every submit.


On 2/23/23 5:52 AM, Konrad Dybcio wrote:

Implement gpu_busy based on the downstream msm-3.4 code [1]. This
allows us to use devfreq on this old old old hardware!

[1] 
https://github.com/LineageOS/android_kernel_sony_apq8064/blob/lineage-16.0/drivers/gpu/msm/adreno_a2xx.c#L1975

Reviewed-by: Dmitry Baryshkov 
Signed-off-by: Konrad Dybcio 
---
  drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 26 ++
  1 file changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
index c67089a7ebc1..104bdf28cdaf 100644
--- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c
@@ -481,6 +481,31 @@ a2xx_create_address_space(struct msm_gpu *gpu, struct 
platform_device *pdev)
return aspace;
  }
  
+/* While the precise size of this field is unknown, it holds at least these three values.. */

+static u64 a2xx_gpu_busy(struct msm_gpu *gpu, unsigned long *out_sample_rate)
+{
+   u64 busy_cycles;
+
+   /* Freeze the counter */
+   gpu_write(gpu, REG_A2XX_CP_PERFMON_CNTL, PERF_STATE_FREEZE);
+
+   busy_cycles = gpu_read64(gpu, REG_A2XX_RBBM_PERFCOUNTER1_LO);
+
+   /* Reset the counter */
+   gpu_write(gpu, REG_A2XX_CP_PERFMON_CNTL, PERF_STATE_RESET);
+
+   /* Re-enable the performance monitors */
+   gpu_rmw(gpu, REG_A2XX_RBBM_PM_OVERRIDE2,
+   A2XX_RBBM_PM_OVERRIDE2_DEBUG_PERF_SCLK_PM_OVERRIDE,
+   A2XX_RBBM_PM_OVERRIDE2_DEBUG_PERF_SCLK_PM_OVERRIDE);
+   gpu_write(gpu, REG_A2XX_RBBM_PERFCOUNTER1_SELECT, 1);
+   gpu_write(gpu, REG_A2XX_CP_PERFMON_CNTL, PERF_STATE_ENABLE);
+
+   *out_sample_rate = clk_get_rate(gpu->core_clk);
+
+   return busy_cycles;
+}
+
  static u32 a2xx_get_rptr(struct msm_gpu *gpu, struct msm_ringbuffer *ring)
  {
ring->memptrs->rptr = gpu_read(gpu, REG_AXXX_CP_RB_RPTR);
@@ -502,6 +527,7 @@ static const struct adreno_gpu_funcs funcs = {
  #if defined(CONFIG_DEBUG_FS) || defined(CONFIG_DEV_COREDUMP)
.show = adreno_show,
  #endif
+   .gpu_busy = a2xx_gpu_busy,
.gpu_state_get = a2xx_gpu_state_get,
.gpu_state_put = adreno_gpu_state_put,
.create_address_space = a2xx_create_address_space,



Re: [12/13] drm/scheduler: rework entity flush, kill and fini

2022-12-26 Thread Jonathan Marek
This patch broke drm/msm in 6.2-rc1 for me. drm_sched_entity_destroy() 
never returns when exiting a process from gdb if it has a drm/msm fd 
opened (if the fd is closed normally then it doesn't have this problem).


Re: [Freedreno] [PATCH 5/6] drm/msm/a6xx: Use GMU_ALWAYS_ON_COUNTER for GMU-equipped GPUs in timestamp

2023-05-17 Thread Jonathan Marek
AFAIK GMU_ALWAYS_ON_COUNTER does not have the same value as 
CP_ALWAYS_ON_COUNTER (only the same frequency), so changing this would 
break userspace expecting to be able to compare the value returned by 
MSM_PARAM_TIMESTAMP with CP timestamp values.


On 5/17/23 12:50 PM, Konrad Dybcio wrote:

Use the always-on counter provided by the GMU to skip having to
keep the GPU online.

Signed-off-by: Konrad Dybcio 
---
  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 9 +++--
  1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 8707e8b6ac7e..d2a999b90589 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1664,12 +1664,9 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, 
uint64_t *value)
  
  	mutex_lock(&a6xx_gpu->gmu.lock);
  
-	/* Force the GPU power on so we can read this register */

-   a6xx_gmu_set_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
-
-   *value = gpu_read64(gpu, REG_A6XX_CP_ALWAYS_ON_COUNTER);
-
-   a6xx_gmu_clear_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
+   *value = gmu_read64(&a6xx_gpu->gmu,
+   REG_A6XX_GMU_ALWAYS_ON_COUNTER_L,
+   REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
  
  	mutex_unlock(&a6xx_gpu->gmu.lock);
  



Re: [Freedreno] [PATCH 5/6] drm/msm/a6xx: Use GMU_ALWAYS_ON_COUNTER for GMU-equipped GPUs in timestamp

2023-05-17 Thread Jonathan Marek

On 5/17/23 3:08 PM, Konrad Dybcio wrote:



On 17.05.2023 20:09, Jonathan Marek wrote:

AFAIK GMU_ALWAYS_ON_COUNTER does not have the same value as 
CP_ALWAYS_ON_COUNTER (only the same frequency), so changing this would break 
userspace expecting to be able to compare the value returned by 
MSM_PARAM_TIMESTAMP with CP timestamp values.

FWIW A630 and A730 seem to work fine with this patch. Anything
in particular I should look out for?


mesa uses it for perfetto tracing to synchronize the GPU/CPU timelines.



Konrad


On 5/17/23 12:50 PM, Konrad Dybcio wrote:

Use the always-on counter provided by the GMU to skip having to
keep the GPU online.

Signed-off-by: Konrad Dybcio 
---
   drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 9 +++--
   1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 8707e8b6ac7e..d2a999b90589 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -1664,12 +1664,9 @@ static int a6xx_get_timestamp(struct msm_gpu *gpu, 
uint64_t *value)
     mutex_lock(&a6xx_gpu->gmu.lock);
   -    /* Force the GPU power on so we can read this register */
-    a6xx_gmu_set_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
-
-    *value = gpu_read64(gpu, REG_A6XX_CP_ALWAYS_ON_COUNTER);
-
-    a6xx_gmu_clear_oob(&a6xx_gpu->gmu, GMU_OOB_PERFCOUNTER_SET);
+    *value = gmu_read64(&a6xx_gpu->gmu,
+    REG_A6XX_GMU_ALWAYS_ON_COUNTER_L,
+    REG_A6XX_GMU_ALWAYS_ON_COUNTER_H);
     mutex_unlock(&a6xx_gpu->gmu.lock);
  


[PATCH] drm/msm/dpu: increase memtype count to 16 for sm8550

2023-08-02 Thread Jonathan Marek
sm8550 has 16 vbif clients.

This fixes the extra 2 clients (DMA4/DMA5) not having their memtype
initialized. This fixes DMA4/DMA5 planes not displaying correctly.

Fixes: efcd0107 ("drm/msm/dpu: add support for SM8550")
Signed-off-by: Jonathan Marek 
---
 .../msm/disp/dpu1/catalog/dpu_9_0_sm8550.h|  4 ++--
 .../gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c| 20 +++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_9_0_sm8550.h 
b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_9_0_sm8550.h
index f17b9a7fee85..89a2ac1e840d 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_9_0_sm8550.h
+++ b/drivers/gpu/drm/msm/disp/dpu1/catalog/dpu_9_0_sm8550.h
@@ -245,8 +245,8 @@ const struct dpu_mdss_cfg dpu_sm8550_cfg = {
.merge_3d = sm8550_merge_3d,
.intf_count = ARRAY_SIZE(sm8550_intf),
.intf = sm8550_intf,
-   .vbif_count = ARRAY_SIZE(sdm845_vbif),
-   .vbif = sdm845_vbif,
+   .vbif_count = ARRAY_SIZE(sm8550_vbif),
+   .vbif = sm8550_vbif,
.perf = &sm8550_perf_data,
.mdss_irqs = BIT(MDP_SSPP_TOP0_INTR) | \
 BIT(MDP_SSPP_TOP0_INTR2) | \
diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
index 0de507d4d7b7..8b17a4a9b438 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_catalog.c
@@ -663,6 +663,26 @@ static const struct dpu_vbif_cfg sdm845_vbif[] = {
},
 };
 
+static const struct dpu_vbif_cfg sm8550_vbif[] = {
+   {
+   .name = "vbif_rt", .id = VBIF_RT,
+   .base = 0, .len = 0x1040,
+   .features = BIT(DPU_VBIF_QOS_REMAP),
+   .xin_halt_timeout = 0x4000,
+   .qos_rp_remap_size = 0x40,
+   .qos_rt_tbl = {
+   .npriority_lvl = ARRAY_SIZE(sdm845_rt_pri_lvl),
+   .priority_lvl = sdm845_rt_pri_lvl,
+   },
+   .qos_nrt_tbl = {
+   .npriority_lvl = ARRAY_SIZE(sdm845_nrt_pri_lvl),
+   .priority_lvl = sdm845_nrt_pri_lvl,
+   },
+   .memtype_count = 16,
+   .memtype = {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3},
+   },
+};
+
 /*
  * PERF data config
  */
-- 
2.26.1



[PATCH] drm/msm/dpu: add missing flush and fetch bits for DMA4/DMA5 planes

2023-07-04 Thread Jonathan Marek
Note that with this, DMA4/DMA5 are still non-functional, but at least
display *something* in modetest instead of nothing or underflow.

Fixes: efcd0107727c ("drm/msm/dpu: add support for SM8550")
Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
index bbdc95ce374a..5af5975f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_ctl.c
@@ -51,7 +51,7 @@
 
 static const u32 fetch_tbl[SSPP_MAX] = {CTL_INVALID_BIT, 16, 17, 18, 19,
CTL_INVALID_BIT, CTL_INVALID_BIT, CTL_INVALID_BIT, CTL_INVALID_BIT, 0,
-   1, 2, 3, CTL_INVALID_BIT, CTL_INVALID_BIT};
+   1, 2, 3, 4, 5};
 
 static const struct dpu_ctl_cfg *_ctl_offset(enum dpu_ctl ctl,
const struct dpu_mdss_cfg *m,
@@ -206,6 +206,12 @@ static void dpu_hw_ctl_update_pending_flush_sspp(struct 
dpu_hw_ctl *ctx,
case SSPP_DMA3:
ctx->pending_flush_mask |= BIT(25);
break;
+   case SSPP_DMA4:
+   ctx->pending_flush_mask |= BIT(13);
+   break;
+   case SSPP_DMA5:
+   ctx->pending_flush_mask |= BIT(14);
+   break;
case SSPP_CURSOR0:
ctx->pending_flush_mask |= BIT(22);
break;
-- 
2.26.1



[PATCH v2] drm/msm: handle for EPROBE_DEFER for of_icc_get

2020-07-10 Thread Jonathan Marek
Check for errors instead of silently not using icc if the msm driver
probes before the interconnect driver.

Allow ENODATA for ocmem path, as it is optional and this error
is returned when "gfx-mem" path is provided but not "ocmem".

Remove the WARN_ON in msm_gpu_cleanup because INIT_LIST_HEAD won't have
been called on the list yet when going through the defer error path.

Changes in v2:
* Changed to not only check for EPROBE_DEFER

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/adreno_gpu.c | 17 ++---
 drivers/gpu/drm/msm/msm_gpu.c   |  2 --
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
index 89673c7ed473..0f5217202eb5 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
@@ -940,12 +940,20 @@ static int adreno_get_pwrlevels(struct device *dev,
 */
gpu->icc_path = of_icc_get(dev, NULL);
}
-   if (IS_ERR(gpu->icc_path))
+   if (IS_ERR(gpu->icc_path)) {
+   ret = PTR_ERR(gpu->icc_path);
gpu->icc_path = NULL;
+   return ret;
+   }
 
gpu->ocmem_icc_path = of_icc_get(dev, "ocmem");
-   if (IS_ERR(gpu->ocmem_icc_path))
+   if (IS_ERR(gpu->ocmem_icc_path)) {
+   ret = PTR_ERR(gpu->ocmem_icc_path);
gpu->ocmem_icc_path = NULL;
+   /* allow -ENODATA, ocmem icc is optional */
+   if (ret != -ENODATA)
+   return ret;
+   }
 
return 0;
 }
@@ -996,6 +1004,7 @@ int adreno_gpu_init(struct drm_device *drm, struct 
platform_device *pdev,
struct adreno_platform_config *config = pdev->dev.platform_data;
struct msm_gpu_config adreno_gpu_config  = { 0 };
struct msm_gpu *gpu = &adreno_gpu->base;
+   int ret;
 
adreno_gpu->funcs = funcs;
adreno_gpu->info = adreno_info(config->rev);
@@ -1007,7 +1016,9 @@ int adreno_gpu_init(struct drm_device *drm, struct 
platform_device *pdev,
 
adreno_gpu_config.nr_rings = nr_rings;
 
-   adreno_get_pwrlevels(&pdev->dev, gpu);
+   ret = adreno_get_pwrlevels(&pdev->dev, gpu);
+   if (ret)
+   return ret;
 
pm_runtime_set_autosuspend_delay(&pdev->dev,
adreno_gpu->info->inactive_period);
diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c
index a22d30622306..ccf9a0dd9706 100644
--- a/drivers/gpu/drm/msm/msm_gpu.c
+++ b/drivers/gpu/drm/msm/msm_gpu.c
@@ -959,8 +959,6 @@ void msm_gpu_cleanup(struct msm_gpu *gpu)
 
DBG("%s", gpu->name);
 
-   WARN_ON(!list_empty(&gpu->active_list));
-
for (i = 0; i < ARRAY_SIZE(gpu->rb); i++) {
msm_ringbuffer_destroy(gpu->rb[i]);
gpu->rb[i] = NULL;
-- 
2.26.1

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


Re: [PATCH v4 3/7] drm: msm: a6xx: set gpu freq through hfi

2020-07-10 Thread Jonathan Marek

On 7/9/20 4:00 PM, Akhil P Oommen wrote:

Newer targets support changing gpu frequency through HFI. So
use that wherever supported instead of the legacy method.



It was already using HFI on newer targets. Don't break it in one commit 
then fix it in the next.



Signed-off-by: Akhil P Oommen 
---
  drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 11 +++
  1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
index 233afea..b547339 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c
@@ -121,6 +121,12 @@ void a6xx_gmu_set_freq(struct msm_gpu *gpu, struct 
dev_pm_opp *opp)
if (gpu_freq == gmu->gpu_freqs[perf_index])
break;
  
+	if (!gmu->legacy) {

+   a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+   icc_set_bw(gpu->icc_path, 0, MBps_to_icc(7216));
+   return;
+   }
+
gmu->current_perf_index = perf_index;
gmu->freq = gmu->gpu_freqs[perf_index];
  
@@ -893,10 +899,7 @@ int a6xx_gmu_resume(struct a6xx_gpu *a6xx_gpu)

enable_irq(gmu->hfi_irq);
  
  	/* Set the GPU to the current freq */

-   if (gmu->legacy)
-   a6xx_gmu_set_initial_freq(gpu, gmu);
-   else
-   a6xx_hfi_set_freq(gmu, gmu->current_perf_index);
+   a6xx_gmu_set_initial_freq(gpu, gmu);
  
  	/*

 * "enable" the GX power domain which won't actually do anything but it


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


[PATCH v2 1/8] drm/msm/dpu: use right setup_blend_config for sm8150 and sm8250

2020-07-14 Thread Jonathan Marek
All DPU versions starting from 4.0 use the sdm845 version, so check for
that instead of checking each version individually. This chooses the right
function for sm8150 and sm8250.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
index 37becd43bd54..4b8baf71423f 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_lm.c
@@ -152,14 +152,13 @@ static void _setup_mixer_ops(const struct dpu_mdss_cfg *m,
unsigned long features)
 {
ops->setup_mixer_out = dpu_hw_lm_setup_out;
-   if (IS_SDM845_TARGET(m->hwversion) || IS_SDM670_TARGET(m->hwversion)
-   || IS_SC7180_TARGET(m->hwversion))
+   if (m->hwversion >= DPU_HW_VER_400)
ops->setup_blend_config = dpu_hw_lm_setup_blend_config_sdm845;
else
ops->setup_blend_config = dpu_hw_lm_setup_blend_config;
ops->setup_alpha_out = dpu_hw_lm_setup_color3;
ops->setup_border_color = dpu_hw_lm_setup_border_color;
-};
+}
 
 static struct dpu_hw_blk_ops dpu_hw_ops;
 
-- 
2.26.1

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


[PATCH v2 1/2] drm/msm/a6xx: hwcg tables in gpulist

2020-07-14 Thread Jonathan Marek
This will allow supporting different hwcg tables for a6xx.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 25 ++
 drivers/gpu/drm/msm/adreno/adreno_device.c |  1 +
 drivers/gpu/drm/msm/adreno/adreno_gpu.h|  8 +++
 3 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 3397e5e00d1c..ddcbc57ac25d 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -151,10 +151,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct 
msm_gem_submit *submit,
a6xx_flush(gpu, ring);
 }
 
-static const struct {
-   u32 offset;
-   u32 value;
-} a6xx_hwcg[] = {
+const struct adreno_reglist a630_hwcg[] = {
{REG_A6XX_RBBM_CLOCK_CNTL_SP0, 0x},
{REG_A6XX_RBBM_CLOCK_CNTL_SP1, 0x},
{REG_A6XX_RBBM_CLOCK_CNTL_SP2, 0x},
@@ -259,7 +256,8 @@ static const struct {
{REG_A6XX_RBBM_CLOCK_MODE_HLSQ, 0x},
{REG_A6XX_RBBM_CLOCK_CNTL_GMU_GX, 0x0222},
{REG_A6XX_RBBM_CLOCK_DELAY_GMU_GX, 0x0111},
-   {REG_A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x0555}
+   {REG_A6XX_RBBM_CLOCK_HYST_GMU_GX, 0x0555},
+   {},
 };
 
 static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
@@ -267,9 +265,13 @@ static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
struct a6xx_gmu *gmu = &a6xx_gpu->gmu;
+   const struct adreno_reglist *reg;
unsigned int i;
u32 val;
 
+   if (!adreno_gpu->info->hwcg)
+   return;
+
val = gpu_read(gpu, REG_A6XX_RBBM_CLOCK_CNTL);
 
/* Don't re-program the registers if they are already correct */
@@ -279,9 +281,8 @@ static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state)
/* Disable SP clock before programming HWCG registers */
gmu_rmw(gmu, REG_A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 1, 0);
 
-   for (i = 0; i < ARRAY_SIZE(a6xx_hwcg); i++)
-   gpu_write(gpu, a6xx_hwcg[i].offset,
-   state ? a6xx_hwcg[i].value : 0);
+   for (i = 0; (reg = &adreno_gpu->info->hwcg[i], reg->offset); i++)
+   gpu_write(gpu, reg->offset, state ? reg->value : 0);
 
/* Enable SP clock */
gmu_rmw(gmu, REG_A6XX_GPU_GMU_GX_SPTPRAC_CLOCK_CONTROL, 0, 1);
@@ -437,12 +438,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu)
gpu_write(gpu, REG_A6XX_TPL1_ADDR_MODE_CNTL, 0x1);
gpu_write(gpu, REG_A6XX_RBBM_SECVID_TSB_ADDR_MODE_CNTL, 0x1);
 
-   /*
-* enable hardware clockgating
-* For now enable clock gating only for a630
-*/
-   if (adreno_is_a630(adreno_gpu))
-   a6xx_set_hwcg(gpu, true);
+   /* enable hardware clockgating */
+   a6xx_set_hwcg(gpu, true);
 
/* VBIF/GBIF start*/
if (adreno_is_a640(adreno_gpu) || adreno_is_a650(adreno_gpu)) {
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c 
b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 7732f03d9e3a..97996e7fc668 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -200,6 +200,7 @@ static const struct adreno_info gpulist[] = {
.inactive_period = DRM_MSM_INACTIVE_PERIOD,
.init = a6xx_gpu_init,
.zapfw = "a630_zap.mdt",
+   .hwcg = a630_hwcg,
}, {
.rev = ADRENO_REV(6, 4, 0, ANY_ID),
.revn = 640,
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h 
b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
index 2f5d2c3acc3a..426cabd374bb 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
+++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
@@ -68,6 +68,13 @@ struct adreno_gpu_funcs {
int (*get_timestamp)(struct msm_gpu *gpu, uint64_t *value);
 };
 
+struct adreno_reglist {
+   u32 offset;
+   u32 value;
+};
+
+extern const struct adreno_reglist a630_hwcg[];
+
 struct adreno_info {
struct adreno_rev rev;
uint32_t revn;
@@ -78,6 +85,7 @@ struct adreno_info {
struct msm_gpu *(*init)(struct drm_device *dev);
const char *zapfw;
u32 inactive_period;
+   const struct adreno_reglist *hwcg;
 };
 
 const struct adreno_info *adreno_info(struct adreno_rev rev);
-- 
2.26.1

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


[PATCH v2 6/8] drm/msm/dpu: intf timing path for displayport

2020-07-14 Thread Jonathan Marek
Calculate the correct timings for displayport, from downstream driver.

Signed-off-by: Jonathan Marek 
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c 
b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
index 64f556d693dd..6f0f54588124 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_intf.c
@@ -107,11 +107,6 @@ static void dpu_hw_intf_setup_timing_engine(struct 
dpu_hw_intf *ctx,
display_v_end = ((vsync_period - p->v_front_porch) * hsync_period) +
p->hsync_skew - 1;
 
-   if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) {
-   display_v_start += p->hsync_pulse_width + p->h_back_porch;
-   display_v_end -= p->h_front_porch;
-   }
-
hsync_start_x = p->h_back_porch + p->hsync_pulse_width;
hsync_end_x = hsync_period - p->h_front_porch - 1;
 
@@ -144,10 +139,25 @@ static void dpu_hw_intf_setup_timing_engine(struct 
dpu_hw_intf *ctx,
hsync_ctl = (hsync_period << 16) | p->hsync_pulse_width;
display_hctl = (hsync_end_x << 16) | hsync_start_x;
 
+   if (ctx->cap->type == INTF_EDP || ctx->cap->type == INTF_DP) {
+   active_h_start = hsync_start_x;
+   active_h_end = active_h_start + p->xres - 1;
+   active_v_start = display_v_start;
+   active_v_end = active_v_start + (p->yres * hsync_period) - 1;
+
+   display_v_start += p->hsync_pulse_width + p->h_back_porch;
+
+   active_hctl = (active_h_end << 16) | active_h_start;
+   display_hctl = active_hctl;
+   }
+
den_polarity = 0;
if (ctx->cap->type == INTF_HDMI) {
hsync_polarity = p->yres >= 720 ? 0 : 1;
vsync_polarity = p->yres >= 720 ? 0 : 1;
+   } else if (ctx->cap->type == INTF_DP) {
+   hsync_polarity = p->hsync_polarity;
+   vsync_polarity = p->vsync_polarity;
} else {
hsync_polarity = 0;
vsync_polarity = 0;
-- 
2.26.1

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


  1   2   3   >