BCC: lkp@intel.com CC: oe-kbuild-all@lists.linux.dev CC: linux-kernel@vger.kernel.org TO: Huacai Chen tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 01f856ae6d0ca5ad0505b79bf2d22d7ca439b2a1 commit: d279134168c78ac2caa1f7cd2a846579da1c93ac LoongArch: Use TLB for ioremap() date: 7 weeks ago :::::: branch date: 17 hours ago :::::: commit date: 7 weeks ago config: loongarch-randconfig-m041-20221130 compiler: loongarch64-linux-gcc (GCC) 12.1.0 If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot | Reported-by: Dan Carpenter New smatch warnings: drivers/message/fusion/mptbase.c:1741 mpt_mapresources() warn: 'mem' from ioremap() not released on lines: 1741. Old smatch warnings: drivers/message/fusion/mptbase.c:4330 initChainBuffers() warn: returning -1 instead of -ENOMEM is sloppy drivers/message/fusion/mptbase.c:4337 initChainBuffers() warn: returning -1 instead of -ENOMEM is sloppy drivers/message/fusion/mptbase.c:4404 initChainBuffers() warn: returning -1 instead of -ENOMEM is sloppy vim +/mem +1741 drivers/message/fusion/mptbase.c ef1d8df72fce07 Prakash, Sathya 2007-07-17 1629 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1630 /** 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1631 * mpt_mapresources - map in memory mapped io 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1632 * @ioc: Pointer to pointer to IOC adapter 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1633 * 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1634 **/ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1635 static int 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1636 mpt_mapresources(MPT_ADAPTER *ioc) 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1637 { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1638 u8 __iomem *mem; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1639 int ii; e46b63b37c3296 Pravin Bathija 2009-12-02 1640 resource_size_t mem_phys; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1641 unsigned long port; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1642 u32 msize; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1643 u32 psize; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1644 int r = -ENODEV; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1645 struct pci_dev *pdev; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1646 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1647 pdev = ioc->pcidev; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1648 ioc->bars = pci_select_bars(pdev, IORESOURCE_MEM); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1649 if (pci_enable_device_mem(pdev)) { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1650 printk(MYIOC_s_ERR_FMT "pci_enable_device_mem() " 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1651 "failed\n", ioc->name); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1652 return r; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1653 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1654 if (pci_request_selected_regions(pdev, ioc->bars, "mpt")) { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1655 printk(MYIOC_s_ERR_FMT "pci_request_selected_regions() with " 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1656 "MEM failed\n", ioc->name); 20953a6277c91d Hanjun Guo 2012-08-11 1657 goto out_pci_disable_device; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1658 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1659 14d0f0b063f536 Kashyap, Desai 2009-05-29 1660 if (sizeof(dma_addr_t) > 4) { 14d0f0b063f536 Kashyap, Desai 2009-05-29 1661 const uint64_t required_mask = dma_get_required_mask 14d0f0b063f536 Kashyap, Desai 2009-05-29 1662 (&pdev->dev); 14d0f0b063f536 Kashyap, Desai 2009-05-29 1663 if (required_mask > DMA_BIT_MASK(32) b114dda6f2f10c Christophe JAILLET 2022-01-06 1664 && !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)) b114dda6f2f10c Christophe JAILLET 2022-01-06 1665 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64))) { 14d0f0b063f536 Kashyap, Desai 2009-05-29 1666 ioc->dma_mask = DMA_BIT_MASK(64); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1667 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1668 ": 64 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1669 ioc->name)); b114dda6f2f10c Christophe JAILLET 2022-01-06 1670 } else if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) b114dda6f2f10c Christophe JAILLET 2022-01-06 1671 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { 14d0f0b063f536 Kashyap, Desai 2009-05-29 1672 ioc->dma_mask = DMA_BIT_MASK(32); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1673 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1674 ": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1675 ioc->name)); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1676 } else { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1677 printk(MYIOC_s_WARN_FMT "no suitable DMA mask for %s\n", 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1678 ioc->name, pci_name(pdev)); 20953a6277c91d Hanjun Guo 2012-08-11 1679 goto out_pci_release_region; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1680 } 14d0f0b063f536 Kashyap, Desai 2009-05-29 1681 } else { b114dda6f2f10c Christophe JAILLET 2022-01-06 1682 if (!dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)) b114dda6f2f10c Christophe JAILLET 2022-01-06 1683 && !dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32))) { 14d0f0b063f536 Kashyap, Desai 2009-05-29 1684 ioc->dma_mask = DMA_BIT_MASK(32); 14d0f0b063f536 Kashyap, Desai 2009-05-29 1685 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT 14d0f0b063f536 Kashyap, Desai 2009-05-29 1686 ": 32 BIT PCI BUS DMA ADDRESSING SUPPORTED\n", 14d0f0b063f536 Kashyap, Desai 2009-05-29 1687 ioc->name)); 14d0f0b063f536 Kashyap, Desai 2009-05-29 1688 } else { 14d0f0b063f536 Kashyap, Desai 2009-05-29 1689 printk(MYIOC_s_WARN_FMT "no suitable DMA mask for %s\n", 14d0f0b063f536 Kashyap, Desai 2009-05-29 1690 ioc->name, pci_name(pdev)); 20953a6277c91d Hanjun Guo 2012-08-11 1691 goto out_pci_release_region; 14d0f0b063f536 Kashyap, Desai 2009-05-29 1692 } 14d0f0b063f536 Kashyap, Desai 2009-05-29 1693 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1694 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1695 mem_phys = msize = 0; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1696 port = psize = 0; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1697 for (ii = 0; ii < DEVICE_COUNT_RESOURCE; ii++) { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1698 if (pci_resource_flags(pdev, ii) & PCI_BASE_ADDRESS_SPACE_IO) { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1699 if (psize) 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1700 continue; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1701 /* Get I/O space! */ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1702 port = pci_resource_start(pdev, ii); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1703 psize = pci_resource_len(pdev, ii); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1704 } else { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1705 if (msize) 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1706 continue; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1707 /* Get memmap */ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1708 mem_phys = pci_resource_start(pdev, ii); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1709 msize = pci_resource_len(pdev, ii); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1710 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1711 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1712 ioc->mem_size = msize; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1713 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1714 mem = NULL; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1715 /* Get logical ptr for PciMem0 space */ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1716 /*mem = ioremap(mem_phys, msize);*/ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1717 mem = ioremap(mem_phys, msize); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1718 if (mem == NULL) { 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1719 printk(MYIOC_s_ERR_FMT ": ERROR - Unable to map adapter" 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1720 " memory!\n", ioc->name); 20953a6277c91d Hanjun Guo 2012-08-11 1721 r = -EINVAL; 20953a6277c91d Hanjun Guo 2012-08-11 1722 goto out_pci_release_region; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1723 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1724 ioc->memmap = mem; e46b63b37c3296 Pravin Bathija 2009-12-02 1725 dinitprintk(ioc, printk(MYIOC_s_INFO_FMT "mem = %p, mem_phys = %llx\n", e46b63b37c3296 Pravin Bathija 2009-12-02 1726 ioc->name, mem, (unsigned long long)mem_phys)); 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1727 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1728 ioc->mem_phys = mem_phys; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1729 ioc->chip = (SYSIF_REGS __iomem *)mem; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1730 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1731 /* Save Port IO values in case we need to do downloadboot */ 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1732 ioc->pio_mem_phys = port; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1733 ioc->pio_chip = (SYSIF_REGS __iomem *)port; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1734 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1735 return 0; 20953a6277c91d Hanjun Guo 2012-08-11 1736 20953a6277c91d Hanjun Guo 2012-08-11 1737 out_pci_release_region: 20953a6277c91d Hanjun Guo 2012-08-11 1738 pci_release_selected_regions(pdev, ioc->bars); 20953a6277c91d Hanjun Guo 2012-08-11 1739 out_pci_disable_device: 20953a6277c91d Hanjun Guo 2012-08-11 1740 pci_disable_device(pdev); 20953a6277c91d Hanjun Guo 2012-08-11 @1741 return r; 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1742 } 4d4109d0eb6930 Prakash, Sathya 2008-03-07 1743 :::::: The code at line 1741 was first introduced by commit :::::: 20953a6277c91d5edf2e494ba5035d07ff4d1885 [SCSI] Fusion MPT: disable pci device when mpt map resoures failed :::::: TO: Hanjun Guo :::::: CC: James Bottomley -- 0-DAY CI Kernel Test Service https://01.org/lkp