From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7B944C433EF for ; Thu, 10 Feb 2022 12:38:16 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4EBD182045; Thu, 10 Feb 2022 13:38:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=opensource.wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="Zavn+Ead"; dkim=pass (2048-bit key; unprotected) header.d=opensource.wdc.com header.i=@opensource.wdc.com header.b="nLjMqho7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 945EF83F01; Thu, 10 Feb 2022 00:18:47 +0100 (CET) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0EA57801EA for ; Thu, 10 Feb 2022 00:18:42 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=opensource.wdc.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=prvs=032e362c4=damien.lemoal@opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1644448723; x=1675984723; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=KfUJG/MmzaS9BygGk/AbgdctCCQLe0eGIbo66CBAueQ=; b=Zavn+EadNEd0j7CAGeZVZ6arbKE1KzGDFca5DT7qk6WikBpw9wIC0N60 CvMs9Fe5xtVtJlJzpD0LKgJJ0AmOLqLAJ7gHgbrfvz8oBKEqvirBblSnX 53pqATj8uRDZ4VXx/AmDw8bwPcEjKqh3Oy9mepPh4sOcfipIsPr4evgcj zmbH3ST4QsldqBWLxGzWiYQCVkpV8F88N2K0xcqr5Y8tJL5x4guhrWDx1 n6F0i66BXAM2D15sTcREpxuvQ3bzeP5MMbljDmSWgGA8aozY9f6uFnWfo OaWyJieOcSqi/KZ487Nebr4FI9ucz8p9eu77+kikpsD7VnqSn43sIZmZV g==; X-IronPort-AV: E=Sophos;i="5.88,356,1635177600"; d="scan'208";a="304449804" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 10 Feb 2022 07:18:40 +0800 IronPort-SDR: bb2kAjL/hRsRBFoCDIQvhXgD/4fDhUVAdtHRdEMJxdHeSE0H/X+nFbRyCmTNH06GKuTFSba7gl Ml1Uxjwse4C4yEW70pxbiZdeIw082lOmBwFArJ3LmL85WC9S8UGgT51vLfFwfWsBsRb6NPQ8hc ff+Ale3NZT0B5PARCkQ5gXhPhgb2nHjys6JlhQMHZeiajqgPXig+tQ0coRd8kW07glxLQyNPG3 62mZhq65QopNrtYFjs3X/cSGtHWSRwABHMKpVuksEnnJOomBd0/nWD09QhNUASx4AmfmVSlVO4 q/sv6WYUXPVFlvcDe+Z2OArH Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 14:50:28 -0800 IronPort-SDR: BAiK/Q0Mx6qc9xZSk8bloDIjkueBWMJc4WvKoefy6VofMfNmFxyQVFLtpERn+n2AISxeVBpb50 tsXzfvNdRAF6PSgZw53+4gXsjL6RxcFgfdgW+LAc6Ots7rMLu4TwTSkaPeervPZQRs1HXHD7xy uhr57NmcO2of4PmaJccH9Xg9d0i+O0R7n6pFEF2csff9SPSYdLueSvisS+v+k8Zm+Lk//1R+bs tCE+MFWOYmufgdyrWHagbQua3f6DO5lOAMS6GdYIVPbmeyvbRCmVAQsqepXaBsyo+eN7kFrrUI wPQ= WDCIronportException: Internal Received: from usg-ed-osssrv.wdc.com ([10.3.10.180]) by uls-op-cesaip02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Feb 2022 15:18:40 -0800 Received: from usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTP id 4JvG5r0w7nz1SVny for ; Wed, 9 Feb 2022 15:18:40 -0800 (PST) Authentication-Results: usg-ed-osssrv.wdc.com (amavisd-new); dkim=pass reason="pass (just generated, assumed good)" header.d=opensource.wdc.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d= opensource.wdc.com; h=content-transfer-encoding:content-type :in-reply-to:organization:from:references:to:content-language :subject:user-agent:mime-version:date:message-id; s=dkim; t= 1644448719; x=1647040720; bh=KfUJG/MmzaS9BygGk/AbgdctCCQLe0eGIbo 66CBAueQ=; b=nLjMqho78hFwHrX/uVqyomhrRqZ5PbGegJhV6eOl2UoPdV8KmSr Z0LtVYdzqPtuPzmB+VrXbEcp/T92Da5boPOsSGS59UChFgvVUUwsGtTGljVghPff LvcHdQaeh2K5/L/aPX88mBQg7qsrakubIJEl4+8/dtkty+Whz9FwIt+I6yctdgmG VZv1auWDFPLgtC/JsCxT/JK64S5+QJBE37XtNbFTv7hk9YhKcYseRxP0ztrxxk6S S0KXVdPp6LCHUr9iSLFcMgkc3iqa9vR30OF3K8jXPpWHSt1afAE12v/lvP3sB77/ kJQNVGG3wZRUb6cUv84wl+zeqBQFa+7m0JQ== Received: from usg-ed-osssrv.wdc.com ([127.0.0.1]) by usg-ed-osssrv.wdc.com (usg-ed-osssrv.wdc.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TE90Dzt2nm2E for ; Wed, 9 Feb 2022 15:18:39 -0800 (PST) Received: from [10.225.163.67] (unknown [10.225.163.67]) by usg-ed-osssrv.wdc.com (Postfix) with ESMTPSA id 4JvG5p3sMyz1Rwrw; Wed, 9 Feb 2022 15:18:38 -0800 (PST) Message-ID: Date: Thu, 10 Feb 2022 08:18:37 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] spi: dw: Fix broken dw_spi_mem_ops() Content-Language: en-US To: Niklas Cassel , Jagan Teki Cc: Pratyush Yadav , Sean Anderson , "u-boot@lists.denx.de" References: <20220208225236.1058824-1-Niklas.Cassel@wdc.com> From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20220208225236.1058824-1-Niklas.Cassel@wdc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Thu, 10 Feb 2022 13:38:12 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 2/9/22 07:52, Niklas Cassel wrote: > From: Niklas Cassel > > The driver is currently using sizeof(op->cmd.opcode) in the op_len > calculation. Commit d15de623013c ("spi: spi-mem: allow specifying a > command's extension") changed op->cmd.opcode from one byte to two. > > Instead, a new struct member op->cmd.nbytes is supposed to be used. > For regular commands op->cmd.nbytes will be one. > > Commit d15de623013c ("spi: spi-mem: allow specifying a command's > extension") did update some drivers that overload the generic mem_ops() > implementation, but forgot to update dw_spi_mem_ops(). > > Calculating op_len incorrectly causes dw_spi_mem_ops() to misbehave, since > op_len is used to determine how many bytes that should be read/written. > > On the canaan k210 board, this causes the probe of the SPI flash to fail. > > Fix the op_len calculation in dw_spi_mem_ops(). Doing so results in > working SPI flash on the canaan k210 board. > > Fixes: d15de623013c ("spi: spi-mem: allow specifying a command's extension") > Signed-off-by: Niklas Cassel > --- > drivers/spi/designware_spi.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/spi/designware_spi.c b/drivers/spi/designware_spi.c > index 742121140d..fc22f540fe 100644 > --- a/drivers/spi/designware_spi.c > +++ b/drivers/spi/designware_spi.c > @@ -572,7 +572,7 @@ static int dw_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op) > int pos, i, ret = 0; > struct udevice *bus = slave->dev->parent; > struct dw_spi_priv *priv = dev_get_priv(bus); > - u8 op_len = sizeof(op->cmd.opcode) + op->addr.nbytes + op->dummy.nbytes; > + u8 op_len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes; > u8 op_buf[op_len]; > u32 cr0; > Tested-by: Damien Le Moal -- Damien Le Moal Western Digital Research