Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp531402ybt; Wed, 17 Jun 2020 07:27:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzewYLKA/3DfaFqzhR/ojXV5HBab515CbFRw0ZyCdKHWNNIxAtEpZjraCVChTFWdwHFnLtO X-Received: by 2002:a17:906:2c5b:: with SMTP id f27mr8166970ejh.413.1592404061913; Wed, 17 Jun 2020 07:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592404061; cv=none; d=google.com; s=arc-20160816; b=0oQv4JW+7eeWMMRqKcXeUwMYLQ22wMSiGL/NWEqkCI3lGEELHxhv42OW2hYuz6T8bZ mPQPbIEjgf/tBOxOWi00d5zeJl/K0uZLRkjI6KRITXuaA+NU3Ew0vQ1UoGEx5JVSRo36 T5zaNZA3xQ0cODlmN0/ESfUU1qBIJ11jGHvClxUHF06RqWYC2fyGVOH3elhiZT8TavRn MkgWuFbUXGcYwqNhl5lzR/62zD2P718/XnT/Z5K8SQuQ19TNbzQUUC82ANhTbjoQlC1y uXbSp5PqsoFmAdlZa8pwFvnMXRboyXFgSJpiql+e6S5Ejs+Cqta/USCbhLPtZ2fKJVNU JzFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=HDoWDHpkjPS6d8LBQgcIgLv8z+yGCK9DQ6/ssyT50xc=; b=Oy6Yuh927wvum80/i0Gn0+JWW3IqD66E8bXsMzXWur9pxkIOnzquVt2oav5M2mkEhY 7q/ngbQInxS1Cx09+inNCl4AcEasZ2P/sMDO06093i+60lxisFmuabXoqSmbJAzsEv3I 4368gOi6rt1DvDvReQQtnh3EiMGqEThDO09Jz1HGAbjm2ULc145n9qpPDxlNyRq4cNy/ HwI0VtgQLLjPOx63E3PIE456BF5WHcPoBvcLShNwsvVlxKyt6yklRNQr6t9NBW35+Pu3 gtKNtb8XWQdD+OUdB8g/waVyCv7jRDLhO76M1qUeXedHRN48278W+Mp3DMTrqt/qjQjr 1K4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kbvD0JS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm13si75052edb.246.2020.06.17.07.27.18; Wed, 17 Jun 2020 07:27:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kbvD0JS5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbgFQOZH (ORCPT + 99 others); Wed, 17 Jun 2020 10:25:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgFQOZG (ORCPT ); Wed, 17 Jun 2020 10:25:06 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 241BEC06174E for ; Wed, 17 Jun 2020 07:25:05 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id l27so2564812ejc.1 for ; Wed, 17 Jun 2020 07:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HDoWDHpkjPS6d8LBQgcIgLv8z+yGCK9DQ6/ssyT50xc=; b=kbvD0JS5p/ATKSjl3hmKNOhn47xO+vXH7w66YDqblxafW1UpHizYuRuC7PhgZbAZYT I9GWrIqicryiZCAMw8NKdkgzFRmd49HU2t4oWYTY1XJxSHugRipIUSrH0J6AwKqR5iEq wvum2Ecq2m1aVwZ33AtzYzsRnOlc6+wVnfnlBYAfgEv9xgXUZdVaRXmQ935HcxmkwaTH GOKAfg2GtQQ5F/6br4TxKHV/8tvmMQ43DtXNnsDaTrBSSwuThSfAqnJRPEJhgWCyK+6j EEHK63g7i/QaWYSQlCHYekjmRZWXlqq6R8/KbrpAT+zVisJ3Nji1a/sLp0Eq7vTY9yIb A3cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HDoWDHpkjPS6d8LBQgcIgLv8z+yGCK9DQ6/ssyT50xc=; b=m0yR2geShH+e13d83KOXD1/K8emtqrPHPN4UwyICwdL4nGQ/XbCCyUrZ/4OK55PMyF rHeO+dUZ8mutfBj8Yo3mv6a3nLA36+QKdWeyPM42J1s/IDflViHS8pDOelLEwyeNWoqg rya53gCUs4HVwjt5gDEdK2Mukr5zHJs9ybEhtgc6B2SfXFCXmnIdGEM81IOaQp8R2vpc 4d9i7VkJPbUUcEviWyz5lwR5Gw6dXPLofxjUKgp2/AQWNYLR2iRA5IyjdQyDbITOmB+X MBbFMtnm6pzFDF++Nay60dUO6erA01gu424GkL7itLKvePDYS/J+VMEKOQdoYLWaOxXH 2ZwA== X-Gm-Message-State: AOAM532M0TVvevOFc5Hc7uXZcwluQOVf3Ed9sLjT3pAkv0Xz+B/ucwlC XCWtwDtPXA8K5G8t65qRNzcJu8UYc+f6g9eskQrcrQ== X-Received: by 2002:a17:906:7208:: with SMTP id m8mr8098561ejk.544.1592403903401; Wed, 17 Jun 2020 07:25:03 -0700 (PDT) MIME-Version: 1.0 References: <20200612121047.GF4282@kadam> <20200612121133.GA1139533@mwanda> <20200612174215.GI4282@kadam> In-Reply-To: From: Mike Leach Date: Wed, 17 Jun 2020 15:24:52 +0100 Message-ID: Subject: Re: [PATCH] coresight: cti: Fix error handling in probe To: Dan Carpenter Cc: Mathieu Poirier , Suzuki K Poulose , Alexander Shishkin , Greg Kroah-Hartman , linux-arm-kernel , Linux Kernel Mailing List , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org HI Dan, Looked into this some more... On Wed, 17 Jun 2020 at 11:53, Mike Leach wrote: > > Hi Dan, > > On Fri, 12 Jun 2020 at 18:43, Dan Carpenter wrote: > > > > On Fri, Jun 12, 2020 at 03:11:33PM +0300, Dan Carpenter wrote: > > > +static int cti_pm_setup(struct cti_drvdata *drvdata) > > > +{ > > > + int ret; > > > + > > > + if (drvdata->ctidev.cpu == -1) > > > + return 0; > > > + > > > + if (nr_cti_cpu) > > > + goto done; > > > + > > > + cpus_read_lock(); > > ^^^^^^^^^^^^^^^^ > > One thing which I do wonder is why we have locking here but not in the > > cti_pm_release() function. That was how the original code was so the > > patch doesn't change anything, but I am curious. > > > > Good point - the CTI PM code was modelled on the same code in the ETM > drivers, which show the same pattern. > Perhaps something we need to revisit in both drivers. > The ETMv4 code calls into the hotplug API twice - so takes the lock and makes both calls while holding the lock - using the "_cpuslocked" call variant to render the pair of calls atomic from the CPUHP context point of view. CTI only calls once so does not really need to take the locks and could simply use the normal variant. In both cases the cpuhp_remove_state uses the normal variant, which takes the locks inside the api call. For the CTI there is certainly a case for simplification, i..e drop the "_cpuslocked" variant and remove the explicit taking of the locks. Something along the lines of.... ... if (nr_cti_cpu) goto done; ret = cpu_pm_register_notifier(&cti_cpu_pm_nb); if (ret) return ret; ret = cpuhp_setup_state_nocalls(......); if (ret) { cpu_pm_unregister_notifier(....); return ret; } done: .... Regards Mike > Regards > > Mike > > > > + ret = cpuhp_setup_state_nocalls_cpuslocked( > > > + CPUHP_AP_ARM_CORESIGHT_CTI_STARTING, > > > + "arm/coresight_cti:starting", > > > + cti_starting_cpu, cti_dying_cpu); > > > + if (ret) { > > > + cpus_read_unlock(); > > > + return ret; > > > + } > > > + > > > + ret = cpu_pm_register_notifier(&cti_cpu_pm_nb); > > > + cpus_read_unlock(); > > > + if (ret) { > > > + cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING); > > > + return ret; > > > + } > > > + > > > +done: > > > + nr_cti_cpu++; > > > + cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata; > > > + > > > + return 0; > > > +} > > > + > > > /* release PM registrations */ > > > static void cti_pm_release(struct cti_drvdata *drvdata) > > > { > > > - if (drvdata->ctidev.cpu >= 0) { > > > - if (--nr_cti_cpu == 0) { > > > - cpu_pm_unregister_notifier(&cti_cpu_pm_nb); > > > + if (drvdata->ctidev.cpu == -1) > > > + return; > > > > > > - cpuhp_remove_state_nocalls( > > > - CPUHP_AP_ARM_CORESIGHT_CTI_STARTING); > > > - } > > > - cti_cpu_drvdata[drvdata->ctidev.cpu] = NULL; > > > + cti_cpu_drvdata[drvdata->ctidev.cpu] = drvdata; > > > + if (--nr_cti_cpu == 0) { > > > + cpu_pm_unregister_notifier(&cti_cpu_pm_nb); > > > + cpuhp_remove_state_nocalls(CPUHP_AP_ARM_CORESIGHT_CTI_STARTING); > > > } > > > } > > > > regards, > > dan carpenter > > > > > -- > Mike Leach > Principal Engineer, ARM Ltd. > Manchester Design Centre. UK -- Mike Leach Principal Engineer, ARM Ltd. Manchester Design Centre. UK