[Cbe-oss-dev] [PATCH]libspe2: add handling of zero tagmask for proxy dma

D. Herrendoerfer d.herrendoerfer at herrendoerfer.name
Thu Jul 26 15:19:06 EST 2007


Right, of course this is on a per-SPE basis.

Fixed version:
This patch adds handling of a zero tagmask parameter when SPE_MAP_PS
is set.

This is the fixed issue mentioned in Gerhard Stenzel's post:
The two side effects are, if a context is created with SPE_MAP_PS:

1) A mask value of 0 will not be interpreted as "all outsanding tags"

Signed-off by: D.Herrendoerfer <d.herrendoerfer at herrendoerfer.name>

Index: libspe2/spebase/dma.c
===================================================================
--- libspe2/spebase/dma.c	(revision 82)
+++ libspe2/spebase/dma.c	(working copy)
@@ -53,6 +53,8 @@ static int issue_mfc_command(spe_context
 		unsigned int eal = (uintptr_t) ea & 0xFFFFFFFF;
 		unsigned int eah = (unsigned long long)(uintptr_t) ea >> 32;
 		_base_spe_context_lock(spectx, FD_MFC);
+		spectx->base_private->active_tagmask |= 1 << tag;
+		DEBUG_PRINTF("set active tagmask = 0x%04x, tag=%i
\n",spectx->base_private->active_tagmask,tag);
 		while ((cmd_area->MFC_QStatus & 0x0000FFFF) == 0) ;
 		do {
 			cmd_area->MFC_LSA         = lsa;
@@ -231,12 +233,14 @@ static int spe_read_tag_status_block(spe
 	if (spectx->base_private->flags & SPE_MAP_PS) {
 		volatile struct spe_mfc_command_area *cmd_area =
 			spectx->base_private->mfc_mmap_base;
-
 		_base_spe_context_lock(spectx, FD_MFC);
 		cmd_area->Prxy_QueryMask = mask;
 		__asm__ ("eieio");
 		do {
 			*tag_status = cmd_area->Prxy_TagStatus;
+			spectx->base_private->active_tagmask ^= *tag_status;
+			DEBUG_PRINTF("unset active tagmask = 0x%04x, tag_status = 0x%04x\n",
+							spectx->base_private->active_tagmask,*tag_status);
 		} while (*tag_status ^ mask);
 		_base_spe_context_unlock(spectx, FD_MFC);
 		return 0;
@@ -266,6 +270,9 @@ static int spe_read_tag_status_noblock(s
 		cmd_area->Prxy_QueryMask = mask;
 		__asm__ ("eieio");
 		*tag_status =  cmd_area->Prxy_TagStatus;
+		spectx->base_private->active_tagmask ^= *tag_status;
+		DEBUG_PRINTF("unset active tagmask = 0x%04x, tag_status = 0x%04x\n",
+						spectx->base_private->active_tagmask,*tag_status);
 		_base_spe_context_unlock(spectx, FD_MFC);
 		return 0;
 	} else {
@@ -302,6 +309,9 @@ int _base_spe_mfcio_tag_status_read(spe_
 	if ( mask != 0 ) {
 		if (!(spectx->base_private->flags & SPE_MAP_PS)) 
 			mask = 0;
+	} else {
+		if ((spectx->base_private->flags & SPE_MAP_PS))
+			mask = spectx->base_private->active_tagmask;
 	}
 
 	if (!tag_status) {
Index: libspe2/spebase/spebase.h
===================================================================
--- libspe2/spebase/spebase.h	(revision 82)
+++ libspe2/spebase/spebase.h	(working copy)
@@ -95,6 +95,11 @@ struct spe_context_base_priv {
 	/* We need to keep the entry point for emulated isolated contexts,
 	 * and ignore the value provided to spe_context_run */
 	int		emulated_entry;
+	
+	/* This is used to keep track of tags used for proxy DMA operations
+	 * so we can use the zero tagmask parameter in the status functions*/
+	 
+	 int active_tagmask;
 };
===================================================================

Regards,

D.Herrendoerfer

On Thu, 2007-07-26 at 00:56 +0900, Kazunori Asayama wrote:
> D. Herrendoerfer wrote:
> > This patch adds handling of a zero tagmask parameter when SPE_MAP_PS
> > is set.
> > 
> > This is the fixed issue mentioned in Gerhard Stenzel's post:
> >> The two side effects are, if a context is created with SPE_MAP_PS:
> >>
> >> 1) A mask value of 0 will not be interpreted as "all outsanding tags"
> > 
> > Ok to apply ?
> 
> The tagmask should be handled per SPE context,
> so the active_tagmask should be a member of spe_context_base_priv
> rather than a global variable.
> 
> 
> > 
> > Signed-off by: D. Herrendoerfer <d.herrendoerfer at herrendoerfer.name>
> > 
> > Index: libspe2/spebase/dma.c
> > ===================================================================
> > --- libspe2/spebase/dma.c	(revision 82)
> > +++ libspe2/spebase/dma.c	(working copy)
> > @@ -32,6 +32,8 @@
> >  static int spe_read_tag_status_block(spe_context_ptr_t spectx, unsigned
> > int mask, unsigned int *tag_status);
> >  static int spe_read_tag_status_noblock(spe_context_ptr_t spectx,
> > unsigned int mask, unsigned int *tag_status);
> >  
> > +static int active_tagmask = 0;
> > +
> >  static int issue_mfc_command(spe_context_ptr_t spectx, unsigned lsa,
> > void *ea,
> >  			     unsigned size, unsigned tag, unsigned tid, unsigned rid,
> >  			     enum mfc_cmd cmd)
> > @@ -53,6 +55,8 @@ static int issue_mfc_command(spe_context
> >  		unsigned int eal = (uintptr_t) ea & 0xFFFFFFFF;
> >  		unsigned int eah = (unsigned long long)(uintptr_t) ea >> 32;
> >  		_base_spe_context_lock(spectx, FD_MFC);
> > +		active_tagmask |= 1 << tag;
> > +		DEBUG_PRINTF("set active tagmask = 0x%04x, tag=%i
> > \n",active_tagmask,tag);
> >  		while ((cmd_area->MFC_QStatus & 0x0000FFFF) == 0) ;
> >  		do {
> >  			cmd_area->MFC_LSA         = lsa;
> > @@ -231,12 +235,13 @@ static int spe_read_tag_status_block(spe
> >  	if (spectx->base_private->flags & SPE_MAP_PS) {
> >  		volatile struct spe_mfc_command_area *cmd_area =
> >  			spectx->base_private->mfc_mmap_base;
> > -
> >  		_base_spe_context_lock(spectx, FD_MFC);
> >  		cmd_area->Prxy_QueryMask = mask;
> >  		__asm__ ("eieio");
> >  		do {
> >  			*tag_status = cmd_area->Prxy_TagStatus;
> > +			active_tagmask ^= *tag_status;
> > +			DEBUG_PRINTF("unset active tagmask = 0x%04x, tag_status = 0x%04x
> > \n",active_tagmask,*tag_status);
> >  		} while (*tag_status ^ mask);
> >  		_base_spe_context_unlock(spectx, FD_MFC);
> >  		return 0;
> > @@ -266,6 +271,8 @@ static int spe_read_tag_status_noblock(s
> >  		cmd_area->Prxy_QueryMask = mask;
> >  		__asm__ ("eieio");
> >  		*tag_status =  cmd_area->Prxy_TagStatus;
> > +		active_tagmask ^= *tag_status;
> > +		DEBUG_PRINTF("unset active tagmask = 0x%04x, tag_status = 0x%04x
> > \n",active_tagmask,*tag_status);
> >  		_base_spe_context_unlock(spectx, FD_MFC);
> >  		return 0;
> >  	} else {
> > @@ -302,6 +309,9 @@ int _base_spe_mfcio_tag_status_read(spe_
> >  	if ( mask != 0 ) {
> >  		if (!(spectx->base_private->flags & SPE_MAP_PS)) 
> >  			mask = 0;
> > +	} else {
> > +		if ((spectx->base_private->flags & SPE_MAP_PS))
> > +			mask = active_tagmask;
> >  	}
> >  
> >  	if (!tag_status) {
> > 
> > ===================================================================
> > 
> > Best regards, 
> > 
> > D. Herrendoerfer




More information about the cbe-oss-dev mailing list