Received: by 2002:ac0:e34a:0:0:0:0:0 with SMTP id g10csp126197imn; Wed, 27 Jul 2022 01:29:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1se5mZU7f8jJuvxah++wPlnVt8fPBktuvuzP01cTTIVYdIt4MFDw8LnVw4zxIIgCuT1viQ5 X-Received: by 2002:a17:902:e5c5:b0:16d:82dd:8c41 with SMTP id u5-20020a170902e5c500b0016d82dd8c41mr11008920plf.133.1658910539789; Wed, 27 Jul 2022 01:28:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658910539; cv=none; d=google.com; s=arc-20160816; b=yxVtgxJiOs8QAcVClHg5m8MIjfkeT3XC98xatsKp5fYHCCSmOJqLEpBT+ar8MPh+9h hNEHWTqqXzFicLlmGGLkfbPuPWknmMRq7RYVGjQ/A5ozr9k6Wdmh+Wl/mHyWMHeO/R9v nmdQdnW1W3K+JuDoHkQo+3wAdD5RiQ16ldCTtdjOHXroVZn4lSe+kQ15dLcmNHkI2i6b ppSflayQKxaqCLumIgRWo6yHNmRDWbf9pBqGF9uvxCZd2J/im3vquPNdQeJw8MjCKdn9 /KDgwq5HstnaPGxqV9kUI+WlyREEtogtpBJYj4tmZwQWXxsz1PkeyS9oax5GOcv5bL0F a7CA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature:dkim-signature; bh=Afwxwpqi4PHP9gQvy42ArBsEBv8pS8AltwvoI3yDjtQ=; b=kDqJFkGkPpD6WmFk4m7wujuJhTDAIjhzz497hkDc8sFGXZh+u6l1x6DL/8xmXubiuf DwWbiUNxPA8SKnby2Td+cShOcJFjfg/uWbFz9viZlHANi7Ew0u+tVMcYZdzHv30QgU6S qCI1+yF8zqd4ObYsXWsLHOZgzJ9YXAzU7jiOSRZwvRMf6ulgQyUpWkokc5Rlbf1d2n0x +agwkgfst2kIGxrIe901H+UDAafvOc2cawQ5gDWJHJROOGpJl9CfEpQ1E5Oi4I93cdnI cLMc5eSclE74pWMUcICk68mSMiRPp0e0QaHE9aWduxFVpSA7MLKCG197WL/meaYs1+vi JpTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Rj1jADJ+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x4-20020a656aa4000000b0041a5e8f9c66si22921853pgu.387.2022.07.27.01.28.44; Wed, 27 Jul 2022 01:28:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Rj1jADJ+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbiG0ISx (ORCPT + 99 others); Wed, 27 Jul 2022 04:18:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbiG0ISv (ORCPT ); Wed, 27 Jul 2022 04:18:51 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AA2E43E63 for ; Wed, 27 Jul 2022 01:18:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5220E33C68; Wed, 27 Jul 2022 08:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1658909929; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Afwxwpqi4PHP9gQvy42ArBsEBv8pS8AltwvoI3yDjtQ=; b=Rj1jADJ+94fsezLiBkilEODE/x0JDmp6RVLfmcn04NIL3VzMnC3684XxezLNv/DAyHWHGh scAdWXy3jC4ZMHbrlvhF+NvJY83WPuOsfxBZb/vzhExk9jwc2po8a+NDBq8Xx3mVOTShrB 3zaCPz2DyXowRHoeBStTkHKNR8qXhN8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1658909929; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Afwxwpqi4PHP9gQvy42ArBsEBv8pS8AltwvoI3yDjtQ=; b=T/Rt4UlJHJV8xdC1uyul6jxikYFTC+ckRjAFVcJEH2PNDpg4Qiiv4m4Yl2xCryj6mvEg4f vO3emAdzQbsSFeCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 17D1E13ABC; Wed, 27 Jul 2022 08:18:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id x+kHBen04GIwKgAAMHmgww (envelope-from ); Wed, 27 Jul 2022 08:18:49 +0000 Date: Wed, 27 Jul 2022 10:18:48 +0200 Message-ID: <875yjjotnb.wl-tiwai@suse.de> From: Takashi Iwai To: Matthieu CHARETTE Cc: lkp@intel.com, airlied@linux.ie, andrealmeid@igalia.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de Subject: Re: [PATCH] drm: Fix EDID firmware load on resume In-Reply-To: <20220727074152.43059-1-matthieu.charette@gmail.com> References: <202207172035.mtErdlaw-lkp@intel.com> <20220727074152.43059-1-matthieu.charette@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Jul 2022 09:41:52 +0200, Matthieu CHARETTE wrote: > > Loading an EDID using drm.edid_firmware parameter makes resume to fail > after firmware cache is being cleaned. This is because edid_load() use a > temporary device to request the firmware. This cause the EDID firmware > not to be cached from suspend. And, requesting the EDID firmware return > an error during resume. > So the request_firmware() call should use a permanent device for each > connector. Also, we should cache the EDID even if no monitor is > connected, in case it's plugged while suspended. > > Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2061 > Signed-off-by: Matthieu CHARETTE Can we simply cache the already loaded EDID bytes instead? Something like below (totally untested). thanks, Takashi -- 8< -- diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 1c48d162c77e..b9d2803b518b 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -286,6 +286,7 @@ int drm_connector_init(struct drm_device *dev, connector->status = connector_status_unknown; connector->display_info.panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; + connector->firmware_edid = NULL; drm_connector_get_cmdline_mode(connector); @@ -485,6 +486,7 @@ void drm_connector_cleanup(struct drm_connector *connector) ida_simple_remove(&dev->mode_config.connector_ida, connector->index); + kfree(connector->firmware_edid); kfree(connector->display_info.bus_formats); drm_mode_object_unregister(dev, &connector->base); kfree(connector->name); diff --git a/drivers/gpu/drm/drm_edid_load.c b/drivers/gpu/drm/drm_edid_load.c index 37d8ba3ddb46..a38fe4e00e4a 100644 --- a/drivers/gpu/drm/drm_edid_load.c +++ b/drivers/gpu/drm/drm_edid_load.c @@ -253,6 +253,13 @@ static void *edid_load(struct drm_connector *connector, const char *name, edid = new_edid; } + connector->firmware_edid = drm_edid_duplicate((struct edid *)edid); + if (!connector->firmware_edid) { + kfree(edid); + edid = ERR_PTR(-ENOMEM); + goto out; + } + DRM_INFO("Got %s EDID base block and %d extension%s from " "\"%s\" for connector \"%s\"\n", (builtin >= 0) ? "built-in" : "external", valid_extensions, valid_extensions == 1 ? "" : "s", @@ -269,6 +276,12 @@ struct edid *drm_load_edid_firmware(struct drm_connector *connector) char *edidname, *last, *colon, *fwstr, *edidstr, *fallback = NULL; struct edid *edid; + /* already loaded? */ + if (connector->firmware_edid) { + edid = drm_edid_duplicate(connector->firmware_edid); + return edid ? edid : ERR_PTR(-ENOMEM); + } + if (edid_firmware[0] == '\0') return ERR_PTR(-ENOENT); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 3ac4bf87f257..b5d0c87327a3 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1528,6 +1528,8 @@ struct drm_connector { enum drm_connector_force force; /** @override_edid: has the EDID been overwritten through debugfs for testing? */ bool override_edid; + /** @firmware_edid: the cached firmware EDID bytes */ + struct edid *firmware_edid; /** @epoch_counter: used to detect any other changes in connector, besides status */ u64 epoch_counter;