Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp751265imm; Thu, 31 May 2018 08:47:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI+vYGDm7Q9vRZs/wuk1NHi+wX/C6DgIh0W/fEYulbCRuHO42EPkIZHva9oT+ccYFKlp+5N X-Received: by 2002:a62:d913:: with SMTP id s19-v6mr2711076pfg.39.1527781628626; Thu, 31 May 2018 08:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527781628; cv=none; d=google.com; s=arc-20160816; b=rWygYm9UOHJnOkGhmqI8NmRomGJns7xYZrqUldo4AYFfsdRdEPTmTPa2Utqd3Kt0Ql DdYD+Q6AclvgxXf4fULuKdV3p1Y/CC0P8l0Z2VGJwvv395rJuIBrguzaDYgzc044C7vS AkP7fw6Z+l8y5gZxR6veyah13HPbpblWAHLCDoaoO1gPuLFAb6w8hwJ6ht9mr+2TvRTL MaMeaDsCe0ID7Qvm6KpMkfAip2iJfPvRD+gE9DsI6hnZzOMKdkt8GKnar34xNyb3FYm2 IhlcimVNkDtt0j/AfWs15vgF3RDci/YCxcM/qELkZW8wobzGXTdIhiBeNhOfHRchGstz 9aVw== 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:dkim-signature :arc-authentication-results; bh=kHwtgZtdmmbgtV0DV/rbfR++APtiaIe/K9tIx/Z9u1E=; b=XPCCCwYuy5th17X+mSY72/n1WxxMvvaQB/nCHA+n3OXs+UjInLNDIjM9fxY8f6gfaI /CI7mRk8fYfgU7xh1xSo9gZKwI/9OKlGk+qobnXCgykfX7ph2p+WtJmDI3yDKNVBLpsw KDycFHn4f5sO6pYQSBFI5B8MT+LMXJ2HuFoBHAqYpBlSeoJPTBcE27kktyayyfxSDvyE kbEtkZ3CQrAsr+FleP6xDsZnUfujvkFE4VxJjmLri/Df32WVGagAY6BuRZSFQYH2gCGi KjNeTbNy7TYwlIw8ThsHPVtnBEzJwEq8PDCSoPxbZQ2OcgUZ8jn+eNmzoFwiu7BSsOmJ STpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=d5GZXfSj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9-v6si36829108pli.427.2018.05.31.08.46.54; Thu, 31 May 2018 08:47:08 -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=@gmail.com header.s=20161025 header.b=d5GZXfSj; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755550AbeEaPqX (ORCPT + 99 others); Thu, 31 May 2018 11:46:23 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:44199 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755417AbeEaPqR (ORCPT ); Thu, 31 May 2018 11:46:17 -0400 Received: by mail-io0-f196.google.com with SMTP id g7-v6so2451185ioh.11; Thu, 31 May 2018 08:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kHwtgZtdmmbgtV0DV/rbfR++APtiaIe/K9tIx/Z9u1E=; b=d5GZXfSjZUbbXWnyDmR/iEigXoUkvnjOCSA1Ck1L4b+AlBm6rjDEwwVKj0DKHTPUOP KVrH4xAnw8T3WChjbYpnmchrARj8TYDCybz8Nd6kgHVSAIHYIW5jdj6KMIpDUYwdM/4C KcYS5jQf+/P5doO4CLCdgdxDH0fykEM2pZbsk/Od0+cUH3Y497yNxTYiRRmE+8aNJQlj sCRw1+IAo2Eb3s4l5cvGXaYqxJdYiBxHVOGfxziA93/4FPXT90HuUa/S/akp111YuFH3 S13CgaTkHr3YjSzFEH1aTXB88/M+4UNWDYc9lXU+pvPQawcBDXk2O5pYIpj/dCkMIM7g sKkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kHwtgZtdmmbgtV0DV/rbfR++APtiaIe/K9tIx/Z9u1E=; b=XWYsLVXINKRrOMGxEBeLz1QVGxezdvZQcYJx7xmg1bkLTvyAQi6pRnknPqQraza6H1 ISkIQVvlFpSDbbcHbz9DuqTVgyyZicLRhjGxewns8Mrm0M8sRF7jc+kKnpARnNXXYOjo DokUlc5FYnTiD4hoJKK2Dhy0SKdjFiya/TE+vqZ7CL4P/4FJJMtyxfppzwxNUfXVWh4f JRbfAqDjnPQr+15SQkTV+tWGu1zNALVD0OBzOFqqLuUgrg+bOdTkcUI1BMvTAgFD+Iju ITkGJZj3MXmXrJGznZ+RMYz9EHzzQnWK0SsTFYSkdfWgB13OdQFKdMb6KhwpZroguLmH 7R9A== X-Gm-Message-State: APt69E1kYKKtLoiEQ1yzEvP53kr1jKXh04hSekzemJ7qSOAT8RDYM1OO 4ckDV0/VE2rSrda0HsOGZTe14Dwg5Ug= X-Received: by 2002:a6b:690b:: with SMTP id e11-v6mr7668447ioc.242.1527781576767; Thu, 31 May 2018 08:46:16 -0700 (PDT) Received: from nuclearis2_1.gtech (c-98-201-114-184.hsd1.tx.comcast.net. [98.201.114.184]) by smtp.gmail.com with ESMTPSA id e189-v6sm328947ioe.0.2018.05.31.08.46.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 31 May 2018 08:46:16 -0700 (PDT) Subject: Re: [PATCH] PCI: Check for PCIe downtraining conditions To: Sinan Kaya , Alex_Gagniuc@Dellteam.com, bhelgaas@google.com Cc: 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> <28004506-24f0-6d10-2d1e-074e0483d2f9@codeaurora.org> <4e0611c872054e768daa96b302651db3@ausx13mps321.AMER.DELL.COM> From: "Alex G." Message-ID: <3b8a895b-3080-7ddb-cbfd-5aa972e9bf65@gmail.com> Date: Thu, 31 May 2018 10:46:07 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: 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 05/31/2018 10:38 AM, Sinan Kaya wrote: > On 5/31/2018 11:29 AM, Alex_Gagniuc@Dellteam.com wrote: >> On 5/31/2018 10:28 AM, Sinan Kaya wrote: >>> 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. >> >> Hmm. I couldn't find them. > > https://lkml.org/lkml/2018/3/30/553 Oh, pcie_get_speed_cap()/pcie_get_width_cap() seems to handle the capability. Not seeing one for status and speed name. > are you working on linux-next? v4.17-rc7 >> >> Alex >> >> > >