From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753356AbcDSNPE (ORCPT ); Tue, 19 Apr 2016 09:15:04 -0400 Received: from foss.arm.com ([217.140.101.70]:39855 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752662AbcDSNPC (ORCPT ); Tue, 19 Apr 2016 09:15:02 -0400 Subject: Re: [PATCH V2 07/15] coresight: tmc: allocating memory when needed To: Mathieu Poirier , linux-arm-kernel@lists.infradead.org References: <1460483692-25061-1-git-send-email-mathieu.poirier@linaro.org> <1460483692-25061-8-git-send-email-mathieu.poirier@linaro.org> <57162AA6.3030605@arm.com> Cc: linux-kernel@vger.kernel.org From: Suzuki K Poulose Message-ID: <57162F53.9030308@arm.com> Date: Tue, 19 Apr 2016 14:14:59 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <57162AA6.3030605@arm.com> 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 On 19/04/16 13:55, Suzuki K Poulose wrote: > On 12/04/16 18:54, Mathieu Poirier wrote: >> In it's current form the TMC probe() function allocates >> trace buffer memory at boot time, event if coresight isn't >> used. This is highly inefficient since trace buffers can >> occupy a lot of memory that could be used otherwised. >> >> This patch allocates trace buffers on the fly, when the >> coresight subsystem is solicited. Allocated buffers are >> released when traces are read using the device descriptors >> under /dev. >> >> /* Wait for TMCSReady bit to be set */ >> @@ -110,19 +108,68 @@ static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata) >> >> static int tmc_enable_etf_sink(struct coresight_device *csdev, u32 mode) >> { >> + bool allocated = false; > > nit: does "used" or buf_used sound more suitable than allocated ? > >> + char *buf = NULL; >> unsigned long flags; >> struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); >> >> + /* This shouldn't be happening */ >> + WARN_ON(mode != CS_MODE_SYSFS); And we should proceed no further. Return immediately. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Suzuki.Poulose@arm.com (Suzuki K Poulose) Date: Tue, 19 Apr 2016 14:14:59 +0100 Subject: [PATCH V2 07/15] coresight: tmc: allocating memory when needed In-Reply-To: <57162AA6.3030605@arm.com> References: <1460483692-25061-1-git-send-email-mathieu.poirier@linaro.org> <1460483692-25061-8-git-send-email-mathieu.poirier@linaro.org> <57162AA6.3030605@arm.com> Message-ID: <57162F53.9030308@arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 19/04/16 13:55, Suzuki K Poulose wrote: > On 12/04/16 18:54, Mathieu Poirier wrote: >> In it's current form the TMC probe() function allocates >> trace buffer memory at boot time, event if coresight isn't >> used. This is highly inefficient since trace buffers can >> occupy a lot of memory that could be used otherwised. >> >> This patch allocates trace buffers on the fly, when the >> coresight subsystem is solicited. Allocated buffers are >> released when traces are read using the device descriptors >> under /dev. >> >> /* Wait for TMCSReady bit to be set */ >> @@ -110,19 +108,68 @@ static void tmc_etf_disable_hw(struct tmc_drvdata *drvdata) >> >> static int tmc_enable_etf_sink(struct coresight_device *csdev, u32 mode) >> { >> + bool allocated = false; > > nit: does "used" or buf_used sound more suitable than allocated ? > >> + char *buf = NULL; >> unsigned long flags; >> struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); >> >> + /* This shouldn't be happening */ >> + WARN_ON(mode != CS_MODE_SYSFS); And we should proceed no further. Return immediately.