2 pd.c (c) 1997-8 Grant R. Guenther <grant@torque.net>
3 Under the terms of the GNU General Public License.
5 This is the high-level driver for parallel port IDE hard
6 drives based on chips supported by the paride module.
8 By default, the driver will autoprobe for a single parallel
9 port IDE drive, but if their individual parameters are
10 specified, the driver can handle up to 4 drives.
12 The behaviour of the pd driver can be altered by setting
13 some parameters from the insmod command line. The following
14 parameters are adjustable:
16 drive0 These four arguments can be arrays of
17 drive1 1-8 integers as follows:
19 drive3 <prt>,<pro>,<uni>,<mod>,<geo>,<sby>,<dly>,<slv>
23 <prt> is the base of the parallel port address for
24 the corresponding drive. (required)
26 <pro> is the protocol number for the adapter that
27 supports this drive. These numbers are
28 logged by 'paride' when the protocol modules
29 are initialised. (0 if not given)
31 <uni> for those adapters that support chained
32 devices, this is the unit selector for the
33 chain of devices on the given port. It should
34 be zero for devices that don't support chaining.
37 <mod> this can be -1 to choose the best mode, or one
38 of the mode numbers supported by the adapter.
41 <geo> this defaults to 0 to indicate that the driver
42 should use the CHS geometry provided by the drive
43 itself. If set to 1, the driver will provide
44 a logical geometry with 64 heads and 32 sectors
45 per track, to be consistent with most SCSI
46 drivers. (0 if not given)
48 <sby> set this to zero to disable the power saving
49 standby mode, if needed. (1 if not given)
51 <dly> some parallel ports require the driver to
52 go more slowly. -1 sets a default value that
53 should work with the chosen protocol. Otherwise,
54 set this to a small integer, the larger it is
55 the slower the port i/o. In some cases, setting
56 this to zero will speed up the device. (default -1)
58 <slv> IDE disks can be jumpered to master or slave.
59 Set this to 0 to choose the master drive, 1 to
60 choose the slave, -1 (the default) to choose the
64 major You may use this parameter to override the
65 default major number (45) that this driver
66 will use. Be sure to change the device
69 name This parameter is a character string that
70 contains the name the kernel will use for this
71 device (in /proc output, for instance).
74 cluster The driver will attempt to aggregate requests
75 for adjacent blocks into larger multi-block
76 clusters. The maximum cluster size (in 512
77 byte sectors) is set with this parameter.
80 verbose This parameter controls the amount of logging
81 that the driver will do. Set it to 0 for
82 normal operation, 1 to see autoprobe progress
83 messages, or 2 to see additional debugging
86 nice This parameter controls the driver's use of
87 idle CPU time, at the expense of some speed.
89 If this driver is built into the kernel, you can use kernel
90 the following command line parameters, with the same values
91 as the corresponding module parameters listed above:
100 In addition, you can use the parameter pd.disable to disable
107 1.01 GRG 1997.01.24 Restored pd_reset()
109 1.02 GRG 1998.05.06 SMP spinlock changes,
111 1.03 GRG 1998.06.16 Eliminate an Ugh.
112 1.04 GRG 1998.08.15 Extra debugging, use HZ in loop timing
113 1.05 GRG 1998.09.24 Added jumbo support
117 #define PD_VERSION "1.05"
122 /* Here are things one can override from the insmod command.
123 Most are autoprobed by paride unless set here. Verbose is off
127 #include <linux/types.h>
129 static int verbose = 0;
130 static int major = PD_MAJOR;
131 static char *name = PD_NAME;
132 static int cluster = 64;
134 static int disable = 0;
136 static int drive0[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
137 static int drive1[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
138 static int drive2[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
139 static int drive3[8] = { 0, 0, 0, -1, 0, 1, -1, -1 };
141 static int (*drives[4])[8] = {&drive0, &drive1, &drive2, &drive3};
143 enum {D_PRT, D_PRO, D_UNI, D_MOD, D_GEO, D_SBY, D_DLY, D_SLV};
145 /* end of parameters */
147 #include <linux/init.h>
148 #include <linux/module.h>
149 #include <linux/gfp.h>
150 #include <linux/fs.h>
151 #include <linux/delay.h>
152 #include <linux/hdreg.h>
153 #include <linux/cdrom.h> /* for the eject ioctl */
154 #include <linux/blk-mq.h>
155 #include <linux/blkpg.h>
156 #include <linux/kernel.h>
157 #include <linux/mutex.h>
158 #include <linux/uaccess.h>
159 #include <linux/workqueue.h>
161 static DEFINE_MUTEX(pd_mutex);
162 static DEFINE_SPINLOCK(pd_lock);
164 module_param(verbose, int, 0);
165 module_param(major, int, 0);
166 module_param(name, charp, 0);
167 module_param(cluster, int, 0);
168 module_param(nice, int, 0);
169 module_param_array(drive0, int, NULL, 0);
170 module_param_array(drive1, int, NULL, 0);
171 module_param_array(drive2, int, NULL, 0);
172 module_param_array(drive3, int, NULL, 0);
178 /* numbers for "SCSI" geometry */
180 #define PD_LOG_HEADS 64
181 #define PD_LOG_SECTS 32
186 #define PD_MAX_RETRIES 5
187 #define PD_TMO 800 /* interrupt timeout in jiffies */
188 #define PD_SPIN_DEL 50 /* spin delay in micro-seconds */
190 #define PD_SPIN (1000000*PD_TMO)/(HZ*PD_SPIN_DEL)
192 #define STAT_ERR 0x00001
193 #define STAT_INDEX 0x00002
194 #define STAT_ECC 0x00004
195 #define STAT_DRQ 0x00008
196 #define STAT_SEEK 0x00010
197 #define STAT_WRERR 0x00020
198 #define STAT_READY 0x00040
199 #define STAT_BUSY 0x00080
201 #define ERR_AMNF 0x00100
202 #define ERR_TK0NF 0x00200
203 #define ERR_ABRT 0x00400
204 #define ERR_MCR 0x00800
205 #define ERR_IDNF 0x01000
206 #define ERR_MC 0x02000
207 #define ERR_UNC 0x04000
208 #define ERR_TMO 0x10000
210 #define IDE_READ 0x20
211 #define IDE_WRITE 0x30
212 #define IDE_READ_VRFY 0x40
213 #define IDE_INIT_DEV_PARMS 0x91
214 #define IDE_STANDBY 0x96
215 #define IDE_ACKCHANGE 0xdb
216 #define IDE_DOORLOCK 0xde
217 #define IDE_DOORUNLOCK 0xdf
218 #define IDE_IDENTIFY 0xec
219 #define IDE_EJECT 0xed
224 struct pi_adapter pia; /* interface to paride layer */
225 struct pi_adapter *pi;
226 int access; /* count of active opens ... */
227 int capacity; /* Size of this volume in sectors */
228 int heads; /* physical geometry */
232 int drive; /* master=0 slave=1 */
233 int changed; /* Have we seen a disk change ? */
234 int removable; /* removable media device ? */
237 char name[PD_NAMELEN]; /* pda, pdb, etc ... */
239 struct blk_mq_tag_set tag_set;
240 struct list_head rq_list;
243 static struct pd_unit pd[PD_UNITS];
246 /* for REQ_OP_DRV_IN: */
247 enum action (*func)(struct pd_unit *disk);
250 static char pd_scratch[512]; /* scratch block buffer */
252 static char *pd_errs[17] = { "ERR", "INDEX", "ECC", "DRQ", "SEEK", "WRERR",
253 "READY", "BUSY", "AMNF", "TK0NF", "ABRT", "MCR",
254 "IDNF", "MC", "UNC", "???", "TMO"
257 static void *par_drv; /* reference of parport driver */
259 static inline int status_reg(struct pd_unit *disk)
261 return pi_read_regr(disk->pi, 1, 6);
264 static inline int read_reg(struct pd_unit *disk, int reg)
266 return pi_read_regr(disk->pi, 0, reg);
269 static inline void write_status(struct pd_unit *disk, int val)
271 pi_write_regr(disk->pi, 1, 6, val);
274 static inline void write_reg(struct pd_unit *disk, int reg, int val)
276 pi_write_regr(disk->pi, 0, reg, val);
279 static inline u8 DRIVE(struct pd_unit *disk)
281 return 0xa0+0x10*disk->drive;
284 /* ide command interface */
286 static void pd_print_error(struct pd_unit *disk, char *msg, int status)
290 printk("%s: %s: status = 0x%x =", disk->name, msg, status);
291 for (i = 0; i < ARRAY_SIZE(pd_errs); i++)
292 if (status & (1 << i))
293 printk(" %s", pd_errs[i]);
297 static void pd_reset(struct pd_unit *disk)
298 { /* called only for MASTER drive */
299 write_status(disk, 4);
301 write_status(disk, 0);
305 #define DBMSG(msg) ((verbose>1)?(msg):NULL)
307 static int pd_wait_for(struct pd_unit *disk, int w, char *msg)
312 while (k < PD_SPIN) {
313 r = status_reg(disk);
315 if (((r & w) == w) && !(r & STAT_BUSY))
319 e = (read_reg(disk, 1) << 8) + read_reg(disk, 7);
322 if ((e & (STAT_ERR | ERR_TMO)) && (msg != NULL))
323 pd_print_error(disk, msg, e);
327 static void pd_send_command(struct pd_unit *disk, int n, int s, int h, int c0, int c1, int func)
329 write_reg(disk, 6, DRIVE(disk) + h);
330 write_reg(disk, 1, 0); /* the IDE task file */
331 write_reg(disk, 2, n);
332 write_reg(disk, 3, s);
333 write_reg(disk, 4, c0);
334 write_reg(disk, 5, c1);
335 write_reg(disk, 7, func);
340 static void pd_ide_command(struct pd_unit *disk, int func, int block, int count)
346 c0 = (block >>= 8) & 255;
347 c1 = (block >>= 8) & 255;
348 h = ((block >>= 8) & 15) + 0x40;
350 s = (block % disk->sectors) + 1;
351 h = (block /= disk->sectors) % disk->heads;
352 c0 = (block /= disk->heads) % 256;
355 pd_send_command(disk, count, s, h, c0, c1, func);
358 /* The i/o request engine */
360 enum action {Fail = 0, Ok = 1, Hold, Wait};
362 static struct request *pd_req; /* current request */
363 static enum action (*phase)(void);
365 static void run_fsm(void);
367 static void ps_tq_int(struct work_struct *work);
369 static DECLARE_DELAYED_WORK(fsm_tq, ps_tq_int);
371 static void schedule_fsm(void)
374 schedule_delayed_work(&fsm_tq, 0);
376 schedule_delayed_work(&fsm_tq, nice-1);
379 static void ps_tq_int(struct work_struct *work)
384 static enum action do_pd_io_start(void);
385 static enum action pd_special(void);
386 static enum action do_pd_read_start(void);
387 static enum action do_pd_write_start(void);
388 static enum action do_pd_read_drq(void);
389 static enum action do_pd_write_done(void);
392 static int pd_claimed;
394 static struct pd_unit *pd_current; /* current request's drive */
395 static PIA *pi_current; /* current request's PIA */
397 static int set_next_request(void)
399 struct gendisk *disk;
400 struct request_queue *q;
401 int old_pos = pd_queue;
404 disk = pd[pd_queue].gd;
405 q = disk ? disk->queue : NULL;
406 if (++pd_queue == PD_UNITS)
409 struct pd_unit *disk = q->queuedata;
411 if (list_empty(&disk->rq_list))
414 pd_req = list_first_entry(&disk->rq_list,
417 list_del_init(&pd_req->queuelist);
418 blk_mq_start_request(pd_req);
421 } while (pd_queue != old_pos);
423 return pd_req != NULL;
426 static void run_fsm(void)
433 pd_current = pd_req->rq_disk->private_data;
434 pi_current = pd_current->pi;
435 phase = do_pd_io_start;
438 switch (pd_claimed) {
441 if (!pi_schedule_claimed(pi_current, run_fsm))
446 pi_current->proto->connect(pi_current);
449 switch(res = phase()) {
450 case Ok: case Fail: {
453 err = res == Ok ? 0 : BLK_STS_IOERR;
454 pi_disconnect(pi_current);
457 spin_lock_irq(&pd_lock);
458 if (!blk_update_request(pd_req, err,
459 blk_rq_cur_bytes(pd_req))) {
460 __blk_mq_end_request(pd_req, err);
462 stop = !set_next_request();
464 spin_unlock_irq(&pd_lock);
473 pi_disconnect(pi_current);
479 static int pd_retries = 0; /* i/o error retry count */
480 static int pd_block; /* address of next requested block */
481 static int pd_count; /* number of blocks still to do */
482 static int pd_run; /* sectors in current cluster */
483 static char *pd_buf; /* buffer for request in progress */
485 static enum action do_pd_io_start(void)
487 switch (req_op(pd_req)) {
493 pd_block = blk_rq_pos(pd_req);
494 pd_count = blk_rq_cur_sectors(pd_req);
495 if (pd_block + pd_count > get_capacity(pd_req->rq_disk))
497 pd_run = blk_rq_sectors(pd_req);
498 pd_buf = bio_data(pd_req->bio);
500 if (req_op(pd_req) == REQ_OP_READ)
501 return do_pd_read_start();
503 return do_pd_write_start();
508 static enum action pd_special(void)
510 struct pd_req *req = blk_mq_rq_to_pdu(pd_req);
512 return req->func(pd_current);
515 static int pd_next_buf(void)
517 unsigned long saved_flags;
527 spin_lock_irqsave(&pd_lock, saved_flags);
528 if (!blk_update_request(pd_req, 0, blk_rq_cur_bytes(pd_req))) {
529 __blk_mq_end_request(pd_req, 0);
534 pd_count = blk_rq_cur_sectors(pd_req);
535 pd_buf = bio_data(pd_req->bio);
537 spin_unlock_irqrestore(&pd_lock, saved_flags);
541 static unsigned long pd_timeout;
543 static enum action do_pd_read_start(void)
545 if (pd_wait_for(pd_current, STAT_READY, "do_pd_read") & STAT_ERR) {
546 if (pd_retries < PD_MAX_RETRIES) {
552 pd_ide_command(pd_current, IDE_READ, pd_block, pd_run);
553 phase = do_pd_read_drq;
554 pd_timeout = jiffies + PD_TMO;
558 static enum action do_pd_write_start(void)
560 if (pd_wait_for(pd_current, STAT_READY, "do_pd_write") & STAT_ERR) {
561 if (pd_retries < PD_MAX_RETRIES) {
567 pd_ide_command(pd_current, IDE_WRITE, pd_block, pd_run);
569 if (pd_wait_for(pd_current, STAT_DRQ, "do_pd_write_drq") & STAT_ERR) {
570 if (pd_retries < PD_MAX_RETRIES) {
576 pi_write_block(pd_current->pi, pd_buf, 512);
580 phase = do_pd_write_done;
581 pd_timeout = jiffies + PD_TMO;
585 static inline int pd_ready(void)
587 return !(status_reg(pd_current) & STAT_BUSY);
590 static enum action do_pd_read_drq(void)
592 if (!pd_ready() && !time_after_eq(jiffies, pd_timeout))
596 if (pd_wait_for(pd_current, STAT_DRQ, "do_pd_read_drq") & STAT_ERR) {
597 if (pd_retries < PD_MAX_RETRIES) {
599 phase = do_pd_read_start;
604 pi_read_block(pd_current->pi, pd_buf, 512);
611 static enum action do_pd_write_done(void)
613 if (!pd_ready() && !time_after_eq(jiffies, pd_timeout))
616 if (pd_wait_for(pd_current, STAT_READY, "do_pd_write_done") & STAT_ERR) {
617 if (pd_retries < PD_MAX_RETRIES) {
619 phase = do_pd_write_start;
627 /* special io requests */
629 /* According to the ATA standard, the default CHS geometry should be
630 available following a reset. Some Western Digital drives come up
631 in a mode where only LBA addresses are accepted until the device
632 parameters are initialised.
635 static void pd_init_dev_parms(struct pd_unit *disk)
637 pd_wait_for(disk, 0, DBMSG("before init_dev_parms"));
638 pd_send_command(disk, disk->sectors, 0, disk->heads - 1, 0, 0,
641 pd_wait_for(disk, 0, "Initialise device parameters");
644 static enum action pd_door_lock(struct pd_unit *disk)
646 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
647 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORLOCK);
648 pd_wait_for(disk, STAT_READY, "Lock done");
653 static enum action pd_door_unlock(struct pd_unit *disk)
655 if (!(pd_wait_for(disk, STAT_READY, "Lock") & STAT_ERR)) {
656 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
657 pd_wait_for(disk, STAT_READY, "Lock done");
662 static enum action pd_eject(struct pd_unit *disk)
664 pd_wait_for(disk, 0, DBMSG("before unlock on eject"));
665 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_DOORUNLOCK);
666 pd_wait_for(disk, 0, DBMSG("after unlock on eject"));
667 pd_wait_for(disk, 0, DBMSG("before eject"));
668 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_EJECT);
669 pd_wait_for(disk, 0, DBMSG("after eject"));
673 static enum action pd_media_check(struct pd_unit *disk)
675 int r = pd_wait_for(disk, STAT_READY, DBMSG("before media_check"));
676 if (!(r & STAT_ERR)) {
677 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
678 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after READ_VRFY"));
680 disk->changed = 1; /* say changed if other error */
683 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_ACKCHANGE);
684 pd_wait_for(disk, STAT_READY, DBMSG("RDY after ACKCHANGE"));
685 pd_send_command(disk, 1, 1, 0, 0, 0, IDE_READ_VRFY);
686 r = pd_wait_for(disk, STAT_READY, DBMSG("RDY after VRFY"));
691 static void pd_standby_off(struct pd_unit *disk)
693 pd_wait_for(disk, 0, DBMSG("before STANDBY"));
694 pd_send_command(disk, 0, 0, 0, 0, 0, IDE_STANDBY);
695 pd_wait_for(disk, 0, DBMSG("after STANDBY"));
698 static enum action pd_identify(struct pd_unit *disk)
701 char id[PD_ID_LEN + 1];
703 /* WARNING: here there may be dragons. reset() applies to both drives,
704 but we call it only on probing the MASTER. This should allow most
705 common configurations to work, but be warned that a reset can clear
706 settings on the SLAVE drive.
709 if (disk->drive == 0)
712 write_reg(disk, 6, DRIVE(disk));
713 pd_wait_for(disk, 0, DBMSG("before IDENT"));
714 pd_send_command(disk, 1, 0, 0, 0, 0, IDE_IDENTIFY);
716 if (pd_wait_for(disk, STAT_DRQ, DBMSG("IDENT DRQ")) & STAT_ERR)
718 pi_read_block(disk->pi, pd_scratch, 512);
719 disk->can_lba = pd_scratch[99] & 2;
720 disk->sectors = le16_to_cpu(*(__le16 *) (pd_scratch + 12));
721 disk->heads = le16_to_cpu(*(__le16 *) (pd_scratch + 6));
722 disk->cylinders = le16_to_cpu(*(__le16 *) (pd_scratch + 2));
724 disk->capacity = le32_to_cpu(*(__le32 *) (pd_scratch + 120));
726 disk->capacity = disk->sectors * disk->heads * disk->cylinders;
728 for (j = 0; j < PD_ID_LEN; j++)
729 id[j ^ 1] = pd_scratch[j + PD_ID_OFF];
731 while ((j >= 0) && (id[j] <= 0x20))
736 disk->removable = pd_scratch[0] & 0x80;
738 printk("%s: %s, %s, %d blocks [%dM], (%d/%d/%d), %s media\n",
740 disk->drive ? "slave" : "master",
741 disk->capacity, disk->capacity / 2048,
742 disk->cylinders, disk->heads, disk->sectors,
743 disk->removable ? "removable" : "fixed");
746 pd_init_dev_parms(disk);
748 pd_standby_off(disk);
753 /* end of io request engine */
755 static blk_status_t pd_queue_rq(struct blk_mq_hw_ctx *hctx,
756 const struct blk_mq_queue_data *bd)
758 struct pd_unit *disk = hctx->queue->queuedata;
760 spin_lock_irq(&pd_lock);
763 blk_mq_start_request(pd_req);
765 list_add_tail(&bd->rq->queuelist, &disk->rq_list);
766 spin_unlock_irq(&pd_lock);
772 static int pd_special_command(struct pd_unit *disk,
773 enum action (*func)(struct pd_unit *disk))
778 rq = blk_get_request(disk->gd->queue, REQ_OP_DRV_IN, 0);
781 req = blk_mq_rq_to_pdu(rq);
784 blk_execute_rq(disk->gd->queue, disk->gd, rq, 0);
789 /* kernel glue structures */
791 static int pd_open(struct block_device *bdev, fmode_t mode)
793 struct pd_unit *disk = bdev->bd_disk->private_data;
795 mutex_lock(&pd_mutex);
798 if (disk->removable) {
799 pd_special_command(disk, pd_media_check);
800 pd_special_command(disk, pd_door_lock);
802 mutex_unlock(&pd_mutex);
806 static int pd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
808 struct pd_unit *disk = bdev->bd_disk->private_data;
810 if (disk->alt_geom) {
811 geo->heads = PD_LOG_HEADS;
812 geo->sectors = PD_LOG_SECTS;
813 geo->cylinders = disk->capacity / (geo->heads * geo->sectors);
815 geo->heads = disk->heads;
816 geo->sectors = disk->sectors;
817 geo->cylinders = disk->cylinders;
823 static int pd_ioctl(struct block_device *bdev, fmode_t mode,
824 unsigned int cmd, unsigned long arg)
826 struct pd_unit *disk = bdev->bd_disk->private_data;
830 mutex_lock(&pd_mutex);
831 if (disk->access == 1)
832 pd_special_command(disk, pd_eject);
833 mutex_unlock(&pd_mutex);
840 static void pd_release(struct gendisk *p, fmode_t mode)
842 struct pd_unit *disk = p->private_data;
844 mutex_lock(&pd_mutex);
845 if (!--disk->access && disk->removable)
846 pd_special_command(disk, pd_door_unlock);
847 mutex_unlock(&pd_mutex);
850 static unsigned int pd_check_events(struct gendisk *p, unsigned int clearing)
852 struct pd_unit *disk = p->private_data;
854 if (!disk->removable)
856 pd_special_command(disk, pd_media_check);
859 return r ? DISK_EVENT_MEDIA_CHANGE : 0;
862 static int pd_revalidate(struct gendisk *p)
864 struct pd_unit *disk = p->private_data;
865 if (pd_special_command(disk, pd_identify) == 0)
866 set_capacity(p, disk->capacity);
872 static const struct block_device_operations pd_fops = {
873 .owner = THIS_MODULE,
875 .release = pd_release,
877 .compat_ioctl = pd_ioctl,
879 .check_events = pd_check_events,
880 .revalidate_disk= pd_revalidate
885 static const struct blk_mq_ops pd_mq_ops = {
886 .queue_rq = pd_queue_rq,
889 static void pd_probe_drive(struct pd_unit *disk)
893 p = alloc_disk(1 << PD_BITS);
897 strcpy(p->disk_name, disk->name);
900 p->first_minor = (disk - pd) << PD_BITS;
901 p->events = DISK_EVENT_MEDIA_CHANGE;
903 p->private_data = disk;
905 memset(&disk->tag_set, 0, sizeof(disk->tag_set));
906 disk->tag_set.ops = &pd_mq_ops;
907 disk->tag_set.cmd_size = sizeof(struct pd_req);
908 disk->tag_set.nr_hw_queues = 1;
909 disk->tag_set.nr_maps = 1;
910 disk->tag_set.queue_depth = 2;
911 disk->tag_set.numa_node = NUMA_NO_NODE;
912 disk->tag_set.flags = BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING;
914 if (blk_mq_alloc_tag_set(&disk->tag_set))
917 p->queue = blk_mq_init_queue(&disk->tag_set);
918 if (IS_ERR(p->queue)) {
919 blk_mq_free_tag_set(&disk->tag_set);
924 p->queue->queuedata = disk;
925 blk_queue_max_hw_sectors(p->queue, cluster);
926 blk_queue_bounce_limit(p->queue, BLK_BOUNCE_HIGH);
928 if (disk->drive == -1) {
929 for (disk->drive = 0; disk->drive <= 1; disk->drive++)
930 if (pd_special_command(disk, pd_identify) == 0)
932 } else if (pd_special_command(disk, pd_identify) == 0)
938 static int pd_detect(void)
940 int found = 0, unit, pd_drive_count = 0;
941 struct pd_unit *disk;
943 for (unit = 0; unit < PD_UNITS; unit++) {
944 int *parm = *drives[unit];
945 struct pd_unit *disk = pd + unit;
946 disk->pi = &disk->pia;
950 disk->drive = parm[D_SLV];
951 snprintf(disk->name, PD_NAMELEN, "%s%c", name, 'a'+unit);
952 disk->alt_geom = parm[D_GEO];
953 disk->standby = parm[D_SBY];
956 INIT_LIST_HEAD(&disk->rq_list);
959 par_drv = pi_register_driver(name);
961 pr_err("failed to register %s driver\n", name);
965 if (pd_drive_count == 0) { /* nothing spec'd - so autoprobe for 1 */
967 if (pi_init(disk->pi, 1, -1, -1, -1, -1, -1, pd_scratch,
968 PI_PD, verbose, disk->name)) {
969 pd_probe_drive(disk);
971 pi_release(disk->pi);
975 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
976 int *parm = *drives[unit];
979 if (pi_init(disk->pi, 0, parm[D_PRT], parm[D_MOD],
980 parm[D_UNI], parm[D_PRO], parm[D_DLY],
981 pd_scratch, PI_PD, verbose, disk->name)) {
982 pd_probe_drive(disk);
984 pi_release(disk->pi);
988 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
990 set_capacity(disk->gd, disk->capacity);
996 printk("%s: no valid drive found\n", name);
997 pi_unregister_driver(par_drv);
1002 static int __init pd_init(void)
1007 if (register_blkdev(major, name))
1010 printk("%s: %s version %s, major %d, cluster %d, nice %d\n",
1011 name, name, PD_VERSION, major, cluster, nice);
1018 unregister_blkdev(major, name);
1023 static void __exit pd_exit(void)
1025 struct pd_unit *disk;
1027 unregister_blkdev(major, name);
1028 for (unit = 0, disk = pd; unit < PD_UNITS; unit++, disk++) {
1029 struct gendisk *p = disk->gd;
1033 blk_cleanup_queue(p->queue);
1034 blk_mq_free_tag_set(&disk->tag_set);
1036 pi_release(disk->pi);
1041 MODULE_LICENSE("GPL");
1042 module_init(pd_init)
1043 module_exit(pd_exit)