Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5F098C00144 for ; Fri, 29 Jul 2022 08:10:04 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id EB1B2841C5; Fri, 29 Jul 2022 10:10:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=quarantine dis=none) header.from=toradex.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4A88B841DB; Fri, 29 Jul 2022 10:09:59 +0200 (CEST) Received: from de-smtp-delivery-113.mimecast.com (de-smtp-delivery-113.mimecast.com [194.104.109.113]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A516C841C5 for ; Fri, 29 Jul 2022 10:09:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=toradex.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=francesco.dolcini@toradex.com Received: from CHE01-GV0-obe.outbound.protection.outlook.com (mail-gv0che01lp2043.outbound.protection.outlook.com [104.47.22.43]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id de-mta-33-pVz6-vMaORmtXDR00_AJEQ-1; Fri, 29 Jul 2022 10:09:55 +0200 X-MC-Unique: pVz6-vMaORmtXDR00_AJEQ-1 Received: from ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:2e::8) by GVAP278MB0181.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:39::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5482.6; Fri, 29 Jul 2022 08:09:54 +0000 Received: from ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM ([fe80::3510:6f55:f14a:380f]) by ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM ([fe80::3510:6f55:f14a:380f%7]) with mapi id 15.20.5482.011; Fri, 29 Jul 2022 08:09:54 +0000 Date: Fri, 29 Jul 2022 10:09:52 +0200 From: Francesco Dolcini To: Pali =?iso-8859-1?Q?Roh=E1r?= CC: Stefan Roese , u-boot@lists.denx.de Subject: Re: [PATCH] pci: pci_mvebu: Add support for reset-gpios Message-ID: <20220729080952.GA15137@francesco-nb.int.toradex.com> References: <20220728130357.24514-1-pali@kernel.org> <8873b549-3fd0-1a9e-14b2-690579f90e32@denx.de> <20220728151013.ea44snu5w63h5l4v@pali> <298327a7-95b7-0f71-f6a5-241f1b9bd5ac@denx.de> <20220728153000.6bwzqpzsxg3oz2ni@pali> In-Reply-To: <20220728153000.6bwzqpzsxg3oz2ni@pali> X-ClientProxiedBy: MR1P264CA0018.FRAP264.PROD.OUTLOOK.COM (2603:10a6:501:2e::23) To ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:2e::8) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fb64ec69-a3de-4a6e-d4bd-08da7139b820 X-MS-TrafficTypeDiagnostic: GVAP278MB0181:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0 X-Microsoft-Antispam-Message-Info: rXVjOgQ1hRNct8ZZW5qsaRAYxDlT8j6qJ9y+sZPkivqJm6zkpSxNOeojd2KDChjL+tNYzfw3d0zc6ZlNul2iXBlM+9SGLLHtX1PR/stccRI1OzRK6k9GYnKJm5meyN8vwvkP6HMXj3TUrRWu9SDBDx2mOiZo9m7jeD/GLppTy6oHPYWnYIfyAs9GWMhcE7FDDIqL6Ryv9WN4ypzKZHi0f4FABPgeVGJxovLACe5qNengXZsvb4B1e6KNVqlpk1hsPsM5S7bidKHLermSCEnL8cTzMilkrZhCgTHgo8O2Wn055fkFzYy5ERVlwhNuUP5SrISQqDIebe/WHNVD1i3iFa3At/nUUybDm+49cy4hvKTw1a/kmQ+MFesyUl0CMS29eT+3a0qhF8yPL6Ogq00WxEsodf+sntwi/c6Gg+GQgopszMSGvUT+/BzhDZQrLr+DYxkBdjccP2g+2P+S3x878qJIZb4OV6LkFDLYt4AbihJ5wfm2avJnLWHrJMbkjTjSUrA5UD+GZeJ9slplbxI/v9S5DY5shhmmy/6lZlMQpqVWDSKPoR/8YGr50N6KqMhlc9Wfy0lOSJhyXRWPbgdRO/xnLcUy1p+EomtbcuZrz+0TQ5N0TjvwHNveeKRVUul69xgB8D3ONGKcEVVHINN13vEGBxJhnOcv/Bws8bOloZEBfOf7SlUs9xvbcsS588R8jZfs4VpKUZbyXsDU0gZYyVbljwWb149naHcwTV5rHT8iwewjF/QqEyZBCqdxltcPxve5v64mBwpm1mh11wJ9ZxjiE+KA3/7hNGNOz3ZItSRddtpSvW4o2hRF6G2ONBjgSfivIEtB22uxUvJBn6ZHbA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(13230016)(4636009)(396003)(366004)(39840400004)(136003)(376002)(346002)(6512007)(41300700001)(5660300002)(6506007)(1076003)(53546011)(33656002)(186003)(966005)(6916009)(8936002)(38100700002)(8676002)(38350700002)(52116002)(26005)(86362001)(66574015)(66556008)(83380400001)(6486002)(66946007)(44832011)(4326008)(316002)(2906002)(478600001)(66476007); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS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6my5wLjV0znc4wPWKnLeqEquY/yLheFPvk/o9ENs0j3Ewf?= =?us-ascii?Q?X78txid7ZB/hEYN6ZYrjodzRKipHICBw3Ap3oxFQTzH/ihAOAHMiQ1i/7ePs?= =?us-ascii?Q?lInvfvSqjx7rVJZIzn2DbmvKai+Au8PIe1SbTl0YCenIWfrSCZ4nAM5umT5p?= =?us-ascii?Q?PI9brRn+QSnDfSVdTUOEqwN2Q3Az0UxO+dzynpHRa1kFl7RNvKTkgNSiNjwI?= =?us-ascii?Q?Ss8Z+eEh+9PxDvzhlK8io8VqARp7+Y4elEoJA6F9ZwS9j4s/2vlt1qK/E7+V?= =?us-ascii?Q?YPrGLsBHIQZIjs/EBySxI7kcHg9ZjFLz1ClB2YWI4FWYspW0q1M6rW54aDbW?= =?us-ascii?Q?S3+NuK6BHqqrjkB1QqThLNS7lftTfCyW1Ped9Q3LdP5xm5UciFz2D30nbn+I?= =?us-ascii?Q?58cEhNzQQT1+xa7KqhPYoy8EY07bBPKzlnaaxHsqs9z0+Hb7ctezS2pHFak2?= =?us-ascii?Q?jSiVsIrHAVdlshiSJ933zHMLk9P59PIpqkNie3+fVjRWFhGPEQ+ZMGvab+dS?= =?us-ascii?Q?yB4sFOrJisbkn60hyh/X9Ozo9HnjUOtYqNGy7pkvKAt7rT02Duhsf2Olk7s2?= =?us-ascii?Q?YbrS4hEMCkAK+6v9A2TL1rYoAY+3pZUL9UWFkqiZMiHaCGHe9hmEuUlJkFqt?= =?us-ascii?Q?dfGyLlQxzPoKEkNwaTBJmE4VknutYYrjqs6F/ufjlBTTDQcC7qcYXPJLJRXd?= =?us-ascii?Q?T8xRRYAPx6/G14yjHZ/1oioiZI5bZoAfivUh+7VscuvcSmDxGbgCOckdOhGC?= =?us-ascii?Q?ag=3D=3D?= X-OriginatorOrg: toradex.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb64ec69-a3de-4a6e-d4bd-08da7139b820 X-MS-Exchange-CrossTenant-AuthSource: ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2022 08:09:54.3532 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d9995866-0d9b-4251-8315-093f062abab4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: HOOYDqcZxgj+R8G2C3PbVzCZQ2vdE8Kpi/HZNOpZCQkKOzvNXeCB2oIFN7PDvn9gYHNY9sPmsLRI1JrtQbOFYHiXyb7c4HSxhvmS817zm3w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVAP278MB0181 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CDE13A77 smtp.mailfrom=francesco.dolcini@toradex.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: toradex.com Content-Type: text/plain; charset=WINDOWS-1252 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Thu, Jul 28, 2022 at 05:30:00PM +0200, Pali Roh=E1r wrote: > On Thursday 28 July 2022 17:13:12 Stefan Roese wrote: > > On 28.07.22 17:10, Pali Roh=E1r wrote: > > > On Thursday 28 July 2022 17:05:38 Stefan Roese wrote: > > > > On 28.07.22 15:03, Pali Roh=E1r wrote: > > > > > Release PERST# signal via GPIO when "reset-gpios" is defined in d= evice tree. > > > > So you're only releasing the GPIO (setting to inactive) here. Would= n't > > > > it make sense to first use the GPIO (if available via DT) to actual= ly > > > > reset the PCI device? How is this done in the Kernel driver(s)? > > >=20 > > > This is something which I do not know what is the best. Kernel driver > > > pci-mvebu.c has same logic - just release from reset at startup. > >=20 > > I see. Could you please check some other PCI Kernel drivers, how they > > handle reset-gpios signalling? >=20 > Every kernel driver is doing it differently. Touching PERST# in > bootloader is for two different purposes (which is board specific): >=20 > 1) Board is designed in a way that PCIe stays in reset after CPU starts > and it is up to the SW to release PCIe reset, including reset of > endpoint cards. >=20 > I think that this is recommended design due to how are PCIe > requirements for timings and dependences on other stuff (like PCIe > clock stabilization, power on, etc...). >=20 > This is also what I prefer for designing new boards. >=20 > 2) Board is designed in a way that endpoint PCIe card is after CPU reset > immediately released from the reset or maybe that PCIe card is not > reset at all after CPU reset. >=20 > In this case lot of "broken" cards do not work until they are > manually reset from software, which requires flipping PERST# pin > manually (via GPIO). Those card that you mention as broken are often just fine, from the standard point, they are just a pain ... >=20 > Bootloader / U-Boot starts as the first SW and depends on specific state > of CPU reset. So it can expects that nothing release PERST# from 1) > before it. I think in general this last one is not a correct assumption, reset could j= ust not be asserted at that point because of the hardware design. I recently had issue because of that (Linux Kernel, not U-Boot), and this is the fix that was merged: a6809941c1f1 ("PCI: imx6: Fix PERST# start-up sequence") (and I also had myself similar issue while working on Intel platform firmware, e.g. UEFI). Said that I agree that the topic is way more complicated than it should be :-/ >=20 > In operating system it is harder as kernel cannot do this assumption. >=20 > And to make it even harder, there is important question: How long should > be PERST# signal active to ensure that endpoint card is correctly reset? >=20 > Without knowing answer to this question, we do not know and cannot > implement 2) properly. >=20 > I was not able to find answer for this question in PCIe specs, so I > have asked it on mailing linux-pci mailing list: > https://lore.kernel.org/linux-pci/20210310110535.zh4pnn4vpmvzwl5q@pali/ > (and it is still without clear answer) >=20 > And if we go deeper to the PCIe initialization (as PERST# signal is part > of it) I described some proposal for Linux kernel how it should be > implemented correctly: > https://lore.kernel.org/linux-pci/20211022183808.jdeo7vntnagqkg7g@pali/ >=20 > So all this stuff needs to be rewritten, ideally into some common > framework. Until that happens, every driver would continue doing it by > its own -- and differently. >=20 > Yes, it is a mess, but I do not know what we can do with it. >=20 > Btw, in past I did also investigation of those resets and delays, and > really every kernel driver is doing it differently: > https://lore.kernel.org/linux-pci/20200424092546.25p3hdtkehohe3xw@pali/ >=20