Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp633377pxv; Thu, 24 Jun 2021 16:19:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCHtSuM+XIB/d4h9q7N2PQj8hvHgTBH8Cv1COY5/pgmKSZ9sos+b4wWNSgPZ7La00cNZOa X-Received: by 2002:a17:907:7708:: with SMTP id kw8mr7894389ejc.111.1624576746131; Thu, 24 Jun 2021 16:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624576746; cv=none; d=google.com; s=arc-20160816; b=uuU7OH3GpspNyZcTnYDlkU00EYKmzTT0XCzz7l7CdIGFYmR3R9eBEfm1hx2IAmHI/6 DVXjv6gE35CnH8se9rS9IoLUaXmvjTMeMv8RlZFngJ0CCTVoTU3al+fAm9tkwEeAsC5d A8uf2d/GVCBbP3HyY9voqV1zp98sKP2jXBvmEe/RJjZEmk1zQ1BVFDq5CWQvsWrDxRaa CVPuwlgIP68xHig8hDa2SwMmZhnkVROdx9GAuLKs9CS+bz/RRpk6jtFNLV7mO1N2JWzL 0YrFSjYsvSUGAwDcM5FQLIHfhzj8p6y3UL7pj3CdTMTH+7SOVz73RqL4pLZON3Pwnspo bXfw== 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=RKvQ84L7i7Q66+4hgvpmihpYU0bPeDpVb9EJphxZQuI=; b=0vdpWqNgW/k5gvny9+rjKl2NOjHTZ6fQ7F5NVRgDU/biwG0sTuXYp7vDnv5JJZTHYI wi7fMaxHHAA2um78kV8yFgvh61ViUQQbsKxFH2V4887Jv1iDJ+G0uX0ZFSIu8WfI2uTj EhmwBTmgpfzUGg/Lyg2MzpQjjzGXKhLvJ3JA952SYbl/5gaPHDARmc3tCzBf366Vp7sm g8+VxeBMa7HM55cyIc4R+sih652/kVHYrS7ayh/IsBHWg1mux28vTv4F3zDZpWP6Ym59 YWR6bwJVmx93MQ6ai5WBxA2RzeuKeUlzeC3pLragcDExuN2JSltirrIQG7+KaXJeHrK6 7Q6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="JHg/jc0b"; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hv7si2668460ejc.369.2021.06.24.16.18.42; Thu, 24 Jun 2021 16:19:06 -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=@linaro.org header.s=google header.b="JHg/jc0b"; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232663AbhFXXNy (ORCPT + 99 others); Thu, 24 Jun 2021 19:13:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbhFXXNt (ORCPT ); Thu, 24 Jun 2021 19:13:49 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CFC8C06175F for ; Thu, 24 Jun 2021 16:11:29 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id h15so13026267lfv.12 for ; Thu, 24 Jun 2021 16:11:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RKvQ84L7i7Q66+4hgvpmihpYU0bPeDpVb9EJphxZQuI=; b=JHg/jc0bbwBhVvdYJ5vx8d2GNcCz+NMvF8A3yduFH0LYdaCwsrnchIU0jhqhz5Ve2Z f4dY09j0Xb0kkjv2omyezcrJQQGA077N47WmrXQMHxkvB3IngzZUknQOk/ikkVSbhbWG +FVtuHVD3ajJ+OcnzMKRfaz8agcde6DoG2XMBzAlxHMvs3k9Ag5WEguLTXZSm6uZsO9n nEPASYO+9eXNZOKhcTP95ddDQ3VWfXP04dnJsBnFo+u7tliAgiTkSMBQ+PK4RSodCqKj JCV5EeOxSMU7F3csKlTCCkhzFUQaSKc3WXuLfcJVkzJWy7WNAGYiCgX8AuHQouhP0Owr 5n2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RKvQ84L7i7Q66+4hgvpmihpYU0bPeDpVb9EJphxZQuI=; b=j/6zntnVgl61F/njEnp7ByE72aZoV8Ow4pbwjvQvuSZbpCYdwPrV4p8xlR6fmddmQu /F9Jb5+LfpPuGHxt6NY8UNm1Z36m7nHHJMLDqLNajgR/rMihPmKSN/fIFVzCbY8i2l7L P2uZKejRrUCrGUicpuwJx6cZDYnCGPQhWZ/yZG0gneuvy1BCAVorYLp/4NLR6wOfEKD3 ZIa/n5WQcQPpk5osnHdUgM+kp0eWIoxEjopRZ0Mid36GCb+cMn+vFiDLcVB8alvBbwDa 0ZBOtrJCCNHVUgGlHnGpzuT5LAU5Pu0JCYTVt53cVqvg293L6RwBYgbiazDSy+rg85Mq WAfA== X-Gm-Message-State: AOAM532xal5K/PvvAX2gbqarK5teUglENjE0EyVgTeT9RIYWQxFN3JVR V7vanxMnGASelPWf3Fl7adKquG9gpEmyYhzEDPKiLg== X-Received: by 2002:ac2:4d25:: with SMTP id h5mr3565495lfk.291.1624576287158; Thu, 24 Jun 2021 16:11:27 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <4d4c0d4d-41b4-4756-5189-bffa15f88406@ti.com> From: Linus Walleij Date: Fri, 25 Jun 2021 01:11:15 +0200 Message-ID: Subject: Re: [PATCH v2] PCI: dra7xx: Fix reset behaviour To: Kishon Vijay Abraham I , Bartosz Golaszewski Cc: Luca Ceresoli , =?UTF-8?Q?Pali_Roh=C3=A1r?= , Lorenzo Pieralisi , linux-pci , Linux-OMAP , Linux ARM , linux-kernel , Rob Herring , Bjorn Helgaas Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Yours, Linus Walleij