[{"id":1769038,"web_url":"http://patchwork.ozlabs.org/comment/1769038/","msgid":"<20170915083105.GE5432@drishya.in.ibm.com>","list_archive_url":null,"date":"2017-09-15T08:31:05","subject":"Re: [Skiboot] [PATCH v4 4/8] SLW: Add opal_slw_set_reg support for\n\tpower9","submitter":{"id":497,"url":"http://patchwork.ozlabs.org/api/people/497/","name":"Vaidyanathan Srinivasan","email":"svaidy@linux.vnet.ibm.com"},"content":"* Akshay Adiga <akshay.adiga@linux.vnet.ibm.com> [2017-09-15 13:04:32]:\n\n> This OPAL call is made from Linux to OPAL to configure values in\n> various SPRs after wakeup from a deep idle state.\n\nThe opal_slw_set_reg() OPAL call is used by Linux during init to setup\ncertain SPR values that should be loaded by microcode on wakeup from\na deep idle states where some SPR states are lost.\n\nThis helps to speed up wakeup by restoring key registers like HSPRG0,\nLPCR and MSR.  On POWER9 platform Linux MSR need to be set using this\nAPI since the micro-code running on host processor may have\na different MSR context.\n \n> Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>\n\nReviewed-by: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>\n\n\n> ---\n>  hw/slw.c | 60 ++++++++++++++++++++++++++++++++++++++++--------------------\n>  1 file changed, 40 insertions(+), 20 deletions(-)\n> \n> diff --git a/hw/slw.c b/hw/slw.c\n> index d8829a6..a1ed7ba 100644\n> --- a/hw/slw.c\n> +++ b/hw/slw.c\n> @@ -30,6 +30,7 @@\n>  #include <libfdt/libfdt.h>\n>  #include <opal-api.h>\n> \n> +#include <p9_stop_api.H>\n>  #include <p8_pore_table_gen_api.H>\n>  #include <sbe_xip_image.h>\n> \n> @@ -1402,41 +1403,60 @@ int64_t opal_slw_set_reg(uint64_t cpu_pir, uint64_t sprn, uint64_t val)\n> \n>  \tstruct cpu_thread *c = find_cpu_by_pir(cpu_pir);\n>  \tstruct proc_chip *chip;\n> -\tvoid *image;\n>  \tint rc;\n> -\tint i;\n> -\tint spr_is_supported = 0;\n> \n>  \tassert(c);\n>  \tchip = get_chip(c->chip_id);\n>  \tassert(chip);\n> -\timage = (void *) chip->slw_base;\n> \n> -\t/* Check of the SPR is supported by libpore */\n> -\tfor ( i=0; i < SLW_SPR_REGS_SIZE ; i++)  {\n> -\t\tif (sprn == SLW_SPR_REGS[i].value)  {\n> -\t\t\tspr_is_supported = 1;\n> -\t\t\tbreak;\n> +\tif (proc_gen == proc_gen_p9) {\n> +\t\tif (!chip->homer_base) {\n> +\t\t\tlog_simple_error(&e_info(OPAL_RC_SLW_REG),\n> +\t\t\t\t\t \"SLW: HOMER base not set %x\\n\",\n> +\t\t\t\t\t chip->id);\n> +\t\t\treturn OPAL_INTERNAL_ERROR;\n>  \t\t}\n> -\t}\n> -\tif (!spr_is_supported) {\n> -\t\tlog_simple_error(&e_info(OPAL_RC_SLW_REG),\n> +\t\trc = p9_stop_save_cpureg((void *)chip->homer_base,\n> +\t\t\t\t\t sprn, val, cpu_pir);\n> +\n> +\t} else if (proc_gen == proc_gen_p8) {\n> +\t\tint spr_is_supported = 0;\n> +\t\tvoid *image;\n> +\t\tint i;\n> +\n> +\t\t/* Check of the SPR is supported by libpore */\n> +\t\tfor (i = 0; i < SLW_SPR_REGS_SIZE ; i++)  {\n> +\t\t\tif (sprn == SLW_SPR_REGS[i].value)  {\n> +\t\t\t\tspr_is_supported = 1;\n> +\t\t\t\tbreak;\n> +\t\t\t}\n> +\t\t}\n> +\t\tif (!spr_is_supported) {\n> +\t\t\tlog_simple_error(&e_info(OPAL_RC_SLW_REG),\n>  \t\t\t\"SLW: Trying to set unsupported spr for CPU %x\\n\",\n> -\t\t\tc->pir);\n> +\t\t\t\tc->pir);\n> +\t\t\treturn OPAL_UNSUPPORTED;\n> +\t\t}\n> +\t\timage = (void *)chip->slw_base;\n> +\t\trc = p8_pore_gen_cpureg_fixed(image, P8_SLW_MODEBUILD_SRAM,\n> +\t\t\t\t\t      sprn, val,\n> +\t\t\t\t\t      cpu_get_core_index(c),\n> +\t\t\t\t\t      cpu_get_thread_index(c));\n> +\t} else {\n> +\t\tlog_simple_error(&e_info(OPAL_RC_SLW_REG),\n> +\t\t\"SLW: proc_gen not supported\\n\");\n>  \t\treturn OPAL_UNSUPPORTED;\n> -\t}\n> \n> -\trc = p8_pore_gen_cpureg_fixed(image, P8_SLW_MODEBUILD_SRAM, sprn,\n> -\t\t\t\t\t\tval, cpu_get_core_index(c),\n> -\t\t\t\t\t\tcpu_get_thread_index(c));\n> +\t}\n> \n>  \tif (rc) {\n>  \t\tlog_simple_error(&e_info(OPAL_RC_SLW_REG),\n> -\t\t\t\"SLW: Failed to set spr for CPU %x\\n\",\n> -\t\t\tc->pir);\n> +\t\t\t\"SLW: Failed to set spr %llx for CPU %x, RC=0x%x\\n\",\n> +\t\t\tsprn, c->pir, rc);\n>  \t\treturn OPAL_INTERNAL_ERROR;\n>  \t}\n> -\n> +\tprlog(PR_DEBUG, \"SLW: restore spr:0x%llx on c:0x%x with 0x%llx\\n\",\n> +\t      sprn, c->pir, val);\n>  \treturn OPAL_SUCCESS;\n> \n>  }\n> -- \n> 2.5.5\n>","headers":{"Return-Path":"<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>","X-Original-To":["incoming@patchwork.ozlabs.org","skiboot@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","skiboot@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtpXC5vcYz9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 18:31:23 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xtpXC50nzzDrX7\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 18:31:23 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n\t[148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xtpX84slszDrWR\n\tfor <skiboot@lists.ozlabs.org>; Fri, 15 Sep 2017 18:31:20 +1000 (AEST)","from pps.filterd (m0098396.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8F8TbnO016650\n\tfor <skiboot@lists.ozlabs.org>; Fri, 15 Sep 2017 04:31:18 -0400","from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2d07g8jg3q-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <skiboot@lists.ozlabs.org>; Fri, 15 Sep 2017 04:31:18 -0400","from localhost\n\tby e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <skiboot@lists.ozlabs.org> from <svaidy@linux.vnet.ibm.com>;\n\tFri, 15 Sep 2017 18:31:16 +1000","from d23relay08.au.ibm.com (202.81.31.227)\n\tby e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tFri, 15 Sep 2017 18:31:13 +1000","from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119])\n\tby d23relay08.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv8F8VDRf35389474\n\tfor <skiboot@lists.ozlabs.org>; Fri, 15 Sep 2017 18:31:13 +1000","from d23av05.au.ibm.com (localhost [127.0.0.1])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv8F8VC3h022763\n\tfor <skiboot@lists.ozlabs.org>; Fri, 15 Sep 2017 18:31:13 +1000","from drishya.in.ibm.com ([9.102.2.33])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv8F8V6Ex022566\n\t(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256\n\tverify=NO); Fri, 15 Sep 2017 18:31:09 +1000"],"Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com\n\t(client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n\tenvelope-from=svaidy@linux.vnet.ibm.com; receiver=<UNKNOWN>)","Date":"Fri, 15 Sep 2017 14:01:05 +0530","From":"Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com>","To":"Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>","References":"<1505460876-7303-1-git-send-email-akshay.adiga@linux.vnet.ibm.com>\n\t<1505460876-7303-5-git-send-email-akshay.adiga@linux.vnet.ibm.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<1505460876-7303-5-git-send-email-akshay.adiga@linux.vnet.ibm.com>","User-Agent":"Mutt/1.8.3 (2017-05-23)","X-TM-AS-MML":"disable","x-cbid":"17091508-0048-0000-0000-0000025D1965","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17091508-0049-0000-0000-0000481389C7","Message-Id":"<20170915083105.GE5432@drishya.in.ibm.com>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-15_03:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709150129","Subject":"Re: [Skiboot] [PATCH v4 4/8] SLW: Add opal_slw_set_reg support for\n\tpower9","X-BeenThere":"skiboot@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Mailing list for skiboot development <skiboot.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/skiboot/>","List-Post":"<mailto:skiboot@lists.ozlabs.org>","List-Help":"<mailto:skiboot-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/skiboot>,\n\t<mailto:skiboot-request@lists.ozlabs.org?subject=subscribe>","Reply-To":"svaidy@linux.vnet.ibm.com","Cc":"ego@linux.vnet.ibm.com, shriyak@linux.vnet.ibm.com,\n\tskiboot@lists.ozlabs.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org","Sender":"\"Skiboot\"\n\t<skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org>"}}]