Skip to content

Wrong values returned from _XAie_GetRowfromRegOff and _XAie_GetColfromRegOff #16

@Yu-Zhewen

Description

@Yu-Zhewen

static inline u8 _XAie_GetRowfromRegOff(XAie_DevInst *DevInst, u64 RegOff)
{
return RegOff &(u64)(~(ULONG_MAX << DevInst->DevProp.RowShift));
}

The provided function is intended to extract the row information from RegOff. However, the current implementation incorrectly extracts only the lower 8 bits (RegOff[7:0]) instead of the intended range, RegOff[ColShift:RowShift].

The correct version is something like this:

 static inline u8 _XAie_GetRowfromRegOff(XAie_DevInst *DevInst, u64 RegOff) 
 { 
	u64 Mask = (u64)(((1U << DevInst->DevProp.ColShift) - 1U) &
			~((1U << DevInst->DevProp.RowShift) - 1U));

	return (u8)((RegOff & Mask) >> (u64)(DevInst->DevProp.RowShift));
 }

I believe the above logic has been misplaced and currently resides in _XAie_GetColfromRegOff. The _XAie_GetColfromRegOff function should also be updated to the following:

 static inline u8 _XAie_GetColfromRegOff(XAie_DevInst *DevInst, u64 RegOff) 
 { 
	return (u8)(RegOff >> (u64)(DevInst->DevProp.ColShift));
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions