Received: by 2002:a05:6504:5087:b0:1e5:d399:13c4 with SMTP id i7csp4470ltq; Fri, 30 Sep 2022 16:31:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/ULqmswnghNSfYqBVzWSlgGKniixDYbBQKPkHXGC7qoAnVbjgevZmCVW0M0Kai6qpkV70 X-Received: by 2002:a62:1dc5:0:b0:540:d8a4:a4ca with SMTP id d188-20020a621dc5000000b00540d8a4a4camr11296397pfd.77.1664580709676; Fri, 30 Sep 2022 16:31:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664580709; cv=none; d=google.com; s=arc-20160816; b=i/sglDDb4K0PWbtNXVaMzvwTuZN0r7fruVWXaFEYd1BuFgQfJunrzNCXz4lH4FNxSe CIoxN5NG4HgGTyGDwJFs+odbdcusKoRLz1PavHaG6eXQt4K9xD+mZhIvAADyJvVBr9Bm 2NT4vI+KnHcthY5lCFsMqLhOxdpL+k2l3Hf/0/qLu7u75CkLMsvxv03QT12medZ6WTdu 6D8g68d4U+rc4ZsmudIFHHAFqOlWOiP9kEDQ9NNGzZsKNXGVi9EUd55v4tHqjvIbXFKy RovQLCRDS5zbeg28j+Ax9EYChjy8rvFDonwB6ycBRshLrx3xjxAtP5clRK5b0XtplOy4 8vNw== 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; bh=wuhxWCVeXVlJVS/RfP/AZNvPaB2WtIt+hlprDEaQew8=; b=whVk6kM2iBTQrf0+ZJduQt3PZSlH2q/qFMeveJH3kZ+W4yIO2QemWeZE32MCUIM5D7 NXxfEgBwYjgEgR+6LwgUJFTv4gUaQajDvs3413PGkiV/gDyxCMfwKfwF18cGhIFYuzDs zdbA6KBSZ/6D0tI+4bR6/gN2q28RLE1JjjODEhFgT/iFhaLALoqBQVkGhunVZdA1CGvI iyrNcUUZOr/3FQY7ZUa5UxU6XA0oJRt6dNrWxsp8r7mXzCiCKqVrgB459oj5zV6hI+rw isaknM+TzY1SEm2hFdz5PBI7+GvVkGmis/UPxIw7eI9+3AJFdznT2ZtDssYUk0j4x82j z5Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=tp0ozYnJ; 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 kk3-20020a17090b4a0300b00202bb6e0923si10746667pjb.155.2022.09.30.16.31.38; Fri, 30 Sep 2022 16:31:49 -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=post header.b=tp0ozYnJ; 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 S232414AbiI3XYe (ORCPT + 99 others); Fri, 30 Sep 2022 19:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbiI3XYS (ORCPT ); Fri, 30 Sep 2022 19:24:18 -0400 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7411715A700; Fri, 30 Sep 2022 16:24:12 -0700 (PDT) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 63B39E0EB5; Fri, 30 Sep 2022 01:46:56 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=wuhxWCVeXVlJVS/RfP/AZNvPaB2WtIt+hlprDEaQew8=; b=tp0ozYnJRVZb 3eOjGM6LN8TCwm25Q+QFgtbgIAcq6fonGNSvoBN/ax9zXSP9KuFKSHRRJhS6lHBY Hp9D7/pv0NAdDxGCXECCbCHCzU+5HbRntTZwP29CWCnCUKnIXExi1hNXj9wDXbL1 rI4PnhJFrDkO3LC4RvuG+ywABgJbY1w= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 56706E0E6B; Fri, 30 Sep 2022 01:46:56 +0300 (MSK) Received: from localhost (192.168.168.10) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 30 Sep 2022 01:46:57 +0300 From: Serge Semin To: Jens Axboe , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Jonathan Derrick , Revanth Rajashekar , Rafael Antognolli , Scott Bauer CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , Thomas Bogendoerfer , , , Subject: [PATCH v2 3/3] block: sed-opal: Cache-line-align the cmd/resp buffers Date: Fri, 30 Sep 2022 01:46:48 +0300 Message-ID: <20220929224648.8997-4-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220929224648.8997-1-Sergey.Semin@baikalelectronics.ru> References: <20220929224648.8997-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [192.168.168.10] 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 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.3