pci.c (5b68705d1e6340127464ef0ac0e1de94f823f14e) pci.c (0b9159d0ff21bc281dbb9ede06ad566330ac0943)
1// SPDX-License-Identifier: GPL-2.0-only
2/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
3#include <uapi/linux/cxl_mem.h>
4#include <linux/security.h>
5#include <linux/debugfs.h>
6#include <linux/module.h>
7#include <linux/sizes.h>
8#include <linux/mutex.h>

--- 50 unchanged lines hidden (view full) ---

59 CXL_MBOX_OP_INJECT_POISON = 0x4301,
60 CXL_MBOX_OP_CLEAR_POISON = 0x4302,
61 CXL_MBOX_OP_GET_SCAN_MEDIA_CAPS = 0x4303,
62 CXL_MBOX_OP_SCAN_MEDIA = 0x4304,
63 CXL_MBOX_OP_GET_SCAN_MEDIA = 0x4305,
64 CXL_MBOX_OP_MAX = 0x10000
65};
66
1// SPDX-License-Identifier: GPL-2.0-only
2/* Copyright(c) 2020 Intel Corporation. All rights reserved. */
3#include <uapi/linux/cxl_mem.h>
4#include <linux/security.h>
5#include <linux/debugfs.h>
6#include <linux/module.h>
7#include <linux/sizes.h>
8#include <linux/mutex.h>

--- 50 unchanged lines hidden (view full) ---

59 CXL_MBOX_OP_INJECT_POISON = 0x4301,
60 CXL_MBOX_OP_CLEAR_POISON = 0x4302,
61 CXL_MBOX_OP_GET_SCAN_MEDIA_CAPS = 0x4303,
62 CXL_MBOX_OP_SCAN_MEDIA = 0x4304,
63 CXL_MBOX_OP_GET_SCAN_MEDIA = 0x4305,
64 CXL_MBOX_OP_MAX = 0x10000
65};
66
67/*
68 * CXL 2.0 - Memory capacity multiplier
69 * See Section 8.2.9.5
70 *
71 * Volatile, Persistent, and Partition capacities are specified to be in
72 * multiples of 256MB - define a multiplier to convert to/from bytes.
73 */
74#define CXL_CAPACITY_MULTIPLIER SZ_256M
75
67/**
68 * struct mbox_cmd - A command to be submitted to hardware.
69 * @opcode: (input) The command set and command submitted to hardware.
70 * @payload_in: (input) Pointer to the input payload.
71 * @payload_out: (output) Pointer to the output payload. Must be allocated by
72 * the caller.
73 * @size_in: (input) Number of bytes to load from @payload_in.
74 * @size_out: (input) Max number of bytes loaded into @payload_out.

--- 1270 unchanged lines hidden (view full) ---

1345 } __packed id;
1346 int rc;
1347
1348 rc = cxl_mem_mbox_send_cmd(cxlm, CXL_MBOX_OP_IDENTIFY, NULL, 0, &id,
1349 sizeof(id));
1350 if (rc < 0)
1351 return rc;
1352
76/**
77 * struct mbox_cmd - A command to be submitted to hardware.
78 * @opcode: (input) The command set and command submitted to hardware.
79 * @payload_in: (input) Pointer to the input payload.
80 * @payload_out: (output) Pointer to the output payload. Must be allocated by
81 * the caller.
82 * @size_in: (input) Number of bytes to load from @payload_in.
83 * @size_out: (input) Max number of bytes loaded into @payload_out.

--- 1270 unchanged lines hidden (view full) ---

1354 } __packed id;
1355 int rc;
1356
1357 rc = cxl_mem_mbox_send_cmd(cxlm, CXL_MBOX_OP_IDENTIFY, NULL, 0, &id,
1358 sizeof(id));
1359 if (rc < 0)
1360 return rc;
1361
1362 cxlm->total_bytes = le64_to_cpu(id.total_capacity);
1363 cxlm->total_bytes *= CXL_CAPACITY_MULTIPLIER;
1364
1365 cxlm->volatile_only_bytes = le64_to_cpu(id.volatile_capacity);
1366 cxlm->volatile_only_bytes *= CXL_CAPACITY_MULTIPLIER;
1367
1368 cxlm->persistent_only_bytes = le64_to_cpu(id.persistent_capacity);
1369 cxlm->persistent_only_bytes *= CXL_CAPACITY_MULTIPLIER;
1370
1371 cxlm->partition_align_bytes = le64_to_cpu(id.partition_align);
1372 cxlm->partition_align_bytes *= CXL_CAPACITY_MULTIPLIER;
1373
1374 dev_dbg(&cxlm->pdev->dev, "Identify Memory Device\n"
1375 " total_bytes = %#llx\n"
1376 " volatile_only_bytes = %#llx\n"
1377 " persistent_only_bytes = %#llx\n"
1378 " partition_align_bytes = %#llx\n",
1379 cxlm->total_bytes,
1380 cxlm->volatile_only_bytes,
1381 cxlm->persistent_only_bytes,
1382 cxlm->partition_align_bytes);
1383
1353 /*
1354 * TODO: enumerate DPA map, as 'ram' and 'pmem' do not alias.
1355 * For now, only the capacity is exported in sysfs
1356 */
1357 cxlm->ram_range.start = 0;
1384 /*
1385 * TODO: enumerate DPA map, as 'ram' and 'pmem' do not alias.
1386 * For now, only the capacity is exported in sysfs
1387 */
1388 cxlm->ram_range.start = 0;
1358 cxlm->ram_range.end = le64_to_cpu(id.volatile_capacity) * SZ_256M - 1;
1389 cxlm->ram_range.end = cxlm->volatile_only_bytes - 1;
1359
1360 cxlm->pmem_range.start = 0;
1390
1391 cxlm->pmem_range.start = 0;
1361 cxlm->pmem_range.end =
1362 le64_to_cpu(id.persistent_capacity) * SZ_256M - 1;
1392 cxlm->pmem_range.end = cxlm->persistent_only_bytes - 1;
1363
1364 cxlm->lsa_size = le32_to_cpu(id.lsa_size);
1365 memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));
1366
1367 return 0;
1368}
1369
1370static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id)

--- 86 unchanged lines hidden ---
1393
1394 cxlm->lsa_size = le32_to_cpu(id.lsa_size);
1395 memcpy(cxlm->firmware_version, id.fw_revision, sizeof(id.fw_revision));
1396
1397 return 0;
1398}
1399
1400static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id)

--- 86 unchanged lines hidden ---