All of lore.kernel.org
 help / color / mirror / Atom feed
* [chrome-os:chromeos-5.10 127/135] drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142 (fwd)
@ 2021-07-01  6:50 Julia Lawall
  2021-07-01 15:02 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2021-07-01  6:50 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6226 bytes --]

Hello,

Should there be a mutex_unlock before line 149?

julia

---------- Forwarded message ----------
Date: Thu, 1 Jul 2021 11:47:21 +0800
From: kernel test robot <lkp@intel.com>
To: kbuild(a)lists.01.org
Cc: lkp(a)intel.com, Julia Lawall <julia.lawall@lip6.fr>
Subject: [chrome-os:chromeos-5.10 127/135]
    drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142

CC: kbuild-all(a)lists.01.org
TO: cros-kernel-buildreports(a)googlegroups.com
TO: Guenter Roeck <groeck@google.com>

tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.10
head:   13e17c58f6e03ea6be019722207550ce15604b3a
commit: 4a6c2287b3ee69a7966d13db1f173cad6a5803a6 [127/135] FROMLIST: platform/x86: amd-pmc: Fix command completion code
:::::: branch date: 6 hours ago
:::::: commit date: 8 hours ago
config: x86_64-randconfig-c022-20210630 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>


cocci warnings: (new ones prefixed by >>)
>> drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142

vim +149 drivers/platform/x86/amd-pmc.c

f9445912e6bb09 Shyam Sundar S K 2020-11-05  135
f9445912e6bb09 Shyam Sundar S K 2020-11-05  136  static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set)
f9445912e6bb09 Shyam Sundar S K 2020-11-05  137  {
f9445912e6bb09 Shyam Sundar S K 2020-11-05  138  	int rc;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  139  	u8 msg;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  140  	u32 val;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  141
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29 @142  	mutex_lock(&dev->lock);
f9445912e6bb09 Shyam Sundar S K 2020-11-05  143  	/* Wait until we get a valid response */
f9445912e6bb09 Shyam Sundar S K 2020-11-05  144  	rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  145  				val, val != 0, PMC_MSG_DELAY_MIN_US,
f9445912e6bb09 Shyam Sundar S K 2020-11-05  146  				PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
f9445912e6bb09 Shyam Sundar S K 2020-11-05  147  	if (rc) {
f9445912e6bb09 Shyam Sundar S K 2020-11-05  148  		dev_err(dev->dev, "failed to talk to SMU\n");
f9445912e6bb09 Shyam Sundar S K 2020-11-05 @149  		return rc;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  150  	}
f9445912e6bb09 Shyam Sundar S K 2020-11-05  151
f9445912e6bb09 Shyam Sundar S K 2020-11-05  152  	/* Write zero to response register */
f9445912e6bb09 Shyam Sundar S K 2020-11-05  153  	amd_pmc_reg_write(dev, AMD_PMC_REGISTER_RESPONSE, 0);
f9445912e6bb09 Shyam Sundar S K 2020-11-05  154
f9445912e6bb09 Shyam Sundar S K 2020-11-05  155  	/* Write argument into response register */
f9445912e6bb09 Shyam Sundar S K 2020-11-05  156  	amd_pmc_reg_write(dev, AMD_PMC_REGISTER_ARGUMENT, set);
f9445912e6bb09 Shyam Sundar S K 2020-11-05  157
f9445912e6bb09 Shyam Sundar S K 2020-11-05  158  	/* Write message ID to message ID register */
f9445912e6bb09 Shyam Sundar S K 2020-11-05  159  	msg = (dev->cpu_id == AMD_CPU_ID_RN) ? MSG_OS_HINT_RN : MSG_OS_HINT_PCO;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  160  	amd_pmc_reg_write(dev, AMD_PMC_REGISTER_MESSAGE, msg);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  161  	/* Wait until we get a valid response */
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  162  	rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  163  				val, val != 0, PMC_MSG_DELAY_MIN_US,
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  164  				PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  165  	if (rc) {
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  166  		dev_err(dev->dev, "SMU response timed out\n");
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  167  		goto out_unlock;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  168  	}
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  169
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  170  	switch (val) {
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  171  	case AMD_PMC_RESULT_OK:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  172  		break;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  173  	case AMD_PMC_RESULT_CMD_REJECT_BUSY:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  174  		dev_err(dev->dev, "SMU not ready. err: 0x%x\n", val);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  175  		rc = -EBUSY;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  176  		goto out_unlock;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  177  	case AMD_PMC_RESULT_CMD_UNKNOWN:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  178  		dev_err(dev->dev, "SMU cmd unknown. err: 0x%x\n", val);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  179  		rc = -EINVAL;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  180  		goto out_unlock;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  181  	case AMD_PMC_RESULT_CMD_REJECT_PREREQ:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  182  	case AMD_PMC_RESULT_FAILED:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  183  	default:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  184  		dev_err(dev->dev, "SMU cmd failed. err: 0x%x\n", val);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  185  		rc = -EIO;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  186  		goto out_unlock;
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  187  	}
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  188
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  189  out_unlock:
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  190  	mutex_unlock(&dev->lock);
4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  191  	return rc;
f9445912e6bb09 Shyam Sundar S K 2020-11-05  192  }
f9445912e6bb09 Shyam Sundar S K 2020-11-05  193

:::::: The code at line 149 was first introduced by commit
:::::: f9445912e6bb094dc64f1dfa4d5c414f448465ee UPSTREAM: platform/x86: amd-pmc: Add AMD platform support for S2Idle

:::::: TO: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
:::::: CC: Commit Bot <commit-bot@chromium.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 45817 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [chrome-os:chromeos-5.10 127/135] drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142 (fwd)
  2021-07-01  6:50 [chrome-os:chromeos-5.10 127/135] drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142 (fwd) Julia Lawall
@ 2021-07-01 15:02 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2021-07-01 15:02 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 7206 bytes --]

Hi Julia,

On Wed, Jun 30, 2021 at 11:50 PM Julia Lawall <julia.lawall@inria.fr> wrote:
>
> Hello,
>
> Should there be a mutex_unlock before line 149?
>

Actually the patch introducing the problem (and the mutex) also
provides a goto target (out_unlock).
It looks like the submitter forgot to handle this case.

I submitted a patch to fix the problem.

Thanks,
Guenter

> julia
>
> ---------- Forwarded message ----------
> Date: Thu, 1 Jul 2021 11:47:21 +0800
> From: kernel test robot <lkp@intel.com>
> To: kbuild(a)lists.01.org
> Cc: lkp(a)intel.com, Julia Lawall <julia.lawall@lip6.fr>
> Subject: [chrome-os:chromeos-5.10 127/135]
>     drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142
>
> CC: kbuild-all(a)lists.01.org
> TO: cros-kernel-buildreports(a)googlegroups.com
> TO: Guenter Roeck <groeck@google.com>
>
> tree:   https://chromium.googlesource.com/chromiumos/third_party/kernel chromeos-5.10
> head:   13e17c58f6e03ea6be019722207550ce15604b3a
> commit: 4a6c2287b3ee69a7966d13db1f173cad6a5803a6 [127/135] FROMLIST: platform/x86: amd-pmc: Fix command completion code
> :::::: branch date: 6 hours ago
> :::::: commit date: 8 hours ago
> config: x86_64-randconfig-c022-20210630 (attached as .config)
> compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
> Reported-by: Julia Lawall <julia.lawall@lip6.fr>
>
>
> cocci warnings: (new ones prefixed by >>)
> >> drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142
>
> vim +149 drivers/platform/x86/amd-pmc.c
>
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  135
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  136  static int amd_pmc_send_cmd(struct amd_pmc_dev *dev, bool set)
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  137  {
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  138         int rc;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  139         u8 msg;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  140         u32 val;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  141
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29 @142         mutex_lock(&dev->lock);
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  143         /* Wait until we get a valid response */
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  144         rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  145                                 val, val != 0, PMC_MSG_DELAY_MIN_US,
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  146                                 PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  147         if (rc) {
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  148                 dev_err(dev->dev, "failed to talk to SMU\n");
> f9445912e6bb09 Shyam Sundar S K 2020-11-05 @149                 return rc;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  150         }
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  151
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  152         /* Write zero to response register */
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  153         amd_pmc_reg_write(dev, AMD_PMC_REGISTER_RESPONSE, 0);
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  154
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  155         /* Write argument into response register */
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  156         amd_pmc_reg_write(dev, AMD_PMC_REGISTER_ARGUMENT, set);
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  157
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  158         /* Write message ID to message ID register */
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  159         msg = (dev->cpu_id == AMD_CPU_ID_RN) ? MSG_OS_HINT_RN : MSG_OS_HINT_PCO;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  160         amd_pmc_reg_write(dev, AMD_PMC_REGISTER_MESSAGE, msg);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  161         /* Wait until we get a valid response */
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  162         rc = readx_poll_timeout(ioread32, dev->regbase + AMD_PMC_REGISTER_RESPONSE,
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  163                                 val, val != 0, PMC_MSG_DELAY_MIN_US,
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  164                                 PMC_MSG_DELAY_MIN_US * RESPONSE_REGISTER_LOOP_MAX);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  165         if (rc) {
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  166                 dev_err(dev->dev, "SMU response timed out\n");
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  167                 goto out_unlock;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  168         }
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  169
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  170         switch (val) {
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  171         case AMD_PMC_RESULT_OK:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  172                 break;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  173         case AMD_PMC_RESULT_CMD_REJECT_BUSY:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  174                 dev_err(dev->dev, "SMU not ready. err: 0x%x\n", val);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  175                 rc = -EBUSY;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  176                 goto out_unlock;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  177         case AMD_PMC_RESULT_CMD_UNKNOWN:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  178                 dev_err(dev->dev, "SMU cmd unknown. err: 0x%x\n", val);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  179                 rc = -EINVAL;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  180                 goto out_unlock;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  181         case AMD_PMC_RESULT_CMD_REJECT_PREREQ:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  182         case AMD_PMC_RESULT_FAILED:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  183         default:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  184                 dev_err(dev->dev, "SMU cmd failed. err: 0x%x\n", val);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  185                 rc = -EIO;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  186                 goto out_unlock;
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  187         }
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  188
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  189  out_unlock:
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  190         mutex_unlock(&dev->lock);
> 4a6c2287b3ee69 Shyam Sundar S K 2021-06-29  191         return rc;
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  192  }
> f9445912e6bb09 Shyam Sundar S K 2020-11-05  193
>
> :::::: The code at line 149 was first introduced by commit
> :::::: f9445912e6bb094dc64f1dfa4d5c414f448465ee UPSTREAM: platform/x86: amd-pmc: Add AMD platform support for S2Idle
>
> :::::: TO: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
> :::::: CC: Commit Bot <commit-bot@chromium.org>
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-01 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-01  6:50 [chrome-os:chromeos-5.10 127/135] drivers/platform/x86/amd-pmc.c:149:2-8: preceding lock on line 142 (fwd) Julia Lawall
2021-07-01 15:02 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.