From patchwork Thu Jan 19 03:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 45572 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp130196wrn; Wed, 18 Jan 2023 20:09:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtoufIJXJUESTrdWtfVR/rZKDMKm8i/5D7mFttTl1rfxJ0d+O3jBLyUWxpoVVksZvJXHIPN X-Received: by 2002:a17:902:7fc9:b0:194:84f2:c1ec with SMTP id t9-20020a1709027fc900b0019484f2c1ecmr9928912plb.21.1674101355355; Wed, 18 Jan 2023 20:09:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674101355; cv=none; d=google.com; s=arc-20160816; b=QFtVGTpeiZ2CcFDM6MundLpfQ/tR0Rik3dmdvvKuvhBqPHm+Mhx8Sz0d3REsTNbgBA dK1R9kgmfoZGIAJ6ymG+Q2blYeSPXu4lpFvfUZHGXNLpUL5334jAQQm8tj++H/MrgP2Z sn8f4HOqI5VSyxGBQPr8d0lgwKNZauFYPVfuI+EnYAbTgPl0fmFfA20HJspAmcWRsFEQ giB3af0RIrBul8SlPLScq2Jk0hu69byifJwGkRkhTxlD9y+BRdoeNrJvkmE1wN7r3UnZ 2Cntn/1bkhPtm6huegoVNQJPiZ8yvA7K7TcX1uheYuysnDiM0d4vljp3CVuKFpCo+qD5 c4fA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j6-20020a170903024600b00192d4c98f87si40393284plh.308.2023.01.18.20.08.46; Wed, 18 Jan 2023 20:09:15 -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 + 99 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-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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755422502791236313?= X-GMAIL-MSGID: =?utf-8?q?1755422502791236313?= 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 Reviewed-by: Dhruva Gole --- 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;