From patchwork Mon Apr 10 12:59:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Slaby X-Patchwork-Id: 97125 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp1350352qgd; Mon, 10 Apr 2017 06:01:19 -0700 (PDT) X-Received: by 10.84.222.139 with SMTP id x11mr14346818pls.112.1491829198593; Mon, 10 Apr 2017 05:59:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t88si4956649pfj.1.2017.04.10.05.59.58; Mon, 10 Apr 2017 05:59:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753368AbdDJM75 (ORCPT + 5 others); Mon, 10 Apr 2017 08:59:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:46365 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753455AbdDJM74 (ORCPT ); Mon, 10 Apr 2017 08:59:56 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 50A72ABEB; Mon, 10 Apr 2017 12:59:55 +0000 (UTC) From: Jiri Slaby To: stable@vger.kernel.org Cc: John Garry , "Martin K . Petersen" , Jiri Slaby Subject: [patch added to 3.12-stable] scsi: libsas: fix ata xfer length Date: Mon, 10 Apr 2017 14:59:17 +0200 Message-Id: <20170410125930.26495-40-jslaby@suse.cz> X-Mailer: git-send-email 2.12.2 In-Reply-To: <20170410125930.26495-1-jslaby@suse.cz> References: <20170410125930.26495-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: John Garry This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. -- 2.12.2 =============== commit 9702c67c6066f583b629cf037d2056245bb7a8e6 upstream. The total ata xfer length may not be calculated properly, in that we do not use the proper method to get an sg element dma length. According to the code comment, sg_dma_len() should be used after dma_map_sg() is called. This issue was found by turning on the SMMUv3 in front of the hisi_sas controller in hip07. Multiple sg elements were being combined into a single element, but the original first element length was being use as the total xfer length. Fixes: ff2aeb1eb64c8a4770a6 ("libata: convert to chained sg") Signed-off-by: John Garry Signed-off-by: Martin K. Petersen Signed-off-by: Jiri Slaby --- drivers/scsi/libsas/sas_ata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index d2895836f9fa..83e3ca703cd1 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -219,7 +219,7 @@ static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc) task->num_scatter = qc->n_elem; } else { for_each_sg(qc->sg, sg, qc->n_elem, si) - xfer += sg->length; + xfer += sg_dma_len(sg); task->total_xfer_len = xfer; task->num_scatter = si;