Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2387280rwn; Fri, 9 Sep 2022 12:55:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR6PoeoPlQcm+eKoGuzekj1A9Ib17oVLAiUVHPQK6l3yjiBWucsM+bROOSr/ibPaZ8qNH8nE X-Received: by 2002:a05:6402:51c6:b0:43d:dd3a:196e with SMTP id r6-20020a05640251c600b0043ddd3a196emr12742800edd.213.1662753337533; Fri, 09 Sep 2022 12:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662753337; cv=none; d=google.com; s=arc-20160816; b=PPxi71higSzGeX3iQ8UqigLNKdlTTlRQHYR/FpucjUo5b2sC8rgG/7bCNsQGULAIgj DU/dqLUXGcR3cSnDDukm02FCIoeML7+J3Mw3Xk5sVCmQ4X6o84oCBqhNl3yJAXgML9WN NHnI6TWjmRpiJypEp3iliC+SHr2ps/iBxcWHd0XN7MgqbzpMFXhuB1dQQ1YjuFS04XUC LZ/WtcD6D5fdLtcvpgW4MO9SVtEYik5mQ8C9l4gusm+tJnzei5R+oqXgBSRxDoBlFdso lYmrv5n0fa2bFdPUJ3p8Sd8gUGwokMx8/2cq1r0AorObP86A1WcMcXudUj6OdX+yRCf7 Jokg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=k04JpT/Stk+B/Zc/3fGfPQL4s7cQC+RHy2d6ex7akDU=; b=WhiUClW6upSk14ii4sN/xuCy3AINJKqiwx0ekY+dkd5da0r3koilhX2FXPI8wK3zzu q6KrqxRiOZX+ToPdAPFC8qizpmffsMs9KGaSKZotslZARKJaiRoaASv1JjBW5GK3ngkF 6oxkZelxsdLNAuDokhYJH0PtgheejCtcTd9+ELQjzA1rLTwXJVRqAvpOW7pFP9aCvT7e iMRjRIw7X3vDYMK1jOVtcQYKkUTX4BFVdaP40TwxcQ4jx7UEJER6hwNXAAFn1ch90vhh 2CJlj85RDdytbrU3ssGZ0mRnIOx+3J6zLANfe6tmIw9SfQkidrEfwQPI4J5LiD20Er8e A8XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=O4gzvBhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r17-20020a50c011000000b00446cd5b771dsi951848edb.223.2022.09.09.12.55.12; Fri, 09 Sep 2022 12:55:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=mail header.b=O4gzvBhH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230262AbiIITTu (ORCPT + 99 others); Fri, 9 Sep 2022 15:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230150AbiIITTm (ORCPT ); Fri, 9 Sep 2022 15:19:42 -0400 Received: from mail.baikalelectronics.com (mail.baikalelectronics.com [87.245.175.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75D0D2A42B; Fri, 9 Sep 2022 12:19:40 -0700 (PDT) Received: from mail (mail.baikal.int [192.168.51.25]) by mail.baikalelectronics.com (Postfix) with ESMTP id 3D9A2DBB; Fri, 9 Sep 2022 22:23:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.baikalelectronics.com 3D9A2DBB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baikalelectronics.ru; s=mail; t=1662751391; bh=k04JpT/Stk+B/Zc/3fGfPQL4s7cQC+RHy2d6ex7akDU=; h=From:To:CC:Subject:Date:In-Reply-To:References:From; b=O4gzvBhHAEGnSNm1f2kkZ6UEROqGLedhiAQeKD2i2IPo4oHcWkAVshH5GltVljce7 PudFDDrmSGjqMFYD5fBijw38Upb/+TrRtwNPdD3nUpAlpRee9joZr4YINs3kF+CCCd YSIPFPKpAb7az2+yxffnEs0ilQlNlpMIxlPTfu5g= Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 9 Sep 2022 22:19:21 +0300 From: Serge Semin To: Jonathan Derrick , Revanth Rajashekar , Jens Axboe , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Rafael Antognolli , Scott Bauer CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Thomas Bogendoerfer , , , Subject: [PATCH 2/2] block: sed-opal: Cache-line-align the cmd/resp buffers Date: Fri, 9 Sep 2022 22:19:16 +0300 Message-ID: <20220909191916.16013-3-Sergey.Semin@baikalelectronics.ru> In-Reply-To: <20220909191916.16013-1-Sergey.Semin@baikalelectronics.ru> References: <20220909191916.16013-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In accordance with [1] the DMA-able memory buffers must be cacheline-aligned otherwise the cache writing-back and invalidation performed during the mapping may cause the adjacent data being lost. It's specifically required for the DMA-noncoherent platforms. Seeing the opal_dev.{cmd,resp} buffers are used for DMAs in the NVME and SCSI/SD drivers in framework of the nvme_sec_submit() and sd_sec_submit() methods respectively we must make sure the passed buffers are cacheline-aligned to prevent the denoted problem. [1] Documentation/core-api/dma-api.rst Fixes: 455a7b238cd6 ("block: Add Sed-opal library") Signed-off-by: Serge Semin --- block/sed-opal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/sed-opal.c b/block/sed-opal.c index 9700197000f2..222acbd1f03a 100644 --- a/block/sed-opal.c +++ b/block/sed-opal.c @@ -73,6 +73,7 @@ struct parsed_resp { struct opal_resp_tok toks[MAX_TOKS]; }; +/* Presumably DMA-able buffers must be cache-aligned */ struct opal_dev { bool supported; bool mbr_enabled; @@ -88,8 +89,8 @@ struct opal_dev { u64 lowest_lba; size_t pos; - u8 cmd[IO_BUFFER_LENGTH]; - u8 resp[IO_BUFFER_LENGTH]; + u8 cmd[IO_BUFFER_LENGTH] ____cacheline_aligned; + u8 resp[IO_BUFFER_LENGTH] ____cacheline_aligned; struct parsed_resp parsed; size_t prev_d_len; -- 2.37.2