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=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no 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 01FE1C43331 for ; Sun, 29 Mar 2020 02:58:52 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 65297206E6 for ; Sun, 29 Mar 2020 02:58:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="JQUR5R0l" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 65297206E6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48qgK50KHJzDqdW for ; Sun, 29 Mar 2020 13:58:49 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=willy@infradead.org; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48qgH30PL6zDqdP for ; Sun, 29 Mar 2020 13:57:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=4yXTPf18akGL4F1+3ogioOkX9iKPvYO8hyOrfJXVtE8=; b=JQUR5R0lE7xi/bwp2+wCOJ6n+2 jr/hNpXfA6Sap1y57jeS+TIIvZ50P9Y0zhfobUFlky6zEHnrl36iUVGituZcetweLxImlDgR+0iir d3QCGnZfRnPVOSoC/nsRLR2bhPsiB+W2w8sFoZ77juMrW4OGkTFvQUvqhPA08FEK7I5Eg97c5tGib Zw7dB5t65kxfGeoY0SAo/6dRwhdi9zSLhZhYeBRJ2LSRPBWI8gvyMpqmHcCHQ0sWsQbZXQvsWH/mT 6hETfSx0PyDhWRS+X/9G+thvPoa8q1ZMjK5EVIvLqln8TC7mmm8ZUKLOFxK9rhl7dENKu5keZOLVK thM8OiZQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jIO7V-00020F-KY; Sun, 29 Mar 2020 02:56:17 +0000 Date: Sat, 28 Mar 2020 19:56:17 -0700 From: Matthew Wilcox To: Alastair D'Silva Subject: Re: [PATCH v4 10/25] nvdimm: Add driver for OpenCAPI Persistent Memory Message-ID: <20200329025617.GT22483@bombadil.infradead.org> References: <20200327071202.2159885-1-alastair@d-silva.org> <20200327071202.2159885-11-alastair@d-silva.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200327071202.2159885-11-alastair@d-silva.org> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Madhavan Srinivasan , Alexey Kardashevskiy , Masahiro Yamada , Oliver O'Halloran , Mauro Carvalho Chehab , Ira Weiny , Thomas Gleixner , Rob Herring , Dave Jiang , linux-nvdimm@lists.01.org, "Aneesh Kumar K . V" , Krzysztof Kozlowski , Anju T Sudhakar , Mahesh Salgaonkar , Andrew Donnellan , Arnd Bergmann , Greg Kurz , Nicholas Piggin , =?iso-8859-1?Q?C=E9dric?= Le Goater , Dan Williams , Hari Bathini , linux-mm@kvack.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Vishal Verma , Frederic Barrat , Paul Mackerras , Andrew Morton , linuxppc-dev@lists.ozlabs.org, "David S. Miller" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Fri, Mar 27, 2020 at 06:11:47PM +1100, Alastair D'Silva wrote: > +static struct mutex minors_idr_lock; > +static struct idr minors_idr; ... > + mutex_lock(&minors_idr_lock); > + minor = idr_alloc(&minors_idr, ocxlpmem, 0, NUM_MINORS, GFP_KERNEL); > + mutex_unlock(&minors_idr_lock); ... > + mutex_lock(&minors_idr_lock); > + idr_remove(&minors_idr, MINOR(ocxlpmem->dev.devt)); > + mutex_unlock(&minors_idr_lock); ... > + mutex_init(&minors_idr_lock); > + idr_init(&minors_idr); Unless you look up ocxlpmem by minor number later in the patch series (and most of the series didn't make it to my mailbox), this can just be an ida. static DEFINE_IDA(minors); ... minor = ida_alloc_max(&minors, NUM_MINORS, GFP_KERNEL); ... ida_free(&minors, MINOR(ocxlpmem->dev.devt)); ... and you can drop the dynamic initialisation. And the mutex.