Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1053153rbb; Sun, 25 Feb 2024 17:34:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXUrcLtjURW5nHT5Ro5mfuEv4krvCkYKjKj1Xnr8qNb0I/grpXPZU1qmDHgf3QUIkc/7PvIOCoCibVPjck/uWCRwTMYkqROJvoUT5UjTA== X-Google-Smtp-Source: AGHT+IE91GB0xocibWXACL7aLFVbMxiyVAbOuyTM1k9i8uAKvA1zZaQ4Su/47TaTLJTapIjz59pB X-Received: by 2002:a17:906:254b:b0:a3f:f73:411f with SMTP id j11-20020a170906254b00b00a3f0f73411fmr3524164ejb.45.1708911244289; Sun, 25 Feb 2024 17:34:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708911244; cv=pass; d=google.com; s=arc-20160816; b=PZAC9+qhZbBEqzJ2O85UggMPtN2WbmJEFQtze4He6o9lW5DCgkreGlKBzbC4ArzuDK jmd+vlNPv9P4ADLuIw9LgvEGimM2eZdrLTwIA5EnXHEhW1xGnely4mWf+D56ryhY9ipl e3qQtttoTu/AZiz1BbAu7hseZlUcg0SL7ssKDtYKRCb7YXW7kxSQkGivEJuBgO9u1o7S W9BqlHfO/cNZeA5wNPunfTvzvn97K6agpJSnd2djuZmqVl3n0nNt1UPXA7O2JoWd/7PI NYyq2EeB2gLgU0ax0fvIg6gL+v+BK2p3FFUx9gvczl3k9jPNavTZDHBlTcKgP4Q56ZaX s0Eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=EQcNerH5zlqRogyZtmxYs0V0RQjRviVf4F1C9HUrbY4=; fh=mmVhTvYsbeh1bD+fbEyRUlh8wi5cMf//Jcp2d7W6Diw=; b=Tp4RZj+Pu7UvLasJs//5bmqJxfqwnpOXUd2thw2CABu2IqbJUdPPONo3/a6P5KC/80 W6YzO7YxlfkzrQGwampBHNLF3q4OZ6UJnU7UleWWm6qCtA+1Gmj95S1mhBDzen9VuA/k g+0EwNXoCMVztA8TKUOHY8fZY6QATcih3Dl9zgXqPvdE8HZxdhPSHLayPEdbNWJI/bVr 1IzEEWBxJ+SKz56iHW6Xcx3BZQjCk0VVOEN7r0Uh5n36u4onnwd1UgQ/kI9YN2qy1kE9 uYxcHI0MGIdQraj9uDfKc8OXnnLqu9Mph6AZInsNQZ/yvjuZdiPweR2V5K+EJpwmQeDL veUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=K4q0+VKp; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-80382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c14-20020a17090654ce00b00a3ec28ac773si1682455ejp.363.2024.02.25.17.34.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 17:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=K4q0+VKp; arc=pass (i=1 spf=pass spfdomain=quicinc.com dkim=pass dkdomain=quicinc.com dmarc=pass fromdomain=quicinc.com); spf=pass (google.com: domain of linux-kernel+bounces-80382-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80382-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DD1A21F20FFE for ; Mon, 26 Feb 2024 01:34:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1AC8DF4D; Mon, 26 Feb 2024 01:33:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="K4q0+VKp" Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C928D2FE; Mon, 26 Feb 2024 01:33:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708911235; cv=none; b=S9tuLFb6cgwyEXHxk6ryg/Q8kUbeqm1cvKyebt9vtQv8/V4NQzH/JhIZK0Bk3uxKFa/fL/DxQ4pP4uqs80i85XVSPMVIvJA3nA1E56a7+kQnSUjs7EdGQ7lksyAGdn/PaMPlY1P2G698JApvNytKnjao8xJSNba8xnhG3aYsnXM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708911235; c=relaxed/simple; bh=IFVZZRMfiP+VjB4RTEv79lj2VIGz4m0+HcV8iKRRuMw=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=lvpudEzC26VbiM8n4BOz5hZhhnnHeTarBGfCzqursVW5bMOS87p38SIi5cwDJEYlG4+GQzmDyNhpdKDDljIxqVWUQ6gffzMItoBw0YlFXU9GpKJYmZbpfEDIfnmtR3yFq4MKtU77Y5X7k/iP152+nKYyrXmfz2Lou8YITb+wDmM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=K4q0+VKp; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 41Q1Xg7i004227; Mon, 26 Feb 2024 01:33:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= message-id:date:mime-version:subject:to:cc:references:from :in-reply-to:content-type:content-transfer-encoding; s= qcppdkim1; bh=EQcNerH5zlqRogyZtmxYs0V0RQjRviVf4F1C9HUrbY4=; b=K4 q0+VKpk0Zj6NFu9BFS5p+ZzcGkdv0KPH9r5vmeCg5L2s4XMexRlK6Z+EpgPTGzSs iCVG5xaPJG91ei8q+BlCQrHmlfgfjzcsU2As+b0xHrRQlbzyyF4/Zwm/izfqVm62 vVWw+cZjpqM53G2oe4Z2k64/Lm9g4QTVjuHZVjTxHlawyaBwceturYkBfX062Ji+ +5IKYBfV374bD98fgtU53RUlqAXJJ7bZ9uSbZL/Ub23dqg2k5Y5Hm/8WrVM2tFjx heKtIbWhqTnIdgVF///iP1zOuzJffhM6pE0ehuqyC1oDNe5LM6IKviQ2UYBs4+uh ZvTTk14e2HeIVpuwYrPg== Received: from nalasppmta02.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3wf7dv2pxx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 01:33:41 +0000 (GMT) Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 41Q1Xe1B004662 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 26 Feb 2024 01:33:40 GMT Received: from [10.110.76.211] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Sun, 25 Feb 2024 17:33:39 -0800 Message-ID: Date: Sun, 25 Feb 2024 17:33:38 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v3 2/3] drm/msm/dpu: split dpu_encoder_wait_for_event into two functions Content-Language: en-US To: Dmitry Baryshkov CC: Rob Clark , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Steev Klimaszewski , , , , References: <20240225-fd-dpu-debug-timeout-v3-0-252f2b21cdcc@linaro.org> <20240225-fd-dpu-debug-timeout-v3-2-252f2b21cdcc@linaro.org> From: Abhinav Kumar In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: g6QEntQV3M3yENABosRIXgXdf3WPIdbl X-Proofpoint-ORIG-GUID: g6QEntQV3M3yENABosRIXgXdf3WPIdbl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1011,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-02-25_29,2024-02-23_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 adultscore=0 suspectscore=0 clxscore=1015 lowpriorityscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2402120000 definitions=main-2402260010 On 2/25/2024 12:52 PM, Dmitry Baryshkov wrote: > On Sun, 25 Feb 2024 at 21:49, Abhinav Kumar wrote: >> >> >> >> On 2/25/2024 6:12 AM, Dmitry Baryshkov wrote: >>> Stop multiplexing several events via the dpu_encoder_wait_for_event() >>> function. Split it into two distinct functions two allow separate >>> handling of those events. >>> >> >> I understand the idea but would handling of those events be really distinct? > > We are interested in capturing the state after the first > wait_for_commit_done() timeout. The wait_for_tx_complete doesn't need > such handling. Even if we were to handle it in some way, it would be a > different conditional. > wait_for_tx_complete timeout also needs similar handling. the timeout mechanisms need to be unified at some point, that time I will re-visit the need to have a common wait_timeout handler. Lets see how this code evolves. So with that nit about the kernel doc addressed, Reviewed-by: Abhinav Kumar > Last but not least, I don't like multiplexing just for the sake of it. > There is nearly no common behaviour. > the multiplexing allows us to have one common timeout path which I think will eventually happen. So i dont think its true that there is no common behavior. >> >> Like if wait_for_commit_done timedout or wait_for_tx_complete timedout, >> the handling will be similar from my PoV. >> >>> Signed-off-by: Dmitry Baryshkov >>> --- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 74 +++++++++++++++++++++-------- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h | 22 ++------- >>> drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 2 +- >>> drivers/gpu/drm/msm/msm_drv.h | 10 ---- >>> 4 files changed, 59 insertions(+), 49 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> index 194dbb08331d..30f349c8a1e5 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c >>> @@ -1282,7 +1282,7 @@ static void dpu_encoder_virt_atomic_disable(struct drm_encoder *drm_enc, >>> trace_dpu_enc_disable(DRMID(drm_enc)); >>> >>> /* wait for idle */ >>> - dpu_encoder_wait_for_event(drm_enc, MSM_ENC_TX_COMPLETE); >>> + dpu_encoder_wait_for_tx_complete(drm_enc); >>> >>> dpu_encoder_resource_control(drm_enc, DPU_ENC_RC_EVENT_PRE_STOP); >>> >>> @@ -2402,10 +2402,23 @@ struct drm_encoder *dpu_encoder_init(struct drm_device *dev, >>> return &dpu_enc->base; >>> } >>> >>> -int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc, >>> - enum msm_event_wait event) >>> +/** >>> + * dpu_encoder_wait_for_commit_done() - Wait for encoder to flush pending state >>> + * @drm_enc: encoder pointer >>> + * >>> + * Wait for hardware to have flushed the current pending frames to hardware at >>> + * a vblank or ctl_start Encoders will map this differently depending on the >>> + * panel type. >>> + * >> >> Missing a '.' between ctl_start and Encoder? > > Ack. Also I should drop the leftovers afterwards. > >> >>> + * MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to >>> + * the panel. Encoders will map this differently >>> + * depending on the panel type. >>> + * vid mode -> vsync_irq >>> + * cmd mode -> pp_done >>> + * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise >>> + */ >>> +int dpu_encoder_wait_for_commit_done(struct drm_encoder *drm_enc) >>> { >>> - int (*fn_wait)(struct dpu_encoder_phys *phys_enc) = NULL; >>> struct dpu_encoder_virt *dpu_enc = NULL; >>> int i, ret = 0; >>> >>> @@ -2419,23 +2432,46 @@ int dpu_encoder_wait_for_event(struct drm_encoder *drm_enc, >>> for (i = 0; i < dpu_enc->num_phys_encs; i++) { >>> struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; >>> >>> - switch (event) { >>> - case MSM_ENC_COMMIT_DONE: >>> - fn_wait = phys->ops.wait_for_commit_done; >>> - break; >>> - case MSM_ENC_TX_COMPLETE: >>> - fn_wait = phys->ops.wait_for_tx_complete; >>> - break; >>> - default: >>> - DPU_ERROR_ENC(dpu_enc, "unknown wait event %d\n", >>> - event); >>> - return -EINVAL; >>> + if (phys->ops.wait_for_commit_done) { >>> + DPU_ATRACE_BEGIN("wait_for_commit_done"); >>> + ret = phys->ops.wait_for_commit_done(phys); >>> + DPU_ATRACE_END("wait_for_commit_done"); >>> + if (ret) >>> + return ret; >>> } >>> + } >>> + >>> + return ret; >>> +} >>> + >>> +/** >>> + * dpu_encoder_wait_for_tx_complete() - Wait for encoder to transfer pixels to panel >>> + * @drm_enc: encoder pointer >>> + * >>> + * Wait for the hardware to transfer all the pixels to the panel. Encoders will >>> + * map this differently depending on the panel type. >>> + * >>> + * Return: 0 on success, -EWOULDBLOCK if already signaled, error otherwise >>> + */ >>> +int dpu_encoder_wait_for_tx_complete(struct drm_encoder *drm_enc) >>> +{ >>> + struct dpu_encoder_virt *dpu_enc = NULL; >>> + int i, ret = 0; >>> + >>> + if (!drm_enc) { >>> + DPU_ERROR("invalid encoder\n"); >>> + return -EINVAL; >>> + } >>> + dpu_enc = to_dpu_encoder_virt(drm_enc); >>> + DPU_DEBUG_ENC(dpu_enc, "\n"); >>> + >>> + for (i = 0; i < dpu_enc->num_phys_encs; i++) { >>> + struct dpu_encoder_phys *phys = dpu_enc->phys_encs[i]; >>> >>> - if (fn_wait) { >>> - DPU_ATRACE_BEGIN("wait_for_completion_event"); >>> - ret = fn_wait(phys); >>> - DPU_ATRACE_END("wait_for_completion_event"); >>> + if (phys->ops.wait_for_tx_complete) { >>> + DPU_ATRACE_BEGIN("wait_for_tx_complete"); >>> + ret = phys->ops.wait_for_tx_complete(phys); >>> + DPU_ATRACE_END("wait_for_tx_complete"); >>> if (ret) >>> return ret; >>> } >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h >>> index fe6b1d312a74..0c928d1876e4 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.h >>> @@ -93,25 +93,9 @@ void dpu_encoder_kickoff(struct drm_encoder *encoder); >>> */ >>> int dpu_encoder_vsync_time(struct drm_encoder *drm_enc, ktime_t *wakeup_time); >>> >>> -/** >>> - * dpu_encoder_wait_for_event - Waits for encoder events >>> - * @encoder: encoder pointer >>> - * @event: event to wait for >>> - * MSM_ENC_COMMIT_DONE - Wait for hardware to have flushed the current pending >>> - * frames to hardware at a vblank or ctl_start >>> - * Encoders will map this differently depending on the >>> - * panel type. >>> - * vid mode -> vsync_irq >>> - * cmd mode -> ctl_start >>> - * MSM_ENC_TX_COMPLETE - Wait for the hardware to transfer all the pixels to >>> - * the panel. Encoders will map this differently >>> - * depending on the panel type. >>> - * vid mode -> vsync_irq >>> - * cmd mode -> pp_done >>> - * Returns: 0 on success, -EWOULDBLOCK if already signaled, error otherwise >>> - */ >>> -int dpu_encoder_wait_for_event(struct drm_encoder *drm_encoder, >>> - enum msm_event_wait event); >>> +int dpu_encoder_wait_for_commit_done(struct drm_encoder *drm_encoder); >>> + >>> +int dpu_encoder_wait_for_tx_complete(struct drm_encoder *drm_encoder); >>> >>> /* >>> * dpu_encoder_get_intf_mode - get interface mode of the given encoder >>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> index d6412395bacc..26b5e54031d9 100644 >>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c >>> @@ -476,7 +476,7 @@ static void dpu_kms_wait_for_commit_done(struct msm_kms *kms, >>> * mode panels. This may be a no-op for command mode panels. >>> */ >>> trace_dpu_kms_wait_for_commit_done(DRMID(crtc)); >>> - ret = dpu_encoder_wait_for_event(encoder, MSM_ENC_COMMIT_DONE); >>> + ret = dpu_encoder_wait_for_commit_done(encoder); >>> if (ret && ret != -EWOULDBLOCK) { >>> DPU_ERROR("wait for commit done returned %d\n", ret); >>> break; >>> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h >>> index 762e13e2df74..91cf57f72321 100644 >>> --- a/drivers/gpu/drm/msm/msm_drv.h >>> +++ b/drivers/gpu/drm/msm/msm_drv.h >>> @@ -74,16 +74,6 @@ enum msm_dsi_controller { >>> #define MSM_GPU_MAX_RINGS 4 >>> #define MAX_H_TILES_PER_DISPLAY 2 >>> >>> -/** >>> - * enum msm_event_wait - type of HW events to wait for >>> - * @MSM_ENC_COMMIT_DONE - wait for the driver to flush the registers to HW >>> - * @MSM_ENC_TX_COMPLETE - wait for the HW to transfer the frame to panel >>> - */ >>> -enum msm_event_wait { >>> - MSM_ENC_COMMIT_DONE = 0, >>> - MSM_ENC_TX_COMPLETE, >>> -}; >>> - >>> /** >>> * struct msm_display_topology - defines a display topology pipeline >>> * @num_lm: number of layer mixers used >>> > > >