Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2141851ybc; Sun, 17 Nov 2019 15:03:35 -0800 (PST) X-Google-Smtp-Source: APXvYqyaRABikAOUH5ok70mpQSjN95cf4H9R7j1pOQP1awHgxUh5mE6eFOemtQUq2QQLqvlkzL38 X-Received: by 2002:a17:906:1d41:: with SMTP id o1mr22124754ejh.333.1574031815577; Sun, 17 Nov 2019 15:03:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574031815; cv=none; d=google.com; s=arc-20160816; b=Zc3miFtzrSKWdPwqcgXU30UDeMqv8b6SOSA17VaZ6BPQqEWmbr+r9X2QSYumns8RlP C1QJ5eO2OdUTaYbFn5G3mYQfCdsLtCKhROL6d02rVIlt38ibW+4o0sRvdHUeOF9hgJ9i rh7SXbkhzUd/A0Bma1DJ1nudyO0JmC6lfWpIlY6oXVNgKZDz099RK8PWi4/Feivs9mir mqNYK5XSKX6azDSG3NsysYp0aBVvfX6nYoO9MDyHS+H6IJ+Ut2zGJeeDmmqazfr5wRVb uqKfJsOXOKQyI66dTKhQgHVtVB/+qDVt0IZEBV4htzVRPg+w65O/XbkQgu6NmAXtEW1p dEJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=d/1Y1QsI93gAHAKWqh4KEcte8aqnaRPIZE1b5kmVqj0=; b=T18Wn2d8Z9poNU9x+dTgrmIhKSsmQmdn9I4v3BRzHeBVqH7qe9bP9fzH+lm48Iz1Y4 CP6sYieW2FHBy6uq40+gnGFa3iKNtQKhfe4fA1CCUCSMwLrOELZHmuvoX+H+fPtdNN5q BDRnZm+OT+bAaoVVjxPcUtkM3C1FifNUQzSD8T4MtTKcVzdC/W/7OSTk8lrJWAsfD1SE rB6dCtsOJrECSHTECNnOrlwF+hOjmYJWr0+T12TPVbZV3tk8DaHjPjd3z8bs8nzii8Jq ejgqUm4N6r8oy7DVh4cK7vOY5ohiK6+xzEVItGXBMc6QuWsIBKY1EN4MKQrndx1RFOOg 2FnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=0+akr7oq; 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 w19si12741482edd.51.2019.11.17.15.03.11; Sun, 17 Nov 2019 15:03:35 -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; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=0+akr7oq; 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 S1726423AbfKQXAc (ORCPT + 99 others); Sun, 17 Nov 2019 18:00:32 -0500 Received: from mail-il1-f193.google.com ([209.85.166.193]:43199 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbfKQXAc (ORCPT ); Sun, 17 Nov 2019 18:00:32 -0500 Received: by mail-il1-f193.google.com with SMTP id r9so14230816ilq.10 for ; Sun, 17 Nov 2019 15:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kudzu-us.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d/1Y1QsI93gAHAKWqh4KEcte8aqnaRPIZE1b5kmVqj0=; b=0+akr7oqEpeSO2u3AMLVbtvvWyYay1wmJK9jgvoxAvQHfv6K0sf07DlcIcnsrq9TT4 yEYe3e9WgTta6rK2pHa1RQJzSonqANR2Pu62/k522iBij0i3EX1MsfVSJgHfIIk6iq9Q 2e3hlLPWuGiveuqjs+9Xi3E/ElfVs5vmilEMN7HgTo/VTH0cJp0Ktb9LCZ84B4LbSoKQ lh8l0cKzQKJ2OYfcyJJq8TU6aC5/WXnK/oz2cn1W/5gLamgrSGUehMTdliEVx13cnD76 CTmxp1cHU6tL6gO0eHgBD+ziLaMOvLo0OOAzrCkFhdN5xe/rggFHr88x5FoZzRuBBiVj qdaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d/1Y1QsI93gAHAKWqh4KEcte8aqnaRPIZE1b5kmVqj0=; b=oLBKQash+F00twJNVmLgQ8CS/lG+F2MFBJjwFFX8cZ8U9nz2ryIKqdPt2s+HJFlUUR jwUU4I/RgPdCdBYhYNGAGLY+WoVeOtVEu65n9UxFE0rbymAb3pjMuGeAXhlJ9NylxQ4y B1RkGJ57Djy4OaWjuUKycZBpRUkBQjKeuHMUUF6I0LXk4Ub7wt/2R+YADJSgzazn41jz BJerlbIjvf1ShnXA7VUyyRbdtl4I514hVuIryV8grrYF/B8O6EXNwK6ZGBcgpO/T6J3b 6L9joevVPsuYmnuO1h/pe6rvp/2MqRxONxBRPpNCQIiLHciP9XySS2E/zIiSTtlo+Lgo bMsw== X-Gm-Message-State: APjAAAX2EUAzxpLbCH6EqA7/G8lCjsx/XKxrxNcH9DsclNz1HAB1StgG oCxhJGINJWDNltoUYKRu3BJZy167AIc200RwLLhlFw== X-Received: by 2002:a92:46c9:: with SMTP id d70mr11936574ilk.159.1574031631207; Sun, 17 Nov 2019 15:00:31 -0800 (PST) MIME-Version: 1.0 References: <1573119336-107732-1-git-send-email-linjiasen@hygon.cn> In-Reply-To: <1573119336-107732-1-git-send-email-linjiasen@hygon.cn> From: Jon Mason Date: Sun, 17 Nov 2019 18:00:17 -0500 Message-ID: Subject: Re: [PATCH] NTB: Fix an error in get link status To: Jiasen Lin Cc: "S-k, Shyam-sundar" , Dave Jiang , Allen Hubbe , linux-kernel , linux-ntb , linjiasen007@gmail.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > 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 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.