From patchwork Thu Sep 20 19:18:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 147160 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2377207ljw; Thu, 20 Sep 2018 12:19:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaehWh0o8YIAqRa5DPkVC+jZwhrh3Ec0EkNWYXTEIkjWsbBjkwBZQCA/LIMZ/5OPmzRvPeU X-Received: by 2002:a63:144b:: with SMTP id 11-v6mr37064856pgu.219.1537471188780; Thu, 20 Sep 2018 12:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537471188; cv=none; d=google.com; s=arc-20160816; b=p+bIpHL3/ebZuHCYQ5CON/dpNKZgJKaLI/V1MfcgY/h0H7YAmvZgGpsK9tndZ8AXwz unR/REXrg5hqB1c0HpIF32JAD1sQNdzSzV++Zn7LbUmuTUtuSJxLqi9HgIkp1OGWbcc/ YvRFY4lPELiwXpP0J+FMpu24EMN3bux29WyHuhAb39HsRsoCI5GlF33v3Rk9v3KZYQN/ ngSYCRP3pzWYBRXBV3NJkKVhbX9oz1z7ZVAOwsdWqENafJKCMjkT8Sc+ZXf4msfJGeU+ Fbrd3eMfS5iieeG0Sfj1zuIs9oGWFbzsYc6Qz0eK+tCgAgwb823SVWNGLBKam/tZYlG4 AZ9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=lEojR96MJu4iyHo4Y0qSuQdeRg8I+A050JDTrUQ4dMg=; b=AUNMgihxae9GroySAZIYbPsNPiw6zpSORs0otLK3FTpJTCm35eKNb8tP5z5mx2TAvo PMtCrQwqQvfQ4jLeDjhIf/QDNGYuXjT1ZPp325Cclk6wDojKQ5MUC5J5Zkxd2GaGZFND 4XiUmH6t/hxM8ywcLQBjF5n85TdY3losPfG+t7zmGQu58njVhX01Ql2HlIku73fJTIHQ MwguAVXn95cBG5KAEX9XdfSnuelkibLNLcEdGYWc9syWR58+De18Ny6zgDGcPaZ+6Mq+ 5jvfiLe5WD5nDuaBK4OZRqTCLqRdAPl3ASQcWcQC/jIyFhYNtesVUvTqnyTH+jgpFEro Auqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YF42dPFh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v37-v6si381060plg.124.2018.09.20.12.19.48; Thu, 20 Sep 2018 12:19:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YF42dPFh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388499AbeIUBEp (ORCPT + 32 others); Thu, 20 Sep 2018 21:04:45 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37763 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388517AbeIUBEX (ORCPT ); Thu, 20 Sep 2018 21:04:23 -0400 Received: by mail-pf1-f195.google.com with SMTP id h69-v6so4826867pfd.4 for ; Thu, 20 Sep 2018 12:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lEojR96MJu4iyHo4Y0qSuQdeRg8I+A050JDTrUQ4dMg=; b=YF42dPFhIvIfWd26UB5GVbVqZ45vldYbKJBXevvUaouVrewwHuwgeqtxmmAvI+VOcw fzhlhy+xBVHfYw4ecZ3i/REwLnbTHVAaZW41OfTgSbGFieWR+PRbudVZx1zSztOh4vHs bzexd3QHt6+/j1C8jxhDR2uOYo8zg7KSTqnH0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lEojR96MJu4iyHo4Y0qSuQdeRg8I+A050JDTrUQ4dMg=; b=BTsiEg/7wQR4Q7oOZ0rYsui1vI2sYTHPKPwHRVcX+uT/6TM7yWRkGclPhPH30En5fF OPX3YCi8ucGNM+w32i51MpiWUx8AgglRl879dnN3pDocXV559Y3hlDvc63/qCZKm5sBo U25iYsHd1a3rzOTkvt3QFE/MgV2EnYyR3s64eBfre5Hx09jCRRYaukGVWcHYlDNtxziV RgsPat/GCbUNiYUTAu9TRKP3vAqpTQrKgHIsDf8EZAkNsWghoyToaGBcGJk6+1l+WBMX ay7RJ+DeJ+lEq+ja0T8L0kQ1akhiwykU9ZXkuiuTIn4wYJwqYyXF+NjB1oIyurVowqRQ 2PWg== X-Gm-Message-State: APzg51A2GiBGsVjVOAyVzoCr6zMLrE7YWPsuTsfbQFBLHU7fusFvqTHc rsgDSh5VUpwDXST0sSHe4nINHEwXdmU= X-Received: by 2002:a62:4808:: with SMTP id v8-v6mr43044662pfa.89.1537471164307; Thu, 20 Sep 2018 12:19:24 -0700 (PDT) Received: from localhost.localdomain ([209.121.128.187]) by smtp.gmail.com with ESMTPSA id k13-v6sm4424443pgf.37.2018.09.20.12.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 12:19:23 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 41/44] coreisght: tmc: Claim device before use Date: Thu, 20 Sep 2018 13:18:16 -0600 Message-Id: <1537471099-19781-42-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> References: <1537471099-19781-1-git-send-email-mathieu.poirier@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suzuki K Poulose Use CLAIM tags to make sure the device is available for use. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-tmc-etf.c | 22 +++++++++++++++++++--- drivers/hwtracing/coresight/coresight-tmc-etr.c | 4 ++++ 2 files changed, 23 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-tmc-etf.c b/drivers/hwtracing/coresight/coresight-tmc-etf.c index 36af23d2c0f8..53fc83b72a49 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etf.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etf.c @@ -36,6 +36,11 @@ static void __tmc_etb_enable_hw(struct tmc_drvdata *drvdata) static int tmc_etb_enable_hw(struct tmc_drvdata *drvdata) { + int rc = coresight_claim_device(drvdata->base); + + if (rc) + return rc; + __tmc_etb_enable_hw(drvdata); return 0; } @@ -63,7 +68,7 @@ static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) return; } -static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) +static void __tmc_etb_disable_hw(struct tmc_drvdata *drvdata) { CS_UNLOCK(drvdata->base); @@ -79,6 +84,12 @@ static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) CS_LOCK(drvdata->base); } +static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) +{ + coresight_disclaim_device(drvdata); + __tmc_etb_disable_hw(drvdata); +} + static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata) { CS_UNLOCK(drvdata->base); @@ -97,6 +108,11 @@ static void __tmc_etf_enable_hw(struct tmc_drvdata *drvdata) static int tmc_etf_enable_hw(struct tmc_drvdata *drvdata) { + int rc = coresight_claim_device(drvdata->base); + + if (rc) + return rc; + __tmc_etf_enable_hw(drvdata); return 0; } @@ -107,7 +123,7 @@ static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata) tmc_flush_and_stop(drvdata); tmc_disable_hw(drvdata); - + coresight_disclaim_device_unlocked(drvdata->base); CS_LOCK(drvdata->base); } @@ -553,7 +569,7 @@ int tmc_read_prepare_etb(struct tmc_drvdata *drvdata) /* Disable the TMC if need be */ if (drvdata->mode == CS_MODE_SYSFS) - tmc_etb_disable_hw(drvdata); + __tmc_etb_disable_hw(drvdata); drvdata->reading = true; out: diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c index daad52146140..f684283890d3 100644 --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c @@ -991,6 +991,9 @@ static int tmc_etr_enable_hw(struct tmc_drvdata *drvdata, * this on. */ rc = tmc_etr_enable_catu(drvdata, etr_buf); + if (rc) + return rc; + rc = coresight_claim_device(drvdata->base); if (!rc) { drvdata->etr_buf = etr_buf; __tmc_etr_enable_hw(drvdata); @@ -1077,6 +1080,7 @@ static void tmc_etr_disable_hw(struct tmc_drvdata *drvdata) __tmc_etr_disable_hw(drvdata); /* Disable CATU device if this ETR is connected to one */ tmc_etr_disable_catu(drvdata); + coresight_disclaim_device(drvdata->base); /* Reset the ETR buf used by hardware */ drvdata->etr_buf = NULL; }