Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1934156imm; Sun, 27 May 2018 21:00:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpJQiPpJ8lxDZSvXj2TgplXuQoflz9/M3cQlN4zE8fjcn+KZp1NYyWjkTukcpdUol+5VG/D X-Received: by 2002:a65:644f:: with SMTP id s15-v6mr9301286pgv.228.1527480032235; Sun, 27 May 2018 21:00:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527480032; cv=none; d=google.com; s=arc-20160816; b=1GtzfH3eXBQvyvEvd+f2HrlD90Eh7Fhyy8AOds1HCRfRturPPXSnulCw4uUJtfuvgz Pe1lxmM6UElNGauRVmjQYBehkVPdzhfAFMl5VAxp7g6OONIKU4QCkLiABPoFqPnA7C2k 8QrU+9qHqt1A6svTzclfqEgY8FrhOlOAyfFVLBWkBGfbR9+d82F1kS3QENm/OW1/+9r4 3UuiLjw69DB2Vf3k5SB1iUbkre6w85GSsA0NNmWv4G6oM2kEAHWy0C1HdJSzuqhiuI1T PAOM+M3add8j0IdMu6hVENNggDwf5FmI0Z6KHvGrF0De4buN6jiUsjzkuVjb3K6aPaIX uTjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:dlp-filter:cms-type :content-transfer-encoding:date:message-id:in-reply-to:cc:from :reply-to:subject:mime-version:to:dkim-signature:dkim-filter :arc-authentication-results; bh=nADWtCSQxJIydRiY/MLSGJvZ0lCvC0nmtpoE4YEatlg=; b=l1FPLghhocwbrNcYFnOLUyihoJE+a6wawP7ty71ztXxeMcwlIsQL4EmZtNy5S3iADk Ip4ir/g5MAxihJbveQbxjKD3pZXUcl29izFdHPXE6eJOcdfDBmlv+DV/EAz9aUxDVtWm iTf70R7aE22nOZMR1djUmY3CyvFuGX3Ymefoji7HVK3bMdFlRO/TGz4Z2X0B3tXyg1It BJyFlfI/SHEVj8Se9FaYfT1QN9RMuFbbBmPS9358Usmz2fiSUKeFVIzOMSY+OP9acT+V u5SI1PdLAfpSI/aRl2hTQ7UuKe+C7Py2jOR9Yovum5zukjTnAVcvPZpms7A4V3UjBI+e PtVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=QOjnkSy+; 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=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12-v6si29322460plg.463.2018.05.27.21.00.17; Sun, 27 May 2018 21:00:32 -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=@samsung.com header.s=mail20170921 header.b=QOjnkSy+; 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=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753154AbeE1EAC (ORCPT + 99 others); Mon, 28 May 2018 00:00:02 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:25069 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752967AbeE1D76 (ORCPT ); Sun, 27 May 2018 23:59:58 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180528035957epoutp010843443773b6b09b3b96da68624f0f36~ysvbkFA3H1141311413epoutp01V for ; Mon, 28 May 2018 03:59:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180528035957epoutp010843443773b6b09b3b96da68624f0f36~ysvbkFA3H1141311413epoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1527479997; bh=nADWtCSQxJIydRiY/MLSGJvZ0lCvC0nmtpoE4YEatlg=; h=To:Subject:Reply-To:From:CC:In-Reply-To:Date:References:From; b=QOjnkSy+4gXXv6RaEpEQxOx4Jb+bLTi6ly4wPNqFiw1hEFDcwniOkGGm+ewGsXfDk qTSBZTanwegwooQBweHhcXWg/xhu8vA+6sMiErnqh8Fsp1dS3ZLJGk7W3lIwLSi2hl TI05NZ9gPxzA8ejrH7dxmq+jHX7Ml6V9CjkWAyOI= Received: from epsmges1p3.samsung.com (unknown [182.195.40.156]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180528035954epcas1p40472402b60c0a25d5c189c8ec743ab47~ysvY1fjEC2562025620epcas1p4m; Mon, 28 May 2018 03:59:54 +0000 (GMT) X-AuditID: b6c32a37-a71ff70000000fec-47-5b0b7ebac2a3 Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p3.samsung.com (Symantec Messaging Gateway) with SMTP id EE.F8.04076.ABE7B0B5; Mon, 28 May 2018 12:59:54 +0900 (KST) To: undisclosed-recipients:; Mime-Version: 1.0 Subject: RE: [PATCH 02/11] PM / devfreq: Fix handling of min/max_freq == 0 Reply-To: myungjoo.ham@samsung.com From: MyungJoo Ham CC: Kyungmin Park , Chanwoo Choi , Arnd Bergmann , Greg Kroah-Hartman , Rob Herring , Mark Rutland , "linux-pm@vger.kernel.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Brian Norris , Douglas Anderson , Matthias Kaehlcke X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20180525203043.249193-3-mka@chromium.org> X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20180528035953epcms1p87bf2a4ec589bd860034032e091820f69@epcms1p8> Date: Mon, 28 May 2018 12:59:53 +0900 X-CMS-MailID: 20180528035953epcms1p87bf2a4ec589bd860034032e091820f69 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-CPGSPASS: Y X-CPGSPASS: Y CMS-TYPE: 101P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCJsWRmVeSWpSXmKPExsWy7bCmnu6uOu5og4ZjbBZ/Jx1jt9j08T2r xctDmhbXvzxntZh/5ByrxdllB9ksmhevZ7M42/SG3eLyrjlsFp97jzBaLL1+kcni84bHjBat e4+wO/B6rJm3htHj969JjB6zGy6yeGxa1cnmsX/uGnaPvi2rGD0+b5ILYI9KtclITUxJLVJI zUvOT8nMS7dV8g6Od443NTMw1DW0tDBXUshLzE21VXLxCdB1y8wBulZJoSwxpxQoFJBYXKyk b2dTlF9akqqQkV9cYqsUbWhopGdoYK5nZASkjWOtjEyBShJSM/rfnWIpuMdd0bv3CmsD41HO LkZODgkBE4nOiyuYQGwhgR2MErd7TEFsEQEZibmzH7N2MXJw8AoISvzdIQxiCgt4SWy/6Q5R rSTRcHMfM4gtLKAv0fFgGyOIzSagK7F1w12WLkYuDmaBJSwSSzb+Z4RYxSsxo/0pC4QtLbF9 +VawOKeAucSH881MEHFRiZur37LD2O+PzYfqFZFovXeWGcIWlHjwczdUXEriyduFUPX1Etc/ L2ICWSwhMIFR4veN/1AJfYlHV2azgdi8Ar4S+x9+ATuCRUBVYvKco6wQNS4St49tAIszC8hL bH87hxnkYWYBTYn1u/Rh7m/Y+Jsdnc0swCfx7msPK0x8x7wnUL+oSRzavQSqXkbi9PSFUPd7 SDTPnccygVFxFiJ0ZyFZPAth8QJG5lWMYqkFxbnpqcWGBcZ6xYm5xaV56XrJ+bmbGMEpVst8 B+OGcz6HGAU4GJV4eBt+c0ULsSaWFVfmHmKU4GBWEuHl0gUK8aYkVlalFuXHF5XmpBYfYjQF +n8is5Rocj4w/eeVxBuaGhkbG1uYGJqZGhoqifO2mf+LEhJITyxJzU5NLUgtgulj4uCUamAM /773mHtXq0RIST7Dt1Vu7/b5uP71Sgwwuhm7VYNvdxhbv9SD9emHWY9UKp5au/vu5wwprjCD osKGsNTzpR7FP2U3GrrXrdQtWtfMt95mcor+Ka+Si4n78/Y6vM4RmXCoTGDBZsaiu3tfb0jI P5jFM0vx9ClhiZm7lnDECLLYcP1y3HZDrlGJpTgj0VCLuag4EQAPeffpxwMAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180525203120epcas2p429d60dc21e16f0b53c58e7b1f942858f References: <20180525203043.249193-3-mka@chromium.org> <20180525203043.249193-1-mka@chromium.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Commit ab8f58ad72c4 ("PM / devfreq: Set min/max_freq when adding the > devfreq device") initializes df->min/max_freq with the min/max OPP when > the device is added. Later commit f1d981eaecf8 ("PM / devfreq: Use the > available min/max frequency") adds df->scaling_min/max_freq and the > following to the frequency adjustment code: > > max_freq = MIN(devfreq->scaling_max_freq, devfreq->max_freq); > > With the current handling of min/max_freq this is incorrect: > > Even though df->max_freq is now initialized to a value != 0 user space > can still set it to 0, in this case max_freq would be 0 instead of > df->scaling_max_freq as intended. In consequence the frequency adjustment > is not performed: > > if (max_freq && freq > max_freq) { > freq = max_freq; > > To fix this set df->min/max freq to the min/max OPP in max/max_freq_store, > when the user passes a value of 0. This also prevents df->max_freq from > being set below the min OPP when df->min_freq is 0, and similar for > min_freq. Since it is now guaranteed that df->min/max_freq can't be 0 the > checks for this case can be removed. > > Fixes: f1d981eaecf8 ("PM / devfreq: Use the available min/max frequency") > Signed-off-by: Matthias Kaehlcke > --- > drivers/devfreq/devfreq.c | 30 ++++++++++++++++++------------ > 1 file changed, 18 insertions(+), 12 deletions(-) Thanks a lot! Nice Catch. Acked-by: MyungJoo Ham Cheers, MyungJoo.