Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp3851406ybe; Mon, 16 Sep 2019 02:23:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe4iP6KoeqKekAEtVOnYcKNqe/3B0gHvNDzYGPubYfkCd+8kdu5nBU39Wm44WSK5kqmuru X-Received: by 2002:a50:ef12:: with SMTP id m18mr5245003eds.18.1568625813108; Mon, 16 Sep 2019 02:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568625813; cv=none; d=google.com; s=arc-20160816; b=r+aPfpxY5JeG/JroM9saLua6Fk3R6vE8z0zH25ddJGAVrnqblWhldciNpPs/8gVxzJ 4odGpB7p9Hmfc1zzAxCdIki1wgtkxnRZ1nN9h/HJqGZXOdkGCw9/E9zFYymdFZUFCPa5 4lt6K+DFZ9xDaJXNz5hnMwt0gyb5cVLBDfzaStckC7MMWQ2zU1wT2PacJf01HUZkmln7 yGiEXKp9SEB0ad5RoV3N4ukv+aatw+QLpVX0y9CtnvAskPNWlPCXmwLYTakPZnJpj5nr 3WQspZrH8A+z1bQf++VOb+9YBNl+r1mJ7oWyBT8D+vTYA8k3Nw28qeWKhL+VlHV0qFCW o+sw== 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=7yOhcbQ3kkJvXHAKpVB1ac6bJmwMGcGUBxtNLWRyWBU=; b=lINoWCQKEW2BzM4E9OnsvN3BSlmZH5LtWm/T5AGXnJPmzBmddljJQ32fbCoapqNFc+ Os+AG+ZdSKFo3qAJX9L0BWMPyYxfBg1FSiCpUFeB6brwSoRTKmF8rlOuuhDa8qJSVjhT PR5UHq2X37ks6OGVDGvjJci66vavFYjMqe0VPXffYVIvuWdPqc3QMnepnmTiNwoGIuAJ R7i6mAcImVhex03hVVHXASzmo19zvOnSU/pWTDPEWpIsOsohQKP5dxtMRO0UwRaNdSNo dERsnmshJnN4FMZ7hTxOgiKmUSg9PHME5Tutpbc540M5cZ18IVNGWFPco1Y/WxxaxN9J Fc3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b="fWp/Sd3E"; 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 j3si10018475edj.448.2019.09.16.02.23.09; Mon, 16 Sep 2019 02:23:33 -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="fWp/Sd3E"; 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 S1729972AbfIPGm5 (ORCPT + 99 others); Mon, 16 Sep 2019 02:42:57 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:8149 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729949AbfIPGm5 (ORCPT ); Mon, 16 Sep 2019 02:42:57 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 46WxWb43F5z9ttgV; Mon, 16 Sep 2019 08:42:51 +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=fWp/Sd3E; 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 pyJyMyAc_DYU; Mon, 16 Sep 2019 08:42:51 +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 46WxWb2kGXz9ttgK; Mon, 16 Sep 2019 08:42:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1568616171; bh=7yOhcbQ3kkJvXHAKpVB1ac6bJmwMGcGUBxtNLWRyWBU=; h=From:Subject:To:Cc:Date:From; b=fWp/Sd3E5hLYs5tiZttauQJnA02xxckK6mzUfwoSY1HVKTWEPG6oLUjKwI+9ARc1W ironm4ki2c3v3d3rsd9aDtTmyu9THr913xbD4OY/da6Jt+rzIa+VpJEf8gpQI3RiNc OV9aUplfXG+ceKL5/lZdYMCTIWwYsYOVWtBq28RA= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id EE09C8B7CA; Mon, 16 Sep 2019 08:42:55 +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 BqLszcFm49l2; Mon, 16 Sep 2019 08:42:55 +0200 (CEST) Received: from pc16032vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B16638B752; Mon, 16 Sep 2019 08:42:55 +0200 (CEST) Received: by pc16032vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 45C046B763; Mon, 16 Sep 2019 06:42:55 +0000 (UTC) Message-Id: <966e6d6a226f9786098d296239a6c65064e73a41.1568616151.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH v2 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: Mon, 16 Sep 2019 06:42:55 +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 --- v2: no change --- 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 84d5fab94f8f..69b2419accef 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