Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2712399lqo; Mon, 20 May 2024 14:17:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU9FZW6LQUsHs09kppqj4x0belSQjysuCT5pZRk9OwMQ2a+0QbjNWlCcBJKQjiZMrVm85xfn1oO0HqkvUvS0TIdLzQffe1UQJ00XHn7ZA== X-Google-Smtp-Source: AGHT+IGlsCVvteXZQXRjBzrUeOWXxBRUhUOtLpPsnl9WYooBq3Uy3v9xpcYsQC5+vlviQKNS9uqQ X-Received: by 2002:a17:902:e892:b0:1f2:fca9:731c with SMTP id d9443c01a7336-1f2fca978fdmr52293935ad.8.1716239841626; Mon, 20 May 2024 14:17:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716239841; cv=pass; d=google.com; s=arc-20160816; b=Jp4UmzGLlQrFDVC5hghcLos1rCVlycnqAhxd5QXKF2TsYpTOti1bp2fG2qo315wlMC AbiayX3uF/tBowMxWEoq6jaEnG6LTinx4A716v/HqFVL8P94g18pVP9wgiVgT/hmAuK7 R1wdvqMCnCCpD2Xc/Ytitmpwa1cOf0Ern7dMMcB3FbG0O06wSl+UHPqrpMesYpFTVrBY 8D7XQvPJhKOfHatB73aad2Vu7/UEuGAAN5+SDjOARY57kFg7lVZNG+pRdAFzH5m05Rrw +ZcN+C+hXejXnr6hVGA9OfuhszkDJS4gs/SieknqRjAq9Dl3jscoqgY0njZTDjmcP+sp 46CA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VG+wyOOGGLfw+B2ijipUditBjceEdzKS6/pyMdE87yA=; fh=CUhn00OP6vvg3TPuqz02AAgRqE+8z5m9/vB/pWTx4gw=; b=vXTtbDPCztT9CwoBos5Taku/MVuiqf3E5J7znmVOO/Z/dVk9nxMids58H73xyYgm7w 02yYr71bpJ6Z55Lao45PWUFWdJIkFiHdBFfeCeqlLHxf4yClZJ5R8ztAvLrdJA443h4y 9gGyNrncYIRsAWN39+FMYqXeZjy+Ot30eGtUBoSnIRm4tOq2Grxip43Vs1NmEPRknW/5 xWAK5Rlsm/koBye1jWW2CRrQUQn2++QOwUITDUDH9n2N4IU77H+GXIk+jP4HkwPFYV/0 jecfJBV2tjwK5ykwnakH+4vmJKBl5yYfp7um4YrDWltnX0a1cPkftMNhGvixFma9KWMG RN1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oU5NziKq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-184191-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0b1aeb51si37944705ad.0.2024.05.20.14.17.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 14:17:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184191-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oU5NziKq; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-184191-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184191-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7B1D1B21BD7 for ; Mon, 20 May 2024 21:17:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C235D13A257; Mon, 20 May 2024 21:16:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oU5NziKq" Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97FDE139D01 for ; Mon, 20 May 2024 21:16:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716239809; cv=none; b=J9bKmNnj3NVRk4hg4rR8k/DfzWhEtu52Mr8ywU56m6Nmnom75UzUMlz47ZNqb7C2m0L5xR0XrEc6ASICXGn1mLxJ/hrkuqGQg5tC9uzcOXAB4UNq3FrPJddDpDJatp1UPMBCFbwNyk6Z3xPqNfd9KDWoZ5cqYkzA+DQ8MWXcb2g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716239809; c=relaxed/simple; bh=Q69knQy5aWtyMV52TDeQIu0cu45JjhpKnFX3Ul/xAnc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pr2y1M+zGtCH6zS4/NXFBkb5H40iwpoiU6VtDkjioVAm2LxqNl93dgjqXuOsmGc2oPcYeAloTxkbdAAJh0U28F9yDJ7uEqSYg9BFNgMIvVHvQf8fUB/DWjYyEw/wVkxND4WDr2XxeCLfbvWxJygyKqjn+TVai/FpM/OHefMQ+rs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oU5NziKq; arc=none smtp.client-ip=209.85.208.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e538a264e0so60821591fa.1 for ; Mon, 20 May 2024 14:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1716239806; x=1716844606; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=VG+wyOOGGLfw+B2ijipUditBjceEdzKS6/pyMdE87yA=; b=oU5NziKq394lPsS2aP1UcgR/CS2KhCHt4fB73JwhRiLIO/V5UwZpncEX97Wx+gEGXW 6xc6PpDGg68WKfwdF9X/QPfI0cPV15k0Ft4/TrQOIES6ggbYhMgQxPviJQGfYcUgwLpq t+JVcaIL/Tkg1fAX8QyrjPOHSkXNSbo/7vym1iOIf7mO/2mmB/JdXOYJPbNMSDLVqbVl RZUbUwkdFQhXANZqzfN/UiudCiDZ18hhVzFdupt3WR+m1CZIPrfT8QfpoJdcE3QTfS5F V7ADDAeGsS6Gw3FEmCK22KLAydohaQe/0/7SOoTn76biwW86nTDOxWDV2MIEYBYUjx7b dXkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716239806; x=1716844606; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=VG+wyOOGGLfw+B2ijipUditBjceEdzKS6/pyMdE87yA=; b=NB6MZD+eyjCOzW0Ual4OEYI+QOXXvNkujjHbpE6YZ60i2dhIpY2qTyrjXbMnBKXT2/ Txiq3fQUQec3XmTcBUCbQJzSxzWHyKFz0cFHgLNdDEqmO52Fnr1Tgf+bHakWVSW8Xe8l msVvf9GokhDfZaFD5vxx2YMisEdIsfxDYtTb+PiO84NDbacFOYn2cjIRLbZTJLWJ1IRt e8qxHB0V6eMRrprfRFy5xf+iQjfVMlD6glyUxL0QJH14W6pV1hp3FSraRcE909WJktxC Itd2eSOgLX6ZKneJLk8U3RU0hD39DDimRQnRJvvvGS5qV/c0qD3jikjHJChxe9WoV3Bv hl/g== X-Forwarded-Encrypted: i=1; AJvYcCW9LKydEKtGzcV3R41Ryjlj9HmzgQSwQopCITAvdlkfn/wXnhm2a9i9uReKwRu9a8xiSCDdylxy6T0vk8TgdbCRKoesUYFe97RXNtyx X-Gm-Message-State: AOJu0YwxuBrX/SB6bKo7RfLALdSj3cwgqat+J7EOzmwSbbgdTmtfRWOd 7gqh7+JEv1MTu6v+HnzAkIlMEpqbEWMAwBvenFi1InduVvoibDQgp6F33GCFGJw= X-Received: by 2002:a2e:a40f:0:b0:2e4:a21a:bf7d with SMTP id 38308e7fff4ca-2e51ff5234cmr312792631fa.21.1716239805722; Mon, 20 May 2024 14:16:45 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzdbxzyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a0c3:3a00::227]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e4d0ce2733sm34965821fa.31.2024.05.20.14.16.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 14:16:45 -0700 (PDT) Date: Tue, 21 May 2024 00:16:43 +0300 From: Dmitry Baryshkov To: Adam Ford Cc: Sui Jingfeng , Liu Ying , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, andrzej.hajda@intel.com, neil.armstrong@linaro.org, rfoss@kernel.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, biju.das.jz@bp.renesas.com, u.kleine-koenig@pengutronix.de, jani.nikula@intel.com, bli@bang-olufsen.dk Subject: Re: [PATCH] drm/bridge: adv7511: Exit interrupt handling when necessary Message-ID: References: <20240516101006.2388767-1-victor.liu@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, May 20, 2024 at 07:46:05AM -0500, Adam Ford wrote: > On Mon, May 20, 2024 at 7:00 AM Dmitry Baryshkov > wrote: > > > > On Mon, 20 May 2024 at 14:48, Sui Jingfeng wrote: > > > > > > Hi, > > > > > > > > > On 5/20/24 19:13, Dmitry Baryshkov wrote: > > > > On Mon, 20 May 2024 at 14:11, Sui Jingfeng wrote: > > > >> > > > >> Hi, > > > >> > > > >> On 5/20/24 06:11, Dmitry Baryshkov wrote: > > > >>> On Thu, May 16, 2024 at 06:10:06PM +0800, Liu Ying wrote: > > > >>>> Commit f3d9683346d6 ("drm/bridge: adv7511: Allow IRQ to share GPIO pins") > > > >>>> fails to consider the case where adv7511->i2c_main->irq is zero, i.e., > > > >>>> no interrupt requested at all. > > > >>>> > > > >>>> Without interrupt, adv7511_wait_for_edid() could return -EIO sometimes, > > > >>>> because it polls adv7511->edid_read flag by calling adv7511_irq_process() > > > >>>> a few times, but adv7511_irq_process() happens to refuse to handle > > > >>>> interrupt by returning -ENODATA. Hence, EDID retrieval fails randomly. > > Sorry about that. I did some testing and didn't see any regressions, > but if it was random, it's likely I just was lucky to not see it. > > > > >>>> > > > >>>> Fix the issue by checking adv7511->i2c_main->irq before exiting interrupt > > > >>>> handling from adv7511_irq_process(). > > > >>>> > > > >>>> Fixes: f3d9683346d6 ("drm/bridge: adv7511: Allow IRQ to share GPIO pins") > > > >>>> Signed-off-by: Liu Ying > > > >>>> --- > > > >>>> drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 3 ++- > > > >>>> 1 file changed, 2 insertions(+), 1 deletion(-) > > > >>>> > > > >>>> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > > >>>> index 6089b0bb9321..2074fa3c1b7b 100644 > > > >>>> --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > > >>>> +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > > >>>> @@ -479,7 +479,8 @@ static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd) > > > >>>> return ret; > > > >>>> > > > >>>> /* If there is no IRQ to handle, exit indicating no IRQ data */ > > > >>>> - if (!(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) && > > > >>>> + if (adv7511->i2c_main->irq && > > > >>>> + !(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) && > > > >>>> !(irq1 & ADV7511_INT1_DDC_ERROR)) > > > >>>> return -ENODATA; > > > >>> > > > >>> I think it might be better to handle -ENODATA in adv7511_wait_for_edid() > > > >>> instead. WDYT? > > > >>> > > > >> > > > >> I think this is may deserve another patch. > > > > > > > > My point is that the IRQ handler is fine to remove -ENODATA here, > > > > > > [...] > > > > > > > there is no pending IRQ that can be handled. > > > > > > But there may has other things need to do in the adv7511_irq_process() > > > function. > > > > But the function returns anyway. So, we know that the condition is broken. > > When I originally submitted the patch, I only added the shared IRQ > flag without any IRQ condition checks, IRQ because I didn't want to > break anything. The feedback I got was to check to see if the IRQ was > intended by the device. My focus was the adv7511_drv.c file because > that appears to be what the registered IRQ hander was, but after > looking through adv7511_cec, I see that adv7511_cec_irq_process checks > adv_cec_tx_raw_status and returns if there is nothing to do. > > Would it make sense to move the if statement did the following things: > > - Make adv7511_cec_irq_process return an int and modify it to return > 0 in normal operation or return -ENODATA where there is nothing to do. > It already has the checks in place to determine if there is work to > do, so the impact here should be minimal. > > - Move the check I added on whether or not there is an interrupt to > the very end of adv7511_irq_process just before the return 0. > > - Instead of blindly returning 0, modify the if statement to read the > state of the return code of adv7511_cec_irq_process and the IRQ flags > it already checks. If ADV7511_INT0_HPD, ADV7511_INT0_EDID_READY and > ADV7511_INT1_DDC_ERROR are all not true and adv7511_cec_irq_process > returned early, return ENODATA, but if any of the interrupts was > present and adv7511_cec_irq_process did work, it would return 0. > > I think that would cover the situation where adv7511_cec_irq_process > would get called, and also prevent a false return of the IRQ being > handled when this part didn't handle anything. > > It would look something like: > > cec_irq = adv7511_cec_irq_process(adv7511, irq1); > > /* If there is no IRQ to handle, exit indicating no IRQ data */) > if (!(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) && > !(irq1 & ADV7511_INT1_DDC_ERROR) && > cec_irq == -ENODATA) > return -ENODATA; > else > return 0 > > > OR... > > > Another alternative to all this is to modify the check that I added to > verify all the following flags which are currently checked in > adv7511_cec_irq_process : > > ADV7511_INT1_CEC_TX_READY > ADV7511_INT1_CEC_TX_ARBIT_LOST > ADV7511_INT1_CEC_TX_RETRY_TIMEOUT > ADV7511_INT1_CEC_RX_READY1 > ADV7511_INT1_CEC_RX_READY2 > ADV7511_INT1_CEC_RX_READY3 > > It would look something like: > > /* If there is no IRQ to handle, exit indicating no IRQ data */ > if (!(irq0 & (ADV7511_INT0_HPD | ADV7511_INT0_EDID_READY)) && > !(irq1 & ADV7511_INT1_DDC_ERROR) && > !(irq1 & ADV7511_INT1_CEC_TX_READY) && > !(irq1 & ADV7511_INT1_CEC_TX_ARBIT_LOST) && > !(irq1 & ADV7511_INT1_CEC_TX_RETRY_TIMEOUT) && > !(irq1 & ADV7511_INT1_CEC_RX_READY1) && > !(irq1 & ADV7511_INT1_CEC_RX_READY2) && > !(irq1 & ADV7511_INT1_CEC_RX_READY3)) > return -ENODATA; This definitely looks ugly. At least it should be a mask. I have a slightly different solution: Make adv7511_irq_process return <0 for error, IRQ_NONE or IRQ_HANDLED. This would also require tracking whether HPD, EDID or CEC processing actually took place (add temp var for the current 'handled' status, make adv7511_cec_irq_process() return IRQ_HANDLED too). > > > Please let me know what is preferred or if there is a third possible solution. > > I can write up a patch with a fixes tag later today when I get back to > my build machine. > > adam > > > > > > > > > So instead of continuing > > > > the execution when we know that IRQ bits are not set, > > > > > > Even when IRQ bits are not set, it just means that there is no HPD > > > and no EDID ready-to-read signal. HDMI CEC interrupts still need > > > to process. > > > > Yes. Let's get the CEC fixed. Then maybe we won't need this commit at all. > > > > > > > > > > > > it's better to > > > > ignore -ENODATA in the calling code and go on with msleep(). > > > > > > > > > > So, It's confusing to ignore the -ENODATA here. > > > > [BTW: you had quotation levels wrong in two places, I've fixed them] > > > > -- > > With best wishes > > Dmitry -- With best wishes Dmitry