Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2446483rdb; Tue, 12 Sep 2023 01:59:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE0JR9JxAAYLdZTjW7pyMVqYzk5ymLy6V8E8hgdDMAInvU7MIvO1z8ECnp0AisHXGvb2l+R X-Received: by 2002:a05:6a21:3b46:b0:142:aced:c643 with SMTP id zy6-20020a056a213b4600b00142acedc643mr9452350pzb.31.1694509197862; Tue, 12 Sep 2023 01:59:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694509197; cv=none; d=google.com; s=arc-20160816; b=Or7nxSsnJd8WdbwHfO9BiqME7c332XppcRgT4flWFb0D2p6rOVUlXTsSyCuDBaIdT4 9gfYOJVXx0oehlq76RuhRxCLdn0ZS/c1pAy24ha0ATjk4OlfMWwdAjzi4JpqC0lVhzsQ UP2pxREJgo3GxiHQZ7hQQ1LkqPDD+T02wrEpu/ibTPvTf1kag3+UCfym1ZEL09kIIrkp FOJ1X6SfNJRsmPBmtuC1F8RB4jL60lKTorTdj45jQl64H5cye7ip9mIeRezA2jPXWkMJ SMDcoep70R2RdrbIcb17QUhXEdNeLCHcyF0M5zaTWvzWM3XdRrl6lCyimHjqD6c8/hGf Fjgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FmAKPfAqYf4qgtonlhIY3CzGnHiN4N9eP1OVn1PTGqg=; fh=rkCGCyaUanfIBh/kPmD7Og9983sD4XZZAz7CtzWNOFg=; b=0U2hsZg/coFTCJ36hB2+qyhz7cEGS6DMSlC42tvj9KSA0hcSDlfB7YV5Ynw9ngtpiE 2EgAMkxH0EpPLKU/7E2rhYhjIRWUxzN6LsqShgiJXhChPYf52U45bc4e/qUDsQB15lhq ULlm7BpSmF9FxdDGKnyepfwOZC6nlRon62/tMILaTvArwLxfXgrQNYOlFZGByN4lAS59 vSvUySRGEJVRaeWUTeIKWRJwWYwdynxHxp1GrUYYAMxkP+L0ouqa3ZfzEFDMZKLsa/xB ccIAtDghw7OYKt6FCw1akeEst1ZQ7lam6mSXxn3GhHiEhZndcNPNkRkqy08hFHwMTrdC l/GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mmKOV9hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id g8-20020a17090a640800b00263d559dbf1si7640747pjj.55.2023.09.12.01.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 01:59:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mmKOV9hk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BCEC6801C010; Mon, 11 Sep 2023 22:05:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjILFFF (ORCPT + 99 others); Tue, 12 Sep 2023 01:05:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229888AbjILFFE (ORCPT ); Tue, 12 Sep 2023 01:05:04 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2921AA; Mon, 11 Sep 2023 22:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694495100; x=1726031100; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=URkUofiEo6whfXpBDveK+XC9cE0isgPklL6xvqQGiL0=; b=mmKOV9hktQlmqLhr/3nLxXJpexzz+dDuhZ+PokeiuRYTvj1mRAnd+OKg iYCoDNk0SjNMksgFMngxDm5SvHDXDLzaGkjLBqxnpqp90vSbO+D/IDrkA g5ha/5XvSz24lBchfva0YO9Gvq/UOe/zzA+hcyjncgJhCsnwDGW6JQ+dh J+iKyg5CnBLsZ9dZNBh0WpaMu8WOrSHN6Xycbcup2s3ORa5KDDaS+0/mQ AT8+skgIODnvhw80+/5NmYodW52MqamgEZp++qhuwDg4mHBuhkQH1t7S1 Py9BxNHF9Kwk0h4tfaGYYfBFnirsxUjkXF7jgOHf9kJVKrOk5zPSlqxBq g==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="409230831" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="409230831" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2023 22:05:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="778649730" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="778649730" Received: from dkandpal-mobl1.amr.corp.intel.com (HELO [10.212.139.48]) ([10.212.139.48]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2023 22:05:00 -0700 Message-ID: <700f14f7-ae3d-410c-8b10-2a83221aba3c@linux.intel.com> Date: Mon, 11 Sep 2023 22:04:59 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 1/4] platform/x86: intel_scu_ipc: Check status after timeout in busy_loop() Content-Language: en-US To: Stephen Boyd , Mika Westerberg , Hans de Goede , Mark Gross Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, platform-driver-x86@vger.kernel.org, Andy Shevchenko , Prashant Malani References: <20230911193937.302552-1-swboyd@chromium.org> <20230911193937.302552-2-swboyd@chromium.org> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20230911193937.302552-2-swboyd@chromium.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 11 Sep 2023 22:05:08 -0700 (PDT) X-Spam-Status: No, score=-1.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Hi, On 9/11/2023 12:39 PM, Stephen Boyd wrote: > It's possible for the polling loop in busy_loop() to get scheduled away > for a long time. > > status = ipc_read_status(scu); // status = IPC_STATUS_BUSY > > if (!(status & IPC_STATUS_BUSY)) > > If this happens, then the status bit could change while the task is > scheduled away and this function would never read the status again after > timing out. Instead, the function will return -ETIMEDOUT when it's > possible that scheduling didn't work out and the status bit was cleared. > Bit polling code should always check the bit being polled one more time > after the timeout in case this happens. > > Fix this by reading the status once more after the while loop breaks. > The read_poll_timeout() macro implements all of this, and it is > shorter, so use that macro here to consolidate code and fix this. > > There were some concerns with using read_poll_timeout() because it uses > timekeeping, and timekeeping isn't running early on or during the late > stages of system suspend or early stages of system resume, but an audit > of the code concluded that this code isn't called during those times so > it is safe to use the macro. > > Cc: Prashant Malani > Cc: Andy Shevchenko > Fixes: e7b7ab3847c9 ("platform/x86: intel_scu_ipc: Sleeping is fine when polling") > Signed-off-by: Stephen Boyd > --- Reviewed-by: Kuppuswamy Sathyanarayanan -- Sathyanarayanan Kuppuswamy Linux Kernel Developer