From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_2 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4803AC432BE for ; Thu, 2 Sep 2021 09:38:06 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0937C61008 for ; Thu, 2 Sep 2021 09:38:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0937C61008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:CC:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=R0zAPdyS6s5GMA9RiSlZnGlvnSVQqXx5lMBg/gC92BM=; b=Oxnn91b7VxswVd 3wzoNLOV8npY81qa/03cQqDFxFG7iiRuciTgiqffPOTWnezGZ0yfTyEabDsw2BvB+QsoBuwYFvViR /A5DviWcu70so585zOrkya4vI6shVjCvzPmeP3A3eeB6UeCUpkLWClJfF9243De2GrW3QhZoG4LLW BYXo+kCDIIsPLj3DNGNiDoI+PGYxb/VONKyuEAMyvdcIamHjte53s04kOZDEdNgx/xfRP9Oyc1N1f HXd4EoWbMCXwRYpoVuYr/ZHFotDF01iYKiOJJJ907izsPybqkY2y5D9V2Gl+k+vXs73Suk0mBT81t JM+4pM8WMbiXqcHAXA3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLj8R-00981G-4v; Thu, 02 Sep 2021 09:35:51 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mLj8K-0097zu-GZ; Thu, 02 Sep 2021 09:35:48 +0000 X-UUID: 9a12bd8ba74849989e3f306e74b37293-20210902 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=ZPDQyXrInu0IQssPczuqbUdeSDCOSdcmMPprWdZX5fA=; b=ukqblwj6wBxjKfQ9K3+7xnfsoyB0O6uqn2flde0iLc3SJ6TQLE1O9XpQUD0OXepxMyPaaZMXY3UHBZ1tgk/V3x83glIWsq9IlPJX3vzcsgEqevi5CNtjqfz+DTwBPLoOc30fIZ9IJs7Vhqn//1Gj0gtcjyestb8P90h5A9q995Q=; X-UUID: 9a12bd8ba74849989e3f306e74b37293-20210902 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 902604847; Thu, 02 Sep 2021 02:35:39 -0700 Received: from MTKMBS07N2.mediatek.inc (172.21.101.141) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 2 Sep 2021 02:34:10 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 2 Sep 2021 17:34:09 +0800 Received: from mhfsdcap04 (10.17.3.154) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 2 Sep 2021 17:34:06 +0800 Message-ID: Subject: Re: [PATCH v12 2/6] PCI: mediatek: Add new method to get shared pcie-cfg base address From: Chuanjia Liu To: Rob Herring CC: Bjorn Helgaas , Bjorn Helgaas , Matthias Brugger , Lorenzo Pieralisi , Ryder Lee , "Jianjun Wang" , Yong Wu , PCI , "moderated list:ARM/Mediatek SoC support" , , linux-arm-kernel , "linux-kernel@vger.kernel.org" Date: Thu, 2 Sep 2021 17:34:08 +0800 In-Reply-To: References: <20210830214317.GA27606@bjorn-Precision-5520> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210902_023544_598135_36F3C688 X-CRM114-Status: GOOD ( 37.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 2021-08-31 at 10:17 -0500, Rob Herring wrote: > On Mon, Aug 30, 2021 at 10:31 PM Chuanjia Liu < > chuanjia.liu@mediatek.com> wrote: > > > > On Mon, 2021-08-30 at 16:43 -0500, Bjorn Helgaas wrote: > > > On Mon, Aug 30, 2021 at 03:09:44PM +0800, Chuanjia Liu wrote: > > > > On Fri, 2021-08-27 at 11:46 -0500, Bjorn Helgaas wrote: > > > > > On Mon, Aug 23, 2021 at 11:27:56AM +0800, Chuanjia Liu wrote: > > > > > > @@ -995,6 +1004,14 @@ static int > > > > > > mtk_pcie_subsys_powerup(struct > > > > > > mtk_pcie *pcie) > > > > > > return PTR_ERR(pcie->base); > > > > > > } > > > > > > > > > > > > + cfg_node = of_find_compatible_node(NULL, NULL, > > > > > > + "mediatek,generi > > > > > > c- > > > > > > pciecfg"); > > > > > > + if (cfg_node) { > > > > > > + pcie->cfg = > > > > > > syscon_node_to_regmap(cfg_node); > > > > > > > > > > Other drivers in drivers/pci/controller/ use > > > > > syscon_regmap_lookup_by_phandle() (j721e, dra7xx, keystone, > > > > > layerscape, artpec6) or syscon_regmap_lookup_by_compatible() > > > > > (imx6, > > > > > kirin, v3-semi). > > > > > > > > > > You should do it the same way unless there's a need to be > > > > > different. > > > > > > > > I have used phandle, but Rob suggested to search for the node > > > > by > > > > compatible. > > > > The reason why syscon_regmap_lookup_by_compatible() is not > > > > used here is that the pciecfg node is optional, and there is no > > > > need to > > > > return error when the node is not searched. > > > > > > How about this? > > > > > > regmap = syscon_regmap_lookup_by_compatible("mediatek,generic- > > > pciecfg"); > > > if (!IS_ERR(regmap)) > > > pcie->cfg = regmap; > > +1 > > > > > Hi Bjorn, > > > > We need to deal with three situations > > 1) No error > > 2) The error of the node not found, don't do anything > > 3) Other errors, return errors > > > > I guess you mean > > > > regmap = syscon_regmap_lookup_by_compatible("mediatek,generic- > > pciecfg"); > > if (!IS_ERR(regmap)) > > pcie->cfg = regmap; > > else if (IS_ERR(regmap) && PTR_ERR(regmap) != -ENODEV) > > You already know IS_ERR is true here. > > > return PTR_ERR(regmap); > > syscon_regmap_lookup_by_compatible_optional is the function you are > looking for. The _optional flavor doesn't exist, so create it. There > is one for the phandle lookup. > > > > > I'm not sure if we need this, it seems a little weird and there are > > many drivers in other subsystems that use syscon_node_to_regmap(). > > You are implementing the exact same sequence that > syscon_regmap_lookup_by_compatible() does, so clearly you should be > using it. The one difference is you forgot the of_node_put(). Hi,Rob Thanks for your explanation. You're right. Now I understand use syscon_regmap_lookup_by_compatible() is a better way. I'll follow your advice regmap = syscon_regmap_lookup_by_compatible("mediatek,generic- pciecfg"); if (!IS_ERR(regmap)) pcie->cfg = regmap; else if (PTR_ERR(regmap) != -ENODEV) return PTR_ERR(regmap); Best regards Chuanjia > > Rob > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel