From patchwork Tue Nov 21 13:23:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10068037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 398BD602B7 for ; Tue, 21 Nov 2017 13:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D9D6295D1 for ; Tue, 21 Nov 2017 13:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22A30295DC; Tue, 21 Nov 2017 13:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CDC98295D7 for ; Tue, 21 Nov 2017 13:23:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751251AbdKUNXy (ORCPT ); Tue, 21 Nov 2017 08:23:54 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:57795 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdKUNXx (ORCPT ); Tue, 21 Nov 2017 08:23:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=35QtkrkPMQzffQemuuxZWkLyOygfDBA+fBth6r/uhTs=; b=UU4eDl+GEmagoSgAlQywUgO+q gd2YYpxRMV9Hz6MMK6UZovNvUr8/OzJpbWAbUYRMuF3gLmRrgmtfA/0V67aG+01W1krdTjnLilA82 VpOPsg+pxahYmLIgE0KNk7a9/tSRbUPHNeTghFMNv39yxc+5aCmqsmvi2r9Q3z+I1ccErc2uU2tXf hI8eqFNf5RswpjYu8S9HhfSGk+PuFyP4xHrUnD6qA4nekius8z0ycoxyOE5IFci2d8SENJz5in5PU 51p22EWWW1QPwMBM+x/1OY1A9KG4P7pmAu0ZOqFk4rNIj+ftHgzS04MG/URHZDI27tUR9qD5PWpKF ydyehBSTg==; Received: from clnet-p099-196.ikbnet.co.at ([83.175.99.196] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1eH8Wl-0007TI-9K; Tue, 21 Nov 2017 13:23:51 +0000 From: Christoph Hellwig To: "Martin K. Petersen" Cc: Huacai Chen , linux-scsi@vger.kernel.org, iommu@lists.linux-foundation.org, stable@vger.kernel.org Subject: [PATCH 3/3] libsas: align sata_device's rps_resp on a cacheline Date: Tue, 21 Nov 2017 14:23:39 +0100 Message-Id: <20171121132339.1702-4-hch@lst.de> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171121132339.1702-1-hch@lst.de> References: <20171121132339.1702-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Huacai Chen The rps_resp buffer in ata_device is a DMA target, but it isn't explicitly cacheline aligned. Due to this, adjacent fields can be overwritten with stale data from memory on non-coherent architectures. As a result, the kernel is sometimes unable to communicate with an SATA device behind a SAS expander. Fix this by ensuring that the rps_resp buffer is cacheline aligned. This issue is similar to that fixed by Commit 84bda12af31f93 ("libata: align ap->sector_buf") and Commit 4ee34ea3a12396f35b26 ("libata: Align ata_device's id on a cacheline"). Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen Signed-off-by: Christoph Hellwig --- include/scsi/libsas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h index 0f9cbf96c093..6df6fe0c2198 100644 --- a/include/scsi/libsas.h +++ b/include/scsi/libsas.h @@ -159,11 +159,11 @@ struct expander_device { struct sata_device { unsigned int class; - struct smp_resp rps_resp; /* report_phy_sata_resp */ u8 port_no; /* port number, if this is a PM (Port) */ struct ata_port *ap; struct ata_host ata_host; + struct smp_resp rps_resp ____cacheline_aligned; /* report_phy_sata_resp */ u8 fis[ATA_RESP_FIS_SIZE]; };