Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp304213rwb; Wed, 14 Dec 2022 17:45:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4nFX+BTmc9liOYp7djejvBbivviQO+/k58yTBFofzp8UzFO8CixntdSBDhx1C9YUxPxU9m X-Received: by 2002:aa7:c6c9:0:b0:46b:a28a:8783 with SMTP id b9-20020aa7c6c9000000b0046ba28a8783mr22037107eds.38.1671068748828; Wed, 14 Dec 2022 17:45:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671068748; cv=none; d=google.com; s=arc-20160816; b=RytHsVLp+ZNs471j7jI5zbOqpiw2jM2S4UFMmglF8p6e3dWs/Mety/VvZdpP6d7pTt V/c2Sv5eZWcM/aPBaM4OR29b5tLUG/3+Lsu11FetvWsXi/c9vaw1VPb+VraI2air85JV kqUk5E9w6Ld/gp0xBechEmBpk8cBhDix1mlZMXDQB0mbW0OG0yfNfghnVtpEQQ/8cK0p ASO5G/CWaoeaU/Z+yAlu9bZhv58SQuqq6/V1IM0RiNaBInXa9xuc+FuYZ4mzkWTscztF HLfzj07cQjOib4dWQYAWX2NDgdrcIzRgRi4OQJW7eqYfTNFn2m3X1YyCHcqHfz2aLXpw 0zxw== 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=HS8L6PaXpcf1aCZXEFRozeT8JM2ZY+VhUFTjBJUxlqo=; b=Yik3lDCwvIP2uCmOyYZJPcf0sD57fCP4OqZZ/bEwABGs3JrMOk5qRUjQKHdQiXG9kM E92p/4dKqpCb5vJfF24W15PjoyvgVzWPf8thdrkILxMlgI8CupacPrfrpsCYrX2Lz7j3 XCFW6+iq8KmaR3IlLBX8HsKrjITBPF9oyfT9MI4KfgBkRPL/lQGn4TcA3YAMPO6/Zgen hsxcAdA8t/BROykCwnW7PPLVbYB4R2vMShLpruqx1LQBNMzv2oYOy1P8F6NDUqAVlsrr Vje29x6dFeCSBMdrye1aWz+zQuUbKRQcu8MhiM2roUtgcy2SDuFk5c6Yz6XzxXZPPF2N tZeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=lmjTifD9; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n17-20020a056402061100b0043dc00e0740si12227872edv.373.2022.12.14.17.45.28; Wed, 14 Dec 2022 17:45:48 -0800 (PST) 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=@quicinc.com header.s=qcppdkim1 header.b=lmjTifD9; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229988AbiLOAiA (ORCPT + 69 others); Wed, 14 Dec 2022 19:38:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229745AbiLOAh7 (ORCPT ); Wed, 14 Dec 2022 19:37:59 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50038396D4; Wed, 14 Dec 2022 16:37:57 -0800 (PST) Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BENC6fR008489; Thu, 15 Dec 2022 00:37:52 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=HS8L6PaXpcf1aCZXEFRozeT8JM2ZY+VhUFTjBJUxlqo=; b=lmjTifD9tM60CR3Qu/++MrkIaDWxdgZjkDN/qz+8gkRtWGTMUHa2cUU3QpiEkvq58/ZA 1MNKyKHctXBcM+BlFpBj3O7ihJuO/V/S25CNptZnSnGtVIDofoX9MKIo8vBkltSo2zhC eBQiTtyjI4ZX4mI4/q51Gy36268VY769tioQaLgxAxkBEpgwfpsHK70kaOJm3M9sHtJe pMr7HQze1NtUSiGnI5Dd+XO2FxHkhf7zxSqNNIYyBmQhQs+lsF5foo4TciQ5Pdg4ktO6 JV50HRM1w/myTMMlbprCw6pT2UoXyPrPXeRuCLPWZ5m0sUdyYOxyiGAca47wJfg3KPC1 uA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3mf6rctqwe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 00:37:51 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 2BF0bot4003206 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 15 Dec 2022 00:37:50 GMT Received: from [10.111.161.145] (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.986.36; Wed, 14 Dec 2022 16:37:47 -0800 Message-ID: Date: Wed, 14 Dec 2022 16:37:44 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [Freedreno] [PATCH] drm/msm/dp: do not complete dp_aux_cmd_fifo_tx() if irq is not for aux transfer Content-Language: en-US To: Doug Anderson CC: , , , , , , , , , , , , Kuogee Hsieh , , References: <1671052890-11627-1-git-send-email-quic_khsieh@quicinc.com> <512f9f0d-a399-27fb-08d0-7311b73fd2a1@quicinc.com> From: Abhinav Kumar In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] 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: Je88X_7I5gmqy39_wNgUTdzitZmW8euF X-Proofpoint-ORIG-GUID: Je88X_7I5gmqy39_wNgUTdzitZmW8euF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-14_12,2022-12-14_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 phishscore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 clxscore=1015 impostorscore=0 malwarescore=0 spamscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2212150002 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS 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 Hi Doug On 12/14/2022 4:14 PM, Doug Anderson wrote: > Hi, > > On Wed, Dec 14, 2022 at 3:46 PM Abhinav Kumar wrote: >> >> Hi Doug >> >> On 12/14/2022 2:29 PM, Doug Anderson wrote: >>> Hi, >>> >>> On Wed, Dec 14, 2022 at 1:21 PM Kuogee Hsieh wrote: >>>> >>>> There are 3 possible interrupt sources are handled by DP controller, >>>> HPDstatus, Controller state changes and Aux read/write transaction. >>>> At every irq, DP controller have to check isr status of every interrupt >>>> sources and service the interrupt if its isr status bits shows interrupts >>>> are pending. There is potential race condition may happen at current aux >>>> isr handler implementation since it is always complete dp_aux_cmd_fifo_tx() >>>> even irq is not for aux read or write transaction. This may cause aux read >>>> transaction return premature if host aux data read is in the middle of >>>> waiting for sink to complete transferring data to host while irq happen. >>>> This will cause host's receiving buffer contains unexpected data. This >>>> patch fixes this problem by checking aux isr and return immediately at >>>> aux isr handler if there are no any isr status bits set. >>>> >>>> Follows are the signature at kernel logs when problem happen, >>>> EDID has corrupt header >>>> panel-simple-dp-aux aux-aea0000.edp: Couldn't identify panel via EDID >>>> panel-simple-dp-aux aux-aea0000.edp: error -EIO: Couldn't detect panel nor find a fallback >>>> >>>> Signed-off-by: Kuogee Hsieh >>>> --- >>>> drivers/gpu/drm/msm/dp/dp_aux.c | 7 +++++++ >>>> 1 file changed, 7 insertions(+) >>>> >>>> diff --git a/drivers/gpu/drm/msm/dp/dp_aux.c b/drivers/gpu/drm/msm/dp/dp_aux.c >>>> index d030a93..8f8b12a 100644 >>>> --- a/drivers/gpu/drm/msm/dp/dp_aux.c >>>> +++ b/drivers/gpu/drm/msm/dp/dp_aux.c >>>> @@ -423,6 +423,13 @@ void dp_aux_isr(struct drm_dp_aux *dp_aux) >>>> >>>> isr = dp_catalog_aux_get_irq(aux->catalog); >>>> >>>> + /* >>>> + * if this irq is not for aux transfer, >>>> + * then return immediately >>>> + */ >>> >>> Why do you need 4 lines for a comment that fits on one line? >> Yes, we can fit this to one line. >>> >>>> + if (!isr) >>>> + return; >>> >>> I can confirm that this works for me. I could reproduce the EDID >>> problems in the past and I can't after this patch. ...so I could give >>> a: >>> >>> Tested-by: Douglas Anderson >>> >>> I'm not an expert on this part of the code, so feel free to ignore my >>> other comments if everyone else thinks this patch is fine as-is, but >>> to me something here feels a little fragile. It feels a little weird >>> that we'll "complete" for _any_ interrupt that comes through now >>> rather than relying on dp_aux_native_handler() / dp_aux_i2c_handler() >>> to specifically identify interrupts that caused the end of the >>> transfer. I guess that idea is that every possible interrupt we get >>> causes the end of the transfer? >>> >>> -Doug >> >> So this turned out to be more tricky and was a good finding from kuogee. >> >> In the bad EDID case, it was technically not bad EDID. >> >> What was happening was, the VIDEO_READY interrupt was continuously >> firing. Ideally, this should fire only once but due to some error >> condition it kept firing. We dont exactly know why yet what was the >> error condition making it continuously fire. >> >> In the DP ISR, the dp_aux_isr() gets called even if it was not an aux >> interrupt which fired (so the call flow in this case was >> dp_display_irq_handler (triggered for VIDEO_READY) ---> dp_aux_isr() >> So we should certainly have some protection to return early from this >> routine if there was no aux interrupt which fired. >> >> Which is what this fix is doing. >> >> Its not completing any interrupt, its just returning early if no aux >> interrupt fired. > > ...but the whole problem was that it was doing the complete() at the > end, right? Kuogee even mentioned that in the commit message. > Specifically, I checked dp_aux_native_handler() and > dp_aux_i2c_handler(), both of which are passed the "isr". Unless I > messed up, both functions already were no-ops if the ISR was 0, even > before Kuogee's patch. That means that the only thing Kuogee's patch > does is to prevent the call to "complete(&aux->comp)" at the end of > "dp_aux_isr()". > > ...and it makes sense not to call the complete() if no "isr" is 0. > ...but what I'm saying is that _any_ non-zero value of ISR will still > cause the complete() to be called after Kuogee's patch. That means > that if any of the 32-bits in the "isr" variable are set, that we will > call complete(). I'm asking if you're sure that every single bit of > the "isr" means that we're ready to call complete(). It feels like it > would be less fragile if dp_aux_native_handler() and > dp_aux_i2c_handler() (which both already look at the ISR) returned > some value saying whether the "isr" contained a bit that meant that > complete() should be called. > Yes, so other than the "transfer done" bits, the other bits we listen to are below: 29 #define DP_INTERRUPT_STATUS1 \ 30 (DP_INTR_AUX_I2C_DONE| \ 31 DP_INTR_WRONG_ADDR | DP_INTR_TIMEOUT | \ 32 DP_INTR_NACK_DEFER | DP_INTR_WRONG_DATA_CNT | \ 33 DP_INTR_I2C_NACK | DP_INTR_I2C_DEFER | \ 34 DP_INTR_PLL_UNLOCKED | DP_INTR_AUX_ERROR All of these, if they fire, will be handled in dp_aux_i2c_handler() and the aux_error_num will be assigned. And only if aux_error_num is DP_AUX_ERR_NONE, we go further and read the data from the fifo. So we should complete even if there is any bit set as they are error bits which will need to be handled. > -Doug