Received: by 10.213.65.68 with SMTP id h4csp351532imn; Fri, 16 Mar 2018 05:16:29 -0700 (PDT) X-Google-Smtp-Source: AG47ELu0djTx+ss3tUvidyNF4CJ2lgWhrx6D+5WEXRc1SGnH6gnzELjM8QSXQr/zEC69sE+e3Qbf X-Received: by 2002:a17:902:678f:: with SMTP id g15-v6mr1981541plk.120.1521202589652; Fri, 16 Mar 2018 05:16:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521202589; cv=none; d=google.com; s=arc-20160816; b=FvlwB79ZkDJr8mT+inpDiNQQclXWr5WnMNef8oClaq/WTXYyt6l73XwpwrgO+clhLL oe4ke9va0lKx3s+JDzhiHo7TA7S888lY24Raj986iax+LUaDBB0L9l1Oc2vFgztHU2oN d8apTx/Nz1dgkPvaK/PaLm1QiuQBjbYgKH+lRWcXSqmjfcs++bS39/sMMH/rH5OS/bnT Uhh4hxLYCDupqCBTX+SFRMgOWPx+/c3JhBuve5Ug2o78ipJPDnXcqxJGp+GFKona96ZM N5Br3884Hu+76y6lHFLHX+MMzoK78HHsYWkuftYF310v97jJNaEilI5X6PEoviC1GRTg oC4g== 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=AVnp0q9KSH/XFg3LbMdEw1fZKNYFDTCuWT7nl8Ch1ro=; b=WcJhhA0BkxvkZyyPi8GkokJ3H5u6zG3jGmuCbdBTg3ozmTzd5SJkMB7HT8os7Og+3Q I805i6PZk/g3n6hFE3H883rWnAN/2K4eI3RATCOrfv0sxY2V3C1PxK/7Fnc/QVtQUkuh xp4gAr2TjvZf/aiYQ5nGZ8vX9mU8a9eYnUHKZ0/7YWTz8lF6lzBzGWypxaN2CMzFG4Jy Aron4KPL7d7IcDfFxbHR7TNw51kXQx6JZidXa5u5V4iOCU8apBycWoxhztZcxPzTDDkV axCQyPAgITg3bp2fZ40QTezueFDZTmsXiofqfw0u9v3g5gMZXFxMjeW/Oi85xhVfGnNx rd7Q== 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.16.14; Fri, 16 Mar 2018 05:16:29 -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 S1752560AbeCPMPM (ORCPT + 99 others); Fri, 16 Mar 2018 08:15:12 -0400 Received: from foss.arm.com ([217.140.101.70]:55110 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752214AbeCPMPJ (ORCPT ); Fri, 16 Mar 2018 08:15:09 -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 293CB1529; Fri, 16 Mar 2018 05:15:09 -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 36D563F487; Fri, 16 Mar 2018 05:15:06 -0700 (PDT) Date: Fri, 16 Mar 2018 12:15:03 +0000 From: Lorenzo Pieralisi To: Honghui Zhang Cc: Bjorn Helgaas , 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: <20180316121503.GC24325@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> <1514425152.25872.39.camel@mhfsdcap03> <20180102105659.GB10536@red-moon> <1514961544.25872.49.camel@mhfsdcap03> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1514961544.25872.49.camel@mhfsdcap03> 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, Jan 03, 2018 at 02:39:04PM +0800, Honghui Zhang wrote: > On Tue, 2018-01-02 at 10:56 +0000, Lorenzo Pieralisi wrote: > > On Thu, Dec 28, 2017 at 09:39:12AM +0800, Honghui Zhang wrote: > > > On Wed, 2017-12-27 at 12:45 -0600, Bjorn Helgaas wrote: > > > > On Wed, Dec 27, 2017 at 08:59:54AM +0800, honghui.zhang@mediatek.com wrote: > > > > > From: Honghui Zhang > > > > > > > > > > > + /* 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. > > > > > > Hmm, the code snippet added here will only be executed by MT7622, since > > > MT2712 will not enter this "if (pcie->base) {" condition. > > > Should the mention of MT7622 must be removed in this case? > > > > You should add an explicit way (eg of_device_is_compatible() match for > > instance) to apply the quirk just on the platform that requires it. > > > > Checking for "if (pcie->base)" is really not the way to do it. > > > > hi, Lorenzo, > Thanks very much for your advise. > Passing the compatible string or platform data into this function needed > to add some new field in the struct mtk_pcie_port, then I guess both set > it for MT2712 and MT7622 is an easy way, since re-setting those values > for MT2712 is safe. > > > > > 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. > > > > > > > > > > My bad, I did not check the comments carefully. > > > Thanks. > > > > > > > 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. > > > > > > > > > > Ok, thanks, I guess I could use the following code snippet in the next > > > version: > > > val = readl(port->base + PCIE_CONF_VENDOR_ID) > > > val &= ~GENMASK(15, 0); > > > val |= PCI_VENDOR_ID_MEDIATEK; > > > writel(val, port->base + PCIE_CONF_VENDOR_ID); > > > > Have you read Bjorn's comment ? Or there is a problem with using > > a writew() ? > > > > This control register is a 32bit register, I'm not sure whether the apb > bus support write an 16bit value with 16bit but not 32bit address > alignment. I prefer the more safety old way of writel. > > I need to do more test about the writew if the code elegant is more > important. I will mark this patch as "Changes Requested" waiting for a new version, thanks. Lorenzo