From patchwork Thu Sep 20 19:18:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 147156 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2376886ljw; Thu, 20 Sep 2018 12:19:27 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/AoQM8Qav0YwpFTVdTD7uPgQOj5cHsoYGuIeOpMk1ldYvcjqwmPEzigwIHyC47OEKTByM X-Received: by 2002:a62:3644:: with SMTP id d65-v6mr42338869pfa.133.1537471167420; Thu, 20 Sep 2018 12:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537471167; cv=none; d=google.com; s=arc-20160816; b=U7r6xdordOrlgJybMpbxClBq4JQAia+hz2SjGtOFf2Lr9Vqwy8x5NuonWo+2KBR8Oc 5XCkU0o8leVcDCXSFBBjwAybx7XqQUcYEx20IVdM4xd57Nlw1Oir1oWtRyjFUtDRUVuP ONjsWEaLJlg63j5vR/aAF8V0yjMUP4kHL8APiLdHy2aBF6wyrrR2070Rbh3aUBRjL08j RCLrsd1YheJ89yFmpMU9zpR8KQsALxd42Qo24l509btX2YepfsGdEekAjCA/MjoRSBCx 2Zj/HWiwVf+Hs0aPI4fxZL3N/su7DEnt2XT1VO8vqdO4ktkHQsPlLljkIxK2veJI1NxA Rqxg== 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=jgeumEyt2vKhIehOlTB8fmQUshNYewxvGQGrAiDNIOo=; b=rZ7nPV/ZztxyYqnyijfPty6VYB1oYOa5TFbWacsWAjZyH2KVPecBzQ++QiD2Zek7eA YqBI1b/vQ4DfbvDIYBZ4nHdEbYy4BzMD9dfR7XP9z9chJhCeR2QYwQ/lImbjWFhIPxYW dIh5WV+966wjl93APLuQtOScOaM6hfWWhRvcbSalZX729OT4zn6tLCEN2HDIV+OXQVoL 0OXmqjHpxJY5Eaj+OzKrsWeciCbQU2LQ++RjSibNv7t1W/L8D+1YJ2QFK4gQixNyGiRY 4ZHh7xEGH+ZlSQS4MtW9WiOOBlyZ3NiS7Gj34szegnShLu5XsduBObpd6z+O23R0lqFV noxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jlBQ2yvr; 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 s136-v6si26101346pfs.255.2018.09.20.12.19.27; Thu, 20 Sep 2018 12:19:27 -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=jlBQ2yvr; 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 S2389109AbeIUBEY (ORCPT + 32 others); Thu, 20 Sep 2018 21:04:24 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:45825 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388518AbeIUBEW (ORCPT ); Thu, 20 Sep 2018 21:04:22 -0400 Received: by mail-pf1-f193.google.com with SMTP id i26-v6so4809671pfo.12 for ; Thu, 20 Sep 2018 12:19:23 -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=jgeumEyt2vKhIehOlTB8fmQUshNYewxvGQGrAiDNIOo=; b=jlBQ2yvr+9fOsWy2m0iI8eo7JeQBNX0qSYDjwtmgE77fotnyIjyC/ni2u3D7iA4Yjx o0FHs9FUWNJfwbixWhLa91Z/XGLIr89wZrBOQWIGCqUQp9dbwvs1VlewteP/vLDf9EeG CIq/6BWEE1Wgem9APqhdVb1Fq3WWiFR0iiarU= 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=jgeumEyt2vKhIehOlTB8fmQUshNYewxvGQGrAiDNIOo=; b=qIm5ymi5mYQYNXkw9IAAaliOqurAxp5lHESzUrO3nGKUTJgY6nip6VLAkf1QWCW8FW t6q3zoBxylwspzfB7VE1fdlbMe11K/5x/XGASMglJ10u7U7A8X78CVJ58wCUVRuJPiJD DN1m3vGSMgJaScfAYkUZKQenRTSL9gyu8eaxuhHfHjjs5RL5UCU3S6bPveNgf2B5pb9v tm1hNZoju5ex0rQ6Wpd2UtMkFQ+nf8L38xqp3bz1q+1Vhu6EAo32bmbbwG2jdmsSz7vu 81GUG2yntAhgNbsaRi/uTY2EaNCKaY0ZeuhTDEUVZsGKHqWqv0x4AEC4xxgd+twJT4vu H6xA== X-Gm-Message-State: APzg51CsIysm/NlTViZt3XzSQHRbd2FMLTHYms5nCxFZ+MFy64BJjK3I uzPVNz8Knin3A/utP7EWev3pXCKYxRk= X-Received: by 2002:a62:6104:: with SMTP id v4-v6mr43176750pfb.122.1537471162782; Thu, 20 Sep 2018 12:19:22 -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.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 12:19:21 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 40/44] coresight: dynamic-replicator: Claim device for use Date: Thu, 20 Sep 2018 13:18:15 -0600 Message-Id: <1537471099-19781-41-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 protocol to make sure the device is available for use. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- .../coresight/coresight-dynamic-replicator.c | 23 +++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c index 97f4673452cb..299667b887fc 100644 --- a/drivers/hwtracing/coresight/coresight-dynamic-replicator.c +++ b/drivers/hwtracing/coresight/coresight-dynamic-replicator.c @@ -41,8 +41,11 @@ static void replicator_reset(struct replicator_state *drvdata) { CS_UNLOCK(drvdata->base); - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); - writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); + if (!coresight_claim_device_unlocked(drvdata->base)) { + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER0); + writel_relaxed(0xff, drvdata->base + REPLICATOR_IDFILTER1); + coresight_disclaim_device_unlocked(drvdata->base); + } CS_LOCK(drvdata->base); } @@ -50,6 +53,7 @@ static void replicator_reset(struct replicator_state *drvdata) static int replicator_enable(struct coresight_device *csdev, int inport, int outport) { + int rc = 0; u32 reg; struct replicator_state *drvdata = dev_get_drvdata(csdev->dev.parent); @@ -67,13 +71,19 @@ static int replicator_enable(struct coresight_device *csdev, int inport, CS_UNLOCK(drvdata->base); + if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) && + (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff)) + rc = coresight_claim_device_unlocked(drvdata->base); /* Ensure that the outport is enabled. */ - writel_relaxed(0x00, drvdata->base + reg); + if (!rc) { + writel_relaxed(0x00, drvdata->base + reg); + dev_dbg(drvdata->dev, "REPLICATOR enabled\n"); + } + CS_LOCK(drvdata->base); - dev_dbg(drvdata->dev, "REPLICATOR enabled\n"); - return 0; + return rc; } static void replicator_disable(struct coresight_device *csdev, int inport, @@ -99,6 +109,9 @@ static void replicator_disable(struct coresight_device *csdev, int inport, /* disable the flow of ATB data through port */ writel_relaxed(0xff, drvdata->base + reg); + if ((readl_relaxed(drvdata->base + REPLICATOR_IDFILTER0) == 0xff) && + (readl_relaxed(drvdata->base + REPLICATOR_IDFILTER1) == 0xff)) + coresight_disclaim_device_unlocked(drvdata->base); CS_LOCK(drvdata->base); dev_dbg(drvdata->dev, "REPLICATOR disabled\n");