Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1251246pxa; Thu, 20 Aug 2020 06:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiTdY5aesnawDzsDlE5f5oOw666iHILt5F2m1SBh0AGZcLAtP/lqWmS0aNITofENnM1KMo X-Received: by 2002:a17:906:e251:: with SMTP id gq17mr3217583ejb.445.1597931280755; Thu, 20 Aug 2020 06:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597931280; cv=none; d=google.com; s=arc-20160816; b=KPGbT09gmoyxDHacH5Cy59tD95Jr1pBbwuY2yD0/Q0RnMjc4oEKgluE0jrVM4gxEKE 3dDC6taxznMh1zGFvsvDaSjlKM6tKZFsNdMCxZYzmIlYCeyyKrMgGtl+74+dUEK8dIGx w2jF9SrZRhDoVGMwNJd+3bH9ZkAjqeRIvAQ70ztN01wrcKEEXgfdJlDBy/dHd9zOk/hz 1p+bba3+ai24vq4ifCwAzwoPGDIgw7OPSbDDK7rzYGy20s2j3gKjUZ27Prgw+xfe9jx2 2enEGlfL2yB5eR88DfefKYXC/Nwvkl3ntmgbQnRLblcnXlXyNjPdpFTzu2DtaL68MBSD ne/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l8Wr+mfJKi+zkGZLB9hGsAS4pRQortvWjd4EBfFSuB4=; b=Q+lzZp8sX1MY4yNa5P/2AiPp3EFn1XS7BZOIzmg2fkvZddGjdeod/Abu710lhfz+8n SRVRGZf1T9pHtQwfM1DXCU0KKSSVzd3jkNEm3UGKM9j3Ile6Ejimj7PzJq2cW3yIG5Vz Of0tb4aXLGIlHs5iH254ZM6772M5tYZbhd5ROMm1yFKc2kyMJyP8i4ISGHbeekcXyuTc +xrchVFpcgQinfKaC3q0D6tECLIexvIu7jrFlWiSNY5lM999EcMOckOeT3jSeOVPCGSN gAkByJB460g19h+doJnoxxhVlXjmgKcrp4fKtxFUOHAC3iozQm5blBopLtAN+JjY69Gh MT8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="IQ/Y6iYq"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp17si356012ejc.746.2020.08.20.06.47.36; Thu, 20 Aug 2020 06:48:00 -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="IQ/Y6iYq"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730396AbgHTNqC (ORCPT + 99 others); Thu, 20 Aug 2020 09:46:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:40736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728129AbgHTJaB (ORCPT ); Thu, 20 Aug 2020 05:30:01 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 3599422BEB; Thu, 20 Aug 2020 09:30:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597915800; bh=qIeXM+NKCoFlMSstjLORdhuyqn+uoFkSc/8KPoObLQc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IQ/Y6iYqAL1IQeYffaGRyZ1WI1Krew42A5zwYLjwNJ87CxxEXXpTJM+AfXQ6Per7W YYvjAeBMRoHfqsArC2HxvSnoIdZJbD3XsaNksscONwvmNFXkYKZ+c0RM6G3TqnmJYi HFRxt9Ciyl3TN5tG5u12lvJHDIvPuwLL4ly2Nb8Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , Sasha Levin Subject: [PATCH 5.8 139/232] devres: keep both device name and resource name in pretty name Date: Thu, 20 Aug 2020 11:19:50 +0200 Message-Id: <20200820091619.557998492@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200820091612.692383444@linuxfoundation.org> References: <20200820091612.692383444@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit 35bd8c07db2ce8fd2834ef866240613a4ef982e7 ] Sometimes debugging a device is easiest using devmem on its register map, and that can be seen with /proc/iomem. But some device drivers have many memory regions. Take for example a networking switch. Its memory map used to look like this in /proc/iomem: 1fc000000-1fc3fffff : pcie@1f0000000 1fc000000-1fc3fffff : 0000:00:00.5 1fc010000-1fc01ffff : sys 1fc030000-1fc03ffff : rew 1fc060000-1fc0603ff : s2 1fc070000-1fc0701ff : devcpu_gcb 1fc080000-1fc0800ff : qs 1fc090000-1fc0900cb : ptp 1fc100000-1fc10ffff : port0 1fc110000-1fc11ffff : port1 1fc120000-1fc12ffff : port2 1fc130000-1fc13ffff : port3 1fc140000-1fc14ffff : port4 1fc150000-1fc15ffff : port5 1fc200000-1fc21ffff : qsys 1fc280000-1fc28ffff : ana But after the patch in Fixes: was applied, the information is now presented in a much more opaque way: 1fc000000-1fc3fffff : pcie@1f0000000 1fc000000-1fc3fffff : 0000:00:00.5 1fc010000-1fc01ffff : 0000:00:00.5 1fc030000-1fc03ffff : 0000:00:00.5 1fc060000-1fc0603ff : 0000:00:00.5 1fc070000-1fc0701ff : 0000:00:00.5 1fc080000-1fc0800ff : 0000:00:00.5 1fc090000-1fc0900cb : 0000:00:00.5 1fc100000-1fc10ffff : 0000:00:00.5 1fc110000-1fc11ffff : 0000:00:00.5 1fc120000-1fc12ffff : 0000:00:00.5 1fc130000-1fc13ffff : 0000:00:00.5 1fc140000-1fc14ffff : 0000:00:00.5 1fc150000-1fc15ffff : 0000:00:00.5 1fc200000-1fc21ffff : 0000:00:00.5 1fc280000-1fc28ffff : 0000:00:00.5 That patch made a fair comment that /proc/iomem might be confusing when it shows resources without an associated device, but we can do better than just hide the resource name altogether. Namely, we can print the device name _and_ the resource name. Like this: 1fc000000-1fc3fffff : pcie@1f0000000 1fc000000-1fc3fffff : 0000:00:00.5 1fc010000-1fc01ffff : 0000:00:00.5 sys 1fc030000-1fc03ffff : 0000:00:00.5 rew 1fc060000-1fc0603ff : 0000:00:00.5 s2 1fc070000-1fc0701ff : 0000:00:00.5 devcpu_gcb 1fc080000-1fc0800ff : 0000:00:00.5 qs 1fc090000-1fc0900cb : 0000:00:00.5 ptp 1fc100000-1fc10ffff : 0000:00:00.5 port0 1fc110000-1fc11ffff : 0000:00:00.5 port1 1fc120000-1fc12ffff : 0000:00:00.5 port2 1fc130000-1fc13ffff : 0000:00:00.5 port3 1fc140000-1fc14ffff : 0000:00:00.5 port4 1fc150000-1fc15ffff : 0000:00:00.5 port5 1fc200000-1fc21ffff : 0000:00:00.5 qsys 1fc280000-1fc28ffff : 0000:00:00.5 ana Fixes: 8d84b18f5678 ("devres: always use dev_name() in devm_ioremap_resource()") Signed-off-by: Vladimir Oltean Link: https://lore.kernel.org/r/20200601095826.1757621-1-olteanv@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- lib/devres.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/devres.c b/lib/devres.c index 6ef51f159c54b..ca0d28727ccef 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -119,6 +119,7 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, { resource_size_t size; void __iomem *dest_ptr; + char *pretty_name; BUG_ON(!dev); @@ -129,7 +130,15 @@ __devm_ioremap_resource(struct device *dev, const struct resource *res, size = resource_size(res); - if (!devm_request_mem_region(dev, res->start, size, dev_name(dev))) { + if (res->name) + pretty_name = devm_kasprintf(dev, GFP_KERNEL, "%s %s", + dev_name(dev), res->name); + else + pretty_name = devm_kstrdup(dev, dev_name(dev), GFP_KERNEL); + if (!pretty_name) + return IOMEM_ERR_PTR(-ENOMEM); + + if (!devm_request_mem_region(dev, res->start, size, pretty_name)) { dev_err(dev, "can't request region for resource %pR\n", res); return IOMEM_ERR_PTR(-EBUSY); } -- 2.25.1