All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Suganath Prabu S <suganath-prabu.subramani@broadcom.com>,
	Sathya Prakash <sathya.prakash@broadcom.com>,
	Chaitra P B <chaitra.basappa@broadcom.com>,
	"James E.J. Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Hannes Reinecke <hare@suse.de>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: mpt3sas: clarify mmio pointer types
Date: Thu, 01 Mar 2018 20:59:05 -0500	[thread overview]
Message-ID: <yq1muzrxmom.fsf@oracle.com> (raw)
In-Reply-To: <20180301130729.3278022-1-arnd@arndb.de> (Arnd Bergmann's message of "Thu, 1 Mar 2018 14:07:07 +0100")


Broadcom folks: Please review!

> The newly added code mixes up phys_addr_t/resource_size_t with dma_addr_t
> and void pointers, as seen from these compiler warning:
>
> drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_base_get_chain_phys':
> drivers/scsi/mpt3sas/mpt3sas_base.c:235:21: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>   base_chain_phys  = (void *)ioc->chip_phys + MPI_FRAME_START_OFFSET +
>                      ^
> drivers/scsi/mpt3sas/mpt3sas_base.c: In function '_clone_sg_entries':
> drivers/scsi/mpt3sas/mpt3sas_base.c:427:20: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>     sgel->Address = (dma_addr_t)dst_addr_phys;
>                     ^
> drivers/scsi/mpt3sas/mpt3sas_base.c:438:7: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>        (dma_addr_t)buff_ptr_phys;
>        ^
> drivers/scsi/mpt3sas/mpt3sas_base.c:444:10: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>           (dma_addr_t)buff_ptr_phys;
>
> Both dma_addr_t and phys_addr_t may be wider than a pointer, so we must
> avoid the conversion to pointer types. This also helps readability.
>
> A second problem is treating MMIO addresses from a 'struct resource'
> as addresses that can be used for DMA on that device. In almost all
> cases, those are the same, but on some of the more obscure architectures,
> PCI memory address 0 is mapped into the CPU address space at a nonzero
> offset. I don't have a good fix for that, so I'm adding a comment here,
> plus a WARN_ON() that triggers whenever the phys_addr_t number is
> outside of the low 32-bit address space and causes a straight overflow
> when assigned to the 32-bit sgel->Address.

-- 
Martin K. Petersen	Oracle Linux Engineering

  reply	other threads:[~2018-03-02  1:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01 13:07 [PATCH] scsi: mpt3sas: clarify mmio pointer types Arnd Bergmann
2018-03-02  1:59 ` Martin K. Petersen [this message]
2018-03-05  6:45 ` Sreekanth Reddy
2018-03-06 18:09 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yq1muzrxmom.fsf@oracle.com \
    --to=martin.petersen@oracle.com \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=arnd@arndb.de \
    --cc=chaitra.basappa@broadcom.com \
    --cc=hare@suse.de \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.