From patchwork Sat Oct 13 00:55:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10639793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E11683CF1 for ; Sat, 13 Oct 2018 00:55:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDF3E2B719 for ; Sat, 13 Oct 2018 00:55:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D15352B72D; Sat, 13 Oct 2018 00:55:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5DE2D2B71D for ; Sat, 13 Oct 2018 00:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=gqEv0MQMYmHFvWKF24+b48T7Gn8NfS+MSjSeRN0XDmM=; b=GjK37BnI/uIET7 vOEe2/BEdC2s7BsbL8EFLbBtW6NwMNDsbsxp8zejXOHBB3v2pp5hE67tDu5wlayLazTKqqUNu5YxW Gym/qjqkyhDTnXtM9lBxgK9R/3M3MJULi7Hv7P1SGaZ4tjXEw2KKg4/xaKFSZMvcJE7RbJaPxnI4D TTC9Tt9Ga4bCyOF9/xOaDRLoLB0kL/PDOqbabGVqPz2HpySI2E4kwwtS/shfE8zX6n37J6WMkyGgL akZW7LbLn7HPpzaOSY3Jgg1MVGvcXBG+ITl14fnfIVMQBqvnOvyh41z6CaBZ3YHgpcvcePYt+1Ezr mtU+ifrS19MoDZ/HV5Ng==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8DX-0001Re-Lr; Sat, 13 Oct 2018 00:55:43 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8DU-0001LO-Fm for ath10k@lists.infradead.org; Sat, 13 Oct 2018 00:55:42 +0000 Received: by mail-pf1-x441.google.com with SMTP id f29-v6so6987076pff.5 for ; Fri, 12 Oct 2018 17:55:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KhatUidEATM1dyEWadH/V2c3Hdep3l08021kxRdjpjQ=; b=AMreK8x/2VIp0PScOGFiVbRdb3ntCFc422TRdQCZ9nXxj68RwHn0hDzZ6p2NmF7mN2 oxI2gqHK5ek4UozFaNfjocC77eJZ/3YlxeJ5UZfReuPCl7NeeTgV+gUarI3X85jpHUE0 h9EchBlvybovGflTL9AF8mYZJxiZgrL7HoZ80= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=KhatUidEATM1dyEWadH/V2c3Hdep3l08021kxRdjpjQ=; b=dAbKs3SPiQIlSt+I3vkPiUpoDSb6Jqn3kFoyN2KXtMstPSq5T7+mZVvW75l4azu3o1 X/6kh2ckStymkzTRHc3j1tODzjjulYaznlctvgJWAjjzN6XfWZCyMQ0+WZK9J/osbGzL LY+NsE5Ao3qyOn9abuGwdvwArCLftEvLvWC5yCLjxzWi3/fioajmpFdNq3qtKWn+Sxf/ XIx/mmUVi0A7xPasA4pmSWSQiUrLw0ELFjjzFf/2k0vuF8bic2uJkpzB9N9q1fvW1AIR +Uo8o+uRK4iSxkWSV8vohydfClVkyO/wrncjmTma61Atk+8saJvPkt2QUYD1JOzxHW+t nJDg== X-Gm-Message-State: ABuFfoiVXmxikf+svRVt4usVdRT5rmMQMhB2guhUPkWE+5TpmUKxYQ8i EETyW5dGOx/OJ4HLa4OSnmpAUw== X-Google-Smtp-Source: ACcGV6318p75321C6lU7pfqQUG8yiKK/ZQ4cliRSbYOhal1cfKuYCTB51x1HtCsdyf7OKSOJVuTACA== X-Received: by 2002:a62:64d5:: with SMTP id y204-v6mr8228333pfb.187.1539392128884; Fri, 12 Oct 2018 17:55:28 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id n7-v6sm2766183pgv.63.2018.10.12.17.55.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:55:27 -0700 (PDT) From: Brian Norris To: Kalle Valo Subject: [PATCH 1/4] ath10k: snoc: remove 'wcn3990' from generic resource handling Date: Fri, 12 Oct 2018 17:55:01 -0700 Message-Id: <20181013005504.46399-1-briannorris@chromium.org> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_175540_532659_C0F1EAED X-CRM114-Status: GOOD ( 11.15 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Govind Singh , Brian Norris , linux-wireless@vger.kernel.org, Doug Anderson , ath10k@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP ath10k_wcn3990_clk_info and ath10k_wcn3990_vreg_info are not WCN3990-specific structures. They hold generic data. So don't name them with wcn3990 specifics. Signed-off-by: Brian Norris Reviewed-by: Douglas Anderson --- drivers/net/wireless/ath/ath10k/snoc.c | 34 +++++++++++++------------- drivers/net/wireless/ath/ath10k/snoc.h | 8 +++--- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 8d3d9bca410f..c6254db17dab 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -46,14 +46,14 @@ static char *const ce_name[] = { "WLAN_CE_11", }; -static struct ath10k_wcn3990_vreg_info vreg_cfg[] = { +static struct ath10k_vreg_info vreg_cfg[] = { {NULL, "vdd-0.8-cx-mx", 800000, 800000, 0, 0, false}, {NULL, "vdd-1.8-xo", 1800000, 1800000, 0, 0, false}, {NULL, "vdd-1.3-rfa", 1304000, 1304000, 0, 0, false}, {NULL, "vdd-3.3-ch0", 3312000, 3312000, 0, 0, false}, }; -static struct ath10k_wcn3990_clk_info clk_cfg[] = { +static struct ath10k_clk_info clk_cfg[] = { {NULL, "cxo_ref_clk_pin", 0, false}, }; @@ -1246,7 +1246,7 @@ static void ath10k_snoc_release_resource(struct ath10k *ar) } static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev, - struct ath10k_wcn3990_vreg_info *vreg_info) + struct ath10k_vreg_info *vreg_info) { struct regulator *reg; int ret = 0; @@ -1284,7 +1284,7 @@ static int ath10k_get_vreg_info(struct ath10k *ar, struct device *dev, } static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, - struct ath10k_wcn3990_clk_info *clk_info) + struct ath10k_clk_info *clk_info) { struct clk *handle; int ret = 0; @@ -1311,10 +1311,10 @@ static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, return ret; } -static int ath10k_wcn3990_vreg_on(struct ath10k *ar) +static int ath10k_snoc_vreg_on(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_wcn3990_vreg_info *vreg_info; + struct ath10k_vreg_info *vreg_info; int ret = 0; int i; @@ -1376,10 +1376,10 @@ static int ath10k_wcn3990_vreg_on(struct ath10k *ar) return ret; } -static int ath10k_wcn3990_vreg_off(struct ath10k *ar) +static int ath10k_snoc_vreg_off(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_wcn3990_vreg_info *vreg_info; + struct ath10k_vreg_info *vreg_info; int ret = 0; int i; @@ -1412,10 +1412,10 @@ static int ath10k_wcn3990_vreg_off(struct ath10k *ar) return ret; } -static int ath10k_wcn3990_clk_init(struct ath10k *ar) +static int ath10k_snoc_clk_init(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_wcn3990_clk_info *clk_info; + struct ath10k_clk_info *clk_info; int ret = 0; int i; @@ -1461,10 +1461,10 @@ static int ath10k_wcn3990_clk_init(struct ath10k *ar) return ret; } -static int ath10k_wcn3990_clk_deinit(struct ath10k *ar) +static int ath10k_snoc_clk_deinit(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); - struct ath10k_wcn3990_clk_info *clk_info; + struct ath10k_clk_info *clk_info; int i; for (i = 0; i < ARRAY_SIZE(clk_cfg); i++) { @@ -1488,18 +1488,18 @@ static int ath10k_hw_power_on(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power on\n"); - ret = ath10k_wcn3990_vreg_on(ar); + ret = ath10k_snoc_vreg_on(ar); if (ret) return ret; - ret = ath10k_wcn3990_clk_init(ar); + ret = ath10k_snoc_clk_init(ar); if (ret) goto vreg_off; return ret; vreg_off: - ath10k_wcn3990_vreg_off(ar); + ath10k_snoc_vreg_off(ar); return ret; } @@ -1509,9 +1509,9 @@ static int ath10k_hw_power_off(struct ath10k *ar) ath10k_dbg(ar, ATH10K_DBG_SNOC, "soc power off\n"); - ath10k_wcn3990_clk_deinit(ar); + ath10k_snoc_clk_deinit(ar); - ret = ath10k_wcn3990_vreg_off(ar); + ret = ath10k_snoc_vreg_off(ar); return ret; } diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h index e1d2d6675556..4a3837b5c68d 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.h +++ b/drivers/net/wireless/ath/ath10k/snoc.h @@ -53,7 +53,7 @@ struct ath10k_snoc_ce_irq { u32 irq_line; }; -struct ath10k_wcn3990_vreg_info { +struct ath10k_vreg_info { struct regulator *reg; const char *name; u32 min_v; @@ -63,7 +63,7 @@ struct ath10k_wcn3990_vreg_info { bool required; }; -struct ath10k_wcn3990_clk_info { +struct ath10k_clk_info { struct clk *handle; const char *name; u32 freq; @@ -81,8 +81,8 @@ struct ath10k_snoc { struct ath10k_snoc_ce_irq ce_irqs[CE_COUNT_MAX]; struct ath10k_ce ce; struct timer_list rx_post_retry; - struct ath10k_wcn3990_vreg_info *vreg; - struct ath10k_wcn3990_clk_info *clk; + struct ath10k_vreg_info *vreg; + struct ath10k_clk_info *clk; struct ath10k_qmi *qmi; }; From patchwork Sat Oct 13 00:55:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10639797 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C698F17E1 for ; Sat, 13 Oct 2018 00:55:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1DD02B719 for ; Sat, 13 Oct 2018 00:55:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B65472B72D; Sat, 13 Oct 2018 00:55:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 51E102B719 for ; Sat, 13 Oct 2018 00:55:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ddLf60qbio81USENCZ/sC+Y9YjqXbN03msEHBEdbFRY=; b=tSLCLHDes97z+R aiIylZNL8UOZwhxzEARST+Fh7rk9T6nsp1AmruZNnCJOKS4UjtCKlVkxRdkwquIKBvqeuiVDF+L8C XfspDHlzESRcUXWw2nKqhF2PRnI2UxCwgajygNaig+T87yN/7D4+w1jLWh7N/QTrv3Eu6rtRAuGEh RX272JLFUpQxB93CZmEzg45D7dXurMAcVxjM2QRCJ8jGjo/h6Z5At2TdkcH+YJeYfTmx6lMG199ko mhW6K1oT91/OM8Gl4ZBa38DcIQda/nAl2v5ACZdCs8lVBuEAGAPSJWE6eOnNhs0H4I18+Te5XnJAf GrHGBJ6Rv9kt6RoAHwCg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8Dc-0001UH-7b; Sat, 13 Oct 2018 00:55:48 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8DV-0001LQ-8M for ath10k@lists.infradead.org; Sat, 13 Oct 2018 00:55:42 +0000 Received: by mail-pl1-x642.google.com with SMTP id f8-v6so6668573plb.2 for ; Fri, 12 Oct 2018 17:55:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kMecC22tuMOwvBh+xSlzoJFNRLm0nG22sbs6lAw+ewo=; b=C5mQ9wjmgpiFwjZY0INecveyEkAHIL7RF9rCfl3sFtmaLr9EIIZguHynKdfoKZLllp qHCr0Hp3ZKl1Ace7P4l5jSZc8NJrUawFM4vIinEfEMtb8Rm7DUpCyzdBuk2DoDu7jm3K O7g1O6A2+Sg7YAIqnYY1H2Xfpy2DvdGB/yUBk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kMecC22tuMOwvBh+xSlzoJFNRLm0nG22sbs6lAw+ewo=; b=QXFPUN79NFlbmp6D5Pq20uxkFEzR8kmq9rBQEcWgdgkPp+/gxQe+78sSb/kHsU/XlZ ACbyOdDd+9VKOMw0r2i4CpGCOCHBx4ZyF7RDmjv8dh2M7zgdJUDcUZX+mmB432+d0jjt RjMNyU5zHHfYTR4UcDnTEq9mUCbb9UH11CO/6iBIDSi2iYbDEN1I7U23SB5jTqSyvggP nW3BsiFTZddJK22lboJ5CaRIfXWsFfMz4iEgBlCybbPTOw84ksFjTVJCU43U93FbtXR2 IrcJbT7SyNlxyhxahOE/k0oaFX8J0Ebi3Q71dJ+suFHOermPwEOer7H3oWg7pxBKu9+g tIMA== X-Gm-Message-State: ABuFfohi8E7GR2sPB+JiU5/b21/WdfghUwFK0W1zz2K+gu2waJbgnmyC SwwLSCMXunjTlJjA9ziDRPNcHw== X-Google-Smtp-Source: ACcGV60zinOTiLbqMDbgskmYskxGFYjBAV7mYupSuC7iM9NDHyEm1DX2/dOAjMEO+EwJS3BQfVDOPg== X-Received: by 2002:a17:902:ba95:: with SMTP id k21-v6mr8022699pls.38.1539392130480; Fri, 12 Oct 2018 17:55:30 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id n7-v6sm2766183pgv.63.2018.10.12.17.55.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:55:29 -0700 (PDT) From: Brian Norris To: Kalle Valo Subject: [PATCH 2/4] ath10k: snoc: fix unabalanced regulator error handling Date: Fri, 12 Oct 2018 17:55:02 -0700 Message-Id: <20181013005504.46399-2-briannorris@chromium.org> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog In-Reply-To: <20181013005504.46399-1-briannorris@chromium.org> References: <20181013005504.46399-1-briannorris@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_175541_308920_ED7B13AB X-CRM114-Status: GOOD ( 15.48 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Govind Singh , Brian Norris , linux-wireless@vger.kernel.org, Doug Anderson , ath10k@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If a regulator fails to set its voltage, we end up with an unbalanced call to regulator_disable(), because the error path starts with the current regulator (which was never enabled). Factor out the "on" function to perform (and unwind if failed) a single regulator at a time, and then main loop (ath10k_snoc_vreg_on()) can just worry about unwinding the regulators that were already enabled. It also helps to factor out the "off" function, to avoid repeating some code here. Signed-off-by: Brian Norris Reviewed-by: Douglas Anderson --- drivers/net/wireless/ath/ath10k/snoc.c | 129 ++++++++++++++----------- 1 file changed, 75 insertions(+), 54 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index c6254db17dab..b63ae8b006b4 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1311,6 +1311,76 @@ static int ath10k_get_clk_info(struct ath10k *ar, struct device *dev, return ret; } +static int __ath10k_snoc_vreg_on(struct ath10k *ar, + struct ath10k_vreg_info *vreg_info) +{ + int ret; + + ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being enabled\n", + vreg_info->name); + + ret = regulator_set_voltage(vreg_info->reg, vreg_info->min_v, + vreg_info->max_v); + if (ret) { + ath10k_err(ar, + "failed to set regulator %s voltage-min: %d voltage-max: %d\n", + vreg_info->name, vreg_info->min_v, vreg_info->max_v); + return ret; + } + + if (vreg_info->load_ua) { + ret = regulator_set_load(vreg_info->reg, vreg_info->load_ua); + if (ret < 0) { + ath10k_err(ar, "failed to set regulator %s load: %d\n", + vreg_info->name, vreg_info->load_ua); + goto err_set_load; + } + } + + ret = regulator_enable(vreg_info->reg); + if (ret) { + ath10k_err(ar, "failed to enable regulator %s\n", + vreg_info->name); + goto err_enable; + } + + if (vreg_info->settle_delay) + udelay(vreg_info->settle_delay); + + return 0; + +err_enable: + regulator_set_load(vreg_info->reg, 0); +err_set_load: + regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v); + + return ret; +} + +static int __ath10k_snoc_vreg_off(struct ath10k *ar, + struct ath10k_vreg_info *vreg_info) +{ + int ret; + + ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being disabled\n", + vreg_info->name); + + ret = regulator_disable(vreg_info->reg); + if (ret) + ath10k_err(ar, "failed to disable regulator %s\n", + vreg_info->name); + + ret = regulator_set_load(vreg_info->reg, 0); + if (ret < 0) + ath10k_err(ar, "failed to set load %s\n", vreg_info->name); + + ret = regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v); + if (ret) + ath10k_err(ar, "failed to set voltage %s\n", vreg_info->name); + + return ret; +} + static int ath10k_snoc_vreg_on(struct ath10k *ar) { struct ath10k_snoc *ar_snoc = ath10k_snoc_priv(ar); @@ -1324,53 +1394,21 @@ static int ath10k_snoc_vreg_on(struct ath10k *ar) if (!vreg_info->reg) continue; - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being enabled\n", - vreg_info->name); - - ret = regulator_set_voltage(vreg_info->reg, vreg_info->min_v, - vreg_info->max_v); - if (ret) { - ath10k_err(ar, - "failed to set regulator %s voltage-min: %d voltage-max: %d\n", - vreg_info->name, vreg_info->min_v, vreg_info->max_v); - goto err_reg_config; - } - - if (vreg_info->load_ua) { - ret = regulator_set_load(vreg_info->reg, - vreg_info->load_ua); - if (ret < 0) { - ath10k_err(ar, - "failed to set regulator %s load: %d\n", - vreg_info->name, - vreg_info->load_ua); - goto err_reg_config; - } - } - - ret = regulator_enable(vreg_info->reg); - if (ret) { - ath10k_err(ar, "failed to enable regulator %s\n", - vreg_info->name); + ret = __ath10k_snoc_vreg_on(ar, vreg_info); + if (ret) goto err_reg_config; - } - - if (vreg_info->settle_delay) - udelay(vreg_info->settle_delay); } return 0; err_reg_config: - for (; i >= 0; i--) { + for (i = i - 1; i >= 0; i--) { vreg_info = &ar_snoc->vreg[i]; if (!vreg_info->reg) continue; - regulator_disable(vreg_info->reg); - regulator_set_load(vreg_info->reg, 0); - regulator_set_voltage(vreg_info->reg, 0, vreg_info->max_v); + __ath10k_snoc_vreg_off(ar, vreg_info); } return ret; @@ -1389,24 +1427,7 @@ static int ath10k_snoc_vreg_off(struct ath10k *ar) if (!vreg_info->reg) continue; - ath10k_dbg(ar, ATH10K_DBG_SNOC, "snoc regulator %s being disabled\n", - vreg_info->name); - - ret = regulator_disable(vreg_info->reg); - if (ret) - ath10k_err(ar, "failed to disable regulator %s\n", - vreg_info->name); - - ret = regulator_set_load(vreg_info->reg, 0); - if (ret < 0) - ath10k_err(ar, "failed to set load %s\n", - vreg_info->name); - - ret = regulator_set_voltage(vreg_info->reg, 0, - vreg_info->max_v); - if (ret) - ath10k_err(ar, "failed to set voltage %s\n", - vreg_info->name); + ret = __ath10k_snoc_vreg_off(ar, vreg_info); } return ret; From patchwork Sat Oct 13 00:55:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10639799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E31917E1 for ; Sat, 13 Oct 2018 00:56:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AF0F2B719 for ; Sat, 13 Oct 2018 00:56:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F21E2B72D; Sat, 13 Oct 2018 00:56:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B5BFB2B719 for ; Sat, 13 Oct 2018 00:56:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TAgavtc8UIr9PDd5mkgXm0TVXZcdUKCPzoEQwUPxOGM=; b=tIjVbjyO0jukNA 1pn+mgiK9ZV20rUZObpjcArOnprgA9hR29MwOWLGjFtvGkbGSwumTYFwreyf/LDlwxqF9VsToPO6P nBTKiVrP6jFMukKBCdIzRxfS7oQMmH2K0E4xBQjzQFLwj0x2XuUqAMVqqVEevFVsng6CrXec5sozm 4TdhP820mkCFOAevM4oVcfvdyPPzymtMbQJh3rn+ysckEu8gJmZ2PtGIq5gG1jqVsEHnnJWM6zACL SvlVLGHgCZsrtuG/cGZhhJOmOWoNUKkAgj2hCtBSNdoBYisAR4iUKv1es9W/H9cYSk0JAzxeoy/v6 dZ3qcxz6VkPK/+Cp0bFQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8Dm-0001ZQ-OT; Sat, 13 Oct 2018 00:55:58 +0000 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8DX-0001Lc-DG for ath10k@lists.infradead.org; Sat, 13 Oct 2018 00:55:47 +0000 Received: by mail-pg1-x542.google.com with SMTP id f8-v6so6573084pgq.5 for ; Fri, 12 Oct 2018 17:55:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tOvjbpyRsbuPWsomBHKEhFntlFsBYkZHEyyX+xGS5QQ=; b=AdljiIzyMDquZb9pCUfNyYhk9HK9POSax2bqMyH/NirH0WQ812CNVR4RN0PblLrfQK USVSnza1jgclk+GiOWBJH5hcTuIlPKApATf+zRWW29ZAEs3PxYaeTr7oO7Sa3+NYASe9 ztWFMuXVp9fKKcaLxyP2YfzFmVN6uqUAMjEQI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tOvjbpyRsbuPWsomBHKEhFntlFsBYkZHEyyX+xGS5QQ=; b=NloFv+zO58l7PxzCMwmtaGFBYziEPjZqosR0H4ZygR/tOxuc8oS12UUNG5BsOQoEQx Qp2aa7GxQCOVjFRgclFStyGUs/iRR9KnJq6e1otpjwLWY138AkbpIWrtC3rSrU7XaegB nylCRLkB9+amlVP/AvUM/mgIPC/gXUAB2snGzXWL84OKKmWOpNQwEeWoP83059tTssjz 4ev/49lPbES74uN2NCBIJ4VS6OeSFX877nl0TjoTZKX+/ly96k9DQGuoczLi7xD5Liva REKX4abLDKrXch+lglCWAfWO9O9hTh40nRqD+H6LC4ES5tCNqQN564gVcX5et61aHOrH kBfg== X-Gm-Message-State: ABuFfoggiL9bqIL65LQ8CwIKI3vOhjTxutWiL51LWqpNl0tvp0REQiNS Pa8PfFgQLEQ23LjPNrErAf2PlA== X-Google-Smtp-Source: ACcGV636T8rgHZXKPx3yLm7H8V4lIl+E7W0FvbdhAc1M7wUaDYMi66v7SX/QXmMKjKDUf7xopXFazQ== X-Received: by 2002:a62:b09:: with SMTP id t9-v6mr8341927pfi.36.1539392132798; Fri, 12 Oct 2018 17:55:32 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id n7-v6sm2766183pgv.63.2018.10.12.17.55.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:55:31 -0700 (PDT) From: Brian Norris To: Kalle Valo Subject: [PATCH 3/4] ath10k: snoc: relax voltage requirements Date: Fri, 12 Oct 2018 17:55:03 -0700 Message-Id: <20181013005504.46399-3-briannorris@chromium.org> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog In-Reply-To: <20181013005504.46399-1-briannorris@chromium.org> References: <20181013005504.46399-1-briannorris@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_175543_447725_6CAB5177 X-CRM114-Status: UNSURE ( 9.88 ) X-CRM114-Notice: Please train this message. X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Govind Singh , Brian Norris , linux-wireless@vger.kernel.org, Doug Anderson , ath10k@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP I rarely see drivers specify precise voltage requirements like this, but if we really have to...let's at least give a little wiggle room. Board designs (and accompanying device trees) may not provide exactly the voltage listed here, and we shouldn't fail to probe just because of this. Round these ranges down to the nearest volt, and provide a 0.05V margin. The regulator should provide its own supported ranges, which will helpfully intersect with these ranges. I would just as well remove these ranges entirely, but if I understand correctly, there's some reason that QCOM SoC's like to set zero / non-zero voltages. Signed-off-by: Brian Norris Reviewed-by: Douglas Anderson --- drivers/net/wireless/ath/ath10k/snoc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index b63ae8b006b4..5a8e87339df2 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -47,10 +47,10 @@ static char *const ce_name[] = { }; static struct ath10k_vreg_info vreg_cfg[] = { - {NULL, "vdd-0.8-cx-mx", 800000, 800000, 0, 0, false}, - {NULL, "vdd-1.8-xo", 1800000, 1800000, 0, 0, false}, - {NULL, "vdd-1.3-rfa", 1304000, 1304000, 0, 0, false}, - {NULL, "vdd-3.3-ch0", 3312000, 3312000, 0, 0, false}, + {NULL, "vdd-0.8-cx-mx", 800000, 850000, 0, 0, false}, + {NULL, "vdd-1.8-xo", 1800000, 1850000, 0, 0, false}, + {NULL, "vdd-1.3-rfa", 1300000, 1350000, 0, 0, false}, + {NULL, "vdd-3.3-ch0", 3300000, 3350000, 0, 0, false}, }; static struct ath10k_clk_info clk_cfg[] = { From patchwork Sat Oct 13 00:55:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 10639801 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 015D614BD for ; Sat, 13 Oct 2018 00:56:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0BA42B719 for ; Sat, 13 Oct 2018 00:56:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E54B72B72D; Sat, 13 Oct 2018 00:56:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB32D2B719 for ; Sat, 13 Oct 2018 00:56:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Xr0ZvL+U3r5i2Yekxyc4t6lqz+XuT+gPiwHan9IsN88=; b=Ialwh8ohTQttKN GQro5ih0dLYPPLSbrUmGE0JLXqlknaTkVHyEfBttgvactE/YwK9UBJE6SQURHMC66qPuh+S6KHL8l EJLtUyg6erY20/XZrojI8ldnO5/miFO+acIkpUKU2USC+fdQkPriQqFQ4NZHCg+VfFMR2/+eTcUCQ 4v1gVYvQw6LOPqBXm6vCPDUCG2tdKyiWEaf36KD8qDN5AQjiuCsVmw4n2/nWKDZpY74sI6sOS950c kx2ziuPjar7z8dKxKT/j4xu3Nb6ddJhnktJbX6LHlTI3C8XsTYD8mfzQppjaGgU6QIbcjKfkWkclX V+VoQ4cgHhNhvTNbSK9A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8Dw-0001eo-MJ; Sat, 13 Oct 2018 00:56:08 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gB8DY-0001Lz-PN for ath10k@lists.infradead.org; Sat, 13 Oct 2018 00:55:50 +0000 Received: by mail-pl1-x643.google.com with SMTP id u6-v6so3918278plz.4 for ; Fri, 12 Oct 2018 17:55:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=szr5KLhOEepnxhuji3Nc/YMARBLGRK4oTE2y29Q5DuI=; b=Vf2+ez732wRfmVM5sn8xhWJ3KJnSnR4AoDZzbC6Vwr6SxJ2oi+WphOdQ7d1JF1g/VW DsWjigQ6B3oVlmy6rHzucW3S3IsbNj9y9HiY5cQzFKImG/RuJJbnS1UakIeCGlD7ip45 X+G/DJNufbQ4WVt1LKM36ZidXZOhb5pZ7DeB0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=szr5KLhOEepnxhuji3Nc/YMARBLGRK4oTE2y29Q5DuI=; b=HkGB4JuiK8DoTRcGEBupAgs5Y6ItU0UIKfj1ZFNuW7EpSLByPZIdGw1sNmZv0mYaAL uzQW8Iue/rHLi0raPXp3ohYIeMd9QPg8e+tM2Cn8g8WqRQfO3h87jvxP585IVWjEYQrB YxV4bOt4bhozHrLi+t6V9ii+U4kV8XGmMQDVMkVewC0Hi8y7KvxbjNiSyWB78FhE+Kro bjpezp90V4Rs1OnNUhx1uU+v7DMpuMdJfcsVT+sLu+Jh0SS7K5sxO92apxhqPawbM5pB KH7QHW7WXl/srAUQ2tuVF871LB9BD7bnDYKwjoqMzqz7FQFhm1MS+NLi/mP1s4p3gziS IykQ== X-Gm-Message-State: ABuFfoien6jvdZ2milAtmFifoMMhkVhqHBAqaAiwuSjKJTsThccpVJRI 4TOsoO+ETm1g0IHrjG/F6eJCog== X-Google-Smtp-Source: ACcGV61Zu1kR1AYSCorKL4Rnwd2Ixd4lQtWeU4CYJ3liGav4XVMNIc+mMIc1AgBkcymlOtFlH5hF9g== X-Received: by 2002:a17:902:50e3:: with SMTP id c32-v6mr5923263plj.129.1539392134274; Fri, 12 Oct 2018 17:55:34 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:1:299d:6b87:5478:d28a]) by smtp.gmail.com with ESMTPSA id n7-v6sm2766183pgv.63.2018.10.12.17.55.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Oct 2018 17:55:33 -0700 (PDT) From: Brian Norris To: Kalle Valo Subject: [PATCH 4/4] ath10k: snoc: fix unbalanced clock error handling Date: Fri, 12 Oct 2018 17:55:04 -0700 Message-Id: <20181013005504.46399-4-briannorris@chromium.org> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog In-Reply-To: <20181013005504.46399-1-briannorris@chromium.org> References: <20181013005504.46399-1-briannorris@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181012_175544_853841_B9231AEC X-CRM114-Status: GOOD ( 12.93 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Govind Singh , Brian Norris , linux-wireless@vger.kernel.org, Doug Anderson , ath10k@lists.infradead.org, linux-kernel@vger.kernel.org Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Similar to regulator error handling, we should only start tearing down the 'i - 1' clock when clock 'i' fails to enable. Otherwise, we might end up with an unbalanced clock, where we never successfully enabled the clock, but we try to disable it anyway. Signed-off-by: Brian Norris Reviewed-by: Douglas Anderson --- drivers/net/wireless/ath/ath10k/snoc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c index 5a8e87339df2..a835599a8d55 100644 --- a/drivers/net/wireless/ath/ath10k/snoc.c +++ b/drivers/net/wireless/ath/ath10k/snoc.c @@ -1470,7 +1470,7 @@ static int ath10k_snoc_clk_init(struct ath10k *ar) return 0; err_clock_config: - for (; i >= 0; i--) { + for (i = i - 1; i >= 0; i--) { clk_info = &ar_snoc->clk[i]; if (!clk_info->handle)