get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/406250/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 406250,
    "url": "http://patchwork.ozlabs.org/api/patches/406250/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1415030910-5799-3-git-send-email-shreyas@linux.vnet.ibm.com/",
    "project": {
        "id": 2,
        "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api",
        "name": "Linux PPC development",
        "link_name": "linuxppc-dev",
        "list_id": "linuxppc-dev.lists.ozlabs.org",
        "list_email": "linuxppc-dev@lists.ozlabs.org",
        "web_url": "https://github.com/linuxppc/wiki/wiki",
        "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git",
        "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/",
        "list_archive_url": "https://lore.kernel.org/linuxppc-dev/",
        "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/",
        "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}"
    },
    "msgid": "<1415030910-5799-3-git-send-email-shreyas@linux.vnet.ibm.com>",
    "list_archive_url": "https://lore.kernel.org/linuxppc-dev/1415030910-5799-3-git-send-email-shreyas@linux.vnet.ibm.com/",
    "date": "2014-11-03T16:08:28",
    "name": "[2/4] powerpc/powernv: Enable Offline CPUs to enter deep idle states",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "f6287e66fbce0c48fe98993d87bf7a1f914bf3b8",
    "submitter": {
        "id": 64129,
        "url": "http://patchwork.ozlabs.org/api/people/64129/?format=api",
        "name": "Shreyas B. Prabhu",
        "email": "shreyas@linux.vnet.ibm.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/1415030910-5799-3-git-send-email-shreyas@linux.vnet.ibm.com/mbox/",
    "series": [],
    "comments": "http://patchwork.ozlabs.org/api/patches/406250/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/406250/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>",
        "X-Original-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Delivered-To": [
            "patchwork-incoming@ozlabs.org",
            "linuxppc-dev@lists.ozlabs.org"
        ],
        "Received": [
            "from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68])\n\t(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 9464A14009F\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue,  4 Nov 2014 03:11:46 +1100 (AEDT)",
            "from ozlabs.org (ozlabs.org [103.22.144.67])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 700931A1A8A\n\tfor <patchwork-incoming@ozlabs.org>;\n\tTue,  4 Nov 2014 03:11:46 +1100 (AEDT)",
            "from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158])\n\t(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 18F0F1A04F0\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tTue,  4 Nov 2014 03:08:57 +1100 (AEDT)",
            "from /spool/local\n\tby e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from <shreyas@linux.vnet.ibm.com>;\n\tMon, 3 Nov 2014 09:08:56 -0700",
            "from d03dlp01.boulder.ibm.com (9.17.202.177)\n\tby e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tMon, 3 Nov 2014 09:08:54 -0700",
            "from b03cxnp08025.gho.boulder.ibm.com\n\t(b03cxnp08025.gho.boulder.ibm.com [9.17.130.17])\n\tby d03dlp01.boulder.ibm.com (Postfix) with ESMTP id 082201FF0045\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tMon,  3 Nov 2014 08:57:38 -0700 (MST)",
            "from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com\n\t[9.17.195.167])\n\tby b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with\n\tESMTP id sA3G8rrg28573796\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 3 Nov 2014 17:08:53 +0100",
            "from d03av01.boulder.ibm.com (localhost [127.0.0.1])\n\tby d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP\n\tid sA3G8pFx026768\n\tfor <linuxppc-dev@lists.ozlabs.org>; Mon, 3 Nov 2014 09:08:53 -0700",
            "from adminib-ovr2cdm.in.ibm.com ([9.79.201.189])\n\tby d03av01.boulder.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP\n\tid sA3G8YB8025138; Mon, 3 Nov 2014 09:08:48 -0700"
        ],
        "From": "\"Shreyas B. Prabhu\" <shreyas@linux.vnet.ibm.com>",
        "To": "linux-kernel@vger.kernel.org",
        "Subject": "[PATCH 2/4] powerpc/powernv: Enable Offline CPUs to enter deep idle\n\tstates",
        "Date": "Mon,  3 Nov 2014 21:38:28 +0530",
        "Message-Id": "<1415030910-5799-3-git-send-email-shreyas@linux.vnet.ibm.com>",
        "X-Mailer": "git-send-email 1.9.3",
        "In-Reply-To": "<1415030910-5799-1-git-send-email-shreyas@linux.vnet.ibm.com>",
        "References": "<1415030910-5799-1-git-send-email-shreyas@linux.vnet.ibm.com>",
        "X-TM-AS-MML": "disable",
        "X-Content-Scanned": "Fidelis XPS MAILER",
        "x-cbid": "14110316-0025-0000-0000-000005D0EA82",
        "Cc": "linux-pm@vger.kernel.org,\n\t\"Shreyas B. Prabhu\" <shreyas@linux.vnet.ibm.com>, \n\t\"Rafael J. Wysocki\" <rjw@rjwysocki.net>,\n\tPaul Mackerras <paulus@samba.org>, \n\t\"Preeti U. Murthy\" <preeti@linux.vnet.ibm.com>,\n\tlinuxppc-dev@lists.ozlabs.org",
        "X-BeenThere": "linuxppc-dev@lists.ozlabs.org",
        "X-Mailman-Version": "2.1.18",
        "Precedence": "list",
        "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>",
        "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>",
        "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>",
        "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>",
        "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=\"utf-8\"",
        "Content-Transfer-Encoding": "base64",
        "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org",
        "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"
    },
    "content": "From: \"Preeti U. Murthy\" <preeti@linux.vnet.ibm.com>\n\nThe secondary threads should enter deep idle states so as to gain maximum\npowersavings when the entire core is offline. To do so the offline path\nmust be made aware of the available deepest idle state. Hence probe the\ndevice tree for the possible idle states in powernv core code and\nexpose the deepest idle state through flags.\n\nSince the  device tree is probed by the cpuidle driver as well, move\nthe parameters required to discover the idle states into an appropriate\ncommon place to both the driver and the powernv core code.\n\nAnother point is that fastsleep idle state may require workarounds in\nthe kernel to function properly. This workaround is introduced in the\nsubsequent patches. However neither the cpuidle driver or the hotplug\npath need be bothered about this workaround.\n\nThey will be taken care of by the core powernv code.\n\nOriginally-by: Srivatsa S. Bhat <srivatsa@mit.edu>\nSigned-off-by: Preeti U. Murthy <preeti@linux.vnet.ibm.com>\nSigned-off-by: Shreyas B. Prabhu <shreyas@linux.vnet.ibm.com>\nCc: Benjamin Herrenschmidt <benh@kernel.crashing.org>\nCc: Paul Mackerras <paulus@samba.org>\nCc: Michael Ellerman <mpe@ellerman.id.au>\nCc: Rafael J. Wysocki <rjw@rjwysocki.net>\nCc: linux-pm@vger.kernel.org\nCc: linuxppc-dev@lists.ozlabs.org\n\n---\n arch/powerpc/include/asm/opal.h          |  8 ++++++\n arch/powerpc/platforms/powernv/powernv.h |  2 ++\n arch/powerpc/platforms/powernv/setup.c   | 49 ++++++++++++++++++++++++++++++++\n arch/powerpc/platforms/powernv/smp.c     |  7 ++++-\n drivers/cpuidle/cpuidle-powernv.c        |  9 ++----\n 5 files changed, 68 insertions(+), 7 deletions(-)",
    "diff": "diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h\nindex 9124b0e..f8b95c0 100644\n--- a/arch/powerpc/include/asm/opal.h\n+++ b/arch/powerpc/include/asm/opal.h\n@@ -155,6 +155,14 @@ struct opal_sg_list {\n #define OPAL_REGISTER_DUMP_REGION\t\t101\n #define OPAL_UNREGISTER_DUMP_REGION\t\t102\n \n+/* Device tree flags */\n+\n+/* Flags set in power-mgmt nodes in device tree if\n+ * respective idle states are supported in the platform.\n+ */\n+#define OPAL_PM_NAP_ENABLED\t0x00010000\n+#define OPAL_PM_SLEEP_ENABLED\t0x00020000\n+\n #ifndef __ASSEMBLY__\n \n #include <linux/notifier.h>\ndiff --git a/arch/powerpc/platforms/powernv/powernv.h b/arch/powerpc/platforms/powernv/powernv.h\nindex 6c8e2d1..604c48e 100644\n--- a/arch/powerpc/platforms/powernv/powernv.h\n+++ b/arch/powerpc/platforms/powernv/powernv.h\n@@ -29,6 +29,8 @@ static inline u64 pnv_pci_dma_get_required_mask(struct pci_dev *pdev)\n }\n #endif\n \n+extern u32 pnv_get_supported_cpuidle_states(void);\n+\n extern void pnv_lpc_init(void);\n \n bool cpu_core_split_required(void);\ndiff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c\nindex 3f9546d..34c6665 100644\n--- a/arch/powerpc/platforms/powernv/setup.c\n+++ b/arch/powerpc/platforms/powernv/setup.c\n@@ -290,6 +290,55 @@ static void __init pnv_setup_machdep_rtas(void)\n }\n #endif /* CONFIG_PPC_POWERNV_RTAS */\n \n+static u32 supported_cpuidle_states;\n+\n+u32 pnv_get_supported_cpuidle_states(void)\n+{\n+\treturn supported_cpuidle_states;\n+}\n+\n+static int __init pnv_init_idle_states(void)\n+{\n+\tstruct device_node *power_mgt;\n+\tint dt_idle_states;\n+\tconst __be32 *idle_state_flags;\n+\tu32 len_flags, flags;\n+\tint i;\n+\n+\tsupported_cpuidle_states = 0;\n+\n+\tif (cpuidle_disable != IDLE_NO_OVERRIDE)\n+\t\treturn 0;\n+\n+\tif (!firmware_has_feature(FW_FEATURE_OPALv3))\n+\t\treturn 0;\n+\n+\tpower_mgt = of_find_node_by_path(\"/ibm,opal/power-mgt\");\n+\tif (!power_mgt) {\n+\t\tpr_warn(\"opal: PowerMgmt Node not found\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tidle_state_flags = of_get_property(power_mgt,\n+\t\t\t\"ibm,cpu-idle-state-flags\", &len_flags);\n+\tif (!idle_state_flags) {\n+\t\tpr_warn(\"DT-PowerMgmt: missing ibm,cpu-idle-state-flags\\n\");\n+\t\treturn 0;\n+\t}\n+\n+\tdt_idle_states = len_flags / sizeof(u32);\n+\n+\tfor (i = 0; i < dt_idle_states; i++) {\n+\t\tflags = be32_to_cpu(idle_state_flags[i]);\n+\t\tsupported_cpuidle_states |= flags;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+subsys_initcall(pnv_init_idle_states);\n+\n+\n static int __init pnv_probe(void)\n {\n \tunsigned long root = of_get_flat_dt_root();\ndiff --git a/arch/powerpc/platforms/powernv/smp.c b/arch/powerpc/platforms/powernv/smp.c\nindex 4753958..3dc4cec 100644\n--- a/arch/powerpc/platforms/powernv/smp.c\n+++ b/arch/powerpc/platforms/powernv/smp.c\n@@ -149,6 +149,7 @@ static int pnv_smp_cpu_disable(void)\n static void pnv_smp_cpu_kill_self(void)\n {\n \tunsigned int cpu;\n+\tu32 idle_states;\n \n \t/* Standard hot unplug procedure */\n \tlocal_irq_disable();\n@@ -159,13 +160,17 @@ static void pnv_smp_cpu_kill_self(void)\n \tgeneric_set_cpu_dead(cpu);\n \tsmp_wmb();\n \n+\tidle_states = pnv_get_supported_cpuidle_states();\n \t/* We don't want to take decrementer interrupts while we are offline,\n \t * so clear LPCR:PECE1. We keep PECE2 enabled.\n \t */\n \tmtspr(SPRN_LPCR, mfspr(SPRN_LPCR) & ~(u64)LPCR_PECE1);\n \twhile (!generic_check_cpu_restart(cpu)) {\n \t\tppc64_runlatch_off();\n-\t\tpower7_nap(1);\n+\t\tif (idle_states & OPAL_PM_SLEEP_ENABLED)\n+\t\t\tpower7_sleep();\n+\t\telse\n+\t\t\tpower7_nap(1);\n \t\tppc64_runlatch_on();\n \n \t\t/* Clear the IPI that woke us up */\ndiff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c\nindex 7d3a349..0a7d827 100644\n--- a/drivers/cpuidle/cpuidle-powernv.c\n+++ b/drivers/cpuidle/cpuidle-powernv.c\n@@ -16,13 +16,10 @@\n \n #include <asm/machdep.h>\n #include <asm/firmware.h>\n+#include <asm/opal.h>\n #include <asm/runlatch.h>\n \n-/* Flags and constants used in PowerNV platform */\n-\n #define MAX_POWERNV_IDLE_STATES\t8\n-#define IDLE_USE_INST_NAP\t0x00010000 /* Use nap instruction */\n-#define IDLE_USE_INST_SLEEP\t0x00020000 /* Use sleep instruction */\n \n struct cpuidle_driver powernv_idle_driver = {\n \t.name             = \"powernv_idle\",\n@@ -198,7 +195,7 @@ static int powernv_add_idle_states(void)\n \t\t * target residency to be 10x exit_latency\n \t\t */\n \t\tlatency_ns = be32_to_cpu(idle_state_latency[i]);\n-\t\tif (flags & IDLE_USE_INST_NAP) {\n+\t\tif (flags & OPAL_PM_NAP_ENABLED) {\n \t\t\t/* Add NAP state */\n \t\t\tstrcpy(powernv_states[nr_idle_states].name, \"Nap\");\n \t\t\tstrcpy(powernv_states[nr_idle_states].desc, \"Nap\");\n@@ -211,7 +208,7 @@ static int powernv_add_idle_states(void)\n \t\t\tnr_idle_states++;\n \t\t}\n \n-\t\tif (flags & IDLE_USE_INST_SLEEP) {\n+\t\tif (flags & OPAL_PM_SLEEP_ENABLED) {\n \t\t\t/* Add FASTSLEEP state */\n \t\t\tstrcpy(powernv_states[nr_idle_states].name, \"FastSleep\");\n \t\t\tstrcpy(powernv_states[nr_idle_states].desc, \"FastSleep\");\n",
    "prefixes": [
        "2/4"
    ]
}