Skip to content

Commit fb75a37

Browse files
basuamdJiri Kosina
authored andcommitted
HID: amd_sfh: Add functionality to clear interrupts
Newer AMD platforms with SFH may generate interrupts on some events which are unwarranted. Until this is cleared the actual MP2 data processing maybe stalled in some cases. Add a mechanism to clear the pending interrupts (if any) during the driver initialization and sensor command operations. Signed-off-by: Basavaraj Natikar <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent b300667 commit fb75a37

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_pcie.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,20 @@ static void amd_stop_all_sensor_v2(struct amd_mp2_dev *privdata)
9292
writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0);
9393
}
9494

95+
static void amd_sfh_clear_intr_v2(struct amd_mp2_dev *privdata)
96+
{
97+
if (readl(privdata->mmio + AMD_P2C_MSG(4))) {
98+
writel(0, privdata->mmio + AMD_P2C_MSG(4));
99+
writel(0xf, privdata->mmio + AMD_P2C_MSG(5));
100+
}
101+
}
102+
103+
static void amd_sfh_clear_intr(struct amd_mp2_dev *privdata)
104+
{
105+
if (privdata->mp2_ops->clear_intr)
106+
privdata->mp2_ops->clear_intr(privdata);
107+
}
108+
95109
void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info)
96110
{
97111
union sfh_cmd_param cmd_param;
@@ -196,13 +210,15 @@ static void amd_mp2_pci_remove(void *privdata)
196210
struct amd_mp2_dev *mp2 = privdata;
197211
amd_sfh_hid_client_deinit(privdata);
198212
mp2->mp2_ops->stop_all(mp2);
213+
amd_sfh_clear_intr(mp2);
199214
}
200215

201216
static const struct amd_mp2_ops amd_sfh_ops_v2 = {
202217
.start = amd_start_sensor_v2,
203218
.stop = amd_stop_sensor_v2,
204219
.stop_all = amd_stop_all_sensor_v2,
205220
.response = amd_sfh_wait_response_v2,
221+
.clear_intr = amd_sfh_clear_intr_v2,
206222
};
207223

208224
static const struct amd_mp2_ops amd_sfh_ops = {
@@ -265,8 +281,13 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
265281
mp2_select_ops(privdata);
266282

267283
rc = amd_sfh_hid_client_init(privdata);
268-
if (rc)
284+
if (rc) {
285+
amd_sfh_clear_intr(privdata);
286+
dev_err(&pdev->dev, "amd_sfh_hid_client_init failed\n");
269287
return rc;
288+
}
289+
290+
amd_sfh_clear_intr(privdata);
270291

271292
return devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
272293
}
@@ -294,6 +315,7 @@ static int __maybe_unused amd_mp2_pci_resume(struct device *dev)
294315
}
295316

296317
schedule_delayed_work(&cl_data->work_buffer, msecs_to_jiffies(AMD_SFH_IDLE_LOOP));
318+
amd_sfh_clear_intr(mp2);
297319

298320
return 0;
299321
}
@@ -318,6 +340,7 @@ static int __maybe_unused amd_mp2_pci_suspend(struct device *dev)
318340
}
319341

320342
cancel_delayed_work_sync(&cl_data->work_buffer);
343+
amd_sfh_clear_intr(mp2);
321344

322345
return 0;
323346
}

drivers/hid/amd-sfh-hid/amd_sfh_pcie.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,6 @@ struct amd_mp2_ops {
141141
void (*stop)(struct amd_mp2_dev *privdata, u16 sensor_idx);
142142
void (*stop_all)(struct amd_mp2_dev *privdata);
143143
int (*response)(struct amd_mp2_dev *mp2, u8 sid, u32 sensor_sts);
144+
void (*clear_intr)(struct amd_mp2_dev *privdata);
144145
};
145146
#endif

0 commit comments

Comments
 (0)