diff options
author | Yan, Zheng <zheng.z.yan@intel.com> | 2012-10-24 04:42:20 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-10-24 04:57:03 -0400 |
commit | 032c3851f51141e30de02ed0bc50a7743dfd776d (patch) | |
tree | 73be4029c23d4f6b584231961c122c5caed2b781 /arch/x86 | |
parent | 58e9eaf06f5476cb2192ec1d012674ce5e79dd21 (diff) |
perf/x86/uncore: Handle pci_read_config_dword() errors
This, beyond handling corner cases, also fixes some build warnings:
arch/x86/kernel/cpu/perf_event_intel_uncore.c: In function ‘snbep_uncore_pci_disable_box’:
arch/x86/kernel/cpu/perf_event_intel_uncore.c:124:9: warning: ‘config’ is used uninitialized in this function [-Wuninitialized]
arch/x86/kernel/cpu/perf_event_intel_uncore.c: In function ‘snbep_uncore_pci_enable_box’:
arch/x86/kernel/cpu/perf_event_intel_uncore.c:135:9: warning: ‘config’ is used uninitialized in this function [-Wuninitialized]
arch/x86/kernel/cpu/perf_event_intel_uncore.c: In function ‘snbep_uncore_pci_read_counter’:
arch/x86/kernel/cpu/perf_event_intel_uncore.c:164:2: warning: ‘count’ is used uninitialized in this function [-Wuninitialized]
Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Cc: a.p.zijlstra@chello.nl
Link: http://lkml.kernel.org/r/1351068140-13456-1-git-send-email-zheng.z.yan@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kernel/cpu/perf_event_intel_uncore.c | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c index 5df8d32ba91e..6f874771ee65 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c | |||
@@ -118,22 +118,24 @@ static void snbep_uncore_pci_disable_box(struct intel_uncore_box *box) | |||
118 | { | 118 | { |
119 | struct pci_dev *pdev = box->pci_dev; | 119 | struct pci_dev *pdev = box->pci_dev; |
120 | int box_ctl = uncore_pci_box_ctl(box); | 120 | int box_ctl = uncore_pci_box_ctl(box); |
121 | u32 config; | 121 | u32 config = 0; |
122 | 122 | ||
123 | pci_read_config_dword(pdev, box_ctl, &config); | 123 | if (!pci_read_config_dword(pdev, box_ctl, &config)) { |
124 | config |= SNBEP_PMON_BOX_CTL_FRZ; | 124 | config |= SNBEP_PMON_BOX_CTL_FRZ; |
125 | pci_write_config_dword(pdev, box_ctl, config); | 125 | pci_write_config_dword(pdev, box_ctl, config); |
126 | } | ||
126 | } | 127 | } |
127 | 128 | ||
128 | static void snbep_uncore_pci_enable_box(struct intel_uncore_box *box) | 129 | static void snbep_uncore_pci_enable_box(struct intel_uncore_box *box) |
129 | { | 130 | { |
130 | struct pci_dev *pdev = box->pci_dev; | 131 | struct pci_dev *pdev = box->pci_dev; |
131 | int box_ctl = uncore_pci_box_ctl(box); | 132 | int box_ctl = uncore_pci_box_ctl(box); |
132 | u32 config; | 133 | u32 config = 0; |
133 | 134 | ||
134 | pci_read_config_dword(pdev, box_ctl, &config); | 135 | if (!pci_read_config_dword(pdev, box_ctl, &config)) { |
135 | config &= ~SNBEP_PMON_BOX_CTL_FRZ; | 136 | config &= ~SNBEP_PMON_BOX_CTL_FRZ; |
136 | pci_write_config_dword(pdev, box_ctl, config); | 137 | pci_write_config_dword(pdev, box_ctl, config); |
138 | } | ||
137 | } | 139 | } |
138 | 140 | ||
139 | static void snbep_uncore_pci_enable_event(struct intel_uncore_box *box, struct perf_event *event) | 141 | static void snbep_uncore_pci_enable_event(struct intel_uncore_box *box, struct perf_event *event) |
@@ -156,7 +158,7 @@ static u64 snbep_uncore_pci_read_counter(struct intel_uncore_box *box, struct pe | |||
156 | { | 158 | { |
157 | struct pci_dev *pdev = box->pci_dev; | 159 | struct pci_dev *pdev = box->pci_dev; |
158 | struct hw_perf_event *hwc = &event->hw; | 160 | struct hw_perf_event *hwc = &event->hw; |
159 | u64 count; | 161 | u64 count = 0; |
160 | 162 | ||
161 | pci_read_config_dword(pdev, hwc->event_base, (u32 *)&count); | 163 | pci_read_config_dword(pdev, hwc->event_base, (u32 *)&count); |
162 | pci_read_config_dword(pdev, hwc->event_base + 4, (u32 *)&count + 1); | 164 | pci_read_config_dword(pdev, hwc->event_base + 4, (u32 *)&count + 1); |
@@ -603,11 +605,12 @@ static struct pci_driver snbep_uncore_pci_driver = { | |||
603 | /* | 605 | /* |
604 | * build pci bus to socket mapping | 606 | * build pci bus to socket mapping |
605 | */ | 607 | */ |
606 | static void snbep_pci2phy_map_init(void) | 608 | static int snbep_pci2phy_map_init(void) |
607 | { | 609 | { |
608 | struct pci_dev *ubox_dev = NULL; | 610 | struct pci_dev *ubox_dev = NULL; |
609 | int i, bus, nodeid; | 611 | int i, bus, nodeid; |
610 | u32 config; | 612 | int err = 0; |
613 | u32 config = 0; | ||
611 | 614 | ||
612 | while (1) { | 615 | while (1) { |
613 | /* find the UBOX device */ | 616 | /* find the UBOX device */ |
@@ -618,10 +621,14 @@ static void snbep_pci2phy_map_init(void) | |||
618 | break; | 621 | break; |
619 | bus = ubox_dev->bus->number; | 622 | bus = ubox_dev->bus->number; |
620 | /* get the Node ID of the local register */ | 623 | /* get the Node ID of the local register */ |
621 | pci_read_config_dword(ubox_dev, 0x40, &config); | 624 | err = pci_read_config_dword(ubox_dev, 0x40, &config); |
625 | if (err) | ||
626 | break; | ||
622 | nodeid = config; | 627 | nodeid = config; |
623 | /* get the Node ID mapping */ | 628 | /* get the Node ID mapping */ |
624 | pci_read_config_dword(ubox_dev, 0x54, &config); | 629 | err = pci_read_config_dword(ubox_dev, 0x54, &config); |
630 | if (err) | ||
631 | break; | ||
625 | /* | 632 | /* |
626 | * every three bits in the Node ID mapping register maps | 633 | * every three bits in the Node ID mapping register maps |
627 | * to a particular node. | 634 | * to a particular node. |
@@ -633,7 +640,11 @@ static void snbep_pci2phy_map_init(void) | |||
633 | } | 640 | } |
634 | } | 641 | } |
635 | }; | 642 | }; |
636 | return; | 643 | |
644 | if (ubox_dev) | ||
645 | pci_dev_put(ubox_dev); | ||
646 | |||
647 | return err ? pcibios_err_to_errno(err) : 0; | ||
637 | } | 648 | } |
638 | /* end of Sandy Bridge-EP uncore support */ | 649 | /* end of Sandy Bridge-EP uncore support */ |
639 | 650 | ||
@@ -2578,9 +2589,11 @@ static int __init uncore_pci_init(void) | |||
2578 | 2589 | ||
2579 | switch (boot_cpu_data.x86_model) { | 2590 | switch (boot_cpu_data.x86_model) { |
2580 | case 45: /* Sandy Bridge-EP */ | 2591 | case 45: /* Sandy Bridge-EP */ |
2592 | ret = snbep_pci2phy_map_init(); | ||
2593 | if (ret) | ||
2594 | return ret; | ||
2581 | pci_uncores = snbep_pci_uncores; | 2595 | pci_uncores = snbep_pci_uncores; |
2582 | uncore_pci_driver = &snbep_uncore_pci_driver; | 2596 | uncore_pci_driver = &snbep_uncore_pci_driver; |
2583 | snbep_pci2phy_map_init(); | ||
2584 | break; | 2597 | break; |
2585 | default: | 2598 | default: |
2586 | return 0; | 2599 | return 0; |