Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4467122pxf; Tue, 16 Mar 2021 14:25:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxua+7ly1f2fpBdUY7IvXucF3EPdRPF+XpCII6TOMDs8t1DauiSOHXe2emEWqC9NXsfPz4 X-Received: by 2002:a17:906:388d:: with SMTP id q13mr32532480ejd.34.1615929910537; Tue, 16 Mar 2021 14:25:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615929910; cv=none; d=google.com; s=arc-20160816; b=JXe6ANetzoPdXw7tBZH1aF4rVoDMr4K+xFbGv9nbwkK/2Z8TJpgyHZ3H4SDHvuVhGO KOKnHbqC6Ne+mPP+hZkoBXsqo0D8CwqPBAdjePFB5FVeV7RFxsBT0Hfu8XZlmV3bVODf m3zwSyTQ1gf739sMx2+BnTz6abLkiE4VwIOt1SfweMIQCCpmRS58YWB+6WB+AbueseFV dXm26IAEwdiSaDSFCrkVO7lsnjOHV7ckUCZcdMkhqqRr0yXBwVu7oS0yRhV5jWiAEtbr ixV0VKO923KzFVjzQ+iU0CD7CR3C5jvXm7pTHJa9fMYF0678ppM/Lf1AilhCJGk2L08b yCkw== 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=DyT2hoANWswY1My2edJBxlO9DN0LrYQonEua2weCt84=; b=Nj0BXUH40EDDfhUns1qTn+EOgHoYRMAa1V4IeFnovZdpFzM54aR6HYxH+MfYwEjftn /bKmFUur0KKbqZD/DWgORIwd7/Nkm0eO3AsvInn1bjZHbquUAtUalIgxUl09OzrJuUzF 16nHVQ32FgYlN4HndL6dpdz/caxRGPuy1xXqBjxqteqh740hukh1VZvIooTSZq6ehFoy wrFZ670ueCy4x43spOSuludWNnPXchnYsjVO2CwfJNLH+KCYdX4iUJYFii2BSp0VuQys w2Wus6AHgkMN0GiAo+MiPcGWW/Om86WP7UfyIG+9IQakO9xxk07ElkJcjmPVzkoEfCrg EgTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=fBhUY4Kn; 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 va29si2751294ejb.713.2021.03.16.14.24.48; Tue, 16 Mar 2021 14:25:10 -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=fBhUY4Kn; 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 S240509AbhCPTji (ORCPT + 99 others); Tue, 16 Mar 2021 15:39:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240505AbhCPTjJ (ORCPT ); Tue, 16 Mar 2021 15:39:09 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 242ECC06174A for ; Tue, 16 Mar 2021 12:39:09 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u17so43264194ybi.10 for ; Tue, 16 Mar 2021 12:39:09 -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=DyT2hoANWswY1My2edJBxlO9DN0LrYQonEua2weCt84=; b=fBhUY4KnMhJq9CyPuR22abSB5bODhZt9LZOsPXAPaVrKZVpkZvLsEdwqELYErXRVX8 D4F6ayBWlArXiqvIbhhBbG7R2TsPQFIxC3HOmLnLNll7P1Vm5V0jkC5UP/oLTPuUsBHt TyjMMi9zWIfl8uBac3LUFP2iLxmg0VN0ZZ6SotUcD6jGVtXqfLku/XFknVu1IDikm1N/ /J11qoZE3p32jpTgXVvQ0VHCVwezqgfNKepiHhE/uWRFCUHkLX3CsYO+YlWIf9y/v1zq 2V7GqwPyGvCRZXTxBW1m/3Y8o6sFtiZ2DyW1lDhTQnwNdPzE4dv/eGN9Xt5ZjaMkAu/P JiUQ== 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=DyT2hoANWswY1My2edJBxlO9DN0LrYQonEua2weCt84=; b=mc+5seloo8N5KTxa1iOZg5QgyK1luUK9T6Xi2aFRdJRKMVGu4DLTRE9snSRJQtOKKq F9LDp69IHJOOYyV268McaN8A8729AfcYWsNoud4HOplJI03vxix0aWAguUr4OxNlb3gU yWyEzY0SpgEfusvRAutEPkVhhEpml9fOoujM8YYjCJ6OA5jqamgdyEBg3r54Prnig33i E37L+upVsr5oqHTSi3+yW2BzxTx/Jomz7+G/w9kJn4BhRK36TKjLfMXRvHTHJqn9N2kN BQcta28flljOv2PzwaEPhjmFB6BbmnsNZwhyb/Mt6qCUCjVoH2m09wPD6qBhLNmlIu+L UHpQ== X-Gm-Message-State: AOAM5321q8m6YHhWxnfa8AfwzWlbpbWgEZTKMemL9b3nEKzfiqO23ytL Wh0aNCXfnJFKqj6ZiC+ZqhZ6YFw/bRY= X-Received: from jollys.svl.corp.google.com ([2620:15c:2c5:13:b0b6:1464:754e:83cb]) (user=jollys job=sendgmr) by 2002:a25:595:: with SMTP id 143mr663212ybf.177.1615923548383; Tue, 16 Mar 2021 12:39:08 -0700 (PDT) Date: Tue, 16 Mar 2021 12:39:05 -0700 Message-Id: <20210316193905.1673600-1-jollys@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.31.0.rc2.261.g7f71774620-goog Subject: [PATCH] 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 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; + } 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