Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1859341rdb; Mon, 9 Oct 2023 05:28:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtnqUNgTxtosNoqRUtS+BkkuyUl2sX9DEgNUQGoLcVXsVgjw9cwtrLzghTsUh+dVrUwRob X-Received: by 2002:a05:6a00:a92:b0:68e:399e:70db with SMTP id b18-20020a056a000a9200b0068e399e70dbmr14912047pfl.6.1696854507109; Mon, 09 Oct 2023 05:28:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696854507; cv=none; d=google.com; s=arc-20160816; b=ItQa2yyOyhcpRgPO6pFV51Fzd0rj7XsReHZeWPdfysHCd9wBy3apFGBVk31KiT6ZMi xLiFhKE2b2illlIDMzF6Zs5/MRV2Bb1H+zdRKYoCvsHHvpsNT02IHbo8W8OaUcJeuPmm lxTU2xMYH6Dtalhh8W43lNR/JobOhTeD2G7H6N3iQc6SH3v6Y0ue/3cyfUPgOI5i6xnl epXi09IcHtvsQ/IY06ghWwBjE91T3hFJCyH9zlKxxxwUNdzQvYiHSv5ak0VR50hjiNTS 0pKGUdzra0W5/U62HskyhyRFW/3XUxf50nmzan1RoZ+2g1hxzfbcByxpCeV80Fvs8BRR RZKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=OMPSiYd2lliTf337PU92V67VODQICk152Z+qImwpBfI=; fh=EhOvddInBVHobvwuJh2BzcCSN6QTiJoasIVRoSVpGtU=; b=OaRkW9E7FFpK4WfN23fLzRB/BdlVCmKcIBRvX/TsuvxXpmDV/m0B1sucMG6Eh+UGdC U3f9+S3F4xglu6GdMwkqNIAskom4FGwTUGornr1Sw48Bpyg+xif+uQewI3n2bsODPbiE a+9uo8HnNnyYV2/pTGR4oHH/Twjp269kv9M8uuK1v4PFIW8iNwttOPUL/JAdWGcOb93q iH+KC/r7ef+sE1bCXVWM7OOZCWrlQNLGQcO3Ea5pFWjltUuf3Q5UeijMc0JzTNJb/NNI 1zU1W1sdsZvP5avHJg9BVBcY6p5v+mX+vN/xtkqmo1MoYxRwHT9fnLfbIFgN9/TYhcU2 JFlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id x127-20020a636385000000b00585a4fc83f9si8999090pgb.291.2023.10.09.05.28.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 05:28:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 3B18880A97E0; Mon, 9 Oct 2023 05:28:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376349AbjJIM2A convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Oct 2023 08:28:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346554AbjJIM17 (ORCPT ); Mon, 9 Oct 2023 08:27:59 -0400 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C62AACA; Mon, 9 Oct 2023 05:27:56 -0700 (PDT) Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-57b83ff7654so267106eaf.1; Mon, 09 Oct 2023 05:27:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696854476; x=1697459276; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aEFOPfZ+WmfDKLy1rOdw40S5bHAGj56vhBWEOoNahLc=; b=LEp5VgFt4I8onQp75e7ILxHLsgvZpG/bKqi1vpgQn1H4DQDZLcclNjtV6Zi0+ThBpp 7lj1pguc9Nwc0FetLc5MVcsTJUmLytsJt2uqckBIEbg9rYSeBrlg51HNrgRIsh9vsTeK 16mQpGdjrLLcnQH7rApVVeWIoIUxTDQTb3DBMnz4e0Y3vbO3QxQBYFkh2i5qoB87OI2C NmzRtD5+iJBBeWi253q8aQj4eSHxONJ9Vqlf1WXrmaV64JvR4Uy3g8GCV2nxDcHUUwOX ZPw/mlykJSPO8VShrEBSNsIaWWGIGsRHN/KcQflwMC8Bn/8BkDTKkYD2z7aw9dapo6GR 4yMw== X-Gm-Message-State: AOJu0YxqhvBupU5nF0koUVq4YdaZFnjD5r6m6saYgus0tqSiV/3a+Cku wZLTIPJitC09a/siJS1pWM2FM1f9MFbikJ3zESs= X-Received: by 2002:a4a:b588:0:b0:578:c2af:45b5 with SMTP id t8-20020a4ab588000000b00578c2af45b5mr12916582ooo.0.1696854475961; Mon, 09 Oct 2023 05:27:55 -0700 (PDT) MIME-Version: 1.0 References: <20231006173055.2938160-1-michal.wilczynski@intel.com> <20231006173055.2938160-4-michal.wilczynski@intel.com> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 9 Oct 2023 14:27:43 +0200 Message-ID: Subject: Re: [PATCH v2 3/6] ACPI: AC: Replace acpi_driver with platform_driver To: "Wilczynski, Michal" Cc: "Rafael J. Wysocki" , Andy Shevchenko , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, nvdimm@lists.linux.dev, rafael.j.wysocki@intel.com, lenb@kernel.org, dan.j.williams@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=2.6 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 09 Oct 2023 05:28:24 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 9, 2023 at 10:40 AM Wilczynski, Michal wrote: > > > Hi ! > > Thanks a lot for a review, to both of you ! :-) > > On 10/7/2023 12:43 PM, Rafael J. Wysocki wrote: > > On Sat, Oct 7, 2023 at 12:41 PM Rafael J. Wysocki wrote: > >> On Sat, Oct 7, 2023 at 9:56 AM Andy Shevchenko > >> wrote: > >>> On Fri, Oct 06, 2023 at 09:47:57PM +0200, Rafael J. Wysocki wrote: > >>>> On Fri, Oct 6, 2023 at 8:33 PM Michal Wilczynski > >>>> wrote: > >>> ... > >>> > >>>>> struct acpi_ac { > >>>>> struct power_supply *charger; > >>>>> struct power_supply_desc charger_desc; > >>>>> - struct acpi_device *device; > >>>>> + struct device *dev; > >>>> I'm not convinced about this change. > >>>> > >>>> If I'm not mistaken, you only use the dev pointer above to get the > >>>> ACPI_COMPANION() of it, but the latter is already found in _probe(), > >>>> so it can be stored in struct acpi_ac for later use and then the dev > >>>> pointer in there will not be necessary any more. > >>>> > >>>> That will save you a bunch of ACPI_HANDLE() evaluations and there's > >>>> nothing wrong with using ac->device->handle. The patch will then > >>>> become almost trivial AFAICS and if you really need to get from ac to > >>>> the underlying platform device, a pointer to it can be added to struct > >>>> acpi_ac without removing the ACPI device pointer from it. > > Yeah we could add platform device without removing acpi device, and > yes that would introduce data duplication, like Andy noticed. But he hasn't answered my question regarding what data duplication he meant, exactly. So what data duplication do you mean? > And yes, maybe for this particular driver there is little impact (as struct device is not > really used), but in my opinion we should adhere to some common coding > pattern among all acpi drivers in order for the code to be easier to maintain > and improve readability, also for any newcomer. Well, maybe. But then please minimize the number of code lines changed in this particular patch and please avoid changes that are not directly related to the purpose of the patch. > >>> The idea behind is to eliminate data duplication. > >> What data duplication exactly do you mean? > >> > >> struct acpi_device *device is replaced with struct device *dev which > >> is the same size. The latter is then used to obtain a struct > >> acpi_device pointer. Why is it better to do this than to store the > >> struct acpi_device itself? > > This should be "store the struct acpi_device pointer itself", sorry. > > Hi, > So let me explain the reasoning here: > > 1) I've had a pleasure to work with different drivers in ACPI directory. In my > opinion the best ones I've seen, were build around the concept of struct > device (e.g NFIT). It's a struct that's well understood in the kernel, and > it's easier to understand without having to read any ACPI specific code. > If I see something like ACPI_HANDLE(dev), I think 'ah-ha - having a struct > device I can easily get struct acpi_device - they're connected'. And I think > using a standardized macro, instead of manually dereferencing pointers is > also much easier for ACPI newbs reading the code, as it hides a bit complexity > of getting acpi device from struct device. And to be honest I don't think there would > be any measurable performance change, as those code paths are far from > being considered 'hot paths'. So if we can get the code easier to understand > from a newcomer perspective, why not do it. I have a differing opinion on a couple of points above, and let's make one change at a time. > > 2) I think it would be good to stick to the convention, and introduce some coding > pattern, for now some drivers store the struct device pointer, and other store > acpi device pointer . As I'm doing this change acpi device pointer become less > relevant, as we're using platform device. So to reflect that loss of relevance > we can choose to adhere to a pattern where we use it less and less, and the > winning approach would be to use 'struct device' by default everywhere we can > so maybe eventually we would be able to lose acpi_device altogether at some point, > as most of the usage is to retrieve acpi handle and execute some AML method. > So in my understanding acpi device is already obsolete at this point, if we can > manage to use it less and less, and eventually wipe it out then why not ;-) No, ACPI device is not obsolete, it will still be needed for various things, like power management and hotplug. Also, I'd rather store a struct acpi_device than acpi_handle, because the latter is much better from the compile-time type correctness checks and similar. I can send my version of the $subject patch just fine if you strongly disagree with me.