Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4450407ioa; Wed, 27 Apr 2022 04:16:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa6pzxasTWPDhMORJMCD7NdGEFrr7YsWJn5L0QtJA5XNSYfyelseEIGOtBGo1ZUMD5yFsK X-Received: by 2002:a17:90a:b285:b0:1d9:aee3:fabd with SMTP id c5-20020a17090ab28500b001d9aee3fabdmr9286727pjr.72.1651058161837; Wed, 27 Apr 2022 04:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651058161; cv=none; d=google.com; s=arc-20160816; b=O1O+2igro7OFzhPpdPZXGbI8cYvUsjgSqk3gTbY+chiyFJ5hRMe6aWdOcnIH5CX6Lb Bzy6P6f6fmZtQifACCevTmeJ5bvyOGAm4Perm/DcuMAF8sVbDXuveR9ZpCvQwTK7CIDr TtuHqBirJe7IoI/rTeeCKhgu0ZNfLQ+I60BWLxGN+T/K83H29jrhAlGG5hiNkIcRr4py 1DSy8IxHJP59fYQFDbsuXiBuUMSh+B6tF0GpPFYKxmOWT+GoDSFi1c+4u2Od4rdMGYWM YCiZ8S22judSRtY77Y80xncyv4VmPERuRWOaW9qT8bE9drnZ9PiRlxtmEaKM2uaLWrf+ lC+Q== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YkA/eqogjj9bY1q/w3HQTgXOX31J90aJOMBJMPKQZT0=; b=KTLUZWVOK/uRD8ziz1GcM0x3IhFzGI3b307Pftzwpr8CxuCSC4XN0Pfu0PpRfqXCPy HgJUXoIg6FBTsezTc2DS9b4wVtMw0o4M4215qKo9oEI3UVoONA8Yce4boe5YEtRV+b3B 3mgmjAvTT2uz1I+fFr/0ZyXFquZBtn7iA4Ruj9VdacnHqMAPd8bX3BUzBoNokzys5ZXs rIP9R4pkC3MpZK8YjihZdFK3RnWvdA3KisOe6Ws/5a0YXOhJ8hPgfdb42llUvNcq3+lX fo8yrC0trZKnYOyEdNqPhJ8GyoXOeOGCP3q6yfp3hjygaU7uj7mFvADbjVKTSLN4pVMC hHNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lfKt8Z1m; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t185-20020a632dc2000000b003ab0ba1da63si1241726pgt.334.2022.04.27.04.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 04:16:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lfKt8Z1m; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94358306717; Wed, 27 Apr 2022 03:09:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233963AbiDZJCQ (ORCPT + 99 others); Tue, 26 Apr 2022 05:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347039AbiDZIpo (ORCPT ); Tue, 26 Apr 2022 04:45:44 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A98473FBFB; Tue, 26 Apr 2022 01:37:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9F0D2CE1BC3; Tue, 26 Apr 2022 08:37:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E2FAC385A0; Tue, 26 Apr 2022 08:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962230; bh=Er9JeDduHx3NE8tk+2GPgX+U68ot1zkwu8WUINdW/4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lfKt8Z1mRwnLvV7uUtD5yXdOo3pXFtn7Hr5CXt7q66Ge8lcKRymY/mWuDgbuLYbRY o+fpNdTqfwIV6JfZ0XAs5RuNgF/qdLSJhXyZvrUkJKBVCB80s2PTWMf5PNKx4kWJNH tbxIGao339YPM+29cKrZXUR99cseeLdOAOxxZx60= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Schiffer , Mark Brown , Sasha Levin Subject: [PATCH 5.15 028/124] spi: cadence-quadspi: fix incorrect supports_op() return value Date: Tue, 26 Apr 2022 10:20:29 +0200 Message-Id: <20220426081748.104548213@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 From: Matthias Schiffer [ Upstream commit f1d388f216aeb41a5df518815ae559d14a6d438e ] Since the conversion to spi-mem, the driver advertised support for various operations that cqspi_set_protocol() was never expected to handle correctly - in particuar all non-DTR operations with command or address buswidth > 1. For DTR, all operations except for 8-8-8 would fail, as cqspi_set_protocol() returns -EINVAL. In non-DTR mode, this resulted in data corruption for SPI-NOR flashes that support such operations. As a minimal fix that can be backported to stable kernels, simply disallow the unsupported operations again to avoid this issue. Fixes: a314f6367787 ("mtd: spi-nor: Convert cadence-quadspi to use spi-mem framework") Signed-off-by: Matthias Schiffer Link: https://lore.kernel.org/r/20220406132832.199777-1-matthias.schiffer@ew.tq-group.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-cadence-quadspi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c index 1a6294a06e72..75680eecd2f7 100644 --- a/drivers/spi/spi-cadence-quadspi.c +++ b/drivers/spi/spi-cadence-quadspi.c @@ -1226,9 +1226,24 @@ static bool cqspi_supports_mem_op(struct spi_mem *mem, all_false = !op->cmd.dtr && !op->addr.dtr && !op->dummy.dtr && !op->data.dtr; - /* Mixed DTR modes not supported. */ - if (!(all_true || all_false)) + if (all_true) { + /* Right now we only support 8-8-8 DTR mode. */ + if (op->cmd.nbytes && op->cmd.buswidth != 8) + return false; + if (op->addr.nbytes && op->addr.buswidth != 8) + return false; + if (op->data.nbytes && op->data.buswidth != 8) + return false; + } else if (all_false) { + /* Only 1-1-X ops are supported without DTR */ + if (op->cmd.nbytes && op->cmd.buswidth > 1) + return false; + if (op->addr.nbytes && op->addr.buswidth > 1) + return false; + } else { + /* Mixed DTR modes are not supported. */ return false; + } if (all_true) return spi_mem_dtr_supports_op(mem, op); -- 2.35.1