From patchwork Tue Nov 21 03:08:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Yan X-Patchwork-Id: 10067609 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 CA30B603FA for ; Tue, 21 Nov 2017 03:10:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7F8F28EAB for ; Tue, 21 Nov 2017 03:10:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACAA928EDD; Tue, 21 Nov 2017 03:10:05 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 41DFD28EAB for ; Tue, 21 Nov 2017 03:10:04 +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=WjfCO5LK7HV5LR3KrNcFNTwUt6BSEDu4AXPjP5zYoOM=; b=ptnzzVHkQsQ3JEPuIRNCU/3h3S K11nKm03TPQ8Mi5awpELNL55ov2CMkhDGygHCWpBfAk/YLEZBkZRlmwL2DSKudgOiAvDNb5HUfVkv 8u9OpUn/uT8o5JyC3BlxtDB9g2Fxo4a59iuui4aH8U3uA26w1al1vHipSEFoRy/9a2mmZhNdwQpj7 w/f9LP+FbGAUv5vKZqlDkHhcLMVhoCzs6ErdfZoAFtAHvPhPCefXcje6t1u4l4MYdBzm4rTi2vT05 lmVaQAkjFy0M+Z2movhFr7rbTQD8UeLF9STkuImVlJ2CL81y2dt1RojwSgf7GhhJt1z+G2iBQORNA RMshA2pg==; 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 1eGywY-0000GP-6M; Tue, 21 Nov 2017 03:09:50 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eGywU-0000Ey-K1 for linux-arm-kernel@lists.infradead.org; Tue, 21 Nov 2017 03:09:48 +0000 Received: by mail-wr0-x243.google.com with SMTP id 4so9967723wrt.0 for ; Mon, 20 Nov 2017 19:09:27 -0800 (PST) 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=cgMQ9x6YDoX30vhU2Eq16T/DCBBM3qvqkq7/8M5Opgc=; b=eTGzfIsQKIR5+MGsIvA+mXF240j86JejVYdlD4JfgFILvoIRP9PEGnoPbCfPx4PDvo 5aQLr94/GOUXyPz8Q1giUXvFcEggVyYB/gYwR3cdP56BRTlGV+8XPwy4vQ7YsQRPrAlC wbVVaUIwQRDQkSivH3i8X5efWpGCV7NV1UjeE= 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=cgMQ9x6YDoX30vhU2Eq16T/DCBBM3qvqkq7/8M5Opgc=; b=juploD2JrLuYDlZzPiX+IDDnHGdQrAdfRNVPuSHCkd31J4p/ZU9TG/nsArbhNuAQda FsDmZTitqCSfFd2CumqWCaGoUYJpeRcM+p4nfbIvRGUvgbvVbIB5Y30twqhZPbGRYvaG fOvHmRnwF9eplQNww3n66a1CezhyvEfTWHrr0wUvbi1+JmyCydXtwqugJpLqAWfxDQGt 8X34pBelY9hbo6Dvpf0QwP75HuYfvoK+H7QIEqMpD0k8pIz1FG1VdDzxj8L2vQW72Q5u OGHks7UvjOWlApJezZyjr6CtrrAxizcAl5S0qWDNcJU3RTvFh8hv5K7a/BwIegLChzKc qVwQ== X-Gm-Message-State: AJaThX4ruvgGKbgoRLjY12wpdfg6AOUmOd9n1Zq7QVubXptG+N9H12cP +yer8M6MGVgGG5tDK0qKZPY8mnYIvp0= X-Google-Smtp-Source: AGs4zMZDoXjjzgVbYQORNHkeE67IJcmOA2qT0yl9u2cjG51iMlIZsWHK7NB7xPbOwasEKWtXnw7onw== X-Received: by 10.223.186.142 with SMTP id p14mr13760546wrg.169.1511233765942; Mon, 20 Nov 2017 19:09:25 -0800 (PST) Received: from localhost.localdomain (li1530-42.members.linode.com. [139.162.245.42]) by smtp.gmail.com with ESMTPSA id z192sm103550wmc.32.2017.11.20.19.09.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Nov 2017 19:09:25 -0800 (PST) From: Leo Yan To: Mathieu Poirier , linux-arm-kernel@lists.infradead.org, CoreSight@lists.linaro.org Subject: [PATCH v2 2/4] coresight: Add and delete dump node for registration/unregistration Date: Tue, 21 Nov 2017 11:08:42 +0800 Message-Id: <1511233724-11867-3-git-send-email-leo.yan@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511233724-11867-1-git-send-email-leo.yan@linaro.org> References: <1511233724-11867-1-git-send-email-leo.yan@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171120_190946_808726_3585651D X-CRM114-Status: UNSURE ( 9.89 ) X-CRM114-Notice: Please train this message. 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: Leo Yan 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 Coresight device registration is a proper time point to insert dump node, the dump code utilizes the coresight device has panic callback function pointer as flag to indicate if need insert panic node or not. If the coresight device has panic callback function isn't NULL, then allocates dump node and inserts node into list, otherwise directly bail out with success. When coresight device unregistration, it removes dump node from list and releases resource properly. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c index b8091be..3248f9b 100644 --- a/drivers/hwtracing/coresight/coresight.c +++ b/drivers/hwtracing/coresight/coresight.c @@ -1044,6 +1044,10 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) if (ret) goto err_device_register; + ret = coresight_dump_add(csdev, desc->pdata ? desc->pdata->cpu : 0); + if (ret) + goto err_dump_add; + mutex_lock(&coresight_mutex); coresight_fixup_device_conns(csdev); @@ -1053,6 +1057,8 @@ struct coresight_device *coresight_register(struct coresight_desc *desc) return csdev; +err_dump_add: + device_unregister(&csdev->dev); err_device_register: kfree(conns); err_kzalloc_conns: @@ -1068,6 +1074,7 @@ void coresight_unregister(struct coresight_device *csdev) { /* Remove references of that device in the topology */ coresight_remove_conns(csdev); + coresight_dump_del(csdev); device_unregister(&csdev->dev); } EXPORT_SYMBOL_GPL(coresight_unregister);