Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2513270lqp; Mon, 25 Mar 2024 00:32:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUNLBdiYm+BMstgS+ZtSaj5D2p9AoWAAxUoDMSFf5iBMiDWT512BHJmtDwlBb0CtGL8tJvyc8ju98RmkFdgGMG1WcN41/mdVBvbKMyrIA== X-Google-Smtp-Source: AGHT+IFbmaxWqsdqKDSTsvx0yQpCvxb5SJBUnl/xPdplIrdObbnN2g3I/dAT6Q9dyVltjzlmJtSe X-Received: by 2002:a05:622a:5b93:b0:431:3df2:206b with SMTP id ec19-20020a05622a5b9300b004313df2206bmr6701255qtb.34.1711351938015; Mon, 25 Mar 2024 00:32:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711351938; cv=pass; d=google.com; s=arc-20160816; b=eDNavgxSRp/6UGP2JuljNYwk9yDluVjkEX8ATXyq4ZKzV5EjHr6Sj8fpIUFlG5hjGB 418sWbpC926uhwmNNgQsR+Qtk0R4DvcSMGqv1nCDRFIsmKwuDCAWRpNNv5b/Rpmt3sch Wp63m8IBotFoKVERbHwZ4JJ8ryetVlxOrEUoilctiKlPzip8LQtYInofpLH4jKsPAYBs 1XWp2nVncBekdo2Y4S922AhAytunfX87lFa8Ck0auW8siIgeGBntS5kUtjo45FBf2AB4 dbFiGu9c0uvGnoBxd95fhcgIhhuKl2uGYEBteDE53tIf1Th3MYQKHnnLejkwjm81N+1s 2BSQ== 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=X2cEm+xgG+ossJb2P41mXkTcfVMm1jrx/cQe8xxMDVY=; fh=bJTwjU6YpBdwaGacPEwvVB25lRpzil6EhUoLyvAB2D0=; b=Z/EgJ4X2aQRcy+1Oj7Ky1UDUYWu0BMVe3CePiD51hU1WQG3EiPnhBmPBEOrKrEpAbF JWStksQBadMA3nxJhxqT8ywSvF4TyBa1MNPIB2lyZD3k6IGj0pnog6OW9p2bQ3PN7Khg sXtqI4XbnZk6zlQ7964l/SnZnGBrS0q52eotIjzjEk8wcBMHyB4dpIJxADV1WxZH7Xev aGYG3dwVtQYG/Xv5FkLOFSN0zeCZonXUM+DIce8AUxrrYPrYpoUXxdFHn3tPgMerJB+1 R0a/nxYD/JgkmsxU6/hXhedjrlwXfrHVibPnadKbJGKdzoflJPcUDWZCh7rH552YJR1u HqKQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gj9q6CX5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id q16-20020a05622a04d000b00430e610860asi4643463qtx.487.2024.03.25.00.32.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 00:32:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115282-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=@kernel.org header.s=k20201202 header.b=gj9q6CX5; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115282-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115282-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 5B7411C2E535 for ; Mon, 25 Mar 2024 07:32:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C6BD15ECD5; Mon, 25 Mar 2024 02:31:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gj9q6CX5" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 31D0B482D0; Sun, 24 Mar 2024 22:47:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320478; cv=none; b=trNdzeUL195I7i0mKIUA9csAlzLuijAlaPD7PP9F6Fs3/rmXY2CZHUOaYuO2IipOMKBlc8BLDfDTQ/oFwp3PSj8gdp/DNvXRoUaMPGmzQgn8+HR2NSXc4RGza6INIzepsF3LiP8h/ERTscqcLX9HdIqs18mNChEISOJqp9uH6L4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711320478; c=relaxed/simple; bh=PkKaGziWURDv/ulaxnHD5Dgsz+znc2l24h5KSkIa8qs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BmsHbmhSC8hD30Ywj9g1ZcSE99RLbLREpLy9szfNomE+AgOOYO5bTnbw0ivXffCVbKV0n5cUiPApqWe4oImeC6QwZFl82B2fLYKajifqYT9iJx+BWIOixUh5OXgNRUXljXMeqv+Z9sDPp+5WVoLPGRtXF4Ec9xw90AfWvay9ft0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gj9q6CX5; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57FF5C43394; Sun, 24 Mar 2024 22:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711320478; bh=PkKaGziWURDv/ulaxnHD5Dgsz+znc2l24h5KSkIa8qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gj9q6CX5e4hS0zw2+Iz8Vha903eraQ21UrFLM4t3P0iQTYycZnq2wAAacDmDXNKlB seaZca4SQvikY1MwmxNfPmHM1j7PeTTJt/xap0FZ7bNAxNNDy2DfB6xjM30d9x8Cuk HczitB7OW1XkeKrSz6VIFHuKC+ALYo7CHg7Tjd39qy7H4PRzb9xGTwiUQPBTcq/gJO dRkBBvnTGH/MJYAT9GMgyXKPPyhZCiJGHgEqslyhcuEhabqXtBsLbNw8R7UQ/j1tUD LE5T8fnbT9I6HlLBdXZW7MjcnxtlR9cL+zRpDewqIEsXU3Kvz1fs3e+/YjiP5ZNKjl hpRSndH7shDFg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Alison Schofield , Wonjae Lee , Dan Williams , Sasha Levin Subject: [PATCH 6.7 037/713] cxl/region: Handle endpoint decoders in cxl_region_find_decoder() Date: Sun, 24 Mar 2024 18:36:03 -0400 Message-ID: <20240324224720.1345309-38-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324224720.1345309-1-sashal@kernel.org> References: <20240324224720.1345309-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Alison Schofield [ Upstream commit 453a7fde8031a5192ed2f9646ad048c1a5e930dc ] In preparation for adding a new caller of cxl_region_find_decoders() teach it to find a decoder from a cxl_endpoint_decoder structure. Combining switch and endpoint decoder lookup in one function prevents code duplication in call sites. Update the existing caller. Signed-off-by: Alison Schofield Tested-by: Wonjae Lee Link: https://lore.kernel.org/r/79ae6d72978ef9f3ceec9722e1cb793820553c8e.1706736863.git.alison.schofield@intel.com Signed-off-by: Dan Williams Signed-off-by: Sasha Levin --- drivers/cxl/core/region.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 7bb656237fa0c..764998fe03edc 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -729,12 +729,17 @@ static int match_auto_decoder(struct device *dev, void *data) return 0; } -static struct cxl_decoder *cxl_region_find_decoder(struct cxl_port *port, - struct cxl_region *cxlr) +static struct cxl_decoder * +cxl_region_find_decoder(struct cxl_port *port, + struct cxl_endpoint_decoder *cxled, + struct cxl_region *cxlr) { struct device *dev; int id = 0; + if (port == cxled_to_port(cxled)) + return &cxled->cxld; + if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) dev = device_find_child(&port->dev, &cxlr->params, match_auto_decoder); @@ -852,10 +857,7 @@ static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr, { struct cxl_decoder *cxld; - if (port == cxled_to_port(cxled)) - cxld = &cxled->cxld; - else - cxld = cxl_region_find_decoder(port, cxlr); + cxld = cxl_region_find_decoder(port, cxled, cxlr); if (!cxld) { dev_dbg(&cxlr->dev, "%s: no decoder available\n", dev_name(&port->dev)); -- 2.43.0