Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2604863pxb; Sun, 17 Oct 2021 20:16:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmgIvjhn5Pget6fMLe0YnHbBaK8FeKCsqamQm3S47a0e2Rq1FcI0X1yo/cQVLqGnEd7LgL X-Received: by 2002:a17:90b:4d8e:: with SMTP id oj14mr30249280pjb.160.1634526986178; Sun, 17 Oct 2021 20:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634526986; cv=none; d=google.com; s=arc-20160816; b=O01xLCsNxuvG7PKX+0NBgcbLtJrGZve7MYy+dbu1I0OHaUmZ8Dr1mc80j1OKRClRmX ha23Yddkxd62TzVUHkITqbjHQuce9wifp8MhWWgymSIU/nfwwPGkUf7NGnWmZtLzu5UJ /uBtLRkasMaR/i6yxXL6ndvBmOKx0ZjigrjwNImlA+craEE7FAoALkiwF0TM/p1WyRsD 0I5qtzHWlguN7kUaOEyq/SBfGJqEw7eP2eieKWs8GMUB/GkutktqBnNhddr2Kpa0YMeD xbeMMZt01dglQ8UCCVYVOOmqc1kMACVn/zUn1xdrjBHmH5dmzWMIGLhvn7ORZs9G0UAx rufQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5p9kKbMM5GPGN62Fe6nlzRORBpkc2DIilK9tSN34G3E=; b=S9RFkaJsQNsBbeNOpjmb+XGeIU8wAGtYF8ZF/08FO8G5pEs1X4CHE5OjTf+grKu9ZB vPx0qPOf/3PKvB73nKN1nTE1wA7vO0uik9emhZ8GBJ747+xY3WQVmyVfC5/gvNLoa+T8 xlBlpWi+qKh5oh50I1PK4934W8DuiRB5Q7rIRVAJq0l7u4LqaJnkLCIl76kuSffUcSY5 78BDRbE3/kAhK+iw8cvq/Wfhqi84nQO5RNr4I5qA0X/+8BpAI8AWsaYIkCI6S2GjGDKT ViiQXsSP9pAvV3l/O4oc61BY2RgriRnIXMab5TrZsCwR3gS5NVRp9QtiRAG/ih+VHtJC OprA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OdvqBCvi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h3si18888839pgp.521.2021.10.17.20.16.14; Sun, 17 Oct 2021 20:16:26 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OdvqBCvi; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243350AbhJOWbT (ORCPT + 98 others); Fri, 15 Oct 2021 18:31:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:42760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235751AbhJOWbS (ORCPT ); Fri, 15 Oct 2021 18:31:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B73FE6115C; Fri, 15 Oct 2021 22:29:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634336951; bh=TQtRtLYNlFE/GQNWGHE6FL49bQNWg/4TcBK38kMyEcE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=OdvqBCvilrxB5rg9TaeamtdhCRox0HpwskMXhsphnvc8PFUZGtmpsu1AMs2gF0wGA 9YbLmc+sy5PqGzjPYGxE5N8j3btU3CYGreT7U6rr0J8kGJsi0k7C4g7XDY79WIj8SC X4V3+fTgQxB9FRxot1OBSbzaVd1IiLGDS13cJj0LkVWA1nzN2HqHnsfI9/uQJBGDlg IGPDilW56TCaxYQa/EkCkyG7N5A+jk31n9n5ovfpDLKLInpH7NgYcgvyXQI9C3p/fg 9LZj9zgxlhoEvuSNjtRnEfXsvvXsgGg1TCleGikg4tBdzfiMNovhH4+q1XNOdgPnkL e0plAGH1ltXhA== Date: Fri, 15 Oct 2021 23:29:08 +0100 From: Mark Brown To: Hans de Goede Cc: "Rafael J . Wysocki" , Mark Gross , Andy Shevchenko , Daniel Scally , Laurent Pinchart , Mauro Carvalho Chehab , Liam Girdwood , Michael Turquette , Stephen Boyd , Len Brown , linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, Sakari Ailus , Kate Hsuan , linux-media@vger.kernel.org, linux-clk@vger.kernel.org Subject: Re: [PATCH 05/12] regulator: Introduce tps68470-regulator driver Message-ID: References: <843f939a-7e43-bc12-e9fc-582e01129b63@redhat.com> <1805d16e-87ab-c291-6a73-adabf41344ca@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="F/jmgXxh9qwDNeFa" Content-Disposition: inline In-Reply-To: <1805d16e-87ab-c291-6a73-adabf41344ca@redhat.com> X-Cookie: 1: No code table for op: ++post Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --F/jmgXxh9qwDNeFa Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 15, 2021 at 10:14:30PM +0200, Hans de Goede wrote: > On 10/15/21 9:59 PM, Mark Brown wrote: > > No, it's not. What normally happens is that whatever registers the > > device will when registering the device supply platform data that the > > device later picks up from the struct device during probe. What you're > > saying is that the idea here is that driver unconditionally declares > > platform data and then other code scribbles over that before the driver > > instantiates. This is cleaner in that it keeps the platform Actually, correction - there's no export of tps68470_init[] so I guess that's just the data that gets used :/ > > configuration together and safer since the device can't exist before > > it's configuration is provided. > Right, this is the standard device-tree model. Unfortunately the > information about which supplies are needed and the constraints > for those supplies is missing from the ACPI description for the > devices which we are dealing with here. That's not just the standard device tree model, that's how systems with board files work too. > During that discussion you said that instead we should sinmply > directly pass the regulator_init_data, rather then first > encoding this in device-properties in a swnode and then > decoding those again in the regulator core. > And passing the regulator_init_data is exactly what we are doing > now; and now again this is not what we should be doing ? No, it is not what the driver doing now. The driver will *optionally* check for platform data, but if none is provided or if it doesn't configure some of the regulators then the driver will provide some hard coded regulator_init_data as a default. These might be OK on the system you're looking at but will also be used on any other system that happens to instantiate the driver without platform data where there's no guarantee that the information provided will be safe. These defaults that are being provided may use the same structure that gets used for platform data but they aren't really platform data. Yes, someone could use this on a system that does things in the standard fashion where the platform data is getting passed in but if it's ever run on any other system then it's going to assume this default platform data with these constraints that have been embedded directly into the driver without anything to ensure that they make sense on that system. Indeed, now I go back and dig out the rest of the series it seems that there's some drivers/platforms/x86 code added later which does in fact do the right thing for some but not all of the regulators, it supplies some platform data which overrides some but not all of this default regulator_init_data using platform_data having identified the system using DMI information (with configurations quite different to and much more restricted than the defaults provided, exactly why defaults are an issue). I'm now even more confused about what the information that's there is doing in the driver. Either it's all unneeded even for your system and should just be deleted, or if any of it is needed then it should be moved to being initialised in the same place everything else is so that it's only used on your system and not on any other system that happens to end up running the driver. In any case given that your platform does actually have code for identifying it and supplying appropriate platform data the driver itself can be fixed by just deleting the else case of if (pdata && pdata->reg_init_data[i]) config.init_data = pdata->reg_init_data[i]; else config.init_data = &tps68470_init[i]; and the data structure/macro it uses. If no configuration is provided by the platform then none should be provided to the core, this in turn means that the regulator framework won't reconfigure the hardware if it doesn't know it's safe to do so. > Also note that the current solution is exactly what I suggested > we should do during the discussion with Daniel and I even provided > example code and you said absolutely nothing about this! I had been under the impression that the platform data would look like normal platform data and come along with the device registration, providing default regulator_init_data hadn't really occurred to me. > And please keep in mind that we *cannot* change the ACPI firmware interfaces > and that whether we like it or not things simply work different in the ACPI > world. > Frankly I'm quit unhappy, angry even about how you are blocking progress > here. You don't like APCI we get it, can we get over that now please? ACPI is fine, we have a bunch of perfectly good ways to handle things that need quirking on it safely - both platform_data and DMI quirks can and do work well here. The issue is that we should be using those things rather than inventing new things unless those new things solve a problem. > So far all you seem to be doing is shooting down solutions, then first > being quiet about suggested alternative solutions and then once the > alternative solutions are implemented shoot them down again... > And all that without adding anything constructive. All you have > told us is how things should not be done (according to you). > So fine everything we come up is wrong, please tell us how we should > solve this instead then! The important thing is to get rid of the hard coded defaults for the regulator_init_data in the driver itself, if there is regulator_init_data in the driver itself then it should be guarded with a DMI or similar quirk. Like I say above I think now I've gone back and dug through the rest of the series once the default init_data is gone it's probably OK. --F/jmgXxh9qwDNeFa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmFqALMACgkQJNaLcl1U h9B5aQgAhQ7bqrNnhCcHborjeRwONxMdsrv6cyyt5sQlX5QAkjsYkIsE6OJfdwPM vHFJhWNXVJxfixf0+HRxF0ROwDSxjE+YOhuAnfxi61RWXx1aLkovdK9kBjVcRP3Y +WAgoVItgQ5PZkaL5x8+EvGDlAAmqjauL2EstgBYLoIA4jO9DW0jUoBEISyTlngS GXw+3CGX0mKpIADv8UCCjVKFZ4gXerXRroZD6tMqS1rV/YkpaLreZtHZz1iTMSOX lkllAPXbaqmKK2XIGd3N6kniK1JgG2uBoXGf4ErkWGl5swcNjIV8QaOVrCfyyg0r w23iI+GBFoQd2NNhwK+8601UryTwZQ== =ujeE -----END PGP SIGNATURE----- --F/jmgXxh9qwDNeFa--