mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
amdiommu: changes for stable/14 merge
to accomodate lack of ilog2() on stable/14. Done as separate commit to ease future cherry-picks. Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
fa67872217
commit
83217f087b
6 changed files with 16 additions and 6 deletions
|
|
@ -320,7 +320,7 @@ amdiommu_init_cmd(struct amdiommu_unit *unit)
|
|||
{
|
||||
uint64_t qi_sz, rv;
|
||||
|
||||
unit->x86c.qi_buf_maxsz = ilog2(AMDIOMMU_CMDBUF_MAX / PAGE_SIZE);
|
||||
unit->x86c.qi_buf_maxsz = ilog2_local(AMDIOMMU_CMDBUF_MAX / PAGE_SIZE);
|
||||
unit->x86c.qi_cmd_sz = AMDIOMMU_CMD_SZ;
|
||||
iommu_qi_common_init(AMD2IOMMU(unit), amdiommu_qi_task);
|
||||
get_x86_iommu()->qi_ensure = amdiommu_cmd_ensure;
|
||||
|
|
@ -334,7 +334,7 @@ amdiommu_init_cmd(struct amdiommu_unit *unit)
|
|||
* See the description of the ComLen encoding for Command
|
||||
* buffer Base Address Register.
|
||||
*/
|
||||
qi_sz = ilog2(unit->x86c.inv_queue_size / PAGE_SIZE) + 8;
|
||||
qi_sz = ilog2_local(unit->x86c.inv_queue_size / PAGE_SIZE) + 8;
|
||||
rv |= qi_sz << AMDIOMMU_CMDBUF_BASE_SZSHIFT;
|
||||
|
||||
AMDIOMMU_LOCK(unit);
|
||||
|
|
|
|||
|
|
@ -462,7 +462,7 @@ dte_entry_init_one(struct amdiommu_dte *dtep, struct amdiommu_ctx *ctx,
|
|||
if (unit->irte_enabled) {
|
||||
dtep->iv = 1;
|
||||
dtep->i = 0;
|
||||
dtep->inttablen = ilog2(unit->irte_nentries);
|
||||
dtep->inttablen = ilog2_local(unit->irte_nentries);
|
||||
dtep->intrroot = pmap_kextract(unit->irte_x2apic ?
|
||||
(vm_offset_t)ctx->irtx2 :
|
||||
(vm_offset_t)ctx->irtb) >> 6;
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ amdiommu_create_dev_tbl(struct amdiommu_unit *sc)
|
|||
sc->devtbl_obj->domain.dr_policy = DOMAINSET_PREF(dom);
|
||||
|
||||
sc->hw_ctrl &= ~AMDIOMMU_CTRL_DEVTABSEG_MASK;
|
||||
sc->hw_ctrl |= (uint64_t)segnum_log << ilog2(AMDIOMMU_CTRL_DEVTABSEG_2);
|
||||
sc->hw_ctrl |= (uint64_t)segnum_log << 34; /* ilog2(AMDIOMMU_CTRL_DEVTABSEG_2) */
|
||||
sc->hw_ctrl |= AMDIOMMU_CTRL_COHERENT;
|
||||
amdiommu_write8(sc, AMDIOMMU_CTRL, sc->hw_ctrl);
|
||||
|
||||
|
|
|
|||
|
|
@ -285,7 +285,7 @@ amdiommu_init_event(struct amdiommu_unit *unit)
|
|||
"amdiommu%d event taskq", unit->iommu.unit);
|
||||
|
||||
base_reg = pmap_kextract((vm_offset_t)unit->event_log) |
|
||||
(((uint64_t)0x8 + ilog2(unit->event_log_size /
|
||||
(((uint64_t)0x8 + ilog2_local(unit->event_log_size /
|
||||
AMDIOMMU_EVNTLOG_MIN)) << AMDIOMMU_EVNTLOG_BASE_SZSHIFT);
|
||||
AMDIOMMU_LOCK(unit);
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -374,7 +374,7 @@ amdiommu_init_irt(struct amdiommu_unit *unit)
|
|||
|
||||
nentries = 32;
|
||||
TUNABLE_INT_FETCH("hw.iommu.amd.ir_num", &nentries);
|
||||
nentries = roundup_pow_of_two(nentries);
|
||||
nentries = roundup_pow_of_two_local(nentries);
|
||||
if (nentries < 1)
|
||||
nentries = 1;
|
||||
if (nentries > 2048)
|
||||
|
|
|
|||
|
|
@ -200,4 +200,14 @@ void iommu_db_print_ctx(struct iommu_ctx *ctx);
|
|||
void iommu_db_domain_print_contexts(struct iommu_domain *iodom);
|
||||
void iommu_db_domain_print_mappings(struct iommu_domain *iodom);
|
||||
|
||||
static __inline __pure2 int
|
||||
ilog2_local(int n)
|
||||
{
|
||||
KASSERT(n != 0, ("ilog argument must be nonzero"));
|
||||
return (8 * sizeof(n) - 1 - __builtin_clz((u_int)n));
|
||||
}
|
||||
|
||||
#define order_base_2_local(n) ilog2_local(2*(n)-1)
|
||||
#define roundup_pow_of_two_local(n) ((__typeof(n))1 << order_base_2_local(n))
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue