Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp2469460rdb; Tue, 12 Sep 2023 02:58:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPdoFGt6+zGFs5ZsaLZYSKDTt7oMHYClEB6VBJKcvkKVhWAWMMOPiMwAwL0eC4zMNI8f5K X-Received: by 2002:a05:6a21:3385:b0:154:e054:d0d1 with SMTP id yy5-20020a056a21338500b00154e054d0d1mr7661335pzb.55.1694512685623; Tue, 12 Sep 2023 02:58:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694512685; cv=none; d=google.com; s=arc-20160816; b=LnNveuH7+B0/X1KjlG0w7Eq+VWTF8BKTZa8MCHeWVtjxkArt+0bZSGwv+pmbKw0G6K p7jg6aDipozid+3eijwkRfEIoYv16xDv869sMDByw2q5s9MkvuraXt8lHdNeQD6UuhZr 017IKeRgsYzKtB1FxZl7G/Au0nn6NdgR8fNfc5rVz/vz434x6R0Hz8tIcVFgfO8KAZoS 6+8qqchxRR88dtX4fzj7ViMMmJGoUaR2d5lzERWERUyePhne8NEnR/8CErFxpxG77Z45 hi+NwvTsU9Wk1LiZAlc6Sftyi3VlLSiQ3EuuxlN2Vp/ljvzjCPCiaSIGNnOF7yB2xRcc 2w8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zm5BjMiKBzGR5tdPoNSCkWqKn6EKB6unl90NpGd4PRc=; fh=9AEOr0li2JaGGZ8GrLy4PDxyCdJTgwX+YE1VTs0mVmY=; b=k7NgAis/W3MBbZpC61Wl5zjA6xSMZTMYAVQZt4TlRT93nNeUIJb71jYhsfCvbnhT7t BmOKIy2w6VeYZCw2rbYdYpLPZfMN6kM8hDZ9X0GrkdIdOVS7TkLv9/TFY6qQir1MD3ZT pyswQBl/j9q5/7jcOq8SPghsbQ46GyoipISTkKAQk+y32/Rm7k8IroIO5DO22fT56BlB gE/IMt0b8SudJXzZ8prqVy6Vl9hQ6gsvY/TNaqElfDItnGGsufGBggSBriO5T0p44fAY Xjlu+0WADO850+HBNeBwJJZ6m5Kr0Ybm448vowWH4RMwIw1bjnak8zaB38WyADqriq8D 9rLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tp+5ilNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l5-20020a170903120500b001c2218c375esi8098979plh.445.2023.09.12.02.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Sep 2023 02:58:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Tp+5ilNZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (Postfix) with ESMTP id 7986880CBF04; Mon, 11 Sep 2023 22:03:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbjILFDc (ORCPT + 99 others); Tue, 12 Sep 2023 01:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbjILFDF (ORCPT ); Tue, 12 Sep 2023 01:03:05 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DB08211D; Mon, 11 Sep 2023 22:02:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694494976; x=1726030976; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=I60HdwBlPxOrrglt4IdST/dJqZyEc8Pl4UhQ06LR5y0=; b=Tp+5ilNZBiZsSO5pnue/F1RUjdbSU6zV0Zzh/9SwdM4sH4MtirlFPxXo 1sFHe14GILKeE5eQS55GK2gPlwjM6H7YKDuxhi5sQVe/fayaI5xrOvewj 1vG7xxL+/wDj/5djgAvIfLd2YOZ3tg3oioZH5fboEPOUE2vUUD9PMMTSP MGSL42Z5xltA9OEUnrYESzt4y2Sgu7fz8rvFTx0T431XurmAGPBOjIkqE jiHD+kHqMZ4Lab/wDNn4ie1BQ9aH5LVbfxkauMCAGSA9ZfVgvrKmXSabU /8t8Aof8SGMZwXM2i2T9+3OTfID7eCyvizEHBcFc7hpVPTwcNWrCpc1FX g==; X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="357712280" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="357712280" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2023 22:02:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10830"; a="746723219" X-IronPort-AV: E=Sophos;i="6.02,245,1688454000"; d="scan'208";a="746723219" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 11 Sep 2023 22:02:53 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 4E1C5248; Tue, 12 Sep 2023 08:02:52 +0300 (EEST) Date: Tue, 12 Sep 2023 08:02:52 +0300 From: Mika Westerberg To: Stephen Boyd Cc: Hans de Goede , Mark Gross , linux-kernel@vger.kernel.org, patches@lists.linux.dev, platform-driver-x86@vger.kernel.org, Andy Shevchenko , Kuppuswamy Sathyanarayanan , Prashant Malani Subject: Re: [PATCH v3 1/4] platform/x86: intel_scu_ipc: Check status after timeout in busy_loop() Message-ID: <20230912050252.GD1599918@black.fi.intel.com> References: <20230911193937.302552-1-swboyd@chromium.org> <20230911193937.302552-2-swboyd@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230911193937.302552-2-swboyd@chromium.org> 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 (lipwig.vger.email [0.0.0.0]); Mon, 11 Sep 2023 22:03:31 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email On Mon, Sep 11, 2023 at 12:39:33PM -0700, 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 Reviewed-by: Mika Westerberg