linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: "Pali Rohár" <pali@kernel.org>
Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org,
	Jens Axboe <axboe@kernel.dk>,
	kernel@pengutronix.de
Subject: Re: [PATCH v2] libata: Fix retrieving of active qcs
Date: Fri, 8 May 2020 07:46:44 +0200	[thread overview]
Message-ID: <20200508054644.GJ5877@pengutronix.de> (raw)
In-Reply-To: <20200503214627.gerb3ipcwek2h3h7@pali>

On Sun, May 03, 2020 at 11:46:27PM +0200, Pali Rohár wrote:
> On Monday 27 January 2020 12:24:28 Sascha Hauer wrote:
> > On Mon, Jan 27, 2020 at 12:16:30PM +0100, Pali Rohár wrote:
> > > On Monday 06 January 2020 09:16:05 Sascha Hauer wrote:
> > > > On Wed, Dec 25, 2019 at 07:18:40PM +0100, Pali Rohár wrote:
> > > > > Hello Sascha!
> > > > > 
> > > > > On Friday 13 December 2019 09:04:08 Sascha Hauer wrote:
> > > > > > ata_qc_complete_multiple() is called with a mask of the still active
> > > > > > tags.
> > > > > > 
> > > > > > mv_sata doesn't have this information directly and instead calculates
> > > > > > the still active tags from the started tags (ap->qc_active) and the
> > > > > > finished tags as (ap->qc_active ^ done_mask)
> > > > > > 
> > > > > > Since 28361c40368 the hw_tag and tag are no longer the same and the
> > > > > > equation is no longer valid. In ata_exec_internal_sg() ap->qc_active is
> > > > > > initialized as 1ULL << ATA_TAG_INTERNAL, but in hardware tag 0 is
> > > > > > started and this will be in done_mask on completion. ap->qc_active ^
> > > > > > done_mask becomes 0x100000000 ^ 0x1 = 0x100000001 and thus tag 0 used as
> > > > > > the internal tag will never be reported as completed.
> > > > > > 
> > > > > > This is fixed by introducing ata_qc_get_active() which returns the
> > > > > > active hardware tags and calling it where appropriate.
> > > > > > 
> > > > > > This is tested on mv_sata, but sata_fsl and sata_nv suffer from the same
> > > > > > problem. There is another case in sata_nv that most likely needs fixing
> > > > > > as well, but this looks a little different, so I wasn't confident enough
> > > > > > to change that.
> > > > > 
> > > > > I can confirm that sata_nv.ko does not work in 4.18 (and new) kernel
> > > > > version correctly. More details are in email:
> > > > > 
> > > > > https://lore.kernel.org/linux-ide/20191225180824.bql2o5whougii4ch@pali/T/
> > > > > 
> > > > > I tried this patch and it fixed above problems with sata_nv.ko. It just
> > > > > needs small modification (see below).
> > > > > 
> > > > > So you can add my:
> > > > > 
> > > > > Tested-by: Pali Rohár <pali.rohar@gmail.com>
> > > > > 
> > > > > And I hope that patch would be backported to 4.18 and 4.19 stable
> > > > > branches soon as distributions kernels are broken for machines with
> > > > > these nvidia sata controllers.
> > > > > 
> > > > > Anyway, what is that another case in sata_nv which needs to be fixed
> > > > > too?
> > > > 
> > > > It's in nv_swncq_sdbfis(). Here we have:
> > > > 
> > > > 	sactive = readl(pp->sactive_block);
> > > > 	done_mask = pp->qc_active ^ sactive;
> > > > 
> > > > 	pp->qc_active &= ~done_mask;
> > > > 	pp->dhfis_bits &= ~done_mask;
> > > > 	pp->dmafis_bits &= ~done_mask;
> > > > 	pp->sdbfis_bits |= done_mask;
> > > > 	ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
> > > > 
> > > > Sascha
> > > 
> > > Ok. Are you going to fix also this case?
> > 
> > As said, this one looks slightly different than the others and I would
> > prefer if somebody could fix it who actually has a hardware and can test
> > it.
> 
> Well, I have hardware and could test changes. But I'm not really sure
> that I understand this part of code. So it would be better if somebody
> else with better knowledge prepares patches I could test them. But
> currently during coronavirus I have only remote ssh access, so boot,
> modify/compile/reboot process is quite slower.

Ok, here we go. Compile tested only.

Regards,
 Sascha

------------------------------8<-----------------------------------

From fcdcfa9e7a4ee4faf411de1df4f3c4e12c78545c Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Fri, 8 May 2020 07:28:19 +0200
Subject: [PATCH] ata: sata_nv: Fix retrieving of active qcs

ata_qc_complete_multiple() has to be called with the tags physically
active, that is the hw tag is at bit 0. ap->qc_active has the same tag
at bit ATA_TAG_INTERNAL instead, so call ata_qc_get_active() to fix that
up. This is done in the vein of 8385d756e114 ("libata: Fix retrieving of
active qcs").

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/ata/sata_nv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index eb9dc14e5147..20190f66ced9 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -2100,7 +2100,7 @@ static int nv_swncq_sdbfis(struct ata_port *ap)
 	pp->dhfis_bits &= ~done_mask;
 	pp->dmafis_bits &= ~done_mask;
 	pp->sdbfis_bits |= done_mask;
-	ata_qc_complete_multiple(ap, ap->qc_active ^ done_mask);
+	ata_qc_complete_multiple(ap, ata_qc_get_active(ap) ^ done_mask);
 
 	if (!ap->qc_active) {
 		DPRINTK("over\n");
-- 
2.26.2

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

  reply	other threads:[~2020-05-08  5:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-13  8:04 [PATCH v2] libata: Fix retrieving of active qcs Sascha Hauer
2019-12-25 18:18 ` Pali Rohár
2019-12-25 18:26   ` Jens Axboe
2019-12-25 18:36     ` Pali Rohár
2019-12-26  0:06       ` Jens Axboe
2020-01-06  8:16   ` Sascha Hauer
2020-01-27 11:16     ` Pali Rohár
2020-01-27 11:24       ` Sascha Hauer
2020-05-03 21:46         ` Pali Rohár
2020-05-08  5:46           ` Sascha Hauer [this message]
2020-10-28 13:55             ` Pali Rohár
2020-10-28 13:58               ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200508054644.GJ5877@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=axboe@kernel.dk \
    --cc=kernel@pengutronix.de \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pali@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).