Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp91816imm; Thu, 21 Jun 2018 14:31:28 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKyNOa6L+rCApSTA8abbxObwZpq+1goRSzT0bfxecW9k7g9MbG+swGcJ2XUMry/MToPaVek X-Received: by 2002:a63:a902:: with SMTP id u2-v6mr23705200pge.67.1529616688483; Thu, 21 Jun 2018 14:31:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616688; cv=none; d=google.com; s=arc-20160816; b=CBrXv+nRo+2386Lj3n2Heq7DTA7Z+BL2WfbO2NG9EDf4tzylEEXFWFfieX8qGSNUBr CLIa8hPr2ydmEaeb0LNicvkKahEew95NWNlwggWkmvF8BRdYzFTEP91Ltb+f/ayAUWnp sOPdDCvqGNWIvV2Ykgm3wJ3XmU4PrlFptTy4dwj18fFDvZl04J9EkzJwpYfizt83pk0g lUgVT0q/sRbBS6IMWMBE+7QeCmj2gP1jjY6I7RN5bR9hRKMew+lA283wE05sdCi4WVzh 1XBnS3Ev9Zc4PdCxm+Zd0YfuIRhc6W/BSo4fp2puP7qsArfexvfxNYc1boVWKY3zTCUq k18Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EN+3nD/qkYtsCpyrBJQJHos/PxRh9YXP5by2XKfq/1Y=; b=UXzVt+QE2+C4/+Q8qhD1Wi09fTxflv511tzt+JzZ6BZvf/vwoG7kRbVIHlJjPf9Ywy QLD6J/dDg3aHGIlUk4sUgR6cWPNnd+iMJI9p+ZZGtuLnshZEsx7OiybF0PcpfpcCiAJu 82jcFWyPuaZtb3waHcIKpoH9TBAF4b3FO7b9eShOfLLQ8LC0KO0Sm1Ir809sAezQFmAB HsZY1xQpnRn02NAmtiFcnfDbn1tovN1GazY3yY7+h5V6nZIoDK1sYMXR22KCmbwSpQYY y7TRPF4DiW8HrP1nYYhvttqEGXmUqSRwckmtBy2Ef5UK3u2Cqlvs3kcmQQM5GRgg6iyJ QBTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=A7NrMiN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f26-v6si5223552pfn.366.2018.06.21.14.31.14; Thu, 21 Jun 2018 14:31:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=A7NrMiN9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933676AbeFUVaM (ORCPT + 99 others); Thu, 21 Jun 2018 17:30:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41882 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934006AbeFUV3N (ORCPT ); Thu, 21 Jun 2018 17:29:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EN+3nD/qkYtsCpyrBJQJHos/PxRh9YXP5by2XKfq/1Y=; b=A7NrMiN9CBkS8Ge8q6QN/nBAD XgUyzPMSVPdEv066QgRq4iNiC49SEJOSJGWfomrh4BpaYEWsbnezypgDc4YPh6yxQxn9OybHaNau7 PhizBI1hvbTmzBv06uhaBxrZZkm0IhiNh+waOfDKf8S1X+3hobeKUa4eo34umSSkQqxFJTL7Qs3jV /47TmUhqZYbk6cpPyJRcsurCmlNNISTte8+1meQfKSOvy55p+Iuw2l1d784WXjkRI9Zcx7yRaZIw2 W8FS8RDdGuSi1vXajEuwevPEke8zoYErNBTGV+Ndtd01NxbK5bj0ONE2UMZUapmJM7LKVX/hqhsZc 2u7vbaSjg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78f-0001c0-J4; Thu, 21 Jun 2018 21:29:09 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 15/26] ppc: Convert vas ID allocation to new IDA API Date: Thu, 21 Jun 2018 14:28:24 -0700 Message-Id: <20180621212835.5636-16-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Removes a custom spinlock and simplifies the code. Signed-off-by: Matthew Wilcox --- arch/powerpc/platforms/powernv/vas-window.c | 26 ++++----------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/arch/powerpc/platforms/powernv/vas-window.c b/arch/powerpc/platforms/powernv/vas-window.c index ff9f48812331..2a5e68a2664d 100644 --- a/arch/powerpc/platforms/powernv/vas-window.c +++ b/arch/powerpc/platforms/powernv/vas-window.c @@ -515,35 +515,17 @@ int init_winctx_regs(struct vas_window *window, struct vas_winctx *winctx) return 0; } -static DEFINE_SPINLOCK(vas_ida_lock); - static void vas_release_window_id(struct ida *ida, int winid) { - spin_lock(&vas_ida_lock); - ida_remove(ida, winid); - spin_unlock(&vas_ida_lock); + ida_free(ida, winid); } static int vas_assign_window_id(struct ida *ida) { - int rc, winid; - - do { - rc = ida_pre_get(ida, GFP_KERNEL); - if (!rc) - return -EAGAIN; - - spin_lock(&vas_ida_lock); - rc = ida_get_new(ida, &winid); - spin_unlock(&vas_ida_lock); - } while (rc == -EAGAIN); - - if (rc) - return rc; + int winid = ida_alloc_max(ida, VAX_WINDOWS_PER_CHIP, GFP_KERNEL); - if (winid > VAS_WINDOWS_PER_CHIP) { - pr_err("Too many (%d) open windows\n", winid); - vas_release_window_id(ida, winid); + if (winid == -ENOSPC) { + pr_err("Too many (%d) open windows\n", VAX_WINDOWS_PER_CHIP); return -EAGAIN; } -- 2.17.1