lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b04abc2c-3e9e-f4c8-d444-a7aebde01719@amd.com>
Date:   Mon, 17 Dec 2018 20:27:19 +0000
From:   "Wentland, Harry" <Harry.Wentland@....com>
To:     Lyude Paul <lyude@...hat.com>,
        "dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
        "nouveau@...ts.freedesktop.org" <nouveau@...ts.freedesktop.org>,
        "intel-gfx@...ts.freedesktop.org" <intel-gfx@...ts.freedesktop.org>,
        "amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>,
        Dave Airlie <airlied@...il.com>,
        "Zuo, Jerry" <Jerry.Zuo@....com>, Juston Li <juston.li@...el.com>,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Maxime Ripard <maxime.ripard@...tlin.com>,
        Sean Paul <sean@...rly.run>, David Airlie <airlied@...ux.ie>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [WIP PATCH 02/15] drm/dp_mst: Refactor
 drm_dp_update_payload_part1()

On 2018-12-14 3:47 a.m., Daniel Vetter wrote:
> On Thu, Dec 13, 2018 at 08:25:31PM -0500, Lyude Paul wrote:
>> There should be no functional changes here
> 
> Would be good to explain what you did refactor here, instead of me trying
> to reconstruct it from the patch. Especially pre-coffee that helps :-)

I concur. Something like "use local variables to improve readability".

With that fixed this is
Reviewed-by: Harry Wentland <harry.wentland@....com>

Harry

>>
>> Signed-off-by: Lyude Paul <lyude@...hat.com>
>> Cc: Juston Li <juston.li@...el.com>
>> ---
>>  drivers/gpu/drm/drm_dp_mst_topology.c | 71 ++++++++++++++++-----------
>>  1 file changed, 42 insertions(+), 29 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
>> index 9b1b5c9b1fa0..2ab16c9e6243 100644
>> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
>> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
>> @@ -1879,39 +1879,48 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr)
>>  
>>  	mutex_lock(&mgr->payload_lock);
>>  	for (i = 0; i < mgr->max_payloads; i++) {
>> +		struct drm_dp_vcpi *vcpi = mgr->proposed_vcpis[i];
>> +		struct drm_dp_payload *payload = &mgr->payloads[i];
>> +
>>  		/* solve the current payloads - compare to the hw ones
>>  		   - update the hw view */
>>  		req_payload.start_slot = cur_slots;
>> -		if (mgr->proposed_vcpis[i]) {
>> -			port = container_of(mgr->proposed_vcpis[i], struct drm_dp_mst_port, vcpi);
>> +		if (vcpi) {
>> +			port = container_of(vcpi, struct drm_dp_mst_port,
>> +					    vcpi);
>>  			port = drm_dp_get_validated_port_ref(mgr, port);
>>  			if (!port) {
>>  				mutex_unlock(&mgr->payload_lock);
>>  				return -EINVAL;
>>  			}
>> -			req_payload.num_slots = mgr->proposed_vcpis[i]->num_slots;
>> -			req_payload.vcpi = mgr->proposed_vcpis[i]->vcpi;
>> +			req_payload.num_slots = vcpi->num_slots;
>> +			req_payload.vcpi = vcpi->vcpi;
>>  		} else {
>>  			port = NULL;
>>  			req_payload.num_slots = 0;
>>  		}
>>  
>> -		mgr->payloads[i].start_slot = req_payload.start_slot;
>> +		payload->start_slot = req_payload.start_slot;
>>  		/* work out what is required to happen with this payload */
>> -		if (mgr->payloads[i].num_slots != req_payload.num_slots) {
>> +		if (payload->num_slots != req_payload.num_slots) {
>>  
>>  			/* need to push an update for this payload */
>>  			if (req_payload.num_slots) {
>> -				drm_dp_create_payload_step1(mgr, mgr->proposed_vcpis[i]->vcpi, &req_payload);
>> -				mgr->payloads[i].num_slots = req_payload.num_slots;
>> -				mgr->payloads[i].vcpi = req_payload.vcpi;
>> -			} else if (mgr->payloads[i].num_slots) {
>> -				mgr->payloads[i].num_slots = 0;
>> -				drm_dp_destroy_payload_step1(mgr, port, mgr->payloads[i].vcpi, &mgr->payloads[i]);
>> -				req_payload.payload_state = mgr->payloads[i].payload_state;
>> -				mgr->payloads[i].start_slot = 0;
>> +				drm_dp_create_payload_step1(mgr, vcpi->vcpi,
>> +							    &req_payload);
>> +				payload->num_slots = req_payload.num_slots;
>> +				payload->vcpi = req_payload.vcpi;
>> +
>> +			} else if (payload->num_slots) {
>> +				payload->num_slots = 0;
>> +				drm_dp_destroy_payload_step1(mgr, port,
>> +							     payload->vcpi,
>> +							     payload);
>> +				req_payload.payload_state =
>> +					payload->payload_state;
>> +				payload->start_slot = 0;
>>  			}
>> -			mgr->payloads[i].payload_state = req_payload.payload_state;
>> +			payload->payload_state = req_payload.payload_state;
>>  		}
>>  		cur_slots += req_payload.num_slots;
>>  
>> @@ -1920,22 +1929,26 @@ int drm_dp_update_payload_part1(struct drm_dp_mst_topology_mgr *mgr)
>>  	}
>>  
>>  	for (i = 0; i < mgr->max_payloads; i++) {
>> -		if (mgr->payloads[i].payload_state == DP_PAYLOAD_DELETE_LOCAL) {
>> -			DRM_DEBUG_KMS("removing payload %d\n", i);
>> -			for (j = i; j < mgr->max_payloads - 1; j++) {
>> -				memcpy(&mgr->payloads[j], &mgr->payloads[j + 1], sizeof(struct drm_dp_payload));
>> -				mgr->proposed_vcpis[j] = mgr->proposed_vcpis[j + 1];
>> -				if (mgr->proposed_vcpis[j] && mgr->proposed_vcpis[j]->num_slots) {
>> -					set_bit(j + 1, &mgr->payload_mask);
>> -				} else {
>> -					clear_bit(j + 1, &mgr->payload_mask);
>> -				}
>> -			}
>> -			memset(&mgr->payloads[mgr->max_payloads - 1], 0, sizeof(struct drm_dp_payload));
>> -			mgr->proposed_vcpis[mgr->max_payloads - 1] = NULL;
>> -			clear_bit(mgr->max_payloads, &mgr->payload_mask);
>> +		if (mgr->payloads[i].payload_state != DP_PAYLOAD_DELETE_LOCAL)
>> +			continue;
>> +
>> +		DRM_DEBUG_KMS("removing payload %d\n", i);
>> +		for (j = i; j < mgr->max_payloads - 1; j++) {
>> +			mgr->payloads[j] = mgr->payloads[j + 1];
>> +			mgr->proposed_vcpis[j] = mgr->proposed_vcpis[j + 1];
>>  
>> +			if (mgr->proposed_vcpis[j] &&
>> +			    mgr->proposed_vcpis[j]->num_slots) {
>> +				set_bit(j + 1, &mgr->payload_mask);
>> +			} else {
>> +				clear_bit(j + 1, &mgr->payload_mask);
>> +			}
>>  		}
>> +
>> +		memset(&mgr->payloads[mgr->max_payloads - 1], 0,
>> +		       sizeof(struct drm_dp_payload));
>> +		mgr->proposed_vcpis[mgr->max_payloads - 1] = NULL;
>> +		clear_bit(mgr->max_payloads, &mgr->payload_mask);
> 
> With the commit message improved to mention
> - Add local variables in the first loop
> - Early continue to reduce 1 indent in the 2nd loop
> 
> this is Reviewed-by: Daniel Vetter <daniel.vetter@...ll.ch>
> 
>>  	}
>>  	mutex_unlock(&mgr->payload_lock);
>>  
>> -- 
>> 2.19.2
>>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ