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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B621EB64DD for ; Tue, 1 Aug 2023 08:40:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231802AbjHAIks (ORCPT ); Tue, 1 Aug 2023 04:40:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231194AbjHAIkp (ORCPT ); Tue, 1 Aug 2023 04:40:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BB1F10E for ; Tue, 1 Aug 2023 01:40:42 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E768561499 for ; Tue, 1 Aug 2023 08:40:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D055AC433C8; Tue, 1 Aug 2023 08:40:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1690879241; bh=ZvBLYBeZn76K2qP99PMw2nICTG1lNnfIlsFyKhUr5UM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kx/FFC3qDDaNoUrqn9xHxCVzKxLdSVnJLGuQZUKVeiRUrn2FarZIOv0XcethkOSrR OTd2S/rYLXNpV5yJaFerwWZ2VAUckLe5vt9L/rIfNFKsaocXeFuEHcsfk2cKuCjmvw tgF0jXzmLBMeHU9dzfGZ05hUXwZ3A21EbL6MA0H4= Date: Tue, 1 Aug 2023 10:40:38 +0200 From: Greg KH To: "Gangurde, Abhijit" Cc: "masahiroy@kernel.org" , "linux-kernel@vger.kernel.org" , "Simek, Michal" , "git (AMD-Xilinx)" , "Agarwal, Nikhil" , "Gupta, Nipun" Subject: Re: [PATCH v2 1/4] cdx: Introduce lock to protect controller ops and controller list Message-ID: <2023080105-eggnog-probably-9ff3@gregkh> References: <20230731120813.123247-1-abhijit.gangurde@amd.com> <20230731120813.123247-2-abhijit.gangurde@amd.com> <2023073148-carried-unshaved-77e4@gregkh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 01, 2023 at 08:34:00AM +0000, Gangurde, Abhijit wrote: > > From: Greg KH > > Sent: Monday, July 31, 2023 5:55 PM > > To: Gangurde, Abhijit > > Cc: masahiroy@kernel.org; linux-kernel@vger.kernel.org; Simek, Michal > > ; git (AMD-Xilinx) ; Agarwal, Nikhil > > ; Gupta, Nipun > > Subject: Re: [PATCH v2 1/4] cdx: Introduce lock to protect controller ops and > > controller list > > > > On Mon, Jul 31, 2023 at 05:38:10PM +0530, Abhijit Gangurde wrote: > > > Add a mutex lock to prevent race between controller ops initiated by > > > the bus subsystem and the controller registration/unregistration. > > > > > > Signed-off-by: Abhijit Gangurde > > > --- > > > drivers/cdx/cdx.c | 14 ++++++++++++++ > > > 1 file changed, 14 insertions(+) > > > > > > diff --git a/drivers/cdx/cdx.c b/drivers/cdx/cdx.c > > > index d2cad4c670a0..66797c8fe400 100644 > > > --- a/drivers/cdx/cdx.c > > > +++ b/drivers/cdx/cdx.c > > > @@ -72,6 +72,8 @@ > > > > > > /* CDX controllers registered with the CDX bus */ > > > static DEFINE_XARRAY_ALLOC(cdx_controllers); > > > +/* Lock to protect controller ops and controller list */ > > > +static DEFINE_MUTEX(cdx_controller_lock); > > > > Wait, why do you have a local list and not just rely on the list the > > driver core has for you already? Isn't this a duplicate list where you > > have objects on two different lists with a lifespan controlled only by > > one of them? > > cdx_controllers list is holding just the controllers registered on the cdx bus system. Which are devices on the bus, so why do you need a separate list? > CDX devices are still maintained by driver core list. Controller list is used by rescan > which triggers rescan on all the controllers. Again, why a separate list? The driver core already tracks these, right? thanks, greg k-h