Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1109846imm; Wed, 1 Aug 2018 10:20:17 -0700 (PDT) X-Google-Smtp-Source: AAOMgpevjytg1+ok4JB38YL7udiAYozaC5V8MZLmdGibJSpDYnpW1zWzy9Nr3LcJsyuE/cK0ZsmG X-Received: by 2002:a65:5141:: with SMTP id g1-v6mr25245650pgq.418.1533144017120; Wed, 01 Aug 2018 10:20:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144017; cv=none; d=google.com; s=arc-20160816; b=XnvglJGZeApKv6iv1qqzKl3yN0w9UZ6k42qpaF+zVj3a8vknuQVIBSp+F0oeRV16lf ndkldR9WfZjtS4Fe988URomhchH7d9yh5StnSw0YJ+f1D5Qaps8zxHRlLRKL90q/U8rh hy6YQFZpaf84gJpFv9gOewpgNkCgarHHa5Ql8nA/2XSj7FWS22I9tBia0w5XoFvJhAxX VAy5Edq6T2u+axGlcrKYugC868/T4Bi34qWC0tzdjsIQIiQrDC8Vr5hswAlws90VVV+O LldK4tZVnvKkVzWjyteOhObQ5VFDhFUnvopZ8Tedq1O6J//WplEMIFoBV/WdmGYpBDeT pXuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=89uBHxu/kfQfe/TZJ6c8QvSSBcbTN0vkU5yEIyvApIA=; b=ovJWf+R7YyD7KAjkWmDS47O2XMNI/MX9VswPsYateJHujCii40Yv6YkV9LVvfFf28a EBEE3k3CNxQ+GI6Yh5qiiRxQmqsMJ7va35NL8UzJ0N5YJZNPI5jrz0NEqEwD7YBHHMBu jvURwNZyst+KwXXN9GnUEKSHxUt/4CEjQtMYrLC2gjPwrkhDYF4MP0DgzSW49JEixH+y WswxmAr1hAQIcn0UslieuN55pZqG7bZqdcowHJ7dVJvopVQzmYv7eGd5JxUsIABvRRhP GdBpjwbaIsfUYqPE+xucJDbWFFaHwEso1oXLa53JU8zXKASLhX3s9FwBLQ2jg6dS492F JKRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=CE2us6i7; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d11-v6si16118444plr.261.2018.08.01.10.20.02; Wed, 01 Aug 2018 10:20:17 -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=@chromium.org header.s=google header.b=CE2us6i7; 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=REJECT sp=REJECT dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404961AbeHATFJ (ORCPT + 99 others); Wed, 1 Aug 2018 15:05:09 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:33182 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404951AbeHATFI (ORCPT ); Wed, 1 Aug 2018 15:05:08 -0400 Received: by mail-pf1-f193.google.com with SMTP id d4-v6so7953449pfn.0 for ; Wed, 01 Aug 2018 10:18:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=89uBHxu/kfQfe/TZJ6c8QvSSBcbTN0vkU5yEIyvApIA=; b=CE2us6i7zs7HmGN5xPznQp2MJV+K0Lhi3eYdjhRq9XchZS63wBqUSXJLdDipDx2lqo QGIr1tUe6K91yRB12Ny5YJpYrnNYall0XgICNoiHwLVFzlx7d3rAeAm4+mgrDA/X1Wou TDomczY/e5TuhzdcqvCn1n8LUaqjRQttl5knM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=89uBHxu/kfQfe/TZJ6c8QvSSBcbTN0vkU5yEIyvApIA=; b=hlKb5vYBqAptRYQT7Ebo0PAsJ2KkhfyoYMf+M7NSK9DlducKmuIgfpM4y7lLHVixiy qsb2DATLqJ5PF99NvgPSUj8z1UoR8qlUDKWaZkfn5D+NbLeWcfSkVBujaWwKbOvds9de ve+VVpOmmeJYCzJ/uN0nBpwvZST5/+WFpjsuYTJLhGFPUHD8u36Rt76S3KVwkoM9w22J qdBthoZutmjGlGTE762E5qd13z56bW850O8wYYCKFELI8eVlKMiqzOZuOpT6ZFPPPThF NGSBMAjooMevWScDMzxstV3rmHaASXGmbxYpRorFdkVZKGjEMaXMv4zCSlk4CwarZVVl g5yw== X-Gm-Message-State: AOUpUlHqBGl42usLwMigp7FfkHP1pQ2+LhCcfE2FVAls7etMT3QCpgaU Cr/svIgvtNPX+8Jkj/Xi6yg2cg== X-Received: by 2002:a62:68c3:: with SMTP id d186-v6mr8623984pfc.70.1533143908044; Wed, 01 Aug 2018 10:18:28 -0700 (PDT) Received: from localhost ([2620:15c:202:1:b6af:f85:ed6c:ac6a]) by smtp.gmail.com with ESMTPSA id v22-v6sm44395411pfi.60.2018.08.01.10.18.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 10:18:27 -0700 (PDT) Date: Wed, 1 Aug 2018 10:18:26 -0700 From: Matthias Kaehlcke To: Chanwoo Choi Cc: MyungJoo Ham , Kyungmin Park , 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 , Enric Balletbo i Serra , "Rafael J . Wysocki" , Viresh Kumar , Lee Jones , Benson Leung , Olof Johansson Subject: Re: [PATCH v5 07/12] PM / devfreq: export devfreq_class Message-ID: <20180801171826.GK68975@google.com> References: <20180703234705.227473-1-mka@chromium.org> <20180703234705.227473-8-mka@chromium.org> <5B3C5B78.6020401@samsung.com> <20180706180923.GH129942@google.com> <41164a91-b271-5f3b-b461-21ff5997cc84@samsung.com> <20180716194114.GA129942@google.com> <20180731192904.GG68975@google.com> <5B616CE0.50400@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5B616CE0.50400@samsung.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 01, 2018 at 05:18:40PM +0900, Chanwoo Choi wrote: > Hi Matthias, > > On 2018년 08월 01일 04:29, Matthias Kaehlcke wrote: > > On Mon, Jul 16, 2018 at 12:41:14PM -0700, Matthias Kaehlcke wrote: > >> Hi Chanwoo, > >> > >> On Thu, Jul 12, 2018 at 06:08:36PM +0900, Chanwoo Choi wrote: > >>> Hi Matthias, > >>> > >>> On 2018년 07월 07일 03:09, Matthias Kaehlcke wrote: > >>>> Hi, > >>>> > >>>> On Wed, Jul 04, 2018 at 02:30:32PM +0900, Chanwoo Choi wrote: > >>>> > >>>>> I didn't see any framework which exporting the class instance. > >>>>> It is very dangerous. Unknown device drivers is able to reset > >>>>> the 'devfreq_class' instance. I can't agree this approach. > >>>> > >>>> While I agree that it is potential dangerous it is actually a common > >>>> practice to export the class: > >>>> > >>> > >>> I tried to find the real usage of exported class instance > >>> and I add the comment for each class instance. Almost exported class > >>> instance are used in the their own director or some exported class > >>> like rio_mport_class/switchtec_class are created from specific device driver > >>> instead of subsystem. > >>> > >>> Only following two cases are used on outside of subsystem directory. > >>> devtmpfs.c and alarmtimer.c are core feature of linux kernel. > >>> > >>> drivers/base/devtmpfs.c uses 'block_class'. > >>> kernel/time/alarmtimer.c uses 'rtc_class'. > >>> > >>> I cannot yet agree this approach due to only block_class and rtc_class. > >> > >> I thought your main concern was that the class is exported, which is > >> what several other subsystems do. That the class isn't used outside of > >> the subsystem directory most likely means that there is no need for > >> it, rather than that it shouldn't be done at all (depending on the > >> type of use of course). > >> > >> In any case not exporting the class object provides a limited > >> protection against potential abuse of the class at best. To use the > >> class API all that is needed is a 'struct device' of a devfreq device, > >> which has a pointer to the class object (dev->class). > >> > >> Theoretically I could register a fake devfreq device to obtain access > >> to the class object, though that doesn't seem a very neat approach ;-) > >> > >>> You added the following comment why devfreq_class instance is necessary. > >>> Actullay, I don't know the best solution right now. But, all device drivers > >>> can be added or removed if driver uses the module type. It is not a problem > >>> for only devfreq instance. > >> > >> Certainly it's not a problem limited to devfreq devices. In many other > >> cases bus notifiers can be used, but since devfreq devices areen't > >> tied to a specific bus this is not an option here. > >> > >> If you really don't want to export the class we could add wrappers > >> for (un)registering a class interface: > >> > >> int devfreq_class_interface_register(struct class_interface *) > >> void devfreq_class_interface_unregister(struct class_interface *) > > About this approach, I agree because it doesn't export the devfreq_class > instance as you commented. Great, I'll change it in the next revision!