Received: by 10.192.165.156 with SMTP id m28csp506002imm; Mon, 16 Apr 2018 04:15:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx48FzmCJHI+4MCyj8PlBSLuN+KMuY3nZsd5rzaqcJwpNK13cdOGFTYZYDsC2sh8SvJnFMvbN X-Received: by 2002:a17:902:28a6:: with SMTP id f35-v6mr15116841plb.204.1523877335869; Mon, 16 Apr 2018 04:15:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523877335; cv=none; d=google.com; s=arc-20160816; b=e9NRnb9WsqdPLu8Vz7y6njU4itzRuSqWqfnu18uHUegFVNDmaFOXCiyTv4oSwZ4d5z voJ81u4j2Kljct3rzShCpQgcIE465o3TA6WRnrkxR6Ur0XQx+owj/JOx0yKeDKzisRaI MJTf8z4Obv/hlRX89fI8DES+jSB5o6H0Cgq8rmNsf3r2jVlFbfDmIrOe30ork4ein3Vj xRmrLQTZsOSYgTqaPUykxgfRR64cqug/Y7qZtYkTR8hjVIvcMb/bMaO76fAa2Hybg7np rrFfJKWz526V+L9+RXfcZSTLfa06y6WFKznvR29mMaprkNKI/BBm9jqhtwHqhJvEv/X7 wZZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=plNFJ/oGpO/BHOD1jsjJ12ei0tZ1b+5TxCuACNy/5us=; b=zcPlqRRZZkdaV13JNIGPTIIjJYZZ/LZ0ZUASrZgFIaUSMaHlmWl7M0rFBU9ax7DGwt +XqNy8dka4PBuBxnKKlOEmKRM9slc6IW4hY8x+RcoyVgR2DvbSjbKyq9zoGbhkAeLRqV REruSa6xV2J5ztL7h0yVZu2rsooJgk1jSBNVSdsduSO36J5WRDIdY07PktFW7nXE8lTn cy12oqBXo3V6A7qm9oYEMSAxqgugyUwPo+k6HSplF0rye3GcmldMhn0Yb1ubQ0rfCSmW 9i1S3fbk8dp/o/7xEMS0x5aClZMyBeKRu4coTp4G5K71JAEMD2RuMuG83JOthZrEAb9Q P4dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=gr+Rem84; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e8si9699061pgf.679.2018.04.16.04.15.22; Mon, 16 Apr 2018 04:15:35 -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=pass header.i=@samsung.com header.s=mail20170921 header.b=gr+Rem84; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752840AbeDPJvM (ORCPT + 99 others); Mon, 16 Apr 2018 05:51:12 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:32979 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750795AbeDPJvJ (ORCPT ); Mon, 16 Apr 2018 05:51:09 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180416095106euoutp02f884b1070da7873bd262fb4a77488612~l4cC7G5Fq1471114711euoutp02k; Mon, 16 Apr 2018 09:51:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180416095106euoutp02f884b1070da7873bd262fb4a77488612~l4cC7G5Fq1471114711euoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523872266; bh=plNFJ/oGpO/BHOD1jsjJ12ei0tZ1b+5TxCuACNy/5us=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=gr+Rem84Yj6cl2okneiMp4WmH7FoHZC5UEFBynBPhPNBEvP6F7werPdTJzAZdNz1O MbO6hVVRAI9SIvozWzVWo9o5hdNg1epblvK6seoWGZ3ws85zko6E2CkYoEMo6B8uyY /yi1nbgR5NegBiuYMWpqacaa8FF4Bx+XrpLd0Y7o= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180416095105eucas1p1c6786b6b1f03f697e41fb9cc7ea30066~l4cB6LIw30926509265eucas1p16; Mon, 16 Apr 2018 09:51:05 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id C7.CA.10409.90274DA5; Mon, 16 Apr 2018 10:51:05 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180416095104eucas1p1a4a4f1cbd39804702412b0dceff083a6~l4cBCdV8d0925309253eucas1p1T; Mon, 16 Apr 2018 09:51:04 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20180416095104eusmtrp27f8d32a2bbd0a65435d8d613ac95414b~l4cAyYX_23017830178eusmtrp2N; Mon, 16 Apr 2018 09:51:04 +0000 (GMT) X-AuditID: cbfec7f5-b5fff700000028a9-e8-5ad47209bcc5 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 15.DC.04183.80274DA5; Mon, 16 Apr 2018 10:51:04 +0100 (BST) Received: from [106.120.43.17] (unknown [106.120.43.17]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20180416095103eusmtip1b52d7248fae3296f5fe803390055b494~l4b-en-BW1133311333eusmtip1H; Mon, 16 Apr 2018 09:51:03 +0000 (GMT) Subject: Re: [PATCH v6 29/30] drm/rockchip: Disallow PSR for the whole atomic commit To: Enric Balletbo i Serra , architt@codeaurora.org, inki.dae@samsung.com, thierry.reding@gmail.com, hjc@rock-chips.com, seanpaul@chromium.org, airlied@linux.ie, tfiga@chromium.org, heiko@sntech.de Cc: dri-devel@lists.freedesktop.org, dianders@chromium.org, ykk@rock-chips.com, kernel@collabora.com, m.szyprowski@samsung.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, rydberg@bitmath.org, krzk@kernel.org, linux-rockchip@lists.infradead.org, kgene@kernel.org, linux-input@vger.kernel.org, orjan.eide@arm.com, wxt@rock-chips.com, jeffy.chen@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, wzz@rock-chips.com, hl@rock-chips.com, jingoohan1@gmail.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, Laurent.pinchart@ideasonboard.com, kuankuan.y@gmail.com, hshi@chromium.org, "Kristian H . Kristensen" From: Andrzej Hajda Message-ID: Date: Mon, 16 Apr 2018 11:51:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180405095000.9756-30-enric.balletbo@collabora.com> Content-Transfer-Encoding: 8bit Content-Language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA02Ta2yTZRTH87z3LhZeCronhQytMwEMw0WSHUQJGkneD5oYPxhSE6W6lw1Z x2zZZDqhdu6KmziIrt0FYraONDM03QZd1ZW1QAe1LU1xbJCuA5bsRhXYjTq3ufaFuG+/c/7/ k+d/TvJwpGKcUXIH8g+LunxNnopJoc5fiQe2ynQ31K+cmtkANYGrBBgrYzT4Lb0M3Jj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5GxBt5SUZOE/Pewz+5IDAAA= X-CMS-MailID: 20180416095104eucas1p1a4a4f1cbd39804702412b0dceff083a6 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-MTR: 20180416095104eucas1p1a4a4f1cbd39804702412b0dceff083a6 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180405095119epcas5p1964fcfc777686af4216a7ff6acd964ce X-RootMTR: 20180405095119epcas5p1964fcfc777686af4216a7ff6acd964ce References: <20180405095000.9756-1-enric.balletbo@collabora.com> <20180405095000.9756-30-enric.balletbo@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05.04.2018 11:49, Enric Balletbo i Serra wrote: > From: Tomasz Figa > > Currently PSR flush is triggered from CRTC's .atomic_begin() callback, > which is executed after modeset disables and enables and before plane > updates are committed. Since PSR flush and re-enable can be triggered > asynchronously by external sources (input event, delayed work), it can > race with hardware programming done in the aforementioned stages. > > This patch blocks the PSR completely before hardware programming part > begins and unblock after it ends. This relies on reference counted PSR > disable introduced with previous patch. > > Cc: Kristian H. Kristensen > Signed-off-by: Tomasz Figa > Signed-off-by: Sean Paul > Signed-off-by: Thierry Escande > Signed-off-by: Enric Balletbo i Serra > Tested-by: Marek Szyprowski > --- > > drivers/gpu/drm/rockchip/rockchip_drm_fb.c | 61 ++++++++++++++++++++++++++++- > drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 7 ---- > 2 files changed, 60 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > index e266539e04e5..d4f4118b482d 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_fb.c > @@ -167,8 +167,67 @@ rockchip_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, > return ERR_PTR(ret); > } > > +static void > +rockchip_drm_psr_inhibit_get_state(struct drm_atomic_state *state) > +{ > + struct drm_crtc *crtc; > + struct drm_crtc_state *crtc_state; > + struct drm_encoder *encoder; > + u32 encoder_mask = 0; > + int i; > + > + for_each_old_crtc_in_state(state, crtc, crtc_state, i) { > + encoder_mask |= crtc_state->encoder_mask; > + encoder_mask |= crtc->state->encoder_mask; Looks clever and cryptic. More readable would be with for_each_oldnew_crtc_in_state. Anyway: Reviewed-by: Andrzej Hajda  -- Regards Andrzej > + } > + > + drm_for_each_encoder_mask(encoder, state->dev, encoder_mask) > + rockchip_drm_psr_inhibit_get(encoder); > +} > + > +static void > +rockchip_drm_psr_inhibit_put_state(struct drm_atomic_state *state) > +{ > + struct drm_crtc *crtc; > + struct drm_crtc_state *crtc_state; > + struct drm_encoder *encoder; > + u32 encoder_mask = 0; > + int i; > + > + for_each_old_crtc_in_state(state, crtc, crtc_state, i) { > + encoder_mask |= crtc_state->encoder_mask; > + encoder_mask |= crtc->state->encoder_mask; > + } > + > + drm_for_each_encoder_mask(encoder, state->dev, encoder_mask) > + rockchip_drm_psr_inhibit_put(encoder); > +} > + > +static void > +rockchip_atomic_helper_commit_tail_rpm(struct drm_atomic_state *old_state) > +{ > + struct drm_device *dev = old_state->dev; > + > + rockchip_drm_psr_inhibit_get_state(old_state); > + > + drm_atomic_helper_commit_modeset_disables(dev, old_state); > + > + drm_atomic_helper_commit_modeset_enables(dev, old_state); > + > + drm_atomic_helper_commit_planes(dev, old_state, > + DRM_PLANE_COMMIT_ACTIVE_ONLY); > + > + rockchip_drm_psr_inhibit_put_state(old_state); > + > + drm_atomic_helper_commit_hw_done(old_state); > + > + drm_atomic_helper_wait_for_vblanks(dev, old_state); > + > + drm_atomic_helper_cleanup_planes(dev, old_state); > +} > + > static const struct drm_mode_config_helper_funcs rockchip_mode_config_helpers = { > - .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, > + .atomic_commit_tail = rockchip_atomic_helper_commit_tail_rpm, > }; > > static const struct drm_mode_config_funcs rockchip_drm_mode_config_funcs = { > diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > index 00f7f3441cf6..f14a10ca4792 100644 > --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c > @@ -1029,16 +1029,9 @@ static void vop_crtc_atomic_flush(struct drm_crtc *crtc, > } > } > > -static void vop_crtc_atomic_begin(struct drm_crtc *crtc, > - struct drm_crtc_state *old_crtc_state) > -{ > - rockchip_drm_psr_flush(crtc); > -} > - > static const struct drm_crtc_helper_funcs vop_crtc_helper_funcs = { > .mode_fixup = vop_crtc_mode_fixup, > .atomic_flush = vop_crtc_atomic_flush, > - .atomic_begin = vop_crtc_atomic_begin, > .atomic_enable = vop_crtc_atomic_enable, > .atomic_disable = vop_crtc_atomic_disable, > };