Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp694217ybz; Fri, 24 Apr 2020 07:45:14 -0700 (PDT) X-Google-Smtp-Source: APiQypL0K+ZtYD75zPrIi8qKfZh3DUH+xxjvI3YQAcKsq8hzM8IV2nDp2x4UIeSte0KSnTU7/FyC X-Received: by 2002:a50:c20a:: with SMTP id n10mr7930181edf.319.1587739514241; Fri, 24 Apr 2020 07:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587739514; cv=none; d=google.com; s=arc-20160816; b=cYWyjOurPD/q8ORHw320bkhJbOMVAHSHxIMulDieqjEOAXz7Lo9AqfNnTp3OvFdEuw 8fjwa8SinzRMuFLpU9Dpq1a7LCYFl5HEOcbDQmNsVN41JgbKV1ingh+nd9h/Qjl1Guz7 8Gwr5FcHedH16ocHGRu4NkartytSFtS4sDr4KQ4BqW298LPXLYdCT9Ah7JAzYZUgdHfc iXCRr7Iksr7XLIOXZZL1HBmYf0Ztzlx6Qh8kcQuDMJZ75ryfaxfEjnTfYYl90zTKjIOT ILlw331kNi/sPda4w/mETtoiWQ1Fjm+1Z64sYqxJI2Fgymqgg5Xw1S5/F9k+32TbbUHS mq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=/heGT90Bbkm45xRxGs1TUT/SyPY8oqXx7ZkKO5wAAfo=; b=Ydige26g9+t1juP+1hGxbU2+vkbMlhAJolenP2lpa2Q5QwjiRBBd08Awwm3zD6HTN1 3SiaSIywCkM86ZeFntbtWJER0AvDZ2NRwWYel+mFFaRGORJGBeFfNpG7oIbx0F3bekOH jpuLAHKo2DRucM3vE4BLIlIX93t47un1kjAPvI5ONxn3q3NajLVtOsb4DpQvd2Hn6Jvq Y/4dIu8FWv74KMPXmmtkHSv1u2LBZClppxAqWLLvbh4pr+Lpa7XVPmmwQPcLbTUvTDaG bFJ9a+NQ6k3ZxohcfKHF8GHcVFNkEXVMXMwUPwvvA9IH/kNMqUKCposJAIeIBUZskhYu fXnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cw6si2988156edb.552.2020.04.24.07.44.49; Fri, 24 Apr 2020 07:45:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbgDXOnR (ORCPT + 99 others); Fri, 24 Apr 2020 10:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726813AbgDXOnR (ORCPT ); Fri, 24 Apr 2020 10:43:17 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB9ABC09B045; Fri, 24 Apr 2020 07:43:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 11E072A2E13 Subject: Re: [PATCH v4] platform: x86: Add ACPI driver for ChromeOS To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, "Rafael J . Wysocki" , Len Brown , Collabora Kernel ML , groeck@chromium.org, bleung@chromium.org, dtor@chromium.org, gwendal@chromium.org, vbendeb@chromium.org, andy@infradead.org, Ayman Bagabas , Benjamin Tissoires , =?UTF-8?Q?Bla=c5=be_Hrastnik?= , Darren Hart , Dmitry Torokhov , Hans de Goede , Jeremy Soller , Mattias Jacobsson <2pi@mok.nu>, Mauro Carvalho Chehab , Rajat Jain , Srinivas Pandruvada , platform-driver-x86@vger.kernel.org References: <20200413134611.478441-1-enric.balletbo@collabora.com> <20200413141259.GA3458877@kroah.com> From: Enric Balletbo i Serra Message-ID: <0f3d5b72-8ff2-ce9c-e4d5-e8e301aece9f@collabora.com> Date: Fri, 24 Apr 2020 16:43:09 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200413141259.GA3458877@kroah.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, Thank you for your comments, some answers below. On 13/4/20 16:12, Greg Kroah-Hartman wrote: > Meta-comment to the ACPI developers, shouldn't all of this happen > "automatically" with the existing ACPI entries in sysfs? If not, is > this driver the proper way to do this? > This is something maintainers didn't answer yet, and I am not sure, to be hones, but meanwhile, I'll rework this driver fixing the Greg comments and send a new version. > Minor review comments below: > > > On Mon, Apr 13, 2020 at 03:46:11PM +0200, Enric Balletbo i Serra wrote: >> +What: /sys/bus/acpi/devices/GGL0001:00/BINF.{0,1,4} >> +Date: April 2020 >> +KernelVersion: 5.8 >> +Description: >> + This file is reserved and doesn't shows useful information >> + for now. > > Then do not even have it present. sysfs should never export files that > nothing can be done with them, userspace "knows" that if a file is not > present, it can not use it. Bring it back when it is useful. > Makes sense. I'll do in next version. >> +What: /sys/bus/acpi/devices/GGL0001:00/MECK >> +Date: April 2020 >> +KernelVersion: 5.8 >> +Description: >> + This binary file returns the SHA-1 or SHA-256 hash that is >> + read out of the Management Engine extend registers during >> + boot. The hash is exported vi ACPI so the OS can verify that >> + the Management Engine firmware has not changed. If Management >> + Engine is not present, or if the firmware was unable to read the >> + extend registers, this buffer can be zero. > > The size is zero, or the contents are 0? > The size. I'll reword in the description, >> +static char *chromeos_acpi_alloc_name(char *name, int count, int index) >> +{ >> + char *str; >> + >> + if (count == 1) >> + str = kstrdup(name, GFP_KERNEL); >> + else >> + str = kasprintf(GFP_KERNEL, "%s.%d", name, index); > > That's crazy, make this more obvious that "count" affects the name so > much. As it is, no one would know this unless they read the function > code, and not just the name. > I see, let me think about this. > >> +/** >> + * chromeos_acpi_add_group() - Create a sysfs group including attributes >> + * representing a nested ACPI package. >> + * >> + * @adev: ACPI device. >> + * @obj: Package contents as returned by ACPI. >> + * @name: Name of the group. >> + * @num_attrs: Number of attributes of this package. >> + * @index: Index number of this particular group. >> + * >> + * The created group is called @name in case there is a single instance, or >> + * @name.@index otherwise. >> + * >> + * All group and attribute storage allocations are included in the lists for >> + * tracking of allocated memory. >> + * >> + * Return: 0 on success, negative errno on failure. >> + */ > > Meta-comment, no need for kerneldoc on static functions. It's nice to > see, but nothing is going to notice them... > >> +static int chromeos_acpi_add_method(struct acpi_device *adev, char *name) >> +{ >> + struct device *dev = &adev->dev; >> + struct acpi_buffer output; >> + union acpi_object *obj; >> + acpi_status status; >> + int ret = 0; >> + >> + output.length = ACPI_ALLOCATE_BUFFER; >> + >> + status = acpi_evaluate_object(adev->handle, name, NULL, &output); >> + if (ACPI_FAILURE(status)) { >> + dev_err(dev, "failed to retrieve %s (%d)\n", name, status); >> + return status; >> + } >> + >> + obj = output.pointer; >> + if (obj->type == ACPI_TYPE_PACKAGE) >> + ret = chromeos_acpi_handle_package(adev, obj, name); >> + >> + kfree(output.pointer); > > Why the need for 'obj' at all in this function? Minor nit. > Ok, I'll remove obj. >> + >> + return ret; >> +} >> + >> +static int chromeos_acpi_device_add(struct acpi_device *adev) >> +{ >> + struct chromeos_acpi_attribute_group *aag = chromeos_acpi.root; >> + struct device *dev = &adev->dev; >> + int i, ret; >> + >> + aag = kzalloc(sizeof(*aag), GFP_KERNEL); >> + if (!aag) >> + return -ENOMEM; >> + >> + INIT_LIST_HEAD(&aag->attribs); >> + INIT_LIST_HEAD(&aag->list); >> + INIT_LIST_HEAD(&chromeos_acpi.groups); >> + >> + chromeos_acpi.root = aag; >> + >> + /* >> + * Attempt to add methods by querying the device's MLST method >> + * for the list of methods. >> + */ >> + if (!chromeos_acpi_process_mlst(adev)) >> + return 0; >> + >> + dev_info(dev, "falling back to default list of methods\n"); > > Is this debugging code left over? If not, make it an error, and what > would a user be able to do with it? > I think I can downgrade to debug level. Thanks, Enric > thanks, > > greg k-h >