Received: by 2002:ab2:68c1:0:b0:1fd:9a81:d0e4 with SMTP id e1csp609526lqp; Sun, 9 Jun 2024 10:41:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXeljk6M5+iFQBARs6Y8RrfIA7G0md/iQPQ/0NWj6y8/YzR6ojdnL8M4FiudHk7cJPzAZA4uEuJvdjscOVSKVUlUX7miy1q9tzHchyFNg== X-Google-Smtp-Source: AGHT+IGYXaPHVY17dCfDjGg9pk7YBzZo5xzLxLyiIyELuUjFCeqF9cSWfw1VQxRHCQqAKUVCdHDN X-Received: by 2002:a17:903:230d:b0:1f7:187f:cb63 with SMTP id d9443c01a7336-1f7187fce09mr553645ad.47.1717954899532; Sun, 09 Jun 2024 10:41:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717954899; cv=pass; d=google.com; s=arc-20160816; b=ZFKi/0AG8D0G/fLg52zA1XFmsLAQraM0XWB6GDDu5YID9Z4kVwSd+8hPCYbdsq6YMS mB6cqIs3P0++eWL0Mli5zj0zTjJWVUoR4vIHYEsft244zy69LZzvSRRIXzkZ2TuYMNDl SW9mv3BhOHifTwMtYgBRPEJqMgDkyJ3l43UABvrKUvRHnWhKsFiS13pgfW6Q+9Xi1UnJ P1io0cgnFsnpONgFXh2ZQlwUhh20j0WxKEOVJKPpkeNtAsyu7CgDDJdi5eF29hAFcUVm XJDZ0RIl6R3begAFXqXD9XMLSsJ5//vltmsxrtzwZo1YoOERkbsCw+2Whwt82sFZDTsv kYYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=TU6uzy6Znj21ZkzrxgGT3l5nBGIbu+NflqZO4C9QeU8=; fh=DjPaqcoaWsOb+RU0F0AN194AArYUu9CrWzeBTdaGYFY=; b=qLio+osaS5cxLszUcPL/OBZJc1onaIHuWmnJ6k+IS0prdnTfDmo0DqIpDDpfKlWUF1 MInol0mpvu0wDQgaaqnSfNC/GRZkI5Y4aqMNFiVMcykwWIKMSAUsCrGMze80RciCuD1d xDj+ODARqzwADYCiSOKT4LjvenNQKMFJmJkh0nk8g6OfDjFz2XhfBq6AVtHZMjg9VvkZ ZEBx8uvoDwANwZQxp8ZY2XD0zolno+xsvh5QYvF/Kd8gT08bCo2RPDfzxq42w1MRDn0Z 860BE+cGp4L8XzoIttrGs00UR6EpcjTs2DrGikr/XMUJnPyYhsaDmCMigvZfJ6uu12Fa snSA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ABMxO1ut; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f6fbe0ea54si20046765ad.216.2024.06.09.10.41.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Jun 2024 10:41:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-207451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ABMxO1ut; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-207451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-207451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4ED91280F3F for ; Sun, 9 Jun 2024 17:41:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BDA774AEEF; Sun, 9 Jun 2024 17:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ABMxO1ut" Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (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 437A847A40 for ; Sun, 9 Jun 2024 17:41:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717954886; cv=none; b=TANHMY6ox2e4qSS3s2TlBvxHYUTyhmXOJIwKMOpNi9Z4QRUcM0uRrWQ3pu57EmvP0g83+NbnVyuhrEsrz87Wbmru3T0LKHVCiWuWSZ02ACqufylLnIdEHGIPC+Yhf0lRMfiVk7xTTrU6q/60Tx/XLV68sN/1vmSMOuMDU9BWBtk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717954886; c=relaxed/simple; bh=w3a7fvB29GfWdZ5y0r1ZUW3aa87+9cKwUWO2cYlJ3SM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=B0mBrbHjxzZEtyewClxQ+AgPM/CVD7V8zCF1tyoyBh5qVWNeSCPA45uCHOxcl144evg/tYwadToktTMXP55teQ2zLLUTmXQzdzp8jy2vlrSuziNAah1fTx7fIsGMv7osLgxEqeRE4EuiWUcrsjO3JNsPw5IPzlWPokrm3ep7uvQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ABMxO1ut; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2c2e31d319eso667561a91.1 for ; Sun, 09 Jun 2024 10:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717954884; x=1718559684; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=TU6uzy6Znj21ZkzrxgGT3l5nBGIbu+NflqZO4C9QeU8=; b=ABMxO1utuf0fjsqYZBR0INC2dNm73T7UdWl6pIq0E3jEI4JjTDItjVg4C+1fbEAJ0W CM9TcHU5bd8dAYxfn4NrvRu0Btp3dgwSIKx8B0sOQULk3O+pATmqKWmIeGU/XhcCzok8 WAFRqiqCSbtgnkwOUYNR1Kv0dR0RX7UmIeeUqFjZ7U2pD6GE6SNAlp0YchheIAh+adfb UKx027i/c1pFuEXs17D1/DLnO6rzMQ3DmFQ0CaLGzudhZ77BtvUV3JQNsEzbVp7Jc4IC uwYIeq8EhPLcKLArcF6iCRYvOS8Ii6383Pggx0EEVCqUKU+PDiYJTcuwSs5YgT3W3R6A kBPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717954884; x=1718559684; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TU6uzy6Znj21ZkzrxgGT3l5nBGIbu+NflqZO4C9QeU8=; b=KM6696nq9e7rx2/7PzFALhBoXJ0FjmemycvroL+KL9oQfhNzgEo9CWE/N19vxDKZ3s CS8y+wPFsf4VjYLWQWFEwhAaYbsWiKi9reU5qM4OBlqm0dwxh9VcRGiQewWcgh4P5pX8 bcBiyJRjZB9wMscwJ6WdxvqGiooXfRpwZc7ZDK4pfSydKIp3SyJCx4QeUJwvSL8Lg2qI 0ecNnXKYo+Ta9Zla7IbryL68W8OMEJdmtB6VaXVJKWyMhnDmQhyMG+K4tkTnv6WPkar9 vNZSKn83wfnPKaK2S4L6O3M7ai5qI98qutSWDR0o3yMDb/jdzP0pTCekGOG8qBKdP2Po 8UQQ== X-Forwarded-Encrypted: i=1; AJvYcCU/aSOHuEERsdOtbILp1IBiEGWdVKnc98cUao4vYzTsy+cHe4C6azrfxZoF8ybV/iz2OYjojvOAK17bLemyo7/tgMyddlwGl5uSyGiy X-Gm-Message-State: AOJu0YyB9C3IPj225AxJurDOYimqYWdyEBq/EXXEfR00AioEn2Juj24t 5UcPCL4nUrurfkVvTSBK9QDl2K2Wq7j/oBJMfLvrsGNL2gc2jGprtW/Dp8i+v5ZKVD7JwWNAEW0 Z1keSzYaBNNhhz8VyoD9Wd74OdZU= X-Received: by 2002:a17:90a:bf0a:b0:2c2:d732:3bc8 with SMTP id 98e67ed59e1d1-2c2d7323ef4mr3816893a91.21.1717954884398; Sun, 09 Jun 2024 10:41:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240601132459.81123-1-aford173@gmail.com> In-Reply-To: <20240601132459.81123-1-aford173@gmail.com> From: Adam Ford Date: Sun, 9 Jun 2024 12:41:13 -0500 Message-ID: Subject: Re: [PATCH V2] drm/bridge: adv7511: Fix Intermittent EDID failures To: dri-devel@lists.freedesktop.org Cc: dmitry.baryshkov@linaro.org, victor.liu@nxp.com, sui.jingfeng@linux.dev, aford@beaconembedded.com, Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Jun 1, 2024 at 8:25=E2=80=AFAM Adam Ford wrote= : > > In the process of adding support for shared IRQ pins, a scenario > was accidentally created where adv7511_irq_process returned > prematurely causing the EDID to fail randomly. > > Since the interrupt handler is broken up into two main helper functions, > update both of them to treat the helper functions as IRQ handlers. These > IRQ routines process their respective tasks as before, but if they > determine that actual work was done, mark the respective IRQ status > accordingly, and delay the check until everything has been processed. > > This should guarantee the helper functions don't return prematurely > while still returning proper values of either IRQ_HANDLED or IRQ_NONE. > > Reported-by: Liu Ying > Fixes: f3d9683346d6 ("drm/bridge: adv7511: Allow IRQ to share GPIO pins") > Signed-off-by: Adam Ford > Tested-by: Liu Ying # i.MX8MP EVK ADV7535 EDID retri= eval w/o IRQ Gentile nudge on this. It would be nice to get this fix applied since it caused a regression. adam > --- > V2: Fix uninitialized cec_status > Cut back a little on error handling to return either IRQ_NONE or > IRQ_HANDLED. > > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/b= ridge/adv7511/adv7511.h > index ea271f62b214..ec0b7f3d889c 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h > @@ -401,7 +401,7 @@ struct adv7511 { > > #ifdef CONFIG_DRM_I2C_ADV7511_CEC > int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511); > -void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1)= ; > +int adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1); > #else > static inline int adv7511_cec_init(struct device *dev, struct adv7511 *a= dv7511) > { > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c b/drivers/gpu/d= rm/bridge/adv7511/adv7511_cec.c > index 44451a9658a3..651fb1dde780 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_cec.c > @@ -119,7 +119,7 @@ static void adv7511_cec_rx(struct adv7511 *adv7511, i= nt rx_buf) > cec_received_msg(adv7511->cec_adap, &msg); > } > > -void adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) > +int adv7511_cec_irq_process(struct adv7511 *adv7511, unsigned int irq1) > { > unsigned int offset =3D adv7511->info->reg_cec_offset; > const u32 irq_tx_mask =3D ADV7511_INT1_CEC_TX_READY | > @@ -130,17 +130,21 @@ void adv7511_cec_irq_process(struct adv7511 *adv751= 1, unsigned int irq1) > ADV7511_INT1_CEC_RX_READY3; > unsigned int rx_status; > int rx_order[3] =3D { -1, -1, -1 }; > - int i; > + int i, ret =3D 0; > + int irq_status =3D IRQ_NONE; > > - if (irq1 & irq_tx_mask) > + if (irq1 & irq_tx_mask) { > adv_cec_tx_raw_status(adv7511, irq1); > + irq_status =3D IRQ_HANDLED; > + } > > if (!(irq1 & irq_rx_mask)) > - return; > + return irq_status; > > - if (regmap_read(adv7511->regmap_cec, > - ADV7511_REG_CEC_RX_STATUS + offset, &rx_status)) > - return; > + ret =3D regmap_read(adv7511->regmap_cec, > + ADV7511_REG_CEC_RX_STATUS + offset, &rx_status); > + if (ret < 0) > + return irq_status; > > /* > * ADV7511_REG_CEC_RX_STATUS[5:0] contains the reception order of= RX > @@ -172,6 +176,8 @@ void adv7511_cec_irq_process(struct adv7511 *adv7511,= unsigned int irq1) > > adv7511_cec_rx(adv7511, rx_buf); > } > + > + return IRQ_HANDLED; > } > > static int adv7511_cec_adap_enable(struct cec_adapter *adap, bool enable= ) > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/d= rm/bridge/adv7511/adv7511_drv.c > index 66ccb61e2a66..c8d2c4a157b2 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > @@ -469,6 +469,8 @@ static int adv7511_irq_process(struct adv7511 *adv751= 1, bool process_hpd) > { > unsigned int irq0, irq1; > int ret; > + int cec_status =3D IRQ_NONE; > + int irq_status =3D IRQ_NONE; > > ret =3D regmap_read(adv7511->regmap, ADV7511_REG_INT(0), &irq0); > if (ret < 0) > @@ -478,29 +480,31 @@ static int adv7511_irq_process(struct adv7511 *adv7= 511, bool process_hpd) > if (ret < 0) > return ret; > > - /* 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)) > - return -ENODATA; > - > regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0); > regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1); > > - if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.enc= oder) > + if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.enc= oder) { > schedule_work(&adv7511->hpd_work); > + irq_status =3D IRQ_HANDLED; > + } > > if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERR= OR) { > adv7511->edid_read =3D true; > > if (adv7511->i2c_main->irq) > wake_up_all(&adv7511->wq); > + irq_status =3D IRQ_HANDLED; > } > > #ifdef CONFIG_DRM_I2C_ADV7511_CEC > - adv7511_cec_irq_process(adv7511, irq1); > + cec_status =3D adv7511_cec_irq_process(adv7511, irq1); > #endif > > - return 0; > + /* If there is no IRQ to handle, exit indicating no IRQ data */ > + if (irq_status =3D=3D IRQ_HANDLED || cec_status =3D=3D IRQ_HANDLE= D) > + return IRQ_HANDLED; > + > + return IRQ_NONE; > } > > static irqreturn_t adv7511_irq_handler(int irq, void *devid) > @@ -509,7 +513,7 @@ static irqreturn_t adv7511_irq_handler(int irq, void = *devid) > int ret; > > ret =3D adv7511_irq_process(adv7511, true); > - return ret < 0 ? IRQ_NONE : IRQ_HANDLED; > + return ret < 0 ? IRQ_NONE : ret; > } > > /* ---------------------------------------------------------------------= -------- > -- > 2.43.0 >