From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59AB9C433B4 for ; Thu, 1 Apr 2021 09:18:09 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 863B0600EF for ; Thu, 1 Apr 2021 09:18:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 863B0600EF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=amsat.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:58262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lRtSp-0003Ba-8S for qemu-devel@archiver.kernel.org; Thu, 01 Apr 2021 05:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lRtRN-0002YO-Df for qemu-devel@nongnu.org; Thu, 01 Apr 2021 05:16:37 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:45672) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lRtRL-0003Ae-9b for qemu-devel@nongnu.org; Thu, 01 Apr 2021 05:16:36 -0400 Received: by mail-wr1-x42a.google.com with SMTP id j9so1053565wrx.12 for ; Thu, 01 Apr 2021 02:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=8AvdzUu0nfjpl785PRn7wGCNF0V+8WeLCO4Fzx85K8U=; b=BgFU3hOZcBoNQSfEtfUnwXlea2+sxN3gooBdui1pAkmKPzj2/Z0IrkIn3Ajjs+XStv /AVQqQb/aFY27ao9+uu6rpADYtJ5YITdAp14a1U/HREtuEPELwc3kHPOyjT5RQdilpKW RsEtLUNG/xBMsOBzCk9PcB0VUl1XfalbVw0GHITb6LjEnTQj0EgwndVUQwZyW4nejaam s4FsmppnAYiYxOsBNW8aAqXpw2hge+YuxRFnR6eOxAtmQqizn4cqQNyL3fyKn83HL4ya Ma0jKEwCSFWC+/OkbdyyQtROqIyUVSBdVI4EktFd+fnk8py7JiwjMoO7I3QBlfSBNl7H NELg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=8AvdzUu0nfjpl785PRn7wGCNF0V+8WeLCO4Fzx85K8U=; b=i6NevLRskQTtv2dGk7h6HHnpvqel8RGjuOPqnTeoTUzY5X+Y+j19hPhAOftHfifpYN +gxk8zvoR9dXfk3gc+BWsBseAe4ns+IDZILReh1J5ihpxJ7qnpEn4PxZXuDwxq+LCqI6 IPaHK4NCHX5kE38riv1iOIV65h6+dJmtnYipQSqbe/5pTvPHgtGv+TXNnIQriqcW2QJh EuRf6+e6e9x3xBZ6XLYNb/745vAHYB5WgZ+RlGD09LXkrdMlaWgFRiHc6nIp2DkEQktc 3OtkM8gNKhsdhWxT66esSFlQR/1Vsn/A2F03BTXkOl8+Wj0DQShgtxO0Qu+BhIQ9emLv rokA== X-Gm-Message-State: AOAM533y+G533WCVUXhmptds6WKWMVuU2PCkEWxAVEriCrD96ayaecgR 9jnW5ZQefDNL+Fk+5ZWY7i0= X-Google-Smtp-Source: ABdhPJx61eeo6IkfkMlLVbC1naTT7SS01QNX0KEHuGi8AyLTPghyS8WFh2AVBw1CUezrpBlY0c5t2w== X-Received: by 2002:a5d:698e:: with SMTP id g14mr8254912wru.127.1617268592607; Thu, 01 Apr 2021 02:16:32 -0700 (PDT) Received: from [192.168.1.36] (17.red-88-21-201.staticip.rima-tde.net. [88.21.201.17]) by smtp.gmail.com with ESMTPSA id f4sm9082415wrz.4.2021.04.01.02.16.31 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Apr 2021 02:16:31 -0700 (PDT) Subject: Re: [PATCH v3 03/11] esp: consolidate esp_cmdfifo_push() into esp_fifo_push() To: Mark Cave-Ayland , qemu-devel@nongnu.org, alxndr@bu.edu, laurent@vivier.eu, pbonzini@redhat.com References: <20210401074933.9923-1-mark.cave-ayland@ilande.co.uk> <20210401074933.9923-4-mark.cave-ayland@ilande.co.uk> <0629537e-f168-020b-7252-8e59028c62b3@ilande.co.uk> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= Message-ID: Date: Thu, 1 Apr 2021 11:16:30 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <0629537e-f168-020b-7252-8e59028c62b3@ilande.co.uk> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.249, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On 4/1/21 10:50 AM, Mark Cave-Ayland wrote: > On 01/04/2021 09:15, Philippe Mathieu-Daudé wrote: > >> On 4/1/21 9:49 AM, Mark Cave-Ayland wrote: >>> Each FIFO currently has its own push functions with the only >>> difference being >>> the capacity check. The original reason for this was that the fifo8 >>> implementation doesn't have a formal API for retrieving the FIFO >>> capacity, >>> however there are multiple examples within QEMU where the capacity >>> field is >>> accessed directly. >> >> So the Fifo8 API is not complete / practical. > > I guess it depends what you consider to be public and private to Fifo8: > what is arguably missing is something like: > > int fifo8_capacity(Fifo8 *fifo) > { >     return fifo->capacity; > } > > But given that most other users access fifo->capacity directly then I > might as well do the same and save myself requiring 2 separate > implementations of esp_fifo_pop_buf() :) Sorry, I should have been more explicit by precising this was not a comment directed to your patch, but I was thinking loudly about the Fifo8 API; and as you mentioned the other models do that so your kludge is acceptable. >>> Change esp_fifo_push() to access the FIFO capacity directly and then >>> consolidate >>> esp_cmdfifo_push() into esp_fifo_push(). >>> >>> Signed-off-by: Mark Cave-Ayland >>> --- >>>   hw/scsi/esp.c | 27 ++++++++------------------- >>>   1 file changed, 8 insertions(+), 19 deletions(-) >>> >>> diff --git a/hw/scsi/esp.c b/hw/scsi/esp.c >>> index 26fe1dcb9d..16aaf8be93 100644 >>> --- a/hw/scsi/esp.c >>> +++ b/hw/scsi/esp.c >>> @@ -98,16 +98,15 @@ void esp_request_cancelled(SCSIRequest *req) >>>       } >>>   } >>>   -static void esp_fifo_push(ESPState *s, uint8_t val) >>> +static void esp_fifo_push(Fifo8 *fifo, uint8_t val) >>>   { >>> -    if (fifo8_num_used(&s->fifo) == ESP_FIFO_SZ) { >>> +    if (fifo8_num_used(fifo) == fifo->capacity) { >>>           trace_esp_error_fifo_overrun(); >>>           return; >>>       } >>>   -    fifo8_push(&s->fifo, val); >>> +    fifo8_push(fifo, val); >>>   } >>> - >> >> Spurious line removal? > > Ooops yes. I'm not too worried about this, but if Paolo has any other > changes then I can roll this into a v4. Actually it reappears in patch 05/11 ;)