Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp948060pxf; Thu, 18 Mar 2021 15:59:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxxI7UkC3kmXBYQ//M+4HRgvs3wNuWsK9bxP7urGiiDlTWT233vVpyIM0YfaVuAJtEr/o0h X-Received: by 2002:a17:906:75a:: with SMTP id z26mr1025567ejb.22.1616108380301; Thu, 18 Mar 2021 15:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616108380; cv=none; d=google.com; s=arc-20160816; b=nBlmIO/0AqbZdfnjVld43hm1Yg5+/xqNMY5ZDJe3PdtExLcIpBnNZNEekN8LlZDYS5 PLvtSNMLLvrS0ej56GYul6Jnh/zNFolBRPbBaZXCjFU9Q7oDsd2PUSZ620Pviva8qyx0 QlTuYNfsh5GNV9OCOpqxsVNvHK8iX8odyYm4yZYFAZPsYvLPneXnK3rmJR3M6IIlXjvs uajbT3duG1oemfCMwOzjUVQqEq2gsNILGNLV8UaomL3hW1bUuRclMf/WupaWCsufllUI xvBhwiz4BaAkL+58rihakzXMhJvN8QRqSwxrKwixtp2gQIuQE5dIps+10swHbau4W//d lV/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=9QoP9965eN6KfleHPxoTcP8X4PcKzAfBQoWsgVWtjyk=; b=yKTa/an5Kl8cdyiqhGf8mhREVk4SVCdXGT3j/PhEomPhWfLNY7SKYG7+ea5vaRMUv2 n3PMR7ZLYRD7dOuBeKXIYWzz/nvTUQv7jQY6pOqDpq8ITUVwshjNgB6iAPvyRvsajpE4 0az3qJ0FHMxN/uxpC8rghrzDwbbzs5YKJfiKBHRI++p+FyLjdy2NZqbm3UnPt8qF2RfF 7P7wbvrfKH9aMA2iTQXx5CXlJ5Do8b/Z3+ovZp4GjKVFDbRKI68+E3uOoJF18/9VRBp8 /4HAMt2nE00VJ5HxQ397en+fq0dZL4WTcBP82LYzwSGRdqGxYo64/rG6enXDIX9eN/dm vlDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KdN9vnUg; 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 u2si2741211ejg.288.2021.03.18.15.59.18; Thu, 18 Mar 2021 15:59:40 -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=KdN9vnUg; 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 S233060AbhCRW47 (ORCPT + 99 others); Thu, 18 Mar 2021 18:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232533AbhCRW4n (ORCPT ); Thu, 18 Mar 2021 18:56:43 -0400 Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 517EAC06174A for ; Thu, 18 Mar 2021 15:56:43 -0700 (PDT) Received: by mail-qk1-x74a.google.com with SMTP id h126so32656382qkd.4 for ; Thu, 18 Mar 2021 15:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=9QoP9965eN6KfleHPxoTcP8X4PcKzAfBQoWsgVWtjyk=; b=KdN9vnUgMhpYZGkGDJfe6+gOWXOb4Zp/3ue54E8kyK8AJz89TEGYEm/SSlKjv7WXNd PXuceVBB+DnIS5CHWd01BmfyhjfAjiG9gvbujZGa+4s8Oow/Z4Ne0sAueUe0XaGU39FS WqHzJOnytd6QR88SSJ48VewDwof1506Y/QBP8gOr/DFL88QmfCmHL7ovPzbqD3DEl5kK rNKcEt4bOsCWI/MbeTvpzap3oi8LP8oiY0bm98b+pn32u7o1/KUxa8u3NNKqJTB2d+Tq J6fCOVhG47pd8BnSefa2nAtGWE6Ls/wDGvjSG9Hz6zzRvjT1QJGKCeJEFUMRwondd+WU gDGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=9QoP9965eN6KfleHPxoTcP8X4PcKzAfBQoWsgVWtjyk=; b=UUvCvfAvnA0i7d/LTeAvZZFGrtrCXW3B1EgcC3smRJlrvdHCkkvJ5RV0/na/0wIK7A 6bsHRDwMWOll/pPu3x0aIkJXRseeQ89kdyhyGuTLa+MJlfk6yeCnXSb4//SDtdNWOgK/ rXu+XOvxkxAd1cAJYIdbsrFEzRKrDQ3tcAQ+kRd8/n7Xprxs+0S3EJNepBKFo6hzeMJU PViVdoeypvt1WwEkqX0cgbk3KBPYe41KuPLtP1w7f3CYRU5rm/Ij2zmrcfavLGe7J4pN iiqpQY6xsH1of8DfL910qnhb48ydZWi7i5B/ia23GQeaVBN6RpxvBlU09NLdiwLnW5kA nvcw== X-Gm-Message-State: AOAM531uZGZt1g95e7riDeteq2tFo4OS8UFVyjdoEzQozLGJC4YjdNDc uORAqVMh8bPlVSfri85UReoxDD3dArQ= X-Received: from jollys.svl.corp.google.com ([2620:15c:2c5:13:84f3:414f:d94c:e1e1]) (user=jollys job=sendgmr) by 2002:a0c:8f09:: with SMTP id z9mr6481323qvd.25.1616108202527; Thu, 18 Mar 2021 15:56:42 -0700 (PDT) Date: Thu, 18 Mar 2021 15:56:32 -0700 Message-Id: <20210318225632.2481291-1-jollys@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH v2] scsi: libsas: Reset num_scatter if libata mark qc as NODATA From: Jolly Shah To: jejb@linux.ibm.com, martin.petersen@oracle.com, john.garry@huawei.com, a.darwish@linutronix.de, yanaijie@huawei.com, luojiaxing@huawei.com, dan.carpenter@oracle.com, b.zolnierkie@samsung.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Jolly Shah Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; } 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; -- 2.31.0.rc2.261.g7f71774620-goog