Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: John Garry <john.garry@huawei.com>,
	Niklas Cassel <Niklas.Cassel@wdc.com>,
	Hannes Reinecke <hare@suse.de>
Cc: "linux-ide@vger.kernel.org" <linux-ide@vger.kernel.org>,
	linux-scsi <linux-scsi@vger.kernel.org>,
	Xiang Chen <chenxiang66@hisilicon.com>
Subject: Re: libata and software reset
Date: Wed, 19 Oct 2022 18:53:17 +0900	[thread overview]
Message-ID: <73cf04c5-3ebd-3aaa-701b-91be59ed035d@opensource.wdc.com> (raw)
In-Reply-To: <28c7127f-f577-9a43-2f2f-80ef89d85a0e@huawei.com>

On 10/19/22 18:42, John Garry wrote:
> On 19/10/2022 06:04, Damien Le Moal wrote:
>> On 10/19/22 14:03, Damien Le Moal wrote:
>>> On 10/18/22 22:24, John Garry wrote:
>>>> Hi guys,
>>>>
>>>> In the hisi_sas driver there are times in which we need to issue an ATA
>>>> software reset. For this we use hisi_sas_softreset_ata_disk() ->
>>>> sas_execute_ata_cmd() -> sas_execute_tmf(), which uses libsas "slow
>>>> task" mechanism to issue the command.
>>> Something is wrong here... The reset command sent by that function is
>>> for ATAPI (DEVICE RESET command). There is no device reset command for
>>> SATA disks following the ACS standard.
> 
> Yeah, that looks wrong.
> 
>>>
>>> So hisi_sas_softreset_ata_disk() seems totally bogus to me, unless you
>>> have a CD/DVD drive connected to the HBA:)
> 
> Sure
> 
>>>
>>> This is why the softreset function is a port operation defined by LLDs.
>>> How you reset the device depends on the adapter. E.g., for AHCI, you
>>> need to send a host2device FIS with the software reset bit set.
> 
> This would be quite a standard method, right?

The TF part should be standard. Would need to dig in SATA-IO specs to
check. How the TF/FIS should be issued/polled for is definitely
dependent on the adapter itself I think, exactly like issuing a qc is.

> 
>> See: ahci_do_softreset() for AHCI.
> 
> For ahci_do_softreset(), do you just implicitly use ATA_CMD_NOP as the
> command?

To be frank, it is the first time I really look at the reset code :)
I need to read SATA-IO specs to understand why it is doing things like that.

> 
> For hisi_sas, maybe ATA_CMD_DEV_RESET is silently ignored when issued
> for a SATA disk, but having SRST set/unset still takes effect (and that
> is how it still works). I need to check on that.

Yes, it may be that having the ATA_SRST bit set causes the device to
ignore the command field, hence you never saw any problem. Still feels
terribly wrong to use an ATAPI command for an ATA disk. ATAPI device
reset command code is 0x08 which is not defined as a command code in ACS.

> 
> Thanks,
> John

-- 
Damien Le Moal
Western Digital Research


  reply	other threads:[~2022-10-19 10:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-18 13:24 libata and software reset John Garry
2022-10-18 15:04 ` Niklas Cassel
2022-10-19  9:32   ` John Garry
2022-10-19  9:56     ` Damien Le Moal
2022-10-19 10:15       ` John Garry
2022-10-19  5:03 ` Damien Le Moal
2022-10-19  5:04   ` Damien Le Moal
2022-10-19  9:42     ` John Garry
2022-10-19  9:53       ` Damien Le Moal [this message]
2022-10-19 10:15       ` Damien Le Moal
2022-10-19 10:34         ` John Garry

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=73cf04c5-3ebd-3aaa-701b-91be59ed035d@opensource.wdc.com \
    --to=damien.lemoal@opensource.wdc.com \
    --cc=Niklas.Cassel@wdc.com \
    --cc=chenxiang66@hisilicon.com \
    --cc=hare@suse.de \
    --cc=john.garry@huawei.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.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