Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5223906img; Wed, 27 Mar 2019 04:40:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNnhukn8zesJCCr/7alHwTxVlcW7y8x/uXmfZoHcYtp96Eupfx228i7YvZl7pAq8QP2IR/ X-Received: by 2002:a63:c112:: with SMTP id w18mr6117300pgf.200.1553686815353; Wed, 27 Mar 2019 04:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553686815; cv=none; d=google.com; s=arc-20160816; b=q3/mRawhex2vkN0dO7CE85Kfemr32a8eE776431Svp3SHFRg7LZW3Hr4+zLlBXNWQf 5sp/HADH/VgJ6FxN/NntPb8YGMa9/rj5OihrpjMg6mCxBP6BLxq5jxnGtP0wHPi9nvie NvucX4RnRXIJhhnSS9bUFZfHwWM3bckltl9F7mOBqQucpKO8fKwdA1LJOh6J3zp957xq YJy1cQSMIKNp2AeQWsb0W+vGHmzayJQDyORxtVNeTKYRIN08qMf7Kv8IP3iQFUoVIwFs 2zJnAGl6nyr2t/sND8LQYVIMg7M5r3huiU61mu9scnnEBBIbK7RVQ/HcqumNY6a01/Zg 2KQw== 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; bh=avVVrHeXEV5bUx81T5u6gK3AeKOHr8aajQTwWZoQYW0=; b=Xtfj3U9MppBadCgsvqxCcpqu5QLvktCNPk+EjHh2QID6oAJaza+7A+ca6x72lR4a4L XR0eXQCOiyDL2Z9qQi4HkBF7zgk76BWQDMAr7ZpLJTXrL9pzGFbyYFsbY2iA1p3saitO J00A/hgmqSjnWlWrTUWWhucBtx9ufUWKoQY1lYbpQXeApaIwf/hPksvgiE60ee+YLtS6 +zdh+wwFQNTFw38fAQyfqZNUg6embTkLEzskqLqLzpYO30nITsm1AUVVFa1Wk1ZRTYcq EbdPV+dTb8to9x86sHJMF4Bx6sSlqRZtAJgxwLM76Z09CCVpX25+CTR7mQemUZ7v0TV+ hQLg== 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 k22si17998989pfa.215.2019.03.27.04.39.59; Wed, 27 Mar 2019 04:40: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 S1728245AbfC0LjR (ORCPT + 99 others); Wed, 27 Mar 2019 07:39:17 -0400 Received: from foss.arm.com ([217.140.101.70]:53156 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726296AbfC0LjQ (ORCPT ); Wed, 27 Mar 2019 07:39:16 -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 41D5E374; Wed, 27 Mar 2019 04:39:16 -0700 (PDT) Received: from e107981-ln.cambridge.arm.com (e107981-ln.cambridge.arm.com [10.1.197.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0A7803F557; Wed, 27 Mar 2019 04:39:13 -0700 (PDT) Date: Wed, 27 Mar 2019 11:39:11 +0000 From: Lorenzo Pieralisi To: David Woodhouse Cc: Jonathan Chocron , linux-pci@vger.kernel.org, bhelgaas@google.com, linux-kernel@vger.kernel.org, vaerov@amazon.com, benh@kernel.crashing.org, alisaidi@amazon.com, zeev@amazon.com, ronenk@amazon.com, barakw@amazon.com, Gustavo Pimentel , Zhou Wang Subject: Re: [PATCH v2] PCI: al: Add Amazon Annapurna Labs PCIe host controller driver Message-ID: <20190327113911.GB8331@e107981-ln.cambridge.arm.com> References: <1553512040-4453-1-git-send-email-jonnyc@amazon.com> <1553594455-30436-1-git-send-email-jonnyc@amazon.com> <20190326121727.GA4171@e107981-ln.cambridge.arm.com> <7bab98421e2144a934d369e49454f0424c2a3758.camel@amazon.co.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7bab98421e2144a934d369e49454f0424c2a3758.camel@amazon.co.uk> 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, Mar 27, 2019 at 09:43:26AM +0000, David Woodhouse wrote: > On Tue, 2019-03-26 at 12:17 +0000, Lorenzo Pieralisi wrote: > > This code is basically identical to (apart from the string matching > > the DBI resource) > > > > drivers/pci/controller/pcie-hisi.c > > > > because, as you said, that's a DW quirk that is really not > > platform specific AFAICS. > > > > Not that I am really fond of the idea but in practice we can > > create a quirk that applies to all host controllers DW based, > > in case they want to boot with ACPI, this patch is basically > > code duplication. > > Having chatted to Jonny in a little more detail... this isn't quite > duplicate code. On the Annapurna implementation we have fixed the > alignment constraints so we can just use pci_generic_config_read() > directly instead of forcing alignment. We only need to filter out the > "ghost" devices on bus zero. > > There might eventually be scope for some form of consolidation, but it > doesn't really seem clear at this point that it would be worth it. The pci_ecam_ops.init function can be certainly reused but I agree duplicating it is not a big deal either - I just noticed it and asked. we can merge code as-is and think about writing a common init function if/when needed. > There are three separate quirks needed for different versions of the DW > controller. > > One is that the config space of the controller itself shows up multiple > times in all slots of bus zero. > > The second is that bus zero cannot be accessed through ECAM and must be > accessed through a separate MMIO region. > > The third is the requirement for 32-bit alignment of the host > controller's config space (through the special MMIO region). I missed this one - thanks for clarifying. > Some vendors have managed to work around some of these issues, for > example Annapurna fixing the alignment one. It looks like the three DT > matches in pci-host-generic.c which use pci_dw_ecam_bus_ops are > assuming the hardware suffers only issue #1 from the list above, and > not the other two. > > The Annapurna hardware gives us a new combination, and that's why it > isn't quite a duplicate. Again, there may be scope for consolidation in > the future but it's not clear what it should look like. Especially as > when exposed through DT, both the hisi and al versions seem to do > things quite differently and need their own specific code there anyway. DT PCI host bridge bootstrap is a different story and on that consolidation is all but impossible. I just want to keep MCFG ECAM quirks as simple as possible, code as it stands is horrible enough and I wish I could remove the mechanism in the future rather than adding more to it, hopefully we are getting there. > There will be a DT variant of the AL driver coming in the near future, > but when it's exposed via ACPI in the "as close to ECAM compliant as we > could make it in this iteration of the hardware" mode, it's relatively > simple so we did that patch first. That's fine, no problems with that. Thanks, Lorenzo