Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1255912ybl; Fri, 23 Aug 2019 16:18:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmDQhVm57oS/EPau8jesuFHN8ng9qPvtx7mTwHAEqnBIdl1xa/LD52AyMaQIitCFgpFTFW X-Received: by 2002:a17:902:43:: with SMTP id 61mr7600321pla.145.1566602312885; Fri, 23 Aug 2019 16:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602312; cv=none; d=google.com; s=arc-20160816; b=sT5ts4gtNNTeKSvhOSBxtuoukLBgzNGH5r1jurjDFNFxWHQjV580eUbAF7bDmTYpRk gVbgNeWCns9xCg7PQqe5EhYMaT0koMWJ69z0ZfYLbL0NKkA/XxqMWhR+eHeBPxVQxCdv nSB/ig2BlE+oqpByZOrDLJYlh/YMB6S20fIvVNVnClrIHQSG22WfjZgXEriN1+l8kbsj YO8TUEzLHybvptjHvWulJSmHFJ0Z/hgF2J7nQEcQdnBz2qOwTt9+RJt/2px9ee4OXAbm 9RoQ63KwtqKWffx2kG8fswk7MUXR1NMvPaBEWfMHHmmmynxmJBYY0DFZU/N0UUDr6u/D kjcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id :dkim-signature; bh=4mMOPrjVRpLXh0l7PSHytbiFzn24Q1HvF90UGH1/AX0=; b=KdHDQ8Z0qciQCoa1LewqY7Hxv4UUe6cmoaTOgaDN+89We03zJHlojhSQaYbIdPcU5r +S6oUCRyT58iY+MIxYxlVpv8ynLwgHt607ixaGSLuXjTcXGUy8EGDGgY8thyB7+JYiOm YXIIZkvSxF+y/Rzdl3PUpbrgQk4mQu81r5y10GZv49KxrdCxrixvbIdrqtnfRTCzlx++ inWIUwq4fLFrJfxP/I6x2TOPYV0+ZJ2YMbskwbUKG0EAfeDDwSGqUmZCHrp8g69pPOpz tFPRtk5QbGLictIFdfXAyvuaIDb/LoPCIPZjR6FZEotPkdfuKjPsYq8bdPMPkae3IK/O nDPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=RRkU5gz3; 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 s9si3193529pgc.305.2019.08.23.16.18.17; Fri, 23 Aug 2019 16:18:32 -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=pass header.i=@c-s.fr header.s=mail header.b=RRkU5gz3; 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 S2394600AbfHWMuY (ORCPT + 99 others); Fri, 23 Aug 2019 08:50:24 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:3073 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390578AbfHWMuU (ORCPT ); Fri, 23 Aug 2019 08:50:20 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46FLpd18Svz9txLy; Fri, 23 Aug 2019 14:50:17 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=RRkU5gz3; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id GWgFKKRpl3XB; Fri, 23 Aug 2019 14:50:17 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 46FLpd06SFz9txLw; Fri, 23 Aug 2019 14:50:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1566564617; bh=4mMOPrjVRpLXh0l7PSHytbiFzn24Q1HvF90UGH1/AX0=; h=From:Subject:To:Cc:Date:From; b=RRkU5gz3pi6/LD8KjsykcLG4BmMYYygvIAvB66NC1PKnOXeErx2+cM/khjgeMMavP vm2g+cOFA4uEWSTgchTYKYG74B1HMb4ZZCjFNQU4da+PxMflEbVLAdTNhNoIHUx3O6 es0MR0NrtONvZgOYrVOYtYEHRwjIcBeBoUcI/7OU= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 6F6CC8B87B; Fri, 23 Aug 2019 14:50:18 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Jj7G2aAZa8GU; Fri, 23 Aug 2019 14:50:18 +0200 (CEST) Received: from pc16032vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.230.103]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 51DA38B866; Fri, 23 Aug 2019 14:50:18 +0200 (CEST) Received: by pc16032vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 9657F639BC; Fri, 23 Aug 2019 12:50:17 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH 1/2] powerpc/32s: automatically allocate BAT in setbat() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , oss@buserror.net, galak@kernel.crashing.org Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Fri, 23 Aug 2019 12:50:17 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If no BAT is given to setbat(), select an available BAT. Signed-off-by: Christophe Leroy --- arch/powerpc/mm/book3s32/mmu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s32/mmu.c b/arch/powerpc/mm/book3s32/mmu.c index 50a1991d257f..5f08b93ecffd 100644 --- a/arch/powerpc/mm/book3s32/mmu.c +++ b/arch/powerpc/mm/book3s32/mmu.c @@ -251,9 +251,18 @@ void __init setbat(int index, unsigned long virt, phys_addr_t phys, { unsigned int bl; int wimgxpp; - struct ppc_bat *bat = BATS[index]; + struct ppc_bat *bat; unsigned long flags = pgprot_val(prot); + if (index == -1) + index = find_free_bat(); + if (index == -1) { + pr_err("%s: no BAT available for mapping 0x%llx\n", __func__, + (unsigned long long)phys); + return; + } + bat = BATS[index]; + if ((flags & _PAGE_NO_CACHE) || (cpu_has_feature(CPU_FTR_NEED_COHERENT) == 0)) flags &= ~_PAGE_COHERENT; -- 2.13.3