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


Groups > linux.kernel > #1361126 > unrolled thread

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

Started bykbuild test robot <fengguang.wu@intel.com>
First post2016-03-19 16:00 +0100
Last post2016-03-21 14:20 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  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

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

Fromkbuild test robot <fengguang.wu@intel.com>
Date2016-03-19 16:00 +0100
Subjectdrivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of expression
Message-ID<reqwa-1bU-7@gated-at.bofh.it>
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   6b5f04b6cf8ebab9a65d9c0026c650bb2538fd0f
commit: a1b3695820aa490e58915d720a1438069813008b NTB: Add support for AMD PCI-Express Non-Transparent Bridge
date:   8 weeks ago
reproduce:
        # apt-get install sparse
        git checkout a1b3695820aa490e58915d720a1438069813008b
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)

>> 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

vim +367 drivers/ntb/hw/amd/ntb_hw_amd.c

   351	
   352		spin_lock_irqsave(&ndev->db_mask_lock, flags);
   353		ndev->db_mask &= ~db_bits;
   354		writew((u16)ndev->db_mask, mmio + AMD_DBMASK_OFFSET);
   355		spin_unlock_irqrestore(&ndev->db_mask_lock, flags);
   356	
   357		return 0;
   358	}
   359	
   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);
   368		if (db_size)
   369			*db_size = sizeof(u32);
   370	
   371		return 0;
   372	}
   373	
   374	static int amd_ntb_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
   375	{

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [next] | [standalone]


#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>
Date2016-03-21 14:20 +0100
SubjectRE: drivers/ntb/hw/amd/ntb_hw_amd.c:367:29: sparse: cast removes address space of expression
Message-ID<rf7Ut-6aS-9@gated-at.bofh.it>
In reply to#1361126
> >> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web