Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407444rwa; Tue, 23 Aug 2022 04:23:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7GFA6xOzUlYxic4KCZpL6wSmRuPweT5jrmkAUzkKi8M6URlTv3fX8B8dACXDqEKAEODOtK X-Received: by 2002:a65:6a0c:0:b0:429:7ade:490b with SMTP id m12-20020a656a0c000000b004297ade490bmr20286014pgu.621.1661253791779; Tue, 23 Aug 2022 04:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253791; cv=none; d=google.com; s=arc-20160816; b=FN6fcRKTwdhZdqLn+lS80o3w8+gwflxAH9JN5bI6h6VvAou47fbpm+I7jXWoJpoy+S 4a/EmweA/wvnfnZ9F0flquCzgk/zWvNOICetmsQl88xIZtGpHlL6l/L2RH0uXlSsLQze jcg//kU4RBL0v9nvcF60nd3f4hJVVkojTBVZ09TbSfDXexAoOkhibbnzJMmDrdAYit/h ajNPtVm4zwAedSdAeUnJvX+LAAC8S4JTWyoVGB92p+V0/Y/9cLj6xKHZfkiJLv7FY+WU kUDKlRbddiUB/kPBKhpLkFgi+xuQsRiJmIa5Bm0KFomztx8HUIpUZap5fkzaMxGjd1ux ZUsA== 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=ifiy3w8LRKPFwfZD6s9c6CJo0NC1WAAF1yHM3tANyZ8=; b=PomqcMl6aALJbrkfDXsBzNFse5/EU51kb61tT9ha7D+E5qAQpiR8kTCnvFw67SI0su r1Jtywp2xuLkTx12nWOw1XRhE7LHW9sqninI1wQpjrodCfSGINCbAxbwxsXEClUdPCIl bvdmQ2eJFq0XvNtwQTcoCarPWin+kXPGQP+SN63tiUhI280nzMlQl0gfxQ3coFfoDHtP ihUeDvqMT/2DVmU00LGBYKwq6KXD8bUKldjWTdUHq/EEXRW1oMFS3L/Zffao5XwZS209 CAAyd8VHaDOWVuYA/zAI6fU8CNO1LNFuUdIo+ZB/cEWQHn8+RktOLyHqlWoUoZoRz9Qk wZww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oHziVeow; 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 f8-20020a17090a638800b001f4fc7af64esi16164143pjj.101.2022.08.23.04.23.00; Tue, 23 Aug 2022 04:23:11 -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=oHziVeow; 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 S1354099AbiHWKUW (ORCPT + 99 others); Tue, 23 Aug 2022 06:20:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352816AbiHWKJE (ORCPT ); Tue, 23 Aug 2022 06:09:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75E627D7BC; Tue, 23 Aug 2022 01:55:00 -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 11D0B61555; Tue, 23 Aug 2022 08:55:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EB4D7C433C1; Tue, 23 Aug 2022 08:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244899; bh=uRM/VlwTBzxaVs7zAY2kE58AHdWWZRLRNwR7riI/cTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oHziVeowzPNROPgTboQf4FsolZJVvUBwpv1PzruL8DSDsfuZ2txXljaUn4plXjQF7 NPDB3T0nDC2HV+XPz1GMW7QBMO1Zr9YhWy7/L7EYTPqPkGTzBf3tvKSAH4FtwU1WbX 3C76YwtD5NbEbpJKSryYpvpTE32vsVqugbua/ae0= 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?= , =?UTF-8?q?Marek=20Beh=C3=BAn?= , Bjorn Helgaas , Sasha Levin Subject: [PATCH 5.15 169/244] PCI: aardvark: Fix reporting Slot capabilities on emulated bridge Date: Tue, 23 Aug 2022 10:25:28 +0200 Message-Id: <20220823080104.893917934@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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 [ Upstream commit bcdb6fd4f3e9ac1097698c8d8f56b70853b49873 ] Slot capabilities are currently not reported because emulated bridge does not report the PCI_EXP_FLAGS_SLOT flag. Set PCI_EXP_FLAGS_SLOT to let the kernel know that PCI_EXP_SLT* registers are supported. Move setting of PCI_EXP_SLTCTL register from "dynamic" pcie_conf_read function to static buffer as it is only statically filled the PCI_EXP_SLTSTA_PDS flag and dynamic read callback is not needed for this register. Set Presence State Bit to 1 since there is no support for unplugging the card and there is currently no platform able to detect presence of a card - in such a case the bit needs to be set to 1. Finally correctly set Physical Slot Number to 1 since there is only one port and zero value is reserved for ports within the same silicon as Root Port which is not our case for Aardvark HW. Link: https://lore.kernel.org/r/20220524132827.8837-3-kabel@kernel.org Signed-off-by: Pali Rohár Signed-off-by: Marek Behún Signed-off-by: Bjorn Helgaas Signed-off-by: Sasha Levin --- drivers/pci/controller/pci-aardvark.c | 33 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c index 7cc2c54daad0..215f7510de9a 100644 --- a/drivers/pci/controller/pci-aardvark.c +++ b/drivers/pci/controller/pci-aardvark.c @@ -8,6 +8,7 @@ * Author: Hezi Shahmoon */ +#include #include #include #include @@ -857,14 +858,11 @@ advk_pci_bridge_emul_pcie_conf_read(struct pci_bridge_emul *bridge, switch (reg) { - case PCI_EXP_SLTCTL: - *value = PCI_EXP_SLTSTA_PDS << 16; - return PCI_BRIDGE_EMUL_HANDLED; - /* - * PCI_EXP_RTCTL and PCI_EXP_RTSTA are also supported, but do not need - * to be handled here, because their values are stored in emulated - * config space buffer, and we read them from there when needed. + * PCI_EXP_SLTCAP, PCI_EXP_SLTCTL, PCI_EXP_RTCTL and PCI_EXP_RTSTA are + * also supported, but do not need to be handled here, because their + * values are stored in emulated config space buffer, and we read them + * from there when needed. */ case PCI_EXP_LNKCAP: { @@ -977,8 +975,25 @@ static int advk_sw_pci_bridge_init(struct advk_pcie *pcie) /* Support interrupt A for MSI feature */ bridge->conf.intpin = PCI_INTERRUPT_INTA; - /* Aardvark HW provides PCIe Capability structure in version 2 */ - bridge->pcie_conf.cap = cpu_to_le16(2); + /* + * Aardvark HW provides PCIe Capability structure in version 2 and + * indicate slot support, which is emulated. + */ + bridge->pcie_conf.cap = cpu_to_le16(2 | PCI_EXP_FLAGS_SLOT); + + /* + * Set Presence Detect State bit permanently since there is no support + * for unplugging the card nor detecting whether it is plugged. (If a + * platform exists in the future that supports it, via a GPIO for + * example, it should be implemented via this bit.) + * + * Set physical slot number to 1 since there is only one port and zero + * value is reserved for ports within the same silicon as Root Port + * which is not our case. + */ + bridge->pcie_conf.slotcap = cpu_to_le32(FIELD_PREP(PCI_EXP_SLTCAP_PSN, + 1)); + bridge->pcie_conf.slotsta = cpu_to_le16(PCI_EXP_SLTSTA_PDS); /* Indicates supports for Completion Retry Status */ bridge->pcie_conf.rootcap = cpu_to_le16(PCI_EXP_RTCAP_CRSVIS); -- 2.35.1