[PATCH] ACPI: ioremap: avoid redundant rounding to OS page size

kernel test robot lkp at intel.com
Mon Aug 17 13:06:45 EDT 2020


Hi Ard,

I love your patch! Perhaps something to improve:

[auto build test WARNING on pm/linux-next]
[also build test WARNING on arm64/for-next/core arm/for-next soc/for-next v5.9-rc1 next-20200817]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ard-Biesheuvel/ACPI-ioremap-avoid-redundant-rounding-to-OS-page-size/20200817-200603
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
config: x86_64-randconfig-s022-20200817 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-180-g49f7e13a-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/acpi/osl.c:362:19: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected void [noderef] __iomem *virt @@     got void * @@
>> drivers/acpi/osl.c:362:19: sparse:     expected void [noderef] __iomem *virt
>> drivers/acpi/osl.c:362:19: sparse:     got void *
   drivers/acpi/osl.c:377:17: sparse: sparse: cast removes address space '__iomem' of expression
   drivers/acpi/osl.c:714:1: sparse: sparse: context imbalance in 'acpi_os_read_memory' - wrong count at exit
   drivers/acpi/osl.c:747:1: sparse: sparse: context imbalance in 'acpi_os_write_memory' - wrong count at exit

# https://github.com/0day-ci/linux/commit/a34cc34917319aed90ebf9b0fbf4146666f5f75d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Ard-Biesheuvel/ACPI-ioremap-avoid-redundant-rounding-to-OS-page-size/20200817-200603
git checkout a34cc34917319aed90ebf9b0fbf4146666f5f75d
vim +362 drivers/acpi/osl.c

   308	
   309	/**
   310	 * acpi_os_map_iomem - Get a virtual address for a given physical address range.
   311	 * @phys: Start of the physical address range to map.
   312	 * @size: Size of the physical address range to map.
   313	 *
   314	 * Look up the given physical address range in the list of existing ACPI memory
   315	 * mappings.  If found, get a reference to it and return a pointer to it (its
   316	 * virtual address).  If not found, map it, add it to that list and return a
   317	 * pointer to it.
   318	 *
   319	 * During early init (when acpi_permanent_mmap has not been set yet) this
   320	 * routine simply calls __acpi_map_table() to get the job done.
   321	 */
   322	void __iomem __ref
   323	*acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
   324	{
   325		struct acpi_ioremap *map;
   326		void __iomem *virt;
   327		acpi_physical_address pg_off;
   328		acpi_size pg_sz;
   329	
   330		if (phys > ULONG_MAX) {
   331			printk(KERN_ERR PREFIX "Cannot map memory that high\n");
   332			return NULL;
   333		}
   334	
   335		if (!acpi_permanent_mmap)
   336			return __acpi_map_table((unsigned long)phys, size);
   337	
   338		mutex_lock(&acpi_ioremap_lock);
   339		/* Check if there's a suitable mapping already. */
   340		map = acpi_map_lookup(phys, size);
   341		if (map) {
   342			map->track.refcount++;
   343			goto out;
   344		}
   345	
   346		map = kzalloc(sizeof(*map), GFP_KERNEL);
   347		if (!map) {
   348			mutex_unlock(&acpi_ioremap_lock);
   349			return NULL;
   350		}
   351	
   352		pg_off = round_down(phys, PAGE_SIZE);
   353		pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
   354		virt = acpi_map(phys, size);
   355		if (!virt) {
   356			mutex_unlock(&acpi_ioremap_lock);
   357			kfree(map);
   358			return NULL;
   359		}
   360	
   361		INIT_LIST_HEAD(&map->list);
 > 362		map->virt = (void *)((unsigned long)virt & PAGE_MASK);
   363		map->phys = pg_off;
   364		map->size = pg_sz;
   365		map->track.refcount = 1;
   366	
   367		list_add_tail_rcu(&map->list, &acpi_ioremaps);
   368	
   369	out:
   370		mutex_unlock(&acpi_ioremap_lock);
   371		return virt;
   372	}
   373	EXPORT_SYMBOL_GPL(acpi_os_map_iomem);
   374	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 41158 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20200818/d3997575/attachment-0001.gz>


More information about the linux-arm-kernel mailing list