mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: luojiaxing <luojiaxing@huawei.com>
To: Jolly Shah <jollys@google.com>
Cc: John Garry <john.garry@huawei.com>,
	Jason Yan <yanaijie@huawei.com>, <jejb@linux.ibm.com>,
	<martin.petersen@oracle.com>, <a.darwish@linutronix.de>,
	<dan.carpenter@oracle.com>, <b.zolnierkie@samsung.com>,
	<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] scsi: libsas: Reset num_scatter if libata mark qc as NODATA
Date: Tue, 6 Apr 2021 18:41:54 +0800	[thread overview]
Message-ID: <e7271655-c92f-1492-92ec-9ed7aed8df7c@huawei.com> (raw)
In-Reply-To: <CABGCNpBABSkdSQf=c2T9qMTGgJPL7Si9Ft_DvC8WiLtT_vmL1Q@mail.gmail.com>


On 2021/4/2 6:34, Jolly Shah wrote:
> Hi Luojiaxing,
>
>
> On Mon, Mar 22, 2021 at 1:41 AM luojiaxing <luojiaxing@huawei.com> wrote:
>>
>> On 2021/3/20 20:14, John Garry wrote:
>>> On 19/03/2021 01:43, Jason Yan wrote:
>>>>
>>>> 在 2021/3/19 6:56, Jolly Shah 写道:
>>>>> When the cache_type for the scsi device is changed, the scsi layer
>>>>> issues a MODE_SELECT command. The caching mode details are communicated
>>>>> via a request buffer associated with the scsi command with data
>>>>> direction set as DMA_TO_DEVICE (scsi_mode_select). When this command
>>>>> reaches the libata layer, as a part of generic initial setup, libata
>>>>> layer sets up the scatterlist for the command using the scsi command
>>>>> (ata_scsi_qc_new). This command is then translated by the libata layer
>>>>> into ATA_CMD_SET_FEATURES (ata_scsi_mode_select_xlat). The libata layer
>>>>> treats this as a non data command (ata_mselect_caching), since it only
>>>>> needs an ata taskfile to pass the caching on/off information to the
>>>>> device. It does not need the scatterlist that has been setup, so it
>>>>> does
>>>>> not perform dma_map_sg on the scatterlist (ata_qc_issue).
>>>>> Unfortunately,
>>>>> when this command reaches the libsas layer(sas_ata_qc_issue), libsas
>>>>> layer sees it as a non data command with a scatterlist. It cannot
>>>>> extract the correct dma length, since the scatterlist has not been
>>>>> mapped with dma_map_sg for a DMA operation. When this partially
>>>>> constructed SAS task reaches pm80xx LLDD, it results in below warning.
>>>>>
>>>>> "pm80xx_chip_sata_req 6058: The sg list address
>>>>> start_addr=0x0000000000000000 data_len=0x0end_addr_high=0xffffffff
>>>>> end_addr_low=0xffffffff has crossed 4G boundary"
>>>>>
>>>>> This patch updates code to handle ata non data commands separately so
>>>>> num_scatter and total_xfer_len remain 0.
>>>>>
>>>>> Fixes: 53de092f47ff ("scsi: libsas: Set data_dir as DMA_NONE if
>>>>> libata marks qc as NODATA")
>>>>> Signed-off-by: Jolly Shah <jollys@google.com>
>>> Reviewed-by: John Garry <john.garry@huawei.com>
>>>
>>> @luojiaxing, can you please test this?
>>
>> Sure, let me take a look, and reply the test result here later
>>
> Wanted to follow up on test results. Any updates?


Sorry for reply to you so late.


I use sdparm to change cache type of SATA disk, and it's ok with my test.

In addition, some other functional tests result have no problem too, So 
I think this patch is ok to me.


Tested-by: Luo Jiaxing <luojiaxing@huawei.com>


Thanks

Jiaxing


>
> Thanks,
> Jolly
>
>> Thanks
>>
>> Jiaxing
>>
>>
>>>>> ---
>>>>> v2:
>>>>> - reorganized code to avoid setting num_scatter twice
>>>>>
>>>>>    drivers/scsi/libsas/sas_ata.c | 9 ++++-----
>>>>>    1 file changed, 4 insertions(+), 5 deletions(-)
>>>>>
>>>>> diff --git a/drivers/scsi/libsas/sas_ata.c
>>>>> b/drivers/scsi/libsas/sas_ata.c
>>>>> index 024e5a550759..8b9a39077dba 100644
>>>>> --- a/drivers/scsi/libsas/sas_ata.c
>>>>> +++ b/drivers/scsi/libsas/sas_ata.c
>>>>> @@ -201,18 +201,17 @@ static unsigned int sas_ata_qc_issue(struct
>>>>> ata_queued_cmd *qc)
>>>>>            memcpy(task->ata_task.atapi_packet, qc->cdb,
>>>>> qc->dev->cdb_len);
>>>>>            task->total_xfer_len = qc->nbytes;
>>>>>            task->num_scatter = qc->n_elem;
>>>>> +        task->data_dir = qc->dma_dir;
>>>>> +    } else if (qc->tf.protocol == ATA_PROT_NODATA) {
>>>>> +        task->data_dir = DMA_NONE;
>>>> Hi Jolly & John,
>>>>
>>>> We only set DMA_NONE for ATA_PROT_NODATA, I'm curious about why
>>>> ATA_PROT_NCQ_NODATA and ATAPI_PROT_NODATA do not need to set DMA_NONE?
>>> So we can see something like atapi_eh_tur() -> ata_exec_internal(),
>>> which is a ATAPI NONDATA and has DMA_NONE, so should be ok.
>>>
>>> Other cases, like those using the xlate function on the qc for
>>> ATA_PROT_NCQ_NODATA, could be checked further.
>>>
>>> For now, we're just trying to fix the fix.
>>>
>>>> Thanks,
>>>> Jason
>>>>
>>>>
>>>>>        } else {
>>>>>            for_each_sg(qc->sg, sg, qc->n_elem, si)
>>>>>                xfer += sg_dma_len(sg);
>>>>>            task->total_xfer_len = xfer;
>>>>>            task->num_scatter = si;
>>>>> -    }
>>>>> -
>>>>> -    if (qc->tf.protocol == ATA_PROT_NODATA)
>>>>> -        task->data_dir = DMA_NONE;
>>>>> -    else
>>>>>            task->data_dir = qc->dma_dir;
>>>>> +    }
>>>>>        task->scatter = qc->sg;
>>>>>        task->ata_task.retry_count = 1;
>>>>>        task->task_state_flags = SAS_TASK_STATE_PENDING;
>>>>>
>>>> .
>>>
>>> .
>>>
> .
>


  reply	other threads:[~2021-04-06 10:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18 22:56 Jolly Shah
2021-03-19  1:43 ` Jason Yan
2021-03-20 12:14   ` John Garry
2021-03-22  8:40     ` luojiaxing
2021-04-01 22:34       ` Jolly Shah
2021-04-06 10:41         ` luojiaxing [this message]
2021-04-13  5:47 ` Martin K. Petersen

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=e7271655-c92f-1492-92ec-9ed7aed8df7c@huawei.com \
    --to=luojiaxing@huawei.com \
    --cc=a.darwish@linutronix.de \
    --cc=b.zolnierkie@samsung.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jejb@linux.ibm.com \
    --cc=john.garry@huawei.com \
    --cc=jollys@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=yanaijie@huawei.com \
    /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

all inboxes | Powered by JetHome®