platform-drivers-x86 for v4.14-3
Use a spin_lock instead of mutex in atomic context. The devm_ fix is a dependency. intel_pmc_ipc: - Use spin_lock to protect GCR updates - Use devm_* calls in driver probe function -----BEGIN PGP SIGNATURE----- iQEcBAABAgAGBQJZ7iUGAAoJEKbMaAwKp364wIQIAKmAi4BH9x7HmJzhBVgToB4T 3UvSMPBdGDbNlz8STfC5txg+rLCcy00FscM2Dhf762mBijdm1TwIBuOMYhkLNawI fPeuexn6wmj0lq8NnLQZ/laSiPoe1ZyRjfmlvPxB+jZu6o3PIeT/ccvHCTxGFy8u dgg1A970rmnPbe8t9EBZQLftO/9KmDodg7w/gelIs6wuCFJ7xvl47hqsPM1GluXa M/HQRRZCXDyVd+P1tqS6i/x4w3q162YT3aQV9q5lV6lsq2obLArtvBzIHF4vYMSm 2TczdpOI2eqRKUZWN3Bv5Inn8d5FOyXf3SCY/dwa6PRYaZkCQHN/OQycc3/3rKU= =2dYt -----END PGP SIGNATURE----- Merge tag 'platform-drivers-x86-v4.14-3' of git://git.infradead.org/linux-platform-drivers-x86 Pull x86 platform driver fixes from Darren Hart: "Use a spin_lock instead of mutex in atomic context. The devm_ fix is a dependency. Summary: intel_pmc_ipc: - Use spin_lock to protect GCR updates - Use devm_* calls in driver probe function" * tag 'platform-drivers-x86-v4.14-3' of git://git.infradead.org/linux-platform-drivers-x86: platform/x86: intel_pmc_ipc: Use spin_lock to protect GCR updates platform/x86: intel_pmc_ipc: Use devm_* calls in driver probe function
This commit is contained in:
Коммит
6cff0a118f
|
@ -33,6 +33,7 @@
|
||||||
#include <linux/suspend.h>
|
#include <linux/suspend.h>
|
||||||
#include <linux/acpi.h>
|
#include <linux/acpi.h>
|
||||||
#include <linux/io-64-nonatomic-lo-hi.h>
|
#include <linux/io-64-nonatomic-lo-hi.h>
|
||||||
|
#include <linux/spinlock.h>
|
||||||
|
|
||||||
#include <asm/intel_pmc_ipc.h>
|
#include <asm/intel_pmc_ipc.h>
|
||||||
|
|
||||||
|
@ -131,6 +132,7 @@ static struct intel_pmc_ipc_dev {
|
||||||
/* gcr */
|
/* gcr */
|
||||||
void __iomem *gcr_mem_base;
|
void __iomem *gcr_mem_base;
|
||||||
bool has_gcr_regs;
|
bool has_gcr_regs;
|
||||||
|
spinlock_t gcr_lock;
|
||||||
|
|
||||||
/* punit */
|
/* punit */
|
||||||
struct platform_device *punit_dev;
|
struct platform_device *punit_dev;
|
||||||
|
@ -225,17 +227,17 @@ int intel_pmc_gcr_read(u32 offset, u32 *data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&ipclock);
|
spin_lock(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
ret = is_gcr_valid(offset);
|
ret = is_gcr_valid(offset);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mutex_unlock(&ipclock);
|
spin_unlock(&ipcdev.gcr_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*data = readl(ipcdev.gcr_mem_base + offset);
|
*data = readl(ipcdev.gcr_mem_base + offset);
|
||||||
|
|
||||||
mutex_unlock(&ipclock);
|
spin_unlock(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -255,17 +257,17 @@ int intel_pmc_gcr_write(u32 offset, u32 data)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mutex_lock(&ipclock);
|
spin_lock(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
ret = is_gcr_valid(offset);
|
ret = is_gcr_valid(offset);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
mutex_unlock(&ipclock);
|
spin_unlock(&ipcdev.gcr_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
writel(data, ipcdev.gcr_mem_base + offset);
|
writel(data, ipcdev.gcr_mem_base + offset);
|
||||||
|
|
||||||
mutex_unlock(&ipclock);
|
spin_unlock(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -287,7 +289,7 @@ int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val)
|
||||||
u32 new_val;
|
u32 new_val;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
mutex_lock(&ipclock);
|
spin_lock(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
ret = is_gcr_valid(offset);
|
ret = is_gcr_valid(offset);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -309,7 +311,7 @@ int intel_pmc_gcr_update(u32 offset, u32 mask, u32 val)
|
||||||
}
|
}
|
||||||
|
|
||||||
gcr_ipc_unlock:
|
gcr_ipc_unlock:
|
||||||
mutex_unlock(&ipclock);
|
spin_unlock(&ipcdev.gcr_lock);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(intel_pmc_gcr_update);
|
EXPORT_SYMBOL_GPL(intel_pmc_gcr_update);
|
||||||
|
@ -480,52 +482,41 @@ static irqreturn_t ioc(int irq, void *dev_id)
|
||||||
|
|
||||||
static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
static int ipc_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
resource_size_t pci_resource;
|
struct intel_pmc_ipc_dev *pmc = &ipcdev;
|
||||||
int ret;
|
int ret;
|
||||||
int len;
|
|
||||||
|
|
||||||
ipcdev.dev = &pci_dev_get(pdev)->dev;
|
/* Only one PMC is supported */
|
||||||
ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
|
if (pmc->dev)
|
||||||
|
|
||||||
ret = pci_enable_device(pdev);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
ret = pci_request_regions(pdev, "intel_pmc_ipc");
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
pci_resource = pci_resource_start(pdev, 0);
|
|
||||||
len = pci_resource_len(pdev, 0);
|
|
||||||
if (!pci_resource || !len) {
|
|
||||||
dev_err(&pdev->dev, "Failed to get resource\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
init_completion(&ipcdev.cmd_complete);
|
|
||||||
|
|
||||||
if (request_irq(pdev->irq, ioc, 0, "intel_pmc_ipc", &ipcdev)) {
|
|
||||||
dev_err(&pdev->dev, "Failed to request irq\n");
|
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
|
|
||||||
|
pmc->irq_mode = IPC_TRIGGER_MODE_IRQ;
|
||||||
|
|
||||||
|
spin_lock_init(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
|
ret = pcim_enable_device(pdev);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev));
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
init_completion(&pmc->cmd_complete);
|
||||||
|
|
||||||
|
pmc->ipc_base = pcim_iomap_table(pdev)[0];
|
||||||
|
|
||||||
|
ret = devm_request_irq(&pdev->dev, pdev->irq, ioc, 0, "intel_pmc_ipc",
|
||||||
|
pmc);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(&pdev->dev, "Failed to request irq\n");
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ipcdev.ipc_base = ioremap_nocache(pci_resource, len);
|
pmc->dev = &pdev->dev;
|
||||||
if (!ipcdev.ipc_base) {
|
|
||||||
dev_err(&pdev->dev, "Failed to ioremap ipc base\n");
|
|
||||||
free_irq(pdev->irq, &ipcdev);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
pci_set_drvdata(pdev, pmc);
|
||||||
}
|
|
||||||
|
|
||||||
static void ipc_pci_remove(struct pci_dev *pdev)
|
return 0;
|
||||||
{
|
|
||||||
free_irq(pdev->irq, &ipcdev);
|
|
||||||
pci_release_regions(pdev);
|
|
||||||
pci_dev_put(pdev);
|
|
||||||
iounmap(ipcdev.ipc_base);
|
|
||||||
ipcdev.dev = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct pci_device_id ipc_pci_ids[] = {
|
static const struct pci_device_id ipc_pci_ids[] = {
|
||||||
|
@ -540,7 +531,6 @@ static struct pci_driver ipc_pci_driver = {
|
||||||
.name = "intel_pmc_ipc",
|
.name = "intel_pmc_ipc",
|
||||||
.id_table = ipc_pci_ids,
|
.id_table = ipc_pci_ids,
|
||||||
.probe = ipc_pci_probe,
|
.probe = ipc_pci_probe,
|
||||||
.remove = ipc_pci_remove,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static ssize_t intel_pmc_ipc_simple_cmd_store(struct device *dev,
|
static ssize_t intel_pmc_ipc_simple_cmd_store(struct device *dev,
|
||||||
|
@ -850,17 +840,12 @@ static int ipc_plat_get_res(struct platform_device *pdev)
|
||||||
return -ENXIO;
|
return -ENXIO;
|
||||||
}
|
}
|
||||||
size = PLAT_RESOURCE_IPC_SIZE + PLAT_RESOURCE_GCR_SIZE;
|
size = PLAT_RESOURCE_IPC_SIZE + PLAT_RESOURCE_GCR_SIZE;
|
||||||
|
res->end = res->start + size - 1;
|
||||||
|
|
||||||
|
addr = devm_ioremap_resource(&pdev->dev, res);
|
||||||
|
if (IS_ERR(addr))
|
||||||
|
return PTR_ERR(addr);
|
||||||
|
|
||||||
if (!request_mem_region(res->start, size, pdev->name)) {
|
|
||||||
dev_err(&pdev->dev, "Failed to request ipc resource\n");
|
|
||||||
return -EBUSY;
|
|
||||||
}
|
|
||||||
addr = ioremap_nocache(res->start, size);
|
|
||||||
if (!addr) {
|
|
||||||
dev_err(&pdev->dev, "I/O memory remapping failed\n");
|
|
||||||
release_mem_region(res->start, size);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
ipcdev.ipc_base = addr;
|
ipcdev.ipc_base = addr;
|
||||||
|
|
||||||
ipcdev.gcr_mem_base = addr + PLAT_RESOURCE_GCR_OFFSET;
|
ipcdev.gcr_mem_base = addr + PLAT_RESOURCE_GCR_OFFSET;
|
||||||
|
@ -917,12 +902,12 @@ MODULE_DEVICE_TABLE(acpi, ipc_acpi_ids);
|
||||||
|
|
||||||
static int ipc_plat_probe(struct platform_device *pdev)
|
static int ipc_plat_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ipcdev.dev = &pdev->dev;
|
ipcdev.dev = &pdev->dev;
|
||||||
ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
|
ipcdev.irq_mode = IPC_TRIGGER_MODE_IRQ;
|
||||||
init_completion(&ipcdev.cmd_complete);
|
init_completion(&ipcdev.cmd_complete);
|
||||||
|
spin_lock_init(&ipcdev.gcr_lock);
|
||||||
|
|
||||||
ipcdev.irq = platform_get_irq(pdev, 0);
|
ipcdev.irq = platform_get_irq(pdev, 0);
|
||||||
if (ipcdev.irq < 0) {
|
if (ipcdev.irq < 0) {
|
||||||
|
@ -939,11 +924,11 @@ static int ipc_plat_probe(struct platform_device *pdev)
|
||||||
ret = ipc_create_pmc_devices();
|
ret = ipc_create_pmc_devices();
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(&pdev->dev, "Failed to create pmc devices\n");
|
dev_err(&pdev->dev, "Failed to create pmc devices\n");
|
||||||
goto err_device;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request_irq(ipcdev.irq, ioc, IRQF_NO_SUSPEND,
|
if (devm_request_irq(&pdev->dev, ipcdev.irq, ioc, IRQF_NO_SUSPEND,
|
||||||
"intel_pmc_ipc", &ipcdev)) {
|
"intel_pmc_ipc", &ipcdev)) {
|
||||||
dev_err(&pdev->dev, "Failed to request irq\n");
|
dev_err(&pdev->dev, "Failed to request irq\n");
|
||||||
ret = -EBUSY;
|
ret = -EBUSY;
|
||||||
goto err_irq;
|
goto err_irq;
|
||||||
|
@ -960,40 +945,22 @@ static int ipc_plat_probe(struct platform_device *pdev)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
err_sys:
|
err_sys:
|
||||||
free_irq(ipcdev.irq, &ipcdev);
|
devm_free_irq(&pdev->dev, ipcdev.irq, &ipcdev);
|
||||||
err_irq:
|
err_irq:
|
||||||
platform_device_unregister(ipcdev.tco_dev);
|
platform_device_unregister(ipcdev.tco_dev);
|
||||||
platform_device_unregister(ipcdev.punit_dev);
|
platform_device_unregister(ipcdev.punit_dev);
|
||||||
platform_device_unregister(ipcdev.telemetry_dev);
|
platform_device_unregister(ipcdev.telemetry_dev);
|
||||||
err_device:
|
|
||||||
iounmap(ipcdev.ipc_base);
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM,
|
|
||||||
PLAT_RESOURCE_IPC_INDEX);
|
|
||||||
if (res) {
|
|
||||||
release_mem_region(res->start,
|
|
||||||
PLAT_RESOURCE_IPC_SIZE +
|
|
||||||
PLAT_RESOURCE_GCR_SIZE);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ipc_plat_remove(struct platform_device *pdev)
|
static int ipc_plat_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct resource *res;
|
|
||||||
|
|
||||||
sysfs_remove_group(&pdev->dev.kobj, &intel_ipc_group);
|
sysfs_remove_group(&pdev->dev.kobj, &intel_ipc_group);
|
||||||
free_irq(ipcdev.irq, &ipcdev);
|
devm_free_irq(&pdev->dev, ipcdev.irq, &ipcdev);
|
||||||
platform_device_unregister(ipcdev.tco_dev);
|
platform_device_unregister(ipcdev.tco_dev);
|
||||||
platform_device_unregister(ipcdev.punit_dev);
|
platform_device_unregister(ipcdev.punit_dev);
|
||||||
platform_device_unregister(ipcdev.telemetry_dev);
|
platform_device_unregister(ipcdev.telemetry_dev);
|
||||||
iounmap(ipcdev.ipc_base);
|
|
||||||
res = platform_get_resource(pdev, IORESOURCE_MEM,
|
|
||||||
PLAT_RESOURCE_IPC_INDEX);
|
|
||||||
if (res) {
|
|
||||||
release_mem_region(res->start,
|
|
||||||
PLAT_RESOURCE_IPC_SIZE +
|
|
||||||
PLAT_RESOURCE_GCR_SIZE);
|
|
||||||
}
|
|
||||||
ipcdev.dev = NULL;
|
ipcdev.dev = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче