Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4976847rdb; Tue, 12 Dec 2023 15:19:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6dqokJ4oohP5VIxFwS5Jqaaudnf12p7FUxvaK8f6hRS7CmHW4nUIPbpi5fk0HMdyih/KS X-Received: by 2002:a92:dc90:0:b0:35d:59a2:6467 with SMTP id c16-20020a92dc90000000b0035d59a26467mr5145501iln.58.1702423198709; Tue, 12 Dec 2023 15:19:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702423198; cv=pass; d=google.com; s=arc-20160816; b=FPt1CFmgVv/NwYYIVI5vxvzrixbzSQn75+17/6OBbi96cgDTlTvK2xLFrOx+Nemamc losrvDUUp8+3lwvlpKJtY36xoJ8ppz5DiK/kiRlw3FQuBd+wLRR+qCi0TX0PVDdZZqe/ AOlyZ2SXK8+ISILS2tPIq07b/nDTIs1HvLOCGqhTPZgQ6DE58D/3b74pFyhDVkuOFRpa GouMbAIgWpRuoMNW5bbU61H6McUpX1tGs5noUf5LWRB29liRg6fU0++Dkri/9pzKwRsm lv+YzS4sufwmnd9uRdNPExh4/x1QwqA4eUYGOkjK+zoIAJqAhBPdiiF/qmMIMWKUDOUF vMLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+vveGhXRNWPtOaY59hn0FvvQqThq02pyK6m9coM5IQk=; fh=mUuATGVOMtFvwUMvvfJbrjIc1nQhhrgIyBLmIUV5EBc=; b=iUzxEFZeo+fx65MC5F4A3eFLHmBsjZ+F9s+9chqhtfXWwO4fwC7Qewuz9CdAb8dgMR H0ja3qmj1Zjs/oztf52EhepGKDjaGKzuJvr9aNk0Iz5lal648miBQPm3wbvvTXROG8nY jAHuh38PELj9hZhVcaC7Ss3NS0ITocGqzvGI9vZbxRcp24HK1aNzzRozcDv08QET0k64 im5eeaHori4F8zO/5UsaheCsuOJoa2tTYhWA9svoQo/N7wFuH/ndJncjssC3AiVsvT2r ZTnZurK51Suz65ufzVIab/eLlvNnPRahRQ1hQ/gu4UK1DRQ4GA6uYtjG5eQgNRc4tLnV SAMQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ClhlQg0S; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id o62-20020a634141000000b005c18d508531si8355179pga.212.2023.12.12.15.19.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 15:19:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ClhlQg0S; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C75E480565BB; Tue, 12 Dec 2023 15:19:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378018AbjLLXTb (ORCPT + 99 others); Tue, 12 Dec 2023 18:19:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235286AbjLLXTZ (ORCPT ); Tue, 12 Dec 2023 18:19:25 -0500 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2045.outbound.protection.outlook.com [40.107.22.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C328100; Tue, 12 Dec 2023 15:19:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C0hbhnA+OS061LRs8TYwyans5XxPOelIiCFfzphTh/+Pn4Yt9fUov6Xdvjw3DBKbveKDhTkw06IZtGgoN4++vaijGa1Yn0TfX3Sq3z0patwm4J1lmObwuXKruHJXd4W4HqgJWgXsgJd9uu8UJ99japh7L954aNO6W1m1pEPRZ6idlQx0a6IZlcndqIbCWwBqd1PpiF1Dgnlt194L+o9Xmiqm8Gz/yepsLAvc6Hu3NY1P1aGXTOQMiyQN+MnUh+otLCXbDViiKruk8DESR9E+BvGqLafSLFLWsdhIaSTEbZBat1vmIFdOMHh0A4IZHivGZrcFsaTM/g1ImOPWw7b5ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+vveGhXRNWPtOaY59hn0FvvQqThq02pyK6m9coM5IQk=; b=DctFh1G16tkogL+QC6FJXng38HH50AcpjHGT8K4G9hRFPSd33oTyzjRkQYT45+mvfPmYf2zXHsJUZX49lIXexjsuxvT4LKAMjA6qhiDnQ4ZFGgcvYLGoryC3hEeLvFJfNjgokK9gkrI17tTccNEFLpIXBDqQChylJOGlwad6Os4kwnWUCAIh27oAa69tUJ6w5RkrFp8J6b7ueS17i/4/4xJDu4oGnP/yGdfTKmkkg0ZpGhLf5QHJ1yq3NDNfmHyAglj2ZrO5ZSMs0oKL3/L17N2omsaGAyd7ukpd7So8nWXDZAs3GbWpEuPS34yyLMk+0Tvmcxv28/yOXrWqIhlPsA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+vveGhXRNWPtOaY59hn0FvvQqThq02pyK6m9coM5IQk=; b=ClhlQg0SAuSgjlFIa4Im//WtzTNg87Ase5I0cJ4vetysymLAScbREPafU9iglRLUsO3KDyZln0TZJwB2RxWuJWwGUZQRZ45YPWdiOP82n9UuysGB5ezX3D20Kk3iPW01Nk10eOIvVTWBjymT+xwtK/tcJyA7bemtz10k9MNbI58= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) by AS8PR04MB8359.eurprd04.prod.outlook.com (2603:10a6:20b:3b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26; Tue, 12 Dec 2023 23:19:05 +0000 Received: from AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40]) by AM6PR04MB4838.eurprd04.prod.outlook.com ([fe80::95f5:5118:258f:ee40%6]) with mapi id 15.20.7068.033; Tue, 12 Dec 2023 23:19:05 +0000 Date: Tue, 12 Dec 2023 18:18:55 -0500 From: Frank Li To: Rob Herring Cc: Manivannan Sadhasivam , bhelgaas@google.com, conor+dt@kernel.org, devicetree@vger.kernel.org, festevam@gmail.com, helgaas@kernel.org, hongxing.zhu@nxp.com, imx@lists.linux.dev, kernel@pengutronix.de, krzysztof.kozlowski+dt@linaro.org, kw@linux.com, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, linux-imx@nxp.com, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, lpieralisi@kernel.org, s.hauer@pengutronix.de, shawnguo@kernel.org Subject: Re: [PATCH v3 01/13] PCI: imx6: Simplify clock handling by using HAS_CLK_* bitmask Message-ID: References: <20231211215842.134823-1-Frank.Li@nxp.com> <20231211215842.134823-2-Frank.Li@nxp.com> <20231212164913.GA21240@thinkpad> <20231212225426.GB2948988-robh@kernel.org> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231212225426.GB2948988-robh@kernel.org> X-ClientProxiedBy: BY5PR03CA0008.namprd03.prod.outlook.com (2603:10b6:a03:1e0::18) To AM6PR04MB4838.eurprd04.prod.outlook.com (2603:10a6:20b:4::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB4838:EE_|AS8PR04MB8359:EE_ X-MS-Office365-Filtering-Correlation-Id: 1ffae849-a1f7-45c7-c8c7-08dbfb68bbb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /vWmq2/0QYHH/bYyV453kkityHf1J9eOQ75r6jCZ+TCD3nMRFMPR6OhWN5bzzzmxKZI+VlPp1wwouiG7Hi4NV7b0JhM3b/TE0Jr6JyyYJCZPz1xTNKjQ3aMRsyCYCs9sVl3COoLQ0GdR6+0XHd4JgxqwSAGQmpmqSO/aK2BDmlNiUGiyRw94+b34fLAkYxdyr9Id9KIGEC1D5l4KWvwkf8kw726j3UR2mp98RqrI0N+lnzUf5Y7pBPoeeUWyMy3mWT+i90/VBRT5cjOoY+b4fRDan64ImCD+Vj9mebMSD34Syk++evvXx3yFSp8N5y0lEL8xTeFupUkhdJFHkg4VbSj6CKIuVCSkcyCwUaob2pHOVi0GW+zpo1YzwXc8l44biEEZcIcVztYg3I3HYYXblAvgCFx42jrLen9g8h/wwy4R9S42R9/kzNgSI687skHN1LTyDOwrbPYEYLk47avWteQLhUAZhuS3Qt9ZUPq9kzhEuki3j94LC5pABZJj+VBYS2xvj3Z4nu01OgIUOiRY3MCQt2dXKiTQBYUHlrMSr/9Hhln/BjL/O8tAld6MMdKfFHBjK+4ne/XBVM9/pjMQCkpMhzSiMA2vbsjnCV2FvonHoiLMEiz/jeSoaTXBDgmo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB4838.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(7916004)(39860400002)(396003)(346002)(136003)(366004)(376002)(230922051799003)(451199024)(1800799012)(64100799003)(186009)(26005)(83380400001)(52116002)(6506007)(6512007)(9686003)(38100700002)(5660300002)(4326008)(8676002)(8936002)(41300700001)(7416002)(2906002)(6486002)(33716001)(6666004)(478600001)(316002)(6916009)(66476007)(66556008)(66946007)(86362001)(38350700005)(66899024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?mTkA3Z1JRD7r7XRjQpt0jI3IbmLPY/q4do/NoCfHoZREmYCNc8x/+WQL9LhG?= =?us-ascii?Q?FagMTIu/gdXz3sCxTR6b2a4HhocpG+//8RT87YsLcbvGccZD8ItOX8GxBgcF?= =?us-ascii?Q?a1Xfdrz75ic/8u4W1oFLpRYj4D2Pd0qwrknxawpnlqX4RAK04DWAsHqQIUJm?= =?us-ascii?Q?PaGH24rLJ5WzSLu0m2wIxT0r3eVNJLFVorhaRmkrAEPmzBcEcBVJblbSzGrr?= =?us-ascii?Q?UX3rUR16bQjZOhX4g3avKCWyl0V2XCiEL67EjRFEpAVSTjnLxydiZVRqv14n?= =?us-ascii?Q?kaO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JzHpJpfpMJUz3AZAy?= =?us-ascii?Q?DDCbLxPVN6kGhwt+IOZ9K5tB9NrG/CXM6UsgoJS6bc+SQlVLSVXnnwNhmMmL?= =?us-ascii?Q?FP4laPsY3nUj0uf9uqi52Udqh/3yKt3axNZ1x0NPfO52IIc0vOuCZFx3hX4b?= =?us-ascii?Q?Rh48FkGnm/pQhpKylLHP2ABLS9rLH9Vaprf5I1QFDAQ/qSGocL9CPuEbulDx?= =?us-ascii?Q?zjQdep2SxeldBc1B37raL2lo75y9EXggN27tYllP90OCb62mXw+JvAZFmBoU?= =?us-ascii?Q?cfXsgU5VGA0zZNj7Bs7tWEQNH5UiFXvivkchCrSDFxBb5vIed9c4wvPXWMD0?= =?us-ascii?Q?NvjXTH4L5HH8fNjnAE/Kv4FgT/GPvEAkUdezyzrv5kvil6JyQrGfaHom+3uP?= =?us-ascii?Q?iQaGJuFTl6Ie3lqFGWc=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1ffae849-a1f7-45c7-c8c7-08dbfb68bbb2 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB4838.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2023 23:19:05.5735 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fU4FgG9kP0h7cpa7Tux7RiI2LgmgpRZkMhppCgE9dd9wU7hIzQ9ilJ8cF/LmNyrj609+k9A9Hcso8GnDz/dcfw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8359 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 15:19:55 -0800 (PST) On Tue, Dec 12, 2023 at 04:54:26PM -0600, Rob Herring wrote: > On Tue, Dec 12, 2023 at 10:19:13PM +0530, Manivannan Sadhasivam wrote: > > On Mon, Dec 11, 2023 at 04:58:30PM -0500, Frank Li wrote: > > > Refactors the clock handling logic in the imx6 PCI driver by adding > > > HAS_CLK_* bitmask define for drvdata::flags . Simplifies the code and makes > > > it more maintainable, as future additions of SOC support will only require > > > straightforward changes. The drvdata::flags and a bitmask ensures a cleaner > > > and more scalable switch-case structure for handling clocks. > > > > > > > Is there any necessity to validate each clock in the driver? I mean, can't you > > just rely on devicetree to provide enough clocks for the functioning of the PCIe > > controller? > > > > If you can rely on devicetree (everyone should in an ideal world), then you can > > just use devm_clk_bulk_get_all() to get all available clocks for the SoC and > > just enable/disable whatever is available. > > Or just use the *_get_optional() variants of functions. They return NULL > such that subsequent calls are just NOPs if the resource is not present. > Of course, they aren't really optional on any given platform in this > case, but does that really matter. I think it'd better use devm_clk_bulk_get() by passed down a clk name list .clk_names = {"pcie_aux", ...}, So it will not silient when dts are not matched requirement. It is not complex because only check once at probe. Frank > > There isn't an optional variant for phys, but it can be added. > > > > > This will greatly simplify the code. > > > > Only downside of this approach is, if the devicetree is not supplying enough > > clocks, then it will be difficult to find why PCIe is not working. But this also > > means that the devicetree is screwed. > > A sufficient schema should prevent that... That's what they're for, not > just torturing people to learn json-schema. :) > > Rob