From patchwork Mon May 18 09:38:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 6427301 X-Patchwork-Delegate: kvalo@adurom.com 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6AB53C0432 for ; Mon, 18 May 2015 09:38:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 765EE2060C for ; Mon, 18 May 2015 09:38:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 720AF20499 for ; Mon, 18 May 2015 09:38:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752866AbbERJih (ORCPT ); Mon, 18 May 2015 05:38:37 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:33021 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751207AbbERJid (ORCPT ); Mon, 18 May 2015 05:38:33 -0400 Received: by wgjc11 with SMTP id c11so19497479wgj.0 for ; Mon, 18 May 2015 02:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tieto.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qa1Sn5ClRWv1s7YaSQ2LWXGp39G/Sw6PYRyo0cxjk+E=; b=x1jf3hzGhksS6mxv/eUNPcyRUH70P+p6rrL02V1Leb7ofKa7By2jkJeOgjrf3JAg/m dU4bIKZXCuQx7jgQVrbzDi7Dhm5Xi5pBhzAsrV4bK7zJrt5ZUFUkOzBY3y1ioW+tMATx RRTr4klOIZo3MnUJtQu1Qpj6hR6WxbPyGP2gk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qa1Sn5ClRWv1s7YaSQ2LWXGp39G/Sw6PYRyo0cxjk+E=; b=MObXHhuV3+t1h2ImivEc3fFzn/2mX18b18BLYel2FOPLG9CPFGNhXhSrzEjPdrpc8o nzNMBe6ETyTz+4s9PJnRgvHQ/8iA5Z2OYju8EElKQ/7XtlXaqSkTHsseHkAYeg362C4M vqznzZ6qIVJ3s/OEilaOO8m5vprVvGPgmbPu8pY9macFHdbzwUrVIbM8cTA+Sl51mrFE a29+/QbrSlGEV0ldbe3CD4XCRd9lrZIkVQtMnJ2N477KDsSdNSj9Qt3IC8Xu6JuwfbY1 1L2CynQ/Ix3453Shg8WbXIGm+8RIVkW9TAbZnti7yCYSWXrwfhWQMoMaMEXli0MB4B2A fYXQ== X-Gm-Message-State: ALoCoQmHpc90Odk/lDP1qfO9yueC3lDCZYKPev/IPl95JyQ1Zi//TBw3YYgWR3W3UzTYfExx3dtzXjd2kXXk2tIjp1E3n3hLXyJra7q5F5CBd3ESUhUyEO3MppkPMyue8I27NolZVg5L X-Received: by 10.194.82.167 with SMTP id j7mr43033387wjy.123.1431941912762; Mon, 18 May 2015 02:38:32 -0700 (PDT) Received: from localhost.localdomain ([91.198.246.8]) by mx.google.com with ESMTPSA id it5sm11574426wid.3.2015.05.18.02.38.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 May 2015 02:38:32 -0700 (PDT) From: Michal Kazior To: ath10k@lists.infradead.org Cc: linux-wireless@vger.kernel.org, Janusz Dziedzic , Michal Kazior Subject: [PATCH v2 1/3] ath10k: enable ASPM Date: Mon, 18 May 2015 09:38:16 +0000 Message-Id: <1431941898-13591-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1431941898-13591-1-git-send-email-michal.kazior@tieto.com> References: <1431076388-24800-1-git-send-email-michal.kazior@tieto.com> <1431941898-13591-1-git-send-email-michal.kazior@tieto.com> X-DomainID: tieto.com 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_SIGNED, 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: Janusz Dziedzic It is actually safe to enable ASPM after the device is booted up. This reduces power drain of QCA61X4 when driver is simply loaded (no interface is up) from 31mA to 14mA. QCA988X wasn't measured but doesn't seem to regress in any other way. Signed-off-by: Janusz Dziedzic Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/pci.c | 15 ++++++++++----- drivers/net/wireless/ath/ath10k/pci.h | 6 ++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 969a1231800e..8be07c653b2d 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1227,11 +1227,15 @@ static void ath10k_pci_irq_enable(struct ath10k *ar) static int ath10k_pci_hif_start(struct ath10k *ar) { + struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif start\n"); ath10k_pci_irq_enable(ar); ath10k_pci_rx_post(ar); + pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, + ar_pci->link_ctl); + return 0; } @@ -1981,6 +1985,7 @@ static int ath10k_pci_chip_reset(struct ath10k *ar) static int ath10k_pci_hif_power_up(struct ath10k *ar) { + struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); int ret; ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot hif power up\n"); @@ -1991,6 +1996,11 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar) return ret; } + pcie_capability_read_word(ar_pci->pdev, PCI_EXP_LNKCTL, + &ar_pci->link_ctl); + pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, + ar_pci->link_ctl & ~PCI_EXP_LNKCTL_ASPMC); + /* * Bring the target up cleanly. * @@ -2502,7 +2512,6 @@ static int ath10k_pci_claim(struct ath10k *ar) { struct ath10k_pci *ar_pci = ath10k_pci_priv(ar); struct pci_dev *pdev = ar_pci->pdev; - u32 lcr_val; int ret; pci_set_drvdata(pdev, ar); @@ -2536,10 +2545,6 @@ static int ath10k_pci_claim(struct ath10k *ar) pci_set_master(pdev); - /* Workaround: Disable ASPM */ - pci_read_config_dword(pdev, 0x80, &lcr_val); - pci_write_config_dword(pdev, 0x80, (lcr_val & 0xffffff00)); - /* Arrange for access to Target SoC registers. */ ar_pci->mem = pci_iomap(pdev, BAR_NUM, 0); if (!ar_pci->mem) { diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h index bddf54320160..ee2173d61257 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h @@ -185,6 +185,12 @@ struct ath10k_pci { /* Map CE id to ce_state */ struct ath10k_ce_pipe ce_states[CE_COUNT_MAX]; struct timer_list rx_post_retry; + + /* Due to HW quirks it is recommended to disable ASPM during device + * bootup. To do that the original PCI-E Link Control is stored before + * device bootup is executed and re-programmed later. + */ + u16 link_ctl; }; static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)