Received: by 10.213.65.68 with SMTP id h4csp1645903imn; Thu, 5 Apr 2018 01:00:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Xh8P4FY9mzjOdb9WBhaOHJaouoGlxerVVCpgd6YckpALw+fNlV9yRjgBeDpo7JFFjaNQ4 X-Received: by 10.98.194.133 with SMTP id w5mr16487716pfk.6.1522915258907; Thu, 05 Apr 2018 01:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522915258; cv=none; d=google.com; s=arc-20160816; b=zmjuwqI3PRH9SPHKPNppJGXNoD/sZQv7I9twMn8JZHRlhLIjxsx75hHo8Kc/yjfVHx iJuC+7rvYsatnwR3ocetnaGqyqIDSl0oHCT67aDrQd1dBPGVFpIORSfDseHbcDMO/Woj WleayVKk23/3V0a/D/rtK0OBhWxK5X05dsNXRXs29b55g9OJZzFnTDeO2iarXh5VNv/i E8xWTHjpcto4CSUemyXeqS57K+1/rGjn0V5HqDw5di3PjEopst8JzBOYxMjEneXpAzSg PqK60SOhYjszt33y0n6lSHn9x0IHtkr9fvwHeqg6kIkehvghhHqpUyfUUhXwOZHU4DOF Zl3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=C4CYxwVL8qLLDHXsLWNwCsLCsG/Q2CDAldNApw2FpXo=; b=u9+xIOyCcnoJdPS/gNVtb1o2uTbx+Qq0+SCsIjn0yDQfRmv8KZdENvH7b2j4it0Hmk ZQDh32o2ex4vkL4jDZGq57rYfDbUoFthdDvr7sDHwsSNe0+cPTi8oDx4MKL7uaFIH/Fx GwY9FD6wgcpXVBkSod4bbkkCr2fjwm4jOGW8i3lj96VH6xIPHDZZb749ET+8KLkIjAan D/KjdW5SWrP0DSkEgwgw+uTjI3DBOmY5Wjig1MDjtgrgiiOJt8GqXkWCDLb/i76XI6Mc yxOz3jSDBfNOdEvkb5M9iyWTYv6T0OovYi5u1sqHckRWn7OjN/caftGmhI0S/2RlHvsQ e+3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=Aqs6SCdo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 207si5666288pfz.108.2018.04.05.01.00.44; Thu, 05 Apr 2018 01:00:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=Aqs6SCdo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751365AbeDEH7f (ORCPT + 99 others); Thu, 5 Apr 2018 03:59:35 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:36994 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751213AbeDEH7e (ORCPT ); Thu, 5 Apr 2018 03:59:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id r131so4265188wmb.2 for ; Thu, 05 Apr 2018 00:59:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=sender:date:from:to:cc:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=C4CYxwVL8qLLDHXsLWNwCsLCsG/Q2CDAldNApw2FpXo=; b=Aqs6SCdo/JmYaF3JnZAl+Kb/x2qKUYNwRGwKp/BsXN95yCrHzycC0kE37rNs0tYcno L9QVf0pLFRT/0hfTBHZHxH22cm309mEmOipkAWMQwj0MX5ghQ817yYcCCRSrQFrPHSjN fPHOPsq6LoUKo0R0A9eO38rw8Hgavxl4fw258= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=C4CYxwVL8qLLDHXsLWNwCsLCsG/Q2CDAldNApw2FpXo=; b=JSOD8+kTnBQm6bagIK6pv473lj59zUeP6S9z4zBobcP7IqfhUfeWLu8Kpgm2z9TRuo Hr40aPvnLocXfL25cLongHU02jlB4aEqz/2nbYhkqNZolzFe4qotIAN6LN5EZOzZhGlu tD0dgnAcQnlH0Et2Vg/LgKWgEt9ZQx7Xqwpg1pdlW4oiOFtj4kKVoR7ZqnQs4RCANmVs bwwJ/IjfEvf6sjGQp/wEg6ejgjcdWJgsSpF1loW+9w37Cu7XcDU7eC/2HtuDNllsbMIv GI+CCcGas0xIQlOpXKXydo0K+Jmn2u4OADBhd/hU0a/spjoJE/uL4auC5VwRW7e4NeoA pCcg== X-Gm-Message-State: ALQs6tBIUsPbxDmzS5VlT1XNc++VbmE1a9BOheUTkaDlvxfH/D1uuaNT L36GY33qGDwWjQwbeB0i4O4+lg== X-Received: by 10.80.189.194 with SMTP id z2mr1894384edh.255.1522915172999; Thu, 05 Apr 2018 00:59:32 -0700 (PDT) Received: from phenom.ffwll.local (212-51-149-109.fiber7.init7.net. [212.51.149.109]) by smtp.gmail.com with ESMTPSA id 94sm4618287edk.43.2018.04.05.00.59.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Apr 2018 00:59:31 -0700 (PDT) Date: Thu, 5 Apr 2018 09:59:29 +0200 From: Daniel Vetter To: Deepak Rawat Cc: dri-devel@lists.freedesktop.org, thellstrom@vmware.com, syeh@vmware.com, linux-graphics-maintainer@vmware.com, daniel@ffwll.ch, ville.syrjala@linux.intel.com, lukasz.spintzyk@displaylink.com, noralf@tronnes.org, robdclark@gmail.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, linux-kernel@vger.kernel.org Subject: Re: [RFC 3/3] drm: Add helper to validate damage during modeset_check Message-ID: <20180405075929.GR3881@phenom.ffwll.local> Mail-Followup-To: Deepak Rawat , dri-devel@lists.freedesktop.org, thellstrom@vmware.com, syeh@vmware.com, linux-graphics-maintainer@vmware.com, ville.syrjala@linux.intel.com, lukasz.spintzyk@displaylink.com, noralf@tronnes.org, robdclark@gmail.com, gustavo@padovan.org, maarten.lankhorst@linux.intel.com, seanpaul@chromium.org, airlied@linux.ie, linux-kernel@vger.kernel.org References: <1522885748-67122-1-git-send-email-drawat@vmware.com> <1522885748-67122-4-git-send-email-drawat@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1522885748-67122-4-git-send-email-drawat@vmware.com> X-Operating-System: Linux phenom 4.15.0-1-amd64 User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 04, 2018 at 04:49:08PM -0700, Deepak Rawat wrote: > This patch adds a helper which should be called by driver which enable > damage (by calling drm_plane_enable_damage_clips) from atomic_check > hook. This helper for now set the damage to NULL for the planes on crtc > which need full modeset. > > The driver also need to check for other crtc properties which can > affect damage in atomic_check hook, like gamma, ctm, etc. Plane related > properties which affect damage can be handled in damage iterator. > > Signed-off-by: Deepak Rawat > --- > drivers/gpu/drm/drm_atomic_helper.c | 47 +++++++++++++++++++++++++++++++++++++ > include/drm/drm_atomic_helper.h | 2 ++ > 2 files changed, 49 insertions(+) > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c > index 355b514..23f44ab 100644 > --- a/drivers/gpu/drm/drm_atomic_helper.c > +++ b/drivers/gpu/drm/drm_atomic_helper.c > @@ -3987,3 +3987,50 @@ drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, > return true; > } > EXPORT_SYMBOL(drm_atomic_helper_damage_iter_next); > + > +/** > + * drm_atomic_helper_check_damage - validate state object for damage changes > + * @dev: DRM device > + * @state: the driver state object > + * > + * Check the state object if damage is required or not. In case damage is not > + * required e.g. need modeset, the damage blob is set to NULL. Why is that needed? I can imagine that drivers unconditionally upload everything for a modeset, and hence don't need special damage tracking. But for that it's imo better to have a clear_damage() helper. But even for modesets (e.g. resolution changes) I'd expect that virtual drivers don't want to upload unecessary amounts of data. Manual upload hw drivers probably need to upload everything, because the panel will have forgotten all the old data once power cycled. And if you think this is really the right thing, then we need to rename the function to tell what it does, e.g. drm_damage_helper_clear_damage_on_modeset() drm_damage_helper because I think we should stuff this all into drm_damage_helper.c, see previous patch. But I think a drm_damage_helper_clear_damage(crtc_state) which you can use in your crtc->atomic_check function like crtc_atomic_check(state) { if (drm_atomic_crtc_needs_modeset(state)) drm_damage_helper_clear_damage(state); } is more flexible and useful for drivers. There might be other cases where clearing damage is the right thing to do. Also, there's the question of whether no damage clips == full damage or not, so maybe we should call this helper full_damage() instead. -Daniel > + * > + * NOTE: This helper is not called by core. Those driver which enable damage > + * using drm_plane_enable_damage_clips should call this from their @atomic_check > + * hook. > + */ > +int drm_atomic_helper_check_damage(struct drm_device *dev, > + struct drm_atomic_state *state) > +{ > + struct drm_crtc *crtc; > + struct drm_plane *plane; > + struct drm_crtc_state *crtc_state; > + unsigned plane_mask; > + int i; > + > + for_each_new_crtc_in_state(state, crtc, crtc_state, i) { > + if (!drm_atomic_crtc_needs_modeset(crtc_state)) > + continue; > + > + plane_mask = crtc_state->plane_mask; > + plane_mask |= crtc->state->plane_mask; > + > + drm_for_each_plane_mask(plane, dev, plane_mask) { > + struct drm_plane_state *plane_state = > + drm_atomic_get_plane_state(state, plane); > + > + if (IS_ERR(plane_state)) > + return PTR_ERR(plane_state); > + > + if (plane_state->damage_clips) { > + drm_property_blob_put(plane_state->damage_clips); > + plane_state->damage_clips = NULL; > + plane_state->num_clips = 0; > + } > + } > + } > + > + return 0; > +} > +EXPORT_SYMBOL(drm_atomic_helper_check_damage); > diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h > index ebd4b66..b12335c 100644 > --- a/include/drm/drm_atomic_helper.h > +++ b/include/drm/drm_atomic_helper.h > @@ -224,6 +224,8 @@ drm_atomic_helper_damage_iter_init(struct drm_atomic_helper_damage_iter *iter, > bool > drm_atomic_helper_damage_iter_next(struct drm_atomic_helper_damage_iter *iter, > struct drm_rect *rect); > +int drm_atomic_helper_check_damage(struct drm_device *dev, > + struct drm_atomic_state *state); > > /** > * drm_atomic_crtc_for_each_plane - iterate over planes currently attached to CRTC > -- > 2.7.4 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch