Skip to contentSkip to conversation

staging: vt6655: Replace macro VNSvInPortD with ioread32()

PATCH Superseded Philipp Hortmann 3 participants 14 messages Apr 27, 2022 – Apr 29, 2022 Staging

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover staging: vt6655: Replace macro VNSvInPortD with ioread32()

Replace macro VNSvInPortD with ioread32.
Avoid cast of the return value as much as possible. The name of macro and the arguments use CamelCase which is not accepted by checkpatch.pl

Tested with vt6655 on mini PCI Module Transferred this patch over wlan connection of vt6655

Used this code for testing of fuction: CARDbGetCurrentTSF in patch "staging: vt6655: Replace VNSvInPortD with ioread32":

	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: %llx", *pqwCurrTSF);
	
	low = ioread32(iobase + MAC_REG_TSFCNTR);
	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF temp_ph: %llx",
			 low + ((u64)high << 32));

output:

[  +0.000083] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 116e83
[  +0.000008] vt6655 0000:01:05.0: CARDbGetCurrentTSF temp_ph: 116e83
[  +0.000009] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 753d80
[  +0.000005] vt6655 0000:01:05.0: CARDbGetCurrentTSF temp_ph: 753d80
[  +0.000010] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 753d8f
[  +0.000004] vt6655 0000:01:05.0: CARDbGetCurrentTSF temp_ph: 753d8f

V1 -> V2: Removed patch "staging: vt6655: Replace VNSvInPortW with ioread16"
as it was already accepted.
Joint patch "Replace two VNSvInPortD with ioread64_lo_hi" with patch "Replace VNSvInPortD with ioread32" and changed ioread64 to two ioread32 as ioread64 does not work with 32 Bit computers. Shorted and simplified patch descriptions.
V2 -> V3: Added missing version in subject lines
Added change history in cover letter
Removed remark in cover letter "This patch series is new.." as it is obsolet.

Philipp Hortmann (3):
staging: vt6655: Replace MACvReadMIBCounter with VNSvInPortD
staging: vt6655: Replace MACvReadISR with VNSvInPortD
staging: vt6655: Replace VNSvInPortD with ioread32

 drivers/staging/vt6655/card.c        |  6 ++++--
 drivers/staging/vt6655/device_main.c |  6 +++---
 drivers/staging/vt6655/mac.h         | 24 +++++++++---------------
 drivers/staging/vt6655/rf.c          |  2 +-
 drivers/staging/vt6655/upc.h         |  3 ---
 5 files changed, 17 insertions(+), 24 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v3 1/3 staging: vt6655: Replace MACvReadMIBCounter with VNSvInPortD

Replace macro MACvReadMIBCounter with VNSvInPortD and as it was the only user, it can now be removed.

---
V1 -> V2: Shorted and simplified patch description V2 -> V3: Added missing version in subject

---
 drivers/staging/vt6655/device_main.c | 2 +-
 drivers/staging/vt6655/mac.h         | 3 ---
 2 files changed, 1 insertion(+), 4 deletions(-)
drivers/staging/vt6655/device_main.c +1 -1
index 08b955c71b3c..7cceb57a5139 100644
@@ -1042,7 +1042,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 	spin_lock_irqsave(&priv->lock, flags);
 
 	/* Read low level stats */
-	MACvReadMIBCounter(priv->port_offset, &mib_counter);
+	VNSvInPortD(priv->port_offset + MAC_REG_MIBCNTR, &mib_counter);
 
 	low_stats->dot11RTSSuccessCount += mib_counter & 0xff;
 	low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff;
drivers/staging/vt6655/mac.h +0 -3
index 4c6739862188..74b45e1f0963 100644
@@ -684,9 +684,6 @@ do {									\
 #define MACvSelectPage1(iobase)				\
 	VNSvOutPortB(iobase + MAC_REG_PAGE1SEL, 1)
 
-#define MACvReadMIBCounter(iobase, pdwCounter)			\
-	VNSvInPortD(iobase + MAC_REG_MIBCNTR, pdwCounter)
-
 #define MACvEnableProtectMD(iobase)					\
 do {									\
 	unsigned long dwOrgValue;					\
Signature · 1 line
2.25.1
#2 lore raw

PATCH v3 2/3 staging: vt6655: Replace MACvReadISR with VNSvInPortD

In reply to Philipp Hortmann

Replace macro MACvReadISR with VNSvInPortD and as it was the only user, it can now be removed.

---
V1 -> V2: Shorted and simplified patch description V2 -> V3: Added missing version in subject

---
 drivers/staging/vt6655/device_main.c | 4 ++--
 drivers/staging/vt6655/mac.h         | 3 ---
 2 files changed, 2 insertions(+), 5 deletions(-)
drivers/staging/vt6655/device_main.c +2 -2
index 7cceb57a5139..c21787f32252 100644
@@ -1029,7 +1029,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 	u32 isr;
 	unsigned long flags;
 
-	MACvReadISR(priv->port_offset, &isr);
+	VNSvInPortD(priv->port_offset + MAC_REG_ISR, &isr);
 
 	if (isr == 0)
 		return;
@@ -1116,7 +1116,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 		    ieee80211_queue_stopped(priv->hw, 0))
 			ieee80211_wake_queues(priv->hw);
 
-		MACvReadISR(priv->port_offset, &isr);
+		VNSvInPortD(priv->port_offset + MAC_REG_ISR, &isr);
 
 		MACvReceive0(priv->port_offset);
 		MACvReceive1(priv->port_offset);
drivers/staging/vt6655/mac.h +0 -3
index 74b45e1f0963..5aaa0de20e67 100644
@@ -666,9 +666,6 @@ do {									\
 	VNSvOutPortB(iobase + MAC_REG_STICKHW, byOrgValue);		\
 } while (0)
 
-#define MACvReadISR(iobase, pdwValue)				\
-	VNSvInPortD(iobase + MAC_REG_ISR, pdwValue)
-
 #define MACvWriteISR(iobase, dwValue)				\
 	VNSvOutPortD(iobase + MAC_REG_ISR, dwValue)
 
Signature · 1 line
2.25.1
#3 lore raw

PATCH v3 3/3 staging: vt6655: Replace VNSvInPortD with ioread32

In reply to Philipp Hortmann

Replace macro VNSvInPortD with ioread32 and as it was the only user, it can now be removed.
The name of macro and the arguments use CamelCase which is not accepted by checkpatch.pl

---
V1 -> V2: This patch was 5/7 and is now 4/6
V2 -> V3: Inserted patch that was before in a different way in
"Rename macros VNSvInPortB,W,D with CamelCase ..." This patch was part of 4/6 and is now 3/7
V3 -> V4: Removed casting of the output variable
V4 -> V5: Joint patch "Replace two VNSvInPortD with ioread64_lo_hi"
with this patch. Changed ioread64 to two ioread32 as ioread64 does not work with 32 Bit computers. Shorted and simplified patch description.
V5 -> V6: Added missing version in subject

---
 drivers/staging/vt6655/card.c        |  6 ++++--
 drivers/staging/vt6655/device_main.c |  6 +++---
 drivers/staging/vt6655/mac.h         | 18 +++++++++---------
 drivers/staging/vt6655/rf.c          |  2 +-
 drivers/staging/vt6655/upc.h         |  3 ---
 5 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/vt6655/card.c +4 -2
index 022310af5485..0dd13e475d6b 100644
@@ -744,6 +744,7 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	void __iomem *iobase = priv->port_offset;
 	unsigned short ww;
 	unsigned char data;
+	u32 low, high;
 
 	MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	}
 	if (ww == W_MAX_TIMEOUT)
 		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);
 
 	return true;
 }
drivers/staging/vt6655/device_main.c +3 -3
index c21787f32252..12fd825c23fe 100644
@@ -1029,7 +1029,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 	u32 isr;
 	unsigned long flags;
 
-	VNSvInPortD(priv->port_offset + MAC_REG_ISR, &isr);
+	isr = ioread32(priv->port_offset + MAC_REG_ISR);
 
 	if (isr == 0)
 		return;
@@ -1042,7 +1042,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 	spin_lock_irqsave(&priv->lock, flags);
 
 	/* Read low level stats */
-	VNSvInPortD(priv->port_offset + MAC_REG_MIBCNTR, &mib_counter);
+	mib_counter = ioread32(priv->port_offset + MAC_REG_MIBCNTR);
 
 	low_stats->dot11RTSSuccessCount += mib_counter & 0xff;
 	low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff;
@@ -1116,7 +1116,7 @@ static void vnt_interrupt_process(struct vnt_private *priv)
 		    ieee80211_queue_stopped(priv->hw, 0))
 			ieee80211_wake_queues(priv->hw);
 
-		VNSvInPortD(priv->port_offset + MAC_REG_ISR, &isr);
+		isr = ioread32(priv->port_offset + MAC_REG_ISR);
 
 		MACvReceive0(priv->port_offset);
 		MACvReceive1(priv->port_offset);
drivers/staging/vt6655/mac.h +9 -9
index 5aaa0de20e67..5b684194745c 100644
@@ -618,7 +618,7 @@ do {								\
 #define MACvReceive0(iobase)						\
 do {									\
 	unsigned long dwData;						\
-	VNSvInPortD(iobase + MAC_REG_RXDMACTL0, &dwData);		\
+	dwData = ioread32(iobase + MAC_REG_RXDMACTL0);			\
 	if (dwData & DMACTL_RUN)					\
 		VNSvOutPortD(iobase + MAC_REG_RXDMACTL0, DMACTL_WAKE); \
 	else								\
@@ -628,7 +628,7 @@ do {									\
 #define MACvReceive1(iobase)						\
 do {									\
 	unsigned long dwData;						\
-	VNSvInPortD(iobase + MAC_REG_RXDMACTL1, &dwData);		\
+	dwData = ioread32(iobase + MAC_REG_RXDMACTL1);			\
 	if (dwData & DMACTL_RUN)					\
 		VNSvOutPortD(iobase + MAC_REG_RXDMACTL1, DMACTL_WAKE); \
 	else								\
@@ -638,7 +638,7 @@ do {									\
 #define MACvTransmit0(iobase)						\
 do {									\
 	unsigned long dwData;						\
-	VNSvInPortD(iobase + MAC_REG_TXDMACTL0, &dwData);		\
+	dwData = ioread32(iobase + MAC_REG_TXDMACTL0);			\
 	if (dwData & DMACTL_RUN)					\
 		VNSvOutPortD(iobase + MAC_REG_TXDMACTL0, DMACTL_WAKE); \
 	else								\
@@ -648,7 +648,7 @@ do {									\
 #define MACvTransmitAC0(iobase)					\
 do {									\
 	unsigned long dwData;						\
-	VNSvInPortD(iobase + MAC_REG_AC0DMACTL, &dwData);		\
+	dwData = ioread32(iobase + MAC_REG_AC0DMACTL);			\
 	if (dwData & DMACTL_RUN)					\
 		VNSvOutPortD(iobase + MAC_REG_AC0DMACTL, DMACTL_WAKE); \
 	else								\
@@ -684,7 +684,7 @@ do {									\
 #define MACvEnableProtectMD(iobase)					\
 do {									\
 	unsigned long dwOrgValue;					\
-	VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue);		\
+	dwOrgValue = ioread32(iobase + MAC_REG_ENCFG);			\
 	dwOrgValue = dwOrgValue | ENCFG_PROTECTMD;			\
 	VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue);		\
 } while (0)
@@ -692,7 +692,7 @@ do {									\
 #define MACvDisableProtectMD(iobase)					\
 do {									\
 	unsigned long dwOrgValue;					\
-	VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue);		\
+	dwOrgValue = ioread32(iobase + MAC_REG_ENCFG);			\
 	dwOrgValue = dwOrgValue & ~ENCFG_PROTECTMD;			\
 	VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue);		\
 } while (0)
@@ -700,7 +700,7 @@ do {									\
 #define MACvEnableBarkerPreambleMd(iobase)				\
 do {									\
 	unsigned long dwOrgValue;					\
-	VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue);		\
+	dwOrgValue = ioread32(iobase + MAC_REG_ENCFG);			\
 	dwOrgValue = dwOrgValue | ENCFG_BARKERPREAM;			\
 	VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue);		\
 } while (0)
@@ -708,7 +708,7 @@ do {									\
 #define MACvDisableBarkerPreambleMd(iobase)				\
 do {									\
 	unsigned long dwOrgValue;					\
-	VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue);		\
+	dwOrgValue = ioread32(iobase + MAC_REG_ENCFG);			\
 	dwOrgValue = dwOrgValue & ~ENCFG_BARKERPREAM;			\
 	VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue);		\
 } while (0)
@@ -716,7 +716,7 @@ do {									\
 #define MACvSetBBType(iobase, byTyp)					\
 do {									\
 	unsigned long dwOrgValue;					\
-	VNSvInPortD(iobase + MAC_REG_ENCFG, &dwOrgValue);		\
+	dwOrgValue = ioread32(iobase + MAC_REG_ENCFG);			\
 	dwOrgValue = dwOrgValue & ~ENCFG_BBTYPE_MASK;			\
 	dwOrgValue = dwOrgValue | (unsigned long)byTyp;			\
 	VNSvOutPortD(iobase + MAC_REG_ENCFG, dwOrgValue);		\
drivers/staging/vt6655/rf.c +1 -1
index 4498c9d400f2..036f48572334 100644
@@ -175,7 +175,7 @@ bool IFRFbWriteEmbedded(struct vnt_private *priv, unsigned long dwData)
 
 	/* W_MAX_TIMEOUT is the timeout period */
 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
-		VNSvInPortD(iobase + MAC_REG_IFREGCTL, &dwValue);
+		dwValue = ioread32(iobase + MAC_REG_IFREGCTL);
 		if (dwValue & IFREGCTL_DONE)
 			break;
 	}
drivers/staging/vt6655/upc.h +0 -3
index 4d09cf18ebe0..a5b74aaadcd3 100644
@@ -20,9 +20,6 @@
 
 /* For memory mapped IO */
 
-#define VNSvInPortD(dwIOAddress, pdwData) \
-	(*(pdwData) = ioread32(dwIOAddress))
-
 #define VNSvOutPortB(dwIOAddress, byData) \
 	iowrite8((u8)(byData), dwIOAddress)
 
Signature · 1 line
2.25.1
#4 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

Quoted 39 lines · Philipp Hortmann

Replace macro VNSvInPortD with ioread32 and as it was the only user, it can now be removed.
The name of macro and the arguments use CamelCase which is not accepted by checkpatch.pl

---
V1 -> V2: This patch was 5/7 and is now 4/6
V2 -> V3: Inserted patch that was before in a different way in
"Rename macros VNSvInPortB,W,D with CamelCase ..." This patch was part of 4/6 and is now 3/7
V3 -> V4: Removed casting of the output variable
V4 -> V5: Joint patch "Replace two VNSvInPortD with ioread64_lo_hi"
with this patch. Changed ioread64 to two ioread32 as ioread64 does not work with 32 Bit computers. Shorted and simplified patch description.
V5 -> V6: Added missing version in subject

---
 drivers/staging/vt6655/card.c        |  6 ++++--
 drivers/staging/vt6655/device_main.c |  6 +++---
 drivers/staging/vt6655/mac.h         | 18 +++++++++---------
 drivers/staging/vt6655/rf.c          |  2 +-
 drivers/staging/vt6655/upc.h         |  3 ---
 5 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/vt6655/card.c +1 -0
index 022310af5485..0dd13e475d6b 100644
@@ -744,6 +744,7 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	void __iomem *iobase = priv->port_offset;
 	unsigned short ww;
 	unsigned char data;
+	u32 low, high;
 
 	MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 8 lines
drivers/staging/vt6655/card.c +3 -2
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	}
 	if (ww == W_MAX_TIMEOUT)
 		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you _sure_ this is doing the same thing?

Adding 1 to a u64 pointer increments it by a full u64. So I guess the cast to u32 * moves it only by a u32? Hopefully? That's messy.

Why not keep the current mess and do:

	pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	((u32 *)pqwCurTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Or does that not compile? Ick, how about:

	u32 *temp = (u32 *)pqwCurTSF;

	temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);

As that duplicates the current code a bit better.

I don't know, it's like polishing dirt, in the end, it's still dirt...

How about looking at the caller of this to see what it expects to do with this information? Unwind the mess from there?

thanks,

greg k-h

#5 lore raw

RE: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

From: Greg Kroah-Hartman

Quoted 53 lines

Sent: 27 April 2022 06:55

Quoted 39 lines · Philipp Hortmann

Replace macro VNSvInPortD with ioread32 and as it was the only user, it can now be removed.
The name of macro and the arguments use CamelCase which is not accepted by checkpatch.pl

---
V1 -> V2: This patch was 5/7 and is now 4/6
V2 -> V3: Inserted patch that was before in a different way in
"Rename macros VNSvInPortB,W,D with CamelCase ..." This patch was part of 4/6 and is now 3/7
V3 -> V4: Removed casting of the output variable
V4 -> V5: Joint patch "Replace two VNSvInPortD with ioread64_lo_hi"
with this patch. Changed ioread64 to two ioread32 as ioread64 does not work with 32 Bit computers. Shorted and simplified patch description.
V5 -> V6: Added missing version in subject

---
 drivers/staging/vt6655/card.c        |  6 ++++--
 drivers/staging/vt6655/device_main.c |  6 +++---
 drivers/staging/vt6655/mac.h         | 18 +++++++++---------
 drivers/staging/vt6655/rf.c          |  2 +-
 drivers/staging/vt6655/upc.h         |  3 ---
 5 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/vt6655/card.c +1 -0
index 022310af5485..0dd13e475d6b 100644
@@ -744,6 +744,7 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	void __iomem *iobase = priv->port_offset;
 	unsigned short ww;
 	unsigned char data;
+	u32 low, high;
 
 	MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 8 lines
drivers/staging/vt6655/card.c +3 -2
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	}
 	if (ww == W_MAX_TIMEOUT)
 		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you _sure_ this is doing the same thing?

Quoted 2 lines

Adding 1 to a u64 pointer increments it by a full u64. So I guess the cast to u32 * moves it only by a u32? Hopefully? That's messy.

The new code is mostly better.
But is different on BE systems - who knows what is actually needed. Depends what is being copied.

Actually I suspect that 'iobase' should be an __iomem structure pointer, pqwCurrTSF a point of the same type and MAC_REG_xxxx structure members.

Then the code should be using readl() not ioread32(). I very much doubt that 'iobase' is in PCI IO space.

David

Quoted 13 lines

Why not keep the current mess and do:

	pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	((u32 *)pqwCurTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Or does that not compile? Ick, how about:

	u32 *temp = (u32 *)pqwCurTSF;

	temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);

As that duplicates the current code a bit better.

Quoted 8 lines

I don't know, it's like polishing dirt, in the end, it's still dirt...

How about looking at the caller of this to see what it expects to do with this information? Unwind the mess from there?

thanks,

greg k-h

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#6 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

Quoted 54 lines · David Laight

From: Greg Kroah-Hartman

Quoted 53 lines

Sent: 27 April 2022 06:55

Quoted 39 lines · Philipp Hortmann

Replace macro VNSvInPortD with ioread32 and as it was the only user, it can now be removed.
The name of macro and the arguments use CamelCase which is not accepted by checkpatch.pl

---
V1 -> V2: This patch was 5/7 and is now 4/6
V2 -> V3: Inserted patch that was before in a different way in
"Rename macros VNSvInPortB,W,D with CamelCase ..." This patch was part of 4/6 and is now 3/7
V3 -> V4: Removed casting of the output variable
V4 -> V5: Joint patch "Replace two VNSvInPortD with ioread64_lo_hi"
with this patch. Changed ioread64 to two ioread32 as ioread64 does not work with 32 Bit computers. Shorted and simplified patch description.
V5 -> V6: Added missing version in subject

---
 drivers/staging/vt6655/card.c        |  6 ++++--
 drivers/staging/vt6655/device_main.c |  6 +++---
 drivers/staging/vt6655/mac.h         | 18 +++++++++---------
 drivers/staging/vt6655/rf.c          |  2 +-
 drivers/staging/vt6655/upc.h         |  3 ---
 5 files changed, 17 insertions(+), 18 deletions(-)
drivers/staging/vt6655/card.c +1 -0
index 022310af5485..0dd13e475d6b 100644
@@ -744,6 +744,7 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	void __iomem *iobase = priv->port_offset;
 	unsigned short ww;
 	unsigned char data;
+	u32 low, high;
 
 	MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
 	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 8 lines
drivers/staging/vt6655/card.c +3 -2
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
 	}
 	if (ww == W_MAX_TIMEOUT)
 		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you _sure_ this is doing the same thing?

Quoted 5 lines
Quoted 2 lines

Adding 1 to a u64 pointer increments it by a full u64. So I guess the cast to u32 * moves it only by a u32? Hopefully? That's messy.

The new code is mostly better.
But is different on BE systems - who knows what is actually needed.

Yeah, the endian issues here are totally ignored, my proposal would ensure it stays the same. The change here breaks this on big endian systems. So I'll drop this patch for now and just apply the first 2.

Quoted 8 lines

Depends what is being copied.

Actually I suspect that 'iobase' should be an __iomem structure pointer, pqwCurrTSF a point of the same type and MAC_REG_xxxx structure members.

Then the code should be using readl() not ioread32(). I very much doubt that 'iobase' is in PCI IO space.

Who knows, but that should be unwound eventually...

thanks,

greg k-h

#7 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

In reply to David Laight
Quoted 6 lines · David Laight

Actually I suspect that 'iobase' should be an __iomem structure pointer, pqwCurrTSF a point of the same type and MAC_REG_xxxx structure members.

Then the code should be using readl() not ioread32(). I very much doubt that 'iobase' is in PCI IO space.

Hi David,

here some infos and questions:

kernel@matrix-ESPRIMO-P710:~/Documents/git/kernels/staging$ sudo lspci -s 01:05.0 -vvv
01:05.0 Network controller: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g
	Subsystem: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g
	Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- 
Stepping+ SERR- FastB2B- DisINTx-
	Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- 
<TAbort- <MAbort- >SERR- <PERR- INTx-
	Latency: 32 (8000ns max), Cache Line Size: 64 bytes
	Interrupt: pin A routed to IRQ 19
	Region 0: Memory at f7c00000 (32-bit, non-prefetchable) [size=256]
	Region 1: I/O ports at e000 [size=256]
	Capabilities: [50] Power Management version 2
		Flags: PMEClk- DSI- D1+ D2+ AuxCurrent=0mA PME(D0-,D1+,D2+,D3hot+,D3cold-)
		Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
	Kernel driver in use: vt6655
	Kernel modules: vt6655_stage

---- In file device_main.c line 1699

	priv->memaddr = pci_resource_start(pcid, 0);
	priv->ioaddr = pci_resource_start(pcid, 1);
	priv->port_offset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK, 
256);
	dev_info(&pcid->dev, "vt6655_probe priv->memaddr: %x priv->ioaddr: %x", 

priv->memaddr, priv->ioaddr);

----- Output:
[ +0.000018] vt6655 0000:01:05.0: vt6655_probe priv->memaddr: f7c00000 priv->ioaddr: e000

So port_offset is derived from memaddr.

----- In file card.c line 742
bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)

{
	void __iomem *iobase = priv->port_offset;
...
	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);

Please tell me if you need further infos to see if it is PCI IO space. I think it is memory-mapped.

So is ioread32 wrong, right or can it be used?

This article gives more info:
https://www.kernel.org/doc/html/latest/driver-api/device-io.html

Thanks for your support.

Bye Philipp

#8 lore raw

RE: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

From: Philipp Hortmann

Quoted 17 lines

Sent: 27 April 2022 20:10

Quoted 6 lines · David Laight

Actually I suspect that 'iobase' should be an __iomem structure pointer, pqwCurrTSF a point of the same type and MAC_REG_xxxx structure members.

Then the code should be using readl() not ioread32(). I very much doubt that 'iobase' is in PCI IO space.

Hi David,

here some infos and questions:

$ sudo lspci -s 01:05.0 -vvv
01:05.0 Network controller: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g
	Subsystem: VIA Technologies, Inc. VT6655 WiFi Adapter, 802.11a/b/g

...

Quoted 2 lines
	Region 0: Memory at f7c00000 (32-bit, non-prefetchable) [size=256]
	Region 1: I/O ports at e000 [size=256]

...

Quoted 4 lines

---- In file device_main.c line 1699

	priv->memaddr = pci_resource_start(pcid, 0);
	priv->ioaddr = pci_resource_start(pcid, 1);
	priv->port_offset = ioremap(priv->memaddr & PCI_BASE_ADDRESS_MEM_MASK, 256);

WTF is that mask?
The driver code I've got just uses pci_iomap(pci_dev, bar_number, length); It then uses pci_iounmap(pci_dev, vaddr) to free it.

Quoted 13 lines
	dev_info(&pcid->dev, "vt6655_probe priv->memaddr: %x priv->ioaddr: %x",

priv->memaddr, priv->ioaddr);

----- Output:
[ +0.000018] vt6655 0000:01:05.0: vt6655_probe priv->memaddr: f7c00000 priv->ioaddr: e000

So port_offset is derived from memaddr.

----- In file card.c line 742
bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)

Quoted 7 lines
{
	void __iomem *iobase = priv->port_offset;
...
	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);

Please tell me if you need further infos to see if it is PCI IO space. I think it is memory-mapped.

BAR 0 is memory, BAR 1 I/O, both almost certainly refer to the same physical device registers.
Basically PCI(e) I/O space is (mostly) deprecated.
It (sort of) exists so that PCI hardware could replace very old (eg ISA) hardware without requiring driver changes.

Quoted 1 line

So is ioread32 wrong, right or can it be used?

(Assuming x86)
ioread32() has to contain a test to see whether the address is an 'io address' or a 'memory address'.
For the former an 'inw' instruction is executed for the latter a normal memory access instruction.
OTOH readl() is just a memory access (with compiler barriers) and is inlined into the driver object.

So if you used priv->ioaddr you'd have to use ioread32(). Since you are using the memory space addresses from BAR 0 you can use ioread32() but it is more efficient to use readl().

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)

#9 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

In reply to Greg Kroah-Hartman
Quoted 4 lines · Greg Kroah-Hartman
Quoted 4 lines

MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {

(quoted diff) +0 -0
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
  	}
Quoted 9 lines

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 7 lines
drivers/staging/vt6655/card.c +3 -2
  	if (ww == W_MAX_TIMEOUT)
  		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you_sure_ this is doing the same thing?

To compare I used the following code:
VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF); VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1); dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: %llx", *pqwCurrTSF); low = ioread32(iobase + MAC_REG_TSFCNTR);
high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF low/high: %llx", low + ((u64)high << 32));

Output:
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd8a
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd8a

So no different results for numbers larger than 32 Bit.

The pqwCurrTSF is a microsecond counter running in the WLAN Router:
At a later Measurement I got the following values:
269 seconds later: 0x3 6d89 fd91 -> 269.30 seconds
15 minutes later: 0x3 6d89 fd91 -> 15.54 minutes
8:38 hours later: 0xa 9787 ad91 -> 8.62 hours

So both methods work on a AMD64 processor.

Quoted 2 lines

Adding 1 to a u64 pointer increments it by a full u64. So I guess the cast to u32 * moves it only by a u32? Hopefully? That's messy.

That is the reason why I wanted to change this.

Quoted 4 lines

Why not keep the current mess and do:

	pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	((u32 *)pqwCurTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Or does that not compile?

drivers/staging/vt6655/card.c:760:13: warning: assignment to ‘u64 *’ {aka ‘long long unsigned int *’} from ‘unsigned int’ makes pointer from integer without a cast [-Wint-conversion]
760 | pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
| ^
drivers/staging/vt6655/card.c:761:26: error: lvalue required as left operand of assignment
761 | ((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);
| ^

This compiles:

	*(u32 *)pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	*((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Log:
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 178f41d90 vt6655 0000:01:05.0: CARDbGetCurrentTSF with ioread: 178f41d90

Ick, how about:

Quoted 5 lines
	u32 *temp = (u32 *)pqwCurTSF;

	temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);

This is working:

	u32 *temp = (u32 *)pqwCurrTSF;

	*temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	*temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
Quoted 7 lines

As that duplicates the current code a bit better.

I don't know, it's like polishing dirt, in the end, it's still dirt...

How about looking at the caller of this to see what it expects to do with this information? Unwind the mess from there?

I will propose something for that.

Quoted 3 lines

thanks,

greg k-h

Thanks

Bye Philipp

#10 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

Quoted 33 lines · Philipp Hortmann
Quoted 4 lines · Greg Kroah-Hartman
Quoted 4 lines

MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {

(quoted diff) +0 -0
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
  	}
Quoted 9 lines

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 7 lines
drivers/staging/vt6655/card.c +3 -2
  	if (ww == W_MAX_TIMEOUT)
  		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you_sure_ this is doing the same thing?

To compare I used the following code:
VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF); VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1); dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: %llx", *pqwCurrTSF);
low = ioread32(iobase + MAC_REG_TSFCNTR);
high = ioread32(iobase + MAC_REG_TSFCNTR + 4); dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF low/high: %llx", low + ((u64)high << 32));

Output:
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd8a
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd8a

Quoted 1 line

So no different results for numbers larger than 32 Bit.

And for a big endian system? Do you get the same result?

Quoted 28 lines

The pqwCurrTSF is a microsecond counter running in the WLAN Router:
At a later Measurement I got the following values:
269 seconds later: 0x3 6d89 fd91 -> 269.30 seconds
15 minutes later: 0x3 6d89 fd91 -> 15.54 minutes
8:38 hours later: 0xa 9787 ad91 -> 8.62 hours

So both methods work on a AMD64 processor.

Quoted 2 lines

Adding 1 to a u64 pointer increments it by a full u64. So I guess the cast to u32 * moves it only by a u32? Hopefully? That's messy.

That is the reason why I wanted to change this.

Quoted 4 lines

Why not keep the current mess and do:

	pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	((u32 *)pqwCurTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Or does that not compile?

drivers/staging/vt6655/card.c:760:13: warning: assignment to ‘u64 *’ {aka ‘long long unsigned int *’} from ‘unsigned int’ makes pointer from integer without a cast [-Wint-conversion]
760 | pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
| ^
drivers/staging/vt6655/card.c:761:26: error: lvalue required as left operand of assignment
761 | ((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);
| ^

Quoted 3 lines

This compiles:

	*(u32 *)pqwCurrTSF = ioread32(iobase + MAC_REG_TSFCNTR);
	*((u32 *)pqwCurrTSF + 1) = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Heh, I just guessed :)

Quoted 11 lines

Log:
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 178f41d90 vt6655 0000:01:05.0: CARDbGetCurrentTSF with ioread: 178f41d90

Ick, how about:

Quoted 5 lines
	u32 *temp = (u32 *)pqwCurTSF;

	temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
Quoted 6 lines

This is working:

	u32 *temp = (u32 *)pqwCurrTSF;

	*temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	*temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);

Nice!

thanks for testing,

greg k-h

#11 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

Quoted 1 line · Greg Kroah-Hartman

And for a big endian system? Do you get the same result?

Just looking if I can buy one.

Can you propose a low cost big endian system with PCI bus?

Thanks for your support.

Bye Philipp

#12 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

Quoted 4 lines · Philipp Hortmann
Quoted 1 line · Greg Kroah-Hartman

And for a big endian system? Do you get the same result?

Just looking if I can buy one.

Ick, no, don't do that.

Quoted 1 line

Can you propose a low cost big endian system with PCI bus?

Try testing the code out on something like https://godbolt.org/ maybe?

I think there might be a qemu big endian target as well but I can't remember it's been a long time. Don't go buy an obsolete box just for this one old staging driver :)

thanks,

greg k-h

#13 lore raw

Re: [PATCH v3 3/3] staging: vt6655: Replace VNSvInPortD with ioread32

In reply to Greg Kroah-Hartman
Quoted 33 lines · Greg Kroah-Hartman
Quoted 32 lines · Philipp Hortmann
Quoted 4 lines · Greg Kroah-Hartman
Quoted 4 lines
MACvRegBitsOn(iobase, MAC_REG_TFTCTL, TFTCTL_TSFCNTRRD);
   	for (ww = 0; ww < W_MAX_TIMEOUT; ww++) {
(quoted diff) +0 -0
@@ -753,8 +754,9 @@ bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF)
   	}
Quoted 9 lines

drivers/staging/vt6655/card.c bool CARDbGetCurrentTSF(struct vnt_private *priv, u64 *pqwCurrTSF) · line 759

Quoted 7 lines
drivers/staging/vt6655/card.c +3 -2
   	if (ww == W_MAX_TIMEOUT)
   		return false;
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
-	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
+	low = ioread32(iobase + MAC_REG_TSFCNTR);
+	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
+	*pqwCurrTSF = low + ((u64)high << 32);

Are you_sure_ this is doing the same thing?

To compare I used the following code:
VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF); VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1); dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: %llx", *pqwCurrTSF);
low = ioread32(iobase + MAC_REG_TSFCNTR);
high = ioread32(iobase + MAC_REG_TSFCNTR + 4); dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF low/high: %llx", low + ((u64)high << 32));

Output:
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 1155ba
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd7c
vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 35d7cbd8a
vt6655 0000:01:05.0: CARDbGetCurrentTSF low/high: 35d7cbd8a

Quoted 3 lines
Quoted 1 line

So no different results for numbers larger than 32 Bit.

And for a big endian system? Do you get the same result?

Using ioread32be to simulate output of the big endian computer.

Code:

	u32 *temp = (u32 *)pqwCurrTSF;	
	
	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: 

0x%016llx", *pqwCurrTSF);

	temp++;
	*temp = ioread32be(iobase + MAC_REG_TSFCNTR);
	temp--;
	*temp = ioread32be(iobase + MAC_REG_TSFCNTR + 4);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF big-endian: 

0x%016llx", *pqwCurrTSF);

	*temp = ioread32(iobase + MAC_REG_TSFCNTR);
	temp++;
	*temp = ioread32(iobase + MAC_REG_TSFCNTR + 4);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF little endian: 

0x%016llx", *pqwCurrTSF);

Output:

[21250.521826] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 0x00 00 00 05 f8 55 1d 9b
[21250.521831] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian: 0x9b 1d 55 f8 05 00 00 00
[21250.521835] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian: 0x00 00 00 05 f8 55 1d 9b

Code 2:

	u32 high, low;
	
	VNSvInPortD(iobase + MAC_REG_TSFCNTR, (u32 *)pqwCurrTSF);
	VNSvInPortD(iobase + MAC_REG_TSFCNTR + 4, (u32 *)pqwCurrTSF + 1);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF *pqwCurrTSF: 

0x%016llx", *pqwCurrTSF);

	low = ioread32be(iobase + MAC_REG_TSFCNTR);
	high = ioread32be(iobase + MAC_REG_TSFCNTR + 4);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF big-endian: 

0x%016llx", high + ((u64)low << 32));

	low = ioread32(iobase + MAC_REG_TSFCNTR);
	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
	dev_info(&priv->pcid->dev, "CARDbGetCurrentTSF little endian: 

0x%016llx", low + ((u64)high << 32));

Output 2:

[21996.659694] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 0x00 00 00 06 24 cd 8d 91
[21996.659698] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian: 0x91 8d cd 24 06 00 00 00
[21996.659701] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian: 0x00 00 00 06 24 cd 8d 91
[22453.448296] vt6655 0000:01:05.0: CARDbGetCurrentTSF *pqwCurrTSF: 0x00 00 00 06 40 07 dd a3
[22453.448300] vt6655 0000:01:05.0: CARDbGetCurrentTSF big-endian: 0xa3 dd 07 40 06 00 00 00
[22453.448304] vt6655 0000:01:05.0: CARDbGetCurrentTSF little endian: 0x00 00 00 06 40 07 dd a3

I am assuming that in case the big endian computer is used the ioread32 will be automatically converted to ioread32be. So I have only to care about the u32 to be exchanged. That is easier with the second example.

Code:

	low = ioread32(iobase + MAC_REG_TSFCNTR);
	high = ioread32(iobase + MAC_REG_TSFCNTR + 4);
#ifdef __BIG_ENDIAN
	*pqwCurrTSF = high + ((u64)low << 32);
#else
	*pqwCurrTSF = low + ((u64)high << 32);

#endif

Comments are welcome.

This is the article that helped me a lot:
https://en.wikipedia.org/wiki/Endianness#Bit_endianness
Especially the "Endian example" picture

Thanks,
Bye Philipp