Received: by 10.223.185.116 with SMTP id b49csp5918037wrg; Wed, 7 Mar 2018 21:46:50 -0800 (PST) X-Google-Smtp-Source: AG47ELu9yuQmFNhkHPn8dg1OS0IS3anO86ckYWngk3iO8BW10B9C5cD0v5IW4RNX6khxliXDid+6 X-Received: by 10.101.85.67 with SMTP id t3mr20406133pgr.310.1520488010666; Wed, 07 Mar 2018 21:46:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520488010; cv=none; d=google.com; s=arc-20160816; b=d8LLNuQ9GhgOAL4cT4//DIjAT5RmSADjp32dpFGIbbyqV6IIE5IYQlP4m0TQMZVbt1 P9gX1+92dJck5ufgpwlp30Cu4QgFUXsRyIClyfddrm369Xqh1ICJYjUy0GcuF6qG2sr2 nnSI4dKNqCKOnFgmYPnPyOiWCY+NesJFBpESuRCIJz+4BuIWviom126xdgcU5oVNi2fc 2U9dgdwo4kgNIXwmzcW5IJCmx8WwDZi4XtjPOtMR5+mGNGZ3R3jyY3dh9MqX+2//YvTa lYTJx+9EUvdPoGu+zOcD3BzZPqnYOv54w6K43u6DLu/xQB4bh3BldRfwAiFrpKxZyLxL /pNw== 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:dkim-signature :arc-authentication-results; bh=ONY87YcaWMfLNZrIRYOKj8w6p8QFQey0WSTejMUAUoI=; b=a6Up8H4XV/DO1FBpP+ChiDS3j47+K7VLIzpPa5QuAa3+CiYBYSpoLOypTSTxO/NC+D MjsGTfBjDkoh14gtrYkQlUrIDBfQ6xEr/ETAlnXHzXpzlA+Wr3e4df1AGRas3vYbv8M6 XqC/+1XADdL0babXw1syM5klDGgtdnAmH1mdkopqW6NtwWuB6gVdcrcHFQYdjziHvcth mX8ydFCPkb97rLYl68JqAsDP8mTyg73Ztg3MfdEWIM9PA8s6L5/tNFvhV2Q5lFLvbfN0 E/qWdDizRn5vh7id0ISFRH4ZUxI+TKzK/kEJ6bSjoO+TjD5U/1BEh1ncwi+R4JlKCY9t Y3Mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=MWFdZdU5; dkim=fail header.i=@jms.id.au header.s=google header.b=lb15JxaL; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si15400218pfd.83.2018.03.07.21.46.36; Wed, 07 Mar 2018 21:46:50 -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=fail header.i=@gmail.com header.s=20161025 header.b=MWFdZdU5; dkim=fail header.i=@jms.id.au header.s=google header.b=lb15JxaL; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966827AbeCHFn5 (ORCPT + 99 others); Thu, 8 Mar 2018 00:43:57 -0500 Received: from mail-qt0-f171.google.com ([209.85.216.171]:39195 "EHLO mail-qt0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966380AbeCHFnt (ORCPT ); Thu, 8 Mar 2018 00:43:49 -0500 Received: by mail-qt0-f171.google.com with SMTP id n9so5504018qtk.6; Wed, 07 Mar 2018 21:43:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ONY87YcaWMfLNZrIRYOKj8w6p8QFQey0WSTejMUAUoI=; b=MWFdZdU5qzFKsUja4AcW8s6Y0N+5mYSR5A3oXROPM7frp5fUxfH/zfyusLO9SbJz/o UzdixauFsWQVIk2rIziO4XSRDRd+QUNt03RbNWoZu368rItnzIV9GuAHpz9ki2VtCEVc ZftaqxfvPrjrGcmiRWKCVGWuTyNIxFc/z7+mWPjocQt3XN/0hRNGcaacg0mQj4AyHJLo ywuaOiIa02bVbXYUCpFOkUipEa3WSVrWCNGhvCCQ+YEDyEz5WkP/3aXgBcDlJF7func+ CI0ncSGjgIFYk0YyDeU/nZ9PivYIk8jnsml9+L7vwV9MU/JJ5rXL/Io/CrnJdOhdOPYM n6nw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jms.id.au; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ONY87YcaWMfLNZrIRYOKj8w6p8QFQey0WSTejMUAUoI=; b=lb15JxaLl1cAqN7LK1P+Y+u84KlnKZt+Pw5L4EJW8bPgpMpfcvMIqo+dZldEpg5tPk vU/kLZh4OGhj/lV6Fewthnp/cowvBzg48mIe4XIV2w3OVeavh3NOdJxPVv2WXZcQIWii LeIouD2mWZ/kamDJYVPOTA4j6f7iaSAv7s+FM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ONY87YcaWMfLNZrIRYOKj8w6p8QFQey0WSTejMUAUoI=; b=G88mp34V8w3KFz20QL/L09P4ukHuIgNw8CDwosjbioME1pko8mwohWquTImmD7OiIp J7PPHq1GsMTY57RBYhErnzERJYJye8PmrbDBGTL88XAcOoX9FgGDWRt8cKlrY9LcJ2sP 1FAaH9YOHECaG1inmDKViRKyrCvzAW9vwb381UZoQY3j/+pmyCFwI9sE28Hhj8HySLjI O8VbmH/xPbYMOT7fx5MRJtWe4p1esSVVJdbEq/nw3WAFJA/J4Z0qFC7NRABu7b/jNwlY dbLwLtzbFfbSDiVdZPch343lxdSZM1dGHACx9sG8qf3YYa1RjCM+EtNqS/NROmYY2mzc I58Q== X-Gm-Message-State: AElRT7GIMgRmm6fXPPgWP5pdNQ2I8w3iKo+fTBSVId7fxX7kzM4ZCdws eTKi4prmAHnjeLTsdRH3hp/8YU/AXynNcp0drqk= X-Received: by 10.200.40.70 with SMTP id 6mr40302068qtr.285.1520487828608; Wed, 07 Mar 2018 21:43:48 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.50.69 with HTTP; Wed, 7 Mar 2018 21:43:28 -0800 (PST) In-Reply-To: References: <1520440570-25280-1-git-send-email-eajames@linux.vnet.ibm.com> From: Joel Stanley Date: Thu, 8 Mar 2018 16:13:28 +1030 X-Google-Sender-Auth: kfj-5iGcso1lRjhLfWBEhp_-YH0 Message-ID: Subject: Re: [PATCH] clk: aspeed: Prevent reset if clock is enabled To: Lei YU 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 4:08 PM, Lei YU wrote: > 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; Good suggestion. We should also fix up aspeed_clk_is_enabled() for clocks that have CLK_GATE_SET_TO_DISABLE set. Cheers, Joel