Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp452098rwb; Wed, 18 Jan 2023 20:51:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXsNHXUvY9LNfM6abNqa1qC+I1NxG7gkkkYpyxDm9t9yy19q4LhkndA4aDDAaqmfqnshgZwF X-Received: by 2002:a17:907:76ac:b0:857:1e36:3b7b with SMTP id jw12-20020a17090776ac00b008571e363b7bmr8995925ejc.11.1674103863386; Wed, 18 Jan 2023 20:51:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674103863; cv=none; d=google.com; s=arc-20160816; b=q4V1xS9/Xa0aJMEMfVI5cZYGfY1RmVO7/hQ2Lh9U4qzSl8tCLXp9dwJeKF/YpLeRmf CNaTcZvDAmnEBW8Al7Ey2pYf8MbxoU2uDuXtjavrH//JHnXas4XRfXMaW1fVr9Zwwhh6 +5RZHclIlYJ0h0P1CGZxmTOlbHeXjidVjUNhZ++3UUkaPBnWSp6V+ITnZ+KYkSx+PraU ZeeVy+S5kBwzL35jE0LhUG3Lz4Mq7tUB4D1AIHvPoMPwaOSN2QLfevy6vxokhNupnGGl v7rGMEJlGrC+sL8Kl+EwuESwo3E7VD803WTqOlxjyvRiMzVhNHuJiz4fS1xb5t/sXTw7 5/yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date; bh=Vpk4BlqV1r5hS3t2t88+cW9b0/99SZA/UQajw1jAEGg=; b=S4Mvq0K+7AykUDBCmUqL1g6RQlZoBmyEj27tYrjuwP4HclPvap4JZdFMPz8OYeRea+ BwoBqkIqQwMgNIiDWe1PwbvLC759yBrpfICX+FniGpt9SDJLFv9ZxYJOMhbyKRoyIG42 nN3kgEJjg7pbUligj7gkSIXZhUp/FCmSnFlG7Zt3s7hcq1lm/q41u3lICwaVVKhdgR19 gcsZpMSt0osmUWGgmNERKKii3123yQ1ygLchnNhH0Rl9XAGOvJKCobSC0FHHA/+uA0f8 uTRJKxSV1bTMoDTTCUZO6HL4qJLKJqiSyrAZQqJFj2Tm7xfslQVVMKkYpvfM0RIPKfCZ 9zVw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y20-20020a170906559400b0087758fed31asi3166398ejp.345.2023.01.18.20.50.52; Wed, 18 Jan 2023 20:51:03 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230162AbjASEG4 (ORCPT + 44 others); Wed, 18 Jan 2023 23:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229712AbjASDtj (ORCPT ); Wed, 18 Jan 2023 22:49:39 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A13B037575 for ; Wed, 18 Jan 2023 19:47:44 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pILs6-0004aJ-14; Thu, 19 Jan 2023 04:45:50 +0100 Date: Thu, 19 Jan 2023 03:45:43 +0000 From: Daniel Golle To: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: Mason Yang , Jianhui Zhao Subject: [PATCH] mtd: spinand: macronix: use scratch buffer for DMA operation Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, 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 The mx35lf1ge4ab_get_eccsr() function uses an SPI DMA operation to read the eccsr, hence the buffer should not be on stack. Since commit 380583227c0c7f ("spi: spi-mem: Add extra sanity checks on the op param") the kernel emmits a warning and blocks such operations. Use the scratch buffer to get eccsr instead of trying to directly read into a stack-allocated variable. Signed-off-by: Daniel Golle --- drivers/mtd/nand/spi/macronix.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c index dce835132a1e2..722a9738ba370 100644 --- a/drivers/mtd/nand/spi/macronix.c +++ b/drivers/mtd/nand/spi/macronix.c @@ -83,9 +83,10 @@ static int mx35lf1ge4ab_ecc_get_status(struct spinand_device *spinand, * in order to avoid forcing the wear-leveling layer to move * data around if it's not necessary. */ - if (mx35lf1ge4ab_get_eccsr(spinand, &eccsr)) + if (mx35lf1ge4ab_get_eccsr(spinand, spinand->scratchbuf)) return nanddev_get_ecc_conf(nand)->strength; + eccsr = *spinand->scratchbuf; if (WARN_ON(eccsr > nanddev_get_ecc_conf(nand)->strength || !eccsr)) return nanddev_get_ecc_conf(nand)->strength; -- 2.39.1