Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2646366ybc; Mon, 18 Nov 2019 02:25:37 -0800 (PST) X-Google-Smtp-Source: APXvYqyG91fupcwfM/AhpashH0fiAooHK9t3mJhtuJfE2s6d2yvgzaIuwEbCMv1a/1qIUJVu3IDq X-Received: by 2002:a17:906:f90d:: with SMTP id lc13mr25551758ejb.154.1574072737310; Mon, 18 Nov 2019 02:25:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574072737; cv=none; d=google.com; s=arc-20160816; b=fg7BKjAF/dPQg9SZ4JaNAP71LU3pkOR9UqmrUQOSAlqbPKSzgcxNUTfC4r2tGlS+mY /Xx0dhkPXgJYFtIKN+TkhGhDjJeCIjZ04cTUKSMfCpGtzvc/nlCpVOxdPY/z4HeXZxOm KL4Cb+TlW51nyfbDDbWyoy5NECMqyO7EeYG/Gy3tQdEHdzX7Y5CzIou502o+j/7OeSRZ 4wt9o6D6Sn7sa6m+Mhmk8IRHLKs7xopVKqp782qp45BCInV+xOMcQunGsftGA8JVsZGC cVWUx1sT/tzJ8e2D5d/+CvbsHVhlNz6mifC5wCqfnFakny57lGs0LaG9bkm2iX0DVcnU IZiA== 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; bh=4fFGbbmJSsJDE/UYgH0ePHRqLQ/gGGqveSqqhIRcvrg=; b=hxyXs9lQ+wMoTmGIG0Lf1vzBnNCgGLFCmZnjaE0jAAB3+Z+UHN0MUimrc8bsniBzxU 1oP8ilgP3g2kVIwh192ZPJi8BZVH5kjwBKmsqubHqSx/zCYiFR3xoUGmt3hbB1oTa/cO klviOCzaynkqTbta/lrFgf2MbZJk1pcWrKxIjXn0Hm4Rdk3KawK/Va0xDFauWMzImQo1 6pGzMveKjqtx1hkQ2j89pvKMFG+HiYq1+e+6tXIoVaWhO+q+s0jTLBUOpppib4U9ldl6 MmDekKo+tysRH9bXIFgUGIznPuKCy5jy9eiZSVCwEl8pNlYHJYwjvMpZ3JTeEaVSPkio V3eQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si9783506edx.271.2019.11.18.02.25.13; Mon, 18 Nov 2019 02:25:37 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=hygon.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbfKRKYE (ORCPT + 99 others); Mon, 18 Nov 2019 05:24:04 -0500 Received: from spam01.hygon.cn ([110.188.70.11]:50976 "EHLO spam1.hygon.cn" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726461AbfKRKYE (ORCPT ); Mon, 18 Nov 2019 05:24:04 -0500 Received: from MK-FE.hygon.cn ([172.23.18.61]) by spam1.hygon.cn with ESMTP id xAIAKXCl085098; Mon, 18 Nov 2019 18:20:33 +0800 (GMT-8) (envelope-from linjiasen@hygon.cn) Received: from cncheex01.Hygon.cn ([172.23.18.10]) by MK-FE.hygon.cn with ESMTP id xAIAKNwP014116; Mon, 18 Nov 2019 18:20:23 +0800 (GMT-8) (envelope-from linjiasen@hygon.cn) Received: from [172.20.21.12] (172.23.18.44) by cncheex01.Hygon.cn (172.23.18.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1466.3; Mon, 18 Nov 2019 18:20:28 +0800 Subject: Re: [PATCH] NTB: Fix an error in get link status To: Jon Mason CC: "S-k, Shyam-sundar" , Dave Jiang , Allen Hubbe , linux-kernel , linux-ntb , References: <1573119336-107732-1-git-send-email-linjiasen@hygon.cn> From: Jiasen Lin Message-ID: <933f74c7-7249-618c-13dc-9e4e47ad75d7@hygon.cn> Date: Mon, 18 Nov 2019 18:17:38 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.23.18.44] X-ClientProxiedBy: cncheex01.Hygon.cn (172.23.18.10) To cncheex01.Hygon.cn (172.23.18.10) X-MAIL: spam1.hygon.cn xAIAKXCl085098 X-DNSRBL: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/11/18 7:00, Jon Mason wrote: > On Thu, Nov 7, 2019 at 4:37 AM Jiasen Lin wrote: >> >> The offset of PCIe Capability Header for AMD and HYGON NTB is 0x64, >> but the macro which named "AMD_LINK_STATUS_OFFSET" is defined as 0x68. >> It is offset of Device Capabilities Reg rather than Link Control Reg. >> >> This code trigger an error in get link statsus: >> >> cat /sys/kernel/debug/ntb_hw_amd/0000:43:00.1/info >> LNK STA - 0x8fa1 >> Link Status - Up >> Link Speed - PCI-E Gen 0 >> Link Width - x0 >> >> This patch use pcie_capability_read_dword to get link status. >> After fix this issue, we can get link status accurately: >> >> cat /sys/kernel/debug/ntb_hw_amd/0000:43:00.1/info >> LNK STA - 0x11030042 >> Link Status - Up >> Link Speed - PCI-E Gen 3 >> Link Width - x16 > > No response from AMD maintainers, but it looks like you are correct. > > This needs a "Fixes:" line here. I took the liberty of adding one to > this patch. > Thank you for your suggestions. Yes, this patch fix the commit id: a1b3695 ("NTB: Add support for AMD PCI-Express Non-Transparent Bridge"). >> Signed-off-by: Jiasen Lin >> --- >> drivers/ntb/hw/amd/ntb_hw_amd.c | 5 +++-- >> drivers/ntb/hw/amd/ntb_hw_amd.h | 1 - >> 2 files changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c >> index 156c2a1..ae91105 100644 >> --- a/drivers/ntb/hw/amd/ntb_hw_amd.c >> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c >> @@ -855,8 +855,8 @@ static int amd_poll_link(struct amd_ntb_dev *ndev) >> >> ndev->cntl_sta = reg; >> >> - rc = pci_read_config_dword(ndev->ntb.pdev, >> - AMD_LINK_STATUS_OFFSET, &stat); >> + rc = pcie_capability_read_dword(ndev->ntb.pdev, >> + PCI_EXP_LNKCTL, &stat); >> if (rc) >> return 0; >> ndev->lnk_sta = stat; >> @@ -1139,6 +1139,7 @@ static const struct ntb_dev_data dev_data[] = { >> static const struct pci_device_id amd_ntb_pci_tbl[] = { >> { PCI_VDEVICE(AMD, 0x145b), (kernel_ulong_t)&dev_data[0] }, >> { PCI_VDEVICE(AMD, 0x148b), (kernel_ulong_t)&dev_data[1] }, >> + { PCI_VDEVICE(HYGON, 0x145b), (kernel_ulong_t)&dev_data[0] }, > > This should be a separate patch. I took the liberty of splitting it > off into a unique patch and attributing it to you. I've pushed them > to the ntb-next branch on > https://github.com/jonmason/ntb > Thank you for your comment. We appreciate the time and effort you have spent to split it off, I will test it ASAP. > Please verify everything looks acceptable to you (given the changes I > did above that are attributed to you). Also, testing of the latest > code is always appreciated. > > Thanks, > Jon > > >> { 0, } >> }; >> MODULE_DEVICE_TABLE(pci, amd_ntb_pci_tbl); >> diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.h b/drivers/ntb/hw/amd/ntb_hw_amd.h >> index 139a307..39e5d18 100644 >> --- a/drivers/ntb/hw/amd/ntb_hw_amd.h >> +++ b/drivers/ntb/hw/amd/ntb_hw_amd.h >> @@ -53,7 +53,6 @@ >> #include >> >> #define AMD_LINK_HB_TIMEOUT msecs_to_jiffies(1000) >> -#define AMD_LINK_STATUS_OFFSET 0x68 >> #define NTB_LIN_STA_ACTIVE_BIT 0x00000002 >> #define NTB_LNK_STA_SPEED_MASK 0x000F0000 >> #define NTB_LNK_STA_WIDTH_MASK 0x03F00000 >> -- >> 2.7.4 >> >> -- >> You received this message because you are subscribed to the Google Groups "linux-ntb" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to linux-ntb+unsubscribe@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/msgid/linux-ntb/1573119336-107732-1-git-send-email-linjiasen%40hygon.cn. Thanks, Jiasen Lin