[PATCH 2/2] drm/dp_mst: Align mst link rate with soure rate

2021-01-12 Thread Koba Ko
After read the link rate from MST hub, align with
maximum source rate.

Signed-off-by: Koba Ko 
---
 drivers/gpu/drm/drm_dp_mst_topology.c   | 8 
 drivers/gpu/drm/i915/display/intel_dp.c | 7 +++
 include/drm/drm_dp_helper.h | 8 
 include/drm/drm_dp_mst_helper.h | 4 
 4 files changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 6982ecbf30b5..e7ceae97be85 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3672,6 +3672,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
 {
int ret = 0;
struct drm_dp_mst_branch *mstb = NULL;
+   unsigned int max_link_rate_tbl[MAX_DRM_DP_MAX_RATE + 1] = {
+   DP_LINK_BW_1_62, DP_LINK_BW_2_7, DP_LINK_BW_5_4,
+   DP_LINK_BW_8_1, DP_LINK_RATE_TABLE
+   };
 
mutex_lock(>payload_lock);
mutex_lock(>lock);
@@ -3693,6 +3697,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
goto out_unlock;
}
 
+   if (mgr->max_source_rate < MAX_DRM_DP_MAX_RATE)
+   mgr->dpcd[1] = max_link_rate_tbl[mgr->max_source_rate];
+
mgr->pbn_div = drm_dp_get_vc_payload_bw(mgr->dpcd[1],
mgr->dpcd[2] & 
DP_MAX_LANE_COUNT_MASK);
if (mgr->pbn_div == 0) {
@@ -5422,6 +5429,7 @@ int drm_dp_mst_topology_mgr_init(struct 
drm_dp_mst_topology_mgr *mgr,
mgr->aux = aux;
mgr->max_dpcd_transaction_bytes = max_dpcd_transaction_bytes;
mgr->max_payloads = max_payloads;
+   mgr->max_source_rate = MAX_DRM_DP_MAX_RATE;
mgr->conn_base_id = conn_base_id;
if (max_payloads + 1 > sizeof(mgr->payload_mask) * 8 ||
max_payloads + 1 > sizeof(mgr->vcpi_mask) * 8)
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index 469e765a1b7b..a89b4c823123 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5392,6 +5392,13 @@ intel_dp_configure_mst(struct intel_dp *intel_dp)
intel_dp->is_mst = sink_can_mst &&
i915->params.enable_dp_mst;
 
+   if (intel_dp_source_supports_hbr3(intel_dp))
+   intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR3;
+   else if (intel_dp_source_supports_hbr2(intel_dp))
+   intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR2;
+   else
+   intel_dp->mst_mgr.max_source_rate = DRM_DP_MAX_RATE_HBR;
+
drm_dp_mst_topology_mgr_set_mst(_dp->mst_mgr,
intel_dp->is_mst);
 }
diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 6236f212da61..ef2b328469cd 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -183,6 +183,14 @@ struct drm_device;
 #define DP_SUPPORTED_LINK_RATES0x010 /* eDP 1.4 */
 # define DP_MAX_SUPPORTED_RATES 8  /* 16-bit 
little-endian */
 
+enum drm_dp_max_link_rate {
+   DRM_DP_MAX_RATE_RBR = 0,
+   DRM_DP_MAX_RATE_HBR,
+   DRM_DP_MAX_RATE_HBR2,
+   DRM_DP_MAX_RATE_HBR3,
+   MAX_DRM_DP_MAX_RATE
+};
+
 /* Multiple stream transport */
 #define DP_FAUX_CAP0x020   /* 1.2 */
 # define DP_FAUX_CAP_1 (1 << 0)
diff --git a/include/drm/drm_dp_mst_helper.h b/include/drm/drm_dp_mst_helper.h
index f5e92fe9151c..e7d8c899fea0 100644
--- a/include/drm/drm_dp_mst_helper.h
+++ b/include/drm/drm_dp_mst_helper.h
@@ -593,6 +593,10 @@ struct drm_dp_mst_topology_mgr {
 * @max_payloads: maximum number of payloads the GPU can generate.
 */
int max_payloads;
+   /**
+* @max_source_rate: maximum link rate of source.
+*/
+   int max_source_rate;
/**
 * @conn_base_id: DRM connector ID this mgr is connected to. Only used
 * to build the MST connector path value.
-- 
2.25.1



[PATCH 1/2] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2021-01-12 Thread Koba Ko
As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1,read the DP_DP13_DPCD_REV to
get the faster capability.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0,read DP_DPCD_REV.

Signed-off-by: Koba Ko 
Reviewed-by: Lyude Paul 
[added aux name to drm_dbg_kms() call]
Signed-off-by: Lyude Paul 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20200922065313.4794-1-koba...@canonical.com
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 0401b2f47500..6982ecbf30b5 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3686,9 +3686,10 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
WARN_ON(mgr->mst_primary);
 
/* get dpcd info */
-   ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
-   if (ret != DP_RECEIVER_CAP_SIZE) {
-   DRM_DEBUG_KMS("failed to read DPCD\n");
+   ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
+   if (ret < 0) {
+   drm_dbg_kms(mgr->dev, "%s: failed to read DPCD, ret 
%d\n",
+   mgr->aux->name, ret);
goto out_unlock;
}
 
-- 
2.25.1



[PATCH] Revert "drm/dp_mst: Retrieve extended DPCD caps for topology manager"

2020-11-02 Thread Koba Ko
This reverts commit ad44c03208e46b83e4ae3269e32c9e524aa71cf8.

Currently DRM driver assume the source device caps is higher than the MST device
caps. With this commit, this statement would be broken.

e.g. the source device only support DP1.2 and the mst device support DP1.4.

Signed-off-by: Koba Ko 
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 153b6065ba29..e87542533640 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3686,10 +3686,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
WARN_ON(mgr->mst_primary);
 
/* get dpcd info */
-   ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
-   if (ret < 0) {
-   drm_dbg_kms(mgr->dev, "%s: failed to read DPCD, ret 
%d\n",
-   mgr->aux->name, ret);
+   ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
+   if (ret != DP_RECEIVER_CAP_SIZE) {
+   DRM_DEBUG_KMS("failed to read DPCD\n");
goto out_unlock;
}
 
-- 
2.17.1



Re: [PATCH V4] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2020-09-22 Thread Koba Ko
Thanks for the review.
Sorry for that I thought the review tag should be appended by myself.
One thing to confirm with you, will you or I push this patch to drm-misc-next ?

Thanks a lot.

On Wed, Sep 23, 2020 at 2:01 AM Lyude Paul  wrote:
>
> One last change I realized we should do is print the name of the AUX adapter
> in question. I don't mind just adding that myself before I push it though so
> you don't need to send a respin.
>
> Going to go push this to drm-misc-next, thanks!
>
> On Tue, 2020-09-22 at 14:53 +0800, Koba Ko wrote:
> > As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1,read the DP_DP13_DPCD_REV to
> > get the faster capability.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0,read DP_DPCD_REV.
> >
> > Signed-off-by: Koba Ko 
> > Reviewed-by: Lyude Paul 
> > ---
> >  drivers/gpu/drm/drm_dp_mst_topology.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> > b/drivers/gpu/drm/drm_dp_mst_topology.c
> > index e87542533640..63f8809b9aa4 100644
> > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > @@ -3686,9 +3686,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct
> > drm_dp_mst_topology_mgr *mgr, bool ms
> >   WARN_ON(mgr->mst_primary);
> >
> >   /* get dpcd info */
> > - ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd,
> > DP_RECEIVER_CAP_SIZE);
> > - if (ret != DP_RECEIVER_CAP_SIZE) {
> > - DRM_DEBUG_KMS("failed to read DPCD\n");
> > + ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
> > + if (ret < 0) {
> > + drm_dbg_kms(mgr->dev, "failed to read DPCD, ret %d\n",
> > ret);
> >   goto out_unlock;
> >   }
> >
> --
> Cheers,
> Lyude Paul (she/her)
> Software Engineer at Red Hat
>


Re: [PATCH v3] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2020-09-22 Thread Koba Ko
On Tue, Sep 22, 2020 at 2:11 AM Lyude Paul  wrote:
>
> Hi, sorry I lost track of this until just now. Comments down below:
>
Sorry, the wrong base. I will modify it based on v2 and will send  v4.
> On Fri, 2020-09-11 at 11:44 +0800, Koba Ko wrote:
> > As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
> > get the faster capability.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.
> >
> > Signed-off-by: Koba Ko 
> > Reviewed-by: Lyude Paul 
> > ---
> > Changelog:
> > 1. Adjust the commit message.
> > 2. use drm_dbg_kms instead and print the return code.
> > ---
> >  drivers/gpu/drm/drm_dp_mst_topology.c | 14 +++---
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> > b/drivers/gpu/drm/drm_dp_mst_topology.c
> > index 7753c718ddf9..63f8809b9aa4 100644
> > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > @@ -3671,8 +3671,6 @@ EXPORT_SYMBOL(drm_dp_read_mst_cap);
> >  int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr,
> > bool mst_state)
> >  {
> >   int ret = 0;
> > - u8 dpcd_ext = 0;
> > - unsigned int dpcd_offset = 0;
> >   struct drm_dp_mst_branch *mstb = NULL;
> >
> >   mutex_lock(>payload_lock);
> > @@ -3686,17 +3684,11 @@ int drm_dp_mst_topology_mgr_set_mst(struct
> > drm_dp_mst_topology_mgr *mgr, bool ms
> >   struct drm_dp_payload reset_pay;
> >
> >   WARN_ON(mgr->mst_primary);
> > - drm_dp_dpcd_read(mgr->aux,
> > -  DP_TRAINING_AUX_RD_INTERVAL,
> > -  _ext, sizeof(dpcd_ext));
> > -
> > - dpcd_offset =
> > - ((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT)
> > ?  DP_DP13_DPCD_REV : DP_DPCD_REV);
>
>
> Uh, are you sure you formatted this patch correctly? None of these hunks are 
> present upstream, this looks like it's a diff for the previous version of 
> this patch that you sent out
> >
> >   /* get dpcd info */
> > - ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd,
> > DP_RECEIVER_CAP_SIZE);
> > - if (ret != DP_RECEIVER_CAP_SIZE) {
> > - DRM_DEBUG_KMS("failed to read DPCD\n");
> > + ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
> > + if (ret < 0) {
> > + drm_dbg_kms(mgr->dev, "failed to read DPCD, ret %d\n",
> > ret);
> >   goto out_unlock;
> >   }
> >
> --
> Cheers,
> Lyude Paul (she/her)
> Software Engineer at Red Hat
>


[PATCH V4] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2020-09-22 Thread Koba Ko
As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1,read the DP_DP13_DPCD_REV to
get the faster capability.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0,read DP_DPCD_REV.

Signed-off-by: Koba Ko 
Reviewed-by: Lyude Paul 
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index e87542533640..63f8809b9aa4 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3686,9 +3686,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
WARN_ON(mgr->mst_primary);
 
/* get dpcd info */
-   ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
-   if (ret != DP_RECEIVER_CAP_SIZE) {
-   DRM_DEBUG_KMS("failed to read DPCD\n");
+   ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
+   if (ret < 0) {
+   drm_dbg_kms(mgr->dev, "failed to read DPCD, ret %d\n", 
ret);
goto out_unlock;
}
 
-- 
2.17.1



Re: [PATCH v3] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2020-09-22 Thread Koba Ko
On Tue, Sep 22, 2020 at 2:11 AM Lyude Paul  wrote:
>
> Hi, sorry I lost track of this until just now. Comments down below:
Sorry, the wrong base. I will modify it based on v2 and will send  v4.
>
> On Fri, 2020-09-11 at 11:44 +0800, Koba Ko wrote:
> > As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
> > get the faster capability.
> > If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.
> >
> > Signed-off-by: Koba Ko 
> > Reviewed-by: Lyude Paul 
> > ---
> > Changelog:
> > 1. Adjust the commit message.
> > 2. use drm_dbg_kms instead and print the return code.
> > ---
> >  drivers/gpu/drm/drm_dp_mst_topology.c | 14 +++---
> >  1 file changed, 3 insertions(+), 11 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> > b/drivers/gpu/drm/drm_dp_mst_topology.c
> > index 7753c718ddf9..63f8809b9aa4 100644
> > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > @@ -3671,8 +3671,6 @@ EXPORT_SYMBOL(drm_dp_read_mst_cap);
> >  int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr,
> > bool mst_state)
> >  {
> >   int ret = 0;
> > - u8 dpcd_ext = 0;
> > - unsigned int dpcd_offset = 0;
> >   struct drm_dp_mst_branch *mstb = NULL;
> >
> >   mutex_lock(>payload_lock);
> > @@ -3686,17 +3684,11 @@ int drm_dp_mst_topology_mgr_set_mst(struct
> > drm_dp_mst_topology_mgr *mgr, bool ms
> >   struct drm_dp_payload reset_pay;
> >
> >   WARN_ON(mgr->mst_primary);
> > - drm_dp_dpcd_read(mgr->aux,
> > -  DP_TRAINING_AUX_RD_INTERVAL,
> > -  _ext, sizeof(dpcd_ext));
> > -
> > - dpcd_offset =
> > - ((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT)
> > ?  DP_DP13_DPCD_REV : DP_DPCD_REV);
>
>
> Uh, are you sure you formatted this patch correctly? None of these hunks are 
> present upstream, this looks like it's a diff for the previous version of 
> this patch that you sent out
> >
> >   /* get dpcd info */
> > - ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd,
> > DP_RECEIVER_CAP_SIZE);
> > - if (ret != DP_RECEIVER_CAP_SIZE) {
> > - DRM_DEBUG_KMS("failed to read DPCD\n");
> > + ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
> > + if (ret < 0) {
> > + drm_dbg_kms(mgr->dev, "failed to read DPCD, ret %d\n",
> > ret);
> >   goto out_unlock;
> >   }
> >
> --
> Cheers,
> Lyude Paul (she/her)
> Software Engineer at Red Hat
>


[PATCH v3] drm/dp_mst: Retrieve extended DPCD caps for topology manager

2020-09-10 Thread Koba Ko
As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
get the faster capability.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.

Signed-off-by: Koba Ko 
Reviewed-by: Lyude Paul 
---
Changelog:
1. Adjust the commit message.
2. use drm_dbg_kms instead and print the return code.
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 14 +++---
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 7753c718ddf9..63f8809b9aa4 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3671,8 +3671,6 @@ EXPORT_SYMBOL(drm_dp_read_mst_cap);
 int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool 
mst_state)
 {
int ret = 0;
-   u8 dpcd_ext = 0;
-   unsigned int dpcd_offset = 0;
struct drm_dp_mst_branch *mstb = NULL;
 
mutex_lock(>payload_lock);
@@ -3686,17 +3684,11 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
struct drm_dp_payload reset_pay;
 
WARN_ON(mgr->mst_primary);
-   drm_dp_dpcd_read(mgr->aux,
-DP_TRAINING_AUX_RD_INTERVAL,
-_ext, sizeof(dpcd_ext));
-
-   dpcd_offset =
-   ((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT) ?  
DP_DP13_DPCD_REV : DP_DPCD_REV);
 
/* get dpcd info */
-   ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
-   if (ret != DP_RECEIVER_CAP_SIZE) {
-   DRM_DEBUG_KMS("failed to read DPCD\n");
+   ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
+   if (ret < 0) {
+   drm_dbg_kms(mgr->dev, "failed to read DPCD, ret %d\n", 
ret);
goto out_unlock;
}
 
-- 
2.25.1



[PATCH] V2: Currently, DRM get the capability of the mst hub only from DP_DPCD_REV and get the slower speed even the mst hub can run in the faster speed.

2020-09-10 Thread Koba Ko
As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
get the faster capability.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.

Signed-off-by: Koba Ko 
---
ChangeLog:
1. use drm_dp_read_dpcd_caps instead.
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 7753c718ddf9..293f71d0ae90 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3694,8 +3694,8 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT) ?  
DP_DP13_DPCD_REV : DP_DPCD_REV);
 
/* get dpcd info */
-   ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
-   if (ret != DP_RECEIVER_CAP_SIZE) {
+   ret = drm_dp_read_dpcd_caps(mgr->aux, mgr->dpcd);
+   if (ret < 0) {
DRM_DEBUG_KMS("failed to read DPCD\n");
goto out_unlock;
}
-- 
2.25.1



Re: [PATCH] drm/dp: For MST hub, Get max_link_rate_lane from extended rx capability field if EXTENDED_RECEIVER_CAPABILITY_FILED_PRESENT is set.

2020-09-09 Thread Koba Ko
On Thu, Aug 27, 2020 at 1:30 PM Koba Ko  wrote:
>
> Currently, DRM get the capability of the mst hub only from DP_DPCD_REV and
> get the slower speed even the mst hub can run in the faster speed.
>
> As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
> If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
> get the faster capability.
> If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.
>
> Signed-off-by: Koba Ko 
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 10 +-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 67dd72ea200e..3b84c6801281 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -3497,6 +3497,8 @@ static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8  
> dp_link_count)
>  int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, 
> bool mst_state)
>  {
> int ret = 0;
> +   u8 dpcd_ext = 0;
> +   unsigned int dpcd_offset = 0;
> struct drm_dp_mst_branch *mstb = NULL;
>
> mutex_lock(>payload_lock);
> @@ -3510,9 +3512,15 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
> drm_dp_mst_topology_mgr *mgr, bool ms
> struct drm_dp_payload reset_pay;
>
> WARN_ON(mgr->mst_primary);
> +   drm_dp_dpcd_read(mgr->aux,
> +DP_TRAINING_AUX_RD_INTERVAL,
> +_ext, sizeof(dpcd_ext));
> +
> +   dpcd_offset =
> +   ((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT) 
> ?  DP_DP13_DPCD_REV : DP_DPCD_REV);
>
> /* get dpcd info */
> -   ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, 
> DP_RECEIVER_CAP_SIZE);
> +   ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd, 
> DP_RECEIVER_CAP_SIZE);
> if (ret != DP_RECEIVER_CAP_SIZE) {
> DRM_DEBUG_KMS("failed to read DPCD\n");
> goto out_unlock;
> --
> 2.25.1
>
Add Lyude Paul


[PATCH] drm/dp: For MST hub, Get max_link_rate_lane from extended rx capability field if EXTENDED_RECEIVER_CAPABILITY_FILED_PRESENT is set.

2020-08-26 Thread Koba Ko
Currently, DRM get the capability of the mst hub only from DP_DPCD_REV and
get the slower speed even the mst hub can run in the faster speed.

As per DP-1.3, First check DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 1, read the DP_DP13_DPCD_REV to
get the faster capability.
If DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT is 0, read DP_DPCD_REV.

Signed-off-by: Koba Ko 
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c 
b/drivers/gpu/drm/drm_dp_mst_topology.c
index 67dd72ea200e..3b84c6801281 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -3497,6 +3497,8 @@ static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8  
dp_link_count)
 int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool 
mst_state)
 {
int ret = 0;
+   u8 dpcd_ext = 0;
+   unsigned int dpcd_offset = 0;
struct drm_dp_mst_branch *mstb = NULL;
 
mutex_lock(>payload_lock);
@@ -3510,9 +3512,15 @@ int drm_dp_mst_topology_mgr_set_mst(struct 
drm_dp_mst_topology_mgr *mgr, bool ms
struct drm_dp_payload reset_pay;
 
WARN_ON(mgr->mst_primary);
+   drm_dp_dpcd_read(mgr->aux,
+DP_TRAINING_AUX_RD_INTERVAL,
+_ext, sizeof(dpcd_ext));
+
+   dpcd_offset =
+   ((dpcd_ext & DP_EXTENDED_RECEIVER_CAP_FIELD_PRESENT) ?  
DP_DP13_DPCD_REV : DP_DPCD_REV);
 
/* get dpcd info */
-   ret = drm_dp_dpcd_read(mgr->aux, DP_DPCD_REV, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
+   ret = drm_dp_dpcd_read(mgr->aux, dpcd_offset, mgr->dpcd, 
DP_RECEIVER_CAP_SIZE);
if (ret != DP_RECEIVER_CAP_SIZE) {
DRM_DEBUG_KMS("failed to read DPCD\n");
goto out_unlock;
-- 
2.25.1



Re: [Issue]platform/x86: iommu: System can't shutdown because iommu driver keeps checking the status of DMA_GSTS_TES

2020-07-09 Thread Koba Ko
Hi Mario
On Fri, Jul 10, 2020 at 4:58 AM Limonciello, Mario
 wrote:
>
> > -Original Message-
> > From: iommu  On Behalf Of Koba Ko
> > Sent: Sunday, June 14, 2020 10:47 PM
> > To: David Woodhouse; Lu Baolu; Joerg Roedel
> > Cc: io...@lists.linux-foundation.org; Kai Heng Feng; Linux Kernel Mailing
> > List
> > Subject: [Issue]platform/x86: iommu: System can't shutdown because iommu
> > driver keeps checking the status of DMA_GSTS_TES
> >
> > hi All,
> > I have a machine and there's only intel gpu.
> > the secureboot and vt-d is enabled in BIOS.
> > On the Ubuntu desktop, I do s2idle first and restart the machine.
> > The machine can't restart successfully, so I need to press the power
> > button to shutdown.
> > I tried  each of the following and the issue can't be triggered.
> > 1. disable secure boot in BIOS.
>
> Just to explain why this happens, on many of Dell's systems VT-d is only 
> enabled
> when secure boot is enabled.
>
> > 2. intel_iommu=off.
> > 3. intel_iomm=igfx_off.
> > 4. nomodeset
> > 5. i915.modeset=0.
> >
> > After I investigate further, find inte_iommu keeps checking the status
> > of DMA_GSTS_TES.
> > During the procedure of restart, the driver would disable iommu translation
> > and
> > check the status of DMA_GSTS_TES until status of DMA_GSTS_TES is 0.
> >
> > If you need more information, I can provide it.
> >
> > Thanks
> > Koba Ko
> > ___
> > iommu mailing list
> > io...@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/iommu
>
> This is reported on TGL pre-production system, but actually same symptom is 
> also
> happening in ICL production systems such as XPS 7390 2-in-1 and XPS 9300.
>
> Details for the ICL issue are available here:
> https://bugzilla.kernel.org/show_bug.cgi?id=206571
>
> A user did bisect it back to commit 6c3a44ed3c553c324845744f30bcd1d3b07d61fd 
> in
> 5.5.  Glancing through the code and comparing the suspend case, I would ask 
> is it
> just a case of missing a flush at shutdown (IE iommu_flush_all)?
>
If dma translation doesn't be disabled during shutdown, the machine
would be powered off successfully.
I have tried to flush before disabled and this can't affect the result
of the issue.

koba ko


Re: [Issue]platform/x86: iommu: System can't shutdown because iommu driver keeps checking the status of DMA_GSTS_TES

2020-07-06 Thread Koba Ko
Dear Baolu,
On Tue, Jun 30, 2020 at 3:52 PM Lu Baolu  wrote:
>
> Hi Koba,
>
> On 2020/6/30 15:31, Koba Ko wrote:
> > On Mon, Jun 15, 2020 at 3:20 PM Lu Baolu  wrote:
> >>
> >> Hi Koba Ko,
> >>
> >> On 2020/6/15 11:19, Koba Ko wrote:
> >>> hi All,
> >>> I have a machine and there's only intel gpu.
> >>> the secureboot and vt-d is enabled in BIOS.
> >>> On the Ubuntu desktop, I do s2idle first and restart the machine.
> >>> The machine can't restart successfully, so I need to press the
> >>> power button to shutdown.
> >>> I tried  each of the following and the issue can't be triggered.
> >>> 1. disable secure boot in BIOS.
> >>> 2. intel_iommu=off.
> >>> 3. intel_iomm=igfx_off.
> >>> 4. nomodeset
> >>> 5. i915.modeset=0.
> >>>
> >>> After I investigate further, find inte_iommu keeps checking the status
> >>> of DMA_GSTS_TES.
> >>> During the procedure of restart, the driver would disable iommu
> >>> translation and
> >>> check status of DMA_GSTS_TES until status of DMA_GSTS_TES is 0.
> >>>
> >>> If you need more information, I can provide it.
> >>
> >> Do you mind telling what platform is it?
> >>
> >> Best regards,
> >> baolu
> > Hi Baolu,
> > Sorry, i missed your email.
> > I'm running on TGL.
> > My colleague has reported this on bugzilla.
> > Have tested your patch and it works fine.
> > https://bugzilla.kernel.org/show_bug.cgi?id=208363
> >
> > Could you explain more about these patches!? Why do we need  a flag
> > for active iommu!?
> >
>
> We're still investigating this issue. If we find out more, I'll let you
> know. Thanks a lot for the reporting.
>
> Best regards,
> baolu
>
Sorry for disturbing,
Do you have any updates for this issue?!
https://bugzilla.kernel.org/show_bug.cgi?id=208363

Koba KO


Re: [Issue]platform/x86: iommu: System can't shutdown because iommu driver keeps checking the status of DMA_GSTS_TES

2020-06-30 Thread Koba Ko
On Mon, Jun 15, 2020 at 3:20 PM Lu Baolu  wrote:
>
> Hi Koba Ko,
>
> On 2020/6/15 11:19, Koba Ko wrote:
> > hi All,
> > I have a machine and there's only intel gpu.
> > the secureboot and vt-d is enabled in BIOS.
> > On the Ubuntu desktop, I do s2idle first and restart the machine.
> > The machine can't restart successfully, so I need to press the
> > power button to shutdown.
> > I tried  each of the following and the issue can't be triggered.
> > 1. disable secure boot in BIOS.
> > 2. intel_iommu=off.
> > 3. intel_iomm=igfx_off.
> > 4. nomodeset
> > 5. i915.modeset=0.
> >
> > After I investigate further, find inte_iommu keeps checking the status
> > of DMA_GSTS_TES.
> > During the procedure of restart, the driver would disable iommu
> > translation and
> > check status of DMA_GSTS_TES until status of DMA_GSTS_TES is 0.
> >
> > If you need more information, I can provide it.
>
> Do you mind telling what platform is it?
>
> Best regards,
> baolu
Hi Baolu,
Sorry, i missed your email.
I'm running on TGL.
My colleague has reported this on bugzilla.
Have tested your patch and it works fine.
https://bugzilla.kernel.org/show_bug.cgi?id=208363

Could you explain more about these patches!? Why do we need  a flag
for active iommu!?

Koba Ko


[Issue]platform/x86: iommu: System can't shutdown because iommu driver keeps checking the status of DMA_GSTS_TES

2020-06-14 Thread Koba Ko
hi All,
I have a machine and there's only intel gpu.
the secureboot and vt-d is enabled in BIOS.
On the Ubuntu desktop, I do s2idle first and restart the machine.
The machine can't restart successfully, so I need to press the power
button to shutdown.
I tried  each of the following and the issue can't be triggered.
1. disable secure boot in BIOS.
2. intel_iommu=off.
3. intel_iomm=igfx_off.
4. nomodeset
5. i915.modeset=0.

After I investigate further, find inte_iommu keeps checking the status
of DMA_GSTS_TES.
During the procedure of restart, the driver would disable iommu translation and
check the status of DMA_GSTS_TES until status of DMA_GSTS_TES is 0.

If you need more information, I can provide it.

Thanks
Koba Ko


[PATCH] V2: platform/x86: dell-laptop: don't register platform::micmute if the related tokens don't exist.

2020-05-10 Thread koba . ko
From: Koba Ko 

On dell G3-3590, error message is issued during boot up,
"platform::micmute: Setting an LED's brightness failed (-19)",
but there's no micmute led on the machine.

Get the related tokens of SMBIOS, GLOBAL_MIC_MUTE_DISABLE/ENABLE.
If one of two tokens doesn't exist,
don't call led_classdev_register() for platform::micmute.
After that, you wouldn't see the platform::micmute in /sys/class/leds/,
and the error message wouldn't see in dmesg.

Signed-off-by: Koba Ko 
---
Changelog:
1. Refine the typo of comment.
---
 drivers/platform/x86/dell-laptop.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c 
b/drivers/platform/x86/dell-laptop.c
index 1e46022fb2c5..afc1ded83e56 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2208,10 +2208,13 @@ static int __init dell_init(void)
 
dell_laptop_register_notifier(_laptop_notifier);
 
-   micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
-   ret = led_classdev_register(_device->dev, _led_cdev);
-   if (ret < 0)
-   goto fail_led;
+   if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
+   dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
+   micmute_led_cdev.brightness = 
ledtrig_audio_get(LED_AUDIO_MICMUTE);
+   ret = led_classdev_register(_device->dev, 
_led_cdev);
+   if (ret < 0)
+   goto fail_led;
+   }
 
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
-- 
2.17.1



[PATCH] platform/x86: dell-laptop: don't register platform::micmute if the related tokens don't exist.

2020-05-10 Thread koba . ko
From: Koba Ko 

On dell G3-3590, error message is issued during boot up,
"platform::micmute: Setting an LED's brightness failed (-19)",
but there's no micmute led on the machine.

Get the related tokens of SMBIOS, GLOBAL_MIC_MUTE_DISABLE/ENABLE.
If one of two tokens doesn't exist,
don't call led_classdev_register() for platform::micmute.
After that, you wouldn't see the platform::micmute in /sys/class/leds/,
and the error message wouldn't see in dmesg.

Signed-off-by: Koba Ko 
---
 drivers/platform/x86/dell-laptop.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c 
b/drivers/platform/x86/dell-laptop.c
index 1e46022fb2c5..afc1ded83e56 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2208,10 +2208,13 @@ static int __init dell_init(void)
 
dell_laptop_register_notifier(_laptop_notifier);
 
-   micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
-   ret = led_classdev_register(_device->dev, _led_cdev);
-   if (ret < 0)
-   goto fail_led;
+   if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
+   dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
+   micmute_led_cdev.brightness = 
ledtrig_audio_get(LED_AUDIO_MICMUTE);
+   ret = led_classdev_register(_device->dev, 
_led_cdev);
+   if (ret < 0)
+   goto fail_led;
+   }
 
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
-- 
2.17.1



[PATCH] platform/x86: dell-laptop: don't register platform::micmute if the related tokens don't exist.

2020-05-07 Thread koba . ko
From: Koba Ko 

During boot up, Error messge is issued,
"platform::micmute: Setting an LED's brightness failed (-19)",
but the device isn't presented.

Get the related tokens of SMBIOS, GLOBAL_MIC_MUTE_DISABLE/ENABLE.
If one of two tokens doesn't exist,
don't call led_classdev_register() for platform::micmute.
After that, you wouldn't see the platform::micmute in /sys/class/leds/,
and the error message wouldn't see in dmesg.

Signed-off-by: Koba Ko 
---
 drivers/platform/x86/dell-laptop.c | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c 
b/drivers/platform/x86/dell-laptop.c
index 74e988f839e8..e315185dbdd6 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2164,7 +2164,7 @@ static struct led_classdev micmute_led_cdev = {
 static int __init dell_init(void)
 {
struct calling_interface_token *token;
-   int max_intensity = 0;
+   int max_intensity = 0, is_micmute_exist = 0;
int ret;
 
if (!dmi_check_system(dell_device_table))
@@ -2204,10 +2204,14 @@ static int __init dell_init(void)
 
dell_laptop_register_notifier(_laptop_notifier);
 
-   micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
-   ret = led_classdev_register(_device->dev, _led_cdev);
-   if (ret < 0)
-   goto fail_led;
+   if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
+   dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
+   micmute_led_cdev.brightness = 
ledtrig_audio_get(LED_AUDIO_MICMUTE);
+   ret = led_classdev_register(_device->dev, 
_led_cdev);
+   if (ret < 0)
+   goto fail_led;
+   is_micmute_exist = 1;
+   }
 
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
@@ -2254,7 +2258,8 @@ static int __init dell_init(void)
 fail_get_brightness:
backlight_device_unregister(dell_backlight_device);
 fail_backlight:
-   led_classdev_unregister(_led_cdev);
+   if (is_micmute_exist)
+   led_classdev_unregister(_led_cdev);
 fail_led:
dell_cleanup_rfkill();
 fail_rfkill:
-- 
2.25.1



[PATCH] platform/x86: dell-laptop: don't register platform::micmute if the related tokens don't exist.

2020-05-07 Thread koba . ko
From: Koba Ko 

Error messge is issued,
"platform::micmute: Setting an LED's brightness failed (-19)",
Even the device isn't presented.

Get the related tokens of SMBIOS, GLOBAL_MIC_MUTE_DISABLE/ENABLE.
If one of two tokens doesn't exist, don't register platform::micmute.

Signed-off-by: Koba Ko 
---
 drivers/platform/x86/dell-laptop.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c 
b/drivers/platform/x86/dell-laptop.c
index 1e46022fb2c5..afc1ded83e56 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2208,10 +2208,13 @@ static int __init dell_init(void)
 
dell_laptop_register_notifier(_laptop_notifier);
 
-   micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
-   ret = led_classdev_register(_device->dev, _led_cdev);
-   if (ret < 0)
-   goto fail_led;
+   if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
+   dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
+   micmute_led_cdev.brightness = 
ledtrig_audio_get(LED_AUDIO_MICMUTE);
+   ret = led_classdev_register(_device->dev, 
_led_cdev);
+   if (ret < 0)
+   goto fail_led;
+   }
 
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
-- 
2.17.1



[PATCH] platform/x86: dell-laptop: don't register platform::micmute if the related tokens don't exist.

2020-05-07 Thread koba . ko
From: Koba Ko 

First, get the related tokens of SMBIOS, GLOBAL_MIC_MUTE_DISABLE/ENABLE.
If one of two tokens doesn't exist, don't register platform::micmute.

Signed-off-by: Koba Ko 
---
 drivers/platform/x86/dell-laptop.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/platform/x86/dell-laptop.c 
b/drivers/platform/x86/dell-laptop.c
index 1e46022fb2c5..afc1ded83e56 100644
--- a/drivers/platform/x86/dell-laptop.c
+++ b/drivers/platform/x86/dell-laptop.c
@@ -2208,10 +2208,13 @@ static int __init dell_init(void)
 
dell_laptop_register_notifier(_laptop_notifier);
 
-   micmute_led_cdev.brightness = ledtrig_audio_get(LED_AUDIO_MICMUTE);
-   ret = led_classdev_register(_device->dev, _led_cdev);
-   if (ret < 0)
-   goto fail_led;
+   if (dell_smbios_find_token(GLOBAL_MIC_MUTE_DISABLE) &&
+   dell_smbios_find_token(GLOBAL_MIC_MUTE_ENABLE)) {
+   micmute_led_cdev.brightness = 
ledtrig_audio_get(LED_AUDIO_MICMUTE);
+   ret = led_classdev_register(_device->dev, 
_led_cdev);
+   if (ret < 0)
+   goto fail_led;
+   }
 
if (acpi_video_get_backlight_type() != acpi_backlight_vendor)
return 0;
-- 
2.17.1