Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp608255rwn; Thu, 8 Sep 2022 06:29:36 -0700 (PDT) X-Google-Smtp-Source: AA6agR6pJy6wgN8a3BiBJXm2BOGPLzuJ4KbqhvgdA6I+n3Fl6pL6HZGdBSx5J4xJsWew3bupXED5 X-Received: by 2002:a63:fe0e:0:b0:434:2b0a:c with SMTP id p14-20020a63fe0e000000b004342b0a000cmr8253735pgh.270.1662643775805; Thu, 08 Sep 2022 06:29:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662643775; cv=none; d=google.com; s=arc-20160816; b=K3okwppSMd4681zTIKCjqDn5Yp+o1+hFtd0TZPIctSmdcOtvtMHu6NnGGYi8lG/00W YN5u8k62r1PIhsWzb58jWY6qIGUOLrQSjFxsxvX72KuDh+XllORC5YQzIOY1NcOcM2Nm jkDt0AH5dIX/AHsJiXOzVmuqYbV6zOyeYIhmPkmKktt9c4yXVdF8lsMPd91uSRR/Axyq O5jdEuAiuTxr83f5r/6vngiKacQJIuQ1CGWMuxIx61h3L6qOw8f1jmxY71j0EQQqyZGa crOrrJTzgAZJcGPsgLYX96JR/5J9dGK4WaWDBMOutXbp0gTm+O9xTI1Ba2m5EEVEwlbW fVmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=pxCPsA42d5aRC10EUmd/OSOfCOyGgvazLm4CGXkGadc=; b=EuN/Kne6N52jjV6QjGWopE4het+G7lgeyRbWioLB82ogzTggtzmD9pSZTsmQl0M8NL +L0itV22M1GCYcE4Sl4e/mcvs9VY0IkxqsfrFrQudIxIq8W7E8Xfy5X+2WttBnAdDoys nWasoNzxHnYOIdr3iDX8+k7J21w4unbblV1fXnKXm0zLzSMj4T5pwMvygiPOh38UzfwR LvoFr/jk1bgFK0yitWZgrDdmnF3oXEwMdN571Snazv12Js25/jXE4Wbyda5AD2nfbhrG 9j4CAqO4XEnH26htDLadXQ8X0f3qO+HU7m70HQXRw4WhngYmsoa4hDMY7nvHsU9vAhNY eqqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=THSWm4TT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b4-20020a630c04000000b0043541f025a7si2785084pgl.595.2022.09.08.06.29.23; Thu, 08 Sep 2022 06:29:35 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=THSWm4TT; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231680AbiIHMzD (ORCPT + 99 others); Thu, 8 Sep 2022 08:55:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230497AbiIHMyz (ORCPT ); Thu, 8 Sep 2022 08:54:55 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E2582ED7E for ; Thu, 8 Sep 2022 05:54:54 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id C65CB1F6E6; Thu, 8 Sep 2022 12:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1662641692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pxCPsA42d5aRC10EUmd/OSOfCOyGgvazLm4CGXkGadc=; b=THSWm4TTTsRjzn12V1zhQzMiraTVxiUoONEGE6bsMgJXnnWXKskQc5vTcMBrNTbjWxFRqv a0R3Vb2mXlpNoYXZpomM7EwtqNub/ogy8bUZkiS/vK7v1kEtxGQnKLdCJyJzWT4Bgm5zDG 0HdBCu9OqC6bpDItDQeGQBc47ads/rU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1662641692; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=pxCPsA42d5aRC10EUmd/OSOfCOyGgvazLm4CGXkGadc=; b=0CS3iBKk0Va566/CXwTCmCAHEbEDLc+FOKEmsgAM1NJ2E+D0XR0WMEXZ9ft5YduTmac4xR KkcQ7lVZDOY9nmDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9645F1322C; Thu, 8 Sep 2022 12:54:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Jen4IxzmGWPpLQAAMHmgww (envelope-from ); Thu, 08 Sep 2022 12:54:52 +0000 Date: Thu, 08 Sep 2022 14:54:51 +0200 Message-ID: <87tu5iauw4.wl-tiwai@suse.de> From: Takashi Iwai To: Thomas Zimmermann Cc: Takashi Iwai , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 08/12] drm/udl: Pass rectangle directly to udl_handle_damage() In-Reply-To: References: <20220908095115.23396-1-tiwai@suse.de> <20220908095115.23396-9-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 Thu, 08 Sep 2022 14:47:52 +0200, Thomas Zimmermann wrote: > > Hi > > Am 08.09.22 um 11:51 schrieb Takashi Iwai: > > Just for some code simplification. > > > > Suggested-by: Thomas Zimmermann > > Signed-off-by: Takashi Iwai > > With my comments fixed, you can add > > Acked-by: Thomas Zimmermann > > > --- > > drivers/gpu/drm/udl/udl_modeset.c | 20 +++++++++----------- > > 1 file changed, 9 insertions(+), 11 deletions(-) > > > > diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c > > index c9b837ac26a7..0142fc6a478a 100644 > > --- a/drivers/gpu/drm/udl/udl_modeset.c > > +++ b/drivers/gpu/drm/udl/udl_modeset.c > > @@ -244,14 +244,13 @@ static long udl_log_cpp(unsigned int cpp) > > static int udl_handle_damage(struct drm_framebuffer *fb, > > const struct iosys_map *map, > > - int x, int y, int width, int height) > > + struct drm_rect *clip) > > Should probably be declared const. > > > { > > struct drm_device *dev = fb->dev; > > void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */ > > int i, ret; > > char *cmd; > > struct urb *urb; > > - struct drm_rect clip; > > int log_bpp; > > ret = udl_log_cpp(fb->format->cpp[0]); > > @@ -259,8 +258,6 @@ static int udl_handle_damage(struct drm_framebuffer *fb, > > return ret; > > log_bpp = ret; > > - drm_rect_init(&clip, x, y, width, height); > > - > > ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); > > if (ret) > > return ret; > > @@ -272,11 +269,11 @@ static int udl_handle_damage(struct drm_framebuffer *fb, > > } > > cmd = urb->transfer_buffer; > > - for (i = clip.y1; i < clip.y2; i++) { > > + for (i = clip->y1; i < clip->y2; i++) { > > const int line_offset = fb->pitches[0] * i; > > - const int byte_offset = line_offset + (clip.x1 << log_bpp); > > - const int dev_byte_offset = (fb->width * i + clip.x1) << log_bpp; > > - const int byte_width = (clip.x2 - clip.x1) << log_bpp; > > + const int byte_offset = line_offset + (clip->x1 << log_bpp); > > + const int dev_byte_offset = (fb->width * i + clip->x1) << log_bpp; > > + const int byte_width = (clip->x2 - clip->x1) << log_bpp; > > Please use drm_rect_width(clip) instead. Somehow there's already too > much code that open-codes this. > > > ret = udl_render_hline(dev, log_bpp, &urb, (char *)vaddr, > > &cmd, byte_offset, dev_byte_offset, > > byte_width); > > @@ -329,6 +326,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, > > struct udl_device *udl = to_udl(dev); > > struct drm_display_mode *mode = &crtc_state->mode; > > struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); > > + struct drm_rect clip; > > Better do a static init with DRM_RECT_INIT(0, 0, fb->width, > fb->height) and remove the other init call below. OK, below is the revised patch. Do you want me a full respin for v4? Takashi -- 8< -- From: Takashi Iwai Subject: [PATCH] drm/udl: Pass rectangle directly to udl_handle_damage() Just for some code simplification. Suggested-by: Thomas Zimmermann Acked-by: Thomas Zimmermann Signed-off-by: Takashi Iwai --- drivers/gpu/drm/udl/udl_modeset.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/udl/udl_modeset.c b/drivers/gpu/drm/udl/udl_modeset.c index c9b837ac26a7..d5e20bf144bc 100644 --- a/drivers/gpu/drm/udl/udl_modeset.c +++ b/drivers/gpu/drm/udl/udl_modeset.c @@ -244,14 +244,13 @@ static long udl_log_cpp(unsigned int cpp) static int udl_handle_damage(struct drm_framebuffer *fb, const struct iosys_map *map, - int x, int y, int width, int height) + const struct drm_rect *clip) { struct drm_device *dev = fb->dev; void *vaddr = map->vaddr; /* TODO: Use mapping abstraction properly */ int i, ret; char *cmd; struct urb *urb; - struct drm_rect clip; int log_bpp; ret = udl_log_cpp(fb->format->cpp[0]); @@ -259,8 +258,6 @@ static int udl_handle_damage(struct drm_framebuffer *fb, return ret; log_bpp = ret; - drm_rect_init(&clip, x, y, width, height); - ret = drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE); if (ret) return ret; @@ -272,11 +269,11 @@ static int udl_handle_damage(struct drm_framebuffer *fb, } cmd = urb->transfer_buffer; - for (i = clip.y1; i < clip.y2; i++) { + for (i = clip->y1; i < clip->y2; i++) { const int line_offset = fb->pitches[0] * i; - const int byte_offset = line_offset + (clip.x1 << log_bpp); - const int dev_byte_offset = (fb->width * i + clip.x1) << log_bpp; - const int byte_width = (clip.x2 - clip.x1) << log_bpp; + const int byte_offset = line_offset + (clip->x1 << log_bpp); + const int dev_byte_offset = (fb->width * i + clip->x1) << log_bpp; + const int byte_width = drm_rect_width(clip) << log_bpp; ret = udl_render_hline(dev, log_bpp, &urb, (char *)vaddr, &cmd, byte_offset, dev_byte_offset, byte_width); @@ -329,6 +326,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, struct udl_device *udl = to_udl(dev); struct drm_display_mode *mode = &crtc_state->mode; struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(plane_state); + struct drm_rect clip = DRM_RECT_INIT(0, 0, fb->width, fb->height); char *buf; char *wrptr; int color_depth = UDL_COLOR_DEPTH_16BPP; @@ -354,7 +352,7 @@ udl_simple_display_pipe_enable(struct drm_simple_display_pipe *pipe, udl->mode_buf_len = wrptr - buf; - udl_handle_damage(fb, &shadow_plane_state->data[0], 0, 0, fb->width, fb->height); + udl_handle_damage(fb, &shadow_plane_state->data[0], &clip); /* enable display */ udl_crtc_write_mode_to_hw(crtc); @@ -396,8 +394,7 @@ udl_simple_display_pipe_update(struct drm_simple_display_pipe *pipe, return; if (drm_atomic_helper_damage_merged(old_plane_state, state, &rect)) - udl_handle_damage(fb, &shadow_plane_state->data[0], rect.x1, rect.y1, - rect.x2 - rect.x1, rect.y2 - rect.y1); + udl_handle_damage(fb, &shadow_plane_state->data[0], &rect); } static const struct drm_simple_display_pipe_funcs udl_simple_display_pipe_funcs = { -- 2.35.3