Received: by 10.192.165.148 with SMTP id m20csp504381imm; Fri, 27 Apr 2018 02:47:45 -0700 (PDT) X-Google-Smtp-Source: AB8JxZofJ3a0NAJ+RD1PWWfSg8ca0TLLaZeg8tylvKsIkwjKj1HUuFMpztI4WmRcvma60JMzlmKs X-Received: by 2002:a17:902:680e:: with SMTP id h14-v6mr1634971plk.90.1524822465000; Fri, 27 Apr 2018 02:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524822464; cv=none; d=google.com; s=arc-20160816; b=moMBBf3oZYbF18KjsbZ6+XUp2960MNen1+Tdgiu0lppqdc/K0QwffWEZmWXEBuIPbO OiD0cig4BgoiM0f/gWBUEixVJWzMxPSW5bmk9n1S/Rh74DKcgXb+HMq5E5yyTF2jF6FH SToCXgCV0iUvm5fByNFIPanfkhN4euml1/zBW9QyzGhpXLE1nxZcFnEQ3VYReo7KrTX9 RJ+vqT+ST8lyqUkzgBCPwsYuRkk3ZgwLxw/WLb+cVAGxb9Gt3EFkVjywNBARqtLje9ez TcD35g6AA1wjgbZN8Fy5CWHFynzQb8dISLeiayT6bvTtAk4X3eFDj1srljFvXzPJ/LHZ Db0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=tJmXQS2FZ/hW/aNmmlqLSkrnq+ADiRAPjydRFagupuM=; b=LK+LcwpQDAz9HalwEbXQ069xZ9EuEDed1bLWUo7fy/5G7e230U9mpCxEsSC88addX8 r0PdwgZluh65J+H3XJeR7lLhdL3PTsC6DnXDwZPp5y1JOH3XA90KAqQ/bIt7N6RWv0TY +bWfsUbL3SWcVecbL1gAE946Eec1pO8e4n3PxbojfRu5NvPRrwAYXQdzz4EnV7t5y7Mr Wj9KpsDLVWbLF+j/oi8+iloVUiKKKeYwtObwp/PUruVH5BiWHKa0XXaRdKREvj73bhIn qcAFiFtgC6hhdht5sMrinMxymVAkxbUv2HpwBaQgqcNHMppjDC6BoocEztEMWg+kQFpK hCng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bZ9QdRGj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3si963221pfp.161.2018.04.27.02.47.30; Fri, 27 Apr 2018 02:47:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bZ9QdRGj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932613AbeD0JqW (ORCPT + 99 others); Fri, 27 Apr 2018 05:46:22 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50262 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932515AbeD0JqR (ORCPT ); Fri, 27 Apr 2018 05:46:17 -0400 Received: by mail-wm0-f65.google.com with SMTP id t11so1617097wmt.0; Fri, 27 Apr 2018 02:46:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=tJmXQS2FZ/hW/aNmmlqLSkrnq+ADiRAPjydRFagupuM=; b=bZ9QdRGjoq6qJKH8TLIPpAQYmsFQKsM6hu06vWb3Nl/MsSE4B25TNu15Pt2653uCp1 vwGJqvSmL1A2QUUA+b0hSkzsnuowYs0NcMkXimVe4Y0KZkTarcCdNr5evztrXdO8uMVg dvTeVHiEg7tLltGZisYTIRnXEqjLET5tyCdHDdt9Gy6+kR26+u0ht8S5bOL7JQa3niUz ZOGtFuRS16JckBv/9jSXrJVdzADtvnJBUvLK5EaOi3w2Y0uIZPvrrtw11bWlCxq4NDcS dRcG4+3OlRvdcjnZ7uMGusV9CiqCs+kRyzQgu4pj471FE7AvmM2fNRPtl+TGbvIoP7yl 6IGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=tJmXQS2FZ/hW/aNmmlqLSkrnq+ADiRAPjydRFagupuM=; b=c/iEy3sDJKCCNcTP/eJDeLcS8KQ27tIyHkEN5Iy227Q1ZTX5rrQEcvp6TJLK9iVbf0 3X1USeJaeXOxrVZslLS6HfFsZQ/dYCVTdZw55QqKwHj8CEP+9ChA8exrLXc5RpWtLquP 74tQA+wH3ZEZgyXYO7V6KH4CskGewPFgZxO6k5z0hRO+ROahlrOsIxFrwkPYHrUW/2vE O9xhMrK5/k/Q+ugPLLAwbcSRa0UpKwFr1EZgA2QVcsw4zI1HmaUx7ObygxLjzfzlpBeG /V2g6tm81c6CzTDCUcIvPWJCW+QLxzlR/UFT2jtCKM9JzWNQz8SfPz9TJQLiTWYJZJWr of4w== X-Gm-Message-State: ALQs6tBusdwL0LJFR44Vjoe/vCp9ULUlWGNyB/RyK2J3wKm03WwQUSIj bkFuYjxx+OJ83FGI3lhRgu4= X-Received: by 2002:a50:b1e2:: with SMTP id n31-v6mr2500101edd.197.1524822376434; Fri, 27 Apr 2018 02:46:16 -0700 (PDT) Received: from ziggy.stardust ([37.223.140.222]) by smtp.gmail.com with ESMTPSA id g24-v6sm695853edj.87.2018.04.27.02.46.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 27 Apr 2018 02:46:15 -0700 (PDT) Subject: Re: [PATCH v2 2/2] soc: mediatek: add a fixed wait for SRAM stable To: Sean Wang Cc: rjw@rjwysocki.net, khilman@baylibre.com, ulf.hansson@linaro.org, linux-mediatek@lists.infradead.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Weiyi Lu References: <2e16481e1477dfae0cfb24568d8111da81d92628.1524472331.git.sean.wang@mediatek.com> <0ef8e87ba7156e626d1a1a48388f222ce917099b.1524472331.git.sean.wang@mediatek.com> <51840588-96e4-2520-f3d7-a61e74da6814@gmail.com> <1524476340.12322.14.camel@mtkswgap22> From: Matthias Brugger Openpgp: preference=signencrypt Autocrypt: addr=matthias.bgg@gmail.com; prefer-encrypt=mutual; keydata= xsFNBFP1zgUBEAC21D6hk7//0kOmsUrE3eZ55kjc9DmFPKIz6l4NggqwQjBNRHIMh04BbCMY fL3eT7ZsYV5nur7zctmJ+vbszoOASXUpfq8M+S5hU2w7sBaVk5rpH9yW8CUWz2+ZpQXPJcFa OhLZuSKB1F5JcvLbETRjNzNU7B3TdS2+zkgQQdEyt7Ij2HXGLJ2w+yG2GuR9/iyCJRf10Okq gTh//XESJZ8S6KlOWbLXRE+yfkKDXQx2Jr1XuVvM3zPqH5FMg8reRVFsQ+vI0b+OlyekT/Xe 0Hwvqkev95GG6x7yseJwI+2ydDH6M5O7fPKFW5mzAdDE2g/K9B4e2tYK6/rA7Fq4cqiAw1+u EgO44+eFgv082xtBez5WNkGn18vtw0LW3ESmKh19u6kEGoi0WZwslCNaGFrS4M7OH+aOJeqK fx5dIv2CEbxc6xnHY7dwkcHikTA4QdbdFeUSuj4YhIZ+0QlDVtS1QEXyvZbZky7ur9rHkZvP ZqlU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c1uZGzJBCQu4 8UjmUSsTwWC3HpE/D9sM+xACs803lFUIZC5H62G059cCPAXKgsFpNMKmBAWweBkVJAisoQeX 50OP+/11ArV0cv+fOTfJj0/KwFXJaaYh3LUQNILLBNxkSrhCLl8dUg53IbHx4NfIAgqxLWGf XM8DY1aFdU79pac005PuhxCWkKTJz3gCmznnoat4GCnL5gy/m0Qk45l4PFqwWXVLo9AQg2Kp 3mlIFZ6fsEKIAN5hxlbNvNb9V2Zo5bFZjPWPFTxOteM0omUAS+QopwU0yPLLGJVf2iCmItHc UXI+r2JwH1CJjrHWeQEI2ucSKsNa8FllDmG/fQ== Message-ID: <0ec15c8a-ca90-26c3-1ea6-00bf0d48b62a@gmail.com> Date: Fri, 27 Apr 2018 11:46:14 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1524476340.12322.14.camel@mtkswgap22> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, On 04/23/2018 11:39 AM, Sean Wang wrote: > On Mon, 2018-04-23 at 11:31 +0200, Matthias Brugger wrote: >> >> On 04/23/2018 10:36 AM, sean.wang@mediatek.com wrote: >>> From: Sean Wang >>> >>> MT7622_POWER_DOMAIN_WB doesn't send an ACK when its managed SRAM becomes >>> stable, which is not like the behavior the other power domains should >>> have. Therefore, it's necessary for such a power domain to have a fixed >>> and well-predefined duration to wait until its managed SRAM can be allowed >>> to access by all functions running on the top. >>> >>> v1 -> v2: >>> - use MTK_SCPD_FWAIT_SRAM flag as an indication requiring force waiting. >>> >>> Signed-off-by: Sean Wang >>> Cc: Matthias Brugger >>> Cc: Ulf Hansson >>> Cc: Weiyi Lu >>> --- >>> drivers/soc/mediatek/mtk-scpsys.c | 24 ++++++++++++++++++------ >>> 1 file changed, 18 insertions(+), 6 deletions(-) >>> >>> diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c >>> index b1b45e4..d4f1a63 100644 >>> --- a/drivers/soc/mediatek/mtk-scpsys.c >>> +++ b/drivers/soc/mediatek/mtk-scpsys.c >>> @@ -32,6 +32,7 @@ >>> #define MTK_POLL_TIMEOUT (jiffies_to_usecs(HZ)) >>> >>> #define MTK_SCPD_ACTIVE_WAKEUP BIT(0) >>> +#define MTK_SCPD_FWAIT_SRAM BIT(1) >>> #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x)) >>> >>> #define SPM_VDE_PWR_CON 0x0210 >>> @@ -237,11 +238,22 @@ static int scpsys_power_on(struct generic_pm_domain *genpd) >>> val &= ~scpd->data->sram_pdn_bits; >>> writel(val, ctl_addr); >>> >>> - /* wait until SRAM_PDN_ACK all 0 */ >>> - ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0, >>> - MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); >>> - if (ret < 0) >>> - goto err_pwr_ack; >>> + /* Either wait until SRAM_PDN_ACK all 0 or have a force wait */ >>> + if (!MTK_SCPD_CAPS(scpd, MTK_SCPD_FWAIT_SRAM)) { After having another look on the patch, could you change the order of the if: So that we check for the existence of the MTK_SCPD_FWAIT_SRAM and sleep and in the else branch we to the readl_poll_timeout. I think in the future this will make the code easier to understand as you can easily oversee the '!' negation in the if. Regards, Matthias >>> + ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0, >>> + MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT); >>> + if (ret < 0) >>> + goto err_pwr_ack; >>> + } else { >>> + /* >>> + * Currently, MTK_SCPD_FWAIT_SRAM is necessary only for >>> + * MT7622_POWER_DOMAIN_WB and thus just a trivial setup is >>> + * applied here. If there're more domains which need to force >>> + * waiting for its own pre-defined value, the duration should >>> + * be coded in the caps field. >>> + */ >> >> I would say, if necessary in the future we can add a switch statement here. >> Other then that the patches look good. If you are OK, I'll just delete the last >> sentence when applying the patch. >> > > yes, it's okay for me. > >> Regards, >> Matthias >> >>> + usleep_range(12000, 12100); >>> + }; >>> >>> if (scpd->data->bus_prot_mask) { >>> ret = mtk_infracfg_clear_bus_protection(scp->infracfg, >>> @@ -785,7 +797,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = { >>> .sram_pdn_ack_bits = 0, >>> .clk_id = {CLK_NONE}, >>> .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_WB, >>> - .caps = MTK_SCPD_ACTIVE_WAKEUP, >>> + .caps = MTK_SCPD_ACTIVE_WAKEUP | MTK_SCPD_FWAIT_SRAM, >>> }, >>> }; >>> >>> > >