Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp996485imm; Tue, 3 Jul 2018 03:49:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJJ/l9u39kNl+KAJwsEGF7BPpOEfRK0xnX3ZnKJhPFH+PVyScoR+VwXy1TefC5kSMIyqgN7 X-Received: by 2002:a17:902:3343:: with SMTP id a61-v6mr29169354plc.241.1530614981058; Tue, 03 Jul 2018 03:49:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530614981; cv=none; d=google.com; s=arc-20160816; b=lXMGokcbgk6Y+FCMoiyoBjbBVzbbUNcF3sHxtwJ+D4/g9V9PmC16G3tt2qSNUEiFPZ edcH/dJ2sJF+VoNCQENSVNi8zK7zx2Vnjwn1i/Iw3gRqVQXdsC1dPktEnFhAp65OW1a5 6Tk2ct9aUW0IuZM6qJB3YVwjraDRWk9v9QqxEhM7jB82eLAq2kDETg5PBBnNUsWYKbpr EF+T448Bcy5gEAuYTHUY9Mw8qyF7izKiHfFjLgiHtNtzXSE6hDJihzf8ruMuCMG7+KIg aq8Zccu4QDLO/q5zm3mcLo9yDvxiJJr+LoPPo+UQWLJiApHsPTGwU+zxlnEgmR2RcDqh N2Zg== 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:to:from :reply-to:subject:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=EWW6JZaAeX9LPP20GR7p0crIRtO3/c3xajacVH9Q/Es=; b=UDFYr7Df3WEoXmiQTIjPLoD1NZ6CU3GR/EGdNqFhljyVs652nawfyn0jQ+m4Tk9GGt ZD56se1q9ui68BHaUiaIivTj16+ZqPe4rfRp9cGkqBUalgwFyRQ8UnOvw4mF3KiS4vo/ K0QuM2/GCqirXn/MXenjmjGloZhWTODQzmTqfBh6MxudP3UBYojwg5qHcbPQ4N+IPRPE kZf13Eod26Nn4SBbPuRvJLQqPzs4OsJdDCFIM8usHUuaNKiEN5/aCrz/T3ExNv9fBHOq HzEhsetkQXVssSav7g6QSCRlqvbpi9cDT6qU7HbpDnkI2cz414Sw97uG7PbbC8nR0jS1 V6zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=WOicj+Jz; 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 w65-v6si901342pfw.95.2018.07.03.03.49.26; Tue, 03 Jul 2018 03:49:41 -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=WOicj+Jz; 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 S1752788AbeGCKr4 (ORCPT + 99 others); Tue, 3 Jul 2018 06:47:56 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:10756 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbeGCKry (ORCPT ); Tue, 3 Jul 2018 06:47:54 -0400 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180703104753epoutp03f12e4f416c29a60744c5e27d86c4e073~91h4eW7gG0218102181epoutp035 for ; Tue, 3 Jul 2018 10:47:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180703104753epoutp03f12e4f416c29a60744c5e27d86c4e073~91h4eW7gG0218102181epoutp035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1530614873; bh=EWW6JZaAeX9LPP20GR7p0crIRtO3/c3xajacVH9Q/Es=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=WOicj+JzoKLz0S7zHMFUTeA4t+PVT589Xo+b4crN86bpFGGUBgS7ayhB943hH8ja/ 0wZmJVK1mDcsTrKl3Ec+Lehvd33ITYEoiS+GpqEXdCLnqVwMjDyJ9XXkJLKuaUZ2SO /OtW+Uy3Im7ose0mF4p/NqAfRHmwuXJSmbgW23qs= Received: from epsmges1p1.samsung.com (unknown [182.195.40.154]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180703104750epcas1p4352376b18d666b307b9858d8f501211b~91h1q1Ojp0578805788epcas1p4Y; Tue, 3 Jul 2018 10:47:50 +0000 (GMT) X-AuditID: b6c32a35-ba1ff70000000fe2-06-5b3b5456befe Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 14.E6.04066.6545B3B5; Tue, 3 Jul 2018 19:47:50 +0900 (KST) Mime-Version: 1.0 Subject: RE: Re: [PATCH v3] PM / devfreq: Fix devfreq_add_device() when drivers are built as modules. Reply-To: myungjoo.ham@samsung.com From: MyungJoo Ham To: "akhilpo@codeaurora.org" , Ezequiel Garcia CC: Enric Balletbo i Serra , "linux-kernel@vger.kernel.org" , "kernel@collabora.com" , Chanwoo Choi , Kyungmin Park , "linux-pm@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <7c67974e40afd15abfca5907b27de097@codeaurora.org> X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20180703104749epcms1p473b2160f6e2bbe3c6b87827b30e8473b@epcms1p4> Date: Tue, 03 Jul 2018 19:47:49 +0900 X-CMS-MailID: 20180703104749epcms1p473b2160f6e2bbe3c6b87827b30e8473b Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-CPGSPASS: Y X-CPGSPASS: Y CMS-TYPE: 101P X-Brightmail-Tracker: H4sIAAAAAAAAA12Sa0hTYRjHeXd2OZNmb9PsRSPXAQMLp2c2d7KsII1VBoLRByXsoKdNcpd2 NlO/NJVu5m0rTJaWs6iwKLXUk0bRigpq+6DdLIwuEwk1jWkYFrWbGX16f/zf/3PlwTGpXRiL F+vNjElPlxDCCH7vw0R50t49G/NTmqYFlKN+VEh9cSVSr2fGBNT1dy5A3emcEVG3PLUCyl01 IaKG+luElK/uEdgqVg/V1/HU3MgloK6/3QHUvu5VOfw8ZpOWoYsYk4zRFxqKivWaDGJXbsG2 AmVaCplEbqBUhExP65gMIjM7J2l7cYm/FUJWSpdY/FIOzbJE8uZNJoPFzMi0BtacQeSTpEJO pqjkCoX/Td2XrlD6LfsZ7Zi9X2isW1JW/d4msgKPuAaIcQTXI5fbJqwBEbgUcgA1zFRiNQDH JXAZ+sVFBTxRUIMefHTyAiyFBLIO38NCejI68aEXBFgIk1BP5wg/wNGQRtXf7IJATgz28VDv 9DVeqJgENR8f5Yc4DvVd6QkGi+FmdPRnjyikL0fD1yb/8tTjCyDE0ejoezcW4mXow4+BsB6L vJPOsP8Ieu1r5wUKI9gI0Pyb3+GPZPTpxTlhgCVwN/Ie44I6HyagienmcKJMNGg9FfRgMB71 TbYEF4HBRHSzP3mhf2vXvOh/xmAk+jpbK1jQufPe8LxrkGvgUti/Ej076wymRFCNbNO6RrDa sbhpxz91HYt12wDWAWIYI6vTMCxpJOUsrWMteo280KDrBsF7XKvkwBlPtgtAHBBLJGXx6flS AV3KlutcAOEYES3pTfBLkiK6vIIxGQpMlhKGdQGlf3wbFru80OC/br25gFQqUlNTqfVkmpIk iRWSsmGYL4Ua2swcZBgjY1qI4+HiWCtom2g0tuY+2ZnmzrrVcCOC4xwnq+0SsmX8gOeQZibm 3tJ1Oy52FIPTW+bnTLaX9iq7+e1oYuusbCCrVTXYbqi82hQ9pSVq7/oiYx55nCMVeZcj7a+c KncpkXtFrbLo7ntvrtttPMbN7csb801in+Oior53j8c/V3SBp28Ot1wl+KyWJtdiJpb+Aw1w OwqlAwAA DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180622212233epcas2p3308116579442dc8a42a9db7445ce8ef8 References: <7c67974e40afd15abfca5907b27de097@codeaurora.org> <20180621220430.25644-1-enric.balletbo@collabora.com> <0383b4a703a0b619023c0654a4a7637419c72ebd.camel@collabora.com> <1e792d3c972998f92109c127886243e32c4cde71.camel@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > >> Adding to Ezequiel's point, shouldn't we take more granular lock > >> (devfreq->lock) first and then call devfreq_list_lock at the time of > >> adding to the list? > >> > > > > Not sure why we should do that. devfreq->lock should be used to > > protect the struct devfreq state, while the devfreq_list_lock > > is apparently protecting the two lists (which seem unrelated > > lists). Correct. devfreq->lock protects an instance of devfreq. devfreq_list_lock protects the global devfreq data (list of devfreq / governors) > > > > So, the two locks are not correlated. > > > > Regards, > > Eze > In governor_store(), we do 'df->governor = governor;' without taking > df->lock. So it is possible to switch governor while update_devfreq() is > in progress. Yup. that's possible. > I smell trouble there. Don't you think so? > I am assuming df->lock protects 'struct devfreq' and devfreq_list_lock > protects both device and governor lists. devfreq_list_lock is not supposed to protect a device. Assuming a memory read of a word is atomic (I'm not aware of one that's not unless in a case where the address is unaligned in some archtectures), update_devfreq won't cause such issues because it reads "devfreq->governor" only one in its execution except for the null check. Thus, if there could be an error, it'd be a case where someone else is doing "devfreq->governor = NULL" without devfreq->lock. And, find_devfreq_governor() does not return NULL. Cheers, MyungJoo > > -Akhil. >