]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
Merge branches 'pm-cpufreq', 'pm-cpuidle' and 'acpi-cppc'
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 Apr 2016 19:46:05 +0000 (21:46 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 8 Apr 2016 19:46:05 +0000 (21:46 +0200)
* pm-cpufreq:
  cpufreq: dt: Drop stale comment
  cpufreq: intel_pstate: Documenation for structures
  cpufreq: intel_pstate: fix inconsistency in setting policy limits
  intel_pstate: Avoid extra invocation of intel_pstate_sample()
  intel_pstate: Do not set utilization update hook too early

* pm-cpuidle:
  intel_idle: Add KBL support
  intel_idle: Add SKX support
  intel_idle: Clean up all registered devices on exit.
  intel_idle: Propagate hot plug errors.
  intel_idle: Don't overreact to a cpuidle registration failure.
  intel_idle: Setup the timer broadcast only on successful driver load.
  intel_idle: Avoid a double free of the per-CPU data.
  intel_idle: Fix dangling registration on error path.
  intel_idle: Fix deallocation order on the driver exit path.
  intel_idle: Remove redundant initialization calls.
  intel_idle: Fix a helper function's return value.
  intel_idle: remove useless return from void function.

* acpi-cppc:
  mailbox: pcc: Don't access an unmapped memory address space

1  2  3  4 
drivers/mailbox/pcc.c

diff --combined drivers/mailbox/pcc.c
index 0ddf638d60f3645c4a083b37027625dfd850b97f,8f779a1ec99c4b248c9721fceef19b579432539b,8f779a1ec99c4b248c9721fceef19b579432539b,9d3955e6ab44f2fb99e23094e73570c11d567024..043828d541f794b331fdaef51e2649a58a472525
    #include <linux/platform_device.h>
    #include <linux/mailbox_controller.h>
    #include <linux/mailbox_client.h>
 ++ #include <linux/io-64-nonatomic-lo-hi.h>
    
    #include "mailbox.h"
    
    
    static struct mbox_chan *pcc_mbox_channels;
    
 ++ /* Array of cached virtual address for doorbell registers */
 ++ static void __iomem **pcc_doorbell_vaddr;
 ++ 
    static struct mbox_controller pcc_mbox_ctrl = {};
    /**
     * get_pcc_channel - Given a PCC subspace idx, get
     */
    static struct mbox_chan *get_pcc_channel(int id)
    {
   -    struct mbox_chan *pcc_chan;
   -
        if (id < 0 || id > pcc_mbox_ctrl.num_chans)
                return ERR_PTR(-ENOENT);
    
   -    pcc_chan = (struct mbox_chan *)
   -            (unsigned long) pcc_mbox_channels +
   -            (id * sizeof(*pcc_chan));
   -
   -    return pcc_chan;
   +    return &pcc_mbox_channels[id];
    }
    
    /**
@@@@@ -164,66 -160,6 -160,6 -170,66 +164,66 @@@@@ void pcc_mbox_free_channel(struct mbox_
    }
    EXPORT_SYMBOL_GPL(pcc_mbox_free_channel);
    
 ++ /*
 ++  * PCC can be used with perf critical drivers such as CPPC
 ++  * So it makes sense to locally cache the virtual address and
 ++  * use it to read/write to PCC registers such as doorbell register
 ++  *
 ++  * The below read_register and write_registers are used to read and
 ++  * write from perf critical registers such as PCC doorbell register
 ++  */
 ++ static int read_register(void __iomem *vaddr, u64 *val, unsigned int bit_width)
 ++ {
 ++     int ret_val = 0;
 ++ 
 ++     switch (bit_width) {
 ++     case 8:
 ++             *val = readb(vaddr);
 ++             break;
 ++     case 16:
 ++             *val = readw(vaddr);
 ++             break;
 ++     case 32:
 ++             *val = readl(vaddr);
 ++             break;
 ++     case 64:
 ++             *val = readq(vaddr);
 ++             break;
 ++     default:
 ++             pr_debug("Error: Cannot read register of %u bit width",
 ++                     bit_width);
 ++             ret_val = -EFAULT;
 ++             break;
 ++     }
 ++     return ret_val;
 ++ }
 ++ 
 ++ static int write_register(void __iomem *vaddr, u64 val, unsigned int bit_width)
 ++ {
 ++     int ret_val = 0;
 ++ 
 ++     switch (bit_width) {
 ++     case 8:
 ++             writeb(val, vaddr);
 ++             break;
 ++     case 16:
 ++             writew(val, vaddr);
 ++             break;
 ++     case 32:
 ++             writel(val, vaddr);
 ++             break;
 ++     case 64:
 ++             writeq(val, vaddr);
 ++             break;
 ++     default:
 ++             pr_debug("Error: Cannot write register of %u bit width",
 ++                     bit_width);
 ++             ret_val = -EFAULT;
 ++             break;
 ++     }
 ++     return ret_val;
 ++ }
 ++ 
    /**
     * pcc_send_data - Called from Mailbox Controller code. Used
     *          here only to ring the channel doorbell. The PCC client
    static int pcc_send_data(struct mbox_chan *chan, void *data)
    {
        struct acpi_pcct_hw_reduced *pcct_ss = chan->con_priv;
 --     struct acpi_generic_address doorbell;
 ++     struct acpi_generic_address *doorbell;
        u64 doorbell_preserve;
        u64 doorbell_val;
        u64 doorbell_write;
 ++     u32 id = chan - pcc_mbox_channels;
 ++     int ret = 0;
 ++ 
 ++     if (id >= pcc_mbox_ctrl.num_chans) {
 ++             pr_debug("pcc_send_data: Invalid mbox_chan passed\n");
 ++             return -ENOENT;
 ++     }
    
 --     doorbell = pcct_ss->doorbell_register;
 ++     doorbell = &pcct_ss->doorbell_register;
        doorbell_preserve = pcct_ss->preserve_mask;
        doorbell_write = pcct_ss->write_mask;
    
        /* Sync notification from OS to Platform. */
 --     acpi_read(&doorbell_val, &doorbell);
 --     acpi_write((doorbell_val & doorbell_preserve) | doorbell_write,
 --                     &doorbell);
 -- 
 --     return 0;
 ++     if (pcc_doorbell_vaddr[id]) {
 ++             ret = read_register(pcc_doorbell_vaddr[id], &doorbell_val,
 ++                     doorbell->bit_width);
 ++             if (ret)
 ++                     return ret;
 ++             ret = write_register(pcc_doorbell_vaddr[id],
 ++                     (doorbell_val & doorbell_preserve) | doorbell_write,
 ++                     doorbell->bit_width);
 ++     } else {
 ++             ret = acpi_read(&doorbell_val, doorbell);
 ++             if (ret)
 ++                     return ret;
 ++             ret = acpi_write((doorbell_val & doorbell_preserve) | doorbell_write,
 ++                     doorbell);
 ++     }
 ++     return ret;
    }
    
    static const struct mbox_chan_ops pcc_chan_ops = {
@@@@@ -347,29 -265,14 -265,14 -353,29 +347,29 @@@@@ static int __init acpi_pcc_probe(void
                return -ENOMEM;
        }
    
 ++     pcc_doorbell_vaddr = kcalloc(count, sizeof(void *), GFP_KERNEL);
 ++     if (!pcc_doorbell_vaddr) {
 ++             kfree(pcc_mbox_channels);
 ++             return -ENOMEM;
 ++     }
 ++ 
        /* Point to the first PCC subspace entry */
        pcct_entry = (struct acpi_subtable_header *) (
                (unsigned long) pcct_tbl + sizeof(struct acpi_table_pcct));
    
        for (i = 0; i < count; i++) {
 ++             struct acpi_generic_address *db_reg;
 ++             struct acpi_pcct_hw_reduced *pcct_ss;
                pcc_mbox_channels[i].con_priv = pcct_entry;
-               pcct_entry = (struct acpi_subtable_header *)
-                       ((unsigned long) pcct_entry + pcct_entry->length);
 ++ 
 ++             /* If doorbell is in system memory cache the virt address */
 ++             pcct_ss = (struct acpi_pcct_hw_reduced *)pcct_entry;
 ++             db_reg = &pcct_ss->doorbell_register;
 ++             if (db_reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
 ++                     pcc_doorbell_vaddr[i] = acpi_os_ioremap(db_reg->address,
 ++                                                     db_reg->bit_width/8);
+               pcct_entry = (struct acpi_subtable_header *)
+                       ((unsigned long) pcct_entry + pcct_entry->length);
        }
    
        pcc_mbox_ctrl.num_chans = count;