Skip to content

Commit

Permalink
EDAC/igen6: Make get_mchbar() helper function
Browse files Browse the repository at this point in the history
Mainline: commit a264f71 ("EDAC/igen6: Make get_mchbar() helper function")
from: v6.8-rc1

Make get_mchbar() helper function to retrieve the BAR address of
the memory controller. No function changes.

Intel-SIG: Upstream commit a264f71 ("EDAC/igen6: Make get_mchbar() helper function").

Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
[ Qingdong Shi: amend commit log ]
Signed-off-by: Qingdong Shi <qingdong.shi@intel.com>
  • Loading branch information
qzhuo2 authored and shiqingd committed Feb 23, 2024
1 parent cfa3e9a commit 72597e7
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions drivers/edac/igen6_edac.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,36 @@ static struct work_struct ecclog_work;
#define DID_RPL_P_SKU4 0xa716
#define DID_RPL_P_SKU5 0xa718

static int get_mchbar(struct pci_dev *pdev, u64 *mchbar)
{
union {
u64 v;
struct {
u32 v_lo;
u32 v_hi;
};
} u;

if (pci_read_config_dword(pdev, MCHBAR_OFFSET, &u.v_lo)) {
igen6_printk(KERN_ERR, "Failed to read lower MCHBAR\n");
return -ENODEV;
}

if (pci_read_config_dword(pdev, MCHBAR_OFFSET + 4, &u.v_hi)) {
igen6_printk(KERN_ERR, "Failed to read upper MCHBAR\n");
return -ENODEV;
}

if (!(u.v & MCHBAR_EN)) {
igen6_printk(KERN_ERR, "MCHBAR is disabled\n");
return -ENODEV;
}

*mchbar = MCHBAR_BASE(u.v);

return 0;
}

static bool ehl_ibecc_available(struct pci_dev *pdev)
{
u32 v;
Expand Down Expand Up @@ -1062,22 +1092,8 @@ static int igen6_pci_setup(struct pci_dev *pdev, u64 *mchbar)

igen6_tom = u.v & GENMASK_ULL(38, 20);

if (pci_read_config_dword(pdev, MCHBAR_OFFSET, &u.v_lo)) {
igen6_printk(KERN_ERR, "Failed to read lower MCHBAR\n");
goto fail;
}

if (pci_read_config_dword(pdev, MCHBAR_OFFSET + 4, &u.v_hi)) {
igen6_printk(KERN_ERR, "Failed to read upper MCHBAR\n");
if (get_mchbar(pdev, mchbar))
goto fail;
}

if (!(u.v & MCHBAR_EN)) {
igen6_printk(KERN_ERR, "MCHBAR is disabled\n");
goto fail;
}

*mchbar = MCHBAR_BASE(u.v);

#ifdef CONFIG_EDAC_DEBUG
if (pci_read_config_dword(pdev, TOUUD_OFFSET, &u.v_lo))
Expand Down

0 comments on commit 72597e7

Please sign in to comment.