Skip to content

Commit 8182d7a

Browse files
committed
Merge tag 'ata-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata
Pull ata fixes from Damien Le Moal: - Three fixes for the pata_parport driver to address a typo in the code, a missing operation implementation and port reset handling in the presence of slave devices (Ondrej) - Fix handling of ATAPI devices reset with the fit3 protocol driver of the pata_parport driver (Ondrej) - A follow up fix for the recent suspend/resume corrections to avoid attempting rescanning on resume the scsi device associated with an ata disk when the request queue of the scsi device is still suspended (in addition to not doing the rescan if the scsi device itself is still suspended) (me) * tag 'ata-6.6-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/dlemoal/libata: scsi: Do not rescan devices with a suspended queue ata: pata_parport: fit3: implement IDE command set registers ata: pata_parport: add custom version of wait_after_reset ata: pata_parport: implement set_devctl ata: pata_parport: fix pata_parport_devchk
2 parents bab19d1 + 626b13f commit 8182d7a

File tree

3 files changed

+84
-19
lines changed

3 files changed

+84
-19
lines changed

drivers/ata/pata_parport/fit3.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
*
1010
* The TD-2000 and certain older devices use a different protocol.
1111
* Try the fit2 protocol module with them.
12-
*
13-
* NB: The FIT adapters do not appear to support the control
14-
* registers. So, we map ALT_STATUS to STATUS and NO-OP writes
15-
* to the device control register - this means that IDE reset
16-
* will not work on these devices.
1712
*/
1813

1914
#include <linux/module.h>
@@ -37,8 +32,7 @@
3732

3833
static void fit3_write_regr(struct pi_adapter *pi, int cont, int regr, int val)
3934
{
40-
if (cont == 1)
41-
return;
35+
regr += cont << 3;
4236

4337
switch (pi->mode) {
4438
case 0:
@@ -59,11 +53,7 @@ static int fit3_read_regr(struct pi_adapter *pi, int cont, int regr)
5953
{
6054
int a, b;
6155

62-
if (cont) {
63-
if (regr != 6)
64-
return 0xff;
65-
regr = 7;
66-
}
56+
regr += cont << 3;
6757

6858
switch (pi->mode) {
6959
case 0:

drivers/ata/pata_parport/pata_parport.c

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ static void pata_parport_dev_select(struct ata_port *ap, unsigned int device)
5151
ata_sff_pause(ap);
5252
}
5353

54+
static void pata_parport_set_devctl(struct ata_port *ap, u8 ctl)
55+
{
56+
struct pi_adapter *pi = ap->host->private_data;
57+
58+
pi->proto->write_regr(pi, 1, 6, ctl);
59+
}
60+
5461
static bool pata_parport_devchk(struct ata_port *ap, unsigned int device)
5562
{
5663
struct pi_adapter *pi = ap->host->private_data;
@@ -64,7 +71,7 @@ static bool pata_parport_devchk(struct ata_port *ap, unsigned int device)
6471
pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 0xaa);
6572
pi->proto->write_regr(pi, 0, ATA_REG_LBAL, 0x55);
6673

67-
pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 055);
74+
pi->proto->write_regr(pi, 0, ATA_REG_NSECT, 0x55);
6875
pi->proto->write_regr(pi, 0, ATA_REG_LBAL, 0xaa);
6976

7077
nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT);
@@ -73,6 +80,72 @@ static bool pata_parport_devchk(struct ata_port *ap, unsigned int device)
7380
return (nsect == 0x55) && (lbal == 0xaa);
7481
}
7582

83+
static int pata_parport_wait_after_reset(struct ata_link *link,
84+
unsigned int devmask,
85+
unsigned long deadline)
86+
{
87+
struct ata_port *ap = link->ap;
88+
struct pi_adapter *pi = ap->host->private_data;
89+
unsigned int dev0 = devmask & (1 << 0);
90+
unsigned int dev1 = devmask & (1 << 1);
91+
int rc, ret = 0;
92+
93+
ata_msleep(ap, ATA_WAIT_AFTER_RESET);
94+
95+
/* always check readiness of the master device */
96+
rc = ata_sff_wait_ready(link, deadline);
97+
if (rc) {
98+
/*
99+
* some adapters return bogus values if master device is not
100+
* present, so don't abort now if a slave device is present
101+
*/
102+
if (!dev1)
103+
return rc;
104+
ret = -ENODEV;
105+
}
106+
107+
/*
108+
* if device 1 was found in ata_devchk, wait for register
109+
* access briefly, then wait for BSY to clear.
110+
*/
111+
if (dev1) {
112+
int i;
113+
114+
pata_parport_dev_select(ap, 1);
115+
116+
/*
117+
* Wait for register access. Some ATAPI devices fail
118+
* to set nsect/lbal after reset, so don't waste too
119+
* much time on it. We're gonna wait for !BSY anyway.
120+
*/
121+
for (i = 0; i < 2; i++) {
122+
u8 nsect, lbal;
123+
124+
nsect = pi->proto->read_regr(pi, 0, ATA_REG_NSECT);
125+
lbal = pi->proto->read_regr(pi, 0, ATA_REG_LBAL);
126+
if (nsect == 1 && lbal == 1)
127+
break;
128+
/* give drive a breather */
129+
ata_msleep(ap, 50);
130+
}
131+
132+
rc = ata_sff_wait_ready(link, deadline);
133+
if (rc) {
134+
if (rc != -ENODEV)
135+
return rc;
136+
ret = rc;
137+
}
138+
}
139+
140+
pata_parport_dev_select(ap, 0);
141+
if (dev1)
142+
pata_parport_dev_select(ap, 1);
143+
if (dev0)
144+
pata_parport_dev_select(ap, 0);
145+
146+
return ret;
147+
}
148+
76149
static int pata_parport_bus_softreset(struct ata_port *ap, unsigned int devmask,
77150
unsigned long deadline)
78151
{
@@ -87,7 +160,7 @@ static int pata_parport_bus_softreset(struct ata_port *ap, unsigned int devmask,
87160
ap->last_ctl = ap->ctl;
88161

89162
/* wait the port to become ready */
90-
return ata_sff_wait_after_reset(&ap->link, devmask, deadline);
163+
return pata_parport_wait_after_reset(&ap->link, devmask, deadline);
91164
}
92165

93166
static int pata_parport_softreset(struct ata_link *link, unsigned int *classes,
@@ -252,6 +325,7 @@ static struct ata_port_operations pata_parport_port_ops = {
252325
.hardreset = NULL,
253326

254327
.sff_dev_select = pata_parport_dev_select,
328+
.sff_set_devctl = pata_parport_set_devctl,
255329
.sff_check_status = pata_parport_check_status,
256330
.sff_check_altstatus = pata_parport_check_altstatus,
257331
.sff_tf_load = pata_parport_tf_load,

drivers/scsi/scsi_scan.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,12 +1627,13 @@ int scsi_rescan_device(struct scsi_device *sdev)
16271627
device_lock(dev);
16281628

16291629
/*
1630-
* Bail out if the device is not running. Otherwise, the rescan may
1631-
* block waiting for commands to be executed, with us holding the
1632-
* device lock. This can result in a potential deadlock in the power
1633-
* management core code when system resume is on-going.
1630+
* Bail out if the device or its queue are not running. Otherwise,
1631+
* the rescan may block waiting for commands to be executed, with us
1632+
* holding the device lock. This can result in a potential deadlock
1633+
* in the power management core code when system resume is on-going.
16341634
*/
1635-
if (sdev->sdev_state != SDEV_RUNNING) {
1635+
if (sdev->sdev_state != SDEV_RUNNING ||
1636+
blk_queue_pm_only(sdev->request_queue)) {
16361637
ret = -EWOULDBLOCK;
16371638
goto unlock;
16381639
}

0 commit comments

Comments
 (0)