Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2417547pxj; Mon, 10 May 2021 02:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSwTxiPdoq7bUIPJjEgfxCjvvtIhSmzD7rWJygxwDi9zQgLhhw3D0UgTLn0SwBFIPEdvM1 X-Received: by 2002:a17:906:1e0b:: with SMTP id g11mr24405870ejj.291.1620638654414; Mon, 10 May 2021 02:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620638654; cv=none; d=google.com; s=arc-20160816; b=NiAHYHexd/WofyOpUvVobFIJfyPt8NkY80KvdmRqmIgr8wu4JMDADGmK9FRmFe8bUl Nh8HNR3ZzVzo2zumBT8HsrzvyeIGfY24mg6V/WMSM1lsMjldNTSPYD4FeRfb7KqIymgk KA8MKvFvXM19HnOcZvA9FcYj1Rk0ljG+49rddoWWao9goWuIrKgF5ZPrUU9MWuajgIld 0EsXXKSVWvnfVkA9846/h2EFMdKktvIN2UwHP/61F0oIo11HK8xtiLLQBa7VihnmkDvl ICUQpmr1QYvhYwzG8M8USTMcF6y0u494iRP7VGGWGJkDAxt9ToQdKN1qlnzvjFJfDdxn pd9A== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=Gzqa8okERyAR6qH7zOXncblogCnXOe5C9zVhP50AQwQ=; b=nU9oKMGccYOQ5BLRD0HUzFKGJwjpW61OP6zll8Q95VxHJ0yFEo7Csd9BMaDFT6/WpK yofs7I0L3ObPdwlgxfKkH34I2DceIxFONLsDSt11vwYi/ao62LtwEesLpdniA9fElH/4 sC2YgUp9oUQkgczSwyXgASTW4w2QHGCgzyEAxDw1VnIRz9mc1x7vyVGjRHAVc4rPcCEB E3TfdWykvObf4SuEF1nyf2H0CW0Y6X65ZkIEH8lYn6riTTEeOho+8GmVsUldq7rF+W0F Va9qQXkWknTYCv6+5uAg2wuuXOQxiyAxyCm0WLeVcB0hoPgQ4uWOaZ49ifTgyoqVml0L zJ+A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si10621038ejy.308.2021.05.10.02.23.50; Mon, 10 May 2021 02:24:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbhEJJYA (ORCPT + 99 others); Mon, 10 May 2021 05:24:00 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:55434 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229566AbhEJJX7 (ORCPT ); Mon, 10 May 2021 05:23:59 -0400 Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 189581F42076; Mon, 10 May 2021 10:22:54 +0100 (BST) Date: Mon, 10 May 2021 11:22:49 +0200 From: Boris Brezillon To: Patrice CHOTARD Cc: Mark Brown , Miquel Raynal , Vignesh Raghavendra , , Alexandre Torgue , , , , , Subject: Re: [PATCH v2 1/3] spi: spi-mem: add automatic poll status functions Message-ID: <20210510112249.5613978e@collabora.com> In-Reply-To: <542000b4-1a65-5090-72f9-441c75ee1098@foss.st.com> References: <20210507131756.17028-1-patrice.chotard@foss.st.com> <20210507131756.17028-2-patrice.chotard@foss.st.com> <20210508095506.4d0d628a@collabora.com> <542000b4-1a65-5090-72f9-441c75ee1098@foss.st.com> Organization: Collabora X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 10 May 2021 10:46:48 +0200 Patrice CHOTARD wrote: > > > >> + > >> + if (ctlr->mem_ops && ctlr->mem_ops->poll_status) { > >> + ret = spi_mem_access_start(mem); > >> + if (ret) > >> + return ret; > >> + > >> + reinit_completion(&ctlr->xfer_completion); > >> + > >> + ret = ctlr->mem_ops->poll_status(mem, op, mask, match, > >> + timeout_ms); > >> + > >> + ms = wait_for_completion_timeout(&ctlr->xfer_completion, > >> + msecs_to_jiffies(timeout_ms)); > > > > Why do you need to wait here? I'd expect the poll_status to take care > > of this wait. > > It was a request from Mark Brown [1]. The idea is to implement > similar mechanism already used in SPI framework. Well, you have to choose, either you pass a timeout to ->poll_status() and let the driver wait for the status change (and return -ETIMEDOUT if it didn't happen in time), or you do it here and the driver only has to signal the core completion object. I think it's preferable to let the driver handle the timeout though, because you don't know how the status check will be implemented, and it's not like the reinit_completion()+wait_for_completion_timeout() done here would greatly simplify the drivers wait logic anyway.