Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/ide.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) static ide_startstop_t ide_ata_error(ide_drive_t *drive, struct request *rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 				     u8 stat, u8 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 	ide_hwif_t *hwif = drive->hwif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	if ((stat & ATA_BUSY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	    ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 		/* other bits are useless when BUSY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 		scsi_req(rq)->result |= ERROR_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	} else if (stat & ATA_ERR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		/* err has different meaning on cdrom and tape */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		if (err == ATA_ABORTED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 			if ((drive->dev_flags & IDE_DFLAG_LBA) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 			    /* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 			    hwif->tp_ops->read_status(hwif) == ATA_CMD_INIT_DEV_PARAMS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 				return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		} else if ((err & BAD_CRC) == BAD_CRC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 			/* UDMA crc error, just retry the operation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 			drive->crc_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		} else if (err & (ATA_BBK | ATA_UNC)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			/* retries won't help these */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 			scsi_req(rq)->result = ERROR_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		} else if (err & ATA_TRK0NF) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 			/* help it find track zero */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 			scsi_req(rq)->result |= ERROR_RECAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	if ((stat & ATA_DRQ) && rq_data_dir(rq) == READ &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	    (hwif->host_flags & IDE_HFLAG_ERROR_STOPS_FIFO) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		int nsect = drive->mult_count ? drive->mult_count : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		ide_pad_transfer(drive, READ, nsect * SECTOR_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	if (scsi_req(rq)->result >= ERROR_MAX || blk_noretry_request(rq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		ide_kill_rq(drive, rq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		scsi_req(rq)->result |= ERROR_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	if ((scsi_req(rq)->result & ERROR_RESET) == ERROR_RESET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		++scsi_req(rq)->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		return ide_do_reset(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	if ((scsi_req(rq)->result & ERROR_RECAL) == ERROR_RECAL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		drive->special_flags |= IDE_SFLAG_RECALIBRATE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	++scsi_req(rq)->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static ide_startstop_t ide_atapi_error(ide_drive_t *drive, struct request *rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 				       u8 stat, u8 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	ide_hwif_t *hwif = drive->hwif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	if ((stat & ATA_BUSY) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	    ((stat & ATA_DF) && (drive->dev_flags & IDE_DFLAG_NOWERR) == 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		/* other bits are useless when BUSY */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		scsi_req(rq)->result |= ERROR_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		/* add decoding error stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	if (hwif->tp_ops->read_status(hwif) & (ATA_BUSY | ATA_DRQ))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		/* force an abort */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		hwif->tp_ops->exec_command(hwif, ATA_CMD_IDLEIMMEDIATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	if (scsi_req(rq)->result >= ERROR_MAX) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		ide_kill_rq(drive, rq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		if ((scsi_req(rq)->result & ERROR_RESET) == ERROR_RESET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 			++scsi_req(rq)->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			return ide_do_reset(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		++scsi_req(rq)->result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static ide_startstop_t __ide_error(ide_drive_t *drive, struct request *rq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 				   u8 stat, u8 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (drive->media == ide_disk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		return ide_ata_error(drive, rq, stat, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	return ide_atapi_error(drive, rq, stat, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  *	ide_error	-	handle an error on the IDE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  *	@drive: drive the error occurred on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  *	@msg: message to report
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  *	@stat: status bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  *	ide_error() takes action based on the error returned by the drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  *	For normal I/O that may well include retries. We deal with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)  *	both new-style (taskfile) and old style command handling here.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)  *	In the case of taskfile command handling there is work left to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)  *	do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) ide_startstop_t ide_error(ide_drive_t *drive, const char *msg, u8 stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	struct request *rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	u8 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	err = ide_dump_status(drive, msg, stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	rq = drive->hwif->rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	if (rq == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	/* retry only "normal" I/O: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	if (blk_rq_is_passthrough(rq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 		if (ata_taskfile_request(rq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 			struct ide_cmd *cmd = ide_req(rq)->special;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 			if (cmd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 				ide_complete_cmd(drive, cmd, stat, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		} else if (ata_pm_request(rq)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 			scsi_req(rq)->result = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 			ide_complete_pm_rq(drive, rq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 			return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		scsi_req(rq)->result = err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		ide_complete_rq(drive, err ? BLK_STS_IOERR : BLK_STS_OK, blk_rq_bytes(rq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	return __ide_error(drive, rq, stat, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) EXPORT_SYMBOL_GPL(ide_error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static inline void ide_complete_drive_reset(ide_drive_t *drive, blk_status_t err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	struct request *rq = drive->hwif->rq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	if (rq && ata_misc_request(rq) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	    scsi_req(rq)->cmd[0] == REQ_DRIVE_RESET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 		if (err <= 0 && scsi_req(rq)->result == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 			scsi_req(rq)->result = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		ide_complete_rq(drive, err, blk_rq_bytes(rq));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* needed below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static ide_startstop_t do_reset1(ide_drive_t *, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)  * atapi_reset_pollfunc() gets invoked to poll the interface for completion
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)  * every 50ms during an atapi drive reset operation.  If the drive has not yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)  * responded, and we have not yet hit our maximum waiting time, then the timer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)  * is restarted for another 50ms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static ide_startstop_t atapi_reset_pollfunc(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	ide_hwif_t *hwif = drive->hwif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	const struct ide_tp_ops *tp_ops = hwif->tp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	u8 stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	tp_ops->dev_select(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	udelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	stat = tp_ops->read_status(hwif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	if (OK_STAT(stat, 0, ATA_BUSY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		printk(KERN_INFO "%s: ATAPI reset complete\n", drive->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		if (time_before(jiffies, hwif->poll_timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			/* continue polling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			return ide_started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		/* end of polling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 		hwif->polling = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		printk(KERN_ERR "%s: ATAPI reset timed-out, status=0x%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			drive->name, stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		/* do it the old fashioned way */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		return do_reset1(drive, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	/* done polling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	hwif->polling = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	ide_complete_drive_reset(drive, BLK_STS_OK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 	return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) static void ide_reset_report_error(ide_hwif_t *hwif, u8 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	static const char *err_master_vals[] =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 		{ NULL, "passed", "formatter device error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 		  "sector buffer error", "ECC circuitry error",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		  "controlling MPU error" };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	u8 err_master = err & 0x7f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	printk(KERN_ERR "%s: reset: master: ", hwif->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	if (err_master && err_master < 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		printk(KERN_CONT "%s", err_master_vals[err_master]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		printk(KERN_CONT "error (0x%02x?)", err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	if (err & 0x80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		printk(KERN_CONT "; slave: failed");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	printk(KERN_CONT "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)  * reset_pollfunc() gets invoked to poll the interface for completion every 50ms
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)  * during an ide reset operation. If the drives have not yet responded,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)  * and we have not yet hit our maximum waiting time, then the timer is restarted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)  * for another 50ms.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) static ide_startstop_t reset_pollfunc(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	ide_hwif_t *hwif = drive->hwif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	const struct ide_port_ops *port_ops = hwif->port_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	u8 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	blk_status_t err = BLK_STS_OK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	if (port_ops && port_ops->reset_poll) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		err = port_ops->reset_poll(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			printk(KERN_ERR "%s: host reset_poll failure for %s.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 				hwif->name, drive->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	tmp = hwif->tp_ops->read_status(hwif);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (!OK_STAT(tmp, 0, ATA_BUSY)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		if (time_before(jiffies, hwif->poll_timeout)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			ide_set_handler(drive, &reset_pollfunc, HZ/20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			/* continue polling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			return ide_started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		printk(KERN_ERR "%s: reset timed-out, status=0x%02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 			hwif->name, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 		drive->failures++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		err = BLK_STS_IOERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	} else  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		tmp = ide_read_error(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		if (tmp == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			printk(KERN_INFO "%s: reset: success\n", hwif->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			drive->failures = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			ide_reset_report_error(hwif, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 			drive->failures++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			err = BLK_STS_IOERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	hwif->polling = 0;	/* done polling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	ide_complete_drive_reset(drive, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static void ide_disk_pre_reset(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	int legacy = (drive->id[ATA_ID_CFS_ENABLE_2] & 0x0400) ? 0 : 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	drive->special_flags =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 		legacy ? (IDE_SFLAG_SET_GEOMETRY | IDE_SFLAG_RECALIBRATE) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	drive->mult_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	drive->dev_flags &= ~IDE_DFLAG_PARKED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	    (drive->dev_flags & IDE_DFLAG_USING_DMA) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		drive->mult_req = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	if (drive->mult_req != drive->mult_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 		drive->special_flags |= IDE_SFLAG_SET_MULTMODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) static void pre_reset(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	const struct ide_port_ops *port_ops = drive->hwif->port_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	if (drive->media == ide_disk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 		ide_disk_pre_reset(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		drive->dev_flags |= IDE_DFLAG_POST_RESET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	if (drive->dev_flags & IDE_DFLAG_USING_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		if (drive->crc_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			ide_check_dma_crc(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			ide_dma_off(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	if ((drive->dev_flags & IDE_DFLAG_KEEP_SETTINGS) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		if ((drive->dev_flags & IDE_DFLAG_USING_DMA) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			drive->dev_flags &= ~IDE_DFLAG_UNMASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 			drive->io_32bit = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	if (port_ops && port_ops->pre_reset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 		port_ops->pre_reset(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	if (drive->current_speed != 0xff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 		drive->desired_speed = drive->current_speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	drive->current_speed = 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321)  * do_reset1() attempts to recover a confused drive by resetting it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)  * Unfortunately, resetting a disk drive actually resets all devices on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)  * the same interface, so it can really be thought of as resetting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)  * interface rather than resetting the drive.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)  * ATAPI devices have their own reset mechanism which allows them to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327)  * individually reset without clobbering other devices on the same interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * Unfortunately, the IDE interface does not generate an interrupt to let
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * us know when the reset operation has finished, so we must poll for this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * Equally poor, though, is the fact that this may a very long time to complete,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * (up to 30 seconds worstcase).  So, instead of busy-waiting here for it,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  * we set a timer to poll at 50ms intervals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static ide_startstop_t do_reset1(ide_drive_t *drive, int do_not_try_atapi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	ide_hwif_t *hwif = drive->hwif;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	struct ide_io_ports *io_ports = &hwif->io_ports;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	const struct ide_tp_ops *tp_ops = hwif->tp_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	const struct ide_port_ops *port_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	ide_drive_t *tdrive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	unsigned long flags, timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	DEFINE_WAIT(wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	spin_lock_irqsave(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	/* We must not reset with running handlers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	BUG_ON(hwif->handler != NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	/* For an ATAPI device, first try an ATAPI SRST. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	if (drive->media != ide_disk && !do_not_try_atapi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		pre_reset(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		tp_ops->dev_select(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		udelay(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 		tp_ops->exec_command(hwif, ATA_CMD_DEV_RESET);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		ndelay(400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		hwif->polling = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		__ide_set_handler(drive, &atapi_reset_pollfunc, HZ/20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		spin_unlock_irqrestore(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		return ide_started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	/* We must not disturb devices in the IDE_DFLAG_PARKED state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		unsigned long now;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		prepare_to_wait(&ide_park_wq, &wait, TASK_UNINTERRUPTIBLE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 		timeout = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		ide_port_for_each_present_dev(i, tdrive, hwif) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 			if ((tdrive->dev_flags & IDE_DFLAG_PARKED) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 			    time_after(tdrive->sleep, timeout))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 				timeout = tdrive->sleep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		now = jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		if (time_before_eq(timeout, now))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		spin_unlock_irqrestore(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		timeout = schedule_timeout_uninterruptible(timeout - now);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		spin_lock_irqsave(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	} while (timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	finish_wait(&ide_park_wq, &wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	 * First, reset any device state data we were maintaining
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	 * for any of the drives on this interface.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	ide_port_for_each_dev(i, tdrive, hwif)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		pre_reset(tdrive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	if (io_ports->ctl_addr == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		spin_unlock_irqrestore(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 		ide_complete_drive_reset(drive, BLK_STS_IOERR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		return ide_stopped;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	 * Note that we also set nIEN while resetting the device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	 * to mask unwanted interrupts from the interface during the reset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	 * However, due to the design of PC hardware, this will cause an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	 * immediate interrupt due to the edge transition it produces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	 * This single interrupt gives us a "fast poll" for drives that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	 * recover from reset very quickly, saving us the first 50ms wait time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	/* set SRST and nIEN */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	tp_ops->write_devctl(hwif, ATA_SRST | ATA_NIEN | ATA_DEVCTL_OBS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	/* more than enough time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 	udelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	/* clear SRST, leave nIEN (unless device is on the quirk list) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	tp_ops->write_devctl(hwif,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		((drive->dev_flags & IDE_DFLAG_NIEN_QUIRK) ? 0 : ATA_NIEN) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		 ATA_DEVCTL_OBS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	/* more than enough time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	udelay(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	hwif->poll_timeout = jiffies + WAIT_WORSTCASE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	hwif->polling = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	__ide_set_handler(drive, &reset_pollfunc, HZ/20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 	 * Some weird controller like resetting themselves to a strange
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	 * state when the disks are reset this way. At least, the Winbond
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	 * 553 documentation says that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	port_ops = hwif->port_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	if (port_ops && port_ops->resetproc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		port_ops->resetproc(drive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	spin_unlock_irqrestore(&hwif->lock, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	return ide_started;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  * ide_do_reset() is the entry point to the drive/interface reset code.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) ide_startstop_t ide_do_reset(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	return do_reset1(drive, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) EXPORT_SYMBOL(ide_do_reset);