📄 xpc_partition.c
字号:
} nasid_mask = xpc_IPI_receive(&act_amos[word]); if (nasid_mask == 0) { /* no IRQs from nasids in this variable */ continue; } dev_dbg(xpc_part, "AMO[%d] gave back 0x%lx\n", word, nasid_mask); /* * If this nasid has been added to the machine since * our partition was reset, this will retain the * remote nasid in our reserved pages machine mask. * This is used in the event of module reload. */ xpc_mach_nasids[word] |= nasid_mask; /* locate the nasid(s) which sent interrupts */ for (bit = 0; bit < (8 * sizeof(u64)); bit++) { if (nasid_mask & (1UL << bit)) { n_IRQs_detected++; nasid = XPC_NASID_FROM_W_B(word, bit); dev_dbg(xpc_part, "interrupt from nasid %ld\n", nasid); xpc_identify_act_IRQ_req(nasid); } } } return n_IRQs_detected;}/* * See if the other side has responded to a partition disengage request * from us. */intxpc_partition_disengaged(struct xpc_partition *part){ partid_t partid = XPC_PARTID(part); int disengaged; disengaged = (xpc_partition_engaged(1UL << partid) == 0); if (part->disengage_request_timeout) { if (!disengaged) { if (jiffies < part->disengage_request_timeout) { /* timelimit hasn't been reached yet */ return 0; } /* * Other side hasn't responded to our disengage * request in a timely fashion, so assume it's dead. */ dev_info(xpc_part, "disengage from remote partition %d " "timed out\n", partid); xpc_disengage_request_timedout = 1; xpc_clear_partition_engaged(1UL << partid); disengaged = 1; } part->disengage_request_timeout = 0; /* cancel the timer function, provided it's not us */ if (!in_interrupt()) { del_singleshot_timer_sync(&part-> disengage_request_timer); } DBUG_ON(part->act_state != XPC_P_DEACTIVATING && part->act_state != XPC_P_INACTIVE); if (part->act_state != XPC_P_INACTIVE) { xpc_wakeup_channel_mgr(part); } if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { xpc_cancel_partition_disengage_request(part); } } return disengaged;}/* * Mark specified partition as active. */enum xpc_retvalxpc_mark_partition_active(struct xpc_partition *part){ unsigned long irq_flags; enum xpc_retval ret; dev_dbg(xpc_part, "setting partition %d to ACTIVE\n", XPC_PARTID(part)); spin_lock_irqsave(&part->act_lock, irq_flags); if (part->act_state == XPC_P_ACTIVATING) { part->act_state = XPC_P_ACTIVE; ret = xpcSuccess; } else { DBUG_ON(part->reason == xpcSuccess); ret = part->reason; } spin_unlock_irqrestore(&part->act_lock, irq_flags); return ret;}/* * Notify XPC that the partition is down. */voidxpc_deactivate_partition(const int line, struct xpc_partition *part, enum xpc_retval reason){ unsigned long irq_flags; spin_lock_irqsave(&part->act_lock, irq_flags); if (part->act_state == XPC_P_INACTIVE) { XPC_SET_REASON(part, reason, line); spin_unlock_irqrestore(&part->act_lock, irq_flags); if (reason == xpcReactivating) { /* we interrupt ourselves to reactivate partition */ xpc_IPI_send_reactivate(part); } return; } if (part->act_state == XPC_P_DEACTIVATING) { if ((part->reason == xpcUnloading && reason != xpcUnloading) || reason == xpcReactivating) { XPC_SET_REASON(part, reason, line); } spin_unlock_irqrestore(&part->act_lock, irq_flags); return; } part->act_state = XPC_P_DEACTIVATING; XPC_SET_REASON(part, reason, line); spin_unlock_irqrestore(&part->act_lock, irq_flags); if (XPC_SUPPORTS_DISENGAGE_REQUEST(part->remote_vars_version)) { xpc_request_partition_disengage(part); xpc_IPI_send_disengage(part); /* set a timelimit on the disengage request */ part->disengage_request_timeout = jiffies + (xpc_disengage_request_timelimit * HZ); part->disengage_request_timer.expires = part->disengage_request_timeout; add_timer(&part->disengage_request_timer); } dev_dbg(xpc_part, "bringing partition %d down, reason = %d\n", XPC_PARTID(part), reason); xpc_partition_going_down(part, reason);}/* * Mark specified partition as inactive. */voidxpc_mark_partition_inactive(struct xpc_partition *part){ unsigned long irq_flags; dev_dbg(xpc_part, "setting partition %d to INACTIVE\n", XPC_PARTID(part)); spin_lock_irqsave(&part->act_lock, irq_flags); part->act_state = XPC_P_INACTIVE; spin_unlock_irqrestore(&part->act_lock, irq_flags); part->remote_rp_pa = 0;}/* * SAL has provided a partition and machine mask. The partition mask * contains a bit for each even nasid in our partition. The machine * mask contains a bit for each even nasid in the entire machine. * * Using those two bit arrays, we can determine which nasids are * known in the machine. Each should also have a reserved page * initialized if they are available for partitioning. */voidxpc_discovery(void){ void *remote_rp_base; struct xpc_rsvd_page *remote_rp; struct xpc_vars *remote_vars; u64 remote_rp_pa; u64 remote_vars_pa; int region; int region_size; int max_regions; int nasid; struct xpc_rsvd_page *rp; partid_t partid; struct xpc_partition *part; u64 *discovered_nasids; enum xpc_retval ret; remote_rp = xpc_kmalloc_cacheline_aligned(XPC_RP_HEADER_SIZE + xp_nasid_mask_bytes, GFP_KERNEL, &remote_rp_base); if (remote_rp == NULL) { return; } remote_vars = (struct xpc_vars *) remote_rp; discovered_nasids = kzalloc(sizeof(u64) * xp_nasid_mask_words, GFP_KERNEL); if (discovered_nasids == NULL) { kfree(remote_rp_base); return; } rp = (struct xpc_rsvd_page *) xpc_rsvd_page; /* * The term 'region' in this context refers to the minimum number of * nodes that can comprise an access protection grouping. The access * protection is in regards to memory, IOI and IPI. */ max_regions = 64; region_size = sn_region_size; switch (region_size) { case 128: max_regions *= 2; case 64: max_regions *= 2; case 32: max_regions *= 2; region_size = 16; DBUG_ON(!is_shub2()); } for (region = 0; region < max_regions; region++) { if ((volatile int) xpc_exiting) { break; } dev_dbg(xpc_part, "searching region %d\n", region); for (nasid = (region * region_size * 2); nasid < ((region + 1) * region_size * 2); nasid += 2) { if ((volatile int) xpc_exiting) { break; } dev_dbg(xpc_part, "checking nasid %d\n", nasid); if (XPC_NASID_IN_ARRAY(nasid, xpc_part_nasids)) { dev_dbg(xpc_part, "PROM indicates Nasid %d is " "part of the local partition; skipping " "region\n", nasid); break; } if (!(XPC_NASID_IN_ARRAY(nasid, xpc_mach_nasids))) { dev_dbg(xpc_part, "PROM indicates Nasid %d was " "not on Numa-Link network at reset\n", nasid); continue; } if (XPC_NASID_IN_ARRAY(nasid, discovered_nasids)) { dev_dbg(xpc_part, "Nasid %d is part of a " "partition which was previously " "discovered\n", nasid); continue; } /* pull over the reserved page structure */ ret = xpc_get_remote_rp(nasid, discovered_nasids, remote_rp, &remote_rp_pa); if (ret != xpcSuccess) { dev_dbg(xpc_part, "unable to get reserved page " "from nasid %d, reason=%d\n", nasid, ret); if (ret == xpcLocalPartid) { break; } continue; } remote_vars_pa = remote_rp->vars_pa; partid = remote_rp->partid; part = &xpc_partitions[partid]; /* pull over the cross partition variables */ ret = xpc_get_remote_vars(remote_vars_pa, remote_vars); if (ret != xpcSuccess) { dev_dbg(xpc_part, "unable to get XPC variables " "from nasid %d, reason=%d\n", nasid, ret); XPC_DEACTIVATE_PARTITION(part, ret); continue; } if (part->act_state != XPC_P_INACTIVE) { dev_dbg(xpc_part, "partition %d on nasid %d is " "already activating\n", partid, nasid); break; } /* * Register the remote partition's AMOs with SAL so it * can handle and cleanup errors within that address * range should the remote partition go down. We don't * unregister this range because it is difficult to * tell when outstanding writes to the remote partition * are finished and thus when it is thus safe to * unregister. This should not result in wasted space * in the SAL xp_addr_region table because we should * get the same page for remote_act_amos_pa after * module reloads and system reboots. */ if (sn_register_xp_addr_region( remote_vars->amos_page_pa, PAGE_SIZE, 1) < 0) { dev_dbg(xpc_part, "partition %d failed to " "register xp_addr region 0x%016lx\n", partid, remote_vars->amos_page_pa); XPC_SET_REASON(part, xpcPhysAddrRegFailed, __LINE__); break; } /* * The remote nasid is valid and available. * Send an interrupt to that nasid to notify * it that we are ready to begin activation. */ dev_dbg(xpc_part, "sending an interrupt to AMO 0x%lx, " "nasid %d, phys_cpuid 0x%x\n", remote_vars->amos_page_pa, remote_vars->act_nasid, remote_vars->act_phys_cpuid); if (XPC_SUPPORTS_DISENGAGE_REQUEST(remote_vars-> version)) { part->remote_amos_page_pa = remote_vars->amos_page_pa; xpc_mark_partition_disengaged(part); xpc_cancel_partition_disengage_request(part); } xpc_IPI_send_activate(remote_vars); } } kfree(discovered_nasids); kfree(remote_rp_base);}/* * Given a partid, get the nasids owned by that partition from the * remote partition's reserved page. */enum xpc_retvalxpc_initiate_partid_to_nasids(partid_t partid, void *nasid_mask){ struct xpc_partition *part; u64 part_nasid_pa; int bte_res; part = &xpc_partitions[partid]; if (part->remote_rp_pa == 0) { return xpcPartitionDown; } memset(nasid_mask, 0, XP_NASID_MASK_BYTES); part_nasid_pa = (u64) XPC_RP_PART_NASIDS(part->remote_rp_pa); bte_res = xp_bte_copy(part_nasid_pa, (u64) nasid_mask, xp_nasid_mask_bytes, (BTE_NOTIFY | BTE_WACQUIRE), NULL); return xpc_map_bte_errors(bte_res);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -