diff options
author | Krzysztof Wilczynski <kw@linux.com> | 2019-08-27 05:49:51 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2019-08-28 16:29:14 -0400 |
commit | 4a2dbeddd3d54484d2e9c12965e4f9bfa1a0ee36 (patch) | |
tree | caf2a8e8e9e8b47356105e462b6d3749affdbe4a | |
parent | 8c3aac6e1b6146ce771b1cabd78e593136d3e5f2 (diff) |
PCI/ACPI: Remove unnecessary struct hotplug_program_ops
Move the ACPI-specific structs hpx_type0, hpx_type1, hpx_type2 and
hpx_type3 to drivers/pci/pci-acpi.c as they are not used anywhere else.
Then remove the struct hotplug_program_ops that has been shared between
drivers/pci/probe.c and drivers/pci/pci-acpi.c from drivers/pci/pci.h as it
is no longer needed.
The struct hotplug_program_ops was added by 87fcf12e846a ("PCI/ACPI: Remove
the need for 'struct hotplug_params'") and replaced previously used struct
hotplug_params enabling the support for the _HPX Type 3 Setting Record that
was added by f873c51a155a ("PCI/ACPI: Implement _HPX Type 3 Setting
Record").
The new struct allowed for the static functions such program_hpx_type0(),
program_hpx_type1(), etc., from the drivers/pci/probe.c to be called from
the function pci_acpi_program_hp_params() in the drivers/pci/pci-acpi.c.
Previously a programming of _HPX Type 0 was as follows:
drivers/pci/probe.c:
program_hpx_type0()
...
pci_configure_device()
hp_ops = {
.program_type0 = program_hpx_type0,
...
}
pci_acpi_program_hp_params(&hp_ops)
drivers/pci/pci-acpi.c:
pci_acpi_program_hp_params(&hp_ops)
acpi_run_hpx(hp_ops)
decode_type0_hpx_record()
hp_ops->program_type0 # program_hpx_type0() called via hp_ops
After the ACPI-specific functions, structs, enums, etc., have been moved to
drivers/pci/pci-acpi.c there is no need for the hotplug_program_ops as all
of the _HPX Type 0, 1, 2 and 3 are directly accessible.
Link: https://lore.kernel.org/r/20190827094951.10613-4-kw@linux.com
Signed-off-by: Krzysztof Wilczynski <kw@linux.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
-rw-r--r-- | drivers/pci/pci-acpi.c | 95 | ||||
-rw-r--r-- | drivers/pci/pci.h | 74 | ||||
-rw-r--r-- | drivers/pci/probe.c | 9 |
3 files changed, 76 insertions, 102 deletions
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index 0bfabb3f9931..6e65d1ff93da 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -118,6 +118,15 @@ phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) | |||
118 | return (phys_addr_t)mcfg_addr; | 118 | return (phys_addr_t)mcfg_addr; |
119 | } | 119 | } |
120 | 120 | ||
121 | /* _HPX PCI Setting Record (Type 0); same as _HPP */ | ||
122 | struct hpx_type0 { | ||
123 | u32 revision; /* Not present in _HPP */ | ||
124 | u8 cache_line_size; /* Not applicable to PCIe */ | ||
125 | u8 latency_timer; /* Not applicable to PCIe */ | ||
126 | u8 enable_serr; | ||
127 | u8 enable_perr; | ||
128 | }; | ||
129 | |||
121 | static struct hpx_type0 pci_default_type0 = { | 130 | static struct hpx_type0 pci_default_type0 = { |
122 | .revision = 1, | 131 | .revision = 1, |
123 | .cache_line_size = 8, | 132 | .cache_line_size = 8, |
@@ -126,7 +135,7 @@ static struct hpx_type0 pci_default_type0 = { | |||
126 | .enable_perr = 0, | 135 | .enable_perr = 0, |
127 | }; | 136 | }; |
128 | 137 | ||
129 | void program_hpx_type0(struct pci_dev *dev, struct hpx_type0 *hpx) | 138 | static void program_hpx_type0(struct pci_dev *dev, struct hpx_type0 *hpx) |
130 | { | 139 | { |
131 | u16 pci_cmd, pci_bctl; | 140 | u16 pci_cmd, pci_bctl; |
132 | 141 | ||
@@ -187,7 +196,15 @@ static acpi_status decode_type0_hpx_record(union acpi_object *record, | |||
187 | return AE_OK; | 196 | return AE_OK; |
188 | } | 197 | } |
189 | 198 | ||
190 | void program_hpx_type1(struct pci_dev *dev, struct hpx_type1 *hpx) | 199 | /* _HPX PCI-X Setting Record (Type 1) */ |
200 | struct hpx_type1 { | ||
201 | u32 revision; | ||
202 | u8 max_mem_read; | ||
203 | u8 avg_max_split; | ||
204 | u16 tot_max_split; | ||
205 | }; | ||
206 | |||
207 | static void program_hpx_type1(struct pci_dev *dev, struct hpx_type1 *hpx) | ||
191 | { | 208 | { |
192 | int pos; | 209 | int pos; |
193 | 210 | ||
@@ -243,7 +260,28 @@ static bool pcie_root_rcb_set(struct pci_dev *dev) | |||
243 | return false; | 260 | return false; |
244 | } | 261 | } |
245 | 262 | ||
246 | void program_hpx_type2(struct pci_dev *dev, struct hpx_type2 *hpx) | 263 | /* _HPX PCI Express Setting Record (Type 2) */ |
264 | struct hpx_type2 { | ||
265 | u32 revision; | ||
266 | u32 unc_err_mask_and; | ||
267 | u32 unc_err_mask_or; | ||
268 | u32 unc_err_sever_and; | ||
269 | u32 unc_err_sever_or; | ||
270 | u32 cor_err_mask_and; | ||
271 | u32 cor_err_mask_or; | ||
272 | u32 adv_err_cap_and; | ||
273 | u32 adv_err_cap_or; | ||
274 | u16 pci_exp_devctl_and; | ||
275 | u16 pci_exp_devctl_or; | ||
276 | u16 pci_exp_lnkctl_and; | ||
277 | u16 pci_exp_lnkctl_or; | ||
278 | u32 sec_unc_err_sever_and; | ||
279 | u32 sec_unc_err_sever_or; | ||
280 | u32 sec_unc_err_mask_and; | ||
281 | u32 sec_unc_err_mask_or; | ||
282 | }; | ||
283 | |||
284 | static void program_hpx_type2(struct pci_dev *dev, struct hpx_type2 *hpx) | ||
247 | { | 285 | { |
248 | int pos; | 286 | int pos; |
249 | u32 reg32; | 287 | u32 reg32; |
@@ -369,6 +407,24 @@ static acpi_status decode_type2_hpx_record(union acpi_object *record, | |||
369 | return AE_OK; | 407 | return AE_OK; |
370 | } | 408 | } |
371 | 409 | ||
410 | /* _HPX PCI Express Setting Record (Type 3) */ | ||
411 | struct hpx_type3 { | ||
412 | u16 device_type; | ||
413 | u16 function_type; | ||
414 | u16 config_space_location; | ||
415 | u16 pci_exp_cap_id; | ||
416 | u16 pci_exp_cap_ver; | ||
417 | u16 pci_exp_vendor_id; | ||
418 | u16 dvsec_id; | ||
419 | u16 dvsec_rev; | ||
420 | u16 match_offset; | ||
421 | u32 match_mask_and; | ||
422 | u32 match_value; | ||
423 | u16 reg_offset; | ||
424 | u32 reg_mask_and; | ||
425 | u32 reg_mask_or; | ||
426 | }; | ||
427 | |||
372 | enum hpx_type3_dev_type { | 428 | enum hpx_type3_dev_type { |
373 | HPX_TYPE_ENDPOINT = BIT(0), | 429 | HPX_TYPE_ENDPOINT = BIT(0), |
374 | HPX_TYPE_LEG_END = BIT(1), | 430 | HPX_TYPE_LEG_END = BIT(1), |
@@ -498,7 +554,7 @@ static void program_hpx_type3_register(struct pci_dev *dev, | |||
498 | pos, orig_value, write_reg); | 554 | pos, orig_value, write_reg); |
499 | } | 555 | } |
500 | 556 | ||
501 | void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx) | 557 | static void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx) |
502 | { | 558 | { |
503 | if (!hpx) | 559 | if (!hpx) |
504 | return; | 560 | return; |
@@ -529,8 +585,7 @@ static void parse_hpx3_register(struct hpx_type3 *hpx3_reg, | |||
529 | } | 585 | } |
530 | 586 | ||
531 | static acpi_status program_type3_hpx_record(struct pci_dev *dev, | 587 | static acpi_status program_type3_hpx_record(struct pci_dev *dev, |
532 | union acpi_object *record, | 588 | union acpi_object *record) |
533 | const struct hotplug_program_ops *hp_ops) | ||
534 | { | 589 | { |
535 | union acpi_object *fields = record->package.elements; | 590 | union acpi_object *fields = record->package.elements; |
536 | u32 desc_count, expected_length, revision; | 591 | u32 desc_count, expected_length, revision; |
@@ -554,7 +609,7 @@ static acpi_status program_type3_hpx_record(struct pci_dev *dev, | |||
554 | for (i = 0; i < desc_count; i++) { | 609 | for (i = 0; i < desc_count; i++) { |
555 | reg_fields = fields + 3 + i * 14; | 610 | reg_fields = fields + 3 + i * 14; |
556 | parse_hpx3_register(&hpx3, reg_fields); | 611 | parse_hpx3_register(&hpx3, reg_fields); |
557 | hp_ops->program_type3(dev, &hpx3); | 612 | program_hpx_type3(dev, &hpx3); |
558 | } | 613 | } |
559 | 614 | ||
560 | break; | 615 | break; |
@@ -567,8 +622,7 @@ static acpi_status program_type3_hpx_record(struct pci_dev *dev, | |||
567 | return AE_OK; | 622 | return AE_OK; |
568 | } | 623 | } |
569 | 624 | ||
570 | static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | 625 | static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle) |
571 | const struct hotplug_program_ops *hp_ops) | ||
572 | { | 626 | { |
573 | acpi_status status; | 627 | acpi_status status; |
574 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; | 628 | struct acpi_buffer buffer = {ACPI_ALLOCATE_BUFFER, NULL}; |
@@ -610,24 +664,24 @@ static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | |||
610 | status = decode_type0_hpx_record(record, &hpx0); | 664 | status = decode_type0_hpx_record(record, &hpx0); |
611 | if (ACPI_FAILURE(status)) | 665 | if (ACPI_FAILURE(status)) |
612 | goto exit; | 666 | goto exit; |
613 | hp_ops->program_type0(dev, &hpx0); | 667 | program_hpx_type0(dev, &hpx0); |
614 | break; | 668 | break; |
615 | case 1: | 669 | case 1: |
616 | memset(&hpx1, 0, sizeof(hpx1)); | 670 | memset(&hpx1, 0, sizeof(hpx1)); |
617 | status = decode_type1_hpx_record(record, &hpx1); | 671 | status = decode_type1_hpx_record(record, &hpx1); |
618 | if (ACPI_FAILURE(status)) | 672 | if (ACPI_FAILURE(status)) |
619 | goto exit; | 673 | goto exit; |
620 | hp_ops->program_type1(dev, &hpx1); | 674 | program_hpx_type1(dev, &hpx1); |
621 | break; | 675 | break; |
622 | case 2: | 676 | case 2: |
623 | memset(&hpx2, 0, sizeof(hpx2)); | 677 | memset(&hpx2, 0, sizeof(hpx2)); |
624 | status = decode_type2_hpx_record(record, &hpx2); | 678 | status = decode_type2_hpx_record(record, &hpx2); |
625 | if (ACPI_FAILURE(status)) | 679 | if (ACPI_FAILURE(status)) |
626 | goto exit; | 680 | goto exit; |
627 | hp_ops->program_type2(dev, &hpx2); | 681 | program_hpx_type2(dev, &hpx2); |
628 | break; | 682 | break; |
629 | case 3: | 683 | case 3: |
630 | status = program_type3_hpx_record(dev, record, hp_ops); | 684 | status = program_type3_hpx_record(dev, record); |
631 | if (ACPI_FAILURE(status)) | 685 | if (ACPI_FAILURE(status)) |
632 | goto exit; | 686 | goto exit; |
633 | break; | 687 | break; |
@@ -643,8 +697,7 @@ static acpi_status acpi_run_hpx(struct pci_dev *dev, acpi_handle handle, | |||
643 | return status; | 697 | return status; |
644 | } | 698 | } |
645 | 699 | ||
646 | static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle, | 700 | static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle) |
647 | const struct hotplug_program_ops *hp_ops) | ||
648 | { | 701 | { |
649 | acpi_status status; | 702 | acpi_status status; |
650 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 703 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; |
@@ -679,20 +732,18 @@ static acpi_status acpi_run_hpp(struct pci_dev *dev, acpi_handle handle, | |||
679 | hpx0.enable_serr = fields[2].integer.value; | 732 | hpx0.enable_serr = fields[2].integer.value; |
680 | hpx0.enable_perr = fields[3].integer.value; | 733 | hpx0.enable_perr = fields[3].integer.value; |
681 | 734 | ||
682 | hp_ops->program_type0(dev, &hpx0); | 735 | program_hpx_type0(dev, &hpx0); |
683 | 736 | ||
684 | exit: | 737 | exit: |
685 | kfree(buffer.pointer); | 738 | kfree(buffer.pointer); |
686 | return status; | 739 | return status; |
687 | } | 740 | } |
688 | 741 | ||
689 | /* pci_get_hp_params | 742 | /* pci_acpi_program_hp_params |
690 | * | 743 | * |
691 | * @dev - the pci_dev for which we want parameters | 744 | * @dev - the pci_dev for which we want parameters |
692 | * @hpp - allocated by the caller | ||
693 | */ | 745 | */ |
694 | int pci_acpi_program_hp_params(struct pci_dev *dev, | 746 | int pci_acpi_program_hp_params(struct pci_dev *dev) |
695 | const struct hotplug_program_ops *hp_ops) | ||
696 | { | 747 | { |
697 | acpi_status status; | 748 | acpi_status status; |
698 | acpi_handle handle, phandle; | 749 | acpi_handle handle, phandle; |
@@ -715,10 +766,10 @@ int pci_acpi_program_hp_params(struct pci_dev *dev, | |||
715 | * this pci dev. | 766 | * this pci dev. |
716 | */ | 767 | */ |
717 | while (handle) { | 768 | while (handle) { |
718 | status = acpi_run_hpx(dev, handle, hp_ops); | 769 | status = acpi_run_hpx(dev, handle); |
719 | if (ACPI_SUCCESS(status)) | 770 | if (ACPI_SUCCESS(status)) |
720 | return 0; | 771 | return 0; |
721 | status = acpi_run_hpp(dev, handle, hp_ops); | 772 | status = acpi_run_hpp(dev, handle); |
722 | if (ACPI_SUCCESS(status)) | 773 | if (ACPI_SUCCESS(status)) |
723 | return 0; | 774 | return 0; |
724 | if (acpi_is_root_bridge(handle)) | 775 | if (acpi_is_root_bridge(handle)) |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index dad43c64b350..97180274c60b 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -608,80 +608,10 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { } | |||
608 | static inline void pci_aer_clear_device_status(struct pci_dev *dev) { } | 608 | static inline void pci_aer_clear_device_status(struct pci_dev *dev) { } |
609 | #endif | 609 | #endif |
610 | 610 | ||
611 | /* _HPX PCI Setting Record (Type 0); same as _HPP */ | ||
612 | struct hpx_type0 { | ||
613 | u32 revision; /* Not present in _HPP */ | ||
614 | u8 cache_line_size; /* Not applicable to PCIe */ | ||
615 | u8 latency_timer; /* Not applicable to PCIe */ | ||
616 | u8 enable_serr; | ||
617 | u8 enable_perr; | ||
618 | }; | ||
619 | |||
620 | /* _HPX PCI-X Setting Record (Type 1) */ | ||
621 | struct hpx_type1 { | ||
622 | u32 revision; | ||
623 | u8 max_mem_read; | ||
624 | u8 avg_max_split; | ||
625 | u16 tot_max_split; | ||
626 | }; | ||
627 | |||
628 | /* _HPX PCI Express Setting Record (Type 2) */ | ||
629 | struct hpx_type2 { | ||
630 | u32 revision; | ||
631 | u32 unc_err_mask_and; | ||
632 | u32 unc_err_mask_or; | ||
633 | u32 unc_err_sever_and; | ||
634 | u32 unc_err_sever_or; | ||
635 | u32 cor_err_mask_and; | ||
636 | u32 cor_err_mask_or; | ||
637 | u32 adv_err_cap_and; | ||
638 | u32 adv_err_cap_or; | ||
639 | u16 pci_exp_devctl_and; | ||
640 | u16 pci_exp_devctl_or; | ||
641 | u16 pci_exp_lnkctl_and; | ||
642 | u16 pci_exp_lnkctl_or; | ||
643 | u32 sec_unc_err_sever_and; | ||
644 | u32 sec_unc_err_sever_or; | ||
645 | u32 sec_unc_err_mask_and; | ||
646 | u32 sec_unc_err_mask_or; | ||
647 | }; | ||
648 | |||
649 | /* _HPX PCI Express Setting Record (Type 3) */ | ||
650 | struct hpx_type3 { | ||
651 | u16 device_type; | ||
652 | u16 function_type; | ||
653 | u16 config_space_location; | ||
654 | u16 pci_exp_cap_id; | ||
655 | u16 pci_exp_cap_ver; | ||
656 | u16 pci_exp_vendor_id; | ||
657 | u16 dvsec_id; | ||
658 | u16 dvsec_rev; | ||
659 | u16 match_offset; | ||
660 | u32 match_mask_and; | ||
661 | u32 match_value; | ||
662 | u16 reg_offset; | ||
663 | u32 reg_mask_and; | ||
664 | u32 reg_mask_or; | ||
665 | }; | ||
666 | |||
667 | void program_hpx_type0(struct pci_dev *dev, struct hpx_type0 *hpx); | ||
668 | void program_hpx_type1(struct pci_dev *dev, struct hpx_type1 *hpx); | ||
669 | void program_hpx_type2(struct pci_dev *dev, struct hpx_type2 *hpx); | ||
670 | void program_hpx_type3(struct pci_dev *dev, struct hpx_type3 *hpx); | ||
671 | |||
672 | struct hotplug_program_ops { | ||
673 | void (*program_type0)(struct pci_dev *dev, struct hpx_type0 *hpx); | ||
674 | void (*program_type1)(struct pci_dev *dev, struct hpx_type1 *hpx); | ||
675 | void (*program_type2)(struct pci_dev *dev, struct hpx_type2 *hpx); | ||
676 | void (*program_type3)(struct pci_dev *dev, struct hpx_type3 *hpx); | ||
677 | }; | ||
678 | |||
679 | #ifdef CONFIG_ACPI | 611 | #ifdef CONFIG_ACPI |
680 | int pci_acpi_program_hp_params(struct pci_dev *dev, | 612 | int pci_acpi_program_hp_params(struct pci_dev *dev); |
681 | const struct hotplug_program_ops *hp_ops); | ||
682 | #else | 613 | #else |
683 | static inline int pci_acpi_program_hp_params(struct pci_dev *dev, | 614 | static inline int pci_acpi_program_hp_params(struct pci_dev *dev) |
684 | const struct hotplug_program_ops *hp_ops) | ||
685 | { | 615 | { |
686 | return -ENODEV; | 616 | return -ENODEV; |
687 | } | 617 | } |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 5847b557dc9a..cdf34a3c531a 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -2100,13 +2100,6 @@ static void pci_configure_serr(struct pci_dev *dev) | |||
2100 | 2100 | ||
2101 | static void pci_configure_device(struct pci_dev *dev) | 2101 | static void pci_configure_device(struct pci_dev *dev) |
2102 | { | 2102 | { |
2103 | static const struct hotplug_program_ops hp_ops = { | ||
2104 | .program_type0 = program_hpx_type0, | ||
2105 | .program_type1 = program_hpx_type1, | ||
2106 | .program_type2 = program_hpx_type2, | ||
2107 | .program_type3 = program_hpx_type3, | ||
2108 | }; | ||
2109 | |||
2110 | pci_configure_mps(dev); | 2103 | pci_configure_mps(dev); |
2111 | pci_configure_extended_tags(dev, NULL); | 2104 | pci_configure_extended_tags(dev, NULL); |
2112 | pci_configure_relaxed_ordering(dev); | 2105 | pci_configure_relaxed_ordering(dev); |
@@ -2114,7 +2107,7 @@ static void pci_configure_device(struct pci_dev *dev) | |||
2114 | pci_configure_eetlp_prefix(dev); | 2107 | pci_configure_eetlp_prefix(dev); |
2115 | pci_configure_serr(dev); | 2108 | pci_configure_serr(dev); |
2116 | 2109 | ||
2117 | pci_acpi_program_hp_params(dev, &hp_ops); | 2110 | pci_acpi_program_hp_params(dev); |
2118 | } | 2111 | } |
2119 | 2112 | ||
2120 | static void pci_release_capabilities(struct pci_dev *dev) | 2113 | static void pci_release_capabilities(struct pci_dev *dev) |