From patchwork Thu Oct 29 11:23:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Su X-Patchwork-Id: 1390065 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CMNP471M0z9sSC for ; Thu, 29 Oct 2020 22:23:52 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=wistron.com Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4CMNP463SKzDqLS for ; Thu, 29 Oct 2020 22:23:52 +1100 (AEDT) X-Original-To: skiboot-stable@lists.ozlabs.org Delivered-To: skiboot-stable@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=wistron.com (client-ip=103.200.3.20; helo=segapp03.wistron.com; envelope-from=lulu_su@wistron.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=wistron.com Received: from segapp03.wistron.com (segapp03.wistron.com [103.200.3.20]) by lists.ozlabs.org (Postfix) with ESMTP id 4CMNNz2lGKzDqSY for ; Thu, 29 Oct 2020 22:23:45 +1100 (AEDT) Received: from EXCHAPP01.whq.wistron (unverified [10.37.38.24]) by TWNHUMSW4.wistron.com (Clearswift SMTPRS 5.6.0) with ESMTP id ; Thu, 29 Oct 2020 19:23:42 +0800 Received: from EXCHAPP01.whq.wistron (10.37.38.24) by EXCHAPP01.whq.wistron (10.37.38.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Thu, 29 Oct 2020 19:23:41 +0800 Received: from gitserver.wistron.com (10.37.38.233) by EXCHAPP01.whq.wistron (10.37.38.24) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Thu, 29 Oct 2020 19:23:41 +0800 From: Lulu Su To: , Stewart Smith Date: Thu, 29 Oct 2020 19:23:38 +0800 Message-ID: <20201029112338.28765-1-Lulu_Su@wistron.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-TM-SNTS-SMTP: 195F4E7C73B06C5465C4800D6837A287B43F79352D5FD37DF0F17AEAB3C217412000:8 Subject: [Skiboot-stable] [PATCH] mowgli: Limit slot1 to Gen3 by default X-BeenThere: skiboot-stable@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches, review, and discussion for stable releases of skiboot" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oliver OHalloran , LuluTHSu , Klaus Heinrich Kiwi Errors-To: skiboot-stable-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot-stable" From: LuluTHSu Refer to the spec. of mowgli, limit the slot to Gen3 speed. For mowgli platform spec. Cc: skiboot-stable@lists.ozlabs.org Signed-off-by: LuluTHSu --- hw/phb4.c | 21 +++++++++++++++++++++ include/phb4.h | 1 + platforms/astbmc/mowgli.c | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/hw/phb4.c b/hw/phb4.c index 17a233f..de10bb0 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -2991,6 +2991,27 @@ static unsigned int phb4_get_max_link_speed(struct phb4 *p, struct dt_node *np) return max_link_speed; } +/* + * Has the same effect as the ibm,max-link-speed property. + * i.e. sets the default link speed, while allowing NVRAM + * overrides, etc to still take effect. + */ +void phb4_set_dt_max_link_speed(struct phb4 *p, int new_max) +{ + uint64_t scr; + int max; + + /* take into account nvram settings, etc */ + if (pcie_max_link_speed) + max = pcie_max_link_speed; + else + max = new_max; + + scr = phb4_read_reg(p, PHB_PCIE_SCR); + scr = SETFIELD(PHB_PCIE_SCR_MAXLINKSPEED, scr, max); + phb4_write_reg(p, PHB_PCIE_SCR, scr); +} + static void phb4_assert_perst(struct pci_slot *slot, bool assert) { struct phb4 *p = phb_to_phb4(slot->phb); diff --git a/include/phb4.h b/include/phb4.h index abba2d9..47a46b7 100644 --- a/include/phb4.h +++ b/include/phb4.h @@ -259,4 +259,5 @@ static inline int phb4_get_opal_id(unsigned int chip_id, unsigned int index) void phb4_pec2_dma_engine_realloc(struct phb4 *p); +void phb4_set_dt_max_link_speed(struct phb4 *p, int new_max); #endif /* __PHB4_H */ diff --git a/platforms/astbmc/mowgli.c b/platforms/astbmc/mowgli.c index 9bfe7a4..0246bff 100644 --- a/platforms/astbmc/mowgli.c +++ b/platforms/astbmc/mowgli.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "astbmc.h" @@ -71,6 +73,19 @@ static int mowgli_secvar_init(void) return secvar_main(secboot_tpm_driver, edk2_compatible_v1); } +/* + * Limit PHB0/(pec0) to gen3 speeds. + */ +static void mowgli_setup_phb(struct phb *phb, unsigned int __unused index) +{ + struct phb4 *p = phb_to_phb4(phb); + + if (p->pec == 0) { + phb4_set_dt_max_link_speed(p, 3); + prlog(PR_DEBUG, "Mowgli: Force the PHB%d Speed to Gen3.\n", p->pec); + } +} + DECLARE_PLATFORM(mowgli) = { .name = "Mowgli", .probe = mowgli_probe, @@ -80,6 +95,7 @@ DECLARE_PLATFORM(mowgli) = { .bmc = &bmc_plat_ast2500_openbmc, .pci_get_slot_info = slot_table_get_slot_info, .pci_probe_complete = check_all_slot_table, + .pci_setup_phb = mowgli_setup_phb, .cec_power_down = astbmc_ipmi_power_down, .cec_reboot = astbmc_ipmi_reboot, .elog_commit = ipmi_elog_commit,