Skip to content

Commit a4daf08

Browse files
damien-lemoalfloatious
authored andcommitted
ata: libata-eh: Simplify reset operation management
Introduce struct ata_reset_operations to aggregate in a single structure the definitions of the 4 reset methods (prereset, softreset, hardreset and postreset) for a port. This new structure is used in struct ata_port to define the reset methods for a regular port (reset field) and for a port-multiplier port (pmp_reset field). A pointer to either of these fields replaces the 4 reset method arguments passed to ata_eh_recover() and ata_eh_reset(). The definition of the reset methods for all drivers is changed to use the reset and pmp_reset fields in struct ata_port_operations. A large number of files is modifed, but no functional changes are introduced. Suggested-by: Niklas Cassel <cassel@kernel.org> 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-3-dlemoal@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org>
1 parent df6f9a9 commit a4daf08

58 files changed

Lines changed: 134 additions & 145 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

drivers/ata/ahci.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,17 @@ static const struct scsi_host_template ahci_sht = {
110110

111111
static struct ata_port_operations ahci_vt8251_ops = {
112112
.inherits = &ahci_ops,
113-
.hardreset = ahci_vt8251_hardreset,
113+
.reset.hardreset = ahci_vt8251_hardreset,
114114
};
115115

116116
static struct ata_port_operations ahci_p5wdh_ops = {
117117
.inherits = &ahci_ops,
118-
.hardreset = ahci_p5wdh_hardreset,
118+
.reset.hardreset = ahci_p5wdh_hardreset,
119119
};
120120

121121
static struct ata_port_operations ahci_avn_ops = {
122122
.inherits = &ahci_ops,
123-
.hardreset = ahci_avn_hardreset,
123+
.reset.hardreset = ahci_avn_hardreset,
124124
};
125125

126126
static const struct ata_port_info ahci_port_info[] = {

drivers/ata/ahci_da850.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ static int ahci_da850_hardreset(struct ata_link *link,
137137

138138
static struct ata_port_operations ahci_da850_port_ops = {
139139
.inherits = &ahci_platform_ops,
140-
.softreset = ahci_da850_softreset,
140+
.reset.softreset = ahci_da850_softreset,
141141
/*
142142
* No need to override .pmp_softreset - it's only used for actual
143143
* PMP-enabled ports.
144144
*/
145-
.hardreset = ahci_da850_hardreset,
146-
.pmp_hardreset = ahci_da850_hardreset,
145+
.reset.hardreset = ahci_da850_hardreset,
146+
.pmp_reset.hardreset = ahci_da850_hardreset,
147147
};
148148

149149
static const struct ata_port_info ahci_da850_port_info = {

drivers/ata/ahci_dm816.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static int ahci_dm816_softreset(struct ata_link *link,
124124

125125
static struct ata_port_operations ahci_dm816_port_ops = {
126126
.inherits = &ahci_platform_ops,
127-
.softreset = ahci_dm816_softreset,
127+
.reset.softreset = ahci_dm816_softreset,
128128
};
129129

130130
static const struct ata_port_info ahci_dm816_port_info = {

drivers/ata/ahci_imx.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -642,18 +642,19 @@ static int ahci_imx_softreset(struct ata_link *link, unsigned int *class,
642642
int ret;
643643

644644
if (imxpriv->type == AHCI_IMX53)
645-
ret = ahci_pmp_retry_srst_ops.softreset(link, class, deadline);
645+
ret = ahci_pmp_retry_srst_ops.reset.softreset(link, class,
646+
deadline);
646647
else
647-
ret = ahci_ops.softreset(link, class, deadline);
648+
ret = ahci_ops.reset.softreset(link, class, deadline);
648649

649650
return ret;
650651
}
651652

652653
static struct ata_port_operations ahci_imx_ops = {
653-
.inherits = &ahci_ops,
654-
.host_stop = ahci_imx_host_stop,
655-
.error_handler = ahci_imx_error_handler,
656-
.softreset = ahci_imx_softreset,
654+
.inherits = &ahci_ops,
655+
.host_stop = ahci_imx_host_stop,
656+
.error_handler = ahci_imx_error_handler,
657+
.reset.softreset = ahci_imx_softreset,
657658
};
658659

659660
static const struct ata_port_info ahci_imx_port_info = {

drivers/ata/ahci_qoriq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class,
146146
}
147147

148148
static struct ata_port_operations ahci_qoriq_ops = {
149-
.inherits = &ahci_ops,
150-
.hardreset = ahci_qoriq_hardreset,
149+
.inherits = &ahci_ops,
150+
.reset.hardreset = ahci_qoriq_hardreset,
151151
};
152152

153153
static const struct ata_port_info ahci_qoriq_port_info = {

drivers/ata/ahci_xgene.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,11 @@ static irqreturn_t xgene_ahci_irq_intr(int irq, void *dev_instance)
613613
static struct ata_port_operations xgene_ahci_v1_ops = {
614614
.inherits = &ahci_ops,
615615
.host_stop = xgene_ahci_host_stop,
616-
.hardreset = xgene_ahci_hardreset,
616+
.reset.hardreset = xgene_ahci_hardreset,
617+
.reset.softreset = xgene_ahci_softreset,
618+
.pmp_reset.softreset = xgene_ahci_pmp_softreset,
617619
.read_id = xgene_ahci_read_id,
618620
.qc_issue = xgene_ahci_qc_issue,
619-
.softreset = xgene_ahci_softreset,
620-
.pmp_softreset = xgene_ahci_pmp_softreset
621621
};
622622

623623
static const struct ata_port_info xgene_ahci_v1_port_info = {
@@ -630,7 +630,7 @@ static const struct ata_port_info xgene_ahci_v1_port_info = {
630630
static struct ata_port_operations xgene_ahci_v2_ops = {
631631
.inherits = &ahci_ops,
632632
.host_stop = xgene_ahci_host_stop,
633-
.hardreset = xgene_ahci_hardreset,
633+
.reset.hardreset = xgene_ahci_hardreset,
634634
.read_id = xgene_ahci_read_id,
635635
};
636636

drivers/ata/ata_piix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ static struct ata_port_operations piix_pata_ops = {
10741074
.cable_detect = ata_cable_40wire,
10751075
.set_piomode = piix_set_piomode,
10761076
.set_dmamode = piix_set_dmamode,
1077-
.prereset = piix_pata_prereset,
1077+
.reset.prereset = piix_pata_prereset,
10781078
};
10791079

10801080
static struct ata_port_operations piix_vmw_ops = {
@@ -1102,7 +1102,7 @@ static const struct scsi_host_template piix_sidpr_sht = {
11021102

11031103
static struct ata_port_operations piix_sidpr_sata_ops = {
11041104
.inherits = &piix_sata_ops,
1105-
.hardreset = sata_std_hardreset,
1105+
.reset.hardreset = sata_std_hardreset,
11061106
.scr_read = piix_sidpr_scr_read,
11071107
.scr_write = piix_sidpr_scr_write,
11081108
.set_lpm = piix_sidpr_set_lpm,

drivers/ata/libahci.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ struct ata_port_operations ahci_ops = {
162162

163163
.freeze = ahci_freeze,
164164
.thaw = ahci_thaw,
165-
.softreset = ahci_softreset,
166-
.hardreset = ahci_hardreset,
167-
.postreset = ahci_postreset,
168-
.pmp_softreset = ahci_softreset,
165+
.reset.softreset = ahci_softreset,
166+
.reset.hardreset = ahci_hardreset,
167+
.reset.postreset = ahci_postreset,
168+
.pmp_reset.softreset = ahci_softreset,
169169
.error_handler = ahci_error_handler,
170170
.post_internal_cmd = ahci_post_internal_cmd,
171171
.dev_config = ahci_dev_config,
@@ -192,7 +192,7 @@ EXPORT_SYMBOL_GPL(ahci_ops);
192192

193193
struct ata_port_operations ahci_pmp_retry_srst_ops = {
194194
.inherits = &ahci_ops,
195-
.softreset = ahci_pmp_retry_softreset,
195+
.reset.softreset = ahci_pmp_retry_softreset,
196196
};
197197
EXPORT_SYMBOL_GPL(ahci_pmp_retry_srst_ops);
198198

drivers/ata/libata-core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@
6565
#include "libata-transport.h"
6666

6767
const struct ata_port_operations ata_base_port_ops = {
68-
.prereset = ata_std_prereset,
69-
.postreset = ata_std_postreset,
68+
.reset.prereset = ata_std_prereset,
69+
.reset.postreset = ata_std_postreset,
7070
.error_handler = ata_std_error_handler,
7171
.sched_eh = ata_std_sched_eh,
7272
.end_eh = ata_std_end_eh,

drivers/ata/libata-eh.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2793,13 +2793,16 @@ static bool ata_eh_followup_srst_needed(struct ata_link *link, int rc)
27932793
}
27942794

27952795
int ata_eh_reset(struct ata_link *link, int classify,
2796-
ata_prereset_fn_t prereset, ata_reset_fn_t softreset,
2797-
ata_reset_fn_t hardreset, ata_postreset_fn_t postreset)
2796+
struct ata_reset_operations *reset_ops)
27982797
{
27992798
struct ata_port *ap = link->ap;
28002799
struct ata_link *slave = ap->slave_link;
28012800
struct ata_eh_context *ehc = &link->eh_context;
28022801
struct ata_eh_context *sehc = slave ? &slave->eh_context : NULL;
2802+
ata_reset_fn_t hardreset = reset_ops->hardreset;
2803+
ata_reset_fn_t softreset = reset_ops->softreset;
2804+
ata_prereset_fn_t prereset = reset_ops->prereset;
2805+
ata_postreset_fn_t postreset = reset_ops->postreset;
28032806
unsigned int *classes = ehc->classes;
28042807
unsigned int lflags = link->flags;
28052808
int verbose = !(ehc->i.flags & ATA_EHI_QUIET);
@@ -3756,10 +3759,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
37563759
/**
37573760
* ata_eh_recover - recover host port after error
37583761
* @ap: host port to recover
3759-
* @prereset: prereset method (can be NULL)
3760-
* @softreset: softreset method (can be NULL)
3761-
* @hardreset: hardreset method (can be NULL)
3762-
* @postreset: postreset method (can be NULL)
3762+
* @reset_ops: The set of reset operations to use
37633763
* @r_failed_link: out parameter for failed link
37643764
*
37653765
* This is the alpha and omega, eum and yang, heart and soul of
@@ -3775,9 +3775,7 @@ static int ata_eh_handle_dev_fail(struct ata_device *dev, int err)
37753775
* RETURNS:
37763776
* 0 on success, -errno on failure.
37773777
*/
3778-
int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
3779-
ata_reset_fn_t softreset, ata_reset_fn_t hardreset,
3780-
ata_postreset_fn_t postreset,
3778+
int ata_eh_recover(struct ata_port *ap, struct ata_reset_operations *reset_ops,
37813779
struct ata_link **r_failed_link)
37823780
{
37833781
struct ata_link *link;
@@ -3845,8 +3843,7 @@ int ata_eh_recover(struct ata_port *ap, ata_prereset_fn_t prereset,
38453843
if (!(ehc->i.action & ATA_EH_RESET))
38463844
continue;
38473845

3848-
rc = ata_eh_reset(link, ata_link_nr_vacant(link),
3849-
prereset, softreset, hardreset, postreset);
3846+
rc = ata_eh_reset(link, ata_link_nr_vacant(link), reset_ops);
38503847
if (rc) {
38513848
ata_link_err(link, "reset failed, giving up\n");
38523849
goto out;
@@ -4077,20 +4074,20 @@ void ata_eh_finish(struct ata_port *ap)
40774074
*/
40784075
void ata_std_error_handler(struct ata_port *ap)
40794076
{
4080-
struct ata_port_operations *ops = ap->ops;
4077+
struct ata_reset_operations *reset_ops = &ap->ops->reset;
40814078
struct ata_link *link = &ap->link;
40824079
int rc;
40834080

40844081
/* 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))
4082+
if ((reset_ops->hardreset == sata_std_hardreset ||
4083+
reset_ops->hardreset == sata_sff_hardreset) &&
4084+
!sata_scr_valid(link))
40874085
link->flags |= ATA_LFLAG_NO_HRST;
40884086

40894087
ata_eh_autopsy(ap);
40904088
ata_eh_report(ap);
40914089

4092-
rc = ata_eh_recover(ap, ops->prereset, ops->softreset,
4093-
ops->hardreset, ops->postreset, NULL);
4090+
rc = ata_eh_recover(ap, reset_ops, NULL);
40944091
if (rc) {
40954092
struct ata_device *dev;
40964093

0 commit comments

Comments
 (0)