Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F156502606
D44456.id171141.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
15 KB
Referenced Files
None
Subscribers
None
D44456.id171141.diff
View Options
diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64
--- a/sys/conf/files.amd64
+++ b/sys/conf/files.amd64
@@ -123,7 +123,7 @@
dev/axgbe/xgbe_osdep.c optional axp
dev/axgbe/xgbe-i2c.c optional axp
dev/axgbe/xgbe-phy-v2.c optional axp
-dev/coredirector/coredirector.c optional coredirector
+dev/intelhfi/intelhfi.c optional intelhfi
dev/enic/enic_res.c optional enic
dev/enic/enic_txrx.c optional enic
dev/enic/if_enic.c optional enic
diff --git a/sys/dev/coredirector/coredirector.c b/sys/dev/intelhfi/intelhfi.c
rename from sys/dev/coredirector/coredirector.c
rename to sys/dev/intelhfi/intelhfi.c
--- a/sys/dev/coredirector/coredirector.c
+++ b/sys/dev/intelhfi/intelhfi.c
@@ -1,29 +1,7 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
+/*
* Copyright (c) 2024 Koine Yuusuke <koinec@yahoo.co.jp>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
#include <sys/cdefs.h>
@@ -54,23 +32,15 @@
#include <x86/intr_machdep.h>
#include <x86/apicvar.h>
-#define COREDIRECTOR_NAME "coredirector"
+#define INTELHFI_NAME "intelhfi"
#ifdef DEBUG
-#define DPRINTF(fmt, args...) printf("coredirector:" fmt, ##args)
+#define DPRINTF(dev, fmt, args...) device_printf(dev, fmt, ##args)
#else
-#define DPRINTF(fmt, args...)
+#define DPRINTF(dev, fmt, args...)
#endif
-#define BITSCOUNT(n) (!!((n)&((uint8_t)1<<0)) \
- + !!((n)&((uint8_t)1<<1)) \
- + !!((n)&((uint8_t)1<<2)) \
- + !!((n)&((uint8_t)1<<3)) \
- + !!((n)&((uint8_t)1<<4)) \
- + !!((n)&((uint8_t)1<<5)) \
- + !!((n)&((uint8_t)1<<6)) \
- + !!((n)&((uint8_t)1<<7)))
-#define ROUNDUP8(n) ((((n)+7)/8)*8)
+#define ROUNDUP8(n) (((n)+7)&(~7))
#define CPUID_LEAF6_ECX_CLASSES(c) (((c)&CPUID_PERF_TD_CLASSES)>>8)
#define CPUID_LEAF6_EDX_TBLPAGES(c) (((c)&CPUID_TD_TBLPAGES)>>8)
@@ -78,9 +48,11 @@
/*
* Structure defines
*/
-struct coredirector_instance {
+struct intelhfi_instance {
int ref;
+ device_t dev;
+
struct {
uint32_t hfi :1;
uint32_t thdirector :1;
@@ -112,27 +84,27 @@
struct mtx intr_lock;
};
-struct coredirector_softc {
+struct intelhfi_softc {
device_t sc_dev;
int cpuid;
- struct coredirector_instance *inst;
+ struct intelhfi_instance *inst;
};
/*
* Prototype defines
*/
-static void coredirector_msr_setflag(uint64_t addr, int cpu, uint64_t flag);
-static void coredirector_get_hwtable(struct coredirector_instance *inst);
-static void coredirector_interrupt(int cpu, void *value);
-static void coredirector_identify(driver_t *driver, device_t parent);
-static int coredirector_probe(device_t dev);
-static void coredirector_set_instance(struct coredirector_softc *sc);
-static int coredirector_attach_notbsp(device_t dev);
-static int coredirector_attach(device_t dev);
-static int coredirector_detach(device_t dev);
-static int coredirector_dumptable_sysctl(SYSCTL_HANDLER_ARGS);
+static void intelhfi_msr_setflag(uint64_t addr, int cpu, uint64_t flag);
+static void intelhfi_get_hwtable(struct intelhfi_instance *inst);
+static void intelhfi_interrupt(int cpu, void *value);
+static void intelhfi_identify(driver_t *driver, device_t parent);
+static int intelhfi_probe(device_t dev);
+static void intelhfi_set_instance(struct intelhfi_softc *sc);
+static int intelhfi_attach_notbsp(device_t dev);
+static int intelhfi_attach(device_t dev);
+static int intelhfi_detach(device_t dev);
+static int intelhfi_dumptable_sysctl(SYSCTL_HANDLER_ARGS);
#if defined(SMP) && defined(SCHED_ULE)
extern struct cpu_group *cpu_top; /* CPU topology */
@@ -141,28 +113,28 @@
/*
* Device methods.
*/
-static device_method_t coredirector_methods[] = {
+static device_method_t intelhfi_methods[] = {
/* Device interface */
- DEVMETHOD(device_identify, coredirector_identify),
- DEVMETHOD(device_probe, coredirector_probe),
- DEVMETHOD(device_attach, coredirector_attach),
- DEVMETHOD(device_detach, coredirector_detach),
+ DEVMETHOD(device_identify, intelhfi_identify),
+ DEVMETHOD(device_probe, intelhfi_probe),
+ DEVMETHOD(device_attach, intelhfi_attach),
+ DEVMETHOD(device_detach, intelhfi_detach),
DEVMETHOD_END
};
-static driver_t coredirector_driver = {
- COREDIRECTOR_NAME,
- coredirector_methods,
- sizeof(struct coredirector_softc),
+static driver_t intelhfi_driver = {
+ INTELHFI_NAME,
+ intelhfi_methods,
+ sizeof(struct intelhfi_softc),
};
-DRIVER_MODULE(coredirector, cpu, coredirector_driver, NULL, NULL);
+DRIVER_MODULE(intelhfi, cpu, intelhfi_driver, NULL, NULL);
-static MALLOC_DEFINE(M_COREHFI, COREDIRECTOR_NAME, "Buffers for coredirector driver");
+static MALLOC_DEFINE(M_INTELHFI, INTELHFI_NAME, "Buffers for intelhfi driver");
static void
-coredirector_msr_setflag(uint64_t addr, int cpu, uint64_t flag)
+intelhfi_msr_setflag(uint64_t addr, int cpu, uint64_t flag)
{
uint64_t msr;
@@ -173,10 +145,10 @@
}
static void
-coredirector_get_hwtable(struct coredirector_instance *inst)
+intelhfi_get_hwtable(struct intelhfi_instance *inst)
{
uint64_t msr_status;
-#if defined(CPUGRP_SCORE) && defined(SMP) && defined(SCHED_ULE)
+#if defined(HMP) && defined(SMP) && defined(SCHED_ULE)
int grp;
uint8_t *entry;
struct cpu_group *cg;
@@ -188,7 +160,7 @@
/* Check HFI/ITD update status */
msr_status = rdmsr(MSR_IA32_PKG_THERM_STATUS);
if (msr_status & IA32_PKG_THERM_STATUS_HFI_UPDATED) {
- DPRINTF("[DEBUG] HWtable UPDATED : status= %lx\n", msr_status );
+ DPRINTF(inst->dev, "[DEBUG] HWtable UPDATED : status= %lx\n", msr_status );
/* Check HFI/ITD update's timestamp */
if (*(inst->cache.timestamp) != *(inst->hwtable.timestamp)) {
@@ -203,7 +175,7 @@
wrmsr(MSR_IA32_PKG_THERM_STATUS, msr_status);
/* Set Perf./Eff. valut to cpu_group structure */
-#if defined(CPUGRP_SCORE) && defined(SMP) && defined(SCHED_ULE)
+#if defined(HMP) && defined(SMP) && defined(SCHED_ULE)
entry = (uint8_t *)inst->cache.ptr + inst->hdrsize;
for(grp=0, cg=cpu_top->cg_child; grp<inst->cpugroups; grp++, cg++, entry+=inst->entrysize)
memcpy(cg->cg_score, entry, inst->entrysize);
@@ -214,19 +186,19 @@
}
static void
-coredirector_interrupt(int cpu, void *value)
+intelhfi_interrupt(int cpu, void *value)
{
- coredirector_get_hwtable((struct coredirector_instance *)value);
+ intelhfi_get_hwtable((struct intelhfi_instance *)value);
}
static void
-coredirector_identify(driver_t *driver, device_t parent)
+intelhfi_identify(driver_t *driver, device_t parent)
{
device_t child;
u_int regs[4];
/* Check exist this driver */
- if (device_find_child(parent, COREDIRECTOR_NAME, -1) != NULL)
+ if (device_find_child(parent, INTELHFI_NAME, -1) != NULL)
return;
/* Check kernel build option with SMP & SCHED_ULE */
@@ -244,19 +216,19 @@
return;
/* Regist driver */
- child = device_add_child(parent, COREDIRECTOR_NAME, device_get_unit(parent));
+ child = device_add_child(parent, INTELHFI_NAME, device_get_unit(parent));
if (child == NULL)
- device_printf(parent, "Failure add coredirector driver\n");
+ device_printf(parent, "Failure add intelhfi driver\n");
return;
}
static int
-coredirector_probe(device_t dev)
+intelhfi_probe(device_t dev)
{
u_int regs[4];
- if (resource_disabled(COREDIRECTOR_NAME, 0))
+ if (resource_disabled(INTELHFI_NAME, 0))
return (ENXIO);
/* Check Intel Hardware Feedback & Thread Director feature */
@@ -279,10 +251,10 @@
}
static void
-coredirector_set_instance(struct coredirector_softc *sc)
+intelhfi_set_instance(struct intelhfi_softc *sc)
{
- struct coredirector_softc *scbsp;
- struct coredirector_instance *inst;
+ struct intelhfi_softc *scbsp;
+ struct intelhfi_instance *inst;
device_t *devchild;
int childs, cnt;
@@ -290,7 +262,7 @@
return;
scbsp = NULL;
- devclass_get_devices(devclass_find(COREDIRECTOR_NAME), &devchild, &childs);
+ devclass_get_devices(devclass_find(INTELHFI_NAME), &devchild, &childs);
for(cnt=0; cnt<childs && scbsp==NULL; cnt++) {
if(device_get_unit(*(devchild + cnt)) == 0)
scbsp = device_get_softc(*(devchild + cnt));
@@ -311,21 +283,21 @@
}
static int
-coredirector_attach_notbsp(device_t dev)
+intelhfi_attach_notbsp(device_t dev)
{
- struct coredirector_softc *sc = device_get_softc(dev);
+ struct intelhfi_softc *sc = device_get_softc(dev);
- coredirector_set_instance(sc);
+ intelhfi_set_instance(sc);
return (0);
}
static int
-coredirector_attach(device_t dev)
+intelhfi_attach(device_t dev)
{
int ret = 0;
- struct coredirector_softc *sc = device_get_softc(dev);
- struct coredirector_instance *inst;
+ struct intelhfi_softc *sc = device_get_softc(dev);
+ struct intelhfi_instance *inst;
u_int regs[4];
uint64_t msrval;
uint64_t capabilities;
@@ -353,7 +325,7 @@
/* Check & Get ITD capabilites (CP) */
capabilities = 2;
if (regs[0] & CPUTPM1_THREAD_DIRECTOR) {
- capabilities = BITSCOUNT(regs[3] & CPUID_TD_CAPABLITIES);
+ capabilities = __builtin_popcount(regs[3] & CPUID_TD_CAPABLITIES);
if (capabilities != 2) {
device_printf(dev, "Not support other than 2 capablities. - disable HFI/ITD.\n");
@@ -366,7 +338,7 @@
if (regs[0] & CPUTPM1_THREAD_DIRECTOR) {
classes = CPUID_LEAF6_ECX_CLASSES(regs[2]);
-#if defined(CPUGRP_SCORE)
+#if defined(HMP)
if (classes > CG_SCORE_CLASS_MAX) {
device_printf(dev, "Not support more than %d capablities. - disable HFI/ITD.\n",
CG_SCORE_CLASS_MAX);
@@ -382,22 +354,25 @@
/* Enable Intel ThreadDirector features for each Core */
if (regs[0] & CPUTPM1_THREAD_DIRECTOR)
- coredirector_msr_setflag(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, device_get_unit(dev), 1ULL);
+ intelhfi_msr_setflag(MSR_IA32_HW_FEEDBACK_THREAD_CONFIG, device_get_unit(dev), 1ULL);
/* Attach for not Bootstrap Processor */
if (device_get_unit(dev) != 0) {
- coredirector_attach_notbsp(dev);
+ intelhfi_attach_notbsp(dev);
return (0);
}
/* Alloc driver instance sturcture */
- inst = (struct coredirector_instance *)malloc(sizeof(struct coredirector_instance),
- M_COREHFI, M_NOWAIT | M_ZERO);
+ inst = (struct intelhfi_instance *)malloc(sizeof(struct intelhfi_instance),
+ M_INTELHFI, M_NOWAIT | M_ZERO);
if (inst == NULL) {
device_printf(dev, "Not enough memory for instance structure. - disable HFI/ITD.\n");
return (ENOMEM);
}
+ /* Set device */
+ inst->dev = dev;
+
/* Set Intel Hardware Feedback & Thread Director feature flags */
if (regs[0] & CPUTPM1_THREAD_DIRECTOR)
inst->flags.thdirector = 1;
@@ -423,7 +398,7 @@
/* Alloc Cache page */
inst->allocsize = (CPUID_LEAF6_EDX_TBLPAGES(regs[3]) + 1) * PAGE_SIZE;
- inst->cache.ptr = malloc(inst->allocsize, M_COREHFI, M_NOWAIT | M_ZERO);
+ inst->cache.ptr = malloc(inst->allocsize, M_INTELHFI, M_NOWAIT | M_ZERO);
if (inst->cache.ptr == NULL) {
device_printf(dev, "Not enough memory for local table cache. - disable HFI/ITD.\n");
ret = ENOMEM;
@@ -431,8 +406,8 @@
}
/* Init. spin-lock structure */
- mtx_init(&inst->hwtbl_lock, "coredirector HWtable lock", NULL, MTX_SPIN);
- mtx_init(&inst->intr_lock, "coredirector Interrupt lock", NULL, MTX_SPIN);
+ mtx_init(&inst->hwtbl_lock, "intelhfi HWtable lock", NULL, MTX_SPIN);
+ mtx_init(&inst->intr_lock, "intelhfi Interrupt lock", NULL, MTX_SPIN);
/* Set Hardware feedback interface table */
msrval = rdmsr(MSR_IA32_HW_FEEDBACK_PTR);
@@ -477,7 +452,7 @@
memcpy(inst->cache.ptr, inst->hwtable.ptr, inst->allocsize);
/* Enable Local APIC thermal interrupt handle */
- lapic_enable_thermal(coredirector_interrupt, (void *)inst);
+ lapic_enable_thermal(intelhfi_interrupt, (void *)inst);
/* Set instance for softc structure */
sc->inst = inst;
@@ -489,7 +464,7 @@
/* Set sysctl interface */
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev), SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
OID_AUTO, "hwtable", CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE,
- dev, sizeof(dev), coredirector_dumptable_sysctl, "A", "Printout HFI/ITD HW table.");
+ dev, sizeof(dev), intelhfi_dumptable_sysctl, "A", "Printout HFI/ITD HW table.");
return (0);
@@ -499,12 +474,12 @@
attach_err1:
if (inst->cache.ptr != NULL) {
- free(inst->cache.ptr, M_COREHFI);
+ free(inst->cache.ptr, M_INTELHFI);
inst->cache.ptr = NULL;
}
if (sc->inst != NULL) {
- free(sc->inst, M_COREHFI);
+ free(sc->inst, M_INTELHFI);
sc->inst = NULL;
}
@@ -512,12 +487,12 @@
}
static int
-coredirector_detach(device_t dev)
+intelhfi_detach(device_t dev)
{
int ref;
uint64_t msr_intr;
- struct coredirector_softc *sc = device_get_softc(dev);
- struct coredirector_instance *inst;
+ struct intelhfi_softc *sc = device_get_softc(dev);
+ struct intelhfi_instance *inst;
inst = sc->inst;
if (inst == NULL)
@@ -566,23 +541,23 @@
/* Free cache area */
if (inst->cache.ptr != NULL) {
- free(inst->cache.ptr, M_COREHFI);
+ free(inst->cache.ptr, M_INTELHFI);
inst->cache.ptr = NULL;
}
/* Free Instance */
- free(sc->inst, M_COREHFI);
+ free(sc->inst, M_INTELHFI);
sc->inst = NULL;
return (0);
}
static int
-coredirector_dumptable_sysctl(SYSCTL_HANDLER_ARGS)
+intelhfi_dumptable_sysctl(SYSCTL_HANDLER_ARGS)
{
device_t dev;
- struct coredirector_softc *sc;
- struct coredirector_instance *inst;
+ struct intelhfi_softc *sc;
+ struct intelhfi_instance *inst;
struct sbuf *buf;
uint8_t *entry;
int grp, cl, err;
@@ -594,7 +569,7 @@
sc = device_get_softc(dev);
inst = sc->inst;
- KASSERT(inst != NULL, ("Not initialized coredirector instance."));
+ KASSERT(inst != NULL, ("Not initialized intelhfi instance."));
buf = sbuf_new_for_sysctl(NULL, NULL, 512, req);
if (buf == NULL)
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -86,7 +86,7 @@
${_cfi} \
${_chromebook_platform} \
${_ciss} \
- ${_coredirector} \
+ ${_intelhfi} \
${_coretemp} \
${_cpsw} \
${_cpuctl} \
@@ -802,7 +802,7 @@
_chvgpio= chvgpio
_ciss= ciss
_chromebook_platform= chromebook_platform
-_coredirector= coredirector
+_intelhfi= intelhfi
_coretemp= coretemp
.if ${MK_SOURCELESS_HOST} != "no" && empty(KCSAN_ENABLED)
_hpt27xx= hpt27xx
diff --git a/sys/modules/coredirector/Makefile b/sys/modules/coredirector/Makefile
--- a/sys/modules/coredirector/Makefile
+++ b/sys/modules/coredirector/Makefile
@@ -1,7 +1,7 @@
-.PATH: ${SRCTOP}/sys/dev/coredirector
+.PATH: ${SRCTOP}/sys/dev/intelhfi
-KMOD= coredirector
-SRCS= coredirector.c bus_if.h device_if.h
+KMOD= intelhfi
+SRCS= intelhfi.c bus_if.h device_if.h opt_sched.h
.include <bsd.kmod.mk>
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, May 15, 4:49 AM (34 m, 47 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33073379
Default Alt Text
D44456.id171141.diff (15 KB)
Attached To
Mode
D44456: intelhfi - Intel TD/HFI driver - Part4: Add intelhfi driver's source-code & Makefile.
Attached
Detach File
Event Timeline
Log In to Comment