Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1765604rwl; Thu, 30 Mar 2023 00:55:23 -0700 (PDT) X-Google-Smtp-Source: AKy350YBfXknaFwpP4snJPPLmLUuijdE33PSIPOLw4+lq5b4pOLo3ZfP2pAj00RE5ei5FlOvvFiJ X-Received: by 2002:a05:6402:268e:b0:502:1f7b:f069 with SMTP id w14-20020a056402268e00b005021f7bf069mr1510430edd.2.1680162923058; Thu, 30 Mar 2023 00:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680162923; cv=none; d=google.com; s=arc-20160816; b=wRdf9ICYIRR+mIYskY7phf6MzK4c8LzeZc9EtxMOwvEYNMOumeV644lvtRIGuOiNnG FZqpLvy8K0A/NqxYYURs1InwX7KaisAgX1liXhKKPqlB2zb2v5ROwdsHurpfn/Em8/1g IFiILw/T9UOu7CoC910dUFUZ4P3Yd9Jv71Q2UcdYIPGKkDrCEnfDv3MKadXEqj8HaJRD Atzs/FwyMa8DHJen2BwVQ5xfSuJLVcT0eU8wYwhlo5sGaUsFxiXG4S72sCEkWGguQdNr su2KRS9jOSYz0eC04bCL+sUgXnuus6lAUH7YN5XO+lfjD4PildQBEWyEkK3s0iw+sNPN ix3A== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:sender:hmm_source_type:hmm_attache_num :hmm_source_ip; bh=89HLLb6mfA+rA/9cb9m9KLQJEWYhzdQFR27V+LLeDIo=; b=eJx/VZM2TchrwvyZMkzjUdXrtalkLVYNxn1M8k+hls7Yo/nbbkzECjiIlXxCXBqsb1 vCXCswt4q4lSOeboFYfmEe5lS7+DcotmoE62Uw8O1T+zWaXMZ1gRXAuhTlX7i08S97kV n04VB18YDpuEBKT5YMeNQMM84wSixhMNbCgUFq7ukf63M2FEqYUPYJEEnRPu7JMp8n0q Ri5MzbnECqbky1sf4TH1tPPck77+de0+6hOnBEbYmDNza6kZ6kTLlItkiLDQoUFDhN/J xvgxGG+9VBFS48vUAOXqrarownlpSBDAiwYe31kxU4oBn92xKGz/nkKLwCRaGXAThKKH jaRg== 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 d5-20020a50fb05000000b004ad0993e54esi35169604edq.487.2023.03.30.00.54.57; Thu, 30 Mar 2023 00:55: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 S229711AbjC3HtO (ORCPT + 99 others); Thu, 30 Mar 2023 03:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229702AbjC3Hs5 (ORCPT ); Thu, 30 Mar 2023 03:48:57 -0400 Received: from 189.cn (ptr.189.cn [183.61.185.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F14E649FE for ; Thu, 30 Mar 2023 00:48:53 -0700 (PDT) HMM_SOURCE_IP: 10.64.8.41:47488.1049430421 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 46AFD1002C5; Thu, 30 Mar 2023 15:48:52 +0800 (CST) Received: from ([114.242.206.180]) by gateway-151646-dep-7b48884fd-bkw2h with ESMTP id ce4be36be1844530b4e60d98cbcf0274 for tzimmermann@suse.de; Thu, 30 Mar 2023 15:48:53 CST X-Transaction-ID: ce4be36be1844530b4e60d98cbcf0274 X-Real-From: 15330273260@189.cn X-Receive-IP: 114.242.206.180 X-MEDUSA-Status: 0 Sender: 15330273260@189.cn Message-ID: <63f981ca-8ceb-2cc3-4b33-0cfa65699a85@189.cn> Date: Thu, 30 Mar 2023 15:48:51 +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 Content-Language: en-US To: Thomas Zimmermann , Lucas De Marchi Cc: David Airlie , liyi , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org References: <20230325074636.136833-1-15330273260@189.cn> <20230330041726.w7boceq7ljymvfq2@ldmartin-desk2> <2e6ec82f-dfde-0f3a-7980-136cea161d6b@189.cn> <4e2a2222-59c2-2935-08a7-4a661d5073b2@suse.de> From: Sui Jingfeng <15330273260@189.cn> In-Reply-To: <4e2a2222-59c2-2935-08a7-4a661d5073b2@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=0.6 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=no 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/30 15:26, Thomas Zimmermann wrote: > Hi > > Am 30.03.23 um 09:17 schrieb Sui Jingfeng: >> Hi, >> >> On 2023/3/30 14:57, Thomas Zimmermann wrote: >>> Hi >>> >>> Am 30.03.23 um 06:17 schrieb Lucas De Marchi: >>>> On Wed, Mar 29, 2023 at 11:04:17AM +0200, 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. >>>> >>>> using a initializer for the cases it's needed IMO would make these >>>> kind >>>> of problems go away, because then the intent is explicit >>>> >>>>> >>>>> 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 >>>> >>>> sounds fine to me, but I'd have to take a deeper look later (or when >>>> someone writes the patch).  It seems we'd replicate almost the entire >>>> API to just accomodate the 2 structs.  And the different types will >>>> lead >>>> to confusion when one or the other should be used >>> >>> I think we can split the current interface onto two categories: >>> mapping and I/O. The former would use iosys_map and the latter would >>> use iosys_ptr. And we'd need a helper that turns gets a ptr for a >>> given map. >>> >>> If I find the tine, I'll probably type up a patch. >>> >>   Here i fix a typo, 'tine' -> 'time' >> >> As far as i can see, they are two major type of memory in the system. >> >> System memory or VRAM,  for the gpu with dedicate video ram, VRAM is >> belong to the IO memory category. >> >> But there are system choose carveout part of system ram as video >> ram(i915?,  for example). >> >> the name iosys_map and iosys_ptr have no difference at the first >> sight, tell me which one is for mapping system ram >> >> and which one is for mapping vram? > > As you say correctly, graphics buffers and be in various locations. > They can even move between I/O and system memory. The idea behind > iosys_map ("I/O and/or system mapping") is that it's a single > interface that can handle both. > I somewhat miss the point, sound like const pointer(const void* const p) V.S. plain pointer (void *) I understand what you meant then. > Best regards > Thomas > >> >> >>> Best regards >>> Thomas >>> >>>> >>>> thanks >>>> Lucas De Marchi >>>> >>>>> 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. >>>>> >>>>> Best regards >>>>> Thomas >>>>> >>>>>> drm_client_buffer_vunmap(buffer); >>>>> >>>>> -- >>>>> Thomas Zimmermann >>>>> Graphics Driver Developer >>>>> SUSE Software Solutions Germany GmbH >>>>> Maxfeldstr. 5, 90409 Nürnberg, Germany >>>>> (HRB 36809, AG Nürnberg) >>>>> Geschäftsführer: Ivo Totev >>>> >>>> >>>> >>> >