From patchwork Mon Nov 24 14:33:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emmanuel Grumbach X-Patchwork-Id: 5367761 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 32BCFC11AC for ; Mon, 24 Nov 2014 14:44:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F8122041D for ; Mon, 24 Nov 2014 14:44:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 71194203F3 for ; Mon, 24 Nov 2014 14:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754162AbaKXOof (ORCPT ); Mon, 24 Nov 2014 09:44:35 -0500 Received: from mail-wi0-f173.google.com ([209.85.212.173]:52517 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752202AbaKXOfS (ORCPT ); Mon, 24 Nov 2014 09:35:18 -0500 Received: by mail-wi0-f173.google.com with SMTP id r20so5861229wiv.6 for ; Mon, 24 Nov 2014 06:35:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C5d1RCjQvzUkuA/ob1pN4FMW5jPniY1FLS15Xaa9FPs=; b=DhyAz5V+SJvHxe7l82/ZPDxBQaMIJs7Swsqxdkvrata/zE3r+V9nb/Cts5zekv6BpE We3ZenwR+denITdn3xrbcXCJzv6doYXBDyhhoY4aEdGmiStRJUsMM2SYgpyo3rNfdxZ1 IJ9yQW0zYhyfIJkVcFqM2OOWzUqzFW1aj2SE/QKheE5gKiPN5nfU1aTzfGinTLDlcp+L xwkYjeYZ2K45bkLOLRrNt9QRofPEFqB+PmLOluDdZqgI5WlgThOBIPWVnpCY97RDR3sT xgzFBv7LjkUYH4l6Ykr6MGKS/wZIKABcrO+ZSBE/cixsKUfkqucHYg8VRTHQaUcSpmFB wHCA== X-Received: by 10.180.107.193 with SMTP id he1mr21755364wib.27.1416839717244; Mon, 24 Nov 2014 06:35:17 -0800 (PST) Received: from localhost.localdomain (46-116-150-134.bb.netvision.net.il. [46.116.150.134]) by mx.google.com with ESMTPSA id n3sm21274744wjz.21.2014.11.24.06.35.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Nov 2014 06:35:16 -0800 (PST) From: Emmanuel Grumbach To: linux-wireless@vger.kernel.org Cc: Emmanuel Grumbach Subject: [PATCH 14/75] iwlwifi: pcie: introduce delay when waking up the device Date: Mon, 24 Nov 2014 16:33:50 +0200 Message-Id: <1416839691-28533-14-git-send-email-egrumbach@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Emmanuel Grumbach In some rare cases, the firmware can put the device to sleep after the driver requested the access. This is because the access request can take a short time to be propagated to the firmware. If that happens, the driver may think that it has access since the firmware hasn't put the device to sleep yet, but right after the driver's check, the firmware might put the device to sleep. Warn when this happens by allowing the firmware to finish the "put the device sleep" flow so that the driver will not get access to the device. This will make the issue visible. This still doesn't fix the race, but at least it makes it more visible. Signed-off-by: Emmanuel Grumbach --- drivers/net/wireless/iwlwifi/pcie/trans.c | 5 +++++ drivers/net/wireless/iwlwifi/pcie/tx.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c index 40a2906..d872749 100644 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c @@ -1031,6 +1031,9 @@ static int iwl_trans_pcie_d3_resume(struct iwl_trans *trans, iwl_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); iwl_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); + if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) + udelay(2); + ret = iwl_poll_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, @@ -1233,6 +1236,8 @@ static bool iwl_trans_pcie_grab_nic_access(struct iwl_trans *trans, bool silent, /* this bit wakes up the NIC */ __iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) + udelay(2); /* * These bits say the device is running, and should keep running for diff --git a/drivers/net/wireless/iwlwifi/pcie/tx.c b/drivers/net/wireless/iwlwifi/pcie/tx.c index eb8e298..4a4104e 100644 --- a/drivers/net/wireless/iwlwifi/pcie/tx.c +++ b/drivers/net/wireless/iwlwifi/pcie/tx.c @@ -1431,6 +1431,9 @@ static int iwl_pcie_enqueue_hcmd(struct iwl_trans *trans, trans_pcie->cmd_in_flight = true; __iwl_trans_pcie_set_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_MAC_ACCESS_REQ); + if (trans->cfg->device_family == IWL_DEVICE_FAMILY_8000) + udelay(2); + ret = iwl_poll_bit(trans, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_VAL_MAC_ACCESS_EN, (CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY |