* [PATCH 1/3] drm/dp/mst: Reduce nested ifs
@ 2019-09-25 14:14 Ville Syrjala
2019-09-25 14:14 ` [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values Ville Syrjala
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Ville Syrjala @ 2019-09-25 14:14 UTC (permalink / raw)
To: dri-devel; +Cc: intel-gfx
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Replace the nested ifs with a single if and a logical AND.
Cc: Lyude Paul <lyude@redhat.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_dp_mst_topology.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 97216099a718..e25597eb3ca1 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -1123,11 +1123,11 @@ static void drm_dp_mst_put_payload_id(struct drm_dp_mst_topology_mgr *mgr,
clear_bit(vcpi - 1, &mgr->vcpi_mask);
for (i = 0; i < mgr->max_payloads; i++) {
- if (mgr->proposed_vcpis[i])
- if (mgr->proposed_vcpis[i]->vcpi == vcpi) {
- mgr->proposed_vcpis[i] = NULL;
- clear_bit(i + 1, &mgr->payload_mask);
- }
+ if (mgr->proposed_vcpis[i] &&
+ mgr->proposed_vcpis[i]->vcpi == vcpi) {
+ mgr->proposed_vcpis[i] = NULL;
+ clear_bit(i + 1, &mgr->payload_mask);
+ }
}
mutex_unlock(&mgr->payload_lock);
}
--
2.21.0
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values
2019-09-25 14:14 [PATCH 1/3] drm/dp/mst: Reduce nested ifs Ville Syrjala
@ 2019-09-25 14:14 ` Ville Syrjala
2019-09-26 0:03 ` Lyude Paul
2019-09-25 14:14 ` [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation Ville Syrjala
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Ville Syrjala @ 2019-09-25 14:14 UTC (permalink / raw)
To: dri-devel; +Cc: Sean Paul, intel-gfx
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Make drm_dp_get_vc_payload() tolerate arbitrary DP_LINK_BW_*
values, just like drm_dp_bw_code_to_link_rate() does since commit
57a1b0893782 ("drm: Make the bw/link rate calculations more forgiving").
Cc: Lyude Paul <lyude@redhat.com>
Cc: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_dp_mst_topology.c | 29 ++++++---------------------
1 file changed, 6 insertions(+), 23 deletions(-)
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index e25597eb3ca1..d4644a3c1324 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2974,30 +2974,13 @@ static int drm_dp_send_up_ack_reply(struct drm_dp_mst_topology_mgr *mgr,
return 0;
}
-static bool drm_dp_get_vc_payload_bw(int dp_link_bw,
- int dp_link_count,
- int *out)
+static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count)
{
- switch (dp_link_bw) {
- default:
+ if (dp_link_bw == 0 || dp_link_count == 0)
DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count: %d)\n",
dp_link_bw, dp_link_count);
- return false;
- case DP_LINK_BW_1_62:
- *out = 3 * dp_link_count;
- break;
- case DP_LINK_BW_2_7:
- *out = 5 * dp_link_count;
- break;
- case DP_LINK_BW_5_4:
- *out = 10 * dp_link_count;
- break;
- case DP_LINK_BW_8_1:
- *out = 15 * dp_link_count;
- break;
- }
- return true;
+ return dp_link_bw * dp_link_count / 2;
}
/**
@@ -3029,9 +3012,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct drm_dp_mst_topology_mgr *mgr, bool ms
goto out_unlock;
}
- if (!drm_dp_get_vc_payload_bw(mgr->dpcd[1],
- mgr->dpcd[2] & DP_MAX_LANE_COUNT_MASK,
- &mgr->pbn_div)) {
+ 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) {
ret = -EINVAL;
goto out_unlock;
}
--
2.21.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation
2019-09-25 14:14 [PATCH 1/3] drm/dp/mst: Reduce nested ifs Ville Syrjala
2019-09-25 14:14 ` [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values Ville Syrjala
@ 2019-09-25 14:14 ` Ville Syrjala
2019-09-26 0:07 ` Lyude Paul
2019-09-25 16:14 ` [PATCH 1/3] drm/dp/mst: Reduce nested ifs Lucas De Marchi
2019-09-25 19:10 ` Lyude Paul
3 siblings, 1 reply; 7+ messages in thread
From: Ville Syrjala @ 2019-09-25 14:14 UTC (permalink / raw)
To: dri-devel; +Cc: Alex Deucher, intel-gfx
From: Ville Syrjälä <ville.syrjala@linux.intel.com>
Get rid of the drm_fixp_from_fraction() usage and just do the
straightforward calculation directly.
Cc: Lyude Paul <lyude@redhat.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
drivers/gpu/drm/drm_dp_mst_topology.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index d4644a3c1324..f899a4432311 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -32,7 +32,6 @@
#include <drm/drm_atomic_helper.h>
#include <drm/drm_dp_mst_helper.h>
#include <drm/drm_drv.h>
-#include <drm/drm_fixed.h>
#include <drm/drm_print.h>
#include <drm/drm_probe_helper.h>
@@ -3840,13 +3839,6 @@ EXPORT_SYMBOL(drm_dp_check_act_status);
*/
int drm_dp_calc_pbn_mode(int clock, int bpp)
{
- u64 kbps;
- s64 peak_kbps;
- u32 numerator;
- u32 denominator;
-
- kbps = clock * bpp;
-
/*
* margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
* The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
@@ -3857,14 +3849,8 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)
* peak_kbps *= (64/54)
* peak_kbps *= 8 convert to bytes
*/
-
- numerator = 64 * 1006;
- denominator = 54 * 8 * 1000 * 1000;
-
- kbps *= numerator;
- peak_kbps = drm_fixp_from_fraction(kbps, denominator);
-
- return drm_fixp2int_ceil(peak_kbps);
+ return DIV_ROUND_UP_ULL(mul_u32_u32(clock * bpp, 64 * 1006),
+ 8 * 54 * 1000 * 1000);
}
EXPORT_SYMBOL(drm_dp_calc_pbn_mode);
--
2.21.0
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] drm/dp/mst: Reduce nested ifs
2019-09-25 14:14 [PATCH 1/3] drm/dp/mst: Reduce nested ifs Ville Syrjala
2019-09-25 14:14 ` [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values Ville Syrjala
2019-09-25 14:14 ` [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation Ville Syrjala
@ 2019-09-25 16:14 ` Lucas De Marchi
2019-09-25 19:10 ` Lyude Paul
3 siblings, 0 replies; 7+ messages in thread
From: Lucas De Marchi @ 2019-09-25 16:14 UTC (permalink / raw)
To: Ville Syrjala; +Cc: Intel Graphics, DRI
On Wed, Sep 25, 2019 at 7:14 AM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Replace the nested ifs with a single if and a logical AND.
>
> Cc: Lyude Paul <lyude@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Lucas De Marchi
> ---
> drivers/gpu/drm/drm_dp_mst_topology.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 97216099a718..e25597eb3ca1 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1123,11 +1123,11 @@ static void drm_dp_mst_put_payload_id(struct drm_dp_mst_topology_mgr *mgr,
> clear_bit(vcpi - 1, &mgr->vcpi_mask);
>
> for (i = 0; i < mgr->max_payloads; i++) {
> - if (mgr->proposed_vcpis[i])
> - if (mgr->proposed_vcpis[i]->vcpi == vcpi) {
> - mgr->proposed_vcpis[i] = NULL;
> - clear_bit(i + 1, &mgr->payload_mask);
> - }
> + if (mgr->proposed_vcpis[i] &&
> + mgr->proposed_vcpis[i]->vcpi == vcpi) {
> + mgr->proposed_vcpis[i] = NULL;
> + clear_bit(i + 1, &mgr->payload_mask);
> + }
> }
> mutex_unlock(&mgr->payload_lock);
> }
> --
> 2.21.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Lucas De Marchi
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] drm/dp/mst: Reduce nested ifs
2019-09-25 14:14 [PATCH 1/3] drm/dp/mst: Reduce nested ifs Ville Syrjala
` (2 preceding siblings ...)
2019-09-25 16:14 ` [PATCH 1/3] drm/dp/mst: Reduce nested ifs Lucas De Marchi
@ 2019-09-25 19:10 ` Lyude Paul
3 siblings, 0 replies; 7+ messages in thread
From: Lyude Paul @ 2019-09-25 19:10 UTC (permalink / raw)
To: Ville Syrjala, dri-devel; +Cc: intel-gfx
Reviewed-by: Lyude Paul <lyude@redhat.com>
On Wed, 2019-09-25 at 17:14 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Replace the nested ifs with a single if and a logical AND.
>
> Cc: Lyude Paul <lyude@redhat.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_dp_mst_topology.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 97216099a718..e25597eb3ca1 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -1123,11 +1123,11 @@ static void drm_dp_mst_put_payload_id(struct
> drm_dp_mst_topology_mgr *mgr,
> clear_bit(vcpi - 1, &mgr->vcpi_mask);
>
> for (i = 0; i < mgr->max_payloads; i++) {
> - if (mgr->proposed_vcpis[i])
> - if (mgr->proposed_vcpis[i]->vcpi == vcpi) {
> - mgr->proposed_vcpis[i] = NULL;
> - clear_bit(i + 1, &mgr->payload_mask);
> - }
> + if (mgr->proposed_vcpis[i] &&
> + mgr->proposed_vcpis[i]->vcpi == vcpi) {
> + mgr->proposed_vcpis[i] = NULL;
> + clear_bit(i + 1, &mgr->payload_mask);
> + }
> }
> mutex_unlock(&mgr->payload_lock);
> }
--
Cheers,
Lyude Paul
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values
2019-09-25 14:14 ` [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values Ville Syrjala
@ 2019-09-26 0:03 ` Lyude Paul
0 siblings, 0 replies; 7+ messages in thread
From: Lyude Paul @ 2019-09-26 0:03 UTC (permalink / raw)
To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Sean Paul
Reviewed-by: Lyude Paul <lyude@redhat.com>
On Wed, 2019-09-25 at 17:14 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Make drm_dp_get_vc_payload() tolerate arbitrary DP_LINK_BW_*
> values, just like drm_dp_bw_code_to_link_rate() does since commit
> 57a1b0893782 ("drm: Make the bw/link rate calculations more forgiving").
>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_dp_mst_topology.c | 29 ++++++---------------------
> 1 file changed, 6 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index e25597eb3ca1..d4644a3c1324 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -2974,30 +2974,13 @@ static int drm_dp_send_up_ack_reply(struct
> drm_dp_mst_topology_mgr *mgr,
> return 0;
> }
>
> -static bool drm_dp_get_vc_payload_bw(int dp_link_bw,
> - int dp_link_count,
> - int *out)
> +static int drm_dp_get_vc_payload_bw(u8 dp_link_bw, u8 dp_link_count)
> {
> - switch (dp_link_bw) {
> - default:
> + if (dp_link_bw == 0 || dp_link_count == 0)
> DRM_DEBUG_KMS("invalid link bandwidth in DPCD: %x (link count:
> %d)\n",
> dp_link_bw, dp_link_count);
> - return false;
>
> - case DP_LINK_BW_1_62:
> - *out = 3 * dp_link_count;
> - break;
> - case DP_LINK_BW_2_7:
> - *out = 5 * dp_link_count;
> - break;
> - case DP_LINK_BW_5_4:
> - *out = 10 * dp_link_count;
> - break;
> - case DP_LINK_BW_8_1:
> - *out = 15 * dp_link_count;
> - break;
> - }
> - return true;
> + return dp_link_bw * dp_link_count / 2;
> }
>
> /**
> @@ -3029,9 +3012,9 @@ int drm_dp_mst_topology_mgr_set_mst(struct
> drm_dp_mst_topology_mgr *mgr, bool ms
> goto out_unlock;
> }
>
> - if (!drm_dp_get_vc_payload_bw(mgr->dpcd[1],
> - mgr->dpcd[2] &
> DP_MAX_LANE_COUNT_MASK,
> - &mgr->pbn_div)) {
> + 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) {
> ret = -EINVAL;
> goto out_unlock;
> }
--
Cheers,
Lyude Paul
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation
2019-09-25 14:14 ` [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation Ville Syrjala
@ 2019-09-26 0:07 ` Lyude Paul
0 siblings, 0 replies; 7+ messages in thread
From: Lyude Paul @ 2019-09-26 0:07 UTC (permalink / raw)
To: Ville Syrjala, dri-devel, Mikita Lipski; +Cc: Alex Deucher, intel-gfx
Reviewed-by: Lyude Paul <lyude@redhat.com>
Cc: Mikita Lipski - figured you'd want to know ahead of time you'll need to
update your changes to drm_dp_calc_pbn_mode() to match
On Wed, 2019-09-25 at 17:14 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Get rid of the drm_fixp_from_fraction() usage and just do the
> straightforward calculation directly.
>
> Cc: Lyude Paul <lyude@redhat.com>
> Cc: Harry Wentland <harry.wentland@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
> drivers/gpu/drm/drm_dp_mst_topology.c | 18 ++----------------
> 1 file changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index d4644a3c1324..f899a4432311 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -32,7 +32,6 @@
> #include <drm/drm_atomic_helper.h>
> #include <drm/drm_dp_mst_helper.h>
> #include <drm/drm_drv.h>
> -#include <drm/drm_fixed.h>
> #include <drm/drm_print.h>
> #include <drm/drm_probe_helper.h>
>
> @@ -3840,13 +3839,6 @@ EXPORT_SYMBOL(drm_dp_check_act_status);
> */
> int drm_dp_calc_pbn_mode(int clock, int bpp)
> {
> - u64 kbps;
> - s64 peak_kbps;
> - u32 numerator;
> - u32 denominator;
> -
> - kbps = clock * bpp;
> -
> /*
> * margin 5300ppm + 300ppm ~ 0.6% as per spec, factor is 1.006
> * The unit of 54/64Mbytes/sec is an arbitrary unit chosen based on
> @@ -3857,14 +3849,8 @@ int drm_dp_calc_pbn_mode(int clock, int bpp)
> * peak_kbps *= (64/54)
> * peak_kbps *= 8 convert to bytes
> */
> -
> - numerator = 64 * 1006;
> - denominator = 54 * 8 * 1000 * 1000;
> -
> - kbps *= numerator;
> - peak_kbps = drm_fixp_from_fraction(kbps, denominator);
> -
> - return drm_fixp2int_ceil(peak_kbps);
> + return DIV_ROUND_UP_ULL(mul_u32_u32(clock * bpp, 64 * 1006),
> + 8 * 54 * 1000 * 1000);
> }
> EXPORT_SYMBOL(drm_dp_calc_pbn_mode);
>
--
Cheers,
Lyude Paul
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-09-26 0:07 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-25 14:14 [PATCH 1/3] drm/dp/mst: Reduce nested ifs Ville Syrjala
2019-09-25 14:14 ` [PATCH 2/3] drm/dp/mst: Handle arbitrary DP_LINK_BW values Ville Syrjala
2019-09-26 0:03 ` Lyude Paul
2019-09-25 14:14 ` [PATCH 3/3] drm/dp/mst: Replace the fixed point thing with straight calculation Ville Syrjala
2019-09-26 0:07 ` Lyude Paul
2019-09-25 16:14 ` [PATCH 1/3] drm/dp/mst: Reduce nested ifs Lucas De Marchi
2019-09-25 19:10 ` Lyude Paul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox