Skip to content

Commit df6f9a9

Browse files
damien-lemoalfloatious
authored andcommitted
ata: libata-eh: Remove ata_do_eh()
The only reason for ata_do_eh() to exist is that the two caller sites, ata_std_error_handler() and ata_sff_error_handler() may pass it a NULL hardreset operation so that the built-in (generic) hardreset operation for a driver is ignored if the adapter SCR access is not available. However, ata_std_error_handler() and ata_sff_error_handler() modifications of the hardreset port operation can easily be combined as they are mutually exclusive. That is, a driver using sata_std_hardreset() as its hardreset operation cannot use sata_sff_hardreset() and vice-versa. With this observation, ata_do_eh() can be removed and its code moved to ata_std_error_handler(). The condition used to ignore the built-in hardreset port operation is modified to be the one that was used in ata_sff_error_handler(). This requires defining a stub for the function sata_sff_hardreset() to avoid compilation errors when CONFIG_ATA_SFF is not enabled. Furthermore, instead of modifying the local hardreset operation definition, set the ATA_LFLAG_NO_HRST link flag to prevent the use of built-in hardreset methods for ports without a valid scr_read function. This flag is checked in ata_eh_reset() and if set, the hardreset method is ignored. This change simplifies ata_sff_error_handler() as this function now only needs to call ata_std_error_handler(). No functional changes. Signed-off-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20250716020315.235457-2-dlemoal@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org>
1 parent 148fbaf commit df6f9a9

3 files changed

Lines changed: 21 additions & 46 deletions

File tree

drivers/ata/libata-eh.c

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4067,59 +4067,39 @@ void ata_eh_finish(struct ata_port *ap)
40674067
}
40684068

40694069
/**
4070-
* ata_do_eh - do standard error handling
4070+
* ata_std_error_handler - standard error handler
40714071
* @ap: host port to handle error for
40724072
*
4073-
* @prereset: prereset method (can be NULL)
4074-
* @softreset: softreset method (can be NULL)
4075-
* @hardreset: hardreset method (can be NULL)
4076-
* @postreset: postreset method (can be NULL)
4077-
*
40784073
* Perform standard error handling sequence.
40794074
*
40804075
* LOCKING:
40814076
* Kernel thread context (may sleep).
40824077
*/
4083-
void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
4084-
ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
4085-
ata_postreset_fn_t postreset)
4078+
void ata_std_error_handler(struct ata_port *ap)
40864079
{
4087-
struct ata_device *dev;
4080+
struct ata_port_operations *ops = ap->ops;
4081+
struct ata_link *link = &ap->link;
40884082
int rc;
40894083

4084+
/* Ignore built-in hardresets if SCR access is not available */
4085+
if ((ops->hardreset == sata_std_hardreset ||
4086+
ops->hardreset == sata_sff_hardreset) && !sata_scr_valid(link))
4087+
link->flags |= ATA_LFLAG_NO_HRST;
4088+
40904089
ata_eh_autopsy(ap);
40914090
ata_eh_report(ap);
40924091

4093-
rc = ata_eh_recover(ap, prereset, softreset, hardreset, postreset,
4094-
NULL);
4092+
rc = ata_eh_recover(ap, ops->prereset, ops->softreset,
4093+
ops->hardreset, ops->postreset, NULL);
40954094
if (rc) {
4096-
ata_for_each_dev(dev, &ap->link, ALL)
4095+
struct ata_device *dev;
4096+
4097+
ata_for_each_dev(dev, link, ALL)
40974098
ata_dev_disable(dev);
40984099
}
40994100

41004101
ata_eh_finish(ap);
41014102
}
4102-
4103-
/**
4104-
* ata_std_error_handler - standard error handler
4105-
* @ap: host port to handle error for
4106-
*
4107-
* Standard error handler
4108-
*
4109-
* LOCKING:
4110-
* Kernel thread context (may sleep).
4111-
*/
4112-
void ata_std_error_handler(struct ata_port *ap)
4113-
{
4114-
struct ata_port_operations *ops = ap->ops;
4115-
ata_reset_fn_t hardreset = ops->hardreset;
4116-
4117-
/* ignore built-in hardreset if SCR access is not available */
4118-
if (hardreset == sata_std_hardreset && !sata_scr_valid(&ap->link))
4119-
hardreset = NULL;
4120-
4121-
ata_do_eh(ap, ops->prereset, ops->softreset, hardreset, ops->postreset);
4122-
}
41234103
EXPORT_SYMBOL_GPL(ata_std_error_handler);
41244104

41254105
#ifdef CONFIG_PM

drivers/ata/libata-sff.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,8 +2054,6 @@ EXPORT_SYMBOL_GPL(ata_sff_drain_fifo);
20542054
*/
20552055
void ata_sff_error_handler(struct ata_port *ap)
20562056
{
2057-
ata_reset_fn_t softreset = ap->ops->softreset;
2058-
ata_reset_fn_t hardreset = ap->ops->hardreset;
20592057
struct ata_queued_cmd *qc;
20602058
unsigned long flags;
20612059

@@ -2077,13 +2075,7 @@ void ata_sff_error_handler(struct ata_port *ap)
20772075

20782076
spin_unlock_irqrestore(ap->lock, flags);
20792077

2080-
/* ignore built-in hardresets if SCR access is not available */
2081-
if ((hardreset == sata_std_hardreset ||
2082-
hardreset == sata_sff_hardreset) && !sata_scr_valid(&ap->link))
2083-
hardreset = NULL;
2084-
2085-
ata_do_eh(ap, ap->ops->prereset, softreset, hardreset,
2086-
ap->ops->postreset);
2078+
ata_std_error_handler(ap);
20872079
}
20882080
EXPORT_SYMBOL_GPL(ata_sff_error_handler);
20892081

include/linux/libata.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,6 @@ extern void ata_eh_thaw_port(struct ata_port *ap);
14121412
extern void ata_eh_qc_complete(struct ata_queued_cmd *qc);
14131413
extern void ata_eh_qc_retry(struct ata_queued_cmd *qc);
14141414

1415-
extern void ata_do_eh(struct ata_port *ap, ata_prereset_fn_t prereset,
1416-
ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
1417-
ata_postreset_fn_t postreset);
14181415
extern void ata_std_error_handler(struct ata_port *ap);
14191416
extern void ata_std_sched_eh(struct ata_port *ap);
14201417
extern void ata_std_end_eh(struct ata_port *ap);
@@ -2152,6 +2149,12 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
21522149

21532150
return status;
21542151
}
2152+
#else /* CONFIG_ATA_SFF */
2153+
static inline int sata_sff_hardreset(struct ata_link *link, unsigned int *class,
2154+
unsigned long deadline)
2155+
{
2156+
return -EOPNOTSUPP;
2157+
}
21552158
#endif /* CONFIG_ATA_SFF */
21562159

21572160
#endif /* __LINUX_LIBATA_H__ */

0 commit comments

Comments
 (0)