From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23C2BC433DF for ; Mon, 18 May 2020 18:04:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF80E20715 for ; Mon, 18 May 2020 18:04:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Vidv/ntQ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ytD2QjeX" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF80E20715 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=pKuMrPFYMm/PnEeIUTUQ/r57MH4wFxm5k625tnKmiLc=; b=Vidv/ntQW0xfXI jCRtcNExRo3DcZnHhnDWQMF2F8ocAFAL5pR6sgeYWNhDZYZbwQit/p1Li0OAjPlIC7Z/OnX7oR6jX 15OfR1ho84WSjgrKcFGX6rqipeswOyib0e5WAFiq9rhDn3OixVKuIjPtkwGj2V1Pfs1chu9N6kDpC /rKIYh7SS/lbCQs2zQdq5SUT848ZZXyn9LVUvXMrpK/cWgECrbNqRou8GJkAceiooPor5i8bRRVHg vtB8l35vckxi+4AKHKFx5M/JkUVDf4T2MEQHiH8OctKhWkeKEg6KOO0Mh+88lP6M1bMp56CVaGPgn dE9gSi2f4haIRNgZEGCA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jak7V-0004LU-Aq; Mon, 18 May 2020 18:04:09 +0000 Received: from mail-pj1-x1042.google.com ([2607:f8b0:4864:20::1042]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jak6E-0003Gp-1G for linux-arm-kernel@lists.infradead.org; Mon, 18 May 2020 18:02:53 +0000 Received: by mail-pj1-x1042.google.com with SMTP id k7so185897pjs.5 for ; Mon, 18 May 2020 11:02:49 -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 :mime-version:content-transfer-encoding; bh=0qup2xfzyR/Fig7E6oaQXo8Xo2JibJ08tYflWG0z/rg=; b=ytD2QjeXDZrbc8HRk73YatO30g/33jOPq/+y+srGwAQEgtfofNjqlW68+UAby2WZxh K0OOt5OIKplgSdawJHU3QxysPrrEORtf8xNfsVmgCOIviXJ1M2Mjw6R5alQZFA6gFYnH zSi4jbwLkOjo3LsUpaMCde8DHhtnXjS6QwrWm4hJxeIMI7zkrSx+GRc4zfdjB5N+PCDv 5qIk85wkYbIQ0aDRQNUSPlzKFOTu8ecG4HFxHW9rzmHLFPHzWIra91lrwmVGcysxtGva gYElEfjLHJyQsiabWrPcLiY5IvHGcHVPQxUUbQN3oiG0YnChjhHK5i3k82yVmO/K1sTA r1hA== 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:mime-version:content-transfer-encoding; bh=0qup2xfzyR/Fig7E6oaQXo8Xo2JibJ08tYflWG0z/rg=; b=llXawlOKQGvZmhrZtNz4B7XX3l1Wi26M7lTSk0YlZBnQmoTwPE54J1oxwPw6LmPW4k wAwUVU2P8pPGNYmXiHcapknZKxWEXf6F5dyGh4HPfT7YJ39GOq1+dLuAwtzbOSuK1guQ xWg9P2t09IHHa2MPKUP9Fp1Rs2ilPeFJsPR+H3G/BQQ/fAjs/4uTUGNFoMCWSJUDqZfF ngUxK3bz3Qx0xNG/W61NTXOSD0qegP138GDh0U4X9iCPSRNghb8euO8700TAXwBsrPAC SPGsd8rXiNESclDXTRYDF/eYJ62c31eve56o1H2bFN9oGmvL1/KUT9XunkAWAzC/svLG SQpw== X-Gm-Message-State: AOAM533QEH2mcUakjE6yAVciyESIt+uFCRUmz9aUsS4gJmrVqz8ka190 wXH/9xyVL+yx6ihbjyOxDRRo9A== X-Google-Smtp-Source: ABdhPJxItxOuiaDBzTApsq2ElULgX5D34VOHCWN5PhW3MOaM1qCraWmrkBHYmVFQyTNsccVJ+KvAiA== X-Received: by 2002:a17:902:9686:: with SMTP id n6mr17944319plp.100.1589824969267; Mon, 18 May 2020 11:02:49 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id v3sm9212314pfv.186.2020.05.18.11.02.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 11:02:48 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 05/23] coresight: cti: Add in sysfs links to other coresight devices Date: Mon, 18 May 2020 12:02:24 -0600 Message-Id: <20200518180242.7916-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200518180242.7916-1-mathieu.poirier@linaro.org> References: <20200518180242.7916-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200518_110250_111867_C296A041 X-CRM114-Status: GOOD ( 15.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Mike Leach Adds in sysfs links for connections where the connected device is another coresight device. This allows examination of the coresight topology. Non-coresight connections remain just as a reference name. Signed-off-by: Mike Leach Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-cti.c | 52 +++++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti.c b/drivers/hwtracing/coresight/coresight-cti.c index aa6e0249bd70..9e262f5a85e3 100644 --- a/drivers/hwtracing/coresight/coresight-cti.c +++ b/drivers/hwtracing/coresight/coresight-cti.c @@ -442,6 +442,34 @@ int cti_channel_setop(struct device *dev, enum cti_chan_set_op op, return err; } +static bool cti_add_sysfs_link(struct cti_drvdata *drvdata, + struct cti_trig_con *tc) +{ + struct coresight_sysfs_link link_info; + int link_err = 0; + + link_info.orig = drvdata->csdev; + link_info.orig_name = tc->con_dev_name; + link_info.target = tc->con_dev; + link_info.target_name = dev_name(&drvdata->csdev->dev); + + link_err = coresight_add_sysfs_link(&link_info); + if (link_err) + dev_warn(&drvdata->csdev->dev, + "Failed to set CTI sysfs link %s<=>%s\n", + link_info.orig_name, link_info.target_name); + return !link_err; +} + +static void cti_remove_sysfs_link(struct cti_trig_con *tc) +{ + struct coresight_sysfs_link link_info; + + link_info.orig_name = tc->con_dev_name; + link_info.target = tc->con_dev; + coresight_remove_sysfs_link(&link_info); +} + /* * Look for a matching connection device name in the list of connections. * If found then swap in the csdev name, set trig con association pointer @@ -452,6 +480,8 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, struct coresight_device *csdev) { struct cti_trig_con *tc; + struct cti_drvdata *drvdata = container_of(ctidev, struct cti_drvdata, + ctidev); list_for_each_entry(tc, &ctidev->trig_cons, node) { if (tc->con_dev_name) { @@ -459,7 +489,12 @@ cti_match_fixup_csdev(struct cti_device *ctidev, const char *node_name, /* match: so swap in csdev name & dev */ tc->con_dev_name = dev_name(&csdev->dev); tc->con_dev = csdev; - return true; + /* try to set sysfs link */ + if (cti_add_sysfs_link(drvdata, tc)) + return true; + /* link failed - remove CTI reference */ + tc->con_dev = NULL; + break; } } } @@ -522,6 +557,7 @@ void cti_remove_assoc_from_csdev(struct coresight_device *csdev) ctidev = &ctidrv->ctidev; list_for_each_entry(tc, &ctidev->trig_cons, node) { if (tc->con_dev == csdev->ect_dev) { + cti_remove_sysfs_link(tc); tc->con_dev = NULL; break; } @@ -543,10 +579,16 @@ static void cti_update_conn_xrefs(struct cti_drvdata *drvdata) struct cti_device *ctidev = &drvdata->ctidev; list_for_each_entry(tc, &ctidev->trig_cons, node) { - if (tc->con_dev) - /* set tc->con_dev->ect_dev */ - coresight_set_assoc_ectdev_mutex(tc->con_dev, + if (tc->con_dev) { + /* if we can set the sysfs link */ + if (cti_add_sysfs_link(drvdata, tc)) + /* set the CTI/csdev association */ + coresight_set_assoc_ectdev_mutex(tc->con_dev, drvdata->csdev); + else + /* otherwise remove reference from CTI */ + tc->con_dev = NULL; + } } } @@ -559,6 +601,8 @@ static void cti_remove_conn_xrefs(struct cti_drvdata *drvdata) if (tc->con_dev) { coresight_set_assoc_ectdev_mutex(tc->con_dev, NULL); + cti_remove_sysfs_link(tc); + tc->con_dev = NULL; } } } -- 2.20.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel