Use a big-lock for kernel sychronization instead of fine-grained locking
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include <proc/proc.h>
|
||||
#include <proc/reschedule.h>
|
||||
#include <status.h>
|
||||
#include <sync/biglock.h>
|
||||
#include <sys/debug.h>
|
||||
#include <sys/intr.h>
|
||||
|
||||
@@ -338,12 +339,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);
|
||||
|
||||
intr_enable();
|
||||
biglock_unlock();
|
||||
|
||||
while (!atomic_load(&req->done))
|
||||
spin_lock_relax();
|
||||
|
||||
intr_disable();
|
||||
biglock_lock();
|
||||
|
||||
free(req);
|
||||
|
||||
@@ -482,12 +483,12 @@ static int idedrv_do_write_irqs(struct idedrv* idedrv, size_t sector, size_t sec
|
||||
|
||||
req->sector_done_count = 1;
|
||||
|
||||
intr_enable();
|
||||
biglock_unlock();
|
||||
|
||||
while (!atomic_load(&req->done))
|
||||
spin_lock_relax();
|
||||
|
||||
intr_disable();
|
||||
biglock_lock();
|
||||
|
||||
free(req);
|
||||
|
||||
@@ -616,7 +617,7 @@ DEFINE_DEVICE_OP(idedrv_write) {
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP(idedrv_get_device_type) {
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
(void)proc, (void)rctx, (void)device, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -629,7 +630,7 @@ DEFINE_DEVICE_OP(idedrv_get_device_type) {
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP(idedrv_get_sector_size) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -644,7 +645,7 @@ DEFINE_DEVICE_OP(idedrv_get_sector_size) {
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP(idedrv_get_size) {
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4, (void)lockflags;
|
||||
(void)proc, (void)rctx, (void)a2, (void)a3, (void)a4;
|
||||
|
||||
if (a1 == NULL)
|
||||
return -ST_BAD_ADDRESS_SPACE;
|
||||
@@ -659,24 +660,16 @@ DEFINE_DEVICE_OP(idedrv_get_size) {
|
||||
}
|
||||
|
||||
DEFINE_DEVICE_OP(idedrv_partition_rescan) {
|
||||
uint64_t fsd;
|
||||
|
||||
struct list_node_link *subdevice_link, *tmp_subdevice_link;
|
||||
list_foreach(device->subdevices, subdevice_link, tmp_subdevice_link) {
|
||||
struct device* subdevice = list_entry(subdevice_link, struct device, subdevices_link);
|
||||
|
||||
spin_lock(&subdevice->lock, &fsd);
|
||||
list_remove(device->subdevices, &subdevice->subdevices_link);
|
||||
spin_unlock(&subdevice->lock, fsd);
|
||||
|
||||
device_delete(subdevice->key, proc, rctx);
|
||||
}
|
||||
|
||||
spin_unlock(&device->lock, *lockflags);
|
||||
|
||||
int r = device_probe_partitions(proc, rctx, device);
|
||||
|
||||
spin_lock(&device->lock, lockflags);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user