Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6972027rwn; Tue, 13 Sep 2022 11:41:13 -0700 (PDT) X-Google-Smtp-Source: AA6agR5kLjL5cz44+3ywCprMz7xGQQCnEB64M7SEkft9Rx3LJACdusAlU7foPDgK6DGSLEBjwwSr X-Received: by 2002:a17:907:60d6:b0:77d:8aed:cf86 with SMTP id hv22-20020a17090760d600b0077d8aedcf86mr7564526ejc.43.1663094473156; Tue, 13 Sep 2022 11:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663094473; cv=none; d=google.com; s=arc-20160816; b=mS/x09kx5zUEPw4AGfnJJkeSfyAo+4zC5uTAEUP6yWlD5CMmUXQxE1V3qZjWa1XUu3 Nhhtw+h+SjdGKwg9uqbkxvr9vEljE7byGHBHmmU+ICyH75dcKOFhOSHA1O4oyzK/PjxS Z8Qmp0XND6WN8Qn6Z3OlM6EX+16BoXsUIWKBXQQ5qEOKrJRmi9u7OxM+gAb+v6e7bKGP x5YfAY5+ltjP/Y6VyjtxlFLXxFd0CFrs2R/Zc2VXwT6zgYNZ3FrX1lzKpHBg38SVOsn6 RzWvcE/E9WmpqyAa1TR9Iwi2p5hvLMHlyd9BBVBeunCMFkT/33NxVM9Vq2fLkmITVt6v kdKg== 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:dkim-signature; bh=C1SHrY0bzxKJ2NJT55YgREa1pzMItM4ioi+jr7Uh69I=; b=uEgWJH+E3If+ET9MdkgK4wkBmzfjOFvc/xnq2BXC0DCBKkhE532D1rP0nEy2qSE8An jGNpjhEdLC3nWLucXwV9qdGDe3p9ZzHTLm7rOybfOZrejECapNto3bXK6xkQBiUyXxlu R429J5mapaImVYZfzhYkfeP06y+ZrfTA8sOgJpRajqllRwSXtJvriJBq5YRjKD/LfVFb /efd0uNmXd7WZ/IpN+273N5//gAn4/uGuEAYdJLFpyy1BN9RpFjF35w5O/cNXVzKOQ1I utro8BWmInoazjQL9kyBmlj40HX5OS+MDwJJG7UtbNyih6mR14TRov2w9H96lHnGqw2F 18hQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZyzHm7wC; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h17-20020a05640250d100b0044f1b69fbedsi11455820edb.338.2022.09.13.11.40.47; Tue, 13 Sep 2022 11:41:13 -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=@linaro.org header.s=google header.b=ZyzHm7wC; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231959AbiIMSD0 (ORCPT + 99 others); Tue, 13 Sep 2022 14:03:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232274AbiIMSDE (ORCPT ); Tue, 13 Sep 2022 14:03:04 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 757EA72EE8 for ; Tue, 13 Sep 2022 10:04:52 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id q21so21260957lfo.0 for ; Tue, 13 Sep 2022 10:04:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date; bh=C1SHrY0bzxKJ2NJT55YgREa1pzMItM4ioi+jr7Uh69I=; b=ZyzHm7wCckAHL4Gs1yvJKUehjmxAlog/Jx3GoSEfC4baYLnjiY7xzQVbg1PkrG4KFC v97vC0Qk1DFJl9ilEx3cLWjd/j9NES0HBuZanV/u/bcCIliA9ktXGZrjhAAxQLsg7oqC 9USwMMYwfKr+JzxZQ3Su1k9TpWSYbZccBk5Go25P9wOiQWcuB/EeDpKNudTt/UDESMDq CCTylyfCgb0/lOANY0qNvTCv2F/hLzFA3m7UOUKmAX+hSZnuxTD+4IRPuhmBEJ5+SwMj ZuFKikE00gDHXMjuVbTrIoI7n0Swziqp6aJViDdPykGVFW9DXifyATtfJz+1ysj3OPLs u4TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date; bh=C1SHrY0bzxKJ2NJT55YgREa1pzMItM4ioi+jr7Uh69I=; b=eoxKr+WMTtRqk+OZf4zzwZy+IqVM8J4SzZVW1sGHGTmFpbCYLsz4qllUktgf5Bq74N 2Af3WrmdkDRrghRhn7ggijIJ7nSQSa2gi3d3TIplSpJyisbgvIdCxYO0pp+FGYRkyoum apF1W31V46pxvH8jBLy6KZgAy/TmZAhIy8oqnvQnshmmYVMaVagDeN/zSlNwBctYHkNa j5iGmBCk2W6cc6duvuWg2/nHg71sRFBOJqrrEFksjaf5UubxAQrvsltyM15UWe6aOt+g RPewuYySc74HDseov1tfgM2chNCvtc21AMEcW/hR3DQJS/VnGCKM5Qiw+P2OTxhlpdyp C1eQ== X-Gm-Message-State: ACgBeo0nKJW3h4aGpWW2cW79ZmkxhdRoqgm06O1ca2dIxi0W6AvoGtLx lrKiYSzGJJREG0rnpLW6y7eToQ== X-Received: by 2002:a19:f805:0:b0:498:df1f:858e with SMTP id a5-20020a19f805000000b00498df1f858emr9917460lff.610.1663088690486; Tue, 13 Sep 2022 10:04:50 -0700 (PDT) Received: from [192.168.1.211] ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id i24-20020a0565123e1800b00492e5d31201sm1833989lfv.7.2022.09.13.10.04.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Sep 2022 10:04:50 -0700 (PDT) Message-ID: Date: Tue, 13 Sep 2022 20:04:49 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.1 Subject: Re: [PATCH v7 01/15] drm/msm/disp/dpu: clear dpu_assign_crtc and get crtc from connector state instead of dpu_enc Content-Language: en-GB To: Vinod Polimera , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, robdclark@gmail.com, dianders@chromium.org, swboyd@chromium.org, quic_kalyant@quicinc.com, quic_khsieh@quicinc.com, quic_vproddut@quicinc.com, quic_bjorande@quicinc.com, quic_aravindh@quicinc.com, quic_abhinavk@quicinc.com, quic_sbillaka@quicinc.com References: <1663080676-12936-1-git-send-email-quic_vpolimer@quicinc.com> <1663080676-12936-2-git-send-email-quic_vpolimer@quicinc.com> From: Dmitry Baryshkov In-Reply-To: <1663080676-12936-2-git-send-email-quic_vpolimer@quicinc.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 13/09/2022 17:51, Vinod Polimera wrote: > Update crtc retrieval from dpu_enc to dpu_enc connector state, > since new links get set as part of the dpu enc virt mode set. > The dpu_enc->crtc cache is no more needed, hence cleaning it as > part of this change. > > Signed-off-by: Vinod Polimera > --- > drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 4 ---- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 35 ++++++++++++----------------- > drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 8 ------- > 3 files changed, 14 insertions(+), 33 deletions(-) > > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > index 13ce321..8ec9a13 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c > @@ -1029,7 +1029,6 @@ static void dpu_crtc_disable(struct drm_crtc *crtc, > */ > if (dpu_encoder_get_intf_mode(encoder) == INTF_MODE_VIDEO) > release_bandwidth = true; > - dpu_encoder_assign_crtc(encoder, NULL); > } > > /* wait for frame_event_done completion */ > @@ -1099,9 +1098,6 @@ static void dpu_crtc_enable(struct drm_crtc *crtc, > trace_dpu_crtc_enable(DRMID(crtc), true, dpu_crtc); > dpu_crtc->enabled = true; > > - drm_for_each_encoder_mask(encoder, crtc->dev, crtc->state->encoder_mask) > - dpu_encoder_assign_crtc(encoder, crtc); > - > /* Enable/restore vblank irq handling */ > drm_crtc_vblank_on(crtc); > } > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > index 9c6817b..0c7d8b5 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c > @@ -132,11 +132,6 @@ enum dpu_enc_rc_states { > * @intfs_swapped: Whether or not the phys_enc interfaces have been swapped > * for partial update right-only cases, such as pingpong > * split where virtual pingpong does not generate IRQs > - * @crtc: Pointer to the currently assigned crtc. Normally you > - * would use crtc->state->encoder_mask to determine the > - * link between encoder/crtc. However in this case we need > - * to track crtc in the disable() hook which is called > - * _after_ encoder_mask is cleared. > * @connector: If a mode is set, cached pointer to the active connector > * @crtc_kickoff_cb: Callback into CRTC that will flush & start > * all CTL paths > @@ -181,7 +176,6 @@ struct dpu_encoder_virt { > > bool intfs_swapped; > > - struct drm_crtc *crtc; > struct drm_connector *connector; > > struct dentry *debugfs_root; > @@ -1288,6 +1282,7 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc, > struct dpu_encoder_phys *phy_enc) > { > struct dpu_encoder_virt *dpu_enc = NULL; > + struct drm_crtc *crtc; > unsigned long lock_flags; > > if (!drm_enc || !phy_enc) > @@ -1298,9 +1293,14 @@ static void dpu_encoder_vblank_callback(struct drm_encoder *drm_enc, > > atomic_inc(&phy_enc->vsync_cnt); > > + if (!dpu_enc->connector || !dpu_enc->connector->state) > + return; > + > + crtc = dpu_enc->connector->state->crtc; > + > spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); > - if (dpu_enc->crtc) > - dpu_crtc_vblank_callback(dpu_enc->crtc); > + if (crtc) > + dpu_crtc_vblank_callback(crtc); > spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); Stephen's comment about reading the state from outside of the lock and then using local variable under spinlock is still valid. Moreover I'm not sure that enc_spinlock protects connector's state. I'd say one has to take the modesetting lock here. > > DPU_ATRACE_END("encoder_vblank_callback"); > @@ -1324,29 +1324,22 @@ static void dpu_encoder_underrun_callback(struct drm_encoder *drm_enc, > DPU_ATRACE_END("encoder_underrun_callback"); > } > > -void dpu_encoder_assign_crtc(struct drm_encoder *drm_enc, struct drm_crtc *crtc) > -{ > - struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); > - unsigned long lock_flags; > - > - spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); > - /* crtc should always be cleared before re-assigning */ > - WARN_ON(crtc && dpu_enc->crtc); > - dpu_enc->crtc = crtc; > - spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); > -} > - > void dpu_encoder_toggle_vblank_for_crtc(struct drm_encoder *drm_enc, > struct drm_crtc *crtc, bool enable) > { > struct dpu_encoder_virt *dpu_enc = to_dpu_encoder_virt(drm_enc); > + struct drm_crtc *new_crtc; > unsigned long lock_flags; > int i; > > trace_dpu_enc_vblank_cb(DRMID(drm_enc), enable); > > + if (!dpu_enc->connector || !dpu_enc->connector->state) > + return; > + > + new_crtc = dpu_enc->connector->state->crtc; > spin_lock_irqsave(&dpu_enc->enc_spinlock, lock_flags); > - if (dpu_enc->crtc != crtc) { > + if (!new_crtc || new_crtc != crtc) { > spin_unlock_irqrestore(&dpu_enc->enc_spinlock, lock_flags); > return; > } > diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > index 9e7236e..eda5cd8 100644 > --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h > @@ -40,14 +40,6 @@ struct msm_display_info { > }; > > /** > - * dpu_encoder_assign_crtc - Link the encoder to the crtc it's assigned to > - * @encoder: encoder pointer > - * @crtc: crtc pointer > - */ > -void dpu_encoder_assign_crtc(struct drm_encoder *encoder, > - struct drm_crtc *crtc); > - > -/** > * dpu_encoder_toggle_vblank_for_crtc - Toggles vblank interrupts on or off if > * the encoder is assigned to the given crtc > * @encoder: encoder pointer -- With best wishes Dmitry