Received: by 2002:a05:7412:7c14:b0:fa:6e18:a558 with SMTP id ii20csp444913rdb; Mon, 22 Jan 2024 08:56:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRpSA2CkoTEZBgEcO2BthJtWPRGbY2Y0F0ZHnogZAglq9+grIc0Kq5WCE9wcgonPhcv0Cf X-Received: by 2002:a05:6512:292:b0:50e:a431:de2e with SMTP id j18-20020a056512029200b0050ea431de2emr1614175lfp.138.1705942613252; Mon, 22 Jan 2024 08:56:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705942613; cv=pass; d=google.com; s=arc-20160816; b=jJ4CHVu6q72GvHf4EJ7p2Pnln2oNqp28Wyfa0x4sG0Zu3Zr4qS+FhnBhhMXK3c8xyc 4YjJjwKscsx3+i7HnbhMlXztF/R11QSQ7GTR52JNpMrwjJO9wqj9UVKkluPZSck3NQH/ gCrPSoi+KbEF3DvZW678lD1kSu5LA8yq4nLvwkiCOXvFSaoRgLoC6Jau5WEK/wg9MIzc tXeUkaOnf9dn9VP3nykHiHgrHWsgrhKgtMTQecy19myhniC+OHhP+OUXHmgIFhTH2kBu YRxhBeWQCnqZRlnRDPcsDeJVHK/fHErI+9M/KVAeVeaJHm4GKOl63fw3zpJv9IxdQeh4 3oMw== 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=a+MEiZR9/pSgeqhyl8Nx/9A64i9fTGmtMbjtt+LDsVs=; fh=ynRNIT604usYvH4ObHEsGAHT5Aa2SneWRwAK5eqdxBU=; b=igahSnAvwWrH56m3WQ9GLgyPCkhA5cx85YN+o9v0Rgr/bsS1kGaX0xcsuaMftO2qrY f0XMbOj+9UzdeK6K4ESiqxsVJbs8jq6u0GVMYlKmU1yyfvTE7PC59AHvAUeHuKdozMYJ QZPG6iQWGBmlFeIhZp91dTAKbKmGUmMKi85uKc0OBqJxS1qjichLoJqQHp4KN6Erk6WW +2jteq0hvYxF/S/qC1u2O7+5spbmPITVRelDrCYzmX83iERRqTWelQytn3lKjUqNXPQi CGJR1jS8MzYbPkFu0E/LuDJNVJy9vknMi8ziSnES6FyuxVH2p3OO9cq2uPHjcHyfgFT8 xsZg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=C+MnRZ6k; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k19-20020a1709067ad300b00a2d920284absi7914497ejo.1024.2024.01.22.08.56.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 08:56:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-33600-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=@kernel.org header.s=k20201202 header.b=C+MnRZ6k; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-33600-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-33600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.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 am.mirrors.kernel.org (Postfix) with ESMTPS id CD6DF1F26085 for ; Mon, 22 Jan 2024 16:56:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B54DD4652B; Mon, 22 Jan 2024 15:29:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C+MnRZ6k" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 CB7D04644A for ; Mon, 22 Jan 2024 15:29:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705937383; cv=none; b=ZEpTKAJewx9s1zacDbS0txxz0as30LUaL4g6+xM7QBYDTpQLtGP9aRtYSU0pb1qsZy4/i0cTl88ouVRRG1O2qxiMTckvvu7AFj4QgdFzfLMSGQErnLCY55orfUNL1BsbeW8djeI5x7M9gB+u6zO2va0j1u5NlN6Xz8ynimRGAtw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705937383; c=relaxed/simple; bh=iO8t2uvf8zKn2pqUIDEeeUGE84Y6SbECB0tNbeiWYzM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=qySJQwaDBrg2OQeH7DeDOFaa22fd3vY0s70Itr+dCRI0HqvxenZ8MTK4HpC0gW0USZiG+qSMHWIzd/R4QCi8KOMCdVG/wVkNQDqvdD8vcLiv62xJ53A1KL5zwhBgpk+G6kszFmaB9MfsFolzu4ULEknEsjtbF6YWjFowscz4vsQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C+MnRZ6k; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D23DC43394 for ; Mon, 22 Jan 2024 15:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705937383; bh=iO8t2uvf8zKn2pqUIDEeeUGE84Y6SbECB0tNbeiWYzM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=C+MnRZ6kGvr+BXdFvyVitkA9XOIvtUbvwNce6ihU2x7vntqpIlXbY+OGnlqAJ8yUa U3hU197FCZSGcGg18ABnbM1rzlMx8mIuflY5F2Rq78Lt0+0ejtx3GlA6WGll1wjHy2 1Ejaoo0pC6Q52OoMEdCaq/0MgAs7NW/VUiP6KmdUrk7QBd/M7ZFh6E4n8M5kzS0mgV VSzl3NUyxPL3kKH0RLieipsM9wc7LG9DcDW2wIGzEy1eAMrLWM4hyxhSguX8ol/dCv Vm7RzDVAGghigNHngtiPHjPnTuXSauoRk26ZaFZhJHDoUTIV/DxZCv8aA+V/ieQ+Wa KfqtLIGLUdxOg== Received: by mail-yb1-f174.google.com with SMTP id 3f1490d57ef6-dc261316b0dso2336639276.3 for ; Mon, 22 Jan 2024 07:29:43 -0800 (PST) X-Gm-Message-State: AOJu0YyXvVC/vAz7XAx7OE47Xto8wwVpsa0YgwbUXl3b62l8iYrkehnd 5kNQvUrdbWvFmz4KPx+BmpJN7+x/QjdSj4KBN/kugEVwEoF7IDdnuq/X5wzwaptZqaYkduOFHLU lej2HzHq6yQqhkMFX3fFaQWyy0F/MaK0VEWqy6Q== X-Received: by 2002:a25:d0cf:0:b0:dc2:2b05:4ab1 with SMTP id h198-20020a25d0cf000000b00dc22b054ab1mr2175479ybg.18.1705937382611; Mon, 22 Jan 2024 07:29:42 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231124-adv7511-cec-edid-v2-0-f0e5eeafdfc2@bang-olufsen.dk> <20231124-adv7511-cec-edid-v2-2-f0e5eeafdfc2@bang-olufsen.dk> In-Reply-To: <20231124-adv7511-cec-edid-v2-2-f0e5eeafdfc2@bang-olufsen.dk> From: Robert Foss Date: Mon, 22 Jan 2024 16:29:31 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] drm/bridge: adv7511: get edid in hpd_work to update CEC phys address To: =?UTF-8?Q?Alvin_=C5=A0ipraga?= Cc: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Hans Verkuil , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, =?UTF-8?Q?Alvin_=C5=A0ipraga?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Nov 24, 2023 at 4:20=E2=80=AFPM Alvin =C5=A0ipraga = wrote: > > From: Alvin =C5=A0ipraga > > The adv7511 driver is solely responsible for setting the physical > address of its CEC adapter. To do this, it must read the EDID. However, > EDID is only read when either the drm_bridge_funcs :: get_edid or > drm_connector_helper_funcs :: get_modes ops are called. Without loss of > generality, it cannot be assumed that these ops are called when a sink > gets attached. Therefore there exist scenarios in which the CEC physical > address will be invalid (f.f.f.f), rendering the CEC adapter inoperable. > > Address this problem by always fetching the EDID in the HPD work when we > detect a connection. The CEC physical address is set in the process. > This is done by moving the EDID DRM helper into an internal helper > function so that it can be cleanly called from an earlier section of > the code. The EDID getter has not changed in practice. > > Signed-off-by: Alvin =C5=A0ipraga > --- > drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 74 ++++++++++++++++++----= ------ > 1 file changed, 48 insertions(+), 26 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/d= rm/bridge/adv7511/adv7511_drv.c > index 5ffc5904bd59..1f1d3a440895 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > @@ -542,6 +542,36 @@ static int adv7511_get_edid_block(void *data, u8 *bu= f, unsigned int block, > return 0; > } > > +static struct edid *__adv7511_get_edid(struct adv7511 *adv7511, > + struct drm_connector *connector) > +{ > + struct edid *edid; > + > + /* Reading the EDID only works if the device is powered */ > + if (!adv7511->powered) { > + unsigned int edid_i2c_addr =3D > + (adv7511->i2c_edid->addr << 1); > + > + __adv7511_power_on(adv7511); > + > + /* Reset the EDID_I2C_ADDR register as it might be cleare= d */ > + regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, > + edid_i2c_addr); > + } > + > + edid =3D drm_do_get_edid(connector, adv7511_get_edid_block, adv75= 11); > + > + if (!adv7511->powered) > + __adv7511_power_off(adv7511); > + > + adv7511_set_config_csc(adv7511, connector, adv7511->rgb, > + drm_detect_hdmi_monitor(edid)); > + > + cec_s_phys_addr_from_edid(adv7511->cec_adap, edid); > + > + return edid; > +} > + > /* ---------------------------------------------------------------------= -------- > * Hotplug handling > */ > @@ -595,8 +625,24 @@ static void adv7511_hpd_work(struct work_struct *wor= k) > adv7511->connector.status =3D status; > > if (adv7511->connector.dev) { > - if (status =3D=3D connector_status_disconnected) > + if (status =3D=3D connector_status_disconnected) = { > cec_phys_addr_invalidate(adv7511->cec_ada= p); > + } else { > + struct edid *edid; > + > + /* > + * Get the updated EDID so that the CEC > + * subsystem gets informed of any change = in CEC > + * address. The helper returns a newly al= located > + * edid structure, so free it to prevent > + * leakage. > + */ > + edid =3D __adv7511_get_edid(adv7511, > + &adv7511->conne= ctor); > + if (edid) > + kfree(edid); kfree(NULL) is safe, so the if statement can be removed. With this fixed, feel free to add my r-b to this full series. Reviewed-by: Robert Foss