CC: [email protected]
CC: [email protected]
TO: Thierry Reding <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   7eac66d0456fe12a462e5c14c68e97c7460989da
commit: af1cbfb9bf0fe079ca328231451fd4db8b3eafec gpu: host1x: Support DMA 
mapping of buffers
date:   10 months ago
:::::: branch date: 12 hours ago
:::::: commit date: 10 months ago
config: arm-randconfig-m031-20200820 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
drivers/gpu/host1x/job.c:165 pin_job() error: uninitialized symbol 'phys_addr'.

# 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=af1cbfb9bf0fe079ca328231451fd4db8b3eafec
git remote add linus 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout af1cbfb9bf0fe079ca328231451fd4db8b3eafec
vim +/phys_addr +165 drivers/gpu/host1x/job.c

6579324a41cc414 Terje Bergstrom 2013-03-22   99  
404bfb78daf3bed Mikko Perttunen 2016-12-14  100  static unsigned int 
pin_job(struct host1x *host, struct host1x_job *job)
6579324a41cc414 Terje Bergstrom 2013-03-22  101  {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  102         struct host1x_client 
*client = job->client;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  103         struct device *dev = 
client->dev;
6579324a41cc414 Terje Bergstrom 2013-03-22  104         unsigned int i;
404bfb78daf3bed Mikko Perttunen 2016-12-14  105         int err;
6579324a41cc414 Terje Bergstrom 2013-03-22  106  
6579324a41cc414 Terje Bergstrom 2013-03-22  107         job->num_unpins = 0;
6579324a41cc414 Terje Bergstrom 2013-03-22  108  
6579324a41cc414 Terje Bergstrom 2013-03-22  109         for (i = 0; i < 
job->num_relocs; i++) {
06490bb99e1840a Thierry Reding  2018-05-16  110                 struct 
host1x_reloc *reloc = &job->relocs[i];
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  111                 dma_addr_t 
phys_addr, *phys;
6579324a41cc414 Terje Bergstrom 2013-03-22  112                 struct sg_table 
*sgt;
6579324a41cc414 Terje Bergstrom 2013-03-22  113  
961e3beae3b29ae Thierry Reding  2014-06-10  114                 
reloc->target.bo = host1x_bo_get(reloc->target.bo);
404bfb78daf3bed Mikko Perttunen 2016-12-14  115                 if 
(!reloc->target.bo) {
404bfb78daf3bed Mikko Perttunen 2016-12-14  116                         err = 
-EINVAL;
6579324a41cc414 Terje Bergstrom 2013-03-22  117                         goto 
unpin;
404bfb78daf3bed Mikko Perttunen 2016-12-14  118                 }
6579324a41cc414 Terje Bergstrom 2013-03-22  119  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  120                 if 
(client->group)
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  121                         phys = 
&phys_addr;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  122                 else
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  123                         phys = 
NULL;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  124  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  125                 sgt = 
host1x_bo_pin(dev, reloc->target.bo, phys);
80327ce3d4edaa9 Thierry Reding  2019-10-28  126                 if 
(IS_ERR(sgt)) {
80327ce3d4edaa9 Thierry Reding  2019-10-28  127                         err = 
PTR_ERR(sgt);
80327ce3d4edaa9 Thierry Reding  2019-10-28  128                         goto 
unpin;
80327ce3d4edaa9 Thierry Reding  2019-10-28  129                 }
6579324a41cc414 Terje Bergstrom 2013-03-22  130  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  131                 if (sgt) {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  132                         
unsigned long mask = HOST1X_RELOC_READ |
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  133                                 
             HOST1X_RELOC_WRITE;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  134                         enum 
dma_data_direction dir;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  135  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  136                         switch 
(reloc->flags & mask) {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  137                         case 
HOST1X_RELOC_READ:
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  138                                 
dir = DMA_TO_DEVICE;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  139                                 
break;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  140  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  141                         case 
HOST1X_RELOC_WRITE:
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  142                                 
dir = DMA_FROM_DEVICE;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  143                                 
break;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  144  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  145                         case 
HOST1X_RELOC_READ | HOST1X_RELOC_WRITE:
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  146                                 
dir = DMA_BIDIRECTIONAL;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  147                                 
break;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  148  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  149                         default:
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  150                                 
err = -EINVAL;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  151                                 
goto unpin;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  152                         }
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  153  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  154                         err = 
dma_map_sg(dev, sgt->sgl, sgt->nents, dir);
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  155                         if 
(!err) {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  156                                 
err = -ENOMEM;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  157                                 
goto unpin;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  158                         }
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  159  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  160                         
job->unpins[job->num_unpins].dev = dev;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  161                         
job->unpins[job->num_unpins].dir = dir;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  162                         
phys_addr = sg_dma_address(sgt->sgl);
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  163                 }
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  164  
6579324a41cc414 Terje Bergstrom 2013-03-22 @165                 
job->addr_phys[job->num_unpins] = phys_addr;
961e3beae3b29ae Thierry Reding  2014-06-10  166                 
job->unpins[job->num_unpins].bo = reloc->target.bo;
6579324a41cc414 Terje Bergstrom 2013-03-22  167                 
job->unpins[job->num_unpins].sgt = sgt;
6579324a41cc414 Terje Bergstrom 2013-03-22  168                 
job->num_unpins++;
6579324a41cc414 Terje Bergstrom 2013-03-22  169         }
6579324a41cc414 Terje Bergstrom 2013-03-22  170  
6579324a41cc414 Terje Bergstrom 2013-03-22  171         for (i = 0; i < 
job->num_gathers; i++) {
6579324a41cc414 Terje Bergstrom 2013-03-22  172                 struct 
host1x_job_gather *g = &job->gathers[i];
404bfb78daf3bed Mikko Perttunen 2016-12-14  173                 size_t 
gather_size = 0;
404bfb78daf3bed Mikko Perttunen 2016-12-14  174                 struct 
scatterlist *sg;
6579324a41cc414 Terje Bergstrom 2013-03-22  175                 struct sg_table 
*sgt;
6579324a41cc414 Terje Bergstrom 2013-03-22  176                 dma_addr_t 
phys_addr;
404bfb78daf3bed Mikko Perttunen 2016-12-14  177                 unsigned long 
shift;
404bfb78daf3bed Mikko Perttunen 2016-12-14  178                 struct iova 
*alloc;
404bfb78daf3bed Mikko Perttunen 2016-12-14  179                 unsigned int j;
6579324a41cc414 Terje Bergstrom 2013-03-22  180  
6579324a41cc414 Terje Bergstrom 2013-03-22  181                 g->bo = 
host1x_bo_get(g->bo);
404bfb78daf3bed Mikko Perttunen 2016-12-14  182                 if (!g->bo) {
404bfb78daf3bed Mikko Perttunen 2016-12-14  183                         err = 
-EINVAL;
6579324a41cc414 Terje Bergstrom 2013-03-22  184                         goto 
unpin;
404bfb78daf3bed Mikko Perttunen 2016-12-14  185                 }
6579324a41cc414 Terje Bergstrom 2013-03-22  186  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  187                 sgt = 
host1x_bo_pin(host->dev, g->bo, NULL);
80327ce3d4edaa9 Thierry Reding  2019-10-28  188                 if 
(IS_ERR(sgt)) {
80327ce3d4edaa9 Thierry Reding  2019-10-28  189                         err = 
PTR_ERR(sgt);
80327ce3d4edaa9 Thierry Reding  2019-10-28  190                         goto 
unpin;
80327ce3d4edaa9 Thierry Reding  2019-10-28  191                 }
404bfb78daf3bed Mikko Perttunen 2016-12-14  192  
404bfb78daf3bed Mikko Perttunen 2016-12-14  193                 if 
(!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && host->domain) {
404bfb78daf3bed Mikko Perttunen 2016-12-14  194                         
for_each_sg(sgt->sgl, sg, sgt->nents, j)
404bfb78daf3bed Mikko Perttunen 2016-12-14  195                                 
gather_size += sg->length;
404bfb78daf3bed Mikko Perttunen 2016-12-14  196                         
gather_size = iova_align(&host->iova, gather_size);
404bfb78daf3bed Mikko Perttunen 2016-12-14  197  
404bfb78daf3bed Mikko Perttunen 2016-12-14  198                         shift = 
iova_shift(&host->iova);
404bfb78daf3bed Mikko Perttunen 2016-12-14  199                         alloc = 
alloc_iova(&host->iova, gather_size >> shift,
404bfb78daf3bed Mikko Perttunen 2016-12-14  200                                 
           host->iova_end >> shift, true);
404bfb78daf3bed Mikko Perttunen 2016-12-14  201                         if 
(!alloc) {
404bfb78daf3bed Mikko Perttunen 2016-12-14  202                                 
err = -ENOMEM;
404bfb78daf3bed Mikko Perttunen 2016-12-14  203                                 
goto unpin;
404bfb78daf3bed Mikko Perttunen 2016-12-14  204                         }
404bfb78daf3bed Mikko Perttunen 2016-12-14  205  
404bfb78daf3bed Mikko Perttunen 2016-12-14  206                         err = 
iommu_map_sg(host->domain,
404bfb78daf3bed Mikko Perttunen 2016-12-14  207                                 
        iova_dma_addr(&host->iova, alloc),
404bfb78daf3bed Mikko Perttunen 2016-12-14  208                                 
        sgt->sgl, sgt->nents, IOMMU_READ);
404bfb78daf3bed Mikko Perttunen 2016-12-14  209                         if (err 
== 0) {
404bfb78daf3bed Mikko Perttunen 2016-12-14  210                                 
__free_iova(&host->iova, alloc);
404bfb78daf3bed Mikko Perttunen 2016-12-14  211                                 
err = -EINVAL;
6579324a41cc414 Terje Bergstrom 2013-03-22  212                                 
goto unpin;
404bfb78daf3bed Mikko Perttunen 2016-12-14  213                         }
6579324a41cc414 Terje Bergstrom 2013-03-22  214  
404bfb78daf3bed Mikko Perttunen 2016-12-14  215                         
job->unpins[job->num_unpins].size = gather_size;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  216                         
phys_addr = iova_dma_addr(&host->iova, alloc);
404bfb78daf3bed Mikko Perttunen 2016-12-14  217                 } else {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  218                         err = 
dma_map_sg(host->dev, sgt->sgl, sgt->nents,
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  219                                 
         DMA_TO_DEVICE);
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  220                         if 
(!err) {
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  221                                 
err = -ENOMEM;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  222                                 
goto unpin;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  223                         }
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  224  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  225                         
job->unpins[job->num_unpins].dev = host->dev;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  226                         
phys_addr = sg_dma_address(sgt->sgl);
404bfb78daf3bed Mikko Perttunen 2016-12-14  227                 }
404bfb78daf3bed Mikko Perttunen 2016-12-14  228  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  229                 
job->addr_phys[job->num_unpins] = phys_addr;
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  230                 
job->gather_addr_phys[i] = phys_addr;
404bfb78daf3bed Mikko Perttunen 2016-12-14  231  
af1cbfb9bf0fe07 Thierry Reding  2019-10-28  232                 
job->unpins[job->num_unpins].dir = DMA_TO_DEVICE;
6579324a41cc414 Terje Bergstrom 2013-03-22  233                 
job->unpins[job->num_unpins].bo = g->bo;
6579324a41cc414 Terje Bergstrom 2013-03-22  234                 
job->unpins[job->num_unpins].sgt = sgt;
6579324a41cc414 Terje Bergstrom 2013-03-22  235                 
job->num_unpins++;
6579324a41cc414 Terje Bergstrom 2013-03-22  236         }
6579324a41cc414 Terje Bergstrom 2013-03-22  237  
404bfb78daf3bed Mikko Perttunen 2016-12-14  238         return 0;
6579324a41cc414 Terje Bergstrom 2013-03-22  239  
6579324a41cc414 Terje Bergstrom 2013-03-22  240  unpin:
6579324a41cc414 Terje Bergstrom 2013-03-22  241         host1x_job_unpin(job);
404bfb78daf3bed Mikko Perttunen 2016-12-14  242         return err;
6579324a41cc414 Terje Bergstrom 2013-03-22  243  }
6579324a41cc414 Terje Bergstrom 2013-03-22  244  

:::::: The code at line 165 was first introduced by commit
:::::: 6579324a41cc414009a601738b70a53d6376325c gpu: host1x: Add channel support

:::::: TO: Terje Bergstrom <[email protected]>
:::::: CC: Thierry Reding <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Attachment: .config.gz
Description: application/gzip

_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to