Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2614128pxb; Sun, 17 Oct 2021 20:32:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1AVMgcxQ2M1uPQneH2zaD12C0sTYydk6Ao0ZQz64ISlmU10Dk2k17EGI8azC4gkHS75uK X-Received: by 2002:a63:5544:: with SMTP id f4mr21414782pgm.431.1634527972573; Sun, 17 Oct 2021 20:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634527972; cv=none; d=google.com; s=arc-20160816; b=O5Hxy+ZQn9E1yV2bK4SCDCK8MmsQKN4/7Pn8tsfy7dem96BMtYi62LVx4T6XYiGSQE gelB/6i7e8+2v3UboDFtfXNWpwIwEf8kAi3md1cMH1P+5SwS2jaOnLFVj6xJjRXzNBOw v4hCkRefgRztCa8vnlZhatMcnnDaNZkC5Jp9en3iLJasgAJVPHogdRdVs8WSkzV11vwj KxRQ935z/nY7zhLR4IF5aPgX5ur9zeG9bnPmET4GHm17dC+CqXOes8tFTTaEPV/1X4bj u+kAiMYtqS9uc3GLy9ZDrbRaCab84oKiWudNsTgZdkd5n3wuueaJO01MyBRaHz7/SdoX jIWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=lRKifhuZPEWMV9NZ2wr+qPq6taJBi8mO/4F/nJu9ENk=; b=dGSJ5FSjxG2HnNXUBPwWwqUOG5CMGF+dc/zdU2Y0dnFjU64wFCidNaIxTaN9cLBLLJ hojYeQB/fxWjC5kytrr+26E87Gwalj3dSQ6nb/0k5tGXPec2PC+FWb2xolguimMX9PU+ nti3uO/2Rt+SnVHKGBiNIFGzXt4hLMsWUw0NvLYRnArc9RJEb+D05hOWBU59bWnAUil3 GW8BHgcJMCOzSQtllhDr6ZXItbf/+NAd3iQ8Dueek1MjxmltYn1XAkpps88WqEv7PLYh u/DhAFgD5qi4HfXFR7XCexktHj3zKpCpR7bHM20kwzrvm69O6TF+JGy1vMCFPnQVX3KU lBMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Kkh/ARh4"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si1827997plp.341.2021.10.17.20.32.40; Sun, 17 Oct 2021 20:32:52 -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=@redhat.com header.s=mimecast20190719 header.b="Kkh/ARh4"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244066AbhJPKUd (ORCPT + 98 others); Sat, 16 Oct 2021 06:20:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60132 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244093AbhJPKUa (ORCPT ); Sat, 16 Oct 2021 06:20:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634379502; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lRKifhuZPEWMV9NZ2wr+qPq6taJBi8mO/4F/nJu9ENk=; b=Kkh/ARh4ZzzY0jfO/HfqlKEgh64pzOBYEwTQodBwTBrukREV9FZ1r51i+1OHjUtJzVEjHv eY7vdtDG00BmvAFqkyjZDzU88lcJavL0VRLpkTp7ZAaQFxt8KXa0zTS1TR+va8qPZ7G1tp NEEnvxWH3DONV69cC8mszAwxsX0fgd4= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-101-pyddv7lWMYmazdgsR9WRCg-1; Sat, 16 Oct 2021 06:18:20 -0400 X-MC-Unique: pyddv7lWMYmazdgsR9WRCg-1 Received: by mail-ed1-f69.google.com with SMTP id r11-20020aa7cfcb000000b003d4fbd652b9so10331604edy.14 for ; Sat, 16 Oct 2021 03:18:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=lRKifhuZPEWMV9NZ2wr+qPq6taJBi8mO/4F/nJu9ENk=; b=WM+7nF8emDhIE2YXsCvKMqnAdQeDA5vPzPDVW78yXJW3OWv6B9cus7mJQ/KWrkHSlm XgNQCSqGsYYgqemnlZjkKHzvm/xBjYE/nmSCQbQemmLbWWR69vLSQpD1kRaLZcf8hjwM AwznnYP9CjNvjZA5ZoG9/vef2UzRIsDq3WwB6YPMp8LXUqS7GVkUAlVI5QGCWdeo6wKA zZ/UuD2p/dRL4pfnFzTAPq4upELNProkpy0tpOSQaV1CfGK5R7LvcLHVU49UTKPPStwE xe+29TShS/j/JVkpTm3pQAdbLR7L0UwU1txAnWTn5Q5aTCNAsd3ZCXW0184Yk6Gqi+KO ZIWA== X-Gm-Message-State: AOAM530AiM1Uk+CToeena0c0J3by9hOLBbr16k+seKcXgxNNdnJjdyeH okEHPmoQpH+f6fZojOj6/LuYN8dUcHGVCx7ywQeNCwLUVJhKh91oHUHuMOtjZ2dCoYYJzcnNBSz knhgZV/x8n0gO16rtkTmVJYGz X-Received: by 2002:a05:6402:1c85:: with SMTP id cy5mr26031896edb.281.1634379499477; Sat, 16 Oct 2021 03:18:19 -0700 (PDT) X-Received: by 2002:a05:6402:1c85:: with SMTP id cy5mr26031859edb.281.1634379499200; Sat, 16 Oct 2021 03:18:19 -0700 (PDT) Received: from x1.localdomain (2001-1c00-0c1e-bf00-1054-9d19-e0f0-8214.cable.dynamic.v6.ziggo.nl. [2001:1c00:c1e:bf00:1054:9d19:e0f0:8214]) by smtp.gmail.com with ESMTPSA id m18sm3371750ejn.62.2021.10.16.03.18.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 Oct 2021 03:18:18 -0700 (PDT) Subject: Re: [PATCH 05/12] regulator: Introduce tps68470-regulator driver To: Mark Brown 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 References: <843f939a-7e43-bc12-e9fc-582e01129b63@redhat.com> <1805d16e-87ab-c291-6a73-adabf41344ca@redhat.com> From: Hans de Goede Message-ID: <26a1b636-1b82-2ca6-4f78-b1d22fa556d6@redhat.com> Date: Sat, 16 Oct 2021 12:18:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, On 10/16/21 12:29 AM, Mark Brown wrote: > On Fri, Oct 15, 2021 at 10:14:30PM +0200, Hans de Goede wrote: >> On 10/15/21 9:59 PM, Mark Brown wrote: >> 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. Ah, ok. The default regulator_init_data in the tps68470_init[] array was already there in the out of tree version of this driver Daniel and I started with: https://github.com/intel/linux-intel-lts/blob/4.14/base/drivers/regulator/tps68470-regulator.c Now that you have pointed this out I would be more then happy to delete it and I agree that providing this bogus data is not a good idea. > 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. Ok, for the next version of this patch-set I will: 1. Remove the default init_data 2. Change the toplevel comment to be all C++ style matching the SPDX line 3. Add a || COMPILE_TEST to the Kconfig so that this can be compile-tested without selecting the INTEL_SKL_INT3472 option Thank you for taking the time to dive a bit deeper into the patch-set and make it clear that your objection is the presence of the default regulator_init_data; and sorry for loosing my cool a bit in my previous email. Regards, Hans