Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp1190625pxb; Thu, 15 Apr 2021 16:56:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvTmV3J1ZGZryepDE6Z1evg8GOWjY57fMD826d4g+h8xPd4C4et+qTAuXrCokKOKd28YpW X-Received: by 2002:a17:906:dc92:: with SMTP id cs18mr6078385ejc.27.1618530961555; Thu, 15 Apr 2021 16:56:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618530961; cv=none; d=google.com; s=arc-20160816; b=vUPF9+tjlFZZD9Nx/h0hn+B2RAx//Bwo6RsAU2W/vlrNJVdqYt+sTCKi3EsIv0q532 GYFfYu8Hd1Q9GjUTd3dLCm9JCkaBsm8/SAyizPvx75BvLguaqlc5TDtIB0AIEyXpavJo Mbzwslc01VWK0Ivp4jpaCWY6ydgg2pA4EC5J8guSH8MIzB/WYw7PD4H8PVulgJnXgPNB kRTZVQMf9rNjHGc0BGwXo4aY9oqHzOTqVjG2lyfMDLddvSyH4gTN7Yci378B/KkqCsbu X/KsGPJfvF+drXmUpLzkKVDcWMKln1tlZ2YoF8htRxsUdsuEo6Al8AgJcuVLpy6bToe3 JBsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=FKTb6sZVZD8KMDRWddE3l03uLaMBnp+wRUXBWLLoS8Y=; b=byviAWEeA6IJ0rCFwLcuwrwmft9JCJXn8S0hs3qO1IjafierdzaRSdxt0n6mi7VIeJ IRgg1JZnEnqFE6qimSz2r0kwTe6AywUMTdwVgfoGVliGoRx2B01RKyeNsmM8PaLb4HsF uyvEhcxL+rXDICvHv/Egrt+Mn5pozEtjCBqRmRmEpx+r8z2Y8dVi/V9plAVsbzj+/28g VPapngbi4tEdUBztheQG/SFEXDD2EC9mUkHt0uCIf+hv82MkaoY1gVvTs/pNHzG4oZui QVJSwm/IN89U67f5Ha/suWTi3xmXpMkE842r5D1cXJjDeBpOrDC0O2OcvFxG7YlsLOaT dwKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n11si3450182edi.273.2021.04.15.16.55.38; Thu, 15 Apr 2021 16:56:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237764AbhDOX0q (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 */ -- 2.31.1