Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2672517pxb; Mon, 19 Apr 2021 10:55:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH5R3oklBhN10swCUfTEz6hwtJASlESWK9pcAPw/eHZNDQtw3e8Xj/TZ5PjZg44MTjVgzi X-Received: by 2002:a62:7cd0:0:b029:253:acca:2ce0 with SMTP id x199-20020a627cd00000b0290253acca2ce0mr21418917pfc.30.1618854931057; Mon, 19 Apr 2021 10:55:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618854931; cv=none; d=google.com; s=arc-20160816; b=c6JlNBJ/xHlIrKrPeBJScwNBNZWT3mfDmoxrzJPXpTIC+oXsW1D+Pmny+muExAVFhy HnLdAlr9uu7WNBpM3OnTj5gDXeCCBrdz5GLpPKZeOUfrErJbajVchM/JfnTGqZ8Cug3O WOXtEg9FLFQbvDiwmV7TDIieru1ONkltP8m5LWaODRkNph/eK3vFFQZoZmLfh+Ppu2lW MX9s/gXfI1k5/je1q+FTX96VNLmatYT3gHZtVTKn1Nvm43DoKR8XN0QJBBI5FCJsLeMh BUhic03tBWLxk/6J4GMRKAprIoqW+X2K6+Y4OXq2SS0qZ+H+9t+O3JSUEcVorKFgaYLo lJbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=moVIVxsw7O68T/KrC6ET3q/4ObIs01IdtSCtJJfPkV0=; b=kvcxi5k6Mw/vGiNsHQDZqWZtyptSJDCRnXdZoy9cF9Q9WbAwC2wjGaJanpB7MBAioV G+7Ao0HAxc4xx8ItuqjZhPQa8Mk3lyYGs7KsSRD4vMqQoeBndam6Jjn/frB2VR5iPMir BW321d/DuxwMhvtuhn5Qim8/cYv771f+S/QTnuD1vpC1GeReB1hkImD3KZu/ptpiqsjD WnvUOOdn0hu5wFcptTLDuykiADnte0s8QSidEtJpFblAyjm+1FWnBoloiaJdzGxU5Fub gjk4z0ICv/l1hq6LbTmVG8vyfisifa0VG5yqQt189wBlWmIbGgSdgBR38/dZActaj+nA J/8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zKTADCS4; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si6145345pfn.207.2021.04.19.10.55.18; Mon, 19 Apr 2021 10:55:31 -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=@linuxfoundation.org header.s=korg header.b=zKTADCS4; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242378AbhDSN1p (ORCPT + 99 others); Mon, 19 Apr 2021 09:27:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:56886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241120AbhDSNTz (ORCPT ); Mon, 19 Apr 2021 09:19:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 130BB613DB; Mon, 19 Apr 2021 13:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838135; bh=zbjn5UPooVYKlFNSLt2xYhyOKP05ZtgEEC6Y+7Iul5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zKTADCS4ydvSmNWvAI1gQTqH8WnP5aKoTg+QKoNwbFHHw0Uyobj8syTgGFwSqB1z9 XxNubZxZQqaOpypK9p4Qya1F5mOjQuxRlDxQrg46LC06KmPHMwirxLcZB17E6yelzn IOfJQKkB9mZ5Lmdp9yhKjbNkPYZpaQ/sZ8IK9kB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Luo Jiaxing , John Garry , Jolly Shah , "Martin K. Petersen" Subject: [PATCH 5.10 056/103] scsi: libsas: Reset num_scatter if libata marks qc as NODATA Date: Mon, 19 Apr 2021 15:06:07 +0200 Message-Id: <20210419130529.739757604@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jolly Shah commit 176ddd89171ddcf661862d90c5d257877f7326d6 upstream. 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 the following 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" Update libsas to handle ATA non-data commands separately so num_scatter and total_xfer_len remain 0. Link: https://lore.kernel.org/r/20210318225632.2481291-1-jollys@google.com Fixes: 53de092f47ff ("scsi: libsas: Set data_dir as DMA_NONE if libata marks qc as NODATA") Tested-by: Luo Jiaxing Reviewed-by: John Garry Signed-off-by: Jolly Shah Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/libsas/sas_ata.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) --- 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(str 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;