Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1861246rwb; Fri, 19 Aug 2022 10:36:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EuNjuoNSzd0NA1nQObAGYKp53tGx9VVzeKtO+IRDKoeJqtxDbtCl9mbZs2xx/lkN9Um/f X-Received: by 2002:a63:6cc4:0:b0:41a:ff04:661f with SMTP id h187-20020a636cc4000000b0041aff04661fmr7090334pgc.600.1660930563672; Fri, 19 Aug 2022 10:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930563; cv=none; d=google.com; s=arc-20160816; b=SMoQE5KalBiqCAmOyZzTJ47O2vOl7oBrMBDz0QLMGGUYDN1dJnq9BUa6LIqxzFXsmf zLlUHubiNylOF1WzCw5wiFIEIxx9jHn0KHMibBycBZL/tMf3omGbwSVh1VZ84Q2isBif YMQBCVz0e+eSMVa827uy5uCd/YnLq1cMhTWS8JEYFrQPjIeFZdI/qhWMAI7gFtq6h4T3 nmNANrHHixTNgAwqLlNwWzwaCYnT4IWsAZWB9HaBa/FZtlmfEku4TKlTcKIjh5OvkYk2 /ZoM32+XeHHAWtgIb1reNFrQ5OJ9GFcZ2b0DvdEWH3N9Pt0iMMyZNgGyv7xEqXKCNTtK pQjg== 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=XhTpU2tKHvVPVlwzCrHsQveY7WeBlMDEcc2r1LyS1m4=; b=qQJ1DYUdIwT5SWlYB8/MKuGrZL3eVF3JtQrKEuKOAE2eKYOZxaKQ9aBr2TsjC/zT96 ye1RSXXlmWot7dxaq8OQXoqF4/5gxo5WVOCdD3ur6oACb/cKg9q+i6J0sqA5jh3Z3lUj W5EMvZCod8S4XXnkO9SGTgYva6DhMMXsGaXoxDPEBVji+QgyGd9gDWoC3PIGUvpqll4B uLEhoQeXaYkm7837fJUyasP5JKvJ9q3bnMek42PCiKKJb1PYPZvml7sv4Nqg6yj2xNZT XnYaFZXwGD9gnjGtiOZmmy77F9d456NpFT0hrYTxAuMdXZFeC3huCevXSE0nzMedVWOk HtOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=doakN1Hp; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w18-20020a63c112000000b0041c0a56edd1si4174163pgf.879.2022.08.19.10.35.52; Fri, 19 Aug 2022 10:36:03 -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=@linuxfoundation.org header.s=korg header.b=doakN1Hp; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350316AbiHSPw3 (ORCPT + 99 others); Fri, 19 Aug 2022 11:52:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350570AbiHSPvA (ORCPT ); Fri, 19 Aug 2022 11:51:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E64AD31EC5; Fri, 19 Aug 2022 08:48:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 0BA1D6170B; Fri, 19 Aug 2022 15:48:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14152C433D6; Fri, 19 Aug 2022 15:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660924111; bh=kydCZxS2HyPc3cC1Mr1++qUBFTk6gJM/dRcmOx+uCNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=doakN1Hp/rHVIeO4/zxqBINxWYdfxdDCivffvAAhsp9wQD9TOcml1QM6ja1idIp9x SarHN6Hm8y+ntN6dz8xNUUkaVKHYIXEZyhD504bixLWhZtpqGd6YAZ6sqlrlsVRMYS 6XkmfyEUrWrR74xZYioaRR25QoAhpDZ/4hY7LtH0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Michael Ellerman Subject: [PATCH 5.10 060/545] powerpc/fsl-pci: Fix Class Code of PCIe Root Port Date: Fri, 19 Aug 2022 17:37:10 +0200 Message-Id: <20220819153831.920784306@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Pali Rohár commit 0c551abfa004ce154d487d91777bf221c808a64f upstream. By default old pre-3.0 Freescale PCIe controllers reports invalid PCI Class Code 0x0b20 for PCIe Root Port. It can be seen by lspci -b output on P2020 board which has this pre-3.0 controller: $ lspci -bvnn 00:00.0 Power PC [0b20]: Freescale Semiconductor Inc P2020E [1957:0070] (rev 21) !!! Invalid class 0b20 for header type 01 Capabilities: [4c] Express Root Port (Slot-), MSI 00 Fix this issue by programming correct PCI Class Code 0x0604 for PCIe Root Port to the Freescale specific PCIe register 0x474. With this change lspci -b output is: $ lspci -bvnn 00:00.0 PCI bridge [0604]: Freescale Semiconductor Inc P2020E [1957:0070] (rev 21) (prog-if 00 [Normal decode]) Capabilities: [4c] Express Root Port (Slot-), MSI 00 Without any "Invalid class" error. So class code was properly reflected into standard (read-only) PCI register 0x08. Same fix is already implemented in U-Boot pcie_fsl.c driver in commit: http://source.denx.de/u-boot/u-boot/-/commit/d18d06ac35229345a0af80977a408cfbe1d1015b Fix activated by U-Boot stay active also after booting Linux kernel. But boards which use older U-Boot version without that fix are affected and still require this fix. So implement this class code fix also in kernel fsl_pci.c driver. Cc: stable@vger.kernel.org Signed-off-by: Pali Rohár Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220706101043.4867-1-pali@kernel.org Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/sysdev/fsl_pci.c | 8 ++++++++ arch/powerpc/sysdev/fsl_pci.h | 1 + 2 files changed, 9 insertions(+) --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -520,6 +520,7 @@ int fsl_add_bridge(struct platform_devic struct resource rsrc; const int *bus_range; u8 hdr_type, progif; + u32 class_code; struct device_node *dev; struct ccsr_pci __iomem *pci; u16 temp; @@ -593,6 +594,13 @@ int fsl_add_bridge(struct platform_devic PPC_INDIRECT_TYPE_SURPRESS_PRIMARY_BUS; if (fsl_pcie_check_link(hose)) hose->indirect_type |= PPC_INDIRECT_TYPE_NO_PCIE_LINK; + /* Fix Class Code to PCI_CLASS_BRIDGE_PCI_NORMAL for pre-3.0 controller */ + if (in_be32(&pci->block_rev1) < PCIE_IP_REV_3_0) { + early_read_config_dword(hose, 0, 0, PCIE_FSL_CSR_CLASSCODE, &class_code); + class_code &= 0xff; + class_code |= PCI_CLASS_BRIDGE_PCI_NORMAL << 8; + early_write_config_dword(hose, 0, 0, PCIE_FSL_CSR_CLASSCODE, class_code); + } } else { /* * Set PBFR(PCI Bus Function Register)[10] = 1 to --- a/arch/powerpc/sysdev/fsl_pci.h +++ b/arch/powerpc/sysdev/fsl_pci.h @@ -18,6 +18,7 @@ struct platform_device; #define PCIE_LTSSM 0x0404 /* PCIE Link Training and Status */ #define PCIE_LTSSM_L0 0x16 /* L0 state */ +#define PCIE_FSL_CSR_CLASSCODE 0x474 /* FSL GPEX CSR */ #define PCIE_IP_REV_2_2 0x02080202 /* PCIE IP block version Rev2.2 */ #define PCIE_IP_REV_3_0 0x02080300 /* PCIE IP block version Rev3.0 */ #define PIWAR_EN 0x80000000 /* Enable */