Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1524101 > unrolled thread

[PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

Started bySergio Paracuellos <sergio.paracuellos@gmail.com>
First post2016-11-17 06:50 +0100
Last post2016-11-18 08:50 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-17 06:50 +0100
    Re: [PATCH v3 1/2] staging: slicoss: fix different address space  warnings: 32 bits Dan Carpenter <dan.carpenter@oracle.com> - 2016-11-17 12:00 +0100
      Re: [PATCH v3 1/2] staging: slicoss: fix different address space  warnings: 32 bits Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-17 12:30 +0100
        Re: [PATCH v3 1/2] staging: slicoss: fix different address space  warnings: 32 bits Dan Carpenter <dan.carpenter@oracle.com> - 2016-11-17 12:40 +0100
          Re: [PATCH v3 1/2] staging: slicoss: fix different address space  warnings: 32 bits Sergio Paracuellos <sergio.paracuellos@gmail.com> - 2016-11-17 12:50 +0100
            Re: [PATCH v3 1/2] staging: slicoss: fix different address space  warnings: 32 bits Greg KH <gregkh@linuxfoundation.org> - 2016-11-18 08:50 +0100

#1524101 — [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-17 06:50 +0100
Subject[PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEnK9-4VC-9@gated-at.bofh.it>
This patch fix the following sparse warnings in slicoss driver:
warning: incorrect type in assignment (different address spaces)

This changes are for 32 bit architectures.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/slicoss/slic.h    |  9 +++++
 drivers/staging/slicoss/slicoss.c | 82 ++++++++++++++++++++++-----------------
 2 files changed, 56 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 420546d..d637ab1 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -540,6 +540,15 @@ static inline void slic_flush_write(struct adapter *adapter)
 	ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+static inline u64 slic_ioread64(void __iomem *mmio)
+{
+	u64 low, high;
+
+	low = ioread32(mmio);
+	high = ioread32(mmio + sizeof(u32));
+	return low | (high << 32);
+}
+
 #define UPDATE_STATS(largestat, newstat, oldstat)                        \
 {                                                                        \
 	if ((newstat) < (oldstat))                                       \
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index d2929b9..c0bc1a8 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -923,8 +923,8 @@ static int slic_upr_request(struct adapter *adapter,
 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 = ioread32(&sm_data->lnkstatus);
 	uint linkup;
 	unsigned char linkspeed;
 	unsigned char linkduplex;
@@ -1003,8 +1003,8 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 	switch (upr->upr_request) {
 	case SLIC_UPR_STATS: {
 		struct slic_shmemory *sm = &adapter->shmem;
-		struct slic_shmem_data *sm_data = sm->shmem_data;
-		struct slic_stats *stats = &sm_data->stats;
+		struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+		struct slic_stats __iomem *stats = &sm_data->stats;
 		struct slic_stats *old = &adapter->inicstats_prev;
 		struct slicnet_stats *stst = &adapter->slic_stats;
 
@@ -1014,50 +1014,62 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
 			break;
 		}
 
-		UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
+		UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
+				slic_ioread64(&stats->xmit_tcp_segs),
 				old->xmit_tcp_segs);
 
-		UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
+		UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
+				slic_ioread64(&stats->xmit_tcp_bytes),
 				old->xmit_tcp_bytes);
 
-		UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs, stats->rcv_tcp_segs,
+		UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
+				slic_ioread64(&stats->rcv_tcp_segs),
 				old->rcv_tcp_segs);
 
-		UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes, stats->rcv_tcp_bytes,
+		UPDATE_STATS_GB(stst->tcp.rcv_tcp_bytes,
+				slic_ioread64(&stats->rcv_tcp_bytes),
 				old->rcv_tcp_bytes);
 
-		UPDATE_STATS_GB(stst->iface.xmt_bytes, stats->xmit_bytes,
+		UPDATE_STATS_GB(stst->iface.xmt_bytes,
+				slic_ioread64(&stats->xmit_bytes),
 				old->xmit_bytes);
 
-		UPDATE_STATS_GB(stst->iface.xmt_ucast, stats->xmit_unicasts,
+		UPDATE_STATS_GB(stst->iface.xmt_ucast,
+				slic_ioread64(&stats->xmit_unicasts),
 				old->xmit_unicasts);
 
-		UPDATE_STATS_GB(stst->iface.rcv_bytes, stats->rcv_bytes,
+		UPDATE_STATS_GB(stst->iface.rcv_bytes,
+				slic_ioread64(&stats->rcv_bytes),
 				old->rcv_bytes);
 
-		UPDATE_STATS_GB(stst->iface.rcv_ucast, stats->rcv_unicasts,
+		UPDATE_STATS_GB(stst->iface.rcv_ucast,
+				slic_ioread64(&stats->rcv_unicasts),
 				old->rcv_unicasts);
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_collisions,
+		UPDATE_STATS_GB(stst->iface.xmt_errors,
+				slic_ioread64(&stats->xmit_collisions),
 				old->xmit_collisions);
 
 		UPDATE_STATS_GB(stst->iface.xmt_errors,
-				stats->xmit_excess_collisions,
+				slic_ioread64(&stats->xmit_excess_collisions),
 				old->xmit_excess_collisions);
 
-		UPDATE_STATS_GB(stst->iface.xmt_errors, stats->xmit_other_error,
+		UPDATE_STATS_GB(stst->iface.xmt_errors,
+				slic_ioread64(&stats->xmit_other_error),
 				old->xmit_other_error);
 
-		UPDATE_STATS_GB(stst->iface.rcv_errors, stats->rcv_other_error,
+		UPDATE_STATS_GB(stst->iface.rcv_errors,
+				slic_ioread64(&stats->rcv_other_error),
 				old->rcv_other_error);
 
-		UPDATE_STATS_GB(stst->iface.rcv_discards, stats->rcv_drops,
+		UPDATE_STATS_GB(stst->iface.rcv_discards,
+				slic_ioread64(&stats->rcv_drops),
 				old->rcv_drops);
 
-		if (stats->rcv_drops > old->rcv_drops)
-			adapter->rcv_drops += (stats->rcv_drops -
+		if (slic_ioread64(&stats->rcv_drops) > old->rcv_drops)
+			adapter->rcv_drops += (slic_ioread64(&stats->rcv_drops) -
 					       old->rcv_drops);
-		memcpy(old, stats, sizeof(*stats));
+		memcpy_fromio(old, stats, sizeof(*stats));
 		break;
 	}
 	case SLIC_UPR_RLSR:
@@ -1679,10 +1691,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,
-				    sm->isr_phaddr);
+		pci_free_consistent(adapter->pcidev, sizeof(*sm_data),
+				    (void __force *)sm_data, sm->isr_phaddr);
 	}
 
 	if (adapter->pingtimerset) {
@@ -2068,15 +2080,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 (ioread32(&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 = ioread32(&sm_data->isr);
+		iowrite32(0, &sm_data->isr);
 		adapter->num_isrs++;
 		switch (adapter->card->state) {
 		case CARD_UP:
@@ -2211,7 +2223,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 */
@@ -2295,7 +2307,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 	/*
 	 *    clear any pending events, then enable interrupts
 	 */
-	sm_data->isr = 0;
+	iowrite32(0, &sm_data->isr);
 	slic_write32(adapter, SLIC_REG_ISR, 0);
 	slic_write32(adapter, SLIC_REG_ICR, ICR_INT_ON);
 
@@ -2584,7 +2596,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;
@@ -2647,9 +2659,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 (ioread32(&sm_data->isr)) {
+				if (ioread32(&sm_data->isr) & ISR_UPC) {
+					iowrite32(0, &sm_data->isr);
 					slic_write64(adapter, SLIC_REG_ISP, 0,
 						     0);
 					slic_write32(adapter, SLIC_REG_ISR, 0);
@@ -2659,7 +2671,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 					break;
 				}
 
-				sm_data->isr = 0;
+				iowrite32(0, &sm_data->isr);
 				slic_write32(adapter, SLIC_REG_ISR, 0);
 				slic_flush_write(adapter);
 			} else {
@@ -2862,7 +2874,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);
-- 
1.9.1

[toc] | [next] | [standalone]


#1524346 — Re: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-11-17 12:00 +0100
SubjectRe: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEsAa-838-35@gated-at.bofh.it>
In reply to#1524101
Hm...  I seem to duplicate the Sparse warnings at all.  That's weird.

Anyway as far as I can tell the warnings are false positives...  Can't
you just remove the __iomem tag?  Have you tested this change?

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1524395 — Re: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-17 12:30 +0100
SubjectRe: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEt3c-8sS-9@gated-at.bofh.it>
In reply to#1524346
On Thu, Nov 17, 2016 at 11:51 AM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> Hm...  I seem to duplicate the Sparse warnings at all.  That's weird.
>

With this patch applied, sparse warnings dissapear for me... That's weird.

> Anyway as far as I can tell the warnings are false positives...  Can't
> you just remove the __iomem tag?  Have you tested this change?
>
I haven' t tested this change because I can't test it :(. Do you think
that just removing
__iomem tag is enough? Maybe we can get feedback from Lior or someone.

Thanks for your review time, Dan.

Cheers,
     Sergio Paracuellos

[toc] | [prev] | [next] | [standalone]


#1524399 — Re: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-11-17 12:40 +0100
SubjectRe: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEtcR-8vW-5@gated-at.bofh.it>
In reply to#1524395
On Thu, Nov 17, 2016 at 12:22:00PM +0100, Sergio Paracuellos wrote:
> On Thu, Nov 17, 2016 at 11:51 AM, Dan Carpenter
> <dan.carpenter@oracle.com> wrote:
> > Hm...  I seem to duplicate the Sparse warnings at all.  That's weird.
> >
> 
> With this patch applied, sparse warnings dissapear for me... That's weird.
>

I understand that.

> > Anyway as far as I can tell the warnings are false positives...  Can't
> > you just remove the __iomem tag?  Have you tested this change?
> >
> I haven' t tested this change because I can't test it :(. Do you think
> that just removing
> __iomem tag is enough?

Give it a shot and see if the warnings go away.  I don't think the tag
is correct.

regards,
dan carpenter

[toc] | [prev] | [next] | [standalone]


#1524407 — Re: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromSergio Paracuellos <sergio.paracuellos@gmail.com>
Date2016-11-17 12:50 +0100
SubjectRe: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEtmy-7P-25@gated-at.bofh.it>
In reply to#1524399
On Thu, Nov 17, 2016 at 12:33 PM, Dan Carpenter
<dan.carpenter@oracle.com> wrote:
> Give it a shot and see if the warnings go away.  I don't think the tag
> is correct.

Just removing __iomem tag in shmem_data field of slic_shmemory struct
makes sparse happy. No warnings around.

Should I send a v4 patch with the tag removed?

Cheers,
    Sergio Paracuellos

[toc] | [prev] | [next] | [standalone]


#1525048 — Re: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits

FromGreg KH <gregkh@linuxfoundation.org>
Date2016-11-18 08:50 +0100
SubjectRe: [PATCH v3 1/2] staging: slicoss: fix different address space warnings: 32 bits
Message-ID<sEM5P-46F-1@gated-at.bofh.it>
In reply to#1524407
On Thu, Nov 17, 2016 at 12:46:12PM +0100, Sergio Paracuellos wrote:
> On Thu, Nov 17, 2016 at 12:33 PM, Dan Carpenter
> <dan.carpenter@oracle.com> wrote:
> > Give it a shot and see if the warnings go away.  I don't think the tag
> > is correct.
> 
> Just removing __iomem tag in shmem_data field of slic_shmemory struct
> makes sparse happy. No warnings around.
> 
> Should I send a v4 patch with the tag removed?

Yes, please fix up this series and resend.

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web