From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D03A0C433E1 for ; Thu, 23 Jul 2020 19:17:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B8D8206F4 for ; Thu, 23 Jul 2020 19:17:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="h2lZGt/C"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="PEMyIAoD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B8D8206F4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=U+za/nHTjKMGUx5u4mZM2swyeltzwCR090hapvn6VYo=; b=h2lZGt/C2Jhbb5PYFEBqGgror BFf7fTP8C9ZnzKXSynggo0WAk1uTLlmtY9JO73iMaEOmP7pGRBQmltezLD/OPtgD1YORTKpq/j/Qi CJkLybKkZMwmYZcTmyiLwXaXX2/BazVFneBd5MpYooC92YmqXqh98iG21Ah7Q5y2v/ai1jI7llwe4 FH5KnwhATSbJ40ekXPYx2h2Z0g2BIREVBz76juTXZorth1pBYQWUgMGDgHP3SJ3+FJZ76KfS577Vm br7EpxX/KqFGf59glhHct9oZYoBdNLroUdz97/Vcu5uHT+zqMJKUcINX99N3IsmoQqWV2RIYJA1gx 3WHVbL1Lg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jygh5-0004ha-CZ; Thu, 23 Jul 2020 19:15:51 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jyggz-0004ga-RE for linux-arm-kernel@lists.infradead.org; Thu, 23 Jul 2020 19:15:48 +0000 Received: by mail-pl1-x641.google.com with SMTP id x8so3000151plm.10 for ; Thu, 23 Jul 2020 12:15:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=drgZiSygN6JSj7SgkkiVPv82AWN+9+SHtaQso4EwF1s=; b=PEMyIAoDBAYfPWyTYwH/eWgNv2QEeKAyCv84crsbpeDvhjBjA3904zBWhiMt4RxK4A uBTrqLVkBObxuzaMTXXuO7Qq19Ayhf1lvsxpGNODUXRlilU76HwiIBo2M/zt71deL5T7 lRIQVmHTEsPuGzDMmkXGPNV8gkgngaViSgoIE3jARDnu4gnPklCGrRuzy1mn3z0XnyKr 0yzyGQlF1L6tdgbNPPod2LxFw8iLdFtrlmX1nNUNbgsSIGT7Vuae5//NT9HfwEPws/ZM TjHryaDBmGNBmXcv8UDHG8U3DkyEUQgeruWd44SYNyYOwcd6sYd9V1nJ7M8Wco5D+47Q HBTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=drgZiSygN6JSj7SgkkiVPv82AWN+9+SHtaQso4EwF1s=; b=WpCKEGqgKabGIwchz2A76eopelMUJ/3ooEFOSiIQ4eNGt7x3BRuBZNYxLv6ThtAmgb rXvUeg7UKT8Zfd16RZbqEYLkBOSuR0qVdjNP7F7R3z4VADBCqBw1YwkN5EXUUy2FOTX0 iEQBrEy7HzA4Q40qb0UKXu1x3LVUASrH0HQn++zVUlEauV+oun9l6oFz6TM++2qE5KaJ vNUHCDIAECTH7fZbBb0JKs6lEpnddSU4H4GnB04t/e4qVU2PytqOJZHcmBw+egS6ABVY 5Z7svsQEFInFqXEfnAymwhUUUSQpF3i0LC6iGiLgsbNUbKrwpsemYf/A3pjZF4oMDDOT uBzQ== X-Gm-Message-State: AOAM532KGaXgCGj3gy+ga/B88AK9BN3+/gYbjc+iOXlmPs5lv4pkrh1D dGWj80CmAW3R2duaDQr+YG5hTg== X-Google-Smtp-Source: ABdhPJyxTdQC+XUb5GzoF3QrS6I5B2GG8MSXzXLqO6kSXrwWX6FgXXfxxvDAHPu6T+fXAHF9XJyt0g== X-Received: by 2002:a17:90a:c90c:: with SMTP id v12mr1756262pjt.112.1595531743566; Thu, 23 Jul 2020 12:15:43 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id a67sm3772644pfa.81.2020.07.23.12.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jul 2020 12:15:42 -0700 (PDT) Date: Thu, 23 Jul 2020 13:15:40 -0600 From: Mathieu Poirier To: Greg Kroah-Hartman Subject: Re: [PATCH v4 06/20] coresight: add try_get_module() in coresight_grab_device() Message-ID: <20200723191540.GB1323936@xps15> References: <20200723042802.22511-1-tingwei@codeaurora.org> <20200723042802.22511-7-tingwei@codeaurora.org> <20200723110707.GA1960107@kroah.com> <20200723180447.GA1323936@xps15> <20200723181837.GA2944775@kroah.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200723181837.GA2944775@kroah.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200723_151546_884886_C3A605BC X-CRM114-Status: GOOD ( 39.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: tsoni@codeaurora.org, Sai Prakash Ranjan , Kim Phillips , Mao Jinlong , Suzuki K Poulose , Alexander Shishkin , coresight@lists.linaro.org, Randy Dunlap , Mian Yousaf Kaukab , Russell King , Tingwei Zhang , Leo Yan , linux-arm-kernel@lists.infradead.org, Mike Leach Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jul 23, 2020 at 08:18:37PM +0200, Greg Kroah-Hartman wrote: > On Thu, Jul 23, 2020 at 12:04:47PM -0600, Mathieu Poirier wrote: > > Hi Greg, > > > > On Thu, Jul 23, 2020 at 01:07:07PM +0200, Greg Kroah-Hartman wrote: > > > On Thu, Jul 23, 2020 at 12:27:48PM +0800, Tingwei Zhang wrote: > > > > When coresight device is in an active session, driver module of > > > > that device should not be removed. Use try_get_module() in > > > > coresight_grab_device() to prevent module to be unloaded. > > > > > > Are you sure this works? Why is it needed at all? Why not just tear > > > down the children properly when a module is removed so that you don't > > > need this at all? > > > > Using the terms parent and child is somewhat ambiguous... This is not a > > parent-child relationship but simply an association between devices, something > > like port 1 on device "parent" is connected to port 2 on device "child". The > > parent-child nomenclature was chosen to reflect that a device appears before > > another in a coresight path. Otherwise there is no other relation between > > devices, hence the choice of using try_get_module()/put_module() to prevent > > drivers from being taken away. I'd be happy to proceed differently but haven't > > found better options. > > > > Going back to parent/child, we could have chosen left/right, up/down or A/B, all > > of which are just as confusion. > > Ok, thanks. > > But this causes confusion for everyone as seen below: > > > > > Signed-off-by: Tingwei Zhang > > > > --- > > > > drivers/hwtracing/coresight/coresight.c | 27 +++++++++++++++++++++---- > > > > 1 file changed, 23 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > > > > index b7151c5f81b1..17bc76ea86ae 100644 > > > > --- a/drivers/hwtracing/coresight/coresight.c > > > > +++ b/drivers/hwtracing/coresight/coresight.c > > > > @@ -640,7 +640,7 @@ struct coresight_device *coresight_get_sink_by_id(u32 id) > > > > * don't appear on the trace path, they should be handled along with the > > > > * the master device. > > > > */ > > > > -static void coresight_grab_device(struct coresight_device *csdev) > > > > +static int coresight_grab_device(struct coresight_device *csdev) > > > > { > > > > int i; > > > > > > > > @@ -648,10 +648,25 @@ static void coresight_grab_device(struct coresight_device *csdev) > > > > struct coresight_device *child; > > > > > > > > child = csdev->pdata->conns[i].child_dev; > > > > - if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) > > > > + if (child && child->type == CORESIGHT_DEV_TYPE_HELPER) { > > > > + if (!try_module_get(child->dev.parent->driver->owner)) > > > > > > Why the child's parent? Why not the child itself? > > > > The device structure of each coresight_device is not associated with a driver. > > It is there to take advantages of device goodies such as dev.type, dev.group, > > dev.release and dev.bus. Coresight IP blocks are discovered on the AMBA bus and as > > such amba_device::dev::driver holds the driver itself. In coresight_register() > > the association coresigth::dev::parent = amba_device::dev is made. > > > > > > > > > > > > + goto err; > > > > > > What about the error given to you here? Why throw that away? > > > > > > > pm_runtime_get_sync(child->dev.parent); > > > > + } > > > > } > > > > + if (!try_module_get(csdev->dev.parent->driver->owner)) > > > > + goto err; > > > > > > You don't reduce the child's parent's driver owner module reference > > > here? > > > > Here @parent is referencing the current device. Now that helper devices > > connected to any of its outgoing ports have been enabled (and a reference count > > to the helper device driver incremented), a reference count to the current device > > driver can also be incremented. > > I mean the fact that your error handling does not seem to roll back the > module reference count you got up above in the other loop. Ah! You were talking about the error condition, while I thought you were referring to the normal execution path. I am in agreement with all your comments on error handling. > > Or if it does, it's really really not obvious, and should at the very > least, be commented as to how it's all cleaning up properly. > > thanks, > > greg k-h _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel