Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp724215pxb; Thu, 24 Mar 2022 06:02:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyD2G1iF2UUotEdLSqq3lixkcVjx+SANtlMMblA3Jt5n+z2IClijNQTTJuQQ7G29P4LTJ/a X-Received: by 2002:a92:6e11:0:b0:2c7:a32b:733d with SMTP id j17-20020a926e11000000b002c7a32b733dmr2555532ilc.196.1648126936941; Thu, 24 Mar 2022 06:02:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648126936; cv=none; d=google.com; s=arc-20160816; b=kPsdEFl1Au2ExaJrdzVxGA8QcrJVyeyJaZ/3S404eALv7tDAUA1VKg1C69KvyDbnfE 29vNeCeLiy3555vTTwqcZwpvSTWOj1b6gwpVyTzQQETJlI4bps69jcYS2SS9CxM4NwQp sTOux+sSbEhgu7SNghmNbdVr1R9M5Ug4WoeWPOebr8oYOsC+2Z8TKp/htpxu0loxBGlk If4r4OqrLC62tfQ04WlYPJ/MQxnNmQFPpELs/9bA70lcHFO/GTGG14+2yDHw3OSBv1iZ hO9ZkPQ8rToKD/hARNl4O6DO5Jr25ZECXIX1+AI2A5kLTtUUTlEl2B2Z0MVDwmrezzoW DNUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=O+zxQs1UunEt1Y0guZW5n1WKoD8ocXtqelE5nMkEa7A=; b=Mi6L6RyfzmEHnxuy5c0ISzP6bhHTxmXphGacugjdVDl/PF1TRVaj1gXf2vQJKg5Lvl gHR2MB8IZxJiZjTKVfZwcDx1ld3HuLyv9h7kXaTGhkvi94WLuxH05+jaF3xYpIaazOx4 wecd91j35uYeMaShr0h5M8MU9AXaAcCMjyRBA80bShdN2J3+jLtg6mJRPUwgYm6HQlzW aUAxwB2qv2+Xj4fWJVzIOJxjHIuiuZBIiSY+wpv/5FV6KaMmNJO4IlowdB4kITUfmv7/ JXrisL1W8TmUahatmpWX6QY7Z+fZGMQoNnNv9u1Xsg8EM9vNbS/xsOQXbhIIaGRScTth cWyA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s17-20020a92cc11000000b002c82d89088csi7916014ilp.174.2022.03.24.06.02.01; Thu, 24 Mar 2022 06:02:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241535AbiCWJoK (ORCPT + 99 others); Wed, 23 Mar 2022 05:44:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240499AbiCWJoJ (ORCPT ); Wed, 23 Mar 2022 05:44:09 -0400 Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC50376641 for ; Wed, 23 Mar 2022 02:42:39 -0700 (PDT) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D0D17201A57; Wed, 23 Mar 2022 10:42:37 +0100 (CET) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 97F50201A41; Wed, 23 Mar 2022 10:42:37 +0100 (CET) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 805A1183AC96; Wed, 23 Mar 2022 17:42:36 +0800 (+08) From: Shengjiu Wang To: bjorn.andersson@linaro.org, mathieu.poirier@linaro.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, shengjiu.wang@gmail.com Subject: [PATCH] remoteproc: core: Remove state checking before changing state Date: Wed, 23 Mar 2022 17:32:50 +0800 Message-Id: <1648027970-11488-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is no mutex protecting of these state checking, which can't garantee there is no another instance is trying to do same operation. The reference counter rproc->power is used to manage state changing and there is mutex protection in each operation function for multi instance case. So remove this state checking in rproc_cdev_write() and state_store(), just let reference counter rproc->power to manage the behaviors. Signed-off-by: Shengjiu Wang --- drivers/remoteproc/remoteproc_cdev.c | 11 ----------- drivers/remoteproc/remoteproc_sysfs.c | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 906ff3c4dfdd..687f205fd70a 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -32,21 +32,10 @@ static ssize_t rproc_cdev_write(struct file *filp, const char __user *buf, size_ return -EFAULT; if (!strncmp(cmd, "start", len)) { - if (rproc->state == RPROC_RUNNING || - rproc->state == RPROC_ATTACHED) - return -EBUSY; - ret = rproc_boot(rproc); } else if (!strncmp(cmd, "stop", len)) { - if (rproc->state != RPROC_RUNNING && - rproc->state != RPROC_ATTACHED) - return -EINVAL; - ret = rproc_shutdown(rproc); } else if (!strncmp(cmd, "detach", len)) { - if (rproc->state != RPROC_ATTACHED) - return -EINVAL; - ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognized option\n"); diff --git a/drivers/remoteproc/remoteproc_sysfs.c b/drivers/remoteproc/remoteproc_sysfs.c index 51a04bc6ba7a..8c7ea8922638 100644 --- a/drivers/remoteproc/remoteproc_sysfs.c +++ b/drivers/remoteproc/remoteproc_sysfs.c @@ -194,23 +194,12 @@ static ssize_t state_store(struct device *dev, int ret = 0; if (sysfs_streq(buf, "start")) { - if (rproc->state == RPROC_RUNNING || - rproc->state == RPROC_ATTACHED) - return -EBUSY; - ret = rproc_boot(rproc); if (ret) dev_err(&rproc->dev, "Boot failed: %d\n", ret); } else if (sysfs_streq(buf, "stop")) { - if (rproc->state != RPROC_RUNNING && - rproc->state != RPROC_ATTACHED) - return -EINVAL; - ret = rproc_shutdown(rproc); } else if (sysfs_streq(buf, "detach")) { - if (rproc->state != RPROC_ATTACHED) - return -EINVAL; - ret = rproc_detach(rproc); } else { dev_err(&rproc->dev, "Unrecognised option: %s\n", buf); -- 2.17.1