Skip to contentSkip to conversation

aic7xxx large integer

PATCH In review Miguel Angel Flores 4 participants 6 messages Dec 4, 2004 – Dec 6, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aic7xxx large integer

Hi all,

I noticed a large integer warning when compiling 2.6.10rc3 with the SCSI AIC-7xxx driver.

Here is the patch.

Cheers,
MaF

drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +1 -1
diff -r -u linux-2.6.10-rc3/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c linux-2.6.10-rc3-maf/drivers/scsi/aic7xxx/aic7xxx_osm_pci.c
@@ -226,7 +226,7 @@
 	}
 	pci_set_master(pdev);
 
-	mask_39bit = 0x7FFFFFFFFFULL;
+	mask_39bit = 0x7FFFFFFF;
 	if (sizeof(dma_addr_t) > 4
 	 && ahc_linux_get_memsize() > 0x80000000
 	 && pci_set_dma_mask(pdev, mask_39bit) == 0) {
#1 lore raw

drivers/scsi/aic7xxx/aic7xxx_osm_pci.c line 229

Quoted 7 lines · * Miguel Angel Flores ([email protected]) wrote:

Hi all,

I noticed a large integer warning when compiling 2.6.10rc3 with the SCSI AIC-7xxx driver.

drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +1 -1
-	mask_39bit = 0x7FFFFFFFFFULL;
+	mask_39bit = 0x7FFFFFFF;

Hmm - I can't help but think that perhaps
'mask_39bit' was intended to be a 39 bit mask.

Dave

-----Open up your eyes, open up your mind, open up your code -------

/ Dr. David Alan Gilbert    | Running GNU/Linux on Alpha,68K| Happy  \ 
\ gro.gilbert @ treblig.org | MIPS,x86,ARM,SPARC,PPC & HPPA | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#2 lore raw
In reply to Miguel Angel Flores

drivers/scsi/aic7xxx/aic7xxx_osm_pci.c line 229

Quoted 2 lines · Miguel Angel Flores
drivers/scsi/aic7xxx/aic7xxx_osm_pci.c +1 -1
-	mask_39bit = 0x7FFFFFFFFFULL;
+	mask_39bit = 0x7FFFFFFF;

I cannot believe that this is the correct solution and, if it is, the name of the variable ought to be changed.

More likely, I suspect that the mask wants to be 39-bits, what with its name and all.

The problem is that DMA addresses come in both 32-bit (generic) and 64-bit (high) forms. mask_39bit is a dma_addr_t so it is 64-bit if CONFIG_HIGHMEM64G and 32-bit otherwise. Possibly, the right solution is to make mask_39bit dma64_addr_t. Or, if the mapping needs to be consistent, assign a different value depending on the value of CONFIG_HIGHMEM64G.

See Documentation/DMA-*.txt for more information.

Robert Love

#3 lore raw
In reply to Miguel Angel Flores
Quoted 8 lines · Miguel Angel Flores

Hi all,

I noticed a large integer warning when compiling 2.6.10rc3 with the SCSI AIC-7xxx driver.

Here is the patch.

Cheers,
MaF

I post the patch very quickly :(. The original code finally seems OK. My controller is not working with 39 bit addressing, although I can't find why the compiler warns. Maybe the length of dma_addr_t type, in the 2.6.9 the type of the mask_39bit variable is bus_addr_t.

Forget the patch. I'll continue looking...

Thanks and excuse the inconvenience.

Cheers,
MaF

#4 lore raw
Quoted 4 lines · Miguel Angel Flores

I post the patch very quickly :(. The original code finally seems OK. My controller is not working with 39 bit addressing, although I can't find why the compiler warns. Maybe the length of dma_addr_t type, in the 2.6.9 the type of the mask_39bit variable is bus_addr_t.

The compiler warns because you are putting a 64-bit value (an unsigned long long) in a 32-bit value (a u32).

There is definitely a problem on non-highmem compiled kernels, there is no doubt of that. The concern was that your suggested fix is not right.

Assuming that a 39-bit value is really wanted, the type either needs to be changed to a dma64_addr_t or the value needs to change at compile-time to a suitable 32-bit variant when !CONFIG_HIGHMEM64G.

Without knowing what the driver is doing, I have no idea.

Robert Love

#5 lore raw
Followup to:  <1102208526.6052.87.camel@localhost>
By author:    Robert Love <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 11 lines · Miguel Angel Flores
Quoted 5 lines

I post the patch very quickly :(. The original code finally seems OK. My controller is not working with 39 bit addressing, although I can't find why the compiler warns. Maybe the length of dma_addr_t type, in the 2.6.9 the type of the mask_39bit variable is bus_addr_t.

The compiler warns because you are putting a 64-bit value (an unsigned long long) in a 32-bit value (a u32).

Quoted 9 lines

There is definitely a problem on non-highmem compiled kernels, there is no doubt of that. The concern was that your suggested fix is not right.

Assuming that a 39-bit value is really wanted, the type either needs to be changed to a dma64_addr_t or the value needs to change at compile-time to a suitable 32-bit variant when !CONFIG_HIGHMEM64G.

Without knowing what the driver is doing, I have no idea.

I suspect that what the driver wants is a mask that is a valid DMA address no wider than 39 bits (because that's all the hardware can do.)

If so, I would assume (dma_addr_t)0x7FFFFFFFFFULL is probably the right thing; it will be truncated to a 32-bit mask if only 32-bit addressing is available.

-hpa