[sound:topic/dma-fix 149/152] sound/core/sgbuf.c:63:11: warning: variable 'prot' set but not used

kernel test robot lkp at intel.com
Wed Jun 10 12:53:40 CEST 2020


tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git topic/dma-fix
head:   cef734d7e27e6c8ecfabdc5596647ed3405ab43f
commit: f3ed524c87951046aed8fde9db74c1d66c2e6000 [149/152] ALSA: pcm: Avoid vmap() for device SG-buffers
config: i386-randconfig-s002-20200607 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-247-gcadbd124-dirty
        git checkout f3ed524c87951046aed8fde9db74c1d66c2e6000
        # save the attached .config to linux build tree
        make W=1 C=1 ARCH=i386 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

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

All warnings (new ones prefixed by >>, old ones prefixed by <<):

sound/core/sgbuf.c: In function 'snd_malloc_sgbuf_pages':
>> sound/core/sgbuf.c:63:11: warning: variable 'prot' set but not used [-Wunused-but-set-variable]
63 |  pgprot_t prot = PAGE_KERNEL;
|           ^~~~

vim +/prot +63 sound/core/sgbuf.c

51e9f2e665bf2b Takashi Iwai       2008-07-30   52  
f3ed524c879510 Takashi Iwai       2020-06-09   53  int snd_malloc_sgbuf_pages(struct device *device,
^1da177e4c3f41 Linus Torvalds     2005-04-16   54  			   size_t size, struct snd_dma_buffer *dmab,
^1da177e4c3f41 Linus Torvalds     2005-04-16   55  			   size_t *res_size)
^1da177e4c3f41 Linus Torvalds     2005-04-16   56  {
^1da177e4c3f41 Linus Torvalds     2005-04-16   57  	struct snd_sg_buf *sgbuf;
51e9f2e665bf2b Takashi Iwai       2008-07-30   58  	unsigned int i, pages, chunk, maxpages;
^1da177e4c3f41 Linus Torvalds     2005-04-16   59  	struct snd_dma_buffer tmpb;
51e9f2e665bf2b Takashi Iwai       2008-07-30   60  	struct snd_sg_page *table;
51e9f2e665bf2b Takashi Iwai       2008-07-30   61  	struct page **pgtable;
42e748a0b3251c Takashi Iwai       2018-08-08   62  	int type = SNDRV_DMA_TYPE_DEV;
42e748a0b3251c Takashi Iwai       2018-08-08  @63  	pgprot_t prot = PAGE_KERNEL;
^1da177e4c3f41 Linus Torvalds     2005-04-16   64  
^1da177e4c3f41 Linus Torvalds     2005-04-16   65  	dmab->area = NULL;
^1da177e4c3f41 Linus Torvalds     2005-04-16   66  	dmab->addr = 0;
59feddb25f9d92 Panagiotis Issaris 2006-07-25   67  	dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL);
^1da177e4c3f41 Linus Torvalds     2005-04-16   68  	if (! sgbuf)
f3ed524c879510 Takashi Iwai       2020-06-09   69  		return -ENOMEM;
42e748a0b3251c Takashi Iwai       2018-08-08   70  	if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_UC_SG) {
42e748a0b3251c Takashi Iwai       2018-08-08   71  		type = SNDRV_DMA_TYPE_DEV_UC;
42e748a0b3251c Takashi Iwai       2018-08-08   72  #ifdef pgprot_noncached
42e748a0b3251c Takashi Iwai       2018-08-08   73  		prot = pgprot_noncached(PAGE_KERNEL);
42e748a0b3251c Takashi Iwai       2018-08-08   74  #endif
42e748a0b3251c Takashi Iwai       2018-08-08   75  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16   76  	sgbuf->dev = device;
^1da177e4c3f41 Linus Torvalds     2005-04-16   77  	pages = snd_sgbuf_aligned_pages(size);
^1da177e4c3f41 Linus Torvalds     2005-04-16   78  	sgbuf->tblsize = sgbuf_align_table(pages);
51e9f2e665bf2b Takashi Iwai       2008-07-30   79  	table = kcalloc(sgbuf->tblsize, sizeof(*table), GFP_KERNEL);
51e9f2e665bf2b Takashi Iwai       2008-07-30   80  	if (!table)
^1da177e4c3f41 Linus Torvalds     2005-04-16   81  		goto _failed;
51e9f2e665bf2b Takashi Iwai       2008-07-30   82  	sgbuf->table = table;
51e9f2e665bf2b Takashi Iwai       2008-07-30   83  	pgtable = kcalloc(sgbuf->tblsize, sizeof(*pgtable), GFP_KERNEL);
51e9f2e665bf2b Takashi Iwai       2008-07-30   84  	if (!pgtable)
^1da177e4c3f41 Linus Torvalds     2005-04-16   85  		goto _failed;
51e9f2e665bf2b Takashi Iwai       2008-07-30   86  	sgbuf->page_table = pgtable;
^1da177e4c3f41 Linus Torvalds     2005-04-16   87  
51e9f2e665bf2b Takashi Iwai       2008-07-30   88  	/* allocate pages */
51e9f2e665bf2b Takashi Iwai       2008-07-30   89  	maxpages = MAX_ALLOC_PAGES;
51e9f2e665bf2b Takashi Iwai       2008-07-30   90  	while (pages > 0) {
51e9f2e665bf2b Takashi Iwai       2008-07-30   91  		chunk = pages;
51e9f2e665bf2b Takashi Iwai       2008-07-30   92  		/* don't be too eager to take a huge chunk */
51e9f2e665bf2b Takashi Iwai       2008-07-30   93  		if (chunk > maxpages)
51e9f2e665bf2b Takashi Iwai       2008-07-30   94  			chunk = maxpages;
51e9f2e665bf2b Takashi Iwai       2008-07-30   95  		chunk <<= PAGE_SHIFT;
42e748a0b3251c Takashi Iwai       2018-08-08   96  		if (snd_dma_alloc_pages_fallback(type, device,
51e9f2e665bf2b Takashi Iwai       2008-07-30   97  						 chunk, &tmpb) < 0) {
51e9f2e665bf2b Takashi Iwai       2008-07-30   98  			if (!sgbuf->pages)
c810f9039f0406 Takashi Iwai       2012-08-03   99  				goto _failed;
51e9f2e665bf2b Takashi Iwai       2008-07-30  100  			if (!res_size)
^1da177e4c3f41 Linus Torvalds     2005-04-16  101  				goto _failed;
51e9f2e665bf2b Takashi Iwai       2008-07-30  102  			size = sgbuf->pages * PAGE_SIZE;
^1da177e4c3f41 Linus Torvalds     2005-04-16  103  			break;
^1da177e4c3f41 Linus Torvalds     2005-04-16  104  		}
51e9f2e665bf2b Takashi Iwai       2008-07-30  105  		chunk = tmpb.bytes >> PAGE_SHIFT;
51e9f2e665bf2b Takashi Iwai       2008-07-30  106  		for (i = 0; i < chunk; i++) {
51e9f2e665bf2b Takashi Iwai       2008-07-30  107  			table->buf = tmpb.area;
51e9f2e665bf2b Takashi Iwai       2008-07-30  108  			table->addr = tmpb.addr;
51e9f2e665bf2b Takashi Iwai       2008-07-30  109  			if (!i)
51e9f2e665bf2b Takashi Iwai       2008-07-30  110  				table->addr |= chunk; /* mark head */
51e9f2e665bf2b Takashi Iwai       2008-07-30  111  			table++;
51e9f2e665bf2b Takashi Iwai       2008-07-30  112  			*pgtable++ = virt_to_page(tmpb.area);
51e9f2e665bf2b Takashi Iwai       2008-07-30  113  			tmpb.area += PAGE_SIZE;
51e9f2e665bf2b Takashi Iwai       2008-07-30  114  			tmpb.addr += PAGE_SIZE;
51e9f2e665bf2b Takashi Iwai       2008-07-30  115  		}
51e9f2e665bf2b Takashi Iwai       2008-07-30  116  		sgbuf->pages += chunk;
51e9f2e665bf2b Takashi Iwai       2008-07-30  117  		pages -= chunk;
51e9f2e665bf2b Takashi Iwai       2008-07-30  118  		if (chunk < maxpages)
51e9f2e665bf2b Takashi Iwai       2008-07-30  119  			maxpages = chunk;
^1da177e4c3f41 Linus Torvalds     2005-04-16  120  	}
^1da177e4c3f41 Linus Torvalds     2005-04-16  121  
^1da177e4c3f41 Linus Torvalds     2005-04-16  122  	sgbuf->size = size;
f3ed524c879510 Takashi Iwai       2020-06-09  123  	dmab->addr = -1UL; /* some non-NULL value as validity */
51e9f2e665bf2b Takashi Iwai       2008-07-30  124  	if (res_size)
51e9f2e665bf2b Takashi Iwai       2008-07-30  125  		*res_size = sgbuf->size;
f3ed524c879510 Takashi Iwai       2020-06-09  126  	return 0;
^1da177e4c3f41 Linus Torvalds     2005-04-16  127  
^1da177e4c3f41 Linus Torvalds     2005-04-16  128   _failed:
^1da177e4c3f41 Linus Torvalds     2005-04-16  129  	snd_free_sgbuf_pages(dmab); /* free the table */
f3ed524c879510 Takashi Iwai       2020-06-09  130  	return -ENOMEM;
^1da177e4c3f41 Linus Torvalds     2005-04-16  131  }
9d069dc00b02b8 Takashi Iwai       2012-09-20  132  

:::::: The code at line 63 was first introduced by commit
:::::: 42e748a0b3251cca0de2c269ca106884907eb289 ALSA: memalloc: Add non-cached buffer type

:::::: TO: Takashi Iwai <tiwai at suse.de>
:::::: CC: Takashi Iwai <tiwai at suse.de>

---
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: 39609 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20200610/9aa6872f/attachment-0001.gz>


More information about the Alsa-devel mailing list