Message ID | 1550224149-30380-1-git-send-email-alexandre.torgue@st.com (mailing list archive) |
---|---|
State | Mainlined, archived |
Commit | 4012e7d09d99b62d80046790657c0b0e32310d50 |
Headers | show |
Series | [net,v2] net: stmmac: handle endianness in dwmac4_get_timestamp | expand |
From: Alexandre Torgue <alexandre.torgue@st.com> Date: Fri, 15 Feb 2019 10:49:09 +0100 > GMAC IP is little-endian and used on several kind of CPU (big or little > endian). Main callbacks functions of the stmmac drivers take care about > it. It was not the case for dwmac4_get_timestamp function. > > Fixes: ba1ffd74df74 ("stmmac: fix PTP support for GMAC4") > > Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> Please do not put an empty line between Fixes: and other tags. All tags are equal and should be placed together as a cohesive group. Applied, thanks.
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c index 20299f6..736e296 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_descs.c @@ -241,15 +241,18 @@ static inline void dwmac4_get_timestamp(void *desc, u32 ats, u64 *ts) static int dwmac4_rx_check_timestamp(void *desc) { struct dma_desc *p = (struct dma_desc *)desc; + unsigned int rdes0 = le32_to_cpu(p->des0); + unsigned int rdes1 = le32_to_cpu(p->des1); + unsigned int rdes3 = le32_to_cpu(p->des3); u32 own, ctxt; int ret = 1; - own = p->des3 & RDES3_OWN; - ctxt = ((p->des3 & RDES3_CONTEXT_DESCRIPTOR) + own = rdes3 & RDES3_OWN; + ctxt = ((rdes3 & RDES3_CONTEXT_DESCRIPTOR) >> RDES3_CONTEXT_DESCRIPTOR_SHIFT); if (likely(!own && ctxt)) { - if ((p->des0 == 0xffffffff) && (p->des1 == 0xffffffff)) + if ((rdes0 == 0xffffffff) && (rdes1 == 0xffffffff)) /* Corrupted value */ ret = -EINVAL; else
GMAC IP is little-endian and used on several kind of CPU (big or little endian). Main callbacks functions of the stmmac drivers take care about it. It was not the case for dwmac4_get_timestamp function. Fixes: ba1ffd74df74 ("stmmac: fix PTP support for GMAC4") Signed-off-by: Alexandre Torgue <alexandre.torgue@st.com> --- changes since V1: -consider this patch as a fix -change targeted tree from net-next to net regards Alex