From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754212AbdKAKMp (ORCPT ); Wed, 1 Nov 2017 06:12:45 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:45076 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751050AbdKAKMo (ORCPT ); Wed, 1 Nov 2017 06:12:44 -0400 Subject: Re: [PATCH 06/17] coresight: tmc: Make ETR SG table circular To: Julien Thierry , linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, robert.walker@arm.com, mike.leach@linaro.org, coresight@lists.linaro.org, mathieu.poirier@linaro.org References: <20171019171553.24056-1-suzuki.poulose@arm.com> <20171019171553.24056-7-suzuki.poulose@arm.com> <28695e86-ad56-847b-dd45-bf5502bd5b01@arm.com> From: Suzuki K Poulose Message-ID: <93b0ae3a-4929-d417-19b2-4c512032a24a@arm.com> Date: Wed, 1 Nov 2017 10:12:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <28695e86-ad56-847b-dd45-bf5502bd5b01@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20/10/17 18:11, Julien Thierry wrote: >> +static int __maybe_unused >> +tmc_etr_sg_table_rotate(struct etr_sg_table *etr_table, u64 base_offset) >> +{ >> +    u32 last_entry, first_entry; >> +    u64 last_offset; >> +    struct tmc_sg_table *sg_table = etr_table->sg_table; >> +    sgte_t *table_ptr = sg_table->table_vaddr; >> +    ssize_t buf_size = tmc_sg_table_buf_size(sg_table); >> + >> +    /* Offset should always be SG PAGE_SIZE aligned */ >> +    if (base_offset & (ETR_SG_PAGE_SIZE - 1)) { >> +        pr_debug("unaligned base offset %llx\n", base_offset); >> +        return -EINVAL; >> +    } >> +    /* Make sure the offset is within the range */ >> +    if (base_offset < 0 || base_offset > buf_size) { > > base_offset is unsigned, so the left operand of the '||' is useless (would've expected the compiler to emit a warning for this). > >> +        base_offset = (base_offset + buf_size) % buf_size; >> +        pr_debug("Resetting offset to %llx\n", base_offset); >> +    } >> +    first_entry = tmc_etr_sg_offset_to_table_index(base_offset); >> +    if (first_entry == etr_table->first_entry) { >> +        pr_debug("Head is already at %llx, skipping\n", base_offset); >> +        return 0; >> +    } >> + >> +    /* Last entry should be the previous one to the new "base" */ >> +    last_offset = ((base_offset - ETR_SG_PAGE_SIZE) + buf_size) % buf_size; >> +    last_entry = tmc_etr_sg_offset_to_table_index(last_offset); >> + >> +    /* Reset the current Last page to Normal and new Last page to NORMAL */ > > Current Last page to NORMAL and new Last page to LAST? Thanks again, will fix them Cheers Suzuki