Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp454878rdb; Thu, 15 Feb 2024 05:33:17 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXhpHqrW1bv7KakbWWGEWaSQUTzXlGVwwMH2MHCvQkaqT9wrHlKaydbfObFnPMz2mniVOXH9a1bZSBpZA+GF9Cy9/ZX0FyJ8UdccdzqIQ== X-Google-Smtp-Source: AGHT+IFt44H+vuK4l2VnCRgIQdar1atDdrdQHINXSAcBOHRkdaxkf+iPtKp8ojpJ/7ULQxNGPc8W X-Received: by 2002:a05:620a:102a:b0:787:3abd:f42f with SMTP id a10-20020a05620a102a00b007873abdf42fmr882007qkk.36.1708003997099; Thu, 15 Feb 2024 05:33:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708003997; cv=pass; d=google.com; s=arc-20160816; b=sjdMnp3DRdXJ8SzQUJhglUd3DRVarEhG++C+aQJygxaTFJ+4EzGC1vpVIMGhxCrFk6 VFloyR0YAfOl2H4erX1nJwUigPWiZtLS2bw+mwmG4fFKrkU4B/5rfP26AA27LhYNp+4O k9NNqGBhV3r/F4igmN7OG/mJYdT4Vf0u8Sscvo9wcFKW+W8mOIMP1qeerw0/LuF5lBCp 8y3Ak1UusvxrBTIFM6HpSLyzngPw+uAp0JEhnAfMxEE4F5ujslxEKSCYH7+tkzQJUarQ 32BzV28VBkM3CQoi/waIjH7vmz8HIPZo9dUMYP4ldsKFPM7K9WNKT2XtBO+iW8F0FV0A GomA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=O1kNva9u+8Vq6BIV5cLUnbTTkZh7L+N7fcbZpRN8WlQ=; fh=IqPiQNnsy7C3I4xl5kG8YKpr7r4CyUEc3lptZ+/Wtvc=; b=fjMU1EOG3hNIbXbO8vMt5ND4rBZbHlgGq241xJpyFCPgDLJtqCnRxHPXGF31CjyNCH pIrQgWZ/ejB+HOB6hkiOMJGwhZ4zb+WQdUdV2PHIyBZJC77/uv4vI8djtg9djPMbi+p4 Q+Casm8vU7hkSgfEdPW5QpFBfj5oVs+9YgMY7Bt0JbSdgPcyMB5OMk87bnnRUPeowakE B2sXuwxgUMDc7Ipi5fIOBlrNW4Z8HaIdXbZx8Yr7PDnpcGWvkfE+OOa43fNMm2i/xTXP 9GGT0v4YEzRDJYJ4adHxGI5qWdGu8T8rlGQjLKxESu2DgZHvjkKaNljpMMwRU3/Dhkbr hCqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KqAPq62K; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id sq1-20020a05620a4ac100b00785bf2d1f99si1405460qkn.445.2024.02.15.05.33.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 05:33:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-66986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KqAPq62K; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-66986-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-66986-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D78231C23B06 for ; Thu, 15 Feb 2024 13:33:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93B72130AFA; Thu, 15 Feb 2024 13:32:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KqAPq62K" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A5702130ADC; Thu, 15 Feb 2024 13:32:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.19 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708003963; cv=none; b=W0ZFqhs1C7HJs1T9eLlOqVNOJ1kHl05xgo+HfXtjmjJ1TX8EHtJZ4j5QcbzxRXjWoHuxWKsdR4hacvMtZe+dC8/CapXSERgR4a7Vw3TlHRr8vaA/4+426lsJHI3OOhy4BR7D24R1VxLwqixhlVBcKOn8L5UVltJ/CLYdY9o7Iek= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708003963; c=relaxed/simple; bh=6rpcH0m9UcnLADJF2mMN2BFoCEixngqiqjxZKB2/Q2A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=PjHYlDxzkfJYkQz1LKM+BszyXua9k/jLG54+hAUgv/EUJsYq/8dY3KKc1utVvlphb64cOjIA02/pQ9vztRAqMsSF93idVSEV1/Hj1F0dlOiZRl0hSWQoBGJ3pwHAtEPjf8NLNomyrqGFnuX0cHXqkOHXhrp/TYBpwz+W4bOc6aA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KqAPq62K; arc=none smtp.client-ip=198.175.65.19 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708003961; x=1739539961; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6rpcH0m9UcnLADJF2mMN2BFoCEixngqiqjxZKB2/Q2A=; b=KqAPq62K+Vl6Dnhks9nuocWaC08Kzifiv5oV1qkeJECqi+y0UkJK4OHy ZFrpyRnSxoCU0fKJd7rnPhV40JPRoO8LUf7PJ2gMdqxMmbKTehusfBaqF L+XExH6HxfV2UopcZJjWjO3a4e+9DIeY8xrXDJ9jdDF5Os5SHpj1KbZQT cIZqaves5vFq0vj51YQv8TyyzYaglCxP4d+JidEvtYjYUSD80nS2fV8Xr wwkmJ4qXgyGvJlYwLzflIYiRzQmay8+RFk7dOizvz4XhYFbhPOMj/ugNz sZGQtsDh5DKr3tkCYP0CikUOpHTRA005JFFR80uyXKdZZooAtOJigF933 A==; X-IronPort-AV: E=McAfee;i="6600,9927,10984"; a="1943636" X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="1943636" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2024 05:32:40 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,161,1705392000"; d="scan'208";a="26690910" Received: from ijarvine-desk1.ger.corp.intel.com (HELO localhost) ([10.246.32.150]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Feb 2024 05:32:35 -0800 From: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= To: Alex Deucher , amd-gfx@lists.freedesktop.org, Daniel Vetter , David Airlie , Dennis Dalessandro , dri-devel@lists.freedesktop.org, Jason Gunthorpe , Leon Romanovsky , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, "Pan, Xinhui" , =?UTF-8?q?Christian=20K=C3=B6nig?= Cc: =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , Lukas Wunner , Dean Luick Subject: [PATCH 3/3] RDMA/hfi1: Use RMW accessors for changing LNKCTL2 Date: Thu, 15 Feb 2024 15:31:55 +0200 Message-Id: <20240215133155.9198-4-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240215133155.9198-1-ilpo.jarvinen@linux.intel.com> References: <20240215133155.9198-1-ilpo.jarvinen@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Convert open coded RMW accesses for LNKCTL2 to use pcie_capability_clear_and_set_word() which makes its easier to understand what the code tries to do. LNKCTL2 is not really owned by any driver because it is a collection of control bits that PCI core might need to touch. RMW accessors already have support for proper locking for a selected set of registers (LNKCTL2 is not yet among them but likely will be in the future) to avoid losing concurrent updates. Suggested-by: Lukas Wunner Signed-off-by: Ilpo Järvinen Reviewed-by: Dean Luick --- drivers/infiniband/hw/hfi1/pcie.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c index 119ec2f1382b..7133964749f8 100644 --- a/drivers/infiniband/hw/hfi1/pcie.c +++ b/drivers/infiniband/hw/hfi1/pcie.c @@ -1207,14 +1207,11 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd) (u32)lnkctl2); /* only write to parent if target is not as high as ours */ if ((lnkctl2 & PCI_EXP_LNKCTL2_TLS) < target_vector) { - lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS; - lnkctl2 |= target_vector; - dd_dev_info(dd, "%s: ..new link control2: 0x%x\n", __func__, - (u32)lnkctl2); - ret = pcie_capability_write_word(parent, - PCI_EXP_LNKCTL2, lnkctl2); + ret = pcie_capability_clear_and_set_word(parent, PCI_EXP_LNKCTL2, + PCI_EXP_LNKCTL2_TLS, + target_vector); if (ret) { - dd_dev_err(dd, "Unable to write to PCI config\n"); + dd_dev_err(dd, "Unable to change parent PCI target speed\n"); return_error = 1; goto done; } @@ -1223,22 +1220,11 @@ int do_pcie_gen3_transition(struct hfi1_devdata *dd) } dd_dev_info(dd, "%s: setting target link speed\n", __func__); - ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_LNKCTL2, &lnkctl2); + ret = pcie_capability_clear_and_set_word(dd->pcidev, PCI_EXP_LNKCTL2, + PCI_EXP_LNKCTL2_TLS, + target_vector); if (ret) { - dd_dev_err(dd, "Unable to read from PCI config\n"); - return_error = 1; - goto done; - } - - dd_dev_info(dd, "%s: ..old link control2: 0x%x\n", __func__, - (u32)lnkctl2); - lnkctl2 &= ~PCI_EXP_LNKCTL2_TLS; - lnkctl2 |= target_vector; - dd_dev_info(dd, "%s: ..new link control2: 0x%x\n", __func__, - (u32)lnkctl2); - ret = pcie_capability_write_word(dd->pcidev, PCI_EXP_LNKCTL2, lnkctl2); - if (ret) { - dd_dev_err(dd, "Unable to write to PCI config\n"); + dd_dev_err(dd, "Unable to change device PCI target speed\n"); return_error = 1; goto done; } -- 2.39.2