Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp779240imm; Thu, 31 May 2018 09:14:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLn51AN63bdBbSBhfU0cdHK4CtHsy5DdkzF7EyOptm37aJxYTvfpJamXsLv4ua+NGJRmhhc X-Received: by 2002:a17:902:9349:: with SMTP id g9-v6mr7331923plp.375.1527783274742; Thu, 31 May 2018 09:14:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527783274; cv=none; d=google.com; s=arc-20160816; b=lCr4pSVokdSHq/wWLJIQvKVhTQpTh5nWBEgHWEACnl9b/kz9QOwnNpQd44zP8TR3Zr LBXTu7QGOeRm/FGTaZ9uTzdpBCG+0BtyhDVqs3MO06ukL054E8v0epnslYgel0tgByjo CHSexNmEKml0HDp67aefhoBlQzKG8XoIRPCqnC6+9sBFbjjGAzpYO8dMmRQOqRELafOj bjTg+JH87Xc/9dpCiA9zbOJnb2fccqt32RT/LMg3yLH2AE9LxHKjeSss/e8FNdvTNpOh 7GR20MQtf1sa0UPmhiinGVhYLu6jDEViqcfN2mh6JQ3RyK06UEcY6ZzQ2ASIJpXcdpI5 fKyA== 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=STbkhXdHMQBQbVOy7UkDrSncdwJV3Ox2lxxjVeZKGdg=; b=gk/ZdaOyp7j1TeKADbdJOIMB1QgyckrrmJo4OcK0QbluIFuRouJWM7BmGsKpMgRuuL bWsPvepK0IWWnQK0p3hsaJ9jGxOGdGd8cRtOaqk65gw35bL4FRit2WhQWZah2/VEbRpD RXOxV3Hw6Yp9Ee77NqkteddRRfDJbXMIL06T2QjIzClgFJNo1CtHExtBP2pa0QqW2pmx IwceF0Pbh2if0zEVDnUIA6Tu3C6j0xnx4y2hh8xV2ftbNDpMg3Qa6cEZHTJa+Heuu6jw vVYniTz2bPIz30zQs0McUsG1YZMUcekrYU4f15xlzZQXQZ+ldOzaJiZcGZXHaJBGbvgI qVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=DEs9gOgF; dkim=pass header.i=@codeaurora.org header.s=default header.b=DEs9gOgF; 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 p18-v6si29594937pgv.493.2018.05.31.09.14.20; Thu, 31 May 2018 09:14: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=DEs9gOgF; dkim=pass header.i=@codeaurora.org header.s=default header.b=DEs9gOgF; 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 S1755583AbeEaQN4 (ORCPT + 99 others); Thu, 31 May 2018 12:13:56 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35308 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755456AbeEaQNy (ORCPT ); Thu, 31 May 2018 12:13:54 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8D25B605FF; Thu, 31 May 2018 16:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527783233; bh=du9pHJvLC0BXZ31KTw0PUQZf783Wv20Q9mKOt+OnUA8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DEs9gOgFWtW+C7O1+s/ZB9rP6SQSecxTqruMvy9moD9VGUi9zrwvU3YuB9P1BrMYS bXR+p7YoxxautLEHZimiaVUR9LcrMnOWoabGrFHUA/lvrJ06IHWTtwtwa+qrerV0kh N2QIu0vcX1QJ8A3/6FKMAo+PfI63755PtCEKTXtY= 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 3DC31602A8; Thu, 31 May 2018 16:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1527783233; bh=du9pHJvLC0BXZ31KTw0PUQZf783Wv20Q9mKOt+OnUA8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DEs9gOgFWtW+C7O1+s/ZB9rP6SQSecxTqruMvy9moD9VGUi9zrwvU3YuB9P1BrMYS bXR+p7YoxxautLEHZimiaVUR9LcrMnOWoabGrFHUA/lvrJ06IHWTtwtwa+qrerV0kh N2QIu0vcX1QJ8A3/6FKMAo+PfI63755PtCEKTXtY= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3DC31602A8 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: "Alex G." , 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> <3b8a895b-3080-7ddb-cbfd-5aa972e9bf65@gmail.com> <35563ce3-e235-096c-4b9b-5f3664d67d0f@codeaurora.org> <093b2789-39a1-db9e-5783-b0488b3c9ccd@gmail.com> From: Sinan Kaya Message-ID: <32d58835-2f35-0b80-38d0-b9ff603619dd@codeaurora.org> Date: Thu, 31 May 2018 12:13:51 -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: <093b2789-39a1-db9e-5783-b0488b3c9ccd@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 12:01 PM, Alex G. wrote: >> PCI: Add pcie_print_link_status() to log link speed and whether it's limited > This one, I have, but it's not what I need. This looks at the available > bandwidth from root port to endpoint, whereas I'm only interested in > downtraining between endpoint and upstream port. I see what you are saying. With a little bit of effort, you can reuse the same code. Here is an attempt. You can probably extend pcie_bandwidth_available() to put an optional parent bridge device for your own use case and terminate the loop around here. https://elixir.bootlin.com/linux/v4.17-rc7/source/drivers/pci/pci.c#L5182 Then, you can use the existing code to achieve what you are looking for via pcie_print_link_status() by adding an optional parent parameter. bw_cap = pcie_bandwidth_capable(dev, &speed_cap, &width_cap); bw_avail = pcie_bandwidth_available(dev, &limiting_dev, &speed, &width, *parent*); If parent parameter is NULL, code can walk all the way to root as it is doing today. If it is not, then will terminate the loop on the first iteration. -- 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.