Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5393758rwl; Mon, 3 Apr 2023 20:08:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YNs4ONB9QcLvoNNRUXVwpaqF++UhGCIbstn8tW5KPvTgHUICMbznrMITsN2NPYM3dstkMx X-Received: by 2002:a17:906:1812:b0:947:d991:8e4c with SMTP id v18-20020a170906181200b00947d9918e4cmr707331eje.68.1680577703093; Mon, 03 Apr 2023 20:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680577703; cv=none; d=google.com; s=arc-20160816; b=alnK3tG8vJdhE9wFfCG7G/UGelnVR/NDwU9QNClrOzXyraKSJ7vfc6StMF5IrQMD5+ 0Np+13Po8bhVQ9Ux7H7/03qFEwyM+dcapdZYPq0qc/RzmoqlV4GRvZC8Ets5GxIzLcXM 5zwVBSc8bKVb118pouIfOCbUPVsNXCrlScc4KPxtYR3s6a1A06uWD0C+nMz1fJsAvP3I 3jjbFHmNpN3uUNLA9221KznBRyKDwJ30/jacjs+h73nVPdeAlEJCkFD/JO7gW/lhBv2L ++GdyzoGW6p/+u6S6OuaMg2dMqOkL1arDMlLBUhaQ6ImfwNVIX1m7INogTT/iRKxxuCQ iP+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:hmm_source_type:hmm_attache_num :hmm_source_ip; bh=Y6JdHuDf25O40uBGJ64uIR2GGOm9og++fIByQbAbYho=; b=Y2vKtg+dy10Rn5FbB9W90EDGEnoVA4wWb0QiU2aSwLBRDas+5H09mf2Er2U3UanCZO jo0YsjCyUMLZclbsaiUApzkAO/rUjffA0V3xCJ3PqZiiCYGcPgF34EUr3lEAtN+xUQsS NKuAE+fCMaNtWY6T5Uj1U0TY70LmXVVGWiB0z8jKTWFM9Itw+BAkrz9IDqqVzf+TvAC6 0qD9mAPRqoW5XvXrkqG6tGBmtI3urV4i3cEyyzn7lxvSwvc7rkVhxQTG+Dh51IdbgJUW 4eqcuSAAR3MbvTFfI9lIxIj1Ks3zv0UhzaohhXhy4H4Xk8Fkunnelp/ctlI8WRPcicGx nV3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc5-20020a170906dfe500b009334f4a470esi1057268ejc.661.2023.04.03.20.07.56; Mon, 03 Apr 2023 20:08:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232198AbjDDCzg (ORCPT + 99 others); Mon, 3 Apr 2023 22:55:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjDDCzf (ORCPT ); Mon, 3 Apr 2023 22:55:35 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 018E119BF for ; Mon, 3 Apr 2023 19:55:32 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:48454.1860087732 HMM_ATTACHE_NUM: 0000 HMM_SOURCE_TYPE: SMTP Received: from clientip-114.242.206.180 (unknown [10.64.8.41]) by 189.cn (HERMES) with SMTP id 97DE0102ADA; Tue, 4 Apr 2023 10:55:29 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-7b48884fd-bkw2h with ESMTP id 9b5738e047274065a67ab0e7b4b82ca0 for tzimmermann@suse.de; Tue, 04 Apr 2023 10:55:31 CST X-Transaction-ID: 9b5738e047274065a67ab0e7b4b82ca0 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: <3c173bbe-c74a-5817-c9c5-f3364c628240@189.cn> Date: Tue, 4 Apr 2023 10:55:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH] drm/fbdev-generic: optimize out a redundant assignment clause To: Thomas Zimmermann , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , suijingfeng , liyi , Lucas De Marchi Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <20230325074636.136833-1-15330273260@189.cn> Content-Language: en-US From: Sui Jingfeng <15330273260@189.cn> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,FROM_LOCAL_DIGITS,FROM_LOCAL_HEX,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/3/29 17:04, Thomas Zimmermann wrote: > (cc'ing Lucas) > > Hi > > Am 25.03.23 um 08:46 schrieb Sui Jingfeng: >>   The assignment already done in drm_client_buffer_vmap(), >>   just trival clean, no functional change. >> >> Signed-off-by: Sui Jingfeng <15330273260@189.cn> >> --- >>   drivers/gpu/drm/drm_fbdev_generic.c | 5 ++--- >>   1 file changed, 2 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/gpu/drm/drm_fbdev_generic.c >> b/drivers/gpu/drm/drm_fbdev_generic.c >> index 4d6325e91565..1da48e71c7f1 100644 >> --- a/drivers/gpu/drm/drm_fbdev_generic.c >> +++ b/drivers/gpu/drm/drm_fbdev_generic.c >> @@ -282,7 +282,7 @@ static int drm_fbdev_damage_blit(struct >> drm_fb_helper *fb_helper, >>                    struct drm_clip_rect *clip) >>   { >>       struct drm_client_buffer *buffer = fb_helper->buffer; >> -    struct iosys_map map, dst; >> +    struct iosys_map map; >>       int ret; >>         /* >> @@ -302,8 +302,7 @@ static int drm_fbdev_damage_blit(struct >> drm_fb_helper *fb_helper, >>       if (ret) >>           goto out; >>   -    dst = map; >> -    drm_fbdev_damage_blit_real(fb_helper, clip, &dst); >> +    drm_fbdev_damage_blit_real(fb_helper, clip, &map); > > I see what you're doing and it's probably correct in this case. > > But there's a larger issue with this iosys interfaces. Sometimes the > address has to be modified (see calls of iosys_map_incr()). That can > prevent incorrect uses of the mapping in other places, especially in > unmap code. > Yes, I just realized that. iosys_map_incr() change the internal state of a opaque structure, this is somewhat evil. if it is non-opaque, then this is abstract failure. You have to worry about that if it is changed by a accident call iosys_map_incr() from other place. The map should be const, I guess most programmer expect  the map be a const. making it const please, copy on demand, modify the copy only, leave the original mapping untouched. Hope this could eliminate the embarrassing. Sorry for missing the point. > I think it would make sense to consider a separate structure for the > I/O location. The buffer as a whole would still be represented by > struct iosys_map.  And that new structure, let's call it struct > iosys_ptr, would point to an actual location within the buffer's > memory range. A few locations and helpers would need changes, but > there are not so many callers that it's an issue.  This would also > allow for a few debugging tests that ensure that iosys_ptr always > operates within the bounds of an iosys_map. > > I've long considered this idea, but there was no pressure to work on > it. Maybe now. > I have also get some idea from you idea. > Best regards > Thomas > >>         drm_client_buffer_vunmap(buffer); >