Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1269936pxb; Fri, 10 Sep 2021 01:59:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc7eAAvhRlIXpmlM7rA75msdktA4wS86f5T+fNNZJthPrJ3gBaGGeCo3N5uEXBG2cxqPPa X-Received: by 2002:a6b:3f54:: with SMTP id m81mr6076633ioa.184.1631264399399; Fri, 10 Sep 2021 01:59:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631264399; cv=none; d=google.com; s=arc-20160816; b=JwYw8OPJ2UhcnKjetmD7OyuuIe6Rui6sQ/1zdFvYUVE/t5a5Ow7N0OV6Hr8M15PRub niZmS6TOjv4DMGfjy/P4OP0qLKfGHjq4d7apA1qgOVXj3LFbaUklch/DGGhiOI5+tZV8 4DMjkbgT8BUSbC/zErIVbmxXgUQ68xgy2shW7koGiEoW9v6T60JkQVmvu/mo45lB6xpH UelIahD87Tpdqk96Qa0G1mdb4Bn5UbDo12QaK/CKVFbG2jel/Es7l5du4KE9f7+5rueU 9kzyVZcLPR5NLA5RnVy1Xk1ebq/zzWpm1Y9Q4O/qh87AWCsQIOeBgPgXuaD0IK0Qa6/W cUoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=Ng6fl+LjSMMDnLGolzdyDkr3lgU0oG0a4p27ETtGecY=; b=npFR1jkWz83nztXjv/WkAh48TfSzsrQ4iJcjSimh/doFMKpg1UjZWzbiIha2vwCRSf HLXuXfW4YJUoA2ibeKeT62ruLXGpVXuMN/3JCVHamX5H3cxM5V/vJm5mHO8NBp+XeDtj ZcZCsjEt/RhdQRyvM5rcTcM34OHnkKsBdHTP0UjkZhFqmw5As1Ys41qpKyJQ0Qaie98O YgFQGGJSGOXiyUpgJtX4gMDlHDBbslwZdykS16WGGDsqMBZ7Adw1dLSd+nr9QxBscsm8 qlBCQY03gTbUYTjoFKNGqrRuL9J31Aqi9/YMya8EA+APEDm7FRTHieb/q8L33CLIkwhf pDrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=SYAIQzUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si4604866ilq.142.2021.09.10.01.59.47; Fri, 10 Sep 2021 01:59:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=SYAIQzUZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231862AbhIJI7H (ORCPT + 99 others); Fri, 10 Sep 2021 04:59:07 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:19190 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231771AbhIJI7G (ORCPT ); Fri, 10 Sep 2021 04:59:06 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18A6UIwZ018935; Fri, 10 Sep 2021 03:57:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=Ng6fl+LjSMMDnLGolzdyDkr3lgU0oG0a4p27ETtGecY=; b=SYAIQzUZiJnhMpKhJaJGPD/9fKUKPupM5InvHm9jpPSFYmbCcsk4RKbkiJH40NhxD8Hs yBdpubdNwoQBXaOXSq2BRgpDneU1YBfEnzDDBMjJ57WQS5r91/G5yJCDZoI5sfmCg/P6 ryi6ZQOokq0cI4iorxWbhSPKIsegoy4aihtqX70O6wIzrUwJIqnA7v+VUGy2PUNqVz0S x8Jp8Yaa228zMbg/yPxapgEf1oSRMWX7eckHAR1ETnTe2lIFK5DE2HiHGkO/4TPwUcPR Mc5cI1hGeVzclxguJ5WXHdKebRt3ydh6LjdA9WnfR4EDUz4adc9jQCg4G0Jpz/XvYxMk nA== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0b-001ae601.pphosted.com with ESMTP id 3aytg78sbf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Fri, 10 Sep 2021 03:57:52 -0500 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.12; Fri, 10 Sep 2021 09:57:36 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.2242.12 via Frontend Transport; Fri, 10 Sep 2021 09:57:36 +0100 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id BDC8EB2F; Fri, 10 Sep 2021 08:57:30 +0000 (UTC) Date: Fri, 10 Sep 2021 08:57:30 +0000 From: Charles Keepax To: Lucas Tanure CC: Mark Brown , Sanjay R Mehta , Nehal Bakulchandra Shah , , , Subject: Re: [PATCH 4/4] spi: amd: Check for idle bus before execute opcode Message-ID: <20210910085730.GX9223@ediswmail.ad.cirrus.com> References: <20210909111005.304101-1-tanureal@opensource.cirrus.com> <20210909111005.304101-4-tanureal@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210909111005.304101-4-tanureal@opensource.cirrus.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-GUID: hxjhjQ3NIX_x0ohRmMZ-Bsf_d-hnqd8V X-Proofpoint-ORIG-GUID: hxjhjQ3NIX_x0ohRmMZ-Bsf_d-hnqd8V X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 12:10:05PM +0100, Lucas Tanure wrote: > Check if the bus is not in use before starting the > transfer > > Signed-off-by: Lucas Tanure > --- > drivers/spi/spi-amd.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c > index 97838b57871c..99b2b0ccff08 100644 > --- a/drivers/spi/spi-amd.c > +++ b/drivers/spi/spi-amd.c > @@ -115,11 +115,18 @@ static int amd_spi_busy_wait(struct amd_spi *amd_spi) > return 0; > } > > -static void amd_spi_execute_opcode(struct amd_spi *amd_spi) > +static int amd_spi_execute_opcode(struct amd_spi *amd_spi) > { > + int ret; > + > + ret = amd_spi_busy_wait(amd_spi); > + if (ret) > + return ret; > + > /* Set ExecuteOpCode bit in the CTRL0 register */ > amd_spi_setclear_reg32(amd_spi, AMD_SPI_CTRL0_REG, AMD_SPI_EXEC_CMD, AMD_SPI_EXEC_CMD); > - amd_spi_busy_wait(amd_spi); > + > + return 0; > } This feels like the commit message could use come additional explanation. The message states we are moving the wait, but not why? Also the original code looks slightly more logical, as in amd_spi_fifo_xfer we read the receive buffer immediately after calling this function. Thanks, Charles