* [PATCH v3] ahci: libahci: clear pending interrupt status
@ 2023-09-06 9:53 Szuying Chen
2023-09-06 11:30 ` Niklas Cassel
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Szuying Chen @ 2023-09-06 9:53 UTC (permalink / raw)
To: Niklas.Cassel, dlemoal, linux-ide, linux-kernel
Cc: Jesse1_Chang, Richard_Hsu, Chloe_Chen
Cleared PxIS and PxIE with error recovery when ISR handle interface fatal.
Then a SDB FIS with ERR (set PxIS.TFES) is received
before PxCMD.ST is set to 0.
When error recovery was finish and PxCMD.ST is set to 1.
The HBA can't issue any new commands.
Because the PxIS.TFES bit is not cleared.
To avoid this,
we adds the function to clear pending interrupt before COMRESET.
It follows the AHCI 1.3.1 - section 6.2.2.2 specification.
Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
---
V1->V2: On suggestion by Damien to renamed helper function and modified
ahci_port_init() to make use of the helper.
V2->V3: On suggestion by Niklas to modify commit log and delete the
extra describe.
drivers/ata/libahci.c | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index e2bacedf28ef..f1263364fa97 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1256,6 +1256,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
return sprintf(buf, "%d\n", emp->blink_policy);
}
+static void ahci_port_clear_pending_irq(struct ata_port *ap)
+{
+ struct ahci_host_priv *hpriv = ap->host->private_data;
+ void __iomem *port_mmio = ahci_port_base(ap);
+ u32 tmp;
+
+ /* clear SError */
+ tmp = readl(port_mmio + PORT_SCR_ERR);
+ dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
+ writel(tmp, port_mmio + PORT_SCR_ERR);
+
+ /* clear port IRQ */
+ tmp = readl(port_mmio + PORT_IRQ_STAT);
+ dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
+ if (tmp)
+ writel(tmp, port_mmio + PORT_IRQ_STAT);
+
+ writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
+}
+
static void ahci_port_init(struct device *dev, struct ata_port *ap,
int port_no, void __iomem *mmio,
void __iomem *port_mmio)
@@ -1270,18 +1290,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
if (rc)
dev_warn(dev, "%s (%d)\n", emsg, rc);
- /* clear SError */
- tmp = readl(port_mmio + PORT_SCR_ERR);
- dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
- writel(tmp, port_mmio + PORT_SCR_ERR);
-
- /* clear port IRQ */
- tmp = readl(port_mmio + PORT_IRQ_STAT);
- dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
- if (tmp)
- writel(tmp, port_mmio + PORT_IRQ_STAT);
-
- writel(1 << port_no, mmio + HOST_IRQ_STAT);
+ ahci_port_clear_pending_irq(ap);
/* mark esata ports */
tmp = readl(port_mmio + PORT_CMD);
@@ -1603,6 +1612,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
tf.status = ATA_BUSY;
ata_tf_to_fis(&tf, 0, 0, d2h_fis);
+ ahci_port_clear_pending_irq(ap);
+
rc = sata_link_hardreset(link, timing, deadline, online,
ahci_check_ready);
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3] ahci: libahci: clear pending interrupt status
2023-09-06 9:53 [PATCH v3] ahci: libahci: clear pending interrupt status Szuying Chen
@ 2023-09-06 11:30 ` Niklas Cassel
2023-09-06 11:56 ` Damien Le Moal
2023-09-06 21:29 ` Damien Le Moal
2 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2023-09-06 11:30 UTC (permalink / raw)
To: Szuying Chen
Cc: dlemoal@kernel.org, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, Jesse1_Chang@asmedia.com.tw,
Richard_Hsu@asmedia.com.tw, Chloe_Chen@asmedia.com.tw
On Wed, Sep 06, 2023 at 05:53:34PM +0800, Szuying Chen wrote:
> Cleared PxIS and PxIE with error recovery when ISR handle interface fatal.
> Then a SDB FIS with ERR (set PxIS.TFES) is received
> before PxCMD.ST is set to 0.
> When error recovery was finish and PxCMD.ST is set to 1.
> The HBA can't issue any new commands.
> Because the PxIS.TFES bit is not cleared.
> To avoid this,
> we adds the function to clear pending interrupt before COMRESET.
> It follows the AHCI 1.3.1 - section 6.2.2.2 specification.
>
> Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
> ---
> V1->V2: On suggestion by Damien to renamed helper function and modified
> ahci_port_init() to make use of the helper.
> V2->V3: On suggestion by Niklas to modify commit log and delete the
> extra describe.
>
> drivers/ata/libahci.c | 35 +++++++++++++++++++++++------------
> 1 file changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index e2bacedf28ef..f1263364fa97 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -1256,6 +1256,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
> return sprintf(buf, "%d\n", emp->blink_policy);
> }
>
> +static void ahci_port_clear_pending_irq(struct ata_port *ap)
> +{
> + struct ahci_host_priv *hpriv = ap->host->private_data;
> + void __iomem *port_mmio = ahci_port_base(ap);
> + u32 tmp;
> +
> + /* clear SError */
> + tmp = readl(port_mmio + PORT_SCR_ERR);
> + dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
> + writel(tmp, port_mmio + PORT_SCR_ERR);
> +
> + /* clear port IRQ */
> + tmp = readl(port_mmio + PORT_IRQ_STAT);
> + dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> + if (tmp)
> + writel(tmp, port_mmio + PORT_IRQ_STAT);
> +
> + writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
> +}
> +
> static void ahci_port_init(struct device *dev, struct ata_port *ap,
> int port_no, void __iomem *mmio,
> void __iomem *port_mmio)
> @@ -1270,18 +1290,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
> if (rc)
> dev_warn(dev, "%s (%d)\n", emsg, rc);
>
> - /* clear SError */
> - tmp = readl(port_mmio + PORT_SCR_ERR);
> - dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
> - writel(tmp, port_mmio + PORT_SCR_ERR);
> -
> - /* clear port IRQ */
> - tmp = readl(port_mmio + PORT_IRQ_STAT);
> - dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> - if (tmp)
> - writel(tmp, port_mmio + PORT_IRQ_STAT);
> -
> - writel(1 << port_no, mmio + HOST_IRQ_STAT);
> + ahci_port_clear_pending_irq(ap);
>
> /* mark esata ports */
> tmp = readl(port_mmio + PORT_CMD);
> @@ -1603,6 +1612,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
> tf.status = ATA_BUSY;
> ata_tf_to_fis(&tf, 0, 0, d2h_fis);
>
> + ahci_port_clear_pending_irq(ap);
> +
> rc = sata_link_hardreset(link, timing, deadline, online,
> ahci_check_ready);
>
> --
> 2.39.2
>
Reviewed-by: Niklas Cassel <niklas.cassel@wdc.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] ahci: libahci: clear pending interrupt status
2023-09-06 9:53 [PATCH v3] ahci: libahci: clear pending interrupt status Szuying Chen
2023-09-06 11:30 ` Niklas Cassel
@ 2023-09-06 11:56 ` Damien Le Moal
2023-09-06 13:28 ` Niklas Cassel
2023-09-06 21:29 ` Damien Le Moal
2 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2023-09-06 11:56 UTC (permalink / raw)
To: Szuying Chen, Niklas.Cassel, linux-ide, linux-kernel
Cc: Jesse1_Chang, Richard_Hsu, Chloe_Chen
On 9/6/23 18:53, Szuying Chen wrote:
> Cleared PxIS and PxIE with error recovery when ISR handle interface fatal.
> Then a SDB FIS with ERR (set PxIS.TFES) is received
> before PxCMD.ST is set to 0.
> When error recovery was finish and PxCMD.ST is set to 1.
> The HBA can't issue any new commands.
> Because the PxIS.TFES bit is not cleared.
> To avoid this,
> we adds the function to clear pending interrupt before COMRESET.
> It follows the AHCI 1.3.1 - section 6.2.2.2 specification.
>
> Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
Fixes tag ?
> ---
> V1->V2: On suggestion by Damien to renamed helper function and modified
> ahci_port_init() to make use of the helper.
> V2->V3: On suggestion by Niklas to modify commit log and delete the
> extra describe.
>
> drivers/ata/libahci.c | 35 +++++++++++++++++++++++------------
> 1 file changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index e2bacedf28ef..f1263364fa97 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -1256,6 +1256,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
> return sprintf(buf, "%d\n", emp->blink_policy);
> }
>
> +static void ahci_port_clear_pending_irq(struct ata_port *ap)
> +{
> + struct ahci_host_priv *hpriv = ap->host->private_data;
> + void __iomem *port_mmio = ahci_port_base(ap);
> + u32 tmp;
> +
> + /* clear SError */
> + tmp = readl(port_mmio + PORT_SCR_ERR);
> + dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
> + writel(tmp, port_mmio + PORT_SCR_ERR);
> +
> + /* clear port IRQ */
> + tmp = readl(port_mmio + PORT_IRQ_STAT);
> + dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> + if (tmp)
> + writel(tmp, port_mmio + PORT_IRQ_STAT);
> +
> + writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
> +}
> +
> static void ahci_port_init(struct device *dev, struct ata_port *ap,
> int port_no, void __iomem *mmio,
> void __iomem *port_mmio)
> @@ -1270,18 +1290,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
> if (rc)
> dev_warn(dev, "%s (%d)\n", emsg, rc);
>
> - /* clear SError */
> - tmp = readl(port_mmio + PORT_SCR_ERR);
> - dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
> - writel(tmp, port_mmio + PORT_SCR_ERR);
> -
> - /* clear port IRQ */
> - tmp = readl(port_mmio + PORT_IRQ_STAT);
> - dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> - if (tmp)
> - writel(tmp, port_mmio + PORT_IRQ_STAT);
> -
> - writel(1 << port_no, mmio + HOST_IRQ_STAT);
> + ahci_port_clear_pending_irq(ap);
>
> /* mark esata ports */
> tmp = readl(port_mmio + PORT_CMD);
> @@ -1603,6 +1612,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
> tf.status = ATA_BUSY;
> ata_tf_to_fis(&tf, 0, 0, d2h_fis);
>
> + ahci_port_clear_pending_irq(ap);
> +
> rc = sata_link_hardreset(link, timing, deadline, online,
> ahci_check_ready);
>
> --
> 2.39.2
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] ahci: libahci: clear pending interrupt status
2023-09-06 11:56 ` Damien Le Moal
@ 2023-09-06 13:28 ` Niklas Cassel
0 siblings, 0 replies; 5+ messages in thread
From: Niklas Cassel @ 2023-09-06 13:28 UTC (permalink / raw)
To: Damien Le Moal
Cc: Szuying Chen, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org, Jesse1_Chang@asmedia.com.tw,
Richard_Hsu@asmedia.com.tw, Chloe_Chen@asmedia.com.tw
On Wed, Sep 06, 2023 at 08:56:08PM +0900, Damien Le Moal wrote:
> On 9/6/23 18:53, Szuying Chen wrote:
> > Cleared PxIS and PxIE with error recovery when ISR handle interface fatal.
> > Then a SDB FIS with ERR (set PxIS.TFES) is received
> > before PxCMD.ST is set to 0.
> > When error recovery was finish and PxCMD.ST is set to 1.
> > The HBA can't issue any new commands.
> > Because the PxIS.TFES bit is not cleared.
> > To avoid this,
> > we adds the function to clear pending interrupt before COMRESET.
> > It follows the AHCI 1.3.1 - section 6.2.2.2 specification.
> >
> > Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
>
> Fixes tag ?
The ata code has not been clearing PxIS after stopping the engine
(the AHCI spec states that PxIS should be cleared after stopping the
engine, and before issuing COMRESET), since the introduction of the
code that stops the engine (when ahci was still living under drivers/scsi).
If you really do want a fixes tag:
Fixes: e0bfd149973d ("[PATCH] ahci: stop engine during hard reset")
Kind regards,
Niklas
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3] ahci: libahci: clear pending interrupt status
2023-09-06 9:53 [PATCH v3] ahci: libahci: clear pending interrupt status Szuying Chen
2023-09-06 11:30 ` Niklas Cassel
2023-09-06 11:56 ` Damien Le Moal
@ 2023-09-06 21:29 ` Damien Le Moal
2 siblings, 0 replies; 5+ messages in thread
From: Damien Le Moal @ 2023-09-06 21:29 UTC (permalink / raw)
To: Szuying Chen, Niklas.Cassel, linux-ide, linux-kernel
Cc: Jesse1_Chang, Richard_Hsu, Chloe_Chen
On 9/6/23 18:53, Szuying Chen wrote:
> Cleared PxIS and PxIE with error recovery when ISR handle interface fatal.
This sentence has no verb and is unclear. What exactly are you trying to say ?
> Then a SDB FIS with ERR (set PxIS.TFES) is received
> before PxCMD.ST is set to 0.
Then -> Then if ?
Then what ? you are not saying what happen in this case.
> When error recovery was finish and PxCMD.ST is set to 1.
was finish -> finishes ?
And ? what happen when that is true ?
> The HBA can't issue any new commands.
That is the issue, but given that all the sentences above are very unclear, it
is hard to understand what conditions lead to this.
> Because the PxIS.TFES bit is not cleared.
Why split that as a different sentence ? Shouldn't this be:
The HBA cannot issue any new command because the PxIS.TFES bit is not cleared.
> To avoid this,
> we adds the function to clear pending interrupt before COMRESET.
> It follows the AHCI 1.3.1 - section 6.2.2.2 specification.
To avoid this, introduce the function ahci_port_clear_pending_irq() to clear
pending interrupts before executing a COMRESET. This follows the AHCI 1.3.1 -
section 6.2.2.2 specification.
>
> Signed-off-by: Szuying Chen <Chloe_Chen@asmedia.com.tw>
> ---
> V1->V2: On suggestion by Damien to renamed helper function and modified
> ahci_port_init() to make use of the helper.
> V2->V3: On suggestion by Niklas to modify commit log and delete the
> extra describe.
>
> drivers/ata/libahci.c | 35 +++++++++++++++++++++++------------
> 1 file changed, 23 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
> index e2bacedf28ef..f1263364fa97 100644
> --- a/drivers/ata/libahci.c
> +++ b/drivers/ata/libahci.c
> @@ -1256,6 +1256,26 @@ static ssize_t ahci_activity_show(struct ata_device *dev, char *buf)
> return sprintf(buf, "%d\n", emp->blink_policy);
> }
>
> +static void ahci_port_clear_pending_irq(struct ata_port *ap)
> +{
> + struct ahci_host_priv *hpriv = ap->host->private_data;
> + void __iomem *port_mmio = ahci_port_base(ap);
> + u32 tmp;
> +
> + /* clear SError */
> + tmp = readl(port_mmio + PORT_SCR_ERR);
> + dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp);
> + writel(tmp, port_mmio + PORT_SCR_ERR);
> +
> + /* clear port IRQ */
> + tmp = readl(port_mmio + PORT_IRQ_STAT);
> + dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> + if (tmp)
> + writel(tmp, port_mmio + PORT_IRQ_STAT);
> +
> + writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT);
> +}
> +
> static void ahci_port_init(struct device *dev, struct ata_port *ap,
> int port_no, void __iomem *mmio,
> void __iomem *port_mmio)
> @@ -1270,18 +1290,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
> if (rc)
> dev_warn(dev, "%s (%d)\n", emsg, rc);
>
> - /* clear SError */
> - tmp = readl(port_mmio + PORT_SCR_ERR);
> - dev_dbg(dev, "PORT_SCR_ERR 0x%x\n", tmp);
> - writel(tmp, port_mmio + PORT_SCR_ERR);
> -
> - /* clear port IRQ */
> - tmp = readl(port_mmio + PORT_IRQ_STAT);
> - dev_dbg(dev, "PORT_IRQ_STAT 0x%x\n", tmp);
> - if (tmp)
> - writel(tmp, port_mmio + PORT_IRQ_STAT);
> -
> - writel(1 << port_no, mmio + HOST_IRQ_STAT);
> + ahci_port_clear_pending_irq(ap);
>
> /* mark esata ports */
> tmp = readl(port_mmio + PORT_CMD);
> @@ -1603,6 +1612,8 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
> tf.status = ATA_BUSY;
> ata_tf_to_fis(&tf, 0, 0, d2h_fis);
>
> + ahci_port_clear_pending_irq(ap);
> +
> rc = sata_link_hardreset(link, timing, deadline, online,
> ahci_check_ready);
>
> --
> 2.39.2
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-09-06 21:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-06 9:53 [PATCH v3] ahci: libahci: clear pending interrupt status Szuying Chen
2023-09-06 11:30 ` Niklas Cassel
2023-09-06 11:56 ` Damien Le Moal
2023-09-06 13:28 ` Niklas Cassel
2023-09-06 21:29 ` Damien Le Moal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox