Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F144637581
D54095.1775949156.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D54095.1775949156.diff
View Options
diff --git a/sys/dev/nvd/nvd.c b/sys/dev/nvd/nvd.c
--- a/sys/dev/nvd/nvd.c
+++ b/sys/dev/nvd/nvd.c
@@ -174,8 +174,6 @@
}
mtx_unlock(&nvd_lock);
- nvme_unregister_consumer(consumer_handle);
-
mtx_destroy(&nvd_lock);
}
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1913,17 +1913,10 @@
struct nvme_namespace;
struct nvme_controller;
-struct nvme_consumer;
struct nvme_passthru_cmd;
typedef void (*nvme_cb_fn_t)(void *, const struct nvme_completion *);
-typedef void *(*nvme_cons_ns_fn_t)(struct nvme_namespace *, void *);
-typedef void *(*nvme_cons_ctrlr_fn_t)(struct nvme_controller *);
-typedef void (*nvme_cons_async_fn_t)(void *, const struct nvme_completion *,
- uint32_t, void *, uint32_t);
-typedef void (*nvme_cons_fail_fn_t)(void *);
-
enum nvme_namespace_flags {
NVME_NS_DEALLOCATE_SUPPORTED = 0x01,
NVME_NS_FLUSH_SUPPORTED = 0x02,
@@ -1977,13 +1970,6 @@
int nvme_ns_dump(struct nvme_namespace *ns, void *virt, off_t offset,
size_t len);
-/* Registration functions */
-struct nvme_consumer * nvme_register_consumer(nvme_cons_ns_fn_t ns_fn,
- nvme_cons_ctrlr_fn_t ctrlr_fn,
- nvme_cons_async_fn_t async_fn,
- nvme_cons_fail_fn_t fail_fn);
-void nvme_unregister_consumer(struct nvme_consumer *consumer);
-
/* Controller helper functions */
device_t nvme_ctrlr_get_device(struct nvme_controller *ctrlr);
const struct nvme_controller_data *
diff --git a/sys/dev/nvme/nvme.c b/sys/dev/nvme/nvme.c
--- a/sys/dev/nvme/nvme.c
+++ b/sys/dev/nvme/nvme.c
@@ -36,39 +36,10 @@
#include "nvme_private.h"
#include "nvme_if.h"
-struct nvme_consumer {
- uint32_t id;
- nvme_cons_ns_fn_t ns_fn;
- nvme_cons_ctrlr_fn_t ctrlr_fn;
- nvme_cons_async_fn_t async_fn;
- nvme_cons_fail_fn_t fail_fn;
-};
-
-struct nvme_consumer nvme_consumer[NVME_MAX_CONSUMERS];
-#define INVALID_CONSUMER_ID 0xFFFF
-
int32_t nvme_retry_count;
MALLOC_DEFINE(M_NVME, "nvme", "nvme(4) memory allocations");
-static void
-nvme_init(void *dummy __unused)
-{
- uint32_t i;
-
- for (i = 0; i < NVME_MAX_CONSUMERS; i++)
- nvme_consumer[i].id = INVALID_CONSUMER_ID;
-}
-
-SYSINIT(nvme_register, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_init, NULL);
-
-static void
-nvme_uninit(void *dummy __unused)
-{
-}
-
-SYSUNINIT(nvme_unregister, SI_SUB_DRIVERS, SI_ORDER_SECOND, nvme_uninit, NULL);
-
int
nvme_shutdown(device_t dev)
{
@@ -117,78 +88,6 @@
return (0);
}
-static void
-nvme_notify(struct nvme_consumer *cons,
- struct nvme_controller *ctrlr)
-{
- struct nvme_namespace *ns;
- void *ctrlr_cookie;
- int cmpset, ns_idx;
-
- /*
- * The consumer may register itself after the nvme devices
- * have registered with the kernel, but before the
- * driver has completed initialization. In that case,
- * return here, and when initialization completes, the
- * controller will make sure the consumer gets notified.
- */
- if (!ctrlr->is_initialized)
- return;
-
- cmpset = atomic_cmpset_32(&ctrlr->notification_sent, 0, 1);
- if (cmpset == 0)
- return;
-
- if (cons->ctrlr_fn != NULL)
- ctrlr_cookie = (*cons->ctrlr_fn)(ctrlr);
- else
- ctrlr_cookie = (void *)(uintptr_t)0xdeadc0dedeadc0de;
- ctrlr->cons_cookie[cons->id] = ctrlr_cookie;
-
- /* ctrlr_fn has failed. Nothing to notify here any more. */
- if (ctrlr_cookie == NULL) {
- (void)atomic_cmpset_32(&ctrlr->notification_sent, 1, 0);
- return;
- }
-
- if (ctrlr->is_failed) {
- ctrlr->cons_cookie[cons->id] = NULL;
- if (cons->fail_fn != NULL)
- (*cons->fail_fn)(ctrlr_cookie);
- /*
- * Do not notify consumers about the namespaces of a
- * failed controller.
- */
- return;
- }
- for (ns_idx = 0; ns_idx < min(ctrlr->cdata.nn, NVME_MAX_NAMESPACES); ns_idx++) {
- ns = &ctrlr->ns[ns_idx];
- if (ns->data.nsze == 0)
- continue;
- if (cons->ns_fn != NULL)
- ns->cons_cookie[cons->id] =
- (*cons->ns_fn)(ns, ctrlr_cookie);
- }
-}
-
-static void
-nvme_notify_new_consumer(struct nvme_consumer *cons)
-{
- device_t *devlist;
- struct nvme_controller *ctrlr;
- int dev_idx, devcount;
-
- if (devclass_get_devices(devclass_find("nvme"), &devlist, &devcount))
- return;
-
- for (dev_idx = 0; dev_idx < devcount; dev_idx++) {
- ctrlr = DEVICE2SOFTC(devlist[dev_idx]);
- nvme_notify(cons, ctrlr);
- }
-
- free(devlist, M_TEMP);
-}
-
void
nvme_notify_async(struct nvme_controller *ctrlr,
const struct nvme_completion *async_cpl,
@@ -231,38 +130,6 @@
free(children, M_TEMP);
}
-struct nvme_consumer *
-nvme_register_consumer(nvme_cons_ns_fn_t ns_fn, nvme_cons_ctrlr_fn_t ctrlr_fn,
- nvme_cons_async_fn_t async_fn,
- nvme_cons_fail_fn_t fail_fn)
-{
- int i;
-
- /*
- * TODO: add locking around consumer registration.
- */
- for (i = 0; i < NVME_MAX_CONSUMERS; i++)
- if (nvme_consumer[i].id == INVALID_CONSUMER_ID) {
- nvme_consumer[i].id = i;
- nvme_consumer[i].ns_fn = ns_fn;
- nvme_consumer[i].ctrlr_fn = ctrlr_fn;
- nvme_consumer[i].async_fn = async_fn;
- nvme_consumer[i].fail_fn = fail_fn;
-
- nvme_notify_new_consumer(&nvme_consumer[i]);
- return (&nvme_consumer[i]);
- }
-
- printf("nvme(4): consumer not registered - no slots available\n");
- return (NULL);
-}
-
-void
-nvme_unregister_consumer(struct nvme_consumer *consumer)
-{
- consumer->id = INVALID_CONSUMER_ID;
-}
-
void
nvme_completion_poll_cb(void *arg, const struct nvme_completion *cpl)
{
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1665,7 +1665,6 @@
ctrlr->is_resetting = 0;
ctrlr->is_initialized = false;
- ctrlr->notification_sent = 0;
TASK_INIT(&ctrlr->reset_task, 0, nvme_ctrlr_reset_task, ctrlr);
for (int i = 0; i < NVME_MAX_ASYNC_EVENTS; i++) {
struct nvme_async_event_request *aer = &ctrlr->aer[i];
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -76,7 +76,6 @@
#define NVME_INT_COAL_THRESHOLD (0) /* 0-based */
#define NVME_MAX_NAMESPACES (16)
-#define NVME_MAX_CONSUMERS (2)
#define NVME_MAX_ASYNC_EVENTS (8)
#define NVME_ADMIN_TIMEOUT_PERIOD (60) /* in seconds */
@@ -205,7 +204,6 @@
uint32_t id;
uint32_t flags;
struct cdev *cdev;
- void *cons_cookie[NVME_MAX_CONSUMERS];
uint32_t boundary;
struct mtx lock;
};
@@ -299,10 +297,7 @@
uint32_t num_aers;
struct nvme_async_event_request aer[NVME_MAX_ASYNC_EVENTS];
- void *cons_cookie[NVME_MAX_CONSUMERS];
-
uint32_t is_resetting;
- uint32_t notification_sent;
u_int fail_on_reset;
bool is_failed;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 11, 11:12 PM (13 h, 37 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28326856
Default Alt Text
D54095.1775949156.diff (6 KB)
Attached To
Mode
D54095: nvme: remove now-redundant consumer interface
Attached
Detach File
Event Timeline
Log In to Comment