From patchwork Sat Jun 15 02:44:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2726201 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 312D79F967 for ; Sat, 15 Jun 2013 02:49:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D5231201CC for ; Sat, 15 Jun 2013 02:49:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D95882019D for ; Sat, 15 Jun 2013 02:49:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754015Ab3FOCtJ (ORCPT ); Fri, 14 Jun 2013 22:49:09 -0400 Received: from mail-pd0-f180.google.com ([209.85.192.180]:37659 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753097Ab3FOCtI (ORCPT ); Fri, 14 Jun 2013 22:49:08 -0400 Received: by mail-pd0-f180.google.com with SMTP id 10so1108773pdi.11 for ; Fri, 14 Jun 2013 19:49:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer; bh=riJ6YrmO1PVlmWzrofWXnV3o4limBW4QS4KKZORhA1A=; b=B39yKzi6r7uqU/wCzmzY6bf0PVlK1KMfFivDI5BsGdbm4ZQoeCszOeWiXOfxSTV95J OumcmDTbcTgJwc7swvXDKPwEAgs8pUvdw6HOVOFNOOiHMP5jseCbV/gGgA6L+4xm8BYi zpB06Bsy/I1Dw3X4G7vhWfDlgm31+4iPWGh6WPbv+ikZ7tHpqnGR6//dTjD632pSLo0q SRdguo/p6WfPR0j0ZtRh41mDIhrHav3hL3BzlP8NnpLxy7YEp0WjQJ3gcolu1a4L+Uyu N3rtlB6pa6+6D1wIosR/fMNnQXoLMHpz7ZmekJCbQa3MK3bkOXX2ThYbYlQB7jMYNGyi hD3A== X-Received: by 10.66.232.196 with SMTP id tq4mr5012181pac.167.1371264547300; Fri, 14 Jun 2013 19:49:07 -0700 (PDT) Received: from localhost.localdomain ([114.250.102.26]) by mx.google.com with ESMTPSA id z5sm4313057pbk.0.2013.06.14.19.49.03 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 19:49:06 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas Cc: Jiang Liu , Yijing Wang , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] PCI: only WARN_ON() when pci_ioremap_bar() is called for io port BAR Date: Sat, 15 Jun 2013 10:44:04 +0800 Message-Id: <1371264244-6007-1-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Ideally caller should check availability of IO BAR resource before calling pci_ioremap_bar(), but no caller doing that yet:( The WARN_ON() in function pci_ioremap_bar() is used to warn the caller if it's called for an IO port BAR, so disable it if OS fails to allocate resources for the BAR, otherwise it will generate heavy log messages as below (actually the last line of log message is enough for analysis): [ 157.383390] ------------[ cut here ]------------ [ 157.383396] WARNING: at drivers/pci/pci.c:130 pci_ioremap_bar+0x69/0x70() [ 157.383397] Modules linked in: ata_generic pata_acpi pata_marvell fuse zram(C) rfcomm bnep snd_hda_codec_hdmi snd_hda_codec_realtek rtsx_pci_ms rtsx_pci_sdmmc memstick mmc_core iTCO_wdt iTCO_vendor_support arc4 uvcvideo iwldvm videobuf2_vmalloc videobuf2_memops mac80211 qcserial videobuf2_core usb_wwan videodev media usbserial btusb bluetooth iwlwifi coretemp kvm_intel kvm sony_laptop cfg80211 snd_hda_intel snd_hda_codec rfkill i915 pcspkr r8169 joydev mii rtsx_pci snd_hwdep intel_agp snd_pcm intel_gtt i2c_algo_bit snd_page_alloc drm_kms_helper snd_timer drm lpc_ich snd agpgart i2c_i801 mfd_core sha256_ssse3 sha256_generic dm_crypt raid0 md_mod crc32_pclmul crc32c_intel ghash_clmulni_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd xhci_hcd ehci_pci ehci_hcd dm_mirror dm_region_hash [ 157.383462] dm_log dm_mod [last unloaded: microcode] [ 157.383469] CPU: 0 PID: 40 Comm: kworker/0:1 Tainted: G WC 3.10.0-rc4 #7 [ 157.383473] Hardware name: Sony Corporation VPCZ23A4R/VAIO, BIOS R1013H5 05/21/2012 [ 157.383478] Workqueue: kacpi_hotplug _handle_hotplug_event_bridge [ 157.383481] ffffffff81a2a114 ffff880253d3f808 ffffffff8165aab8 ffff880253d3f848 [ 157.383487] ffffffff8103c8cb ffff880253d3f828 ffff880253152800 ffff88022eb09000 [ 157.383494] 0000000000000000 ffff880253153000 0000000000000001 ffff880253d3f858 [ 157.383500] Call Trace: [ 157.383507] [] dump_stack+0x19/0x1b [ 157.383513] [] warn_slowpath_common+0x6b/0xa0 [ 157.383519] [] warn_slowpath_null+0x15/0x20 [ 157.383524] [] pci_ioremap_bar+0x69/0x70 [ 157.383532] [] azx_first_init+0x56/0x600 [snd_hda_intel] [ 157.383536] [] ? pci_get_domain_bus_and_slot+0x2f/0x70 [ 157.383540] [] azx_probe+0x555/0x940 [snd_hda_intel] [ 157.383543] [] ? trace_hardirqs_on+0xd/0x10 [ 157.383546] [] local_pci_probe+0x46/0x80 [ 157.383549] [] pci_device_probe+0xf9/0x120 [ 157.383549] [] pci_device_probe+0xf9/0x120 [ 157.383554] [] driver_probe_device+0x76/0x220 [ 157.383556] [] __device_attach+0x4b/0x60 [ 157.383559] [] ? __driver_attach+0xb0/0xb0 [ 157.383561] [] bus_for_each_drv+0x5c/0x90 [ 157.383564] [] device_attach+0x98/0xb0 [ 157.383566] [] pci_bus_add_device+0x34/0x60 [ 157.383569] [] pci_bus_add_devices+0x39/0xa0 [ 157.383571] [] pci_bus_add_devices+0x87/0xa0 [ 157.383573] [] pci_bus_add_devices+0x87/0xa0 [ 157.383575] [] pci_bus_add_devices+0x87/0xa0 [ 157.383577] [] pci_bus_add_devices+0x87/0xa0 [ 157.383580] [] enable_device+0x370/0x450 [ 157.383583] [] acpiphp_enable_slot+0xca/0x140 [ 157.383585] [] acpiphp_check_bridge+0x77/0x100 [ 157.383587] [] _handle_hotplug_event_bridge+0x13d/0x290 [ 157.383591] [] process_one_work+0x1c2/0x560 [ 157.383594] [] ? process_one_work+0x157/0x560 [ 157.383596] [] worker_thread+0x116/0x370 [ 157.383598] [] ? manage_workers.isra.20+0x2d0/0x2d0 [ 157.383601] [] kthread+0xd6/0xe0 [ 157.383604] [] ? _raw_spin_unlock_irq+0x2b/0x60 [ 157.383607] [] ? __init_kthread_worker+0x70/0x70 [ 157.383610] [] ret_from_fork+0x7c/0xb0 [ 157.383613] [] ? __init_kthread_worker+0x70/0x70 [ 157.383614] ---[ end trace f366acc9dc87b38a ]--- [ 157.383616] hda-intel 0000:16:00.1: ioremap error Signed-off-by: Jiang Liu Cc: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/pci/pci.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index a899d8b..9288161 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -127,7 +127,8 @@ void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) * Make sure the BAR is actually a memory resource, not an IO resource */ if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { - WARN_ON(1); + if (pci_resource_flags(pdev, bar)) + WARN_ON(1); return NULL; } return ioremap_nocache(pci_resource_start(pdev, bar),