Skip to contentSkip to conversation

staging: slicoss: fix different address space sparse warnings

PATCH In review Peng Sun 2 participants 10 messages Sep 17, 2016 Staging

lore
Share & tools
lore

Peng Sun

author
#0 lore raw

cover staging: slicoss: fix different address space sparse warnings

commit-id d221eb9f14f9, "Add linux-next specific files for 20160909"

add several macros to fix these warnings

Peng Sun (7):
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning

 drivers/staging/slicoss/slic.h    | 46 ++++++++++++++++++++++
 drivers/staging/slicoss/slicoss.c | 82 +++++++++++++++++++++++----------------
 2 files changed, 95 insertions(+), 33 deletions(-)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 1/7 staging: slicoss: slicoss.c: fix different address space sparse warning

add IOMEM_GET_FIELD32 to get u32 value of a member of a __iomem structure;

---
 drivers/staging/slicoss/slic.h    | 7 +++++++
 drivers/staging/slicoss/slicoss.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slic.h +7 -0
index fe1d2ce..022e7f6 100644
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELD32(base, member)					\
+({									\
+	char __iomem *_base = (char __iomem *)base;			\
+	_base += offsetof(typeof(*base), member);			\
+	ioread32(_base);						\
+})
+
 #define UPDATE_STATS(largestat, newstat, oldstat)                        \
 {                                                                        \
 	if ((newstat) < (oldstat))                                       \
drivers/staging/slicoss/slicoss.c +2 -2
index 21280a3..929a0d5 100644
@@ -924,8 +924,8 @@ err_unlock_irq:
 static void slic_link_upr_complete(struct adapter *adapter, u32 isr)
 {
 	struct slic_shmemory *sm = &adapter->shmem;
-	struct slic_shmem_data *sm_data = sm->shmem_data;
-	u32 lst = sm_data->lnkstatus;
+	struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+	u32 lst = IOMEM_GET_FIELD32(sm_data, lnkstatus);
 	uint linkup;
 	unsigned char linkspeed;
 	unsigned char linkduplex;
Signature · 1 line
2.7.4
author
#2 lore raw

PATCH 2/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun

add IOMEM_GET_FIELDADDR to get address of a member of a __iomem structure; add IOMEM_GET_FIELD64 to get u64 value of a member of a __iomem structure;

---
 drivers/staging/slicoss/slic.h    | 32 +++++++++++++++++++++++++
 drivers/staging/slicoss/slicoss.c | 49 +++++++++++++++++++++++++--------------
 2 files changed, 64 insertions(+), 17 deletions(-)
drivers/staging/slicoss/slic.h +32 -0
index 022e7f6..fec9ec5 100644
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELDADDR(base, member)				\
+({									\
+	char __iomem *_base = (char __iomem *)base;			\
+	_base += offsetof(typeof(*base), member);			\
+	(void __iomem *)_base;						\
+})
+
 #define IOMEM_GET_FIELD32(base, member)					\
 ({									\
 	char __iomem *_base = (char __iomem *)base;			\
@@ -546,6 +553,31 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(_base);						\
 })
 
+#ifdef CONFIG_64BIT
+#define IOMEM_GET_FIELD64(base, member)					\
+({									\
+	char __iomem *_base = (char __iomem *)base;			\
+	_base += offsetof(typeof(*base), member);			\
+	readq(_base);							\
+})
+#else
+#define IOMEM_GET_FIELD64(base, member)					\
+({									\
+	char __iomem *_base = (char __iomem *)base;			\
+	u64 val;							\
+	_base += offsetof(typeof(*base), member);			\
+	val = ((u64)ioread8(_base + 7)) << 56;				\
+	val += ((u64)ioread8(_base + 6)) << 48;				\
+	val += ((u64)ioread8(_base + 5)) << 40;				\
+	val += ((u64)ioread8(_base + 4)) << 32;				\
+	val += ((u64)ioread8(_base + 3)) << 24;				\
+	val += ((u64)ioread8(_base + 2)) << 16;				\
+	val += ((u64)ioread8(_base + 1)) << 8;				\
+	val += ioread8(_base);						\
+	le64_to_cpu(val);						\
+})
+#endif
+
 #define UPDATE_STATS(largestat, newstat, oldstat)                        \
 {                                                                        \
 	if ((newstat) < (oldstat))                                       \
drivers/staging/slicoss/slicoss.c +32 -17

88 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#3 lore raw

PATCH 3/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun
---
 drivers/staging/slicoss/slicoss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +3 -2
index 8426392..2128963 100644
@@ -1697,9 +1697,10 @@ static void slic_init_cleanup(struct adapter *adapter)
 
 	if (adapter->shmem.shmem_data) {
 		struct slic_shmemory *sm = &adapter->shmem;
-		struct slic_shmem_data *sm_data = sm->shmem_data;
+		struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 
-		pci_free_consistent(adapter->pcidev, sizeof(*sm_data), sm_data,
+		pci_free_consistent(adapter->pcidev, sizeof(*sm_data),
+				    (void __force *)sm_data,
 				    sm->isr_phaddr);
 	}
 
Signature · 1 line
2.7.4
author
#4 lore raw

PATCH 4/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun

add IOMEM_SET_FIELD32 to set u32 value of a member of a __iomem structure;

---
 drivers/staging/slicoss/slic.h    | 7 +++++++
 drivers/staging/slicoss/slicoss.c | 8 ++++----
 2 files changed, 11 insertions(+), 4 deletions(-)
drivers/staging/slicoss/slic.h +7 -0
index fec9ec5..b9595c4 100644
@@ -553,6 +553,13 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(_base);						\
 })
 
+#define IOMEM_SET_FIELD32(value, base, member)				\
+({									\
+	char __iomem *_base = (char __iomem *)base;			\
+	_base += offsetof(typeof(*base), member);			\
+	iowrite32(value, _base);					\
+})
+
 #ifdef CONFIG_64BIT
 #define IOMEM_GET_FIELD64(base, member)					\
 ({									\
drivers/staging/slicoss/slicoss.c +4 -4
index 2128963..c92b8c5 100644
@@ -2087,15 +2087,15 @@ static irqreturn_t slic_interrupt(int irq, void *dev_id)
 	struct net_device *dev = dev_id;
 	struct adapter *adapter = netdev_priv(dev);
 	struct slic_shmemory *sm = &adapter->shmem;
-	struct slic_shmem_data *sm_data = sm->shmem_data;
+	struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 	u32 isr;
 
-	if (sm_data->isr) {
+	if (IOMEM_GET_FIELD32(sm_data, isr)) {
 		slic_write32(adapter, SLIC_REG_ICR, ICR_INT_MASK);
 		slic_flush_write(adapter);
 
-		isr = sm_data->isr;
-		sm_data->isr = 0;
+		isr = IOMEM_GET_FIELD32(sm_data, isr);
+		IOMEM_SET_FIELD32(0, sm_data, isr);
 		adapter->num_isrs++;
 		switch (adapter->card->state) {
 		case CARD_UP:
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH 5/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun
---
 drivers/staging/slicoss/slicoss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +2 -2
index c92b8c5..bf9b381 100644
@@ -2230,7 +2230,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 	struct sliccard *card = adapter->card;
 	struct net_device *dev = adapter->netdev;
 	struct slic_shmemory *sm = &adapter->shmem;
-	struct slic_shmem_data *sm_data = sm->shmem_data;
+	struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 	int rc;
 
 	/* adapter should be down at this point */
@@ -2314,7 +2314,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 	/*
 	 *    clear any pending events, then enable interrupts
 	 */
-	sm_data->isr = 0;
+	IOMEM_SET_FIELD32(0, sm_data, isr);
 	slic_write32(adapter, SLIC_REG_ISR, 0);
 	slic_write32(adapter, SLIC_REG_ICR, ICR_INT_ON);
 
Signature · 1 line
2.7.4
author
#6 lore raw

PATCH 6/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun
---
 drivers/staging/slicoss/slicoss.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/slicoss/slicoss.c +5 -5
index bf9b381..59c4fbc 100644
@@ -2603,7 +2603,7 @@ static void slic_config_pci(struct pci_dev *pcidev)
 static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 {
 	struct slic_shmemory *sm = &adapter->shmem;
-	struct slic_shmem_data *sm_data = sm->shmem_data;
+	struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 	struct slic_eeprom *peeprom;
 	struct oslic_eeprom *pOeeprom;
 	dma_addr_t phys_config;
@@ -2666,9 +2666,9 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 		}
 
 		for (;;) {
-			if (sm_data->isr) {
-				if (sm_data->isr & ISR_UPC) {
-					sm_data->isr = 0;
+			if (IOMEM_GET_FIELD32(sm_data, isr)) {
+				if (IOMEM_GET_FIELD32(sm_data, isr) & ISR_UPC) {
+					IOMEM_SET_FIELD32(0, sm_data, isr);
 					slic_write64(adapter, SLIC_REG_ISP, 0,
 						     0);
 					slic_write32(adapter, SLIC_REG_ISR, 0);
@@ -2678,7 +2678,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 					break;
 				}
 
-				sm_data->isr = 0;
+				IOMEM_SET_FIELD32(0, sm_data, isr);
 				slic_write32(adapter, SLIC_REG_ISR, 0);
 				slic_flush_write(adapter);
 			} else {
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH 7/7 staging: slicoss: slicoss.c: fix different address space sparse warning

In reply to Peng Sun
---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/slicoss/slicoss.c +1 -1
index 59c4fbc..abe7592 100644
@@ -2883,7 +2883,7 @@ static int slic_init_adapter(struct net_device *netdev,
 	if (!sm_data)
 		return -ENOMEM;
 
-	sm->shmem_data = sm_data;
+	sm->shmem_data = (struct slic_shmem_data __force __iomem *)sm_data;
 	sm->isr_phaddr = phaddr;
 	sm->lnkstatus_phaddr = phaddr + offsetof(struct slic_shmem_data,
 						 lnkstatus);
Signature · 1 line
2.7.4
maintainer
#8 lore raw

Re: [PATCH 7/7] staging: slicoss: slicoss.c: fix different address space sparse warning

Quoted 4 lines · Peng Sun
---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

And again, I can't take patches without any changelog text at all.

maintainer
#9 lore raw
In reply to Peng Sun
Quoted 4 lines · Peng Sun

commit-id d221eb9f14f9, "Add linux-next specific files for 20160909"

add several macros to fix these warnings

Quoted 15 lines

Peng Sun (7):
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning
staging: slicoss: slicoss.c: fix different address space sparse
warning

All of these had the identical subject: line, but they do different things! Please fix them up and make them unique.

thanks,

greg k-h