Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp1672697ima; Sat, 2 Feb 2019 05:24:20 -0800 (PST) X-Google-Smtp-Source: ALg8bN6t5sGeOLiqts8h8ijWo0xpnwnk789eIkr2pqeH/qIrwOBnRpRa/DsKAalSj+Y3K1A2+HPr X-Received: by 2002:a17:902:e08b:: with SMTP id cb11mr44377409plb.263.1549113860390; Sat, 02 Feb 2019 05:24:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549113860; cv=none; d=google.com; s=arc-20160816; b=sJ4pu3YcEqGIWUXn3uNwu/Ant28rMVtRavAp8hgGUtr1cCQ4FRDPwwpkd7qLmlrL0x xgr1wjysS1Oqfezu/50NMTxCUcdn531HHgBs+J1TYKtiyN9GcM81aWWZeQUI3/3TSaHB wr1IBg1Bb3/rxL5E4KIZhEoKv0i1q1972EaG5owBUJcwfN8JMl5yNBjOYk/CsFxEKPzL jgUJJikgbpkfu54Fiu++UHRhT5vC7O48W/cpyxmoD+zzAnn6Puowpk/Db9kdHcAjOhf1 m7dwF4n0oOVWqbh76vMpnXon3hk1zvOaGpEuhVdNZEP2er/XFdyV8ODurcpQowZW8z7K 41Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=YUVwX2rfawSKAB50zrEGtTDfj9+tCzkgkvzLBoc0h4A=; b=V9WRuqpldtebQZm4JZ/uUyNtlxiVxXBNQ32NOjNnfkiAY/Z3sUznVRyiPeuHAJoNUd o2H5NTV+I2F0jPNYkK8d4pLH8QsK2Awgm/QPPYDeZPEcy/ekt2mO4cIn+a+PDXV8wuJo yTa2vraElDxkLozXZj+NmCNOSRMSa9C+xXaOpScXAzO9viM6bMdI5zGkfb9fA8bqv64j U2r66vZJMOuXb2Ok5oivlvB2e6+Ipp1HFYM4wiiu/S5cwbne9lsGX1SvqxgaUu+j0iRv IuEQF0lIMPGgUoTGLsBlNs4BBJQkAqhFqCzgJDT110MXM1f7rC51PmLzENFVK/2DaOka Trgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yvn9i/T2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f18si10060665pgl.457.2019.02.02.05.24.02; Sat, 02 Feb 2019 05:24:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Yvn9i/T2"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728016AbfBBNUn (ORCPT + 99 others); Sat, 2 Feb 2019 08:20:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:37772 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727847AbfBBNUn (ORCPT ); Sat, 2 Feb 2019 08:20:43 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9F9682173B; Sat, 2 Feb 2019 13:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549113641; bh=KsuDKuKlJQAE474thXEYS0gFc9Y879d0/apCZUyA2BU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Yvn9i/T2YxRQ61YiDLwBBRswAL47uWfTMzRseCidx4/oSP5KHtFEi4EqDwqd2vnMH BXlWwtA8Jn3yaPKxyNZ3MdUcPWwt7lCFAJppVeqndFKVzXmHvtyIrvHtQrAwUr3XNj iayI1CXdSAhgQf2EiWgoD48l/4oVA6cr2v3UFo0M= Date: Sat, 2 Feb 2019 14:20:29 +0100 From: Boris Brezillon To: Cc: , , , , , , , , , , , Subject: Re: [PATCH v3 01/13] spi: atmel-quadspi: cache MR value to avoid a write access Message-ID: <20190202142029.76ac36b6@bbrezillon> In-Reply-To: References: <20190202040653.1217-1-tudor.ambarus@microchip.com> <20190202040653.1217-2-tudor.ambarus@microchip.com> <20190202080650.44becc2d@bbrezillon> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2 Feb 2019 08:38:40 +0000 wrote: > On 02/02/2019 09:06 AM, Boris Brezillon wrote: > > On Sat, 2 Feb 2019 04:07:13 +0000 > > wrote: > > > >> From: Tudor Ambarus > >> > >> Cache Serial Memory Mode (SMM) value to avoid write access when > >> setting the controller in serial memory mode. SMM is set in > >> exec_op() and not at probe time, to let room for future regular > >> SPI support. > >> > >> Signed-off-by: Tudor Ambarus > >> --- > >> v3: update smm value when different. rename mr/smm > >> v2: cache MR value instead of moving the write access at probe > >> > >> drivers/spi/atmel-quadspi.c | 7 ++++++- > >> 1 file changed, 6 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c > >> index ddc712410812..645284c6ec9a 100644 > >> --- a/drivers/spi/atmel-quadspi.c > >> +++ b/drivers/spi/atmel-quadspi.c > >> @@ -155,6 +155,7 @@ struct atmel_qspi { > >> struct clk *clk; > >> struct platform_device *pdev; > >> u32 pending; > >> + u32 smm; > >> struct completion cmd_completion; > >> }; > >> > >> @@ -238,7 +239,11 @@ static int atmel_qspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op) > >> icr = QSPI_ICR_INST(op->cmd.opcode); > >> ifr = QSPI_IFR_INSTEN; > >> > >> - qspi_writel(aq, QSPI_MR, QSPI_MR_SMM); > >> + /* Set the QSPI controller in Serial Memory Mode */ > >> + if (aq->smm != QSPI_MR_SMM) { > > > > Sorry, I think I misunderstood your previous suggestion, I thought the > > reg was called SMM. If the reg is called MR and the value you expect in > > there is SMM, then the field should be named ->mr as it caches the > > whole reg, not only the SMM bit. So it's actually: > > > > if (aq->mr != QSPI_MR_SMM) { > > No worries. When keeping the reg name, and not the bit itself, I would expect to > do the check as in v2, to let room for checking other bits too: > > + if (!(aq->mr & QSPI_MR_SMM)) > > I don't have any problems to keep "mr" name, but I would like to understand your > reasons. Either you want to only set the SMM bit and keep the other bits untouched or you want to make sure the register contains the value you expect for all bitfields. If you're trying to achieve the former, you should only update SMM instead of setting SMM + clearing all other bits. In the other hand, if you want to apply a new MR setting where you know exactly that only SMM should be set, that means you should test the value in the cache (->mr) against the value you expect, and not only the check that QSPI_MR_SMM is set. BTW, you should probably initialize ->mr at probe time (using a readl_relaxed()).