Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp931688pxb; Tue, 14 Sep 2021 11:51:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqI2ZgC1CiZ5LM091yZ+s7vHRah3EcVTrY93dzPbbgDPw+jASNwB/w/45B8s1sbSNPutO1 X-Received: by 2002:a6b:6c17:: with SMTP id a23mr15203666ioh.110.1631645514368; Tue, 14 Sep 2021 11:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631645514; cv=none; d=google.com; s=arc-20160816; b=fDJfHHtXju4LfaB1/7HGNrPMHi7idqBakn76NCZKfP0rYkzBO5s/tJicRAqU7Kk5YS CU68cx2R508lCosEpVqDL3emunZMgj9ZSmxZx9uRO+OTO/aUAwO0t/I8lIHFcZ+lyEuN RkFj+Pl4CUfwNa8SAEqPiqfwD10PxvLIrQqJSPn0zVII68NoVdfcyPr2DZ8BPm/cX5bV 087lQejaAmFOKnZlLoQpXiAE9/0a3GWQcKmjFP2A3CV2BIKCYp4RU5HT95F7HIlORW2L UyMTR2U473qxCmCLgf/LsQ53x9DtvyVXb8zSAlD8SH1y+CUSzdxbF2psA4WpUpVRVXyl Rv2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from; bh=4M0gxrjJprYK3rCwroAQhqqyandOI9lKbHcnpZy/31k=; b=YwbFuf/uSidsUSY8kvyu+0Tnbab0JGePPad2YXrblytVzNX56sBuRuVtsWcDqr5kh3 SsRdPqKf8ls4KMEnCzpc4zDKIWAHL9xHBrL5PgbhPcrgyBAOMoiBIX0PAi+C8Zo3Ag/W ik1/2Qlk2FZ5kkjO2CbtUux/nygdp3h4SoycmstNy10vWLO2csdtXgifuZxYMvpjhpD7 udhJAN4wsEV3BplXtub1a74JpAQkncU7ajZcDVswSjzdzsoEi1x/kzuYUhy+VXKO+R70 E3aJcOcgcaWnMHrRQ+I8HOfO6Fgv2Dhj/XtMF25p9SEugiG7alqaf9sVNBfW4hM7q7QH zrqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m43si10929930jav.131.2021.09.14.11.51.41; Tue, 14 Sep 2021 11:51:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231401AbhINSvp (ORCPT + 99 others); Tue, 14 Sep 2021 14:51:45 -0400 Received: from mga04.intel.com ([192.55.52.120]:13235 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229869AbhINSvo (ORCPT ); Tue, 14 Sep 2021 14:51:44 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10107"; a="220225411" X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="220225411" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2021 11:50:26 -0700 X-IronPort-AV: E=Sophos;i="5.85,292,1624345200"; d="scan'208";a="544237888" Received: from lveltman-mobl.ger.corp.intel.com (HELO localhost) ([10.251.216.6]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2021 11:50:19 -0700 From: Jani Nikula To: Douglas Anderson , Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Maxime Ripard , Thomas Zimmermann , Linus W , Daniel Vetter , linux-arm-msm@vger.kernel.org, Steev Klimaszewski , Maarten Lankhorst , Bjorn Andersson , David Airlie , dri-devel@lists.freedesktop.org, Douglas Anderson , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 02/15] drm/edid: Break out reading block 0 of the EDID In-Reply-To: <20210909135838.v4.2.I62e76a034ac78c994d40a23cd4ec5aeee56fa77c@changeid> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20210909210032.465570-1-dianders@chromium.org> <20210909135838.v4.2.I62e76a034ac78c994d40a23cd4ec5aeee56fa77c@changeid> Date: Tue, 14 Sep 2021 21:50:15 +0300 Message-ID: <878rzz0z6g.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 09 Sep 2021, Douglas Anderson wrote: > A future change wants to be able to read just block 0 of the EDID, so > break it out of drm_do_get_edid() into a sub-function. > > This is intended to be a no-op change--just code movement. > > Signed-off-by: Douglas Anderson > Acked-by: Sam Ravnborg Reviewed-by: Jani Nikula > --- > > Changes in v4: > - "u8 *edid" => "void *edid" to avoid cast. > - Don't put kmalloc() in the "if" test even if the old code did. > - drm_do_get_edid_blk0() => drm_do_get_edid_base_block() > > drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++----------- > 1 file changed, 45 insertions(+), 18 deletions(-) > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 6325877c5fd6..520fe1391769 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -1905,6 +1905,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector) > } > EXPORT_SYMBOL(drm_add_override_edid_modes); > > +static struct edid *drm_do_get_edid_base_block( > + int (*get_edid_block)(void *data, u8 *buf, unsigned int block, > + size_t len), > + void *data, bool *edid_corrupt, int *null_edid_counter) > +{ > + int i; > + void *edid; > + > + edid = kmalloc(EDID_LENGTH, GFP_KERNEL); > + if (edid == NULL) > + return NULL; > + > + /* base block fetch */ > + for (i = 0; i < 4; i++) { > + if (get_edid_block(data, edid, 0, EDID_LENGTH)) > + goto out; > + if (drm_edid_block_valid(edid, 0, false, edid_corrupt)) > + break; > + if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { > + if (null_edid_counter) > + (*null_edid_counter)++; > + goto carp; > + } > + } > + if (i == 4) > + goto carp; > + > + return edid; > + > +carp: > + kfree(edid); > + return ERR_PTR(-EINVAL); > + > +out: > + kfree(edid); > + return NULL; > +} > + > /** > * drm_do_get_edid - get EDID data using a custom EDID block read function > * @connector: connector we're probing > @@ -1938,25 +1976,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, > if (override) > return override; > > - if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) > + edid = (u8 *)drm_do_get_edid_base_block(get_edid_block, data, > + &connector->edid_corrupt, > + &connector->null_edid_counter); > + if (IS_ERR_OR_NULL(edid)) { > + if (IS_ERR(edid)) > + connector_bad_edid(connector, edid, 1); > return NULL; > - > - /* base block fetch */ > - for (i = 0; i < 4; i++) { > - if (get_edid_block(data, edid, 0, EDID_LENGTH)) > - goto out; > - if (drm_edid_block_valid(edid, 0, false, > - &connector->edid_corrupt)) > - break; > - if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { > - connector->null_edid_counter++; > - goto carp; > - } > } > - if (i == 4) > - goto carp; > > - /* if there's no extensions, we're done */ > + /* if there's no extensions or no connector, we're done */ > valid_extensions = edid[0x7e]; > if (valid_extensions == 0) > return (struct edid *)edid; > @@ -2010,8 +2039,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, > > return (struct edid *)edid; > > -carp: > - connector_bad_edid(connector, edid, 1); > out: > kfree(edid); > return NULL; -- Jani Nikula, Intel Open Source Graphics Center