Commit a3767e3c authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

Merge branches 'acpi-smbus', 'acpi-ec' and 'acpi-pci'

* acpi-smbus:
  Revert "ACPI / SBS: Add 5 us delay to fix SBS hangs on MacBook"
  ACPI / SMBus: Fix boot stalls / high CPU caused by reentrant code

* acpi-ec:
  ACPI-EC: Drop unnecessary check made before calling acpi_ec_delete_query()

* acpi-pci:
  PCI: Fix OF logic in pci_dma_configure()
...@@ -1103,7 +1103,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data) ...@@ -1103,7 +1103,7 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 *data)
} }
err_exit: err_exit:
if (result && q) if (result)
acpi_ec_delete_query(q); acpi_ec_delete_query(q);
if (data) if (data)
*data = value; *data = value;
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/dmi.h>
#include "sbshc.h" #include "sbshc.h"
#define PREFIX "ACPI: " #define PREFIX "ACPI: "
...@@ -30,6 +29,7 @@ struct acpi_smb_hc { ...@@ -30,6 +29,7 @@ struct acpi_smb_hc {
u8 query_bit; u8 query_bit;
smbus_alarm_callback callback; smbus_alarm_callback callback;
void *context; void *context;
bool done;
}; };
static int acpi_smbus_hc_add(struct acpi_device *device); static int acpi_smbus_hc_add(struct acpi_device *device);
...@@ -88,8 +88,6 @@ enum acpi_smb_offset { ...@@ -88,8 +88,6 @@ enum acpi_smb_offset {
ACPI_SMB_ALARM_DATA = 0x26, /* 2 bytes alarm data */ ACPI_SMB_ALARM_DATA = 0x26, /* 2 bytes alarm data */
}; };
static bool macbook;
static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data) static inline int smb_hc_read(struct acpi_smb_hc *hc, u8 address, u8 *data)
{ {
return ec_read(hc->offset + address, data); return ec_read(hc->offset + address, data);
...@@ -100,26 +98,10 @@ static inline int smb_hc_write(struct acpi_smb_hc *hc, u8 address, u8 data) ...@@ -100,26 +98,10 @@ static inline int smb_hc_write(struct acpi_smb_hc *hc, u8 address, u8 data)
return ec_write(hc->offset + address, data); return ec_write(hc->offset + address, data);
} }
static inline int smb_check_done(struct acpi_smb_hc *hc)
{
union acpi_smb_status status = {.raw = 0};
smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw);
return status.fields.done && (status.fields.status == SMBUS_OK);
}
static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout) static int wait_transaction_complete(struct acpi_smb_hc *hc, int timeout)
{ {
if (wait_event_timeout(hc->wait, smb_check_done(hc), if (wait_event_timeout(hc->wait, hc->done, msecs_to_jiffies(timeout)))
msecs_to_jiffies(timeout)))
return 0; return 0;
/*
* After the timeout happens, OS will try to check the status of SMbus.
* If the status is what OS expected, it will be regarded as the bogus
* timeout.
*/
if (smb_check_done(hc))
return 0;
else
return -ETIME; return -ETIME;
} }
...@@ -135,8 +117,7 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol, ...@@ -135,8 +117,7 @@ static int acpi_smbus_transaction(struct acpi_smb_hc *hc, u8 protocol,
} }
mutex_lock(&hc->lock); mutex_lock(&hc->lock);
if (macbook) hc->done = false;
udelay(5);
if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp)) if (smb_hc_read(hc, ACPI_SMB_PROTOCOL, &temp))
goto end; goto end;
if (temp) { if (temp) {
...@@ -235,8 +216,10 @@ static int smbus_alarm(void *context) ...@@ -235,8 +216,10 @@ static int smbus_alarm(void *context)
if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw)) if (smb_hc_read(hc, ACPI_SMB_STATUS, &status.raw))
return 0; return 0;
/* Check if it is only a completion notify */ /* Check if it is only a completion notify */
if (status.fields.done) if (status.fields.done && status.fields.status == SMBUS_OK) {
hc->done = true;
wake_up(&hc->wait); wake_up(&hc->wait);
}
if (!status.fields.alarm) if (!status.fields.alarm)
return 0; return 0;
mutex_lock(&hc->lock); mutex_lock(&hc->lock);
...@@ -262,29 +245,12 @@ extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit, ...@@ -262,29 +245,12 @@ extern int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
acpi_handle handle, acpi_ec_query_func func, acpi_handle handle, acpi_ec_query_func func,
void *data); void *data);
static int macbook_dmi_match(const struct dmi_system_id *d)
{
pr_debug("Detected MacBook, enabling workaround\n");
macbook = true;
return 0;
}
static struct dmi_system_id acpi_smbus_dmi_table[] = {
{ macbook_dmi_match, "Apple MacBook", {
DMI_MATCH(DMI_BOARD_VENDOR, "Apple"),
DMI_MATCH(DMI_PRODUCT_NAME, "MacBook") },
},
{ },
};
static int acpi_smbus_hc_add(struct acpi_device *device) static int acpi_smbus_hc_add(struct acpi_device *device)
{ {
int status; int status;
unsigned long long val; unsigned long long val;
struct acpi_smb_hc *hc; struct acpi_smb_hc *hc;
dmi_check_system(acpi_smbus_dmi_table);
if (!device) if (!device)
return -EINVAL; return -EINVAL;
......
...@@ -1685,8 +1685,8 @@ static void pci_dma_configure(struct pci_dev *dev) ...@@ -1685,8 +1685,8 @@ static void pci_dma_configure(struct pci_dev *dev)
{ {
struct device *bridge = pci_get_host_bridge_device(dev); struct device *bridge = pci_get_host_bridge_device(dev);
if (IS_ENABLED(CONFIG_OF) && dev->dev.of_node) { if (IS_ENABLED(CONFIG_OF) &&
if (bridge->parent) bridge->parent && bridge->parent->of_node) {
of_dma_configure(&dev->dev, bridge->parent->of_node); of_dma_configure(&dev->dev, bridge->parent->of_node);
} else if (has_acpi_companion(bridge)) { } else if (has_acpi_companion(bridge)) {
struct acpi_device *adev = to_acpi_device_node(bridge->fwnode); struct acpi_device *adev = to_acpi_device_node(bridge->fwnode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment