Received: by 10.192.165.148 with SMTP id m20csp3209846imm; Mon, 23 Apr 2018 02:33:07 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/HPd26vh/ECqGiBnqvXpcYtRHhkzSZgWgAPoUfIgC8rKJIaUTPcxiCC9jxkARehEnNXT6J X-Received: by 10.99.137.74 with SMTP id v71mr16888420pgd.423.1524475986970; Mon, 23 Apr 2018 02:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524475986; cv=none; d=google.com; s=arc-20160816; b=szJtBal6hERQCsypoyHqUUcrZsH7Gh5SPs+tboIDfuejKecQeIGemQOvL9py1ajXMp OTQ837O3UX+SJvKi4uzHy/qtZ1bEkhX7LMO5QoQJe2UhmOWlEz0gs3ftX+YnCiqjqsIF 35AyaLfNwMvNSgpsF3fYmEkq7WotpBh87cwdrfJ9KHBH8BHtVHQod94vSw+4uSqOBaHu 1DoO9gSdWH3L+he3bBSm/eBazWSIWV3JLYQSmTt43oBXhjHqC84QsP7XYDBnpgg2I+oW Y0/xD4ppauJ48nYoKVG5wkBZR0fC/PJepnU2aosCrXbX+4Koioo+QJDHLfN998cdQrla KhwQ== 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=iC+l1PhdZnBdHt7tEM2twGPtnyysfbYv8VPW/1YY6oU=; b=Gk+0CDjI+keII7y3X2bGQVeDRhrx58ZKmD2On7jC8KeOEyd5FP9oX2u1NFLZGyhhcA B7mky/V+qPaexvzbr7NKxU+it9RDb8EDl8A5a6ynfG42d6YiVWajejIknBt/YVvHm+kJ f/tJMF+07SKNJON48IIB5DS5krEfvyPJn0TiHIhADklo72s5xcokoW8Tf8xF94qyiPDJ 6+dqAeWnhCuC3hwfschDo9NlfpFWsZsxuzVlZsoh4PGATW1pt1Z3CG4t+UjuSobSzL5T T2V5bNvi3AswUGhV5e399nVgRZ1gTyrOJICbM0e9mTXLZSXqJrilnl494+6oAZHF3ggO cGAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aFNkxXQa; 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 t198si9468014pgc.600.2018.04.23.02.32.52; Mon, 23 Apr 2018 02:33:06 -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=aFNkxXQa; 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 S1754456AbeDWJbm (ORCPT + 99 others); Mon, 23 Apr 2018 05:31:42 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:44161 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754245AbeDWJbk (ORCPT ); Mon, 23 Apr 2018 05:31:40 -0400 Received: by mail-wr0-f194.google.com with SMTP id o15-v6so39234098wro.11; Mon, 23 Apr 2018 02:31:39 -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=iC+l1PhdZnBdHt7tEM2twGPtnyysfbYv8VPW/1YY6oU=; b=aFNkxXQaL1sRQSaCW7/5NO8tIvIfNg6m36tTzHXSivVPA/q+01tBuYHjUAzPZx4Qj8 k6GL9bBq/lTULkWjZxEzqiy+BsEeqsy47ulL/gFJyujYBGOD14qpQJzuq0LCigaJp0ex EMApKd3JRjcLzZaiG1uxuR8U1VRgYfavWGJMugMlWCQh7/hwEVBPGpHUQ+m1F3X6DwIA jvVnn/p2JDzT6e9MJu0Mg3LIoEUgJ+loGZa97reXcuNSJb0kkZuE/+k8hK0DSCUJwadM Ege/255Bw2GBPNDFttAR+Z8XjIkCTIwI3vTzR3tObgbxC1KJNwRvzjJBV49O2Ce+hbDn 2nMg== 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=iC+l1PhdZnBdHt7tEM2twGPtnyysfbYv8VPW/1YY6oU=; b=Smg/XWlqA5ym4hv7autyQ9CvyQyGyrZfsvubmRtKe6np0xoc2Aut9cAj/yrWJ9S0qC 96j2PRh/YlV8+aNlbsx8mSjEk9cMzZOeZIs1Q/OD4AmGLwvoqck84sVURqzzDkpgAr95 ILIyycIA8TU6Hb/cDBiWbxXQ8aouZDv7WodWEYPqQPub8jnVtW0hTjv0WMRK3iGY5Fq/ 7wLiO9QshfRlTeityC6ad4HdWhhOVBBY+G9NVmM/3ii84zMDH8F014cdrucGURf3Z+hT WEE+TYD5Iv1ahkEDZEFptaIMOW8GEp49gXkkkQHuTANCKgxCZCEQsNT/EpESlS3cFWsM 0s3Q== X-Gm-Message-State: ALQs6tBl69TpGNOT6nrxb89h+soQiDaWDOm3ndksimKBcR3lPTuqZ3Et vyqp9vtddRxsm6IgkkSBBqo= X-Received: by 10.167.212.137 with SMTP id b9mr12884274edr.121.1524475898696; Mon, 23 Apr 2018 02:31:38 -0700 (PDT) Received: from ziggy.stardust ([37.223.140.222]) by smtp.gmail.com with ESMTPSA id f11sm6937610edf.68.2018.04.23.02.31.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 02:31:37 -0700 (PDT) Subject: Re: [PATCH v2 2/2] soc: mediatek: add a fixed wait for SRAM stable To: sean.wang@mediatek.com, rjw@rjwysocki.net, khilman@baylibre.com Cc: 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> 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 ZqlUsLJ2nOqsmahMTIQ8Mgx9SLEShWqD4kOF4zNfPJsgEMB49KbS2o9jxbGB+JKupjNddfxZ HlH1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AVclppiHctRA0gssE 3GRKuEIuXx1SDnchsfHg18gCCrEtYZ9czwNjVoV1Tv2lpzTTk+6HEJaQpMnPeAKbOeehq3gY KcvmDL+bRCTjmXg8WrBZdUuj0BCDYqneaUgVnp+wQogA3mHGVs281v1XZmjlsVmM9Y8VPE61 4zSiZQBL5CinBTTI8ssYlV/aIKYi0dxRcj6vYnAfUImOsdZ5AQja5xIqw1rwWWUOYb99 Message-ID: <51840588-96e4-2520-f3d7-a61e74da6814@gmail.com> Date: Mon, 23 Apr 2018 11:31:36 +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: <0ef8e87ba7156e626d1a1a48388f222ce917099b.1524472331.git.sean.wang@mediatek.com> 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 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)) { > + 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. 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, > }, > }; > >