* [PATCH] qlogicpti: Fix compiler warnings
@ 2016-11-23 21:29 Tushar Dave
2016-11-23 22:57 ` James Bottomley
0 siblings, 1 reply; 6+ messages in thread
From: Tushar Dave @ 2016-11-23 21:29 UTC (permalink / raw)
To: jejb, martin.petersen, linux-scsi, thomas.tai, sparclinux
qlogicpti uses '__u32' for dma handle while invoking kernel DMA APIs,
instead of using dma_addr_t. This hasn't caused any 'incompatible
pointer type' warning on SPARC because until now dma_addr_t is of
type u32. However, recent changes in SPARC ATU (iommu) enabled 64bit
DMA and therefore dma_addr_t became of type u64. This makes
'incompatible pointer type' warnings inevitable.
e.g.
drivers/scsi/qlogicpti.c: In function ‘qpti_map_queues’:
drivers/scsi/qlogicpti.c:813: warning: passing argument 3 of ‘dma_alloc_coherent’ from incompatible pointer type
./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but argument is of type ‘__u32 *’
drivers/scsi/qlogicpti.c:822: warning: passing argument 3 of ‘dma_alloc_coherent’ from incompatible pointer type
./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but argument is of type ‘__u32 *’
This patch resolves above compiler warnings.
Signed-off-by: Tushar Dave <tushar.n.dave@oracle.com>
Reviewed-by: thomas tai <thomas.tai@oracle.com>
---
drivers/scsi/qlogicpti.c | 10 ++++++----
drivers/scsi/qlogicpti.h | 4 ++--
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 69bfc0a..e25ad8c 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -315,6 +315,8 @@ static inline void qlogicpti_set_hostdev_defaults(struct qlogicpti *qpti)
static int qlogicpti_reset_hardware(struct Scsi_Host *host)
{
struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
+ __u32 qres_dvma = (__u32)qpti->res_dvma;
+ __u32 qreq_dvma = (__u32)qpti->req_dvma;
u_short param[6];
unsigned short risc_code_addr;
int loop_count, i;
@@ -391,8 +393,8 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)
param[0] = MBOX_INIT_RES_QUEUE;
param[1] = RES_QUEUE_LEN + 1;
- param[2] = (u_short) (qpti->res_dvma >> 16);
- param[3] = (u_short) (qpti->res_dvma & 0xffff);
+ param[2] = (u_short)(qres_dvma >> 16);
+ param[3] = (u_short)(qres_dvma & 0xffff);
param[4] = param[5] = 0;
if (qlogicpti_mbox_command(qpti, param, 1)) {
printk(KERN_EMERG "qlogicpti%d: Cannot init response queue.\n",
@@ -403,8 +405,8 @@ static int qlogicpti_reset_hardware(struct Scsi_Host *host)
param[0] = MBOX_INIT_REQ_QUEUE;
param[1] = QLOGICPTI_REQ_QUEUE_LEN + 1;
- param[2] = (u_short) (qpti->req_dvma >> 16);
- param[3] = (u_short) (qpti->req_dvma & 0xffff);
+ param[2] = (u_short)(qreq_dvma >> 16);
+ param[3] = (u_short)(qreq_dvma & 0xffff);
param[4] = param[5] = 0;
if (qlogicpti_mbox_command(qpti, param, 1)) {
printk(KERN_EMERG "qlogicpti%d: Cannot init request queue.\n",
diff --git a/drivers/scsi/qlogicpti.h b/drivers/scsi/qlogicpti.h
index 4377e87..892a0b0 100644
--- a/drivers/scsi/qlogicpti.h
+++ b/drivers/scsi/qlogicpti.h
@@ -356,8 +356,8 @@ struct qlogicpti {
/* The rest of the elements are unimportant for performance. */
struct qlogicpti *next;
- __u32 res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/
- __u32 req_dvma; /* Ptr to REQUEST bufs (DVMA) */
+ dma_addr_t res_dvma; /* Ptr to RESPONSE bufs (DVMA)*/
+ dma_addr_t req_dvma; /* Ptr to REQUEST bufs (DVMA) */
u_char fware_majrev, fware_minrev, fware_micrev;
struct Scsi_Host *qhost;
int qpti_id;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] qlogicpti: Fix compiler warnings
2016-11-23 21:29 [PATCH] qlogicpti: Fix compiler warnings Tushar Dave
@ 2016-11-23 22:57 ` James Bottomley
2016-11-24 1:08 ` tndave
2016-11-24 1:24 ` David Miller
0 siblings, 2 replies; 6+ messages in thread
From: James Bottomley @ 2016-11-23 22:57 UTC (permalink / raw)
To: Tushar Dave, martin.petersen, linux-scsi, thomas.tai, sparclinux
On Wed, 2016-11-23 at 13:29 -0800, Tushar Dave wrote:
> qlogicpti uses '__u32' for dma handle while invoking kernel DMA APIs,
> instead of using dma_addr_t. This hasn't caused any 'incompatible
> pointer type' warning on SPARC because until now dma_addr_t is of
> type u32. However, recent changes in SPARC ATU (iommu) enabled 64bit
> DMA and therefore dma_addr_t became of type u64. This makes
> 'incompatible pointer type' warnings inevitable.
>
> e.g.
> drivers/scsi/qlogicpti.c: In function ‘qpti_map_queues’:
> drivers/scsi/qlogicpti.c:813: warning: passing argument 3 of
> ‘dma_alloc_coherent’ from incompatible pointer type
> ./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but
> argument is of type ‘__u32 *’
> drivers/scsi/qlogicpti.c:822: warning: passing argument 3 of
> ‘dma_alloc_coherent’ from incompatible pointer type
> ./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but
> argument is of type ‘__u32 *’
>
> This patch resolves above compiler warnings.
There appears to be no point to the first three hunks of this diff:
(ushort)(x << 16)
(ushort)(x & 0xffff)
return the same thing whether the type of x is u32 or u64, so there was
no need to alter the original code.
What's the guarantee, since the device descriptors only cope with 32
bits of physical address, that this driver never gets any dma address
beyond its addressable range? Is it that the sbus can never be
attached to this ATU type IOMMU? If so, saying that in the log would
be useful.
James
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qlogicpti: Fix compiler warnings
2016-11-23 22:57 ` James Bottomley
@ 2016-11-24 1:08 ` tndave
2016-11-24 1:25 ` David Miller
2016-11-24 1:24 ` David Miller
1 sibling, 1 reply; 6+ messages in thread
From: tndave @ 2016-11-24 1:08 UTC (permalink / raw)
To: James Bottomley, martin.petersen, linux-scsi, thomas.tai,
sparclinux
On 11/23/2016 02:57 PM, James Bottomley wrote:
> On Wed, 2016-11-23 at 13:29 -0800, Tushar Dave wrote:
>> qlogicpti uses '__u32' for dma handle while invoking kernel DMA APIs,
>> instead of using dma_addr_t. This hasn't caused any 'incompatible
>> pointer type' warning on SPARC because until now dma_addr_t is of
>> type u32. However, recent changes in SPARC ATU (iommu) enabled 64bit
>> DMA and therefore dma_addr_t became of type u64. This makes
>> 'incompatible pointer type' warnings inevitable.
>>
>> e.g.
>> drivers/scsi/qlogicpti.c: In function ‘qpti_map_queues’:
>> drivers/scsi/qlogicpti.c:813: warning: passing argument 3 of
>> ‘dma_alloc_coherent’ from incompatible pointer type
>> ./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but
>> argument is of type ‘__u32 *’
>> drivers/scsi/qlogicpti.c:822: warning: passing argument 3 of
>> ‘dma_alloc_coherent’ from incompatible pointer type
>> ./include/linux/dma-mapping.h:445: note: expected ‘dma_addr_t *’ but
>> argument is of type ‘__u32 *’
>>
>> This patch resolves above compiler warnings.
>
> There appears to be no point to the first three hunks of this diff:
>
> (ushort)(x << 16)
> (ushort)(x & 0xffff)
>
> return the same thing whether the type of x is u32 or u64, so there was
> no need to alter the original code.
Agree, will make the change.
>
> What's the guarantee, since the device descriptors only cope with 32
> bits of physical address, that this driver never gets any dma
> address beyond its addressable range? Is it that the sbus can never
> be attached to this ATU type IOMMU? If so, saying that in the log
> would be useful.
Thanks for catching this.
As per my understanding, I think, all DMA map/unmap go through
ATU (iommu) in sun4v sparc. To guarantee that driver doesn't get DMA
address beyond its addressable range , driver must set dma mask before
requesting any DMA mapping!
I will investigate further and send v2.
Thanks for the review.
-Tushar
>
> James
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qlogicpti: Fix compiler warnings
2016-11-24 1:08 ` tndave
@ 2016-11-24 1:25 ` David Miller
2016-11-24 1:44 ` tndave
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2016-11-24 1:25 UTC (permalink / raw)
To: tushar.n.dave
Cc: James.Bottomley, martin.petersen, linux-scsi, thomas.tai,
sparclinux
From: tndave <tushar.n.dave@oracle.com>
Date: Wed, 23 Nov 2016 17:08:23 -0800
> As per my understanding, I think, all DMA map/unmap go through
> ATU (iommu) in sun4v sparc. To guarantee that driver doesn't get DMA
> address beyond its addressable range , driver must set dma mask before
> requesting any DMA mapping!
>
> I will investigate further and send v2.
>
> Thanks for the review.
This is an SBUS driver, it's not going to execute on any sun4v
system.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qlogicpti: Fix compiler warnings
2016-11-24 1:25 ` David Miller
@ 2016-11-24 1:44 ` tndave
0 siblings, 0 replies; 6+ messages in thread
From: tndave @ 2016-11-24 1:44 UTC (permalink / raw)
To: David Miller
Cc: James.Bottomley, martin.petersen, linux-scsi, thomas.tai,
sparclinux
On 11/23/2016 05:25 PM, David Miller wrote:
> From: tndave <tushar.n.dave@oracle.com>
> Date: Wed, 23 Nov 2016 17:08:23 -0800
>
>> As per my understanding, I think, all DMA map/unmap go through
>> ATU (iommu) in sun4v sparc. To guarantee that driver doesn't get DMA
>> address beyond its addressable range , driver must set dma mask before
>> requesting any DMA mapping!
>>
>> I will investigate further and send v2.
>>
>> Thanks for the review.
>
> This is an SBUS driver, it's not going to execute on any sun4v
> system.
Thank you for the info, Dave.
In that case, the DMA address comes from legacy iommu and that address
is always in 32-bit range i.e. below 4G.
-Tushar
> --
> To unsubscribe from this list: send the line "unsubscribe sparclinux" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] qlogicpti: Fix compiler warnings
2016-11-23 22:57 ` James Bottomley
2016-11-24 1:08 ` tndave
@ 2016-11-24 1:24 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2016-11-24 1:24 UTC (permalink / raw)
To: James.Bottomley
Cc: tushar.n.dave, martin.petersen, linux-scsi, thomas.tai,
sparclinux
From: James Bottomley <James.Bottomley@HansenPartnership.com>
Date: Wed, 23 Nov 2016 14:57:39 -0800
> What's the guarantee, since the device descriptors only cope with 32
> bits of physical address, that this driver never gets any dma address
> beyond its addressable range? Is it that the sbus can never be
> attached to this ATU type IOMMU? If so, saying that in the log would
> be useful.
SBUS hasn't changed for 20 years and is a 32-bit bus.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-11-24 1:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-23 21:29 [PATCH] qlogicpti: Fix compiler warnings Tushar Dave
2016-11-23 22:57 ` James Bottomley
2016-11-24 1:08 ` tndave
2016-11-24 1:25 ` David Miller
2016-11-24 1:44 ` tndave
2016-11-24 1:24 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).