Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbdFEJYq (ORCPT ); Mon, 5 Jun 2017 05:24:46 -0400 Received: from foss.arm.com ([217.140.101.70]:59220 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751300AbdFEJYp (ORCPT ); Mon, 5 Jun 2017 05:24:45 -0400 Subject: Re: [PATCH v1 2/4] coresight: add and remove panic callback for sink To: Leo Yan , Mathieu Poirier , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mike Leach , Chunyan Zhang References: <1496500976-18362-1-git-send-email-leo.yan@linaro.org> <1496500976-18362-3-git-send-email-leo.yan@linaro.org> From: Suzuki K Poulose Message-ID: Date: Mon, 5 Jun 2017 10:24:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1496500976-18362-3-git-send-email-leo.yan@linaro.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1609 Lines: 47 On 03/06/17 15:42, Leo Yan wrote: > If the sink device has panic callback function, add the panic callback > node for coresight panic dump list when the sink device is enabled; > also cleanup the node when the sink device is disabled. > > Signed-off-by: Leo Yan > --- > drivers/hwtracing/coresight/coresight.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c > index 0c37356..5928886 100644 > --- a/drivers/hwtracing/coresight/coresight.c > +++ b/drivers/hwtracing/coresight/coresight.c > @@ -138,6 +138,13 @@ static int coresight_enable_sink(struct coresight_device *csdev, u32 mode) > if (ret) > return ret; > } > + > + /* Add kernel panic callback */ > + if (sink_ops(csdev)->panic_cb) { > + ret = coresight_add_panic_cb(csdev); > + if (ret) > + return ret; > + } > csdev->enable = true; > } > > @@ -149,6 +156,10 @@ static int coresight_enable_sink(struct coresight_device *csdev, u32 mode) > static void coresight_disable_sink(struct coresight_device *csdev) > { > if (atomic_dec_return(csdev->refcnt) == 0) { > + /* Remove kernel panic callback */ > + if (sink_ops(csdev)->panic_cb) > + coresight_del_panic_cb(csdev); > + > if (sink_ops(csdev)->disable) { > sink_ops(csdev)->disable(csdev); > csdev->enable = false; > Just a thought, instead of adding/deleting every time the sink is enabled, could we add/del the device once for-ever and let the panic_cb decide to dump it based on whether the device was active or not ? Suzuki