[bug report] ASoC: Intel: catpt: Firmware loading and context restore

Dan Carpenter dan.carpenter at oracle.com
Sat Oct 10 22:15:47 CEST 2020


Hello Cezary Rojewski,

The patch a9aa6fb3eb6c: "ASoC: Intel: catpt: Firmware loading and
context restore" from Sep 29, 2020, leads to the following static
checker warning:

	sound/soc/intel/catpt/loader.c:654 catpt_first_boot_firmware()
	warn: consider using resource_size() here

sound/soc/intel/catpt/loader.c
   638  int catpt_first_boot_firmware(struct catpt_dev *cdev)
   639  {
   640          struct resource *res;
   641          int ret;
   642  
   643          ret = catpt_boot_firmware(cdev, false);
   644          if (ret) {
   645                  dev_err(cdev->dev, "basefw boot failed: %d\n", ret);
   646                  return ret;
   647          }
   648  
   649          /* restrict FW Core dump area */
   650          __request_region(&cdev->dram, 0, 0x200, NULL, 0);
   651          /* restrict entire area following BASE_FW - highest offset in DRAM */
   652          for (res = cdev->dram.child; res->sibling; res = res->sibling)
   653                  ;
   654          __request_region(&cdev->dram, res->end + 1,
   655                           cdev->dram.end - res->end, NULL, 0);
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
It's been years since I have seen one of these warnings.  Back in the
day we used have have a lot of off by one warnings because resource_size()
is supposed to be calculated as "end - start + 1".  But here we are
calculating "dram.end - res->end" so I'm not sure if the math is correct
or not.  This is very new code so hopefully you know the answer off the
top of your head?

   656  
   657          ret = catpt_ipc_get_mixer_stream_info(cdev, &cdev->mixer);
   658          if (ret)
   659                  return CATPT_IPC_ERROR(ret);
   660  
   661          ret = catpt_arm_stream_templates(cdev);
   662          if (ret) {
   663                  dev_err(cdev->dev, "arm templates failed: %d\n", ret);
   664                  return ret;
   665          }
   666  
   667          /* update dram pg for scratch and restricted regions */
   668          catpt_dsp_update_srampge(cdev, &cdev->dram, cdev->spec->dram_mask);
   669  
   670          return 0;
   671  }

regards,
dan carpenter


More information about the Alsa-devel mailing list