Received: by 10.223.185.116 with SMTP id b49csp5912899wrg; Wed, 7 Mar 2018 21:40:11 -0800 (PST) X-Google-Smtp-Source: AG47ELvGnHzl+wbJIrtigg2wRF38l8Ip4L+K/fY+eu2/BPXiZ0qaI87zVyLhPg0k96hKihzjxmZe X-Received: by 2002:a17:902:22f:: with SMTP id 44-v6mr22625424plc.418.1520487611789; Wed, 07 Mar 2018 21:40:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520487611; cv=none; d=google.com; s=arc-20160816; b=dK/lqElj5NY58FXQbv+xfyZgw6wm9Pzs7YMm7tC5izw+QYcUUIL/LviIgZ8R8nniRd wW9ov/Fl50aLA95QLtrL+qHjy69CKOpXz6M2QofbeRaQH1Cr3UzDhu1yHvGtur8kObFE mCRwuv+j3CMuRtkjLDz3fWEL6DLdBIkKWjTmuuay2jnObOwL9wtPVXW8k+J4cOIoTCm7 djlGLXm8KyAXfge4alxYhDVR0wRAJbzjicRndVCr3/dkO/k+IRgVA1MXCH8BRSRt53Gi mxZH7XVdtx5ZBugmw5i764TNTQkyrlpqUPuQSHUInP9E08pt4hbYe67IEtb94DzgEh/b X7yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=0APw5USdRxC9T1I5IElJJ3i/7vnfpYWuwwaAUnJpZWo=; b=bLsg5IgB5P1ZhuYvaWjLImoaS+OlLoNsJj32z+E1JBfasfgoz2fYvUT4pHXJo3nj4/ CFCBkRkmF6eBuO0+CXm4bn2aw0ExsnMFdlwRpgzOIOEDkSggOr9A1sgZ1S8ZH0ujMeud 3ys1gP0NIP8wIPeisXyNKoSdxwrzdgERIzakIdm1b8lQ2hYfzAtzJnu4K4r37Cew+ShM vIaDMR8dSGJEIUpks2ZVcm3jCLxHhGIygb+c6GkSlQEFGuKLB542It1p4i/khgtQ9gOX jPyq0pFzUya1ZoeDiAYwuSediXfiSCmuoh49WoA+KKNSbOnp0M3QnXyhOzsTWzvA+VI4 WLrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DHEMSbAV; 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 e1-v6si14133584pln.578.2018.03.07.21.39.57; Wed, 07 Mar 2018 21:40:11 -0800 (PST) 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=DHEMSbAV; 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 S966609AbeCHFiv (ORCPT + 99 others); Thu, 8 Mar 2018 00:38:51 -0500 Received: from mail-it0-f43.google.com ([209.85.214.43]:40005 "EHLO mail-it0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966074AbeCHFis (ORCPT ); Thu, 8 Mar 2018 00:38:48 -0500 Received: by mail-it0-f43.google.com with SMTP id e64so6419205ita.5; Wed, 07 Mar 2018 21:38:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0APw5USdRxC9T1I5IElJJ3i/7vnfpYWuwwaAUnJpZWo=; b=DHEMSbAVGJ7CqL2/nXgBQtVFtpWjoQaZnsWj5hQQMtdgVhknLtCJGwP0yfmbDjNic8 59kOfC/Sv6gK5G8i/2uH7rsjjmq0fFK7G7bVTXfc1jo/k+z/TrDoohWxiU4wIc48Aamt IWM9ykCVlPXbbtJlBwTqo2OvUTtGzYatUCLdY/vRDdMwHD0DueUL7JbPtpoCgPfrGC3N nsolfvnFXiAYxb1LwVe8HxhPxQkbPPaAzQtt61RElmnNx5EgoOQ/mYz7KmyDQSgnkRSk TDoONXcQeUJOkLxbPSW/skyIc4KlcqSfYKiiqGAiziC99EP7nItDZuXTiqoFszpthLE4 x7bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0APw5USdRxC9T1I5IElJJ3i/7vnfpYWuwwaAUnJpZWo=; b=bVzCIxwSKA9Mugp0EMDmARQNFAtYAMAkTKg9qwr3w8v2UrBsqjin3vbUpC5Ja2ukcL M4WqloOCkGh8Wp1sostu9ImPK75tmvOgld5ttVWpFuSDKUgyJv9Q6aedA9z/OdeS1hKO KBmrUfwIB9LP44HsisyBrNe9iGTaWsDV6mPjeYmX3Vy9UB3KEVUYNqMpPfJ4zKJt7lDu E4eSiMFTez0ypqGVQQbtkBQcVT8DZMZlheIDyg4bFdr7IheMkkKuqZVyl3Rom12IeuUq ABwqTOHTWUutJbpT3JwBkhw/QfHrTOeGB5SrTYHAfKNije+plIUBYhY88I5oKHZJRE9Y saWQ== X-Gm-Message-State: AElRT7GIkyDLLHOqiLxXDL2OiER9v2p3W8nZ6Qa8yKo9/JVwM2lUoc3c f2GBbCDsa1l8aVqFNBIGsAMPKgWWFJmkeqNSaC/DXOmJ X-Received: by 10.36.54.144 with SMTP id l138mr26281068itl.14.1520487527928; Wed, 07 Mar 2018 21:38:47 -0800 (PST) MIME-Version: 1.0 Received: by 10.79.146.18 with HTTP; Wed, 7 Mar 2018 21:38:47 -0800 (PST) In-Reply-To: References: <1520440570-25280-1-git-send-email-eajames@linux.vnet.ibm.com> From: Lei YU Date: Thu, 8 Mar 2018 13:38:47 +0800 Message-ID: Subject: Re: [PATCH] clk: aspeed: Prevent reset if clock is enabled To: Joel Stanley Cc: Eddie James , Linux Kernel Mailing List , linux-clk@vger.kernel.org, Michael Turquette , sboyd@kernel.org, Ryan Chen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 8, 2018 at 11:42 AM, Joel Stanley wrote: >> + /* Only reset/enable/unreset if clock is stopped */ >> + regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); >> + if (!(reg & clk)) >> + return 0; > > This doesn't generalise to all of the clocks, as some clocks use set > to disable. Perhaps we could do something like this: > > /* Only reset/enable/unreset if clock is stopped. The LPC clock > on ast2500 has issues otherwise */ > enval = (gate->flags & CLK_GATE_SET_TO_DISABLE) ? 0 : clk; > regmap_read(gate->map, ASPEED_CLK_STOP_CTRL, ®); > if ((reg & clk) == enval) { > spin_unlock_irqrestore(gate->lock, flags); > return 0; > } > > I think we should also do this operation under the lock. > > Please cc Ryan Chen so he can confirm that > this workaround is valid, and credit Lei who spent a lot of time > investigating this issue. Perhaps "Root-caused-by". > The code has aspeed_clk_is_enabled() already, why not just: if (aspeed_clk_is_enabled(hw)) return 0;