idedrv Remove unlocking while waiting for interrupt
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include <proc/reschedule.h>
|
||||
#include <status.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/intr.h>
|
||||
|
||||
#define IDE_REG_DATA 0x00
|
||||
#define IDE_REG_ERROR 0x01
|
||||
@@ -107,17 +108,12 @@ static void ide_delay(uint16_t ctrl) {
|
||||
static void ide_irq(void* arg, void* regs, bool user, struct reschedule_ctx* rctx) {
|
||||
(void)user, (void)regs, (void)rctx;
|
||||
|
||||
uint64_t fd;
|
||||
|
||||
struct idedrv* idedrv = arg;
|
||||
|
||||
spin_lock(&idedrv->device->lock, &fd);
|
||||
|
||||
struct idedrv_request* req = idedrv->current_req;
|
||||
|
||||
if (req == NULL) {
|
||||
(void)inb(idedrv->io + IDE_REG_STATUS);
|
||||
spin_unlock(&idedrv->device->lock, fd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +122,6 @@ static void ide_irq(void* arg, void* regs, bool user, struct reschedule_ctx* rct
|
||||
if ((status & (IDE_ERR | IDE_DF))) {
|
||||
atomic_store(&req->done, 1);
|
||||
idedrv->current_req = NULL;
|
||||
spin_unlock(&idedrv->device->lock, fd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,8 +140,6 @@ static void ide_irq(void* arg, void* regs, bool user, struct reschedule_ctx* rct
|
||||
atomic_store(&req->done, 1);
|
||||
idedrv->current_req = NULL;
|
||||
}
|
||||
|
||||
spin_unlock(&idedrv->device->lock, fd);
|
||||
}
|
||||
|
||||
void ide_probe(uint16_t io, uint16_t ctrl, uint8_t devno, struct ide_probe* probe) {
|
||||
@@ -326,7 +319,7 @@ DEFINE_DEVICE_FINI(idedrv_fini) {
|
||||
}
|
||||
|
||||
static int idedrv_do_read_irqs(struct idedrv* idedrv, size_t sector, size_t sector_count,
|
||||
void* buffer, uint64_t* lockflags) {
|
||||
void* buffer) {
|
||||
struct idedrv_request* req = malloc(sizeof(*req));
|
||||
|
||||
if (req == NULL)
|
||||
@@ -345,12 +338,12 @@ static int idedrv_do_read_irqs(struct idedrv* idedrv, size_t sector, size_t sect
|
||||
uint8_t cmd = idedrv->lba48 ? IDE_CMD_READ48 : IDE_CMD_READ28;
|
||||
outb(idedrv->io + IDE_REG_CMD, cmd);
|
||||
|
||||
spin_unlock(&idedrv->device->lock, *lockflags);
|
||||
intr_enable();
|
||||
|
||||
while (!atomic_load(&req->done))
|
||||
spin_lock_relax();
|
||||
|
||||
spin_lock(&idedrv->device->lock, lockflags);
|
||||
intr_disable();
|
||||
|
||||
free(req);
|
||||
|
||||
@@ -454,13 +447,13 @@ DEFINE_DEVICE_OP(idedrv_read) {
|
||||
return -ST_XDRV_READ_ERROR;
|
||||
|
||||
if (idedrv->irqs_support)
|
||||
return idedrv_do_read_irqs(idedrv, sector, sector_count, buffer, lockflags);
|
||||
return idedrv_do_read_irqs(idedrv, sector, sector_count, buffer);
|
||||
else
|
||||
return idedrv_do_read_no_irqs(idedrv, sector, sector_count, buffer);
|
||||
}
|
||||
|
||||
static int idedrv_do_write_irqs(struct idedrv* idedrv, size_t sector, size_t sector_count,
|
||||
void* buffer, uint64_t* lockflags) {
|
||||
void* buffer) {
|
||||
struct idedrv_request* req = malloc(sizeof(*req));
|
||||
|
||||
if (req == NULL)
|
||||
@@ -489,12 +482,12 @@ static int idedrv_do_write_irqs(struct idedrv* idedrv, size_t sector, size_t sec
|
||||
|
||||
req->sector_done_count = 1;
|
||||
|
||||
spin_unlock(&idedrv->device->lock, *lockflags);
|
||||
intr_enable();
|
||||
|
||||
while (!atomic_load(&req->done))
|
||||
spin_lock_relax();
|
||||
|
||||
spin_lock(&idedrv->device->lock, lockflags);
|
||||
intr_disable();
|
||||
|
||||
free(req);
|
||||
|
||||
@@ -595,7 +588,7 @@ DEFINE_DEVICE_OP(idedrv_write) {
|
||||
return -ST_XDRV_WRITE_ERROR;
|
||||
|
||||
if (idedrv->irqs_support)
|
||||
ret = idedrv_do_write_irqs(idedrv, sector, sector_count, buffer, lockflags);
|
||||
ret = idedrv_do_write_irqs(idedrv, sector, sector_count, buffer);
|
||||
else
|
||||
ret = idedrv_do_write_no_irqs(idedrv, sector, sector_count, buffer);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user