From patchwork Thu Sep 22 12:14:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9345171 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35F0B6077A for ; Thu, 22 Sep 2016 12:16:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27B262AA52 for ; Thu, 22 Sep 2016 12:16:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C7662AA56; Thu, 22 Sep 2016 12:16:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3B512AA52 for ; Thu, 22 Sep 2016 12:16:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756761AbcIVMPv (ORCPT ); Thu, 22 Sep 2016 08:15:51 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:63118 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756722AbcIVMPt (ORCPT ); Thu, 22 Sep 2016 08:15:49 -0400 Received: from wuerfel.localnet ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue102) with ESMTPSA (Nemesis) id 0MWAdl-1bSwfj2Lg9-00XNHH; Thu, 22 Sep 2016 14:14:34 +0200 From: Arnd Bergmann To: Gabriele Paoloni Cc: zhichang , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "lorenzo.pieralisi@arm.com" , "minyard@acm.org" , "linux-pci@vger.kernel.org" , "gregkh@linuxfoundation.org" , John Garry , "will.deacon@arm.com" , "linux-kernel@vger.kernel.org" , Yuanzhichang , Linuxarm , "xuwei (O)" , "linux-serial@vger.kernel.org" , "benh@kernel.crashing.org" , "zourongrong@gmail.com" , "liviu.dudau@arm.com" , "kantyzc@163.com" Subject: Re: [PATCH V3 2/4] ARM64 LPC: LPC driver implementation on Hip06 Date: Thu, 22 Sep 2016 14:14:31 +0200 Message-ID: <9178320.n4yHmfyPA3@wuerfel> User-Agent: KMail/5.1.3 (Linux/4.4.0-34-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: References: <1473855354-150093-1-git-send-email-yuanzhichang@hisilicon.com> <3538381.vOsx75UXVU@wuerfel> MIME-Version: 1.0 X-Provags-ID: V03:K0:r8MjfCwn9Rd8QeTlEzwbW3lJwMBoeQfGNzvdvWVAPGKdPnYHoW7 7BZUetfZ6GN2RmGDA+WVRFHIzrKXaCZRizluxVT+W1ZhXzo5HTOYA3rmmVFGY6p9EIp/l/q blHyHEOWUxuiw4quW+YK+8zs8cuvQ16d3h5CQetyQUJq5Icmt8EOuVkiBG928JaaHbbNcoe z2/P0ktH9H0Vf7b2Om1Cw== X-UI-Out-Filterresults: notjunk:1; V01:K0:MTv3Obhs5Hs=:GmxeRSc48Oj+/aQybrzmsM iUUwTzulszHh7UF4qyM3Gi1xAcPrfVCsoQ8HWMLSwrPtPDTppy7TXMBeCPhqeciX3hgtAZLU1 ceK8WjqFmujC+Ij3850hXYTvQKtIdZHxMBURxjkJni9btbNCO6C4ofbFurv/LvFpiXRQySO6N JjyGO2jcaEhDXCmR6YjStsCAJONFU4RibTwCZO1RFEOtgkpNfkMEhhickCkhhh2GlTnruLcdg cSQU2LleAQoR+rL1R816pCmZaJ4OK/sCYUx6GK9M3rSN80Sg59VLEPNdssGYKiv1MELnowh5s XkXAaeoaQk8C6peVWmI45Vlw6CoWbrf8FQm+Rqe/fFs1Je6r5eZfCmBsS1yGUKaglSq0pjXoT dUC9ePqJehlclsOlBDgXuzqaYy5rDiqJmJ8RPU8/9l2f3m0JZq7j0RgQsqbhZTqfLGqA5AGNf 0TQmX/1osPoID0BscWnxntVNejJVeHrTT1Jnr0r4bionGLRoaAqJvoXHNSMqB6XRnipq4+Lq4 FmDma1rIFK9BMFTl++uYBihqoDwbpZqm2+RDDlMTfPHmBG+EMtzW60oG5CyiuPD1UUDcsGJU/ WYbvO91gOY3JbvpiDNsuKzKnOmcN5XZxCzE9DSbY8i7iPiN2PwufFfxtcbN0r5i8HLU6uFT64 mnXluulh2AfWX2b0Tsq1Asf+/rkzRmmjQgYDcmyp5Zs9x6g== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Thursday, September 22, 2016 11:55:45 AM CEST Gabriele Paoloni wrote: > > > I think extending of_empty_ranges_quirk() may be a reasonable > > solution. > > > What do you think Arnd? > > > > I don't really like that idea, that quirk is meant to work around > > broken DTs, but we can just make the DT valid and implement the > > code properly. > > Ok I understand your point where it is not right to use of_empty_ranges_quirk() > As a quirk is used to work around broken HW or broken FW (as in this case) > rather than to fix code > > What about the following? I think adding the check you suggested next to > of_empty_ranges_quirk() is adding the case we need in the right point (thus > avoiding any duplication) > > --- a/drivers/of/address.c > +++ b/drivers/of/address.c > @@ -457,6 +457,15 @@ static struct of_bus *of_match_bus(struct device_node *np) > return NULL; > } > > +static inline int of_isa_indirect_io(struct device_node *np) > +{ > + /* > + * check if the current node is an isa bus and if indirectio operation > + * are registered > + */ > + return (of_bus_isa_match(np) && arm64_extio_ops); > +} > + > static int of_empty_ranges_quirk(struct device_node *np) > { > if (IS_ENABLED(CONFIG_PPC)) { > @@ -503,7 +512,7 @@ static int of_translate_one(struct device_node *parent, struct of_bus *bus, > * This code is only enabled on powerpc. --gcl > */ > ranges = of_get_property(parent, rprop, &rlen); > - if (ranges == NULL && !of_empty_ranges_quirk(parent)) { > + if (ranges == NULL && !of_empty_ranges_quirk(parent) && !of_isa_indirect_io(parent)) { > pr_debug("OF: no ranges; cannot translate\n"); > return 1; > } I don't see what effect that would have. What do you want to achieve with this? I think all we need from this function is to return '1' if we hit an ISA I/O window, and that should happen for the two interesting cases, either no 'ranges' at all, or no translation for the range in question, so that __of_translate_address can return OF_BAD_ADDR, and we can enter the special case handling in the caller, that handles it like Arnd --- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/of/address.c b/drivers/of/address.c index 02b2903fe9d2..a18d96843fae 100644 --- a/drivers/of/address.c +++ b/drivers/of/address.c @@ -685,17 +685,24 @@ static int __of_address_to_resource(struct device_node *dev, if ((flags & (IORESOURCE_IO | IORESOURCE_MEM)) == 0) return -EINVAL; taddr = of_translate_address(dev, addrp); - if (taddr == OF_BAD_ADDR) - return -EINVAL; memset(r, 0, sizeof(struct resource)); + if (flags & IORESOURCE_IO) { unsigned long port; - port = pci_address_to_pio(taddr); + + if (taddr == OF_BAD_ADDR) + port = arch_of_address_to_pio(dev, addrp) + else + port = pci_address_to_pio(taddr); + if (port == (unsigned long)-1) return -EINVAL; r->start = port; r->end = port + size - 1; } else { + if (taddr == OF_BAD_ADDR) + return -EINVAL; + r->start = taddr; r->end = taddr + size - 1; }