int is_apmf_func_supported(struct amd_pmf_dev *pdev, unsignedlong index)
{ /* If bit-n is set, that indicates function n+1 is supported */ return !!(pdev->supported_func & BIT(index - 1));
}
int apts_get_static_slider_granular_v2(struct amd_pmf_dev *pdev, struct amd_pmf_apts_granular_output *data, u32 apts_idx)
{ if (!is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) return -EINVAL;
guard(mutex)(&pmf_dev->update_mutex);
ret = apmf_get_sbios_requests(pmf_dev, &req); if (ret) {
dev_err(pmf_dev->dev, "Failed to get SBIOS requests:%d\n", ret); return;
}
if (req.pending_req & BIT(APMF_AMT_NOTIFICATION)) {
dev_dbg(pmf_dev->dev, "AMT is supported and notifications %s\n",
req.amt_event ? "Enabled" : "Disabled");
pmf_dev->amt_enabled = !!req.amt_event;
if (pmf_dev->amt_enabled)
amd_pmf_handle_amt(pmf_dev); else
amd_pmf_reset_amt(pmf_dev);
}
if (req.pending_req & BIT(APMF_CQL_NOTIFICATION)) {
dev_dbg(pmf_dev->dev, "CQL is supported and notifications %s\n",
req.cql_event ? "Enabled" : "Disabled");
/* update the target mode information */ if (pmf_dev->amt_enabled)
amd_pmf_update_2_cql(pmf_dev, req.cql_event);
}
}
staticint apmf_if_verify_interface(struct amd_pmf_dev *pdev)
{ struct apmf_verify_interface output; int err;
err = apmf_if_call_store_buffer(pdev, APMF_FUNC_VERIFY_INTERFACE, &output, sizeof(output)); if (err) return err;
/* only set if not already set by a quirk */ if (!pdev->supported_func)
pdev->supported_func = output.supported_functions;
/* Install the APMF Notify handler */ if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) &&
is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS)) {
status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
apmf_event_handler, pmf_dev); if (ACPI_FAILURE(status)) {
dev_err(pmf_dev->dev, "failed to install notify handler\n"); return -ENODEV;
}
/* Call the handler once manually to catch up with possibly missed notifies. */
apmf_event_handler(ahandle, 0, pmf_dev);
}
if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V2) {
status = acpi_install_notify_handler(ahandle, ACPI_ALL_NOTIFY,
apmf_event_handler_v2, pmf_dev); if (ACPI_FAILURE(status)) {
dev_err(pmf_dev->dev, "failed to install notify handler for custom BIOS inputs\n"); return -ENODEV;
}
}
return 0;
}
int apmf_check_smart_pc(struct amd_pmf_dev *pmf_dev)
{ struct platform_device *pdev = to_platform_device(pmf_dev->dev);
pmf_dev->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!pmf_dev->res) {
dev_dbg(pmf_dev->dev, "Failed to get I/O memory resource\n"); return -EINVAL;
}
pmf_dev->policy_addr = pmf_dev->res->start; /* * We cannot use resource_size() here because it adds an extra byte to round off the size. * In the case of PMF ResourceTemplate(), this rounding is already handled within the _CRS. * Using resource_size() would increase the resource size by 1, causing a mismatch with the * length field and leading to issues. Therefore, simply use end-start of the ACPI resource * to obtain the actual length.
*/
pmf_dev->policy_sz = pmf_dev->res->end - pmf_dev->res->start;
if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1)
cancel_delayed_work_sync(&pmf_dev->heart_beat);
if (is_apmf_func_supported(pmf_dev, APMF_FUNC_AUTO_MODE) &&
is_apmf_func_supported(pmf_dev, APMF_FUNC_SBIOS_REQUESTS))
acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler);
if (pmf_dev->smart_pc_enabled && pmf_dev->pmf_if_version == PMF_IF_V2)
acpi_remove_notify_handler(ahandle, ACPI_ALL_NOTIFY, apmf_event_handler_v2);
}
int apmf_acpi_init(struct amd_pmf_dev *pmf_dev)
{ int ret;
ret = apmf_if_verify_interface(pmf_dev); if (ret) {
dev_err(pmf_dev->dev, "APMF verify interface failed :%d\n", ret); goto out;
}
ret = apmf_get_system_params(pmf_dev); if (ret) {
dev_dbg(pmf_dev->dev, "APMF apmf_get_system_params failed :%d\n", ret); goto out;
}
if (pmf_dev->hb_interval && pmf_dev->pmf_if_version == PMF_IF_V1) { /* send heartbeats only if the interval is not zero */
INIT_DELAYED_WORK(&pmf_dev->heart_beat, apmf_sbios_heartbeat_notify);
schedule_delayed_work(&pmf_dev->heart_beat, 0);
}
out: return ret;
}
Messung V0.5
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.