Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754011AbdDEGf3 (ORCPT ); Wed, 5 Apr 2017 02:35:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52649 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753859AbdDEGf2 (ORCPT ); Wed, 5 Apr 2017 02:35:28 -0400 Subject: Re: [PATCH v6 02/11] powerpc/powernv: Autoload IMC device driver module To: Daniel Axtens , mpe@ellerman.id.au References: <1491231308-15282-1-git-send-email-maddy@linux.vnet.ibm.com> <1491231308-15282-3-git-send-email-maddy@linux.vnet.ibm.com> <87pogtkmyf.fsf@possimpible.ozlabs.ibm.com> Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, ego@linux.vnet.ibm.com, bsingharora@gmail.com, benh@kernel.crashing.org, paulus@samba.org, anton@samba.org, sukadev@linux.vnet.ibm.com, mikey@neuling.org, stewart@linux.vnet.ibm.com, eranian@google.com, Hemant Kumar , Anju T Sudhakar From: Madhavan Srinivasan Date: Wed, 5 Apr 2017 12:04:20 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <87pogtkmyf.fsf@possimpible.ozlabs.ibm.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-MML: disable x-cbid: 17040506-0052-0000-0000-0000022B890A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17040506-0053-0000-0000-000008049F9B Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-04-05_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704050061 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3807 Lines: 128 On Tuesday 04 April 2017 06:28 AM, Daniel Axtens wrote: > Hi all, > > I'm trying to get my head around these patches - at this point I'm just > doing a first pass, so I may have more substantive structural comments > later on. In the mean time - here are some minor C nits: > >> + * Copyright (C) 2016 Madhavan Srinivasan, IBM Corporation. >> + * (C) 2016 Hemant K Shaw, IBM Corporation. > Should these be bumped to 2017? Facepalm. my bad. Will fix it. >> + >> + do { >> + pages = PAGE_SIZE * i; >> + pcni->vbase[i++] = (u64)phys_to_virt(pcni->pbase + >> + pages); >> + } while (i < (pcni->size / PAGE_SIZE)); >> + } > I had to scroll back up to the top of this function to make sure I > understood what this loop does. Would it be better to write it as: > > for (i = 0; i < (pcni->size / PAGE_SIZE); i++) { > pages = PAGE_SIZE * i; > pcni->vbase[i] = (u64).... > } Idea is to map all of the nest counter area since event offset could be anywhere within this region. Will document that here. > > And, just checking - this is expected to work on both 4 and 64kB pages? Yes. thats the intended. That said, i need to fix the IMC_NEST_MAX_PAGES value for 4K page size. Reason being, there was a recent change in the size of memory allocated for nest counters in the HOMER region for the microcode. > >> + >> + return 0; >> +err: >> + return -ENODEV; > You're not releasing any resources here - would it be better to just > replace the gotos with this return? I haven't checked to see if you > change the function later on to allocate memory - if so please ignore :) We check in multiple places in the function and return on fail. Thats why we made it as a generic return with goto. >> +} >> + >> +static const struct of_device_id opal_imc_match[] = { >> + { .compatible = IMC_DTB_COMPAT }, >> + {}, >> +}; >> + >> +static struct platform_driver opal_imc_driver = { >> + .driver = { >> + .name = "opal-imc-counters", >> + .of_match_table = opal_imc_match, >> + }, >> + .probe = opal_imc_counters_probe, >> +}; >> + >> +MODULE_DEVICE_TABLE(of, opal_imc_match); >> +module_platform_driver(opal_imc_driver); >> +MODULE_DESCRIPTION("PowerNV OPAL IMC driver"); >> +MODULE_LICENSE("GPL"); >> diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c >> index e0f856bfbfe8..85ea1296f030 100644 >> --- a/arch/powerpc/platforms/powernv/opal.c >> +++ b/arch/powerpc/platforms/powernv/opal.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -30,6 +31,7 @@ >> #include >> #include >> #include >> +#include >> >> #include "powernv.h" >> >> @@ -631,6 +633,15 @@ static void opal_pdev_init(const char *compatible) >> of_platform_device_create(np, NULL, NULL); >> } >> >> +static void opal_imc_init_dev(void) >> +{ >> + struct device_node *np; >> + >> + np = of_find_compatible_node(NULL, NULL, IMC_DTB_COMPAT); >> + if (np) >> + of_platform_device_create(np, NULL, NULL); >> +} > Should this function be tagged __init? Yes. Thats right. Will make the changes. Thanks for review Maddy > >> + >> static int kopald(void *unused) >> { >> unsigned long timeout = msecs_to_jiffies(opal_heartbeat) + 1; >> @@ -704,6 +715,9 @@ static int __init opal_init(void) >> /* Setup a heatbeat thread if requested by OPAL */ >> opal_init_heartbeat(); >> >> + /* Detect IMC pmu counters support and create PMUs */ >> + opal_imc_init_dev(); >> + >> /* Create leds platform devices */ >> leds = of_find_node_by_path("/ibm,opal/leds"); >> if (leds) { >> -- >> 2.7.4