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


Groups > linux.kernel > #1361815

RE: drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of expression

From "Allen Hubbe" <Allen.Hubbe@emc.com>
Newsgroups linux.kernel
Subject RE: drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of expression
Date 2016-03-21 14:20 +0100
Message-ID <rf7Ut-6aS-9@gated-at.bofh.it> (permalink)
References <reqwa-1bU-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


> >> drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of
> expression
>    drivers/ntb/hw/amd/ntb_hw_amd.c:427:31: sparse: cast removes address space of
> expression

>    360	static int amd_ntb_peer_db_addr(struct ntb_dev *ntb,
>    361					phys_addr_t *db_addr,
>    362					resource_size_t *db_size)
>    363	{
>    364		struct amd_ntb_dev *ndev = ntb_ndev(ntb);
>    365
>    366		if (db_addr)
>  > 367			*db_addr = (phys_addr_t)(ndev->peer_mmio + AMD_DBREQ_OFFSET);

This is a good warning.  The code here does look wrong (both lines 367 and 427).

Instead of peer_mmio, the code here should use pci_resource_start(pcidev, 0) + AMD_PEER_OFFSET.  For comparison, in ntb_hw_intel the offset is based on a physical address stored in peer_addr, not the virtual mapping of that address in peer_mmio.

Look at ntb_hw_amd around lines 1016 where self_mmio and peer_mmio are set up.  The register physical address is never saved in the ndev object, only the virtual address is saved, therefore the physical address would need to be retrieved with pci_resoruce_start wherever it is used in the ntb_hw_amd driver.

Alternatively, the offending functions could be deleted until they are added later, after they have been tested.  Note that the ntb_foo_addr functions are an optional part of the api for drivers to implement.

Allen

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address  space of expression kbuild test robot <fengguang.wu@intel.com> - 2016-03-19 16:00 +0100
  RE: drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of expression "Allen Hubbe" <Allen.Hubbe@emc.com> - 2016-03-21 14:20 +0100

csiph-web