Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp742742pxb; Fri, 16 Apr 2021 17:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwad2wG7TQUfBRx1bMy8jB5RJ1d0BrVyOoTL6sngINy8kOD28A5l5AF/tt8klP0usQ0/ATi X-Received: by 2002:a05:6402:17c6:: with SMTP id s6mr13099086edy.319.1618620530802; Fri, 16 Apr 2021 17:48:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618620530; cv=none; d=google.com; s=arc-20160816; b=Q+cY7HC3KG8H9stitYApYm0+9a+IG1ldFfaefzWjN+heJvuIbCK7yxEFL0Q3C7Rd8r vuCg/j/Zp9VA/+T30afljM4MDBWx5FIomMC2DRPQpK/gwgG4Ayd+eFITyJppNobNf+pa kLpzm887ThSTP1bbvKxkM7iqmwWjXirZVi47VLr4taoz/Eh8eZLHqymR63q1Pe6AybHl ooDLLAosoZojf6SYpxL6IiMOds/InYSXX0OCSucpxPL0FxkNbO0t7O0aAVsFJm4C13iN X8d3LEE0qEvfrPznKb4Lth4hgm+XWrhAzR7o1hJhGp2MWw6aDw/l4TJGIn8IW9AoSxCk EyxQ== 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 :user-agent:message-id:date:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=2RpvHmQvOF1w3NNeIwiBJQiE0fnddZNGdDNHZripnhA=; b=E4mok7Vuyah+7IT0ojfyMdoKZIwx6pN+jNFMbII4GU0DD69K5P8k9c+aw4Qh1/1KfV 60ShbMwLJQpdDzeZ7V+rGuCgE/CaUF567o17m16zvTjTvOQ0Ss7g7ndzRgeG92I/qf9Z y5nxH5XBocu2W7EttT9tsfIt+5Us2014vOJ5t65eGD8053sySgOCHPmK0hK6FopqUsR6 WoJt15ApuqIzlFRXtpJszzPt/TjYjii6shVZYslxZQKFrQiRmKCcrZyywg7UtmF1lca8 lLK6SyBIG64zueuhdve1tVL8fXiDnP24fp4XKyGUKZmhz4UlZm04rxj08an+wJzjz2uw aOew== 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 c30si6746005edf.213.2021.04.16.17.48.25; Fri, 16 Apr 2021 17:48:50 -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 S235230AbhDQAn6 (ORCPT + 99 others); Fri, 16 Apr 2021 20:43:58 -0400 Received: from mga11.intel.com ([192.55.52.93]:6137 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbhDQAn6 (ORCPT ); Fri, 16 Apr 2021 20:43:58 -0400 IronPort-SDR: dtx5NJtdtXEwD5q8309UjZZzHCXkB+B6M8/B4CPmcAPnoS5sKA1dF1ONyuSfRL39l/DU32pE3E 3YLf13Uhb/aA== X-IronPort-AV: E=McAfee;i="6200,9189,9956"; a="191945091" X-IronPort-AV: E=Sophos;i="5.82,228,1613462400"; d="scan'208";a="191945091" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 17:43:31 -0700 IronPort-SDR: U0HwynFJN13frkFgYFNfwQPVWtRdY+KYaNF7l9ODADqWQIyzW5rc0qAq06K/bsDSg6zWO0R1ls gJ9XA08qrveg== X-IronPort-AV: E=Sophos;i="5.82,228,1613462400"; d="scan'208";a="419317971" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.25]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 Apr 2021 17:43:30 -0700 Subject: [PATCH] cxl/mem: Fix memory device capacity probing From: Dan Williams To: linux-cxl@vger.kernel.org Cc: Ben Widawsky , linux-kernel@vger.kernel.org, vishal.l.verma@intel.com Date: Fri, 16 Apr 2021 17:43:30 -0700 Message-ID: <161862021044.3259705.7008520073059739760.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The CXL Identify Memory Device output payload emits capacity in 256MB units. The driver is treating the capacity field as bytes. This was missed because QEMU reports bytes when it should report bytes / 256MB. Fixes: 8adaf747c9f0 ("cxl/mem: Find device capabilities") Cc: Ben Widawsky Signed-off-by: Dan Williams --- drivers/cxl/mem.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c index 1b5078311f7d..2acc6173da36 100644 --- a/drivers/cxl/mem.c +++ b/drivers/cxl/mem.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -1419,6 +1420,7 @@ static int cxl_mem_enumerate_cmds(struct cxl_mem *cxlm) */ static int cxl_mem_identify(struct cxl_mem *cxlm) { + /* See CXL 2.0 Table 175 Identify Memory Device Output Payload */ struct cxl_mbox_identify { char fw_revision[0x10]; __le64 total_capacity; @@ -1447,10 +1449,11 @@ static int cxl_mem_identify(struct cxl_mem *cxlm) * For now, only the capacity is exported in sysfs */ cxlm->ram_range.start = 0; - cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) - 1; + cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) * SZ_256M - 1; cxlm->pmem_range.start = 0; - cxlm->pmem_range.end = le64_to_cpu(id.persistent_capacity) - 1; + cxlm->pmem_range.end = + le64_to_cpu(id.persistent_capacity) * SZ_256M - 1; memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));