From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752678AbeBSLus (ORCPT ); Mon, 19 Feb 2018 06:50:48 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:58008 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752563AbeBSLur (ORCPT ); Mon, 19 Feb 2018 06:50:47 -0500 Cc: Sudeep Holla , ALKML , LKML , DTML , Roy Franz , Harb Abdulhamid , Nishanth Menon , Loc Ho , Alexey Klimov , Ryan Harkin , Jassi Brar Subject: Re: [PATCH v5 11/20] firmware: arm_scmi: add support for polling based SCMI transfers To: Arnd Bergmann References: <1514904162-11201-1-git-send-email-sudeep.holla@arm.com> <1514904162-11201-12-git-send-email-sudeep.holla@arm.com> From: Sudeep Holla Organization: ARM Message-ID: Date: Mon, 19 Feb 2018 11:50:42 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19/02/18 11:32, Arnd Bergmann wrote: > On Tue, Jan 2, 2018 at 3:42 PM, Sudeep Holla wrote: > >> +#define SCMI_MAX_POLLING_TIMEOUT_NS (100 * NSEC_PER_USEC) >> /** >> * scmi_do_xfer() - Do one transfer >> * >> @@ -389,14 +406,30 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer) > >> + if (xfer->hdr.poll_completion) { >> + ktime_t stop, cur; >> + >> + stop = ktime_add_ns(ktime_get(), SCMI_MAX_POLLING_TIMEOUT_NS); >> + do { >> + udelay(5); >> + cur = ktime_get(); >> + } while (!scmi_xfer_poll_done(info, xfer) && >> + ktime_before(cur, stop)); > > The 5 microsecond back-off isn't that much smaller than the 100 microsecond > timeout, given that udelay() often waits much longer than the specified time. > > How did you come up with those two numbers? Are you sure this is better > than just using a cpu_relax() instead of the udelay()? > Somehow I assumed that cpu_relax will schedule out and since this is called in the fast switching path, I can't do that. But now I see that it's just an hint and so I can use it. Sorry for missing it earlier, you did point this out in previous version and I retained it based on my wrong assumption. Thanks. -- Regards, Sudeep