Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp125655pxf; Wed, 17 Mar 2021 17:27:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyfhSxz+oASth8y0BxSXo3c8cS8hntAirC50emBBhPL154tGrkXBbHn/XIkv8qiIy2uutYR X-Received: by 2002:a50:cdd1:: with SMTP id h17mr409042edj.178.1616027256247; Wed, 17 Mar 2021 17:27:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616027256; cv=none; d=google.com; s=arc-20160816; b=abUniR2Xp5texkZBIkj62R5hjviWoG4hYBNazxu7+2qV8ddv3yZCC7USydON2FZSTT xGKxa07O1hm6oVVlRfeRDmbhjsdqxSbZcV0j+d1p8VCYrRAPq4yDC95f+aWMDO5kvfto TJy61bJDY+Y6ROjhKX9RojL/wDJEcgRf7NR4USiKUPd7qe48BLYAMTsPivt41Mdj3ZWT wkIIcJ3vHSDEZ1y+aX1iSV6OtRt6NrdRhNI7gjF+gsIyDGynEKFqz0hEckOr538cazAU wyHF3RnLmakqTvYTipUVA4YZPDsfLJU72EuoyystTr3a0PFPw93jqMez3M6znn/bRHIu hQLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=62xgyuajU6tPw+M6TsZi2hiokYvIOr5Uaenxy/zAlGg=; b=knbsP1Lj/sCOzJh6Mf2ftHrvT0qEGq1jKmFOYQ7BD94ZtlNgJNT1BIq5Z3wBuxBB8o Mhc9un7Kc2narQ5UnvR0yZBVbHU8YJ6JMlpRkz4yxUnJogGrCgIeidDubLUlJJ5cQtWe JO3OJZ2k43pxIpNOMWJKb3yM5P5cI2rwAqZjmBitw4dTgcJ8TWyYZ4TiNJvAvtvVyGTA jQZQsyrSfdtCG+AnoiYH8t5qjhjTomKjjU6uZMnXI+7HPbYj2UkTdUvSyQ/cYOIsj2un /oMhvUN7AFz9C1eJeRZv51WFqIajNEVyxS9GWWOi0BOmwh2V+bUf6RuVZ8PLFZI6ZrjQ GNLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WI0VP6Tt; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d17si327558edv.29.2021.03.17.17.27.13; Wed, 17 Mar 2021 17:27:36 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=WI0VP6Tt; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230145AbhCRAZM (ORCPT + 99 others); Wed, 17 Mar 2021 20:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbhCRAY4 (ORCPT ); Wed, 17 Mar 2021 20:24:56 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB40AC06174A for ; Wed, 17 Mar 2021 17:24:55 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id w11so389043ply.6 for ; Wed, 17 Mar 2021 17:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=62xgyuajU6tPw+M6TsZi2hiokYvIOr5Uaenxy/zAlGg=; b=WI0VP6TtBL+cnRViHv7of0jXPRhATu5KFZ/BcWIMdApFfQJkhUP7LkF0M+RYMD4sVA 11AWfppCK9H3XEcYaoiaFjrkqx6eoT/NGqHBnyyRysqGOAxIJFe8O15Fy5CA03VmfwSI l28WWneVh2/QnaY+NCOK2wLlK7sfucZHd9q2lsxrWDLBvWw6KJLv7NX+RDZynH8D8fM9 QbIiNPwfP0XS4Buanio/I+GBH6d+SWNSVCwqnhu4DPqwV3ok04fYQ+H3mr8McZ9bsVwj bvTyPr/F7kCtMDRu5l/RGB5MAmlQfiXYzmu4aaOauC4es79EWQzmTRdqBPmmrfiRTueZ nbHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=62xgyuajU6tPw+M6TsZi2hiokYvIOr5Uaenxy/zAlGg=; b=H2j0tQHqKqzyeg1iyMmy/l8L/hG/yJ2fucbQjeq+VV5bXfUZOCWztcBgFY2/z0zLNh /oOrqW0+x0Wp83FpG4EGdm9pK0S425uf3XNRLuy0BxUFo/Q2brMXYpGJsq6haZXN1u0b 362KF8D7qFEm090CTzmQ9MqZmZTvcKM9wMdKwTHilks7QKn80U93Ge0A9Sbw5VAtkrMV Sy+TFjFKfranvjga3dnJOA2VRTxi+MFdtzppMap/pPMJZmzrelW94FNarWLRRMcXZcz0 TXa60xEWnyYkBKLtuSkb73tzFWNcps3XUfcc6MqzgmgxWq23T4MppxG8aTFXVakBxSTz 4mQw== X-Gm-Message-State: AOAM532Jg2BVuHsx54s+rYIAra/ae6NbpC8Vv3yRHicx7Mderav92VQY F1qCM27/CDqfHC4A/PCERYSKndl0df36HShbwXdvEg== X-Received: by 2002:a17:902:bf01:b029:e6:6b59:a48b with SMTP id bi1-20020a170902bf01b02900e66b59a48bmr6959147plb.55.1616027094933; Wed, 17 Mar 2021 17:24:54 -0700 (PDT) MIME-Version: 1.0 References: <20210316193905.1673600-1-jollys@google.com> <5e2c35b6-a9c4-0637-738b-ff6920635425@huawei.com> In-Reply-To: <5e2c35b6-a9c4-0637-738b-ff6920635425@huawei.com> From: Jolly Shah Date: Wed, 17 Mar 2021 17:24:44 -0700 Message-ID: Subject: Re: [PATCH] scsi: libsas: Reset num_scatter if libata mark qc as NODATA To: John Garry Cc: jejb@linux.ibm.com, martin.petersen@oracle.com, a.darwish@linutronix.de, Jason Yan , luojiaxing@huawei.com, dan.carpenter@oracle.com, b.zolnierkie@samsung.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi John, Thanks for the review. On Wed, Mar 17, 2021 at 4:44 AM John Garry wrote: > > On 16/03/2021 19:39, Jolly Shah wrote: > > 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). > > So if we don't perform the dma_map_sg() on the sgl at this point, then > it seems to me that we should not perform for_each_sg() on it either, > right? That is still what happens in sas_ata_qc_issue() in this case. > Yes that's right. To avoid that, I can add elseif block for ATA_PROT_NODATA before for_each_sg() is performed. Currently there's existing code block for ATA_PROT_NODATA after for_each_sg() is performed, reused that to reset num_scatter. Please suggest. > > 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 assigns appropriate value to num_sectors for ata non data > > commands. > > > > Signed-off-by: Jolly Shah > > --- > > drivers/scsi/libsas/sas_ata.c | 6 ++++-- > > 1 file changed, 4 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c > > index 024e5a550759..94ec08cebbaa 100644 > > --- a/drivers/scsi/libsas/sas_ata.c > > +++ b/drivers/scsi/libsas/sas_ata.c > > @@ -209,10 +209,12 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) > > task->num_scatter = si; > > } > > > > - if (qc->tf.protocol == ATA_PROT_NODATA) > > + if (qc->tf.protocol == ATA_PROT_NODATA) { > > task->data_dir = DMA_NONE; > > - else > > + task->num_scatter = 0; > > task->num_scatter has already been set in this function. Best not set it > twice. > Sure. Please suggest if I should update patch to above suggested approach. That will avoid setting num_scatter twice. Thanks, Jolly Shah > Thanks, > John > > > + } 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; > > >