Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2142923iof; Tue, 7 Jun 2022 21:11:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEjkTlCs4Xti3OYOzYmi8+mIdfq+QckmqPwmWc1KydBUcSMFmJjTxuGjcDF0KapKbhwOt5 X-Received: by 2002:a63:8841:0:b0:3fc:6f1f:d11 with SMTP id l62-20020a638841000000b003fc6f1f0d11mr28839900pgd.498.1654661460544; Tue, 07 Jun 2022 21:11:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661460; cv=none; d=google.com; s=arc-20160816; b=A2XAVt1prTegO4XCSmMflBsmcbzT0homwxzfAnAliVkSOBY6D/wEvrhRDY4Xr5swM/ ZHf/n+OUDGnYUMFZStXpxpYBnTxL0aJfvXZZnEo3MWAGq1HNk4DPf6JDB7OVNi6bpXmV bQWA/YE37/AkD799D4Hr5CeB4YZrPu8wUmfIoBUtE4HwuKmYcjsW2+3OPltIw2fIiv1d znbGIItt8QIH5pAqB0wmLQ9+lGDFeVZS4DdpTJXMahyfCXPv4RgFPPgp7rStlkwpUxDE JnK3zYNtOExgtAIgeITeEjPKj5DxVGabUcJluS58zcrSruIMe1jQGFWGHlMZiCxt03e3 SFTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QyFZSiMgVl98k8EGJTcy3R4cJyLdyqOtZoP49cWSLCA=; b=IRa0JShjNSb3LLxzDOqh2XS/AOGWZLtYMdxZBTv/xywaLy3U2BOLcNr+yzDaToNnSk m8v12b7lncEvS66yafVSFnkfGixwK2VzpNhZaaTppvX59zxITPTCoqNq+RtMZCY+OhMy UAvZ7ZHSk96SIfEJ/65Mma2Kp0Py2Jt1NFFJhns2KIESfdfXm2ChSqDJDF+zETO+W2p8 EPWVgu3vfXdp+MVOLqkW+/lZBKPTDkoFBpcmEq1XLIIOGlML6lVo4NbiOrb+gPfIyuCj 0dcF6PWNOpjgH9fGWB0TC6bcR60UBLOj7MqsD5FeaB6QwOuKoXu8MqHBMBODjVHdFv0R w39w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ds1qUW3K; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g11-20020a170902d5cb00b001608b341d2csi12674053plh.124.2022.06.07.21.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:11:00 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ds1qUW3K; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B83E21E0C9; Tue, 7 Jun 2022 20:42:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239449AbiFGSJL (ORCPT + 99 others); Tue, 7 Jun 2022 14:09:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348980AbiFGRuY (ORCPT ); Tue, 7 Jun 2022 13:50:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0F10137440; Tue, 7 Jun 2022 10:37:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 56882B822B1; Tue, 7 Jun 2022 17:37:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A69A0C385A5; Tue, 7 Jun 2022 17:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623456; bh=RJrjyvSFLG5vaE/YCedMXiTGe5JIDbSiGT/RnpKzjtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ds1qUW3KKPSHvnlL8cgp4OsU8WZUWJrMNyah5Izpm3YFo3j+3tj9TfbtevTVO1Eg0 UwP2xPVyE4zn8PcXaEa0hseg27pwg4QyHODTVTKH3IpHIL4V2gCSj2NWYVLTILqM3x Prndqd9cWew1oYjZuDwDIkjThnmQJcBIPPtG6kUA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ville Syrjala , Jani Nikula Subject: [PATCH 5.10 383/452] drm/i915/dsi: fix VBT send packet port selection for ICL+ Date: Tue, 7 Jun 2022 19:04:00 +0200 Message-Id: <20220607164919.978470651@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Jani Nikula commit 0ea917819d12fed41ea4662cc26ffa0060a5c354 upstream. The VBT send packet port selection was never updated for ICL+ where the 2nd link is on port B instead of port C as in VLV+ DSI. First, single link DSI needs to use the configured port instead of relying on the VBT sequence block port. Remove the hard-coded port C check here and make it generic. For reference, see commit f915084edc5a ("drm/i915: Changes related to the sequence port no for") for the original VLV specific fix. Second, the sequence block port number is either 0 or 1, where 1 indicates the 2nd link. Remove the hard-coded port C here for 2nd link. (This could be a "find second set bit" on DSI ports, but just check the two possible options.) Third, sanity check the result with a warning to avoid a NULL pointer dereference. Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/5984 Cc: stable@vger.kernel.org # v4.19+ Cc: Ville Syrjala Signed-off-by: Jani Nikula Reviewed-by: Ville Syrjälä Link: https://patchwork.freedesktop.org/patch/msgid/20220520094600.2066945-1-jani.nikula@intel.com (cherry picked from commit 08c59dde71b73a0ac94e3ed2d431345b01f20485) Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/display/intel_dsi_vbt.c | 33 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 11 deletions(-) --- a/drivers/gpu/drm/i915/display/intel_dsi_vbt.c +++ b/drivers/gpu/drm/i915/display/intel_dsi_vbt.c @@ -121,9 +121,25 @@ struct i2c_adapter_lookup { #define ICL_GPIO_DDPA_CTRLCLK_2 8 #define ICL_GPIO_DDPA_CTRLDATA_2 9 -static enum port intel_dsi_seq_port_to_port(u8 port) +static enum port intel_dsi_seq_port_to_port(struct intel_dsi *intel_dsi, + u8 seq_port) { - return port ? PORT_C : PORT_A; + /* + * If single link DSI is being used on any port, the VBT sequence block + * send packet apparently always has 0 for the port. Just use the port + * we have configured, and ignore the sequence block port. + */ + if (hweight8(intel_dsi->ports) == 1) + return ffs(intel_dsi->ports) - 1; + + if (seq_port) { + if (intel_dsi->ports & PORT_B) + return PORT_B; + else if (intel_dsi->ports & PORT_C) + return PORT_C; + } + + return PORT_A; } static const u8 *mipi_exec_send_packet(struct intel_dsi *intel_dsi, @@ -145,15 +161,10 @@ static const u8 *mipi_exec_send_packet(s seq_port = (flags >> MIPI_PORT_SHIFT) & 3; - /* For DSI single link on Port A & C, the seq_port value which is - * parsed from Sequence Block#53 of VBT has been set to 0 - * Now, read/write of packets for the DSI single link on Port A and - * Port C will based on the DVO port from VBT block 2. - */ - if (intel_dsi->ports == (1 << PORT_C)) - port = PORT_C; - else - port = intel_dsi_seq_port_to_port(seq_port); + port = intel_dsi_seq_port_to_port(intel_dsi, seq_port); + + if (drm_WARN_ON(&dev_priv->drm, !intel_dsi->dsi_hosts[port])) + goto out; dsi_device = intel_dsi->dsi_hosts[port]->device; if (!dsi_device) {