Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp670274pxb; Thu, 30 Sep 2021 14:36:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmiAiah+Oin4Cllbh2H7LGe/66E9wlUoLMC672n+zqa2Yh2F6JGXsnkVY/Rg7welVVqoVG X-Received: by 2002:a05:6402:181a:: with SMTP id g26mr3157750edy.54.1633037783828; Thu, 30 Sep 2021 14:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633037783; cv=none; d=google.com; s=arc-20160816; b=qKYFLmthbIA7KyVHvYCL9SCxl7B7EwNumwQY8n3JQ3kEc/kWZHRVEdggKsJrzqWXCT 225F7K7K/Wm+9OZ2aQw5CzIFIBcrsSQIgsEtaK5J+oWFK7ud5OuZ64qsqsEH9yMTQH8M o8aVqnZ8+c5B6uKL7v6ExY+kkyzlP0Wai/F0px1FgZwCzbxcvZITXAH74Tz5wbvqCjxb S4s/OllWXGr+GCg+QNDQYNK1CSZENSKfoRAn9HrdWBY/U/q4WB93306rll7nUWLISE6b G0NT093T5BBrIeeB4H7fkT11OqkVCRmF9dkjCN2v4u8Wk/KvAGY0MvWJpKQ03AmFmTuP EALg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=q7RZ9GkLkLjv+AxK5uN6EmGjKn7+hiIWylm7X0XLaXE=; b=EX1vpn67Vxp+wKen6JguygOiIuobcaWzc5SI7pyIXkdp5PGKCQ0w4Qu5yKFt2PNvq/ tO+k6pg5sMMqPpUjxTElu6VJJt1fpnvljlR/P22py8I/qHgUA4vRmloENohZnU+s6clr SaVBp6+5YY9VNAqHjwQcFU71wDvAyGNSUwPRlHPMnq+sBeueOa/TrQdw54/IHFgkreQm Vm0EflhMdr93iez5UYxCzKM6+qV+UMnRc3GPm3QKcDTr7yGFOiemKYP3SuLwm4hmYSw9 2HTnIA/g6+gA2wuWeqvSUr2XevM7jchvIYjM2pKJEZhu1MQm92P+6uQ82By2lRRDk1s2 ncLQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p6si2685695ejm.180.2021.09.30.14.35.56; Thu, 30 Sep 2021 14:36:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348488AbhI3VAc (ORCPT + 78 others); Thu, 30 Sep 2021 17:00:32 -0400 Received: from mga05.intel.com ([192.55.52.43]:22707 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229957AbhI3VAb (ORCPT ); Thu, 30 Sep 2021 17:00:31 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10123"; a="310832977" X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="310832977" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 13:58:47 -0700 X-IronPort-AV: E=Sophos;i="5.85,336,1624345200"; d="scan'208";a="618437339" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Sep 2021 13:58:43 -0700 Received: from andy by smile with local (Exim 4.95-RC2) (envelope-from ) id 1mW38Z-007Fx0-P6; Thu, 30 Sep 2021 23:58:39 +0300 Date: Thu, 30 Sep 2021 23:58:39 +0300 From: Andy Shevchenko To: Jonas =?iso-8859-1?Q?Dre=DFler?= Cc: Amitkumar Karwar , Ganapathi Bhat , Xinming Hu , Kalle Valo , "David S. Miller" , Jakub Kicinski , Tsuchiya Yuto , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Maximilian Luz , Bjorn Helgaas , Pali =?iso-8859-1?Q?Roh=E1r?= , Heiner Kallweit , Johannes Berg , Brian Norris , stable@vger.kernel.org Subject: Re: [PATCH v2 2/2] mwifiex: Try waking the firmware until we get an interrupt Message-ID: References: <20210914114813.15404-1-verdre@v0yd.nl> <20210914114813.15404-3-verdre@v0yd.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Thu, Sep 30, 2021 at 08:04:00PM +0200, Jonas Dre?ler wrote: > On 9/22/21 1:19 PM, Andy Shevchenko wrote: > > On Tue, Sep 14, 2021 at 01:48:13PM +0200, Jonas Dre?ler wrote: ... > > > + do { > > > + if (mwifiex_write_reg(adapter, reg->fw_status, FIRMWARE_READY_PCIE)) { > > > + mwifiex_dbg(adapter, ERROR, > > > + "Writing fw_status register failed\n"); > > > + return -EIO; > > > + } > > > + > > > + n_tries++; > > > + > > > + if (n_tries <= N_WAKEUP_TRIES_SHORT_INTERVAL) > > > + usleep_range(400, 700); > > > + else > > > + msleep(10); > > > + } while (n_tries <= N_WAKEUP_TRIES_SHORT_INTERVAL + N_WAKEUP_TRIES_LONG_INTERVAL && > > > + READ_ONCE(adapter->int_status) == 0); > > > > Can't you use read_poll_timeout() twice instead of this custom approach? > > I've tried this now, but read_poll_timeout() is not ideal for our use-case. > What we'd need would be read->sleep->poll->repeat instead of > read->poll->sleep->repeat. With read_poll_timeout() we always end up doing > one more (unnecessary) write. First of all, there is a parameter to get sleep beforehand. Second, what is the problem with having one write more or less? Your current code doesn't guarantee this either. It only decreases probability of such scenario. Am I wrong? -- With Best Regards, Andy Shevchenko