Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp735101imm; Thu, 31 May 2018 08:30:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK3YrWlzzTbz1spBujiUo4DKsiM33AGcUB4xcmtrfEsMKhfm0Kw/beuZc8IVdUVeoeJemhl X-Received: by 2002:a65:5c89:: with SMTP id a9-v6mr5879942pgt.51.1527780634577; Thu, 31 May 2018 08:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527780634; cv=none; d=google.com; s=arc-20160816; b=m/Nvo5HmOWlOeQ20XTdfe2+2RXf/VClIHu/kt6JPGsdNlOqxB1oyAckOcKAkxlNN8v v0bXR97dGN2iwsoW9oqaAh91Rdk/aKQf3PyWdRt9Ch33n1x5Z9L54e4SnvaBfhNu/Tjq oMjg+94NAFKNtlfOnrAVrVUl13qTqcMywbJ0PqpoDzcvk5i3ZooyvxVo6piYLMnKQAsA R9aEG78NHhZVNEi5qsuR02eeZZNL8tz+3WbNKgX6U7sq2zJKPzdpGpo9vyS5xQXML7ZN mmKK296z4Y/EqMgeSGdz3OcbdWBOljIL9rL8tWrJntuM2NpQGUguqAGF3qDgd+2w2/d8 7b3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=O966s70AcTh7DC6czRAZdwNJMNHKnEjG0wwpOFFYHow=; b=jPwkcTaVj+UW2r/lyPJSw1mvvbT8p55bbiQKwp0IuIGX+PvBOIwp3Ods0m+hBMvWXs 70H4c4/eqRUa9hpuAcn6f+2QW7XyPcmhPQSR5cYH3O7De93MIHlUnsNOeXSOKxjEV9hA kesgsk48CU+GKI6XG7uCf8JccDl96AwCzr68Q0hnklbldKfnW2E3tAOrPhM9Zl87lpcA r/0svJvEUZ+4ELxMILOpqji1iyuLOE5trjacvATegiV+qHPMxYuFVGlydaF1pC4/R4Xe fGuv1wc5OAJFb74lPhoQgAAjVa8C2K+e1TwuoXa4zS53hbFmfU1PvWooKkRVrvowk5nB cvKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=b1GoCQ1E; dkim=pass header.i=@codeaurora.org header.s=default header.b=b1GoCQ1E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a19-v6si3783283pfi.353.2018.05.31.08.29.56; Thu, 31 May 2018 08:30:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=b1GoCQ1E; dkim=pass header.i=@codeaurora.org header.s=default header.b=b1GoCQ1E; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755542AbeEaP2O (ORCPT + 99 others); Thu, 31 May 2018 11:28:14 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36320 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755421AbeEaP2K (ORCPT ); Thu, 31 May 2018 11:28:10 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 67578605FF; Thu, 31 May 2018 15:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527780490; bh=i9//Eu+g7xX9yWr7UNdd09I6HemaymP9fcXgc71ebeo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=b1GoCQ1ET7L/enNzuDKor7qHF0ZmaWisJtELT51YfUpC5JLK5pg38zNXMEsBd2xrJ KoNdf9bAxovm+t0XAzO4vDvR0NVnVqbBnvaLwcSlL3tF7Oqiq8SqlW/AAMn9ekGtts Q7ko66eynRFHTHXTxRKLkWHk9fdy867pGhn7yJRc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.235.228.150] (global_nat1_iad_fw.qualcomm.com [129.46.232.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: okaya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6664D60261; Thu, 31 May 2018 15:28:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527780490; bh=i9//Eu+g7xX9yWr7UNdd09I6HemaymP9fcXgc71ebeo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=b1GoCQ1ET7L/enNzuDKor7qHF0ZmaWisJtELT51YfUpC5JLK5pg38zNXMEsBd2xrJ KoNdf9bAxovm+t0XAzO4vDvR0NVnVqbBnvaLwcSlL3tF7Oqiq8SqlW/AAMn9ekGtts Q7ko66eynRFHTHXTxRKLkWHk9fdy867pGhn7yJRc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6664D60261 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=okaya@codeaurora.org Subject: Re: [PATCH] PCI: Check for PCIe downtraining conditions To: Alexandru Gagniuc , bhelgaas@google.com Cc: alex_gagniuc@dellteam.com, austin_bolen@dell.com, shyam_iyer@dell.com, keith.busch@intel.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org References: <20180531150535.9684-1-mr.nuke.me@gmail.com> From: Sinan Kaya Message-ID: <28004506-24f0-6d10-2d1e-074e0483d2f9@codeaurora.org> Date: Thu, 31 May 2018 11:28:07 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180531150535.9684-1-mr.nuke.me@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/31/2018 11:05 AM, Alexandru Gagniuc wrote: > +static void pcie_max_link_cap(struct pci_dev *dev, enum pci_bus_speed *speed, > + enum pcie_link_width *width) > +{ > + uint32_t lnkcap; > + > + pcie_capability_read_dword(dev, PCI_EXP_LNKCAP, &lnkcap); > + > + *speed = pcie_link_speed[lnkcap & PCI_EXP_LNKCAP_SLS]; > + *width = (lnkcap & PCI_EXP_LNKCAP_MLW) >> PCI_EXP_LNKCAP_MLW_SHIFT; > +} > + > +static void pcie_cur_link_sta(struct pci_dev *dev, enum pci_bus_speed *speed, > + enum pcie_link_width *width) > +{ > + uint16_t lnksta; > + > + pcie_capability_read_word(dev, PCI_EXP_LNKSTA, &lnksta); > + *speed = pcie_link_speed[lnksta & PCI_EXP_LNKSTA_CLS]; > + *width = (lnksta & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT; > +} > + > +static const char *pcie_bus_speed_name(enum pci_bus_speed speed) > +{ > + switch (speed) { > + case PCIE_SPEED_2_5GT: > + return "2.5 GT/s"; > + case PCIE_SPEED_5_0GT: > + return "5.0 GT/s"; > + case PCIE_SPEED_8_0GT: > + return "8.0 GT/s"; > + default: > + return "unknown"; > + } > +} I thought Bjorn added some functions to retrieve this now. -- Sinan Kaya Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm Technologies, Inc. Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.