Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp515461lqs; Tue, 5 Mar 2024 08:19:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU9ni7wRPoCi9/SLVpRLf9g4V2Uc7FtTDVCHfCLmnke69s1jMN2G0M1zvp69hGZTtJZdMQ7UIi3IYSx1ymkxb/N3KpSVn8rI5Nri4Q9yA== X-Google-Smtp-Source: AGHT+IHDx6X1C45l/IaZZLyM2XdUYOLN/5JN6w3DlJ2DsrdqTYiF84l1LubpHDdw5TlM9FZEkZTG X-Received: by 2002:a17:906:5a9a:b0:a3e:5ffa:d564 with SMTP id l26-20020a1709065a9a00b00a3e5ffad564mr7682144ejq.8.1709655548124; Tue, 05 Mar 2024 08:19:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709655548; cv=pass; d=google.com; s=arc-20160816; b=V3UShXit9rX/P0hbVpCvbXHPWQqSB+1R48252dh6jU+tmkWzPiS1MOHS9UtBGvHlGl f9yQYi0T4YCi1XV4zDZlJWi6J3KGIyGmewLoXkmjHa68NsJ+kFufvPI6SPiOjnj+CfIn iuI/Zc3fT+qOxNZlJ3fIhxzYpywSj+o/384IoFPdKd03MflQVnH+BM1MNaxXBCPAy68G xe9NNz3fMGeLqlmGz8Cb1wI/uauSMc7K3V1HP+SfVE7LerKNCAHrIuu3z73X5RpjcWcQ 98JQYvTFTCdrQmMsBQsd73BCHEwimnIKKjwHhp70CBMR5oP4wLVFQiNRFWz+MwKVSxpo xmnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=pi8+pvOo5GD31+DShFQAK7E9GDE8R7NbCExr59rZ79w=; fh=L8770YbdqwN+H3w09Wz/3K/eDJDtY4TwSa8IY1Y5Rik=; b=Q7vxWBJ19aMk3hX5GzVaz94IJTnSFKFJm84Cb41g3oWRQOzOB5RYZUdw801NQjqskH Qg9UwBxqFRLMtq9VvVf+M658C5WW17O4Pexlb53xgx84qW83rDHwLWUW1WjzFXVBRqE6 nqUxbOx91lKucNZ1L1kR0luq1UPhpM4sNSaZmBlkJ2LwPkkPo6dQfSUjJ8XUVQvdBPHj 5mIxDZL8shdKw2ErqCGivsIKPOx721o0TkWUuHT3zgjIproDQTx55b4jz8mHzX3nYAgG xqmgaKg2FcQslKahRTKOM91DsRxqN+twADXym6zo1gRm2bqOzBRrBUhCxFYe2VnoBtLh yNtA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IJ4qkZCa; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-92669-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92669-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 d11-20020a1709067f0b00b00a4307efaeebsi4964639ejr.343.2024.03.05.08.19.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 08:19:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92669-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=@intel.com header.s=Intel header.b=IJ4qkZCa; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-92669-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92669-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 9FE421F26017 for ; Tue, 5 Mar 2024 16:19:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0A38D128801; Tue, 5 Mar 2024 16:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IJ4qkZCa" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 498A4128382 for ; Tue, 5 Mar 2024 16:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655540; cv=none; b=SL/tIvT7AyjnXB1vhe3AzeLWZAnpxG7fYAVUDJBLR9bTj74kcOWSPyHWBZHwX2sfCmmc+aCAiVNarDFAGLmMd3Y2VXjBUF5WG8pdVEB8jQUtQy9Z/iq4k1xXPkBZ6SyR+BoioM+D7OAD+FjT5wsi0P8Ff6j6S6HctCZj6KX3cSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709655540; c=relaxed/simple; bh=Pa0fMVUTeiUhUY2VLkFLVyMrIu9XCbjjrHzKX5ueVOA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=lgEd7HgvOquWBgEAPCNE+pA87X0buW0rSAUPIwFB8Ixey+hJdgZ6CZyy8dQhBmiIdI/BC8popNpGZntPsbCqgaiXk3NvdbUYsS1q35xt2kAf0ZrMUCDZPKrqn4/YrMUERn9FuNIgFMOKy2PsTj8NxmUmsPXy8IodxlymkFIw20A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=IJ4qkZCa; arc=none smtp.client-ip=192.198.163.13 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709655538; x=1741191538; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=Pa0fMVUTeiUhUY2VLkFLVyMrIu9XCbjjrHzKX5ueVOA=; b=IJ4qkZCaz63pUg99SXEYb9CtFb57zDlSpMwtAd1D8r038svN8TWKdQcj WE0zIUQFnkPoavC67+nwbWngEf7nUBBtsZ93dYKIaK7VhiFPC56hDvBAR CiSmgkkZQdSl4IfEHP/J8hbqBy4yNkuchphDAv+bF2FtzqhNGh4PjqeuS u2hzu6sHOgEX9pfo7IPC1Qv2B7GcW8zgOHb1ZxTH4E9zYXd/7vCCArS3K N4wNcPVmEPfrip8QdHW0DAPdsK9scaokBPcAxvxC6CUAfb5BeSvyBB7bN ZDvfsBZPpq0PB07DrQ288syLF1GckAt6HFAFRoTQeEkBz4IM8Ux3nnGq6 g==; X-IronPort-AV: E=McAfee;i="6600,9927,11003"; a="7161281" X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="7161281" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 08:18:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,205,1705392000"; d="scan'208";a="9533104" Received: from omakhlou-mobl4.amr.corp.intel.com (HELO localhost) ([10.252.51.143]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Mar 2024 08:18:52 -0800 From: Jani Nikula To: Alvin =?utf-8?Q?=C5=A0ipraga?= , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , David Airlie , Daniel Vetter , Hans Verkuil Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Alvin =?utf-8?Q?=C5=A0ipraga?= Subject: Re: [PATCH v3 2/2] drm/bridge: adv7511: get edid in hpd_work to update CEC phys address In-Reply-To: <20240219-adv7511-cec-edid-v3-2-445aed2f1cd7@bang-olufsen.dk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240219-adv7511-cec-edid-v3-0-445aed2f1cd7@bang-olufsen.dk> <20240219-adv7511-cec-edid-v3-2-445aed2f1cd7@bang-olufsen.dk> Date: Tue, 05 Mar 2024 18:18:50 +0200 Message-ID: <87cys81wk5.fsf@intel.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-Transfer-Encoding: quoted-printable On Mon, 19 Feb 2024, 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. > > Reviewed-by: Robert Foss > Signed-off-by: Alvin =C5=A0ipraga > --- > drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 73 ++++++++++++++++++----= ------ > 1 file changed, 47 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..d823b372ff43 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; > } >=20=20 > +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 cleared */ > + regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, > + edid_i2c_addr); > + } > + > + edid =3D drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); > + > + 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); It really would be better to do drm_edid_read_custom(), drm_edid_connector_update(), and cec_s_phys_addr() with the physical address from connector->display_info.source_physical_address initialized by drm_edid_connector_update(). The point is, cec_s_phys_addr_from_edid() has its own duplicate EDID parsing, which is slightly different from drm_edid_connector_update() and of course redundant. BR, Jani. > + > + return edid; > +} > + > /* ---------------------------------------------------------------------= -------- > * Hotplug handling > */ > @@ -595,8 +625,23 @@ static void adv7511_hpd_work(struct work_struct *wor= k) > adv7511->connector.status =3D status; >=20=20 > if (adv7511->connector.dev) { > - if (status =3D=3D connector_status_disconnected) > + if (status =3D=3D connector_status_disconnected) { > cec_phys_addr_invalidate(adv7511->cec_adap); > + } 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 allocated > + * edid structure, so free it to prevent > + * leakage. > + */ > + edid =3D __adv7511_get_edid(adv7511, > + &adv7511->connector); > + kfree(edid); > + } > + > drm_kms_helper_hotplug_event(adv7511->connector.dev); > } else { > drm_bridge_hpd_notify(&adv7511->bridge, status); > @@ -611,31 +656,7 @@ static void adv7511_hpd_work(struct work_struct *wor= k) > 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 cleared */ > - regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, > - edid_i2c_addr); > - } > - > - edid =3D drm_do_get_edid(connector, adv7511_get_edid_block, adv7511); > - > - 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; > + return __adv7511_get_edid(adv7511, connector); > } >=20=20 > static int adv7511_get_modes(struct adv7511 *adv7511, --=20 Jani Nikula, Intel