16
16
*
17
17
* This implements the PCI exclusive functionality for a CXL device as it is
18
18
* defined by the Compute Express Link specification. CXL devices may surface
19
- * certain functionality even if it isn't CXL enabled.
19
+ * certain functionality even if it isn't CXL enabled. While this driver is
20
+ * focused around the PCI specific aspects of a CXL device, it binds to the
21
+ * specific CXL memory device class code, and therefore the implementation of
22
+ * cxl_pci is focused around CXL memory devices.
20
23
*
21
24
* The driver has several responsibilities, mainly:
22
25
* - Create the memX device and register on the CXL bus.
23
26
* - Enumerate device's register interface and map them.
24
- * - Probe the device attributes to establish sysfs interface.
25
- * - Provide an IOCTL interface to userspace to communicate with the device for
26
- * things like firmware update.
27
+ * - Registers nvdimm bridge device with cxl_core.
28
+ * - Registers a CXL mailbox with cxl_core.
27
29
*/
28
30
29
31
#define cxl_doorbell_busy (cxlm ) \
33
35
/* CXL 2.0 - 8.2.8.4 */
34
36
#define CXL_MAILBOX_TIMEOUT_MS (2 * HZ)
35
37
36
- static int cxl_mem_wait_for_doorbell (struct cxl_mem * cxlm )
38
+ static int cxl_pci_mbox_wait_for_doorbell (struct cxl_mem * cxlm )
37
39
{
38
40
const unsigned long start = jiffies ;
39
41
unsigned long end = start ;
@@ -55,7 +57,7 @@ static int cxl_mem_wait_for_doorbell(struct cxl_mem *cxlm)
55
57
return 0 ;
56
58
}
57
59
58
- static void cxl_mem_mbox_timeout (struct cxl_mem * cxlm ,
60
+ static void cxl_pci_mbox_timeout (struct cxl_mem * cxlm ,
59
61
struct cxl_mbox_cmd * mbox_cmd )
60
62
{
61
63
struct device * dev = cxlm -> dev ;
@@ -65,7 +67,7 @@ static void cxl_mem_mbox_timeout(struct cxl_mem *cxlm,
65
67
}
66
68
67
69
/**
68
- * __cxl_mem_mbox_send_cmd () - Execute a mailbox command
70
+ * __cxl_pci_mbox_send_cmd () - Execute a mailbox command
69
71
* @cxlm: The CXL memory device to communicate with.
70
72
* @mbox_cmd: Command to send to the memory device.
71
73
*
@@ -86,7 +88,7 @@ static void cxl_mem_mbox_timeout(struct cxl_mem *cxlm,
86
88
* not need to coordinate with each other. The driver only uses the primary
87
89
* mailbox.
88
90
*/
89
- static int __cxl_mem_mbox_send_cmd (struct cxl_mem * cxlm ,
91
+ static int __cxl_pci_mbox_send_cmd (struct cxl_mem * cxlm ,
90
92
struct cxl_mbox_cmd * mbox_cmd )
91
93
{
92
94
void __iomem * payload = cxlm -> regs .mbox + CXLDEV_MBOX_PAYLOAD_OFFSET ;
@@ -140,9 +142,9 @@ static int __cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm,
140
142
cxlm -> regs .mbox + CXLDEV_MBOX_CTRL_OFFSET );
141
143
142
144
/* #5 */
143
- rc = cxl_mem_wait_for_doorbell (cxlm );
145
+ rc = cxl_pci_mbox_wait_for_doorbell (cxlm );
144
146
if (rc == - ETIMEDOUT ) {
145
- cxl_mem_mbox_timeout (cxlm , mbox_cmd );
147
+ cxl_pci_mbox_timeout (cxlm , mbox_cmd );
146
148
return rc ;
147
149
}
148
150
@@ -181,13 +183,13 @@ static int __cxl_mem_mbox_send_cmd(struct cxl_mem *cxlm,
181
183
}
182
184
183
185
/**
184
- * cxl_mem_mbox_get () - Acquire exclusive access to the mailbox.
186
+ * cxl_pci_mbox_get () - Acquire exclusive access to the mailbox.
185
187
* @cxlm: The memory device to gain access to.
186
188
*
187
189
* Context: Any context. Takes the mbox_mutex.
188
190
* Return: 0 if exclusive access was acquired.
189
191
*/
190
- static int cxl_mem_mbox_get (struct cxl_mem * cxlm )
192
+ static int cxl_pci_mbox_get (struct cxl_mem * cxlm )
191
193
{
192
194
struct device * dev = cxlm -> dev ;
193
195
u64 md_status ;
@@ -212,7 +214,7 @@ static int cxl_mem_mbox_get(struct cxl_mem *cxlm)
212
214
* Mailbox Interface Ready bit. Therefore, waiting for the doorbell
213
215
* to be ready is sufficient.
214
216
*/
215
- rc = cxl_mem_wait_for_doorbell (cxlm );
217
+ rc = cxl_pci_mbox_wait_for_doorbell (cxlm );
216
218
if (rc ) {
217
219
dev_warn (dev , "Mailbox interface not ready\n" );
218
220
goto out ;
@@ -252,12 +254,12 @@ static int cxl_mem_mbox_get(struct cxl_mem *cxlm)
252
254
}
253
255
254
256
/**
255
- * cxl_mem_mbox_put () - Release exclusive access to the mailbox.
257
+ * cxl_pci_mbox_put () - Release exclusive access to the mailbox.
256
258
* @cxlm: The CXL memory device to communicate with.
257
259
*
258
260
* Context: Any context. Expects mbox_mutex to be held.
259
261
*/
260
- static void cxl_mem_mbox_put (struct cxl_mem * cxlm )
262
+ static void cxl_pci_mbox_put (struct cxl_mem * cxlm )
261
263
{
262
264
mutex_unlock (& cxlm -> mbox_mutex );
263
265
}
@@ -266,17 +268,17 @@ static int cxl_pci_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
266
268
{
267
269
int rc ;
268
270
269
- rc = cxl_mem_mbox_get (cxlm );
271
+ rc = cxl_pci_mbox_get (cxlm );
270
272
if (rc )
271
273
return rc ;
272
274
273
- rc = __cxl_mem_mbox_send_cmd (cxlm , cmd );
274
- cxl_mem_mbox_put (cxlm );
275
+ rc = __cxl_pci_mbox_send_cmd (cxlm , cmd );
276
+ cxl_pci_mbox_put (cxlm );
275
277
276
278
return rc ;
277
279
}
278
280
279
- static int cxl_mem_setup_mailbox (struct cxl_mem * cxlm )
281
+ static int cxl_pci_setup_mailbox (struct cxl_mem * cxlm )
280
282
{
281
283
const int cap = readl (cxlm -> regs .mbox + CXLDEV_MBOX_CAPS_OFFSET );
282
284
@@ -304,7 +306,7 @@ static int cxl_mem_setup_mailbox(struct cxl_mem *cxlm)
304
306
return 0 ;
305
307
}
306
308
307
- static void __iomem * cxl_mem_map_regblock (struct cxl_mem * cxlm ,
309
+ static void __iomem * cxl_pci_map_regblock (struct cxl_mem * cxlm ,
308
310
u8 bar , u64 offset )
309
311
{
310
312
void __iomem * addr ;
@@ -330,12 +332,12 @@ static void __iomem *cxl_mem_map_regblock(struct cxl_mem *cxlm,
330
332
return addr ;
331
333
}
332
334
333
- static void cxl_mem_unmap_regblock (struct cxl_mem * cxlm , void __iomem * base )
335
+ static void cxl_pci_unmap_regblock (struct cxl_mem * cxlm , void __iomem * base )
334
336
{
335
337
pci_iounmap (to_pci_dev (cxlm -> dev ), base );
336
338
}
337
339
338
- static int cxl_mem_dvsec (struct pci_dev * pdev , int dvsec )
340
+ static int cxl_pci_dvsec (struct pci_dev * pdev , int dvsec )
339
341
{
340
342
int pos ;
341
343
@@ -427,7 +429,7 @@ static void cxl_decode_register_block(u32 reg_lo, u32 reg_hi,
427
429
}
428
430
429
431
/**
430
- * cxl_mem_setup_regs () - Setup necessary MMIO.
432
+ * cxl_pci_setup_regs () - Setup necessary MMIO.
431
433
* @cxlm: The CXL memory device to communicate with.
432
434
*
433
435
* Return: 0 if all necessary registers mapped.
@@ -436,7 +438,7 @@ static void cxl_decode_register_block(u32 reg_lo, u32 reg_hi,
436
438
* regions. The purpose of this function is to enumerate and map those
437
439
* registers.
438
440
*/
439
- static int cxl_mem_setup_regs (struct cxl_mem * cxlm )
441
+ static int cxl_pci_setup_regs (struct cxl_mem * cxlm )
440
442
{
441
443
void __iomem * base ;
442
444
u32 regloc_size , regblocks ;
@@ -445,7 +447,7 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
445
447
struct pci_dev * pdev = to_pci_dev (dev );
446
448
struct cxl_register_map * map , maps [CXL_REGLOC_RBI_TYPES ];
447
449
448
- regloc = cxl_mem_dvsec (pdev , PCI_DVSEC_ID_CXL_REGLOC_DVSEC_ID );
450
+ regloc = cxl_pci_dvsec (pdev , PCI_DVSEC_ID_CXL_REGLOC_DVSEC_ID );
449
451
if (!regloc ) {
450
452
dev_err (dev , "register location dvsec not found\n" );
451
453
return - ENXIO ;
@@ -480,7 +482,7 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
480
482
if (reg_type > CXL_REGLOC_RBI_MEMDEV )
481
483
continue ;
482
484
483
- base = cxl_mem_map_regblock (cxlm , bar , offset );
485
+ base = cxl_pci_map_regblock (cxlm , bar , offset );
484
486
if (!base )
485
487
return - ENOMEM ;
486
488
@@ -492,7 +494,7 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
492
494
ret = cxl_probe_regs (cxlm , base + offset , map );
493
495
494
496
/* Always unmap the regblock regardless of probe success */
495
- cxl_mem_unmap_regblock (cxlm , base );
497
+ cxl_pci_unmap_regblock (cxlm , base );
496
498
497
499
if (ret )
498
500
return ret ;
@@ -511,7 +513,7 @@ static int cxl_mem_setup_regs(struct cxl_mem *cxlm)
511
513
return ret ;
512
514
}
513
515
514
- static int cxl_mem_probe (struct pci_dev * pdev , const struct pci_device_id * id )
516
+ static int cxl_pci_probe (struct pci_dev * pdev , const struct pci_device_id * id )
515
517
{
516
518
struct cxl_memdev * cxlmd ;
517
519
struct cxl_mem * cxlm ;
@@ -532,11 +534,11 @@ static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id)
532
534
if (IS_ERR (cxlm ))
533
535
return PTR_ERR (cxlm );
534
536
535
- rc = cxl_mem_setup_regs (cxlm );
537
+ rc = cxl_pci_setup_regs (cxlm );
536
538
if (rc )
537
539
return rc ;
538
540
539
- rc = cxl_mem_setup_mailbox (cxlm );
541
+ rc = cxl_pci_setup_mailbox (cxlm );
540
542
if (rc )
541
543
return rc ;
542
544
@@ -569,15 +571,15 @@ static const struct pci_device_id cxl_mem_pci_tbl[] = {
569
571
};
570
572
MODULE_DEVICE_TABLE (pci , cxl_mem_pci_tbl );
571
573
572
- static struct pci_driver cxl_mem_driver = {
574
+ static struct pci_driver cxl_pci_driver = {
573
575
.name = KBUILD_MODNAME ,
574
576
.id_table = cxl_mem_pci_tbl ,
575
- .probe = cxl_mem_probe ,
577
+ .probe = cxl_pci_probe ,
576
578
.driver = {
577
579
.probe_type = PROBE_PREFER_ASYNCHRONOUS ,
578
580
},
579
581
};
580
582
581
583
MODULE_LICENSE ("GPL v2" );
582
- module_pci_driver (cxl_mem_driver );
584
+ module_pci_driver (cxl_pci_driver );
583
585
MODULE_IMPORT_NS (CXL );
0 commit comments