Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp274697ybt; Mon, 6 Jul 2020 09:02:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoVv3svh4SrgAPZK+23Ld2Ablq8+5dqK8bfEndIlgyQPY3xxC6HFUEIKMwXpq3fHuvFRxS X-Received: by 2002:aa7:d04e:: with SMTP id n14mr33053917edo.161.1594051338548; Mon, 06 Jul 2020 09:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594051338; cv=none; d=google.com; s=arc-20160816; b=vaPLbmy+3bHOsXWJJFbA2GJ4CRP14LJJkvtu9RvTPzhSqp1SOMTb506S7p/zEE1mSV Pvj1i6WnlVKJOlIRVQ0bkfjH9/gMC7KdQnoO1Xs36fTx98eFwIgdWGwYFwR42FACWu4f rqaNGeI5jYsRc7iRXVA8Ss0iXzw3t/EiPAuxQGQJhGUdwNpryEnMnxAP3D8aJcSNIyKg U4jIh/axyc7rp5vSKed92aEu+VmeLV6Du/lvO+Z9Liv/TiY1Z00zpP6v4JXeBSKgGSyf IINDN9fcD/Sps+rsAoS8Io0D1S7TeXoQlVJtZu3kU9++z4Np3NzmJYMaycuLjzujSdFY avbA== 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=TIcZL4Y7av8NXLOyj/7n4bE9B83zkuILeOuqN8lxZ3I=; b=E0cDpffaKl2c/WKmm5djeEHTxF7OOknP5+N83rG7GXioxyBsuWXTW3y2heRJGT1Mjt 7m5kkqPLDffyCudrEO5lu/q5KrbqQLr+anFCb3fWkoZeZTW/jh9f3lUCfXgd40JJbtmN 5T1hLHG7kYbk2KVuJ6p7ovw20vmVk//TNOdzqJGBhft3Z37Dfu0vG4WPeTfjBPUQkXJX 8bEg1ZgcW3Vjyjqbh6kU8DxBOoLa7dsghqXwOkLg2HF1Ojt6reEhOgkAMHAuqPK6qvSW UhbFQBeGdQjN6zdd0JIPAM95PFxBPpTgwhIPwLEbizufrUjWVgMvBym3JoWpZKM/rPmR 9EOw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si13495582edq.166.2020.07.06.09.01.55; Mon, 06 Jul 2020 09:02:18 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729437AbgGFP6z (ORCPT + 99 others); Mon, 6 Jul 2020 11:58:55 -0400 Received: from foss.arm.com ([217.140.110.172]:51924 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729358AbgGFP6y (ORCPT ); Mon, 6 Jul 2020 11:58:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E78281FB; Mon, 6 Jul 2020 08:58:53 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B293C3F68F; Mon, 6 Jul 2020 08:58:52 -0700 (PDT) Date: Mon, 6 Jul 2020 16:58:47 +0100 From: Lorenzo Pieralisi To: Rob Herring Cc: "Chocron, Jonathan" , "zhengdejin5@gmail.com" , "linux-kernel@vger.kernel.org" , "thomas.petazzoni@bootlin.com" , "pratyush.anand@gmail.com" , "linux-pci@vger.kernel.org" , "bhelgaas@google.com" , "tjoseph@cadence.com" Subject: Re: [PATCH v1] PCI: controller: Remove duplicate error message Message-ID: <20200706155847.GA32050@e121166-lin.cambridge.arm.com> References: <20200526150954.4729-1-zhengdejin5@gmail.com> <1d7703d5c29dc9371ace3645377d0ddd9c89be30.camel@amazon.com> <20200527132005.GA7143@nuc8i5> <1b54c08f759c101a8db162f4f62c6b6a8a455d3f.camel@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 02, 2020 at 09:01:13AM -0600, Rob Herring wrote: [...] > > > In fact, I think its error handling is clear enough, It just goes > > > wrong > > > in three places, as follows: > > > > > > void __iomem *devm_pci_remap_cfg_resource(struct device *dev, > > > struct resource *res) > > > { > > > resource_size_t size; > > > const char *name; > > > void __iomem *dest_ptr; > > > > > > BUG_ON(!dev); > > > > > > if (!res || resource_type(res) != IORESOURCE_MEM) { > > > dev_err(dev, "invalid resource\n"); > > > return IOMEM_ERR_PTR(-EINVAL); > > > } > > > > > In the above error case there is no indication of which resource failed > > (mainly relevant if the resource name is missing in the devicetree, > > since in the drivers you are changing platform_get_resource_byname() is > > mostly used). In the existing drivers' code, on return from this > > function in this case, the name would be printed by the caller. > > A driver should only have one call to devm_pci_remap_cfg_resource() as > there's only 1 config space. However, it looks like this function is > frequently used on what is not config space which is a bigger issue. That certainly is and should be fixed. > If this error happens, it's almost always going to be a NULL ptr as > platform_get_resource_byname() would have set IORESOURCE_MEM. Perhaps > a WARN here so you get a backtrace to the caller location. +1 > > > size = resource_size(res); > > > name = res->name ?: dev_name(dev); > > > > > > if (!devm_request_mem_region(dev, res->start, size, name)) { > > > dev_err(dev, "can't request region for resource > > > %pR\n", res); > > > return IOMEM_ERR_PTR(-EBUSY); > > > } > > > > > > dest_ptr = devm_pci_remap_cfgspace(dev, res->start, size); > > > if (!dest_ptr) { > > > dev_err(dev, "ioremap failed for resource %pR\n", > > > res); > > > devm_release_mem_region(dev, res->start, size); > > > dest_ptr = IOMEM_ERR_PTR(-ENOMEM); > > > } > > > > > The other 2 error cases as well don't print the resource name as far as > > I recall (they will at least print the resource start/end). > > Start/end are what are important for why either of these functions > failed. > > But sure, we could add 'name' here. That's a separate patch IMO. I agree. In sum, I think it is OK to proceed with this patch, provided we send follow-ups as discussed here, are we in agreement ? Lorenzo