From patchwork Mon Apr 13 07:45:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 6206361 Return-Path: X-Original-To: patchwork-ath10k@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 46AF19F54E for ; Mon, 13 Apr 2015 07:47:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 580FE20222 for ; Mon, 13 Apr 2015 07:47:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C0C820265 for ; Mon, 13 Apr 2015 07:47:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YhZ52-0007Ub-Sl; Mon, 13 Apr 2015 07:46:52 +0000 Received: from mail-la0-x22f.google.com ([2a00:1450:4010:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YhZ50-0007R9-7K for ath10k@lists.infradead.org; Mon, 13 Apr 2015 07:46:51 +0000 Received: by layy10 with SMTP id y10so50949593lay.0 for ; Mon, 13 Apr 2015 00:46:24 -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; bh=FE1Czr+Bn8QVqhodxZnTfNLijahY5AavQe5G1wVw990=; b=KfFaZdOefN3NvvJ9LzvLhBkyxnCyxVIvaDXI17mSOhw9DutSTVPrnP1aFSfSqNSI2H 1igt/VeL8UnPH30D00CAO7cyfqP59o+Yd/zudRaIE1VCvNlAnArhMbnmGNSxvtY04VN7 Ja4MwjBoxxxTt28nE2eEZiIWL2nWfOKzd1c14= 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; bh=FE1Czr+Bn8QVqhodxZnTfNLijahY5AavQe5G1wVw990=; b=I/AffwRjFSSkrF7nTX0AkAVdd7DhqDqYMq7AwPQgvQGw2XK0MG4rItiVEpszyqEZeF gs0NaatjJD0pcbNKP+bn4OV/YWPUL7+C3oEtz+t1lsTMa5K6AaY2tw7r8evXO6MzQbFs xubLRR7Wd6ruSk8kJ/LT/YfJ3ux25aljJy31A5JpBS13dfHmOVbae2G0HZN9Nf3ZH2nF EXWz5/u3OTXhf1AkI1GevTI6Jupv8JnIVCZ25ZM+UbK49FngLMip8j1/bdO+R/JPnpMy tsq7rqysv3SDPLmCW1LA8yKMj0WYGVA4cQQdake6Z2Ke4fyvPxcXVWL032Fm7MPOQ+UD c2Bw== X-Gm-Message-State: ALoCoQnQjeenfVTUNaygAhoHnkKgJ2eXsp+mMqm7Yee8r9x1fgbCSys5N9NwZR41BtqhlBqxOrtuuU1cj6AyxemJLhyq27Mjk9tesRm5FIvThb95Ep9i0jzbhpLTIigJ+uX9VvtW09uRNUHF04JZiWQwn4FUryGqMINLkzWoq4v+sNBptrT1Fm3Gzv50Ox6uLucaxH78vv0f X-Received: by 10.152.234.42 with SMTP id ub10mr11998517lac.60.1428911184123; Mon, 13 Apr 2015 00:46:24 -0700 (PDT) Received: from localhost.localdomain (apn-46-215-24-237.dynamic.gprs.plus.pl. [46.215.24.237]) by mx.google.com with ESMTPSA id ba4sm1461123lab.31.2015.04.13.00.46.22 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Apr 2015 00:46:23 -0700 (PDT) From: Janusz Dziedzic To: ath10k@lists.infradead.org Subject: [RFC 1/2] ath10k: refactor ASPM workaround Date: Mon, 13 Apr 2015 09:45:40 +0200 Message-Id: <1428911141-6534-1-git-send-email-janusz.dziedzic@tieto.com> X-Mailer: git-send-email 1.9.1 X-DomainID: tieto.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150413_004650_465991_342A59B9 X-CRM114-Status: GOOD ( 10.89 ) X-Spam-Score: -0.8 (/) Cc: Janusz Dziedzic , linux-wireless@vger.kernel.org X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Disable ASPM only when loading firmware. After that back to BIOS/system ASMP settings. When ASPM is enable by system, this decrease power consumtion. Signed-off-by: Janusz Dziedzic --- drivers/net/wireless/ath/ath10k/pci.c | 17 ++++++++++++----- drivers/net/wireless/ath/ath10k/pci.h | 3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c index 51e3921..9923c09 100644 --- a/drivers/net/wireless/ath/ath10k/pci.c +++ b/drivers/net/wireless/ath/ath10k/pci.c @@ -1227,11 +1227,16 @@ 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); + /* Workaround: Back to BIOS/system settings */ + pcie_capability_write_word(ar_pci->pdev, PCI_EXP_LNKCTL, + ar_pci->link_ctl); + return 0; } @@ -1982,6 +1987,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"); @@ -1992,6 +1998,12 @@ static int ath10k_pci_hif_power_up(struct ath10k *ar) return ret; } + /* Workaround: Disable ASPM */ + 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. * @@ -2515,7 +2527,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); @@ -2549,10 +2560,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 56795ed..a6eafec 100644 --- a/drivers/net/wireless/ath/ath10k/pci.h +++ b/drivers/net/wireless/ath/ath10k/pci.h @@ -185,6 +185,9 @@ struct ath10k_pci { /* Map CE id to ce_state */ struct ath10k_ce_pipe ce_states[CE_COUNT_MAX]; struct timer_list rx_post_retry; + + /* Link Control */ + u16 link_ctl; }; static inline struct ath10k_pci *ath10k_pci_priv(struct ath10k *ar)