Received: by 10.213.65.68 with SMTP id h4csp350834imn; Fri, 16 Mar 2018 05:15:16 -0700 (PDT) X-Google-Smtp-Source: AG47ELszB88pp3FvfY5CYWTTHUrU/5p7S9IZJyIURGznyQAbgUWL4WTtLzxhwxAh7sFuoefNw08d X-Received: by 2002:a17:902:7b85:: with SMTP id w5-v6mr1923478pll.131.1521202516001; Fri, 16 Mar 2018 05:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521202515; cv=none; d=google.com; s=arc-20160816; b=J82Zqf1/S+uars/6BPz5Te8B0CANoR9jqSFZT4ZqOQJd5aef79JenfASDXycEWbmKz Xo8RWdTNTX007WHVwyxFpye3o0A4ispfW33q5H5I2AxAAdsJgThoqB3hVoSovtNwmNNQ b93vSXtYIJsPfWF6tztmmcrUOoCShUl1AW51nCPJ6jbRaOo8MO7eHx+pFVgyYMaGJc86 yrnEYvGGMq6OXcBtqJzqwp+wQ61eUTDM4i+aQLdvJwJ2c2eJsaaMk8OBzWfTWjKlFUV5 my4jDuXSi1bJG60bg7EOD5a3c/cN/IGwjWRzvHPB89FXMUSLNij0SY0ldyoG+9JtS8vL oqEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=lzx8KzTsro8PVfBpyN1WNFulDdUG/QWIbTAMgI2MomI=; b=IzQC2PcpSvM5Y7gvxMSjLeBVG7XsNMdCh9xAk+stGgUL1qJmElVj8LeUZdAmkFeCDB yaMGVaFvmwFCsUi7YGzQvpZA5SfG95pXYt+INmbqE4l/8Smd1Rt9EndcDLTkpJT5QBaw grbxmklu20YvfkONgS41XvEI74CnXGbZYOBpV7QFmo0QSFvUy0Caa6mqXHTWGYTYbKQ6 da1wrIBEWTrmRkJyH/QrW42GG91zpuLwS94obXOVhqSbWnITYq4euzvFdCNCbuvP3tq9 1uUggdghwRKDr31ymIqtwgeil7ZldCgj3WKHPLHaRJhrcCq/oj5X+L7gCB9fQqJY743H i0Og== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e7si4308607pgu.760.2018.03.16.05.15.01; Fri, 16 Mar 2018 05:15:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752410AbeCPMN6 (ORCPT + 99 others); Fri, 16 Mar 2018 08:13:58 -0400 Received: from foss.arm.com ([217.140.101.70]:55078 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751236AbeCPMN4 (ORCPT ); Fri, 16 Mar 2018 08:13:56 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 482791529; Fri, 16 Mar 2018 05:13:56 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.207.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 546EA3F487; Fri, 16 Mar 2018 05:13:53 -0700 (PDT) Date: Fri, 16 Mar 2018 12:13:50 +0000 From: Lorenzo Pieralisi To: Bjorn Helgaas Cc: honghui.zhang@mediatek.com, bhelgaas@google.com, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, yingjoe.chen@mediatek.com, eddie.huang@mediatek.com, ryder.lee@mediatek.com, hongkun.cao@mediatek.com, youlin.pei@mediatek.com, yong.wu@mediatek.com, yt.shen@mediatek.com, sean.wang@mediatek.com, xinping.qian@mediatek.com Subject: Re: [PATCH v5 2/2] PCI: mediatek: Set up class type and vendor ID for MT7622 Message-ID: <20180316121350.GB24325@e107981-ln.cambridge.arm.com> References: <1514336394-17747-1-git-send-email-honghui.zhang@mediatek.com> <1514336394-17747-3-git-send-email-honghui.zhang@mediatek.com> <20171227184542.GA79892@bhelgaas-glaptop.roam.corp.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171227184542.GA79892@bhelgaas-glaptop.roam.corp.google.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Dec 27, 2017 at 12:45:42PM -0600, Bjorn Helgaas wrote: [...] > > + /* Set up class code for MT7622 */ > > + val = PCI_CLASS_BRIDGE_PCI << 16; > > + writel(val, port->base + PCIE_CONF_CLASS); > > 1) Your comments mention MT7622 specifically, but this code is run for > both mt2712-pcie and mt7622-pcie. If this code is safe and necessary > for both mt2712-pcie and mt7622-pcie, please remove the mention of > MT7622. > > 2) The first comment mentions both "vendor ID and device ID" but you > don't write the device ID. Since this code applies to both > mt2712-pcie and mt7622-pcie, my guess is that you don't *want* to > write the device ID. If that's the case, please fix the comment. > > 3) If you only need to set the vendor ID, you're performing a 32-bit > write (writel()) to update a 16-bit value. Please use writew() > instead. > > 4) If you only need to set the vendor ID, please use a definition like > "PCIE_CONF_VENDOR_ID" instead of the ambiguous "PCIE_CONF_ID". > > 5) If you only need to set the vendor ID, please update the changelog > to mention "vendor ID" specifically instead of the ambiguous "IDs". > > 6) Please add a space before the closing "*/" of the first comment. > > 7) PCI_CLASS_BRIDGE_PCI is for a PCI-to-PCI bridge, i.e., one that has > PCI on both the primary (upstream) side and the secondary (downstream) > side. That kind of bridge has a type 1 config header (see > PCI_HEADER_TYPE) and the PCI_PRIMARY_BUS and PCI_SECONDARY_BUS > registers tell us the bus number of the primary and secondary sides. > > I don't believe this device is a PCI-to-PCI bridge. I think it's a > *host* bridge that has some non-PCI interface on the upstream side and > should have a type 0 config header. If that's the case you should use > PCI_CLASS_BRIDGE_HOST instead. I think these registers actually programme the root port register space in the RC (whether real or fake - that depends on the RC design) so the class is PCI_CLASS_BRIDGE_PCI, that's what most of host bridge drivers in drivers/pci/host do. I would like to get to the bottom of this since it is indeed misleading (and I do not have HW to test it myself to check my understanding). Thanks, Lorenzo