Skip to content

Commit e603586

Browse files
committed
nvme: remove CHATHAM related code
Chatham was an internal NVMe prototype board used for early driver development. MFC after: 1 week Sponsored by: Intel
1 parent eef38a1 commit e603586

File tree

5 files changed

+10
-252
lines changed

5 files changed

+10
-252
lines changed

sys/dev/nvme/nvme.c

-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ static struct _pcsid
8787
const char *desc;
8888
} pci_ids[] = {
8989
{ 0x01118086, 0, 0, "NVMe Controller" },
90-
{ CHATHAM_PCI_ID, 0, 0, "Chatham Prototype NVMe Controller" },
9190
{ IDT32_PCI_ID, 0, 0, "IDT NVMe Controller (32 channel)" },
9291
{ IDT8_PCI_ID, 0, 0, "IDT NVMe Controller (8 channel)" },
9392
{ 0x09538086, 1, 0x3702, "DC P3700 SSD" },

sys/dev/nvme/nvme_ctrlr.c

+2-169
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ static int
4949
nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr)
5050
{
5151

52-
/* Chatham puts the NVMe MMRs behind BAR 2/3, not BAR 0/1. */
53-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
54-
ctrlr->resource_id = PCIR_BAR(2);
55-
else
56-
ctrlr->resource_id = PCIR_BAR(0);
52+
ctrlr->resource_id = PCIR_BAR(0);
5753

5854
ctrlr->resource = bus_alloc_resource(ctrlr->dev, SYS_RES_MEMORY,
5955
&ctrlr->resource_id, 0, ~0, 1, RF_ACTIVE);
@@ -81,117 +77,6 @@ nvme_ctrlr_allocate_bar(struct nvme_controller *ctrlr)
8177
return (0);
8278
}
8379

84-
#ifdef CHATHAM2
85-
static int
86-
nvme_ctrlr_allocate_chatham_bar(struct nvme_controller *ctrlr)
87-
{
88-
89-
ctrlr->chatham_resource_id = PCIR_BAR(CHATHAM_CONTROL_BAR);
90-
ctrlr->chatham_resource = bus_alloc_resource(ctrlr->dev,
91-
SYS_RES_MEMORY, &ctrlr->chatham_resource_id, 0, ~0, 1,
92-
RF_ACTIVE);
93-
94-
if(ctrlr->chatham_resource == NULL) {
95-
nvme_printf(ctrlr, "unable to alloc pci resource\n");
96-
return (ENOMEM);
97-
}
98-
99-
ctrlr->chatham_bus_tag = rman_get_bustag(ctrlr->chatham_resource);
100-
ctrlr->chatham_bus_handle =
101-
rman_get_bushandle(ctrlr->chatham_resource);
102-
103-
return (0);
104-
}
105-
106-
static void
107-
nvme_ctrlr_setup_chatham(struct nvme_controller *ctrlr)
108-
{
109-
uint64_t reg1, reg2, reg3;
110-
uint64_t temp1, temp2;
111-
uint32_t temp3;
112-
uint32_t use_flash_timings = 0;
113-
114-
DELAY(10000);
115-
116-
temp3 = chatham_read_4(ctrlr, 0x8080);
117-
118-
device_printf(ctrlr->dev, "Chatham version: 0x%x\n", temp3);
119-
120-
ctrlr->chatham_lbas = chatham_read_4(ctrlr, 0x8068) - 0x110;
121-
ctrlr->chatham_size = ctrlr->chatham_lbas * 512;
122-
123-
device_printf(ctrlr->dev, "Chatham size: %jd\n",
124-
(intmax_t)ctrlr->chatham_size);
125-
126-
reg1 = reg2 = reg3 = ctrlr->chatham_size - 1;
127-
128-
TUNABLE_INT_FETCH("hw.nvme.use_flash_timings", &use_flash_timings);
129-
if (use_flash_timings) {
130-
device_printf(ctrlr->dev, "Chatham: using flash timings\n");
131-
temp1 = 0x00001b58000007d0LL;
132-
temp2 = 0x000000cb00000131LL;
133-
} else {
134-
device_printf(ctrlr->dev, "Chatham: using DDR timings\n");
135-
temp1 = temp2 = 0x0LL;
136-
}
137-
138-
chatham_write_8(ctrlr, 0x8000, reg1);
139-
chatham_write_8(ctrlr, 0x8008, reg2);
140-
chatham_write_8(ctrlr, 0x8010, reg3);
141-
142-
chatham_write_8(ctrlr, 0x8020, temp1);
143-
temp3 = chatham_read_4(ctrlr, 0x8020);
144-
145-
chatham_write_8(ctrlr, 0x8028, temp2);
146-
temp3 = chatham_read_4(ctrlr, 0x8028);
147-
148-
chatham_write_8(ctrlr, 0x8030, temp1);
149-
chatham_write_8(ctrlr, 0x8038, temp2);
150-
chatham_write_8(ctrlr, 0x8040, temp1);
151-
chatham_write_8(ctrlr, 0x8048, temp2);
152-
chatham_write_8(ctrlr, 0x8050, temp1);
153-
chatham_write_8(ctrlr, 0x8058, temp2);
154-
155-
DELAY(10000);
156-
}
157-
158-
static void
159-
nvme_chatham_populate_cdata(struct nvme_controller *ctrlr)
160-
{
161-
struct nvme_controller_data *cdata;
162-
163-
cdata = &ctrlr->cdata;
164-
165-
cdata->vid = 0x8086;
166-
cdata->ssvid = 0x2011;
167-
168-
/*
169-
* Chatham2 puts garbage data in these fields when we
170-
* invoke IDENTIFY_CONTROLLER, so we need to re-zero
171-
* the fields before calling bcopy().
172-
*/
173-
memset(cdata->sn, 0, sizeof(cdata->sn));
174-
memcpy(cdata->sn, "2012", strlen("2012"));
175-
memset(cdata->mn, 0, sizeof(cdata->mn));
176-
memcpy(cdata->mn, "CHATHAM2", strlen("CHATHAM2"));
177-
memset(cdata->fr, 0, sizeof(cdata->fr));
178-
memcpy(cdata->fr, "0", strlen("0"));
179-
cdata->rab = 8;
180-
cdata->aerl = 3;
181-
cdata->lpa.ns_smart = 1;
182-
cdata->sqes.min = 6;
183-
cdata->sqes.max = 6;
184-
cdata->cqes.min = 4;
185-
cdata->cqes.max = 4;
186-
cdata->nn = 1;
187-
188-
/* Chatham2 doesn't support DSM command */
189-
cdata->oncs.dsm = 0;
190-
191-
cdata->vwc.present = 1;
192-
}
193-
#endif /* CHATHAM2 */
194-
19580
static void
19681
nvme_ctrlr_construct_admin_qpair(struct nvme_controller *ctrlr)
19782
{
@@ -461,11 +346,6 @@ nvme_ctrlr_identify(struct nvme_controller *ctrlr)
461346
return (ENXIO);
462347
}
463348

464-
#ifdef CHATHAM2
465-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
466-
nvme_chatham_populate_cdata(ctrlr);
467-
#endif
468-
469349
/*
470350
* Use MDTS to ensure our default max_xfer_size doesn't exceed what the
471351
* controller supports.
@@ -779,10 +659,6 @@ nvme_ctrlr_configure_aer(struct nvme_controller *ctrlr)
779659
/* aerl is a zero-based value, so we need to add 1 here. */
780660
ctrlr->num_aers = min(NVME_MAX_ASYNC_EVENTS, (ctrlr->cdata.aerl+1));
781661

782-
/* Chatham doesn't support AERs. */
783-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
784-
ctrlr->num_aers = 0;
785-
786662
for (i = 0; i < ctrlr->num_aers; i++) {
787663
aer = &ctrlr->aer[i];
788664
nvme_ctrlr_construct_and_submit_aer(ctrlr, aer);
@@ -1034,27 +910,6 @@ nvme_ctrlr_ioctl(struct cdev *cdev, u_long cmd, caddr_t arg, int flag,
1034910
break;
1035911
case NVME_PASSTHROUGH_CMD:
1036912
pt = (struct nvme_pt_command *)arg;
1037-
#ifdef CHATHAM2
1038-
/*
1039-
* Chatham IDENTIFY data is spoofed, so copy the spoofed data
1040-
* rather than issuing the command to the Chatham controller.
1041-
*/
1042-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID &&
1043-
pt->cmd.opc == NVME_OPC_IDENTIFY) {
1044-
if (pt->cmd.cdw10 == 1) {
1045-
if (pt->len != sizeof(ctrlr->cdata))
1046-
return (EINVAL);
1047-
return (copyout(&ctrlr->cdata, pt->buf,
1048-
pt->len));
1049-
} else {
1050-
if (pt->len != sizeof(ctrlr->ns[0].data) ||
1051-
pt->cmd.nsid != 1)
1052-
return (EINVAL);
1053-
return (copyout(&ctrlr->ns[0].data, pt->buf,
1054-
pt->len));
1055-
}
1056-
}
1057-
#endif
1058913
return (nvme_ctrlr_passthrough_cmd(ctrlr, pt, pt->cmd.nsid,
1059914
1 /* is_user_buffer */, 1 /* is_admin_cmd */));
1060915
default:
@@ -1087,15 +942,6 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
1087942
if (status != 0)
1088943
return (status);
1089944

1090-
#ifdef CHATHAM2
1091-
if (pci_get_devid(dev) == CHATHAM_PCI_ID) {
1092-
status = nvme_ctrlr_allocate_chatham_bar(ctrlr);
1093-
if (status != 0)
1094-
return (status);
1095-
nvme_ctrlr_setup_chatham(ctrlr);
1096-
}
1097-
#endif
1098-
1099945
/*
1100946
* Software emulators may set the doorbell stride to something
1101947
* other than zero, but this driver is not set up to handle that.
@@ -1244,14 +1090,8 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev)
12441090
* during shutdown). This ensures the controller receives a
12451091
* shutdown notification in case the system is shutdown before
12461092
* reloading the driver.
1247-
*
1248-
* Chatham does not let you re-enable the controller after shutdown
1249-
* notification has been received, so do not send it in this case.
1250-
* This is OK because Chatham does not depend on the shutdown
1251-
* notification anyways.
12521093
*/
1253-
if (pci_get_devid(ctrlr->dev) != CHATHAM_PCI_ID)
1254-
nvme_ctrlr_shutdown(ctrlr);
1094+
nvme_ctrlr_shutdown(ctrlr);
12551095

12561096
nvme_ctrlr_disable(ctrlr);
12571097
taskqueue_free(ctrlr->taskqueue);
@@ -1280,13 +1120,6 @@ nvme_ctrlr_destruct(struct nvme_controller *ctrlr, device_t dev)
12801120
ctrlr->bar4_resource_id, ctrlr->bar4_resource);
12811121
}
12821122

1283-
#ifdef CHATHAM2
1284-
if (ctrlr->chatham_resource != NULL) {
1285-
bus_release_resource(dev, SYS_RES_MEMORY,
1286-
ctrlr->chatham_resource_id, ctrlr->chatham_resource);
1287-
}
1288-
#endif
1289-
12901123
if (ctrlr->tag)
12911124
bus_teardown_intr(ctrlr->dev, ctrlr->res, ctrlr->tag);
12921125

sys/dev/nvme/nvme_ns.c

+8-38
Original file line numberDiff line numberDiff line change
@@ -465,28 +465,6 @@ nvme_ns_bio_process(struct nvme_namespace *ns, struct bio *bp,
465465
return (err);
466466
}
467467

468-
#ifdef CHATHAM2
469-
static void
470-
nvme_ns_populate_chatham_data(struct nvme_namespace *ns)
471-
{
472-
struct nvme_controller *ctrlr;
473-
struct nvme_namespace_data *nsdata;
474-
475-
ctrlr = ns->ctrlr;
476-
nsdata = &ns->data;
477-
478-
nsdata->nsze = ctrlr->chatham_lbas;
479-
nsdata->ncap = ctrlr->chatham_lbas;
480-
nsdata->nuse = ctrlr->chatham_lbas;
481-
482-
/* Chatham2 doesn't support thin provisioning. */
483-
nsdata->nsfeat.thin_prov = 0;
484-
485-
/* Set LBA size to 512 bytes. */
486-
nsdata->lbaf[0].lbads = 9;
487-
}
488-
#endif /* CHATHAM2 */
489-
490468
int
491469
nvme_ns_construct(struct nvme_namespace *ns, uint16_t id,
492470
struct nvme_controller *ctrlr)
@@ -513,23 +491,15 @@ nvme_ns_construct(struct nvme_namespace *ns, uint16_t id,
513491
if (!mtx_initialized(&ns->lock))
514492
mtx_init(&ns->lock, "nvme ns lock", NULL, MTX_DEF);
515493

516-
#ifdef CHATHAM2
517-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
518-
nvme_ns_populate_chatham_data(ns);
519-
else {
520-
#endif
521-
status.done = FALSE;
522-
nvme_ctrlr_cmd_identify_namespace(ctrlr, id, &ns->data,
523-
nvme_completion_poll_cb, &status);
524-
while (status.done == FALSE)
525-
DELAY(5);
526-
if (nvme_completion_is_error(&status.cpl)) {
527-
nvme_printf(ctrlr, "nvme_identify_namespace failed\n");
528-
return (ENXIO);
529-
}
530-
#ifdef CHATHAM2
494+
status.done = FALSE;
495+
nvme_ctrlr_cmd_identify_namespace(ctrlr, id, &ns->data,
496+
nvme_completion_poll_cb, &status);
497+
while (status.done == FALSE)
498+
DELAY(5);
499+
if (nvme_completion_is_error(&status.cpl)) {
500+
nvme_printf(ctrlr, "nvme_identify_namespace failed\n");
501+
return (ENXIO);
531502
}
532-
#endif
533503

534504
/*
535505
* Note: format is a 0-based value, so > is appropriate here,

sys/dev/nvme/nvme_private.h

-35
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,6 @@
5050

5151
MALLOC_DECLARE(M_NVME);
5252

53-
#define CHATHAM2
54-
55-
#ifdef CHATHAM2
56-
#define CHATHAM_PCI_ID 0x20118086
57-
#define CHATHAM_CONTROL_BAR 0
58-
#endif
59-
6053
#define IDT32_PCI_ID 0x80d0111d /* 32 channel board */
6154
#define IDT8_PCI_ID 0x80d2111d /* 8 channel board */
6255

@@ -267,13 +260,6 @@ struct nvme_controller {
267260
int bar4_resource_id;
268261
struct resource *bar4_resource;
269262

270-
#ifdef CHATHAM2
271-
bus_space_tag_t chatham_bus_tag;
272-
bus_space_handle_t chatham_bus_handle;
273-
int chatham_resource_id;
274-
struct resource *chatham_resource;
275-
#endif
276-
277263
uint32_t msix_enabled;
278264
uint32_t force_intx;
279265
uint32_t enable_aborts;
@@ -339,11 +325,6 @@ struct nvme_controller {
339325

340326
boolean_t is_failed;
341327
STAILQ_HEAD(, nvme_request) fail_req;
342-
343-
#ifdef CHATHAM2
344-
uint64_t chatham_size;
345-
uint64_t chatham_lbas;
346-
#endif
347328
};
348329

349330
#define nvme_mmio_offsetof(reg) \
@@ -366,22 +347,6 @@ struct nvme_controller {
366347
(val & 0xFFFFFFFF00000000UL) >> 32); \
367348
} while (0);
368349

369-
#ifdef CHATHAM2
370-
#define chatham_read_4(softc, reg) \
371-
bus_space_read_4((softc)->chatham_bus_tag, \
372-
(softc)->chatham_bus_handle, reg)
373-
374-
#define chatham_write_8(sc, reg, val) \
375-
do { \
376-
bus_space_write_4((sc)->chatham_bus_tag, \
377-
(sc)->chatham_bus_handle, reg, val & 0xffffffff); \
378-
bus_space_write_4((sc)->chatham_bus_tag, \
379-
(sc)->chatham_bus_handle, reg+4, \
380-
(val & 0xFFFFFFFF00000000UL) >> 32); \
381-
} while (0);
382-
383-
#endif /* CHATHAM2 */
384-
385350
#if __FreeBSD_version < 800054
386351
#define wmb() __asm volatile("sfence" ::: "memory")
387352
#define mb() __asm volatile("mfence" ::: "memory")

sys/dev/nvme/nvme_qpair.c

-9
Original file line numberDiff line numberDiff line change
@@ -469,15 +469,6 @@ nvme_qpair_construct(struct nvme_qpair *qpair, uint32_t id,
469469
qpair->id = id;
470470
qpair->vector = vector;
471471
qpair->num_entries = num_entries;
472-
#ifdef CHATHAM2
473-
/*
474-
* Chatham prototype board starts having issues at higher queue
475-
* depths. So use a conservative estimate here of no more than 64
476-
* outstanding I/O per queue at any one point.
477-
*/
478-
if (pci_get_devid(ctrlr->dev) == CHATHAM_PCI_ID)
479-
num_trackers = min(num_trackers, 64);
480-
#endif
481472
qpair->num_trackers = num_trackers;
482473
qpair->ctrlr = ctrlr;
483474

0 commit comments

Comments
 (0)