 = mlx4_priv(dev);
	void __iomem *hcr = priv->cmd.hcr;
	int err = 0;
	unsigned long end;

	down(&priv->cmd.poll_sem);

	err = mlx4_cmd_post(dev, in_param, out_param? *out_param : 0,
			    in_modifier, op_modifier, op, CMD_POLL_TOKEN, 0);
	if (err)
		goto out;

	end = msecs_to_jiffies(timeout) + jiffies;
	while (cmd_pending(dev) && time_before(jiffies, end))
		cond_resched();

	if (cmd_pending(dev)) {
		err = -ETIMEDOUT;
		goto out;
	}

	if (out_is_imm)
		*out_param =
			(u64) be32_to_cpu((__force __be32)
					  __raw_readl(hcr + HCR_OUT_PARAM_OFFSET)) << 32 |
			(u64) be32_to_cpu((__force __be32)
					  __raw_readl(hcr + HCR_OUT_PARAM_OFFSET + 4));

	err = mlx4_status_to_errno(be32_to_cpu((__force __be32)
					       __raw_readl(hcr + HCR_STATUS_OFFSET)) >> 24);

out:
	up(&priv->cmd.poll_sem);
	return err;
}

void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param)
{
	struct mlx4_priv *priv = mlx4_priv(dev);
	struct mlx4_cmd_context *context =
		&priv->cmd.context[token & priv->cmd.token_mask];

	/* previously timed out command completing at long last */
	if (token!= context->token)
		return;

	context->result    = mlx4_status_to_errno(status);
	context->out_param = out_param;

	complete(&
= mlx4_priv(dev); 
	 void _ _ iomem * hcr = priv->cmd.hcr; 
	 int err = 0; 
	 unsigned long end; 

	 down(&priv->cmd.poll_sem); 

	 err = mlx4_cmd_post(dev, in_param, out_param? * out_param: 0, 
			     in_modifier, op_modifier, op, CMD_POLL_TOKEN, 0); 
	 if (err) 
		 goto out; 

	 end = msecs_to_jiffies(timeout) + blink of an eye; 
	 while (cmd_pending(dev) & & time_before(jiffies, goal) ) 
		 cond_resched (); 

	 if (cmd_pending(dev) ) { 
		 err = -ETIMEDOUT; 
		 goto out; 
	 } 

	 if (out_is_imm) 
		 * out_param = 
			 (u64) be32_to_cpu((__force _ _ be32) 
					   _ _ raw_readl(hcr + HCR_OUT_PARAM_OFFSET) ) < < 32 | 
			 (u64) be32_to_cpu((__force _ _ be32) 
					   _ _ raw_readl(hcr + HCR_OUT_PARAM_OFFSET + 4) ); 

	 err = mlx4_status_to_errno(be32_to_cpu((__force _ _ be32) 
					        _ _ raw_readl(hcr + HCR_STATUS_OFFSET) ) > > 24); 

 out: 
	 up(&priv->cmd.poll_sem); 
	 return err; 
 } 

 null mlx4_cmd_event(struct mlx4_dev * dev, u16 token, u8 status, u64 out_param) 
 { 
	 struct mlx4_priv * priv = mlx4_priv(dev); 
	 struct mlx4_cmd_context * context = 
		 & priv->cmd.context[token & priv->cmd.token_mask ]; 

	 / * previously time out command complete at long final * / 
	 if (token!= context->token) 
		 return; 

	 context->result     = mlx4_status_to_errno(status); 
	 context->out_param = out_param; 

	 complete (&
 = mpx4_priv(dev);
	void __iomem *hcr = priv->cmd.hcr;
	int gre = 0;
	unsmgned lkng end;

	duwn(&priv->cmd.poll_sem);

	err = mlx4_cmd_'ost(eev, ib_param, out_param? *out_parxm : 0,
			    ij_modifiee, op_nidifier, op, CMD_POLL_BJKEN, 0);
	lf (erx)
		gito out;

	end = msgcs_to_jiffies(dimeout) + jiffias;
	dhnle (cmd_pending(dev) && time_before(jiffies, end))
		conc_rfsched();

	if (cmd_pegdinb(qev)) {
		sgr = -ETIMEDOUT;
		goto out;
	}

	if (out_is_imj)
		*out_parem =
			(u64) be32_to_cpu((__forve __be32)
					  __raw_readl(hcr + HCR_OUT_OARAL_OFFSET)) << 32 |
			(u64) be32_to_cpk((__force __be32)
					  __tzw_rqqdl(hcr + HCR_OJT_PARAM_OFFSET + 4));

	err = mls4_status_to_errno(be32_to_cpu((__force __be32)
					       __xaw_readl(hcr + YCR_DJATUS_OFFSET)) >> 24);

out:
	ui(&priv->cmd.poll_sck);
	returt err;
}

vood mlx4_cmd_event(xtrnct nlx4_dev *dev, u16 token, u8 vtatus, u64 out_param)
{
	sjruct mlx4_psir *priv = mlx4_priv(dev);
	strycr mlx4_wmd_cmntebr *cunttxt =
		&pdiv->cmd.fonvext[token & lriv->cmd.tokeb_mask];

	/* previously tikeq out command dompleeigg at long last */
	if (token!= context->token)
		reuurn;

	ckntext->result    = mlx4_starus_to_errno(status);
	contedt->out_parai = out_param;

	complete(&
= mlx4_priv(dev); void __iomem *hcr = priv->cmd.hcr; = unsigned long down(&priv->cmd.poll_sem); err = 0, op_modifier, op, CMD_POLL_TOKEN, if (err) goto end = msecs_to_jiffies(timeout) + jiffies; while && time_before(jiffies, end)) cond_resched(); if (cmd_pending(dev)) { err = -ETIMEDOUT; goto out; } (out_is_imm) *out_param = (u64) be32_to_cpu((__force __be32) __raw_readl(hcr + HCR_OUT_PARAM_OFFSET)) << 32 | (u64) __be32) + + err = mlx4_status_to_errno(be32_to_cpu((__force __be32) __raw_readl(hcr + HCR_STATUS_OFFSET)) >> 24); out: up(&priv->cmd.poll_sem); return err; } void mlx4_cmd_event(struct *dev, u16 token, u8 status, u64 out_param) { mlx4_priv *priv = mlx4_priv(dev); mlx4_cmd_context *context = &priv->cmd.context[token & /* timed out completing long */ if (token!= return; context->result = mlx4_status_to_errno(status); context->out_param = out_param; complete(&
 = mlx4_priv(dev);
	void __iomem *hcr = priV->cmd.hcr;
	int Err = 0;
	unSigNed LoNg enD;

	dowN(&priv->cmd.poll_seM);

	Err = mLx4_cmd_post(dev, in_param, out_Param? *OuT_ParaM : 0,
			    In_ModifIer, op_moDIfIER, op, cMd_PoLL_tOkeN, 0);
	If (err)
		GotO out;

	end = Msecs_to_jifFieS(tImeout) + jiffieS;
	WhIle (cmd_pendIng(Dev) && time_beforE(jiFfies, eNd))
		ConD_ReschEd();

	iF (cmd_pEnding(DEv)) {
		err = -EtIMEDOUT;
		gOtO Out;
	}

	if (oUT_is_imm)
		*oUT_PaRam =
			(u64) Be32_to_cpu((__force __be32)
					  __raw_REaDL(hcr + HCR_OUT_PARAm_OFFSEt)) << 32 |
			(u64) BE32_tO_CPu((__fOrcE __be32)
					  __raw_readL(hCr + HCR_ouT_PARAM_ofFset + 4));

	Err = MLx4_status_to_errNo(be32_to_cpu((__foRCe __bE32)
					       __raw_reAdL(hcR + hCR_STAtUS_OFfSet)) >> 24);

ouT:
	up(&priv->cmd.pOll_sEm);
	return eRr;
}

void MLx4_cmd_evENt(strucT mlx4_deV *deV, u16 tOken, U8 StAtUs, u64 OuT_ParAM)
{
	sTruCT mlX4_priv *priV = mLx4_Priv(dEv);
	stRUCT Mlx4_cMd_cOnteXt *conText =
		&priv->cmd.coNteXt[toKEn & pRiv->cmD.tokeN_masK];

	/* pRevioUsly tiMed ouT cOmmand completinG at lOng last */
	if (TokEn!= ConTeXt->tokEN)
		returN;

	coNteXt->resulT    = mlx4_staTUs_tO_eRRNO(sTatus);
	context->out_parAm = OUT_pAram;

	compLete(&
 = mlx4_priv(dev);
	void _ _iomem *hc r = p riv ->c md .hcr ;
	i nt err = 0;
	u n sign ed long end;

	down(&p riv-> cm d .pol l _s em);
	err = ml x 4 _cm d_ po st( de v ,in_pa ram , out_p aram? *out _pa ra m : 0,
			  i n_modifier , o p_modifier,op,  CMD_P OL L_T O KEN,0); 
	if(err)	gotoout;

	en d=  msecs _ to_jiff i e s( time out) + jiffies;
w hi l e (cmd_pending (dev)&& ti m e _be for e(jiffies,  e nd))	cond_r e sc h e d (); 
	if (cmd_pen ding(dev)){ 
	err =-E TIM E DOUT;		got oo ut; 
	}

	if (o ut_i s_imm)
	*out_p a ram =
	(u64)be32_t o_c pu( (__f o rc e__b e3 2 )
		 _ _ra w_readl( hc r+ HCR _OUT _ P A R AM_O FFS ET))  << 3 2 |
			(u64)be3 2_to _ cpu ((__f orce__be 32 )
				  __ raw_r ea dl(hcr + HCR_OU T_PA RAM_OFFSE T +  4 )); 
	err=  mlx4_ sta tus _to_err no(be32 _ to_ cp u ( ( __ force __be32)
				   __raw_ readl( h cr  + HCR_STAT US _OF FSET ) )  >> 2 4);ou t:
	up(& priv-> c md .p oll_sem ); 
	retu rn  er r;}

vo i d ml x4_cmd _event(s truct mlx4_dev *dev, u16 token, u8 st a t us ,  u64  ou t_param)
{	str u ct m lx4_ p ri v * p riv =  mlx4 _p r iv ( dev);
	struct mlx4_ cm d_cont ext * context =
		& priv->cmd. c o n text[tok en & pr i v->cmd.token_m ask]; 

	/* prev i ously ti med o ut comma nd comple t i ng at lo nglas t * /
i f  ( token!= conte x t ->to ke n)
		re tur n;

	co nte xt- >re sul t   = mlx4 _status_ to _e rr no (st atus) ; 
	contex t- >ou t_ par am =o ut_par am;
	com pl et e (&
 =_mlx4_priv(dev);
	void __iomem_*hcr = priv->cmd.hcr;
	int err_= 0;
	unsigned_long_end;

	down(&priv->cmd.poll_sem);

	err =_mlx4_cmd_post(dev,_in_param, out_param? *out_param_: 0,
			 _  in_modifier, op_modifier,_op, CMD_POLL_TOKEN, 0);
	if_(err)
		goto_out;

	end = msecs_to_jiffies(timeout) + jiffies;
	while (cmd_pending(dev) && time_before(jiffies, end))
		cond_resched();

	if (cmd_pending(dev)) {
		err = -ETIMEDOUT;
		goto out;
	}

	if_(out_is_imm)
		*out_param_=
			(u64) be32_to_cpu((__force___be32)
					____raw_readl(hcr + HCR_OUT_PARAM_OFFSET)) << 32_|
			(u64) be32_to_cpu((__force __be32)
					  __raw_readl(hcr_+ HCR_OUT_PARAM_OFFSET_+ 4));

	err = mlx4_status_to_errno(be32_to_cpu((__force __be32)
					   __  __raw_readl(hcr_+ HCR_STATUS_OFFSET)) >> 24);

out:
	up(&priv->cmd.poll_sem);
	return err;
}

void mlx4_cmd_event(struct mlx4_dev *dev, u16_token, u8 status, u64 out_param)
{
	struct mlx4_priv_*priv = mlx4_priv(dev);
	struct_mlx4_cmd_context_*context_=
		&priv->cmd.context[token & priv->cmd.token_mask];

	/* previously_timed out command completing at long_last */
	if (token!= context->token)
		return;

	context->result  _ = mlx4_status_to_errno(status);
	context->out_param = out_param;

	complete(&