On 8/31/23 12:09, Szuying Chen wrote: > This patch adds the function to clear pending interrupt before COMRESET. > It follows the AHCI1.3.1 - section6.2.2.2 specification. Please explain here the relevant part of that section. > > Signed-off-by: Szuying Chen <Chloe_Chen@xxxxxxxxxxxxxx> > --- > drivers/ata/libahci.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c > index 06aec35f88f2..1ae788251a6c 100644 > --- a/drivers/ata/libahci.c > +++ b/drivers/ata/libahci.c > @@ -1584,6 +1584,23 @@ static int ahci_pmp_retry_softreset(struct ata_link *link, unsigned int *class, > return rc; > } > > +static void PortClearPendingInterrupt(struct ata_port *ap) No CaMeLCaSe please ! Call this ahci_port_clear_peinding_irq(). > +{ > + struct ahci_host_priv *hpriv = ap->host->private_data; > + void __iomem *port_mmio = ahci_port_base(ap); > + u32 tmp; > + > + /* clear port SERR */ > + tmp = readl(port_mmio + PORT_SCR_ERR); > + writel(tmp, port_mmio + PORT_SCR_ERR); > + > + /* clear port IRQ */ > + tmp = readl(port_mmio + PORT_IRQ_STAT); > + writel(tmp, port_mmio + PORT_IRQ_STAT); > + > + writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT); This code is nearly identical to what ahci_port_init() does. So better make it common: keep the debug messages that are in ahci_port_init() and modify that function to call this new helper. > +} > + > int ahci_do_hardreset(struct ata_link *link, unsigned int *class, > unsigned long deadline, bool *online) > { > @@ -1602,6 +1619,9 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class, > tf.status = ATA_BUSY; > ata_tf_to_fis(&tf, 0, 0, d2h_fis); > > + /* clear pending Interrupt */ > + PortClearPendingInterrupt(ap); > + > rc = sata_link_hardreset(link, timing, deadline, online, > ahci_check_ready); > > -- > 2.39.2 > -- Damien Le Moal Western Digital Research