Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3a644142 authored by Omar Sandoval's avatar Omar Sandoval Committed by Jens Axboe
Browse files

parport/pf: stop sharing request queue across multiple gendisks



Compile-tested only.

Cc: Tim Waugh <tim@cyberelk.net>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarJens Axboe <axboe@fb.com>
parent 547b50a1
Loading
Loading
Loading
Loading
+38 −19
Original line number Original line Diff line number Diff line
@@ -287,6 +287,12 @@ static void __init pf_init_units(void)
		struct gendisk *disk = alloc_disk(1);
		struct gendisk *disk = alloc_disk(1);
		if (!disk)
		if (!disk)
			continue;
			continue;
		disk->queue = blk_init_queue(do_pf_request, &pf_spin_lock);
		if (!disk->queue) {
			put_disk(disk);
			return;
		}
		blk_queue_max_segments(disk->queue, cluster);
		pf->disk = disk;
		pf->disk = disk;
		pf->pi = &pf->pia;
		pf->pi = &pf->pia;
		pf->media_status = PF_NM;
		pf->media_status = PF_NM;
@@ -772,7 +778,28 @@ static int pf_ready(void)
	return (((status_reg(pf_current) & (STAT_BUSY | pf_mask)) == pf_mask));
	return (((status_reg(pf_current) & (STAT_BUSY | pf_mask)) == pf_mask));
}
}


static struct request_queue *pf_queue;
static int pf_queue;

static int set_next_request(void)
{
	struct pf_unit *pf;
	struct request_queue *q;
	int old_pos = pf_queue;

	do {
		pf = &units[pf_queue];
		q = pf->present ? pf->disk->queue : NULL;
		if (++pf_queue == PF_UNITS)
			pf_queue = 0;
		if (q) {
			pf_req = blk_fetch_request(q);
			if (pf_req)
				break;
		}
	} while (pf_queue != old_pos);

	return pf_req != NULL;
}


static void pf_end_request(int err)
static void pf_end_request(int err)
{
{
@@ -780,16 +807,13 @@ static void pf_end_request(int err)
		pf_req = NULL;
		pf_req = NULL;
}
}


static void do_pf_request(struct request_queue * q)
static void pf_request(void)
{
{
	if (pf_busy)
	if (pf_busy)
		return;
		return;
repeat:
repeat:
	if (!pf_req) {
	if (!pf_req && !set_next_request())
		pf_req = blk_fetch_request(q);
		if (!pf_req)
		return;
		return;
	}


	pf_current = pf_req->rq_disk->private_data;
	pf_current = pf_req->rq_disk->private_data;
	pf_block = blk_rq_pos(pf_req);
	pf_block = blk_rq_pos(pf_req);
@@ -817,6 +841,11 @@ static void do_pf_request(struct request_queue * q)
	}
	}
}
}


static void do_pf_request(struct request_queue *q)
{
	pf_request();
}

static int pf_next_buf(void)
static int pf_next_buf(void)
{
{
	unsigned long saved_flags;
	unsigned long saved_flags;
@@ -846,7 +875,7 @@ static inline void next_request(int err)
	spin_lock_irqsave(&pf_spin_lock, saved_flags);
	spin_lock_irqsave(&pf_spin_lock, saved_flags);
	pf_end_request(err);
	pf_end_request(err);
	pf_busy = 0;
	pf_busy = 0;
	do_pf_request(pf_queue);
	pf_request();
	spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
	spin_unlock_irqrestore(&pf_spin_lock, saved_flags);
}
}


@@ -972,15 +1001,6 @@ static int __init pf_init(void)
			put_disk(pf->disk);
			put_disk(pf->disk);
		return -EBUSY;
		return -EBUSY;
	}
	}
	pf_queue = blk_init_queue(do_pf_request, &pf_spin_lock);
	if (!pf_queue) {
		unregister_blkdev(major, name);
		for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++)
			put_disk(pf->disk);
		return -ENOMEM;
	}

	blk_queue_max_segments(pf_queue, cluster);


	for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
	for (pf = units, unit = 0; unit < PF_UNITS; pf++, unit++) {
		struct gendisk *disk = pf->disk;
		struct gendisk *disk = pf->disk;
@@ -988,7 +1008,6 @@ static int __init pf_init(void)
		if (!pf->present)
		if (!pf->present)
			continue;
			continue;
		disk->private_data = pf;
		disk->private_data = pf;
		disk->queue = pf_queue;
		add_disk(disk);
		add_disk(disk);
	}
	}
	return 0;
	return 0;
@@ -1003,10 +1022,10 @@ static void __exit pf_exit(void)
		if (!pf->present)
		if (!pf->present)
			continue;
			continue;
		del_gendisk(pf->disk);
		del_gendisk(pf->disk);
		blk_cleanup_queue(pf->disk->queue);
		put_disk(pf->disk);
		put_disk(pf->disk);
		pi_release(pf->pi);
		pi_release(pf->pi);
	}
	}
	blk_cleanup_queue(pf_queue);
}
}


MODULE_LICENSE("GPL");
MODULE_LICENSE("GPL");