Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp45244pxb; Thu, 14 Oct 2021 23:47:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwknlrWyI36opChoobWV3uC51LSbN+RolfXjmEyKAFPUVeoAt6cASqYagJzKPwg5sAk1f2J X-Received: by 2002:a17:90b:4c47:: with SMTP id np7mr11528081pjb.22.1634280454653; Thu, 14 Oct 2021 23:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634280454; cv=none; d=google.com; s=arc-20160816; b=n0sIV6GjurYu7gIiuL39MtG0wLas43AbMsmupFh6fWDlBVeGXLhAFyE7BGuvxidNnp 5RQH9L4aMr43cFnowqiCOqxdWw3W+sA7Fy3DDDHoat8sqR6Dzx9uwmWLVRgBI6z97/i4 G2W3pNqMD/iQXed5xULsmkQynceai+v1lTT2Xbj4U8SEtAQapYAMdgLlQy4Psn44SFY7 Tb2OtsHkV25UOSZeJhWVXe4vVsqa6j3620oRboW//pBEF11/LE8ge8GJAD4CcSYE5Nxw HXgHtp5Ozn0HfEoi43YBCdcah6oyZtsjNnXrCEsq0IcRhSUija5tESc0gcSj+mB0V5Dl 6oGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/Dxks3n+CT8tpkTMPzgrau4ERcTEYK4wdvZCUzguPss=; b=r1nS2Y5GXqdR918gYvYc0NMKkJW+e3MkmOJTZTMscWdobM8YUIz6NYN5K6Y2mUqDYg FMXgLw0PIlYDttyf6ZWewAGM4JtZWoHVUL+o+K2XYdmJRFxK11eF5EQdpjhMYNZcUwN+ Tb+cXpc5v7DhrzW80N7iyOxsCVvluCO1p4A31TMumBfdbgW5xlN0p8NorMLWIXdHgle7 g2a/8otftgdVuOoGmWFoCNarKwnSHRDLYlmyIcL3AZIH7x7bk8CY976xD13gAu+Cy9OS TKCfLZg/LR5U1ZVPSwm87NejUORLGaD/x/vmmUKt8uCJOYFiLW/V9XGvSn7AJtTJtiQh dH6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b8si8116133plg.82.2021.10.14.23.46.09; Thu, 14 Oct 2021 23:47:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232277AbhJNWeM (ORCPT + 99 others); Thu, 14 Oct 2021 18:34:12 -0400 Received: from foss.arm.com ([217.140.110.172]:32790 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234278AbhJNWeB (ORCPT ); Thu, 14 Oct 2021 18:34:01 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2385F14BF; Thu, 14 Oct 2021 15:31:56 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AD85D3F694; Thu, 14 Oct 2021 15:31:54 -0700 (PDT) From: Suzuki K Poulose To: will@kernel.org, mathieu.poirier@linaro.org Cc: catalin.marinas@arm.com, anshuman.khandual@arm.com, mike.leach@linaro.org, leo.yan@linaro.org, maz@kernel.org, coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Suzuki K Poulose Subject: [PATCH v5 12/15] coresight: trbe: Make sure we have enough space Date: Thu, 14 Oct 2021 23:31:22 +0100 Message-Id: <20211014223125.2605031-13-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20211014223125.2605031-1-suzuki.poulose@arm.com> References: <20211014223125.2605031-1-suzuki.poulose@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The TRBE driver makes sure that there is enough space for a meaningful run, otherwise pads the given space and restarts the offset calculation once. But there is no guarantee that we may find space or hit "no space". Make sure that we repeat the step until, either : - We have the minimum space OR - There is NO space at all. Cc: Anshuman Khandual Cc: Mathieu Poirier Cc: Mike Leach Cc: Leo Yan Reviewed-by: Mathieu Poirier Signed-off-by: Suzuki K Poulose --- drivers/hwtracing/coresight/coresight-trbe.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-trbe.c b/drivers/hwtracing/coresight/coresight-trbe.c index 4a50309a892d..5fb9f49eab33 100644 --- a/drivers/hwtracing/coresight/coresight-trbe.c +++ b/drivers/hwtracing/coresight/coresight-trbe.c @@ -477,10 +477,14 @@ static unsigned long trbe_normal_offset(struct perf_output_handle *handle) * If the head is too close to the limit and we don't * have space for a meaningful run, we rather pad it * and start fresh. + * + * We might have to do this more than once to make sure + * we have enough required space. */ - if (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { + while (limit && ((limit - head) < trbe_min_trace_buf_size(handle))) { trbe_pad_buf(handle, limit - head); limit = __trbe_normal_offset(handle); + head = PERF_IDX2OFF(handle->head, buf); } return limit; } -- 2.25.4