Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp110672pxf; Tue, 6 Apr 2021 16:33:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0UFDPwyUe+tT4V/U1OZCXsXjKJpd+JPsmcVvKm90iIiFwz3T9Z/uYH6gMJPvcG22p7X2N X-Received: by 2002:a05:6402:270e:: with SMTP id y14mr940559edd.283.1617752024733; Tue, 06 Apr 2021 16:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617752024; cv=none; d=google.com; s=arc-20160816; b=PJIRAH45r2XseGbPuITf+yu3dfWw34xOFGEvRjdVF67xa7U3VSmIZtzOKytyKNq6RS NSeog1OJeU0tYq0Gc9C6JnN3ebu3D+16mGFand3H058ywkE49jmYfUY4B/f0SU9/KyU1 1NLWbH4MAkKd7QMnzQzPPB0ZsMgdvraoGsMhr2A/XmbLocqvpvQpRAJLWAbCoLiFQe6c gW0wQBBs0XB36/MGertUhdJAHoKJIYNqXzwwrkmYBSZA7f9bPE6lASo+ZQKk3I2HO1BH HrYo9VsMdMspHqzrbFjByWlyKjphr+N9w55v9yRHknT4rB+H9ER0j/OaoGqRIL1bzCs0 Wzrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=6hVoGNNYkLx3cDOnpp0mTnf+U71N+jz9vrqdB+i+/9s=; b=sTUtEO6UxvTLGSOCEbUzR10ZW/6kJ9v/X31u5Ow7Bkm116W20iIpyeG5SoTu+LJEtZ eQqx8NmdJQ4NKwG5Ck7Ww5VGAQlXTgLNL2+CrZWYTOQRDXzQvhHvVJWQAaAVLTNawakq SMe6gb0h+nGIwfD2SbTJcjdl9DkuJsnXj7iy5GyY1T0s/w7/zLnmbVC9ApLm+EYgw/K0 NWpu4u+B4KjINJpFmWeu34+xzseoLGkO84eKEHylhJudbw0+Kxkvt2gzNIzpm1m5Cyv/ FSZRXQz3iS91pOn8n7zJTf1HuQOYiONOlVP8nwIqKiS3F/AYkp3VczzFh/aQdC99XcXZ qw2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yw24si4075213ejb.488.2021.04.06.16.33.21; Tue, 06 Apr 2021 16:33:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234431AbhDFKmQ (ORCPT + 99 others); Tue, 6 Apr 2021 06:42:16 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:15494 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbhDFKmP (ORCPT ); Tue, 6 Apr 2021 06:42:15 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FF3ty6HsDzrd88; Tue, 6 Apr 2021 18:39:54 +0800 (CST) Received: from [127.0.0.1] (10.40.192.131) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.498.0; Tue, 6 Apr 2021 18:41:54 +0800 Subject: Re: [PATCH v2] scsi: libsas: Reset num_scatter if libata mark qc as NODATA To: Jolly Shah CC: John Garry , Jason Yan , , , , , , , References: <20210318225632.2481291-1-jollys@google.com> <5e7ea537-86ab-f654-1df4-765364116e18@huawei.com> <993f97da-01f0-262b-3fbe-66fa1769698a@huawei.com> From: luojiaxing Message-ID: Date: Tue, 6 Apr 2021 18:41:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.40.192.131] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/2 6:34, Jolly Shah wrote: > Hi Luojiaxing, > > > On Mon, Mar 22, 2021 at 1:41 AM luojiaxing 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 >>> Reviewed-by: John Garry >>> >>> @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 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; >>>>> >>>> . >>> >>> . >>> > . >