Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2914670ybk; Tue, 12 May 2020 11:11:10 -0700 (PDT) X-Google-Smtp-Source: APiQypKw5VUkfg/tqc/pdSAogtu2t8oe1RaaLm4XrQKHcPt9mq4cHRE+IO+onZ9BUXrsapa+LENp X-Received: by 2002:a17:907:7242:: with SMTP id ds2mr19551166ejc.297.1589307069794; Tue, 12 May 2020 11:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589307069; cv=none; d=google.com; s=arc-20160816; b=rvVWS+hBW6Kua5BkmckX7FVZFlMTG4Fi9Y6jtK05oPtlik6TkTyaTGCfgumXrDTSPJ kDysyAg2sMD98RsWasxG1n7jvNqDo62fwF1DTN9YxfQS79wVUiVyYOy5CQnMz/Xvxc4p vdCP0sQ3Ie5acLVoFh/MiMdTpZwFtdF7WXZDM/pfwGwMNmpUKdxS9c8BBh75XPCTbz5F 439rE5RVAeRiRHfGJbTBqj6aqm6dOXRctSUliSF1XJR2POEdv3/n477WhOKZU/Hw2tZU GgFB4PGOvc/dn540/gvhtjIs7/g1ej7/pkJfvTaAu5RFCnSc1YdXaKJIBI5aL3BPWGSV KwoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=wXwsp4PqXSF8pPzSWntyCqkPglAcqKSjzPEg2ZKTK54=; b=jdQvnS2QRW5INMfF3ErW0l6QqIC2XMTLng1UNlnvF9SPxgI5bAsIDhEoYlKp+jPWc9 wEnbt4Y33JB/1B1U6Bj8jOJR+zEh5R6gxIryg55IxGRWJMQ8wW55K0sCAHCCrXSKbyuY yfkelxBmwsLejcBHuyibl2w5JhLoXpzX2Qm5KbM2hH0FMoMVMwnTsGKpz0j/cWD83kRE lhU6xWloT2mqu9Ha8uCuxqwzQgMhT+h0yMxx1pGoBlbXcdaoLTIICjyEQtQGQn+ZuBC3 OdMTraa35D3qV9cLz0/2itXWxUUwR0R3tIaTvevz/jbi4joxwi3G67Vvd/z3Wtftk/tj bj7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2bwY1ea4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o12si6170536edq.34.2020.05.12.11.10.46; Tue, 12 May 2020 11:11:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2bwY1ea4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730734AbgELSGF (ORCPT + 99 others); Tue, 12 May 2020 14:06:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:53030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728081AbgELSGE (ORCPT ); Tue, 12 May 2020 14:06:04 -0400 Received: from localhost (mobile-166-175-190-200.mycingular.net [166.175.190.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4FD720720; Tue, 12 May 2020 18:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589306764; bh=u6F9DLRbr9iVJIIz0f3H5qz89UqdlJ6qKaSYphCX6ak=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=2bwY1ea4D1zVQuZSsqjre852YXMAh6qn1U4AxMFwEpVakTIAx3F7MvxvEccTa7HqG 0ipEmFqpAqPt7kskzY3xT2LdKxbAyYWAoffOBznznFDRWntjKrn5FCidcUJekMvi62 ZyD3pQqwt6R9ROxTSRhmRqnp1uB+r7/ppVV7NQa0= Date: Tue, 12 May 2020 13:06:02 -0500 From: Bjorn Helgaas To: Jiaxun Yang Cc: linux-pci@vger.kernel.org, Rob Herring , Bjorn Helgaas , Rob Herring , Thomas Bogendoerfer , Huacai Chen , Lorenzo Pieralisi , Paul Burton , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: Re: [PATCH v9 2/5] PCI: Add Loongson PCI Controller support Message-ID: <20200512180602.GA273658@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200512074413.3557835-2-jiaxun.yang@flygoat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 12, 2020 at 03:43:56PM +0800, Jiaxun Yang wrote: > This controller can be found on Loongson-2K SoC, Loongson-3 > systems with RS780E/LS7A PCH. > > The RS780E part of code was previously located at > arch/mips/pci/ops-loongson3.c and now it can use generic PCI > driver implementation. > > Signed-off-by: Jiaxun Yang > Reviewed-by: Rob Herring > +static void system_bus_quirk(struct pci_dev *pdev) > +{ > + u16 tmp; > + > + /* > + * These devices are not sharing resouces with rest of devices > + * on host bus and firmware will ensure their BARs are placed > + * in safe ranges. Also there might be some config registers > + * in their config space so kernel shouldn't ignore them. "Firmware ensuring BARs are placed in 'safe' ranges" is not a sufficient answer. As I said before, Linux needs to know both the ADDRESS and the SIZE of whatever non-standard BARs these are. Otherwise, we're liable to assign that space to a different device. If you have to hard-code the size, so be it. That would mean the hardware is completely broken, but at least we could make Linux deal with it. If the hardware consumes address space we don't know about, we can't deal with that. > + */ > + pdev->mmio_always_on = 1; > + pdev->non_compliant_bars = 1; > +} > +void __iomem *pci_loongson_map_bus(struct pci_bus *bus, unsigned int devfn, > + int where) > +{ > + unsigned char busnum = bus->number; > + struct pci_host_bridge *bridge = pci_find_host_bridge(bus); > + struct loongson_pci *priv = pci_host_bridge_priv(bridge); > + > + /* > + * Do not read more than one device on the bus other than > + * the host bus 0. > + */ If the hardware is restricted such that the root bus number must be zero, pleae say that explicitly here. Otherwise, it just looks like a bug. > + if (priv->flags & FLAG_DEV_FIX && busnum != 0 && > + PCI_SLOT(devfn) > 0) > + return NULL; > + > + /* CFG0 can only access standard space */ > + if (where < PCI_CFG_SPACE_SIZE && priv->cfg0_base) > + return cfg0_map(priv, busnum, devfn, where); > + > + /* CFG1 can access extended space */ > + if (where < PCI_CFG_SPACE_EXP_SIZE && priv->cfg1_base) > + return cfg1_map(priv, busnum, devfn, where); > + > + return NULL; > +}