Skip to content
This repository was archived by the owner on Oct 12, 2018. It is now read-only.

Commit 0fe90a9

Browse files
committed
Fixed broken support for Polaris cards (AMD RX 460/470/480/560/570/580)
1 parent 2563155 commit 0fe90a9

File tree

4 files changed

+27
-23
lines changed

4 files changed

+27
-23
lines changed

GPUSensors/RadeonSensors/RadeonSensors.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,29 @@ bool RadeonSensors::managedStart(IOService *provider)
103103
// }
104104
// }
105105

106+
IOMemoryMap * mmio5 = NULL;
107+
IOMemoryDescriptor * theDescriptor;
108+
IOPhysicalAddress bar = (IOPhysicalAddress)((card.pdev->configRead32(kIOPCIConfigBaseAddress5)) & ~0x3f);
109+
theDescriptor = IOMemoryDescriptor::withPhysicalAddress (bar, 0x80000, kIODirectionOutIn);
110+
if(theDescriptor != NULL)
111+
{
112+
mmio5 = theDescriptor->map();
113+
}
106114
card.mmio = card.pdev->mapDeviceMemoryWithIndex(1);
107115

108116
if (!card.mmio || 0 == card.mmio->getPhysicalAddress()) {
109117
HWSensorsInfoLog("failed to map device memory");
110118
return false;
111119
}
112120

121+
if (card.mmio) {
122+
card.mmio_base = (volatile UInt8 *)card.mmio->getVirtualAddress();
123+
HWSensorsInfoLog("mmio_base=0x%llx\n", card.mmio->getPhysicalAddress());
124+
}
125+
else {
126+
HWSensorsInfoLog(" have no mmio\n ");
127+
return false;
128+
}
113129
card.family = CHIP_FAMILY_UNKNOW;
114130
card.int_thermal_type = THERMAL_TYPE_NONE;
115131

@@ -350,6 +366,14 @@ bool RadeonSensors::managedStart(IOService *provider)
350366
}
351367
}
352368

369+
if (!card.mmio_base || card.family >= CHIP_FAMILY_HAWAII) {
370+
if (mmio5 && mmio5->getPhysicalAddress() != 0) {
371+
card.mmio = mmio5;
372+
card.mmio_base = (volatile UInt8 *)card.mmio->getVirtualAddress();
373+
}
374+
HWSensorsInfoLog(" use mmio5 at 0x%llx\n", (unsigned long long)card.mmio_base);
375+
}
376+
353377
char key[5];
354378

355379
if (card.get_core_temp) {

GPUSensors/RadeonSensors/radeon.h

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ typedef struct {
6262
struct radeon_device {
6363
IOPCIDevice *pdev;
6464
IOMemoryMap *mmio;
65+
volatile UInt8 *mmio_base;
6566
UInt32 chip_id;
6667
UInt16 family;
6768
RADEONCardInfo info;

GPUSensors/RadeonSensors/radeon_chipinfo_gen.h

+1
Original file line numberDiff line numberDiff line change
@@ -702,4 +702,5 @@ static RADEONCardInfo RADEONCards[] = {
702702
{ 0x67BE, CHIP_FAMILY_HAWAII, 0, 0, 0, 0, 0 },
703703
{ 0x67EF, CHIP_FAMILY_POLARIS, 0, 0, 0, 0, 0 },
704704
{ 0x67DF, CHIP_FAMILY_POLARIS, 0, 0, 0, 0, 0 },
705+
{ 0x67FF, CHIP_FAMILY_POLARIS, 0, 0, 0, 0, 0 },
705706
};

GPUSensors/RadeonSensors/vega.cpp

+1-23
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,8 @@
1818

1919
int vega_get_temp(struct radeon_device *rdev)
2020
{
21-
// I don't know what I am doing...
22-
IOMemoryMap * mmio5 = NULL;
23-
IOMemoryDescriptor * theDescriptor;
24-
IOPhysicalAddress bar = (IOPhysicalAddress)((rdev->pdev->configRead32(kIOPCIConfigBaseAddress5)) & ~0x3f);
25-
26-
theDescriptor = IOMemoryDescriptor::withPhysicalAddress (bar, 0x80000, kIODirectionOutIn);
27-
28-
if(theDescriptor != NULL)
29-
{
30-
mmio5 = theDescriptor->map();
31-
}
32-
33-
IOMemoryMap * mmio = NULL;
34-
volatile UInt8* mmio_base;
35-
36-
if (mmio5 && mmio5->getPhysicalAddress() != 0)
37-
{
38-
mmio = mmio5;
39-
mmio_base = (volatile UInt8 *)mmio->getVirtualAddress();
40-
}
41-
42-
// Finally: temp retrieval
4321
UInt32 temp, actual_temp = 0;
44-
temp = OSReadLittleInt32(((volatile UInt8 *)mmio_base), THM_TCON_CUR_TMP) >> THM_TCON_CUR_TMP__CUR_TEMP__SHIFT;
22+
temp = OSReadLittleInt32(rdev->mmio_base, THM_TCON_CUR_TMP) >> THM_TCON_CUR_TMP__CUR_TEMP__SHIFT;
4523
actual_temp = temp & 0x1ff;
4624

4725
return actual_temp;

0 commit comments

Comments
 (0)