/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* memory support routines for sbd.
*/
#include <sys/dditypes.h>
#include <sys/ddi_impldefs.h>
#include <sys/sysmacros.h>
#include <sys/machsystm.h>
#include <sys/spitregs.h>
#include <sys/cpu_module.h>
#include <sys/memlist_impl.h>
#include <sys/mem_cage.h>
#include <sys/platform_module.h>
#include <vm/seg_kmem.h>
sbderror_t *ep);
*ep);
struct memlist *
{
static fn_t f = "sbd_get_memlist";
PR_MEM("%s...\n", f);
/*
* Return cached memlist, if present.
* This memlist will be present following an
* unconfigure (a.k.a: detach) of this memunit.
* It should only be used in the case were a configure
* is bringing this memunit back in without going
* through the disconnect and connect states.
*/
PR_MEM("%s: found cached memlist\n", f);
} else {
/* attempt to construct a memlist using phys_install */
/*
* NOTE: this code block assumes only one memunit per
* board. This is currently safe because the function
* sbd_init_mem_devlist() forces this assumption to be
* valid.
*/
/* round down to slice base address */
/* build mlist from the lower layer */
PR_MEM("sbd:%s: failed to get memlist for "
"dip (0x%p) ecode %d errno %d", f,
return (NULL);
}
}
PR_MEM("%s: memlist for mem-unit (%d.%d), dip 0x%p:\n",
return (mlist);
}
int
{
int err_flag = 0;
int d, i;
static fn_t f = "sbd_pre_attach_mem";
PR_MEM("%s...\n", f);
SBD_SET_ERR(ep, 0);
for (d = 0; d < devnum; d++) {
int unit;
int rv;
/* sbd_get_devlist will not devlist element w/ dip of 0 */
if (unit == -1) {
continue;
else {
err_flag = 1;
break;
}
}
PR_MEM("sbd: OS attach mem-unit (%d.%d)\n",
switch (state) {
case SBD_STATE_UNCONFIGURED:
/* use memlist cached by sbd_post_detach_mem_unit */
PR_MEM("%s: recovering from UNCONFIG"
" mem-unit (%d.%d)\n",
PR_MEM("%s: re-configure cached memlist:\n", f);
/*
* kphysm del handle should have been freed
*/
== 0);
} else {
continue;
else {
err_flag = 1;
PR_MEM("%s: mem-unit (%d.%d)"
" unusable\n",
break;
}
}
/*FALLTHROUGH*/
case SBD_STATE_CONNECTED:
PR_MEM("%s: reprogramming mem hardware (board %d)\n",
for (i = 0; i < SBD_NUM_MC_PER_BOARD; i++) {
continue;
PR_MEM("%s: enabling mc 0x%p on board %d\n",
if (rv < 0) {
"%s: failed to program mem ctrlr %p on "
err_flag = 1;
}
}
break;
default:
"%s: unexpected state (%d) for mem-unit "
if (SBD_GET_ERR(ep) == 0) {
err_flag = 1;
}
break;
}
/* exit for loop if error encountered */
if (err_flag) {
break;
}
}
return (err_flag ? -1 : 0);
}
int
{
int d;
static fn_t f = "sbd_post_attach_mem";
PR_MEM("%s...\n", f);
for (d = 0; d < devnum; d++) {
int unit;
/* sbd_get_devlist will not devlist element w/ dip of 0 */
if (unit == -1) {
continue;
else {
break;
}
}
"%s: no memlist for mem-unit (%d.%d)",
f,
if (SBD_GET_ERR(ep) == 0) {
}
continue;
}
/*
* Verify the memory really did successfully attach
* by checking for its existence in phys_install.
*/
"%s: mem-unit (%d.%d) memlist not in"
if (SBD_GET_ERR(ep) == 0) {
}
continue;
}
}
/*
* Destroy cached memlist, if any.
* There will be a cached memlist in sbm_mlist if
* this board is being configured directly after
* an unconfigure.
* To support this transition, sbd_post_detach_mem
* left a copy of the last known memlist in sbm_mlist.
* This memlist could differ from any derived from
* hardware if while this memunit was last configured
* the system detected and deleted bad pages from
* phys_install. The location of those bad pages
* will be reflected in the cached memlist.
*/
}
}
return (0);
}
int
{
int d;
int unit;
for (d = 0; d < devnum; d++) {
/* sbd_get_devlist will not devlist element w/ dip of 0 */
if (unit == -1) {
continue;
else {
return (-1);
}
}
/* sanity check */
PR_MEM("sbd: OS detach mem-unit (%d.%d)\n",
}
return (0);
}
int
{
int d, rv;
static fn_t f = "sbd_post_detach_mem";
PR_MEM("%s...\n", f);
rv = 0;
for (d = 0; d < devnum; d++) {
int unit;
/* sbd_get_devlist will not devlist element w/ dip of 0 */
rv = -1;
}
if (unit == -1) {
continue;
else {
if (rv != -1)
break;
}
}
if (rv == -1) {
} else {
/* this is no target unit */
}
rv = -1;
}
return (rv);
}
static void
{
static fn_t f = "sbd_add_memory_spans";
PR_MEM("%s...", f);
#ifdef DEBUG
PR_MEM("%s:WARNING: memlist intersects with phys_install\n", f);
}
#endif
int rv;
" unexpected kphysm_add_memory_dynamic"
" return value %d;"
" basepfn=0x%lx, npages=%ld\n",
continue;
}
if (rv != 0)
continue;
}
}
/* hack for test scripts. *** remove before code finalized *** */
int sbd_last_target;
static int
{
int rv;
static fn_t f = "sbd_post_detach_mem_unit";
PR_MEM("%s...\n", f);
"sbd:%s: no alignment for mem-unit (%d.%d)",
return (-1);
}
/* s_mp->sbm_del_mlist could be NULL, meaning no deleted spans */
PR_MEM("%s: brd %d: deleted memlist (EMPTY maybe okay):\n",
/* sanity check */
PR_MEM("%s: target brd %d: deleted memlist:\n",
} else {
/* this is no target unit */
}
/*
* Verify the memory really did successfully detach
* by checking for its non-existence in phys_install.
*/
rv = 0;
}
}
if (rv) {
"%s: %smem-unit (%d.%d) memlist still in phys_install",
f,
return (-1);
}
/*
* We had to swap mem-units, so update
* memlists accordingly with new base
* addresses.
*/
}
/*
* There is no need to explicitly rename the target delete
* memlist, because sbm_del_mlist and sbm_mlist always
*/
PR_MEM("%s: renamed target memlist and delete memlist", f);
}
PR_MEM("%s: renamed source memlist", f);
#ifdef DEBUG
/*
* Renaming s_mp->sbm_del_mlist is not necessary. This
* list is not used beyond this point, and in fact, is
* disposed of at the end of this function.
*/
}
PR_MEM("%s: renamed source delete memlist", f);
#endif
int mlret;
/*
* We had to perform a copy-rename from a
* small memory node to a big memory node.
* Need to add back the remaining memory on
* the big board that wasn't used by that
* from the small board during the copy.
* Subtract out the portion of the target memory
* node that was taken over by the source memory
* node.
*/
PR_MEM("%s: adding back remaining portion"
" of mem-unit (%d.%d), memlist:\n",
}
}
/* delete target's entire address space */
/* delete source board's vacant address space */
} else {
/* delete board's entire address space */
}
#ifdef LINT
#endif
return (0);
}
static void
{
/* clean up target mem unit */
/*
* sbm_del_mlist and sbm_mlist point at the same list
* We only need to delete one and then set both pointers
* to NULL
*/
/*
* work that was done in sbd_release_mem_done.
*/
/*
* If error don't set the target to configured
*/
if (SBD_GET_ERR(ep) == 0) {
}
/* hack for test scripts. *** remove before code finalized *** */
}
/*
* clean up (source) board's mem unit structure.
* NOTE: sbm_mlist is retained. It is referred to as the
* cached memlist. The cached memlist is used to re-attach
* (configure back in) this memunit from the unconfigured
* state.
*/
/*
* Don't want to call memlist_delete for sbm_del_mlist,
* since that list points to the sbm_list
*/
}
}
/*
* Successful return from this function will have the memory
* handle in sbp->sb_dev[..mem-unit...].sbm_memhandle allocated
* and waiting. This routine's job is to select the memory that
* actually has to be released (detached) which may not necessarily
* be the same memory node that came in in devlist[],
* i.e. a copy-rename is needed.
*/
int
{
extern int kcage_on;
int d;
int err_flag = 0;
static fn_t f = "sbd_pre_release_mem";
PR_MEM("%s...\n", f);
if (kcage_on == 0) {
/*
* Can't Detach memory if Cage is OFF.
*/
return (-1);
}
for (d = 0; d < devnum; d++) {
int rv;
/* sbd_get_devlist will not devlist element w/ dip of 0 */
/*
* If all the mem unit is marked as failed then don't allow the
* operation
*/
err_flag = -1;
break;
}
/*
* if interleave is set to across boards fail the op
*/
if (mp->sbm_interleave) {
err_flag = -1;
break;
}
if (SBD_GET_ERR(lep) != 0) {
err_flag = -1;
break;
}
/*
* Board is currently involved in a delete
* memory operation. Can't detach this guy until
* that operation completes.
*/
"%s: ineligible mem-unit (%d.%d) for detach",
err_flag = -1;
break;
}
/*
* Check whether the detaching memory requires a
* copy-rename.
*/
"%s: unexpected kphysm_del_span_query"
" return value %d;"
" basepfn 0x%lx, npages 0x%lx,"
" mem-unit (%d.%d), dip 0x%p",
f,
rv,
mp->sbm_npages,
err_flag = -1;
break;
}
if (mq.nonrelocatable != 0) {
/* caller wasn't prompted for a suspend */
err_flag = 1;
break;
}
}
/* flags should be clean at this time */
}
PR_MEM("%s: no memlist found for board %d\n",
err_flag = -1;
break;
}
/* allocate a kphysm handle */
"%s: unexpected kphysm_del_gethandle"
" return value %d", f, rv);
err_flag = -1;
break;
}
if ((mq.nonrelocatable != 0) ||
/*
* Either the detaching memory node contains
* non-reloc memory or we failed to reserve the
* detaching memory node (which did _not_ have
* any non-reloc memory, i.e. some non-reloc mem
* got onboard).
*/
int rv;
/*
* We had no luck locating a target
* memory node to be the recipient of
* the non-reloc memory on the node
* we're trying to detach.
* Clean up be disposing the mem handle
* and the mem list.
*/
/*
* can do nothing but complain
* and hope helpful for debug
*/
" kphysm_del_release return"
" value %d",
f, rv);
}
/* make sure sbm_flags is clean */
"%s: no available target for "
"mem-unit (%d.%d)",
err_flag = -1;
break;
}
/*
* ml is not memlist_deleted here because
* it has been assigned to mp->sbm_mlist
* by sbd_select_mem_target.
*/
} else {
/* no target needed to detach this board */
}
#ifdef DEBUG
sbp = (sbd_board_t *)
" selected target board %d\n",
} else {
}
#endif
}
return (err_flag);
}
void
{
int rv;
static fn_t f = "sbd_release_mem_done";
/*
* This unit will be flagged with SBD_MFLAG_SOURCE, if it
* has a target unit.
*/
} else {
/* this is no target unit */
}
/* free delete handle */
/*
* can do nothing but complain
* and hope helpful for debug
*/
" return value %d", f, rv);
}
/*
* If an error was encountered during release, clean up
* the source (and target, if present) unit data.
*/
if (SBD_GET_ERR(ep) != 0) {
PR_MEM("%s: unit %d.%d: error %d noted\n",
SBD_GET_ERR(ep));
/* bail out */
return;
}
/*
* the kphysm delete operation that drained the source
* board also drained this target board. Since the source
* board drain is now known to have succeeded, we know this
* target board is drained too.
*/
/*
* NOTE: do not transition target's board state,
* even if the mem-unit was the last configure
* this mem-unit will transitioned back to
* the configured state. In the meantime, the
* board's must remain as is.
*/
}
/* if board(s) had deleted memory, verify it is gone */
rv = 0;
}
}
if (rv) {
"deleted memory still found in phys_install",
f,
return;
}
}
PR_MEM("%s: marking mem-unit (%d.%d) release DONE\n",
PR_MEM("%s: marking mem-unit (%d.%d) release DONE\n",
}
}
int
{
static fn_t f = "sbd_disconnect_mem";
PR_MEM("%s...\n", f);
}
return (0);
}
int
{
static fn_t f = "sbd_cancel_mem";
/* must cancel source board, not target board */
return (-1);
/* must always match the source board's state */
} else {
/* this is no target unit */
}
switch (state) {
case SBD_STATE_UNREFERENCED: /* state set by sbd_release_mem_done */
PR_MEM("%s: undoing target board %d memory delete\n",
}
PR_MEM("%s: undoing board %d memory delete\n",
}
/*FALLTHROUGH*/
case SBD_STATE_CONFIGURED:
/*
* we got here because of an error early in the release process
* Just leave the memory as is and report the error
*/
}
}
}
return (0);
default:
PR_MEM("%s: WARNING unexpected state (%d) for "
"mem-unit %d.%d\n",
f,
(int)state,
return (-1);
}
/*NOTREACHED*/
}
void
{
int i;
} else {
}
/*
* Check all the possible memory nodes on the board. If all of them
* have a failed status mark memory as failed. Otherwise mem is ok
*/
if (!sbp->sb_memaccess_ok) {
return;
}
for (i = 0; i < SBD_NUM_MC_PER_BOARD; i++) {
if (cur_mc_dip == NULL)
continue;
present_mcs |= (1 << i);
if (mc_cond == SBD_COND_FAILED) {
failed_mcs |= (1 << i);
}
}
if (failed_mcs == present_mcs) {
/*
* All mem nodes failed, therefore mark all mem
* as failed
*/
} else {
}
/*
* Any changes to this memory unit should be performed above
* this call to ensure the unit is fully initialized
* before transitioning to the new state.
*/
}
static void
{
static fn_t f = "sbd_init_mem_unit_data";
PR_MEM("%s...\n", f);
/* a little sanity checking */
/* get basepfn of mem unit */
" for mem-unit (%d.%d)",
f,
return;
}
/* attempt to get number of pages from PDA */
/* if didn't work, calculate using memlist */
if (mp->sbm_npages == 0) {
}
"sbd:%s: no alignment for mem-unit (%d.%d)",
return;
}
PR_MEM("%s: board %d (basepfn = 0x%lx, npgs = 0x%lx interleave %d)\n",
mp->sbm_npages,
mp->sbm_interleave);
}
static int
{
int err;
static fn_t f = "sbd_reserve_mem_spans";
PR_MEM("%s...\n", f);
/*
* Walk the supplied memlist scheduling each span for removal
* with kphysm_del_span. It is possible that a span may intersect
* an area occupied by the cage.
*/
" unexpected kphysm_del_span return value %d;"
" basepfn=0x%lx npages=%ld",
return (-1);
}
}
return (0);
}
/* debug counters */
int sbd_smt_realigned;
#ifdef DEBUG
#endif
/*
* Verify that there is no memory overlapping if copy-rename is
* done with the selected target board.
*
* Returns 0 if OK, -1 otherwise.
*/
static int
{
int mlret;
static fn_t f = "sbd_check_boundaries";
if (new_memlist == NULL) {
PR_MEM("%s: can't dup original memlist\n", f);
return (-1);
}
&new_memlist);
if (mlret != MEML_SPANOP_OK) {
goto check_done;
}
&new_memlist);
if (mlret != MEML_SPANOP_OK) {
goto check_done;
}
&new_memlist);
if (mlret != MEML_SPANOP_OK) {
goto check_done;
}
&new_memlist);
if (mlret != MEML_SPANOP_OK) {
}
if (mlret == MEML_SPANOP_OK)
return (0);
else
return (-1);
}
/*
* given source board.
* All boards in the system are examined and categorized in relation to
* their memory size versus the source board's memory size. Order of
* preference is:
* 1st: board has same memory size
* 2nd: board has larger memory size
* 3rd: board has smaller memory size
* 4th: board has smaller memory size, available memory will be reduced.
* Boards in category 3 and 4 will have their MC's reprogrammed to locate the
* span to which the MC responds to address span that appropriately covers
* the nonrelocatable span of the source board.
*/
static int
{
int n_units_per_set;
int idx;
int t_bd;
int t_unit;
int max_boards;
int rv;
static fn_t f = "sbd_select_mem_target";
PR_MEM("%s...\n", f);
"sbd:%s: no alignment for mem-unit (%d.%d)",
return (-1);
}
/*
* Make one pass through all memory units on all boards
* and categorize them with respect to the source board.
*/
/*
* The board structs are a contiguous array
* so we take advantage of that to find the
* correct board struct pointer for a given
* board number.
*/
/* source board can not be its own target */
continue;
/* this memory node must be attached */
continue;
/* source unit can not be its own target */
/* catch this in debug kernels */
ASSERT(0);
continue;
}
/*
* this memory node must not already be reserved
* by some other memory delete operation.
*/
continue;
/*
* categorize the memory node
* If this is a smaller memory node, create a
* temporary, edited copy of the source board's
* memlist containing only the span of the non-
* relocatable pages.
*/
preference = 0;
t_mp->sbm_slice_offset = 0;
preference = 1;
t_mp->sbm_slice_offset = 0;
} else {
/*
* We do not allow other options right now
*/
continue;
}
/* calculate index to start of preference set */
/* calculate offset to respective element */
}
}
/*
* NOTE: this would be a good place to sort each candidate
* set in to some desired order, e.g. memory size in ascending
* order. Without an additional sorting step here, the order
* within a set is ascending board number order.
*/
/* cleanup t_ml after previous pass */
}
/* get candidate target board mem unit */
continue;
/* get target board memlist */
" mem-unit %d, board %d",
f,
continue;
}
/* get appropriate source board memlist */
/*
* make a copy of the source board memlist
* then edit it to remove the spans that
* are outside the calculated span of
* [pfn..s_mq.last_nonrelocatable].
*/
PR_MEM("%s: memlist_dup failed\n", f);
/* TODO: should abort */
continue;
}
/* trim off lower portion */
if (excess > 0) {
int mlret;
&x_ml);
}
/*
* Since this candidate target board is smaller
* than the source board, s_mq must have been
* initialized in previous loop while processing
* this or some other candidate board.
* FIXME: this is weak.
*/
/* trim off upper portion */
if (excess > 0) {
pfn_t p;
int mlret;
p -= excess;
_ptob64(p),
&x_ml);
}
PR_MEM("%s: brd %d: edited source memlist:\n",
#ifdef DEBUG
/* sanity check memlist */
#endif
/*
* x_ml now describes only the portion of the
* source board that will be moved during the
*/
} else {
/* use original memlist; all spans will be moved */
}
/* verify target can support source memory spans. */
PR_MEM("%s: source memlist won't"
" fit in target memlist\n", f);
PR_MEM("%s: source memlist:\n", f);
PR_MEM("%s: target memlist:\n", f);
continue;
}
/* NOTE: the value of d_ml is not used beyond this point */
PR_MEM("%s: checking for no-reloc on board %d, "
" basepfn=0x%lx, npages=%ld\n",
f,
t_mp->sbm_npages);
PR_MEM("%s: kphysm_del_span_query:"
" unexpected return value %d\n", f, rv);
continue;
}
if (mq.nonrelocatable != 0) {
PR_MEM("%s: candidate board %d has"
" nonrelocatable span [0x%lx..0x%lx]\n",
f,
continue;
}
#ifdef DEBUG
/*
* This is a debug tool for excluding certain boards
* from being selected as a target board candidate.
* sbd_ignore_board is only tested by this driver.
* favorite debugger.
*/
if (sbd_ignore_board &
PR_MEM("%s: sbd_ignore_board flag set,"
" ignoring board %d as candidate\n",
continue;
}
#endif
/*
* Make sure there is no memory overlap if this
* target board is used for copy-rename.
*/
continue;
/*
* Reserve excess source board memory, if any.
*
* When the number of pages on the candidate target
* board is less than the number of pages on the source,
* then some spans (clearly) of the source board's address
* space will not be covered by physical memory after the
* schedules those spans to be deleted.
*/
int mlret;
PR_MEM("%s: cant dup src brd memlist\n", f);
/* TODO: should abort */
continue;
}
/* calculate base pfn relative to target board */
/* remove span that will reside on candidate board */
&d_ml);
PR_MEM("%s: brd %d: reserving src brd memlist:\n",
/* reserve excess spans */
/* likely more non-reloc pages appeared */
/* TODO: restart from top? */
continue;
}
} else {
/* no excess source board memory */
}
/*
* reserve all memory on target board.
* NOTE: source board's memhandle is used.
*
* If this succeeds (eq 0), then target selection is
* complete and all unwanted memory spans, both source and
* target, have been reserved. Loop is terminated.
*/
PR_MEM("%s: brd %d: target board memory reserved\n",
/* a candidate target board is now reserved */
/* *** EXITING LOOP *** */
break;
}
/* did not successfully reserve the target board. */
PR_MEM("%s: could not reserve target board %d\n",
/*
* NOTE: an undo of the sbd_reserve_mem_span work
* will happen automatically when the memhandle
* (s_mp->sbm_memhandle) is kphysm_del_release'd.
*/
}
/* clean up after memlist editing logic */
/*
* c_mp will be NULL when the entire sets[] array
* has been searched without reserving a target board.
*/
PR_MEM("%s: brd %d: target selection failed.\n",
return (-1);
}
PR_MEM("%s: found target board %d for source board %d\n",
f,
PR_MEM("%s: upsize (source pgs 0x%lx < target pgs 0x%lx)\n",
PR_MEM("%s: downsize (source pgs 0x%lx > target pgs 0x%lx)\n",
}
return (0);
}
int
{
int ret;
if (ret != 0)
return (ret);
}
/*
* Memlist support.
*/
void
{
}
struct memlist *
{
return (NULL);
mp = memlist_get_one();
break;
}
else
}
return (hl);
}
void
{
PR_MEM("memlist> EMPTY\n");
} else {
}
}
int
{
return (0);
return (0);
return (1);
return (0);
return (1);
}
return (0);
}
/*
* Determine whether the source memlist (s_mlist) will
* fit into the target memlist (t_mlist) in terms of
* size and holes (i.e. based on same relative base address).
*/
static int
{
int rv = 0;
return (0);
/*
* Base both memlists on common base address (0).
*/
break;
}
}
/*
* If we ran out of source memlist chunks that mean
* we found a home for all of them.
*/
rv = 1;
/*
* Need to add base addresses back since memlists
* are probably in use by caller.
*/
return (rv);
}
void
{
static fn_t f = "sbd_attach_mem";
int i;
PR_MEM("%s...\n", f);
/*
* all four cpus have to be attached before
* configuring mem
*/
for (i = 0; i < MAX_CPU_UNITS_PER_BOARD; i++) {
continue;
goto error;
goto error;
"sbd:%s: cpu_get failed for cpu %d",
f, cpup->sbc_cpu_id);
goto error;
}
if (cpu_is_poweredoff(cp)) {
goto error;
}
continue;
return;
}
if (unit < 0) {
return;
}
"sbd:%s: failed to get memlist for "
/*
* Need to record an error and return.
*/
return;
}
err = 0;
"%s: kphysm_add_memory_dynamic fail %d", f, err);
/* translate kphysm error */
switch (err) {
case KPHYSM_ERESOURCE:
err = ESBD_NOMEM;
break;
case KPHYSM_EFAULT:
err = ESBD_FAULT;
break;
default:
err = ESBD_INVAL;
break;
}
break;
}
if (err != 0) {
"%s: kcage_range_add fail %d", f, err);
/* Translate kcage error. */
switch (err) {
case ENOMEM:
err = ESBD_NOMEM;
break;
default:
err = ESBD_INVAL;
break;
}
break;
}
}
if (err != 0) {
}
/*
* Now attach all mem devinfo nodes to the device tree.
*/
for (i = 0; i < SBD_NUM_MC_PER_BOARD; i++) {
continue;
SBD_GET_ERR(ep) == 0) {
}
}
}
typedef struct {
int error;
int done;
/*
* When we reach here the memory being drained should have
* already been reserved in sbd_pre_release_mem().
* Our only task here is to kick off the "drain".
* Returns -1 when error encountered or zero for success.
*/
int
{
int err;
int cancel_flag = 0;
int e_code = 0;
static fn_t f = "sbd_release_mem";
/*
* If this node has a scheduled memory delete operation,
* it will have a memhandle. If it does have a memhandle (the
* return value of sbd_get_memhandle is zero when true),
* then perform the delete.
*/
return (cancel_flag);
}
/* wait for completion */
if (cancel_flag) {
/* previously canceled */
/* interrupted: cancel and wait */
cancel_flag = -1;
(void) kphysm_del_cancel(mh);
}
}
/* get the result of the memory delete operation */
} else {
(void) kphysm_del_release(mh);
}
switch (err) {
case KPHYSM_ENOWORK:
break;
case KPHYSM_EHANDLE:
case KPHYSM_ESEQUENCE:
break;
case KPHYSM_ENOTVIABLE:
break;
case KPHYSM_EREFUSED:
break;
case KPHYSM_ENONRELOC:
break;
case KPHYSM_ECANCELLED:
break;
case KPHYSM_ERESOURCE:
break;
default:
" unexpected kphysm error code %d,"
" dip 0x%p",
break;
}
if (e_code != 0) {
cancel_flag = -1;
}
}
return (cancel_flag);
}
/*
* Memory has been logically removed by the time this routine is called.
*/
void
{
}
/*
* If detaching node contains memory that is "non-permanent"
* then the memory adr's are simply cleared. If the memory
* is non-relocatable, then do a copy-rename.
*/
int
int unit)
{
int rv;
static fn_t f = "sbd_detach_memory";
PR_MEM("%s...\n", f);
/* lookup target mem unit and target board structure, if any */
} else {
}
/* verify mem unit's state is UNREFERENCED */
if (state != SBD_STATE_UNREFERENCED) {
" mem-unit (%d.%d)",
f,
return (-1);
}
/* verify target mem unit's state is UNREFERENCED, if any */
if (state != SBD_STATE_UNREFERENCED) {
" target mem-unit (%d.%d)",
f,
return (-1);
}
}
/*
* Displacement flush all ecaches in the system.
* That's the fastest way to remove all cache references
* to the detaching memory.
*/
xc_all(sbd_flush_ecache, 0, 0);
/*
* we're done!
*/
/*
* Reprogram interconnect hardware and disable
* memory controllers for memory node that's going away.
*/
if (rv) {
"%s: failed to deprogram mem-unit (%d.%d),"
" dip 0x%p",
f,
/*
* Make sure we don't rewrite an sbdp error
*/
if (SBD_GET_ERR(ep) != 0) {
}
}
} else {
if (rv) {
int i;
" from board %d to board %d",
f,
/*
* Make sure we don't rewrite an sbdp error
*/
if (SBD_GET_ERR(ep) != 0) {
}
/*
* If we failed here, it means that the target board's
* memory has been unconfigured. We need to configure
* it back
*/
for (i = 0; i < MAX_MEM_UNITS_PER_BOARD; i++) {
int unit;
/*
* We already saved the error that created
* this mess. If we fail, make sure not
* to overwrite the original error
*/
if (unit == -1) {
continue;
}
continue;
/*
* clean up
*/
}
}
}
PR_MEM("%s: %s memory COPY-RENAME (board %d -> %d)\n",
f,
}
if (rv == 0) {
}
return (rv);
}
/*ARGSUSED*/
static void
{
}