mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-28 22:04:56 +08:00
parent
e98239fbe3
commit
9f196b281c
@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include <rtems/blkdev.h>
|
#include <rtems/blkdev.h>
|
||||||
|
#include <rtems/thread.h>
|
||||||
|
|
||||||
#define NVD_STR "nvd"
|
#define NVD_STR "nvd"
|
||||||
|
|
||||||
@ -208,28 +209,27 @@ nvd_request(struct nvd_disk *ndisk, rtems_blkdev_request *req,
|
|||||||
static void
|
static void
|
||||||
nvd_sync_completion(void *arg, const struct nvme_completion *status)
|
nvd_sync_completion(void *arg, const struct nvme_completion *status)
|
||||||
{
|
{
|
||||||
rtems_status_code sc;
|
rtems_binary_semaphore *sync;
|
||||||
|
|
||||||
if (nvme_completion_is_error(status)) {
|
sync = arg;
|
||||||
sc = RTEMS_IO_ERROR;
|
rtems_binary_semaphore_post(sync);
|
||||||
} else {
|
|
||||||
sc = RTEMS_SUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
rtems_blkdev_request_done(arg, sc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
nvd_sync(struct nvd_disk *ndisk, rtems_blkdev_request *req)
|
nvd_sync(struct nvd_disk *ndisk)
|
||||||
{
|
{
|
||||||
|
rtems_binary_semaphore sync;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = nvme_ns_cmd_flush(ndisk->ns, nvd_sync_completion, req);
|
rtems_binary_semaphore_init(&sync, "nvd sync");
|
||||||
if (error != 0) {
|
|
||||||
rtems_blkdev_request_done(req, RTEMS_NO_MEMORY);
|
error = nvme_ns_cmd_flush(ndisk->ns, nvd_sync_completion, &sync);
|
||||||
|
if (error == 0) {
|
||||||
|
rtems_binary_semaphore_wait(&sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
rtems_binary_semaphore_destroy(&sync);
|
||||||
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -244,7 +244,7 @@ nvd_ioctl(rtems_disk_device *dd, uint32_t req, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (req == RTEMS_BLKDEV_REQ_SYNC) {
|
if (req == RTEMS_BLKDEV_REQ_SYNC) {
|
||||||
return (nvd_sync(ndisk, arg));
|
return (nvd_sync(ndisk));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req == RTEMS_BLKIO_CAPABILITIES) {
|
if (req == RTEMS_BLKIO_CAPABILITIES) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user