From patchwork Tue Jun 13 09:38:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 691966 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d91:0:0:0:0:0 with SMTP id b17csp360582wru; Tue, 13 Jun 2023 04:27:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4xbWBRxaV4skFhmOsnmcoLDQCmOu536YD1zn36fcdt0XUA49oR7KyZOJ76wrHvMMKUeC9g X-Received: by 2002:ac8:5b4f:0:b0:3fc:7ef:c9d0 with SMTP id n15-20020ac85b4f000000b003fc07efc9d0mr1704652qtw.62.1686655624934; Tue, 13 Jun 2023 04:27:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686655624; cv=none; d=google.com; s=arc-20160816; b=MpOSzzjoq612qKxvPOz+A6zFK3W62ke/N7MIlWifyvlt7T+vXrWGllFBKSfbfiiDco I7zrS/763znqIwU3gtan0RUVW2AfnaveukN1+rx4fY5TJpRuBwmHixEhsbtYtDHgsJzq +mvb6SvdNbUnEXlJ277m0H1H/mXADv+pbHL/G2DR7HgmMNMt/sFrKLxUHPBxJJ0Uex3o V8461CdQbLoUhX9jkt6yO+fL8Nh8TPvyuuvyh2Rhr9PG/lmxYYP0O5ARKIfvF4BAUj/q LkaV9Les7c0OlyThnYMaVCzMI3wz6YxFKROk7KxI9cVg/6ylOyBiMJ42mpx5gyZalqs1 f9vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=eupMI3Meu8cffWS+qjznZxnt/lkJ4Ptq7I5pw8yZlMY=; b=IQFFw0nuH7YPWhjCzB/qFd/oO8PJhVxdaulRXkYdOO6lGjJJ5QyXP+vlPh6ckkTd5u EYggTibrn6YcU+zn4cROiKUU3YcG8LyREdGouCugSMBDOM7iXepL2k18wetjJ5fattQP kyoSm1RugyMcShRfWWmRfTguJFhcqKVcsYSVG7pY1vkUXFiueHj90OncHYlEP0dMvraj CfPMODA5otHp4PULbCpX13bti6/Wne6qHD+0f9fASBF7NuDpy8fDI1zy6O57FOhREnvI 1sTOgjCsZfPbn+RohoCluUJ47iaRFWXSBQG4b5HH4jQ9qpHhDV7bZjpVbXx4d7JmkNn+ 4boA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K2Vb46AS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z15-20020a05622a028f00b003f6a9bea941si7348033qtw.567.2023.06.13.04.27.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Jun 2023 04:27:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=K2Vb46AS; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q90Uq-0005ew-VW; Tue, 13 Jun 2023 05:39:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q90Up-0005eZ-SB for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:39:27 -0400 Received: from mail-ej1-x635.google.com ([2a00:1450:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1q90Uj-0005df-SQ for qemu-devel@nongnu.org; Tue, 13 Jun 2023 05:39:27 -0400 Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-9745d99cfccso937839466b.1 for ; Tue, 13 Jun 2023 02:39:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1686649159; x=1689241159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eupMI3Meu8cffWS+qjznZxnt/lkJ4Ptq7I5pw8yZlMY=; b=K2Vb46ASF7WJ45/pWoE+CvyqBsi3zplG7pR4R2HR8XgsS2gLwQatnABew+2l3dLof6 Qt/X4cnfNlq0xpKVhZaADfy6XfTiEJLjguRDeMSHd4ztui73693xVi21mEiF3Uhqx0pR YRKirmzTgX1GertNwhFYaosB4qTLbxJMFTJPXwIi2uh5WlLKtfSZCVFc76KMjoCpqa2S v+JhWM0wZaHHZgyDBzGpIAtp3DRhGyqLzwxCm+CCsFuNSRyC3mcF1RbSmbExTOYscn9C 2JwNAWJHHLB02mCN05ZqkoybJbblASlRNnOSmlA9etqxksl6DHDQvtNa/2+aO+d9AH67 UGsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686649159; x=1689241159; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eupMI3Meu8cffWS+qjznZxnt/lkJ4Ptq7I5pw8yZlMY=; b=ZIYvoKvIC6/lwYAafAbPzdwwIMbBhoaHsBptW53XNciBjsnxJP+ehI7PgAA1L0Of/9 oS4kZY4/EygVbDoyWySnGGvMVhsw27es09AUXjmDHqOebL82aNXU2jb96FZuy8pUVoAu X682xcKVQLv778Gfsb3bmZaGYKSIiI/S2HYMEZOK8uHcMcLurTBZ72lULG+LDbP3O6Qp oxpw/4lw08Y0iZ5yB9b3fTi4czHeh+j92QKnC+PRJxCqH8R6qnPJVobctQfkR4MsgEG5 /b2K7JGwUiaF8lp3IpJf/Gs2wHfd/SVBDQstLsHQK9AHo742kZ0sonvVWTa2Cf/iiaen BbUw== X-Gm-Message-State: AC+VfDwzXMeYFvh0Vc6rQUulCUhpFC3y3XKmVFKP32BE8waCx0y2tfK7 kSpYIcnQJfHqWTyVwjQnTuMO1tY//bGsDsMK+ejEHA== X-Received: by 2002:a17:907:7da9:b0:973:93d6:189f with SMTP id oz41-20020a1709077da900b0097393d6189fmr14472263ejc.61.1686649159550; Tue, 13 Jun 2023 02:39:19 -0700 (PDT) Received: from localhost.localdomain ([185.140.244.249]) by smtp.gmail.com with ESMTPSA id m25-20020a1709062b9900b0096637a19dccsm6318257ejg.210.2023.06.13.02.39.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 13 Jun 2023 02:39:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Hannes Reinecke Subject: [PULL 12/17] hw/scsi/megasas: Silent GCC duplicated-cond warning Date: Tue, 13 Jun 2023 11:38:17 +0200 Message-Id: <20230613093822.63750-13-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230613093822.63750-1-philmd@linaro.org> References: <20230613093822.63750-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::635; envelope-from=philmd@linaro.org; helo=mail-ej1-x635.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé GCC9 is confused when building with CFLAG -O3: hw/scsi/megasas.c: In function ‘megasas_scsi_realize’: hw/scsi/megasas.c:2387:26: error: duplicated ‘if’ condition [-Werror=duplicated-cond] 2387 | } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) { hw/scsi/megasas.c:2385:19: note: previously used here 2385 | if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) { cc1: all warnings being treated as errors When this device was introduced in commit e8f943c3bcc, the author cared about modularity, using a definition for the firmware limit. However if the firmware limit isn't changed (MEGASAS_MAX_SGE = 128), the code ends doing the same check twice. Per the maintainer [*]: > The original code assumed that one could change MFI_PASS_FRAME_SIZE, > but it turned out not to be possible as it's being hardcoded in the > drivers themselves (even though the interface provides mechanisms to > query it). So we can remove the duplicate lines. Add the 'MEGASAS_MIN_SGE' definition for the '64' magic value, slightly rewrite the condition check to simplify a bit the logic and remove the unnecessary / duplicated check. [*] https://lore.kernel.org/qemu-devel/e0029fc5-882f-1d63-15e3-1c3dbe9b6a2c@suse.de/ Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Hannes Reinecke Message-Id: <20230328210126.16282-1-philmd@linaro.org> --- hw/scsi/megasas.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 9cbbb16121..32c70c9e99 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -42,6 +42,7 @@ #define MEGASAS_MAX_FRAMES 2048 /* Firmware limit at 65535 */ #define MEGASAS_DEFAULT_FRAMES 1000 /* Windows requires this */ #define MEGASAS_GEN2_DEFAULT_FRAMES 1008 /* Windows requires this */ +#define MEGASAS_MIN_SGE 64 #define MEGASAS_MAX_SGE 128 /* Firmware limit */ #define MEGASAS_DEFAULT_SGE 80 #define MEGASAS_MAX_SECTORS 0xFFFF /* No real limit */ @@ -2356,6 +2357,7 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp) MegasasState *s = MEGASAS(dev); MegasasBaseClass *b = MEGASAS_GET_CLASS(s); uint8_t *pci_conf; + uint32_t sge; int i, bar_type; Error *err = NULL; int ret; @@ -2424,13 +2426,15 @@ static void megasas_scsi_realize(PCIDevice *dev, Error **errp) if (!s->hba_serial) { s->hba_serial = g_strdup(MEGASAS_HBA_SERIAL); } - if (s->fw_sge >= MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE) { - s->fw_sge = MEGASAS_MAX_SGE - MFI_PASS_FRAME_SIZE; - } else if (s->fw_sge >= 128 - MFI_PASS_FRAME_SIZE) { - s->fw_sge = 128 - MFI_PASS_FRAME_SIZE; - } else { - s->fw_sge = 64 - MFI_PASS_FRAME_SIZE; + + sge = s->fw_sge + MFI_PASS_FRAME_SIZE; + if (sge < MEGASAS_MIN_SGE) { + sge = MEGASAS_MIN_SGE; + } else if (sge >= MEGASAS_MAX_SGE) { + sge = MEGASAS_MAX_SGE; } + s->fw_sge = sge - MFI_PASS_FRAME_SIZE; + if (s->fw_cmds > MEGASAS_MAX_FRAMES) { s->fw_cmds = MEGASAS_MAX_FRAMES; }