From patchwork Thu Apr 15 23:26:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 1466794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4FLwTD0LSlz9sVb for ; Fri, 16 Apr 2021 09:26:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237762AbhDOX0q (ORCPT ); Thu, 15 Apr 2021 19:26:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:7826 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237756AbhDOX0p (ORCPT ); Thu, 15 Apr 2021 19:26:45 -0400 IronPort-SDR: IxQPiblq7NKmtC7U4nMp7rxv24m5zhkX3PU6biTdMPRRn3eQf+iZQ8lAvxGYBkMXXMTnkTLSBi sWaAescTqjXg== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="280279113" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="280279113" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:19 -0700 IronPort-SDR: 00aMwu4UlW9fnUV8MBvABkj1YdCXaV6Rg3y8GVTloR8Z3+GSonkXvtCHK2E0IKCgdb6D8NnMjw gMatbJHw+QzQ== X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="522540082" Received: from oamoninu-mobl1.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.130.91]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:18 -0700 From: Ben Widawsky To: linux-cxl@vger.kernel.org Cc: Ben Widawsky , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] cxl/mem: Fix register block offset calculation Date: Thu, 15 Apr 2021 16:26:08 -0700 Message-Id: <20210415232610.603273-1-ben.widawsky@intel.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The offset for the register block should be a 64K aligned value, and therefore FIELD_GET (which will shift) is not correct for the calculation. From 8.1.9.1 of the CXL 2.0 spec: A[31:16] of offset from the address contained by one of the Function's Base Address Registers to point to the base of the Register Block. Register Block Offset is 64K aligned. Hence A[15:0] is zero Fix this by simply using a mask. This wasn't found earlier because the primary development done in the QEMU environment only uses 0 offsets Fixes: 8adaf747c9f0b ("cxl/mem: Find device capabilities") Reported-by: Vishal Verma Signed-off-by: Ben Widawsky --- drivers/cxl/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index e3003f49b329..1b5078311f7d 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -998,7 +998,7 @@ static struct cxl_mem *cxl_mem_create(struct pci_dev *pdev, u32 reg_lo, return NULL; } - offset = ((u64)reg_hi << 32) | FIELD_GET(CXL_REGLOC_ADDR_MASK, reg_lo); + offset = ((u64)reg_hi << 32) | (reg_lo & CXL_REGLOC_ADDR_MASK); bar = FIELD_GET(CXL_REGLOC_BIR_MASK, reg_lo); /* Basic sanity check that BAR is big enough */ From patchwork Thu Apr 15 23:26:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 1466795 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4FLwTD2qcKz9sW4 for ; Fri, 16 Apr 2021 09:26:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237768AbhDOX0q (ORCPT ); Thu, 15 Apr 2021 19:26:46 -0400 Received: from mga05.intel.com ([192.55.52.43]:7828 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237758AbhDOX0p (ORCPT ); Thu, 15 Apr 2021 19:26:45 -0400 IronPort-SDR: kgos/+aVUlEvwpcQwBUuR4ZLTHKFDLjz7pkzP1quqot6xGFC6yfAGt3QZJT0pWm1E6gU+5bM6E R9s23xmcJvTg== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="280279116" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="280279116" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:20 -0700 IronPort-SDR: jmV1F1lTCchcfeqtPxoAsAoMWKCxgOr36x6JvwRMls9G4IEE1ovyl1WmdwK4D83gIa7Jj+ntGE eRPPl+QuflmA== X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="522540092" Received: from oamoninu-mobl1.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.130.91]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:19 -0700 From: Ben Widawsky To: linux-cxl@vger.kernel.org Cc: Ben Widawsky , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] cxl/mem: Print unknown capability IDs as hex Date: Thu, 15 Apr 2021 16:26:09 -0700 Message-Id: <20210415232610.603273-2-ben.widawsky@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415232610.603273-1-ben.widawsky@intel.com> References: <20210415232610.603273-1-ben.widawsky@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Trivial. The spec lists these as hex, so do the same here to make debugging easier. Fixes: 8adaf747c9f0b ("cxl/mem: Find device capabilities") Signed-off-by: Ben Widawsky --- drivers/cxl/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 1b5078311f7d..c05617b0ba4b 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -939,7 +939,7 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm) cxlm->memdev_regs = register_block; break; default: - dev_dbg(dev, "Unknown cap ID: %d (0x%x)\n", cap_id, offset); + dev_dbg(dev, "Unknown cap ID: %x (0x%x)\n", cap_id, offset); break; } } From patchwork Thu Apr 15 23:26:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Widawsky X-Patchwork-Id: 1466796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4FLwTD4qxPz9sWK for ; Fri, 16 Apr 2021 09:26:24 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237779AbhDOX0r (ORCPT ); Thu, 15 Apr 2021 19:26:47 -0400 Received: from mga05.intel.com ([192.55.52.43]:7828 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236674AbhDOX0q (ORCPT ); Thu, 15 Apr 2021 19:26:46 -0400 IronPort-SDR: 6w+CmnceWvY+qgU9OHYOP2QMyKEbKJwuDXs1s3m0jGb2s0cJgVEsUqSlek/Ss9Boh9fNbqljCG c4zCY3oajL1g== X-IronPort-AV: E=McAfee;i="6200,9189,9955"; a="280279117" X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="280279117" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:20 -0700 IronPort-SDR: vBd27/QSGH/VbkxNXnXmPcAJGrONBrIKlgbJfWxWtHiuaMGq0QBrc2L7/v2PwkHCyEKGjueFDo wcL47sPimiPA== X-IronPort-AV: E=Sophos;i="5.82,226,1613462400"; d="scan'208";a="522540100" Received: from oamoninu-mobl1.amr.corp.intel.com (HELO bwidawsk-mobl5.local) ([10.252.130.91]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2021 16:26:20 -0700 From: Ben Widawsky To: linux-cxl@vger.kernel.org Cc: Ben Widawsky , linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, ira.weiny@intel.com, vishal.l.verma@intel.com, alison.schofield@intel.com, dan.j.williams@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] cxl/mem: Demarcate vendor specific capability IDs Date: Thu, 15 Apr 2021 16:26:10 -0700 Message-Id: <20210415232610.603273-3-ben.widawsky@intel.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210415232610.603273-1-ben.widawsky@intel.com> References: <20210415232610.603273-1-ben.widawsky@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Vendor capabilities occupy 0x8000 to 0xFFFF according to CXL 2.0 spec 8.2.8.2.1 CXL Device Capabilities. While they are not defined by the spec, they are allowed and not "unknown". Call this detail out in the logs to let users easily distinguish the difference. Fixes: 8adaf747c9f0b ("cxl/mem: Find device capabilities") Signed-off-by: Ben Widawsky --- drivers/cxl/mem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index c05617b0ba4b..0909f73db994 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -939,7 +939,10 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm) cxlm->memdev_regs = register_block; break; default: - dev_dbg(dev, "Unknown cap ID: %x (0x%x)\n", cap_id, offset); + if (cap_id > 0x8000) + dev_dbg(dev, "Vendor cap ID: %x (0x%x)\n", cap_id, offset); + else + dev_dbg(dev, "Unknown cap ID: %x (0x%x)\n", cap_id, offset); break; } }