Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp34000pxb; Mon, 25 Oct 2021 03:20:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6+IOnz0fPJQKFLqXhzni/OSlG8eM55ytuXZE8Yel9CVuiX6ppYKKoPjceQJRTGyasYvr1 X-Received: by 2002:a17:906:6848:: with SMTP id a8mr21831307ejs.314.1635157255657; Mon, 25 Oct 2021 03:20:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635157255; cv=none; d=google.com; s=arc-20160816; b=vmT4NvKuBstclz+RIk4ggGBXZCHv/zaTHvFeMen59iqowwiwOV7KYJfGujDCTmFZom bUFrsfKfLwVFvoK9FxEIH39AztMBDGNNq+Izphmofg24t+oBo9Z8rAeFkJTynRUZB7oc YW09FkD/cTp0xoxOMTbRhuWL/TieGIS5cQ5BjatLwvXkWiiLJkMufmV7FgoPcLisDHHq nIEIeytsEa57xvWplWDvW5u06rIBpVblp0n8Q3AXk1cHM1ncw4jtjh/UD8091/dGixC0 HReXjrIQ0c5voqeCFcaOX+QNpIW3ZuJMYLHABUjbytKEUz4vrbRxz4XJF0yoKlSwBK9Z 7pIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=NoOyCfUHoc1NYPh3QSE+q8V42pQrvXovBnbm5bi8Q4k=; b=m+V5Jy4oqqNJ1+ZDh6NjiT6y3W0EtFu2spPI2G38dLhuyh7I0wxWXZCNxcELD3HNIs N2C0P5UCnD7I/9hC1JDULr6gUqjzXq9n7/ejIFnKpx+S1Rz2E2LgNL5nHfLCJ/luq+WM 29lJptQUtkgrtSMNIzyVn1RGaC1LHb+yyb1Huzg7uToeEAN+8p+Ns1pYBS8E5IAABwLR fy+mtCQIASgsjYtLEMOGgKhUvDnlo+lTdplEDA5T6T92wVRIP7E9ao3OL5bVGUiNIHsR z2fqco8F13Oc6aI1Ya6J9ZOZbL8FAD05nJX1fpF700bZi57vXO5wxNlDqH6xcZe+yVDE 3hSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=QYH7ZKvR; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qa38si25699423ejc.111.2021.10.25.03.20.32; Mon, 25 Oct 2021 03:20:55 -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=@gmail.com header.s=20210112 header.b=QYH7ZKvR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232790AbhJYKSp (ORCPT + 99 others); Mon, 25 Oct 2021 06:18:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232772AbhJYKSo (ORCPT ); Mon, 25 Oct 2021 06:18:44 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C7CAC061745; Mon, 25 Oct 2021 03:16:22 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id l13so20345973edi.8; Mon, 25 Oct 2021 03:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=NoOyCfUHoc1NYPh3QSE+q8V42pQrvXovBnbm5bi8Q4k=; b=QYH7ZKvRWU1KiiEGEiqhp/peQaL15IJnNfVPiYX/zO0MWra7+JI3SXg0Lc0JOA98XW WPj0LrY1A9k5qE+Fp7rMP4ng0O1HUTlPumAhQb4+v52N+Gxh4ARNPuyOlTxD1lWp2hPU +CZeBnhLNgI5Sswr1xtPARYwEWLeJVIyMo0vKQkodDvIb+wFY1C1QMKmpWuR8CETdaeY +1QUbqZOiVqSWFHOAOgre3vMI8qKI9BZ3oqaxTWnWpEwtFrprfAJnVoUrrormyAw67w8 q4J0hElT7j8paGd5sJawJ1zttr7+KMkjayF3pBz9cS4vqbe4A781qONfgGIej61A2KEd BXmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NoOyCfUHoc1NYPh3QSE+q8V42pQrvXovBnbm5bi8Q4k=; b=YLCsN5rUDWHtcgPzdu3n/cvmPBLNUNpadsuByUhqCHuPN9FRhbSojbgwewGPoLVFW3 YvMb5UlwcHo5APY2bwX+4jmKSJkjgyae1ziXHJRAlwKqt5RIGyVzqJ/Z1yf3MsOcsoKR +aY1rwdScPqkTZE0AN4poAUofUou2SzzgXWjvSg8tvA5eqCO76isv1PRt/rwFpJHZT+h AAath7Sd++g+EHs9Ff7e398+VCOvbeNtYAuO4VnzbUeSATuM8cWuuAjwb+Az4KIxwVMo 0qWYIp4r70suvf7amWwnTzn5caKZ3EIyOjyUwYqaDzLZbI3iSN2IqXzv56o3cnbeQfb7 ARDQ== X-Gm-Message-State: AOAM531DJ8XveusHL9XjbWZ2rLpP2hXuuEzOxFXhn/IbrAW9uZ/WsTNd vX/GeZ+spkrAEGomKkB9ZJXVnlWojpUURP9pnVU= X-Received: by 2002:a17:906:a158:: with SMTP id bu24mr19541505ejb.356.1635156977533; Mon, 25 Oct 2021 03:16:17 -0700 (PDT) MIME-Version: 1.0 References: <20211021174223.43310-1-kernel@esmil.dk> <20211021174223.43310-13-kernel@esmil.dk> In-Reply-To: From: Andy Shevchenko Date: Mon, 25 Oct 2021 13:15:23 +0300 Message-ID: Subject: Re: [PATCH v2 12/16] pinctrl: starfive: Add pinctrl driver for StarFive SoCs To: Emil Renner Berthing Cc: linux-riscv , devicetree , linux-clk , "open list:GPIO SUBSYSTEM" , "open list:SERIAL DRIVERS" , Palmer Dabbelt , Paul Walmsley , Rob Herring , Michael Turquette , Stephen Boyd , Thomas Gleixner , Marc Zyngier , Philipp Zabel , Linus Walleij , Greg Kroah-Hartman , Daniel Lezcano , Andy Shevchenko , Jiri Slaby , Maximilian Luz , Sagar Kadam , Drew Fustini , Geert Uytterhoeven , Michael Zhu , Fu Wei , Anup Patel , Atish Patra , Matteo Croce , Linux Kernel Mailing List , Huan Feng Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 24, 2021 at 12:29 PM Emil Renner Berthing wrote: > On Sat, 23 Oct 2021 at 23:02, Emil Renner Berthing wrote: > > On Sat, 23 Oct 2021 at 22:29, Andy Shevchenko wrote: > > > On Sat, Oct 23, 2021 at 9:46 PM Emil Renner Berthing wrote: ... > > So is that a yes or a no to my question? It's not clear to me. > > I see now that you've probably misunderstood what the code does. It's > not one time use. The function parses the device tree and dynamically > registers groups and functions with the pinctrl framework. Each group > needs a string name, an int array of pins and optionally the pinmux > data. Once the group is registered those pieces of data needs to live > with the group until the drive is unloaded. But if the device tree > parsing fails before the group is registered then those allocations > would never be referenced and just hang around as garbage until the > driver is unloaded. In such cases fx. pinctrl-single uses devm_free to > free them again. Thank you for elaboration. Please, drop devm_*(). In this case it's inappropriate to use it. pinctrl-single should be amended accordingly, but it's out of scope here. ... > > > > I such cases where you get conflicting PIN_CONFIG_BIAS_* settings I > > > > don't see why it's better to do the rmw on the padctl register for the > > > > first bias setting only to then change the bits again a few > > > > microseconds later when the loop encounters the second bias setting. > > > > After the loop is done the end result would still be just the last > > > > bias setting. > > > > > > It could be bias X followed by something else followed by bias Y. You > > > will write something else with bias Y. I admit I don't know this > > > hardware and you and maintainers are supposed to decide what's better, > > > but my guts are telling me that current algo is buggy. > > > > So there is only one padctl register pr. pin. I don't see why first > > setting the bias bits to X, then setting some other bits, and then > > setting the bias bits to Y would be different from just setting all > > the bits in one go. Except for during that little microsecond window > > during the loop that I actually think it's better to avoid. > > Maybe an example is in order. Suppose we get strong pull-up, drive > strength 3 and pull-down config flags (the strong pull-up and pull > down flags conflict) and the padctl value is 0x0c0 (pull-up, input and > schmitt trigger enabled). With your solution of just altering the > padctl bits immediately we'd call starfive_padctl_rmw 3 times in rapid > succession like this: > > starfive_padctl_rmw(pin, 0x130, 0x100); > starfive_padctl_rmw(pin, 0x007, 0x003); > starfive_padctl_rmw(pin, 0x130, 0x010); > > ..and the end result would be 0x0d3, although the strong pull-up would > be enabled for the microseconds between the 1st and 3nd call. > As the code is now it'd just directly do > > starfive_padctl_rmw(pin, 0x137, 0x013) > > ..which again results in 0x0d3, only without the microsecond blink of > the strong pull-up. You missed the point. Hardware on the other end may behave well differently in these two cases. -- With Best Regards, Andy Shevchenko