Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp925353pxv; Fri, 25 Jun 2021 01:14:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZqo1EbUsinaeYr5vd5RgDfss/E1njZrnBtvG4U6e4jRqhPyaEyA3xLwrSeAXrOSGKMJG2 X-Received: by 2002:a50:fb14:: with SMTP id d20mr12794352edq.187.1624608856290; Fri, 25 Jun 2021 01:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624608856; cv=none; d=google.com; s=arc-20160816; b=YezdcAOo9SsI/EeMAHOYmy9P/NTys0b3bown1lwPsYaEneFt/Ae03NnBV+PSfuBkqa PsaJ8XXCdTu1rAekgLoTu6nz/HQG//dWUEgZht+sPqFS7QzGwg5R+GByh+IbBG7msjTD iLAuxZqliGk5uBmZoNFnW2tpqu9Lc7WuTicqNyd2r/KANOdgUC1P3xp1TxwbtLDUDE8S dPhLipg1k2DAH/T6t6Y20WxbkOXGHjf7qbO5Vbw64WEDuTPtFllqoCBS3zD+XYtCl9m8 V8ky9BI94LOO/NLZIbJQWChi4FBsZ6+J4tPAQec92fX+m2W2z98hsfa6S9RYRV3/b97H aK9w== 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; bh=N+wJ6Hbyg1kwHJYzyADfMhBwimMK5YKhihEcGs5pNnw=; b=t27TKDrn6QK7Ixr2eplMVDRYnxkjtfXCjjHhIxqxmXz3N02Wte1uAg7fubQlSPGNzm nReZwjwFrkrd0heSVFbzz9DVBtUIp6jcEK9ocO6gVfFFzGoBCvS74uJz42wZ+oKkAblo 3pwWYUyZEclkgUdxjP5+e2PFCKQ6RaaJy+oHR6pvwO0kPAtYomJlZQ+m+0rNSdvOsKvD 1y2qgZvhJ0i0Mo8JfmhMTYHf0bwbNrf8iYpcn8XUqqbu7AMawk5lmeNSRNRWX9sRjqfk W3gZ0V8iEIq4x4FAj+AsPnsQt+9HESRvJUr4AkjTyl1ISVyWWSWWD6fcUQeugKm/zZl2 S+yQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o9si5502475edq.547.2021.06.25.01.13.51; Fri, 25 Jun 2021 01:14:16 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229956AbhFYIM3 (ORCPT + 99 others); Fri, 25 Jun 2021 04:12:29 -0400 Received: from hostingweb31-40.netsons.net ([89.40.174.40]:43655 "EHLO hostingweb31-40.netsons.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229748AbhFYIM2 (ORCPT ); Fri, 25 Jun 2021 04:12:28 -0400 Received: from [77.244.183.192] (port=64458 helo=[192.168.178.41]) by hostingweb31.netsons.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1lwguc-000GX1-Pd; Fri, 25 Jun 2021 10:10:06 +0200 Subject: Re: [PATCH v2] PCI: dra7xx: Fix reset behaviour To: Linus Walleij , Kishon Vijay Abraham I , Bartosz Golaszewski Cc: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Lorenzo Pieralisi , linux-pci , Linux-OMAP , Linux ARM , linux-kernel , Rob Herring , Bjorn Helgaas References: <20210531090540.2663171-1-luca@lucaceresoli.net> <20210531133211.llyiq3jcfy25tmz4@pali> <8ff1c54f-bb29-1e40-8342-905e34361e1c@lucaceresoli.net> <9fdbada4-4902-cec1-f283-0d12e1d4ac64@ti.com> <20210531162242.jm73yzntzmilsvbg@pali> <8207a53c-4de9-d0e5-295a-c165e7237e36@lucaceresoli.net> <20210622110627.aqzxxtf2j3uxfeyl@pali> <20210622115604.GA25503@lpieralisi> <20210622121649.ouiaecdvwutgdyy5@pali> <18a104a9-2cb8-7535-a5b2-f5f049adff47@lucaceresoli.net> <4d4c0d4d-41b4-4756-5189-bffa15f88406@ti.com> From: Luca Ceresoli Message-ID: Date: Fri, 25 Jun 2021 10:10:06 +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=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca@lucaceresoli.net X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Linus, On 25/06/21 01:11, Linus Walleij wrote: > On Tue, Jun 22, 2021 at 3:57 PM Kishon Vijay Abraham I wrote: > >> While the patch itself is correct, this kind-of changes the behavior on >> already upstreamed platforms. Previously the driver expected #PERST to >> be asserted be external means (or default power-up state) and only takes >> care of de-asserting the #PERST line. >> >> There are 2 platforms that will be impacted due to this change >> 1) arch/arm/boot/dts/am57xx-beagle-x15-common.dist (has an inverter on >> GPIO line) >> 2) arch/arm/boot/dts/am571x-idk.dts (directly connected to #PERST) >> >> For 1), gpiod_set_value(reset, 0) will assert the PERST line due to the >> inverter (and GPIO_ACTIVE_LOW) >> For 2), gpiod_set_value(reset, 0) will assert the PERST line because we >> have GPIO_ACTIVE_HIGH > > The presence of an inverter makes it necessary to model this the right > way to get out of the situation. > >> So this patch should have to be accompanied with DT changes (and this >> patch also breaks old DT compatibility). > > There are ways to deal with this perfectly. It may or may not be worth > the extra work. But I can show how it is done. > > Make the patch to the driver that assumes driving the gpio descriptor > to 1 (asserted) has the desired effect. > > In this patch, I would include a hunk that fixes the above device trees, > so they are correct from this point. This is one of the few cases where > I think it warrants to fix the driver and the DTS file at the same time, > but the DTS can also be patched separately because of the described > solution below: > > To avoid regressions with old device trees, add code to > drivers/gpio/gpiolib-of.c in function of_gpio_flags_quirks() > to react to the old incorrect device trees. This is where we > stockpile OF errors and bug fixes. > > This needs to be pretty elaborate. It begins like this: > > if (IS_ENABLED(CONFIG_PCI) && > (of_machine_is_compatible("ti,am572x-beagle-x15") || > of_machine_is_compatible("ti,am5718-idk")) && > of_node_name_eq(np, "pcie")) { > /* ... add code to check and enforce the flags ... */ > } > > You see the idea here. Include this in the patch to make the > Perfect(TM) solution to this problem both fixing all device trees > in place and dealing with the old erroneous ones using some > elaborate code. > > There are plenty of examples on how to detect warn and > modify flags in of_gpio_flags_quirks() make it clear and add > some warning prints and comments. Keep me and Bartosz > in the loop. It'll look fine in the end. Thanks for thaking the time to explain this in detail! As I volounteered to write the patch, and since I'm lazy, I was going to vote for the former solution. But to be honest the latter has some good reason to exist as it handles the case of kernel upgrade without DT upgrade... My bad, this two-liner patch is growing so big. :-) -- Luca