| .. | .. |
|---|
| 25 | 25 | * Alex Deucher |
|---|
| 26 | 26 | * Jerome Glisse |
|---|
| 27 | 27 | */ |
|---|
| 28 | | -#include <drm/drmP.h> |
|---|
| 29 | | -#include "radeon_reg.h" |
|---|
| 30 | | -#include "radeon.h" |
|---|
| 31 | | -#include "atom.h" |
|---|
| 32 | 28 | |
|---|
| 33 | | -#include <linux/slab.h> |
|---|
| 34 | 29 | #include <linux/acpi.h> |
|---|
| 30 | +#include <linux/pci.h> |
|---|
| 31 | +#include <linux/slab.h> |
|---|
| 32 | + |
|---|
| 33 | +#include <drm/drm_device.h> |
|---|
| 34 | + |
|---|
| 35 | +#include "atom.h" |
|---|
| 36 | +#include "radeon.h" |
|---|
| 37 | +#include "radeon_reg.h" |
|---|
| 38 | + |
|---|
| 35 | 39 | /* |
|---|
| 36 | 40 | * BIOS. |
|---|
| 37 | 41 | */ |
|---|
| .. | .. |
|---|
| 223 | 227 | |
|---|
| 224 | 228 | if (!found) |
|---|
| 225 | 229 | return false; |
|---|
| 230 | + pci_dev_put(pdev); |
|---|
| 226 | 231 | |
|---|
| 227 | 232 | rdev->bios = kmalloc(size, GFP_KERNEL); |
|---|
| 228 | 233 | if (!rdev->bios) { |
|---|
| .. | .. |
|---|
| 608 | 613 | acpi_size tbl_size; |
|---|
| 609 | 614 | UEFI_ACPI_VFCT *vfct; |
|---|
| 610 | 615 | unsigned offset; |
|---|
| 616 | + bool r = false; |
|---|
| 611 | 617 | |
|---|
| 612 | 618 | if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr))) |
|---|
| 613 | 619 | return false; |
|---|
| 614 | 620 | tbl_size = hdr->length; |
|---|
| 615 | 621 | if (tbl_size < sizeof(UEFI_ACPI_VFCT)) { |
|---|
| 616 | 622 | DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n"); |
|---|
| 617 | | - return false; |
|---|
| 623 | + goto out; |
|---|
| 618 | 624 | } |
|---|
| 619 | 625 | |
|---|
| 620 | 626 | vfct = (UEFI_ACPI_VFCT *)hdr; |
|---|
| .. | .. |
|---|
| 627 | 633 | offset += sizeof(VFCT_IMAGE_HEADER); |
|---|
| 628 | 634 | if (offset > tbl_size) { |
|---|
| 629 | 635 | DRM_ERROR("ACPI VFCT image header truncated\n"); |
|---|
| 630 | | - return false; |
|---|
| 636 | + goto out; |
|---|
| 631 | 637 | } |
|---|
| 632 | 638 | |
|---|
| 633 | 639 | offset += vhdr->ImageLength; |
|---|
| 634 | 640 | if (offset > tbl_size) { |
|---|
| 635 | 641 | DRM_ERROR("ACPI VFCT image truncated\n"); |
|---|
| 636 | | - return false; |
|---|
| 642 | + goto out; |
|---|
| 637 | 643 | } |
|---|
| 638 | 644 | |
|---|
| 639 | 645 | if (vhdr->ImageLength && |
|---|
| .. | .. |
|---|
| 645 | 651 | rdev->bios = kmemdup(&vbios->VbiosContent, |
|---|
| 646 | 652 | vhdr->ImageLength, |
|---|
| 647 | 653 | GFP_KERNEL); |
|---|
| 654 | + if (rdev->bios) |
|---|
| 655 | + r = true; |
|---|
| 648 | 656 | |
|---|
| 649 | | - if (!rdev->bios) |
|---|
| 650 | | - return false; |
|---|
| 651 | | - return true; |
|---|
| 657 | + goto out; |
|---|
| 652 | 658 | } |
|---|
| 653 | 659 | } |
|---|
| 654 | 660 | |
|---|
| 655 | 661 | DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n"); |
|---|
| 656 | | - return false; |
|---|
| 662 | + |
|---|
| 663 | +out: |
|---|
| 664 | + acpi_put_table(hdr); |
|---|
| 665 | + return r; |
|---|
| 657 | 666 | } |
|---|
| 658 | 667 | #else |
|---|
| 659 | 668 | static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev) |
|---|
| .. | .. |
|---|
| 668 | 677 | uint16_t tmp; |
|---|
| 669 | 678 | |
|---|
| 670 | 679 | r = radeon_atrm_get_bios(rdev); |
|---|
| 671 | | - if (r == false) |
|---|
| 680 | + if (!r) |
|---|
| 672 | 681 | r = radeon_acpi_vfct_bios(rdev); |
|---|
| 673 | | - if (r == false) |
|---|
| 682 | + if (!r) |
|---|
| 674 | 683 | r = igp_read_bios_from_vram(rdev); |
|---|
| 675 | | - if (r == false) |
|---|
| 684 | + if (!r) |
|---|
| 676 | 685 | r = radeon_read_bios(rdev); |
|---|
| 677 | | - if (r == false) |
|---|
| 686 | + if (!r) |
|---|
| 678 | 687 | r = radeon_read_disabled_bios(rdev); |
|---|
| 679 | | - if (r == false) |
|---|
| 688 | + if (!r) |
|---|
| 680 | 689 | r = radeon_read_platform_bios(rdev); |
|---|
| 681 | | - if (r == false || rdev->bios == NULL) { |
|---|
| 690 | + if (!r || rdev->bios == NULL) { |
|---|
| 682 | 691 | DRM_ERROR("Unable to locate a BIOS ROM\n"); |
|---|
| 683 | 692 | rdev->bios = NULL; |
|---|
| 684 | 693 | return false; |
|---|