From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758685AbcDHO6B (ORCPT ); Fri, 8 Apr 2016 10:58:01 -0400 Received: from mga11.intel.com ([192.55.52.93]:34810 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758660AbcDHO55 (ORCPT ); Fri, 8 Apr 2016 10:57:57 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,454,1455004800"; d="scan'208";a="81624171" From: Alexander Shishkin To: Greg KH Cc: Mathieu Poirier , Chunyan Zhang , laurent.fert@intel.com, yann.fouassier@intel.com, linux-kernel@vger.kernel.org, Alexander Shishkin Subject: [QUEUED v20160408 18/18] intel_th: msu: Release resources on removal Date: Fri, 8 Apr 2016 17:56:41 +0300 Message-Id: <1460127401-30801-19-git-send-email-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1460127401-30801-1-git-send-email-alexander.shishkin@linux.intel.com> References: <1460127401-30801-1-git-send-email-alexander.shishkin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Do release the resources when msu subdevice gets removed: stop the capture if it is active (which is still possible even though the module in pinned) and free the capture buffers. Signed-off-by: Alexander Shishkin --- drivers/hwtracing/intel_th/msu.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/hwtracing/intel_th/msu.c b/drivers/hwtracing/intel_th/msu.c index bcc3b47133..0974090abc 100644 --- a/drivers/hwtracing/intel_th/msu.c +++ b/drivers/hwtracing/intel_th/msu.c @@ -1492,6 +1492,18 @@ static int intel_th_msc_probe(struct intel_th_device *thdev) static void intel_th_msc_remove(struct intel_th_device *thdev) { + struct msc *msc = dev_get_drvdata(&thdev->dev); + int ret; + + intel_th_msc_deactivate(thdev); + + /* + * Buffers should not be used at this point except if the + * output character device is still open and the parent + * device gets detached from its bus, which is a FIXME. + */ + ret = msc_buffer_free_unless_used(msc); + WARN_ON_ONCE(ret); } static struct intel_th_driver intel_th_msc_driver = { -- 2.8.0.rc3