From patchwork Mon Jun 5 20:15:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 9767407 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0DD7760353 for ; Mon, 5 Jun 2017 20:16:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F2B4C281E1 for ; Mon, 5 Jun 2017 20:16:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E74CB2841E; Mon, 5 Jun 2017 20:16:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6E8DD281E1 for ; Mon, 5 Jun 2017 20:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=ZPcpfOZVuwVYNRgl2zeU2DwVK6x6qDPqfzwvGb8jS4E=; b=QRVu6g5G9GDHy1eNUd1t7VjErf aXdhK2hLO79vrTUy+/nT76ddx3FftqFA9rGeMux8AV8ntbQA/cDs6GOHzMleY0xRmFJY9P42XvR2Q UOeHUhEheLdG+HOY08yN2vA3KTTiA7hVqNJYOqjaZH/rqqbUw86gRc9Iu7qsgoLzqlU3z5W4Pi1ug OiMCdVMXfNpjPmSnNW4jiS8o6Pu455PHfQGNvCOjLtaNoUs3nuWeDHyC1Is9t5wjw2dxRsc6f/mx9 KGzUF0bJBcJyPsBZNDrdYQP4hhb5SBh2jPXLevVyQ/1NN/7kNILBYu8vCwLbpL61OzU4k6GSEuu3Q uwHs+eRw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dHyQR-0000aT-8k; Mon, 05 Jun 2017 20:16:31 +0000 Received: from mail-it0-x233.google.com ([2607:f8b0:4001:c0b::233]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dHyPi-000841-6X for linux-arm-kernel@lists.infradead.org; Mon, 05 Jun 2017 20:15:48 +0000 Received: by mail-it0-x233.google.com with SMTP id r63so89362760itc.1 for ; Mon, 05 Jun 2017 13:15:25 -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=0GRAhXFm44SVlO8vfaxhFLidohSuj9yL59GasgMvc/U=; b=c2Ca8+WA15BhTExAjq3D4EetFDzNdX70cPaexIWFlmvtr4TJwiO/E9+sLlZarSlnFH 5FYhByaQuVsBkGQ4vgOrwVpNC6G0e4eKHlzoBT/9LPEWwDb4KJmq0n3F7YWwhT8/dBWf yrK8anm3oenAqP1goCyqyUaXGM6dxeYgCcItw= 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=0GRAhXFm44SVlO8vfaxhFLidohSuj9yL59GasgMvc/U=; b=AOUjaLM4WTt+ja5ZKDuVRexB1htDxK/xmoePVC4ZiPxEURd38PyGmWV0xLuo2/V2c3 2EcxGRF3pKDHlHrlOtW7qKI1Wg8vPAycleG6YmT3x7vaVcy6g6AJD9vpIOdFNnSM99VU NwdieUyNxrohCD66PcNE5ZHOBorDQt8/fyE3uTYzrSBmv/kWkaHiaOGg7uagDgenKmMS RmWs/Rx36qaCFa4iOyUVMWBsyIU/pvMOfug0Y57S7FYXhi2WB24h1LKg/JJUIAfFn6ek XXp1By5hsjfQ/40pz+xMmo8tOitnUGYjpFevfw4JyiBV9+uJSQzyJFC1lFyrPXO4tZ2D Hbkg== X-Gm-Message-State: AODbwcBkulWyxpiM+kG8EzAwmvcbwz0rwxxZ7UiH+X+4YkKKMjb5+5J0 Pq1vOHRmttbcBm6m X-Received: by 10.107.15.198 with SMTP id 67mr21060881iop.128.1496693725170; Mon, 05 Jun 2017 13:15:25 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 200sm5372369itl.7.2017.06.05.13.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 05 Jun 2017 13:15:23 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 02/17] coresight: Fix reference count for software sources Date: Mon, 5 Jun 2017 14:15:03 -0600 Message-Id: <1496693718-9191-3-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496693718-9191-1-git-send-email-mathieu.poirier@linaro.org> References: <1496693718-9191-1-git-send-email-mathieu.poirier@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170605_131546_602813_C2D1E9C9 X-CRM114-Status: GOOD ( 15.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, leo.yan@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Suzuki K Poulose For software sources (i.e STM), there could be multiple agents generating the trace data, unlike the ETMs. So we need to properly do the accounting for the active number of users to disable the device when the last user goes away. Right now, the reference counting is broken for sources as we skip the actions when we detect that the source is enabled. This patch fixes the problem by adding the refcounting for software sources, even when they are enabled. Cc: Mathieu Poirier Reported-by: Robert Walker Signed-off-by: Suzuki K Poulose Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index 532a2acfa8cc..6a0202b7384f 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -558,6 +558,9 @@ int coresight_enable(struct coresight_device *csdev) int cpu, ret = 0; struct coresight_device *sink; struct list_head *path; + enum coresight_dev_subtype_source subtype; + + subtype = csdev->subtype.source_subtype; mutex_lock(&coresight_mutex); @@ -565,8 +568,16 @@ int coresight_enable(struct coresight_device *csdev) if (ret) goto out; - if (csdev->enable) + if (csdev->enable) { + /* + * There could be multiple applications driving the software + * source. So keep the refcount for each such user when the + * source is already enabled. + */ + if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) + atomic_inc(csdev->refcnt); goto out; + } /* * Search for a valid sink for this session but don't reset the @@ -593,7 +604,7 @@ int coresight_enable(struct coresight_device *csdev) if (ret) goto err_source; - switch (csdev->subtype.source_subtype) { + switch (subtype) { case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: /* * When working from sysFS it is important to keep track