From nobody Sun Jun 21 22:07:04 2026 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4gk5612zc8z6htCj for ; Sun, 21 Jun 2026 22:07:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "YR1" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4gk5610Gvnz42xp for ; Sun, 21 Jun 2026 22:07:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782079625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mBwWhpNB493eQJiWSIVkjELI23IiLDG7NVmHDyCk5Jg=; b=S0mwEic7jpuHE6P6ogehpgXEVlrwkvzeB5phcXBsLYSzUsjq4mh73TTh3qYUe6nmfjDiUU iteOiru0NZS5gQtVRZCP7x55Tv7UUVJcj0lgXU2A9BqcwO9GINSWAPVQgcIYkJutoOI7iv UXV6xHaLKjuJs7gVhRch+FkPfis0vY9r6UknHqwi3ECwGgsp25Tyl5Q1Yrsns3Dwct8gaG /kgeMhkhE3NqhoEEtBnTlj9r8ANyk0DUmhSW1gPZvIecf4z4g0J54eTW/sEUlBk1JFY0Wd WLtq67eW2om+56RquoUWepvJIG45kNpOKURLlfXJ7OHo5vsJk3p/8O6K0M7Y+A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1782079625; a=rsa-sha256; cv=none; b=ycq3Qy6uruKuuqJsvgKWiRLOzmddMw+26hD9ktmh5jDczeVO7Ub7rXa2m+DNqSb48C1P3b H6jcuCkt1CPEao3aCCqwZiXYFMPb32SgGa0WCL7TYogdcN9Wv7m3/PHL48k86/4KdMi67J raSwm5qZxOqR529hgu40pml/DQS0FOS77lOJpYv8VGMdSLZxJAQLVk2C6/xbAe/rhc4OkT KMlw4GO6TEeA/c47kyb0iYHO4dNrueX5Ex134EE+0akKLFF3ufcJMeuwmsz42SUiWm3YG+ J3ynx41xCJaH9uGxM5CzYZOWkmfsFEwtAn6DKTzmxXsFk2X6ygdXbGfGYJX+Tw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1782079625; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mBwWhpNB493eQJiWSIVkjELI23IiLDG7NVmHDyCk5Jg=; b=iMZzhWnLVDoDEXJvc5eO6hNTFtoituoONMRB32Wv6NJ6tOB48HLh8o7RTpg6ZSeC+j3OHn qW76/a/YeGt3GypZMF+yF9f1RK4tVILaY4lC4N6edTQfKDTomgiDRqDgOS133HYscW2kyo QmYSb5ZGfZXoKu3HN72uCscPhAw2Y4mLmSLZ4LZ9P6lmW9VqBtM9QZR+LWjgznJVXCqWSY vZE0CkX6pYuP9mwU4q7lln2Qh/bBqpK9vZhEBvPfHI6ck8z6qghC0oBm852T64KJ0MfMjN IEwBDy/jqayFRmzev3qS2og5kDKCfI0BXoygYWcOfCj+F8FqMXpzHLp+gUvCLw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4gk5606SFJz4ll for ; Sun, 21 Jun 2026 22:07:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 20d3b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sun, 21 Jun 2026 22:07:04 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Justin Hibbits Subject: git: 9faeaac936ae - main - powerpc/pmap: Use variable-sized TID List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhibbits X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9faeaac936aea78f9b5ce1a8ad3d27e2632d4e37 Auto-Submitted: auto-generated Date: Sun, 21 Jun 2026 22:07:04 +0000 Message-Id: <6a386088.20d3b.d76b1bd@gitrepo.freebsd.org> The branch main has been updated by jhibbits: URL: https://cgit.FreeBSD.org/src/commit/?id=9faeaac936aea78f9b5ce1a8ad3d27e2632d4e37 commit 9faeaac936aea78f9b5ce1a8ad3d27e2632d4e37 Author: Justin Hibbits AuthorDate: 2025-12-17 03:20:55 +0000 Commit: Justin Hibbits CommitDate: 2026-06-21 21:24:03 +0000 powerpc/pmap: Use variable-sized TID e6500 core supports 14-bit TIDs (16384), while all earlier cores support only 8 bit TIDs. Dynamically allocate the tidbusy array at bootstrap time so that it stays in the TLB1, but is sized appropriately for the core. With MAXCPU of 32, a e6500 tidbusy would be (8 * 32 * 16384), or 4MB for this array, while e5500 would use (8 * 32 * 256), or 64kB. --- sys/powerpc/booke/pmap.c | 52 ++++++++++++++++++++++++++++++++++++++++------- sys/powerpc/include/spr.h | 2 ++ 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/sys/powerpc/booke/pmap.c b/sys/powerpc/booke/pmap.c index 625d57940c01..310d38d5c450 100644 --- a/sys/powerpc/booke/pmap.c +++ b/sys/powerpc/booke/pmap.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include #include @@ -204,8 +205,10 @@ extern int elf32_nxstack; /* TLB and TID handling */ /**************************************************************************/ -/* Translation ID busy table */ -static volatile pmap_t tidbusy[MAXCPU][TID_MAX + 1]; +/* Translation ID busy table (dynamically allocated) */ +static __inline void tid_set_busy(int cpu, int tid, pmap_t pmap); +static volatile pmap_t *tidbusy; +uint32_t tid_max; /* * TLB0 capabilities (entry, way numbers etc.). These can vary between e500 @@ -637,6 +640,7 @@ mmu_booke_bootstrap(vm_offset_t start, vm_offset_t kernelend) vm_size_t kstack0_sz; vm_paddr_t kstack0_phys; vm_offset_t kstack0; + uint32_t tid_bits; void *dpcpu; debugf("mmu_booke_bootstrap: entered\n"); @@ -660,6 +664,18 @@ mmu_booke_bootstrap(vm_offset_t start, vm_offset_t kernelend) /* Read TLB0 size and associativity. */ tlb0_get_tlbconf(); + /* + * Calculate the max TID from the hardware. Allow overriding with a + * tunable. The tunable should be a power of 2. + */ + tid_bits = ((mfspr(SPR_MMUCFG) & MMUCFG_PIDSIZE_M) >> MMUCFG_PIDSIZE_S); + TUNABLE_INT_FETCH("machdep.tid_max", &tid_max); + if (tid_max <= 0) + tid_max = INT_MAX; + else + tid_max = 1 << ilog2(tid_max); + tid_max = min((1 << tid_bits), tid_max) - 1; + /* * Align kernel start and end address (kernel image). * Note that kernel end does not necessarily relate to kernsize. @@ -668,6 +684,11 @@ mmu_booke_bootstrap(vm_offset_t start, vm_offset_t kernelend) data_start = round_page(kernelend); data_end = data_start; + tidbusy = (void *)data_end; + printf("tidbusy at %p\n", tidbusy); + printf("tidmax = %d\n", tid_max); + data_end += round_page(sizeof(pmap_t) * MAXCPU * (tid_max + 1)); + /* Allocate the dynamic per-cpu area. */ dpcpu = (void *)data_end; data_end += DPCPU_SIZE; @@ -913,7 +934,7 @@ mmu_booke_bootstrap(vm_offset_t start, vm_offset_t kernelend) kernel_pmap->pm_tid[i] = TID_KERNEL; /* Initialize each CPU's tidbusy entry 0 with kernel_pmap */ - tidbusy[i][TID_KERNEL] = kernel_pmap; + tid_set_busy(i, TID_KERNEL, kernel_pmap); } /* Mark kernel_pmap active on all CPUs */ @@ -2460,6 +2481,22 @@ mmu_booke_page_array_startup(long pages) /* TID handling */ /**************************************************************************/ +static __inline void +tid_set_busy(int cpu, int tid, pmap_t pmap) +{ + tidbusy[cpu * (tid_max + 1) + tid] = pmap; + if (pmap == NULL) + pmap->pm_tid[cpu] = TID_NONE; + else + pmap->pm_tid[cpu] = tid; +} + +static __inline pmap_t +tid_get_busy(int cpu, int tid) +{ + return (tidbusy[cpu * (tid_max + 1) + tid]); +} + /* * Allocate a TID. If necessary, steal one from someone else. * The new TID is flushed from the TLB before returning. @@ -2477,21 +2514,22 @@ tid_alloc(pmap_t pmap) thiscpu = PCPU_GET(cpuid); tid = PCPU_GET(booke.tid_next); - if (tid > TID_MAX) + /* tid_max is always a power-of-2-minus-1, so check for overflow. */ + if ((tid & ~tid_max) != 0) tid = TID_MIN; PCPU_SET(booke.tid_next, tid + 1); /* If we are stealing TID then clear the relevant pmap's field */ - if (tidbusy[thiscpu][tid] != NULL) { + if (tid_get_busy(thiscpu, tid) != NULL) { CTR2(KTR_PMAP, "%s: warning: stealing tid %d", __func__, tid); - tidbusy[thiscpu][tid]->pm_tid[thiscpu] = TID_NONE; + tid_set_busy(thiscpu, tid, NULL); /* Flush all entries from TLB0 matching this TID. */ tid_flush(tid); } - tidbusy[thiscpu][tid] = pmap; + tid_set_busy(thiscpu, tid, pmap); pmap->pm_tid[thiscpu] = tid; __asm __volatile("msync; isync"); diff --git a/sys/powerpc/include/spr.h b/sys/powerpc/include/spr.h index afa1692bed75..40911a7c293d 100644 --- a/sys/powerpc/include/spr.h +++ b/sys/powerpc/include/spr.h @@ -868,6 +868,8 @@ #define BUCSR_BBFI 0x00000200 /* Branch Buffer Flash Invalidate */ #define SPR_MMUCFG 0x3f7 /* ..8 MMU Configuration Register */ +#define MMUCFG_LPIDSIZE_M 0x0F000000 +#define MMUCFG_LPIDSIZE_S 24 #define MMUCFG_PIDSIZE_M 0x000007c0 #define MMUCFG_PIDSIZE_S 6 #define MMUCFG_MAVN_M 0x00000003