From patchwork Thu Sep 20 19:18:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 147154 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp2376831ljw; Thu, 20 Sep 2018 12:19:23 -0700 (PDT) X-Google-Smtp-Source: ANB0VdauQlH2chesDt3Lsoisi2weOK5AaI6mM28MOm42yawaLeJNwJdJVatbuxM0p6HwjnUXHMMN X-Received: by 2002:a63:2b4d:: with SMTP id r74-v6mr38374847pgr.406.1537471163760; Thu, 20 Sep 2018 12:19:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537471163; cv=none; d=google.com; s=arc-20160816; b=knTvUYm+TEMkmlOnBhD8yiyeD7QHWPFJ4h+LWtk8H/ifmfUYpEolZ7IJ/jrx5eftgY QhjRzx2MqR4YbS/FDhLYJDLZMhlYyWINTCXe2qND4MzY1a8V7LgghzG1oLU8MfADMaxR EFfAEOiDKOVXQcv78eD8r9E3wgIa4Y4yEZberEe/hV7lMiN1/4vd5bOeQCkSrd5l72Yl yCZshfqZPzsGVxzWdi6AWfXNsAtLNfVKuLYXfxlBm/srPVELPZP3i0gig8yPHZkXePSL Kg/ba5MQGCBM8vzMcbF3ERQG+xWfwTRu+8//REiMtlbRby7itwRt73+QVikiInkU/Z4c f8yA== 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=ZQN6xPGKIW6glHZexLLxjYGOYgPeCk+jeaAojs1cWHQ=; b=FaMYeGrWGc7I98+gu7SvzS5EvtllH23/7tfyS5zyCzWpUWPeuT9GId6YwKvY4hYp90 RWZqEBuc8hdlN98iVzH9Gzss5fnGfZMYzbxGnT6XxfsZrbVs7scFx1U3A5zw7SnA/qCF gRiLotk4i/Dg+B+Tf584aFbtV7i9zzp43E9Vy74kMwKmrbcs87xuhOpk6iQeZcn8RAaZ CxwYr3FZeapcFSsUjZqdfwpNfhLaAfDa3r3qd4YvWQWZb0kmI3a+/BFfzbmdgndMYbWB qNc899X58QcKTmDXLsbFFAMExW97eO8wUVD7zY8PL7IbMG3Qn3IPbLRNaKlg3zjaQN0P OhNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jSaZ0Es6; 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 v10-v6si24194882pfe.173.2018.09.20.12.19.23; Thu, 20 Sep 2018 12:19:23 -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=jSaZ0Es6; 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 S2389086AbeIUBET (ORCPT + 32 others); Thu, 20 Sep 2018 21:04:19 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:38308 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388518AbeIUBES (ORCPT ); Thu, 20 Sep 2018 21:04:18 -0400 Received: by mail-pl1-f195.google.com with SMTP id u11-v6so4800515plq.5 for ; Thu, 20 Sep 2018 12:19:20 -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=ZQN6xPGKIW6glHZexLLxjYGOYgPeCk+jeaAojs1cWHQ=; b=jSaZ0Es6z/aw9H1R3PsvJd0l4YafThGWssA9gwkuflwAm4dlzISK6Cy2WIJtiGe7Wy jTegSCuFh4QTKuOd7s5EGb2rxnPRMDEExWOQy/cMZ2rkt4iDjQhcZHFtbx21ZrH95Xm5 QcuCuH6qfLx981Zzo01RdvOyRuiWZGfOmAOLI= 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=ZQN6xPGKIW6glHZexLLxjYGOYgPeCk+jeaAojs1cWHQ=; b=WazMdsDJCpiXtHAAlYCMygFK5/MENux4vvRbqMfj83+5hBj4QrEca2J7JCYuQMGtJh GcQ66KzZCpda9aoJBWX33Rl8LTA0KC6JbBpw4o/rUh6+5oOzbnuDooREzI02+DGHk9G2 w9Zn0GO85UuNOIynv6no1bX6M1ZTeIfH10iOGYMiyy+/ow9AZLGHCV2eQDOrB9PbOZQf pM/k12Q46nI18PuSq6c2INiARsdZDJhEHc2IIzkT48CbnfYx843wEDEXtgV9whR2Wyhn 7XFrDDLSfOfIM5l/rMbzTmuj5jYROEjzmdoV/jgsYed0d6zu/JPQUnCyJZ03+XPnTmIq 7VNw== X-Gm-Message-State: APzg51AqTFERbkqbxTwzn2tIUgkQ1g5Ox4iXv8l2lw6nwHDbqdP7gC0Y MTWCHhJAIpy5Zy1RUdiFNjhyOA== X-Received: by 2002:a17:902:724c:: with SMTP id c12-v6mr40234625pll.326.1537471159687; Thu, 20 Sep 2018 12:19:19 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Sep 2018 12:19:18 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH 38/44] coresight: funnel: Claim devices before use Date: Thu, 20 Sep 2018 13:18:13 -0600 Message-Id: <1537471099-19781-39-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 the CLAIM protocol to grab the ownership of the component. Cc: Mathieu Poirier Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-funnel.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c index ee7a30bf9480..927925151509 100644 --- a/drivers/hwtracing/coresight/coresight-funnel.c +++ b/drivers/hwtracing/coresight/coresight-funnel.c @@ -25,6 +25,7 @@ #define FUNNEL_HOLDTIME_MASK 0xf00 #define FUNNEL_HOLDTIME_SHFT 0x8 #define FUNNEL_HOLDTIME (0x7 << FUNNEL_HOLDTIME_SHFT) +#define FUNNEL_ENSx_MASK 0xff /** * struct funnel_drvdata - specifics associated to a funnel component @@ -42,31 +43,42 @@ struct funnel_drvdata { unsigned long priority; }; -static void funnel_enable_hw(struct funnel_drvdata *drvdata, int port) +static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port) { u32 functl; + int rc = 0; CS_UNLOCK(drvdata->base); functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL); + /* Claim the device only when we enable the first slave */ + if (!(functl & FUNNEL_ENSx_MASK)) { + rc = coresight_claim_device_unlocked(drvdata->base); + if (rc) + goto done; + } + functl &= ~FUNNEL_HOLDTIME_MASK; functl |= FUNNEL_HOLDTIME; functl |= (1 << port); writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL); writel_relaxed(drvdata->priority, drvdata->base + FUNNEL_PRICTL); - +done: CS_LOCK(drvdata->base); + return rc; } static int funnel_enable(struct coresight_device *csdev, int inport, int outport) { + int rc; struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); - funnel_enable_hw(drvdata, inport); + rc = funnel_enable_hw(drvdata, inport); - dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport); - return 0; + if (!rc) + dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport); + return rc; } static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport) @@ -79,6 +91,10 @@ static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport) functl &= ~(1 << inport); writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL); + /* Disclaim the device if none of the slaves are now active */ + if (!(functl & FUNNEL_ENSx_MASK)) + coresight_disclaim_device_unlocked(drvdata->base); + CS_LOCK(drvdata->base); }