Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp108738ybg; Mon, 8 Jun 2020 17:50:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqklDVkl5rxdNzowFVFxR8/zGUG34HpyyH50TL0fDBq9ldT3Ci9r1FrkI5tBPqi62Qag6w X-Received: by 2002:aa7:ce13:: with SMTP id d19mr25188280edv.355.1591663838311; Mon, 08 Jun 2020 17:50:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591663838; cv=none; d=google.com; s=arc-20160816; b=h6O0l1E2CBCfEfPh4qb3OI/WsDd3W2+4s+93Mxj6TdOqRyp7veHzxzMGn6LupHytKq YYCb+JoFoTzMV6huumHFsq105ud87gdiBYSOsqk+zBS4Eub02N1NifVG+E/7Hhf71WU3 jAtWFPhrDaIZOc6CK+nkIaj2NQfvIRfW72QU4jh/mQO8R8nifH3tZ2E1bZSwvdR058XO 2YbwswRe8vd+MQL9L1/WCYrpymb9DTWPnf5bt8Qpgf7c7/E9lWZKgX9m2qnQClJf9gq4 HZRNg29up8rhUgSqVNOHEFu/70icvT0+d2wMHNGPXhhBcJWVUxQtbsy8OMVmKiSYN1yy 7HyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Po8EsdPXsRN+7gGwXj/iQePRaMoUCgUG93lS01vp6PQ=; b=U3BbczXzy7Pdlg6NdBLs/njWeDr/xGPUMuSSEczq5fLFj86X/DQX1iTpT77eTrT41s hahADJtz7xwXzNza37pBRmw/rpFFst6sXkEKG7IYirbBEbXGj0Hj/YCNFYhy2gWSHCKn PEsTZ0tho1GgHFWDyxeacB8KBK/dIad1NLabX4Qc3VS7oU9mfQhffyKyf+gNMVgmWYaL O7dFHJY0F/8XGmcBNJGWWQWSQqu6f5Ry7siWlWVUHM+QIPdm071Kei1YgR42IJLCi4mE qYDMCbma8R6aEHAHmnmdlexjdC2BL2jRK/EjWcWsR7Gx2PeSAMHJ+pC8zZGZK3YBBnzD 7u0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1DKeL21O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q22si4959743edb.541.2020.06.08.17.50.14; Mon, 08 Jun 2020 17:50:38 -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; dkim=pass header.i=@kernel.org header.s=default header.b=1DKeL21O; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732892AbgFIAsh (ORCPT + 99 others); Mon, 8 Jun 2020 20:48:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728781AbgFHXKy (ORCPT ); Mon, 8 Jun 2020 19:10:54 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9AE4520890; Mon, 8 Jun 2020 23:10:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657852; bh=HeE/HJwWUMBmoDka4WbFolryeFAQ61D7D/Kmtai3kmM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1DKeL21O6lceXBAw4EJv2ne46NvKRPe9DCtkfU0aM/o22nCH2+GmMDJjc8OpJvT1O XnSgY+IIeWaTlLpqErL0yuDSeU0S6MdnZN9SJy6qIEDMKv7rUKC40OyU+giziVSbFn O/yXHc0jhO13w5tRnt9KFW6FCkvMMcZAvdYYhq4M= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jesse Brandeburg , Andrew Bowers , Jeff Kirsher , Sasha Levin , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 217/274] ice: cleanup vf_id signedness Date: Mon, 8 Jun 2020 19:05:10 -0400 Message-Id: <20200608230607.3361041-217-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jesse Brandeburg [ Upstream commit 53bb66983f34d4ff0af179fe228e2c55e1e45921 ] The vf_id variable is dealt with in the code in inconsistent ways of sign usage, preventing compilation with -Werror=sign-compare. Fix this problem in the code by always treating vf_id as unsigned, since there are no valid values of vf_id that are negative. Signed-off-by: Jesse Brandeburg Tested-by: Andrew Bowers Signed-off-by: Jeff Kirsher Signed-off-by: Sasha Levin --- drivers/net/ethernet/intel/ice/ice.h | 2 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 17 +++++++++-------- .../net/ethernet/intel/ice/ice_virtchnl_pf.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h index 5c11448bfbb3..020ee167f73a 100644 --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -366,7 +366,7 @@ struct ice_pf { struct ice_sw *first_sw; /* first switch created by firmware */ /* Virtchnl/SR-IOV config info */ struct ice_vf *vf; - int num_alloc_vfs; /* actual number of VFs allocated */ + u16 num_alloc_vfs; /* actual number of VFs allocated */ u16 num_vfs_supported; /* num VFs supported for this PF */ u16 num_qps_per_vf; u16 num_msix_per_vf; diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c index 15191a325918..c9c281167873 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c @@ -10,10 +10,11 @@ * @pf: pointer to the PF structure * @vf_id: the ID of the VF to check */ -static int ice_validate_vf_id(struct ice_pf *pf, int vf_id) +static int ice_validate_vf_id(struct ice_pf *pf, u16 vf_id) { + /* vf_id range is only valid for 0-255, and should always be unsigned */ if (vf_id >= pf->num_alloc_vfs) { - dev_err(ice_pf_to_dev(pf), "Invalid VF ID: %d\n", vf_id); + dev_err(ice_pf_to_dev(pf), "Invalid VF ID: %u\n", vf_id); return -EINVAL; } return 0; @@ -27,7 +28,7 @@ static int ice_validate_vf_id(struct ice_pf *pf, int vf_id) static int ice_check_vf_init(struct ice_pf *pf, struct ice_vf *vf) { if (!test_bit(ICE_VF_STATE_INIT, vf->vf_states)) { - dev_err(ice_pf_to_dev(pf), "VF ID: %d in reset. Try again.\n", + dev_err(ice_pf_to_dev(pf), "VF ID: %u in reset. Try again.\n", vf->vf_id); return -EBUSY; } @@ -337,7 +338,7 @@ void ice_free_vfs(struct ice_pf *pf) * before this function ever gets called. */ if (!pci_vfs_assigned(pf->pdev)) { - int vf_id; + unsigned int vf_id; /* Acknowledge VFLR for all VFs. Without this, VFs will fail to * work correctly when SR-IOV gets re-enabled. @@ -368,9 +369,9 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr) { struct ice_pf *pf = vf->pf; u32 reg, reg_idx, bit_idx; + unsigned int vf_abs_id, i; struct device *dev; struct ice_hw *hw; - int vf_abs_id, i; dev = ice_pf_to_dev(pf); hw = &pf->hw; @@ -418,7 +419,7 @@ static void ice_trigger_vf_reset(struct ice_vf *vf, bool is_vflr, bool is_pfr) if ((reg & VF_TRANS_PENDING_M) == 0) break; - dev_err(dev, "VF %d PCI transactions stuck\n", vf->vf_id); + dev_err(dev, "VF %u PCI transactions stuck\n", vf->vf_id); udelay(ICE_PCI_CIAD_WAIT_DELAY_US); } } @@ -1483,7 +1484,7 @@ int ice_sriov_configure(struct pci_dev *pdev, int num_vfs) void ice_process_vflr_event(struct ice_pf *pf) { struct ice_hw *hw = &pf->hw; - int vf_id; + unsigned int vf_id; u32 reg; if (!test_and_clear_bit(__ICE_VFLR_EVENT_PENDING, pf->state) || @@ -1524,7 +1525,7 @@ static void ice_vc_reset_vf(struct ice_vf *vf) */ static struct ice_vf *ice_get_vf_from_pfq(struct ice_pf *pf, u16 pfq) { - int vf_id; + unsigned int vf_id; ice_for_each_vf(pf, vf_id) { struct ice_vf *vf = &pf->vf[vf_id]; diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h index 3f9464269bd2..62875704cecf 100644 --- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h @@ -64,7 +64,7 @@ struct ice_mdd_vf_events { struct ice_vf { struct ice_pf *pf; - s16 vf_id; /* VF ID in the PF space */ + u16 vf_id; /* VF ID in the PF space */ u16 lan_vsi_idx; /* index into PF struct */ /* first vector index of this VF in the PF space */ int first_vector_idx; -- 2.25.1