Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp1987114rdb; Sun, 4 Feb 2024 09:32:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeo/NpS0wUUblkXFuyFtjoqLAuyovWW0r3R2HcOjjtMzbvGd9XUsK8OAC198sduDjqxA/R X-Received: by 2002:a05:6a20:8012:b0:19e:3006:5dc5 with SMTP id e18-20020a056a20801200b0019e30065dc5mr12152138pza.3.1707067945973; Sun, 04 Feb 2024 09:32:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707067945; cv=pass; d=google.com; s=arc-20160816; b=L7VKfvsYOM7eNt/BeIJ2nd3ZblrFbnu1in2od73Sfh2YeKTwwFbwGDnbZ53LV0qipp XUHJeAAndMZuaGrJEA35xSMr4BWcA0nFZOR/XEKtCrYqdn1gffra4ZYUlF3JM0PohFSP +9Abz+5He0lw4QvmXAxh0fm4NcDQ1uBDYN5KCs4CB7nbL8xtnDGZP58X+Gc8JT1Cnbm2 EDbwRddhbrYVHaxiQPfvHeAwuHUQm1E46xUFLAFPlN2Q0pSuURrl2iFTUhhLuCBd7Sy/ P7nyj5nBAMOK89yHgf72tMdpO3jUwRZpSB7aIf/8AAwPpiCNHSvI2mnWr/JIZdBZcvR2 VdMA== 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=QTa8tNa8jy3TVEJ6cWHQo+L4WauI+ElnUx+hUNLlCyQ=; fh=lDALVeTDuv8eEMeJphAgwlY23pbgEzaQynvzFsyy1/o=; b=i2rftnjuvA4+xlv+uobINikZKZbCMDSuEVkCEyY3VYFRjQYcJ8WYU+R/ILJtOL9pNR sijyA0+lO/h6nhz4OXAL+Xn/HYtUGcR4C5A94uNcz8VVGiSuKLCIoqOocq8QznGWgEOG 6IFW8S7aeQpAY+F3vjGG+y8rK3Z3w2uWbG+6D4XYms+5tZPubJP/iQslpWEn/2AsA550 dozfzWoSTsKOuNFjXoa8HGoy/8K5jScVrYJlE5/U4QQj3dcUBsxjOrjVkmn7z3yrvbx5 pwlQhXTB2sR0fhcnLX94JGDr5OeAbyKgq4kX44bn4Re52I/ROjqsQ61FQE6MIBmt1sUd KKEA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMxkc0Bj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-51829-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51829-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCWp1/vsJoZs5C3AKUP8I5RSvEQjzi+VDLZhKhksqLN1b2/aD41w3CTYsZEAzCkd05R4irtQE9Ree31uCWn67AQXXQy9KJzQaurV7f93Ng== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b1-20020a63eb41000000b005cdec4d186dsi4623470pgk.516.2024.02.04.09.32.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 09:32:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51829-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ZMxkc0Bj; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-51829-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51829-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A194E284212 for ; Sun, 4 Feb 2024 17:32:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FFEE25578; Sun, 4 Feb 2024 17:31:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ZMxkc0Bj" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) (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 064522555F; Sun, 4 Feb 2024 17:31:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.14 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067882; cv=none; b=h751M6A+pLhtNhw+v9oePFwFjMJp/BH64EdcBu8WlmeOcSWMmj7QDDFLyt0wJge7ca414HhVkB6tMD2tZzRjebG8uoVcxdEAUFh22A6mWBKZ2DW0p+hJXU2Opfz9LExCUyOz7g9DFhS413WRCVl//Ef00iKBEH8Ecdp2G/HpEBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707067882; c=relaxed/simple; bh=FPf3c+XFlSNb7MJJi6PdgXBeD5uKtm42qLdX4zSVwgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hov32Us3IJxqWeReI0HuelDWSzx4yklBPVyaFcTHp65rcxUMCV8SMWLwBZ0X97EG5g/ai16+kiVCYYCIXES5MxVRXXquv3roquXsTwid9DI7N7N4XPmBE9hpkKasOlKN2opsg2D3/SU92oorZfhGx6FkhvUQxlA0D/pSz0ohY7c= 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=ZMxkc0Bj; arc=none smtp.client-ip=198.175.65.14 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=1707067881; x=1738603881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FPf3c+XFlSNb7MJJi6PdgXBeD5uKtm42qLdX4zSVwgw=; b=ZMxkc0Bj8IwXyGhz+drDD2xmCxXDcKcMNa2mK+C+XhlilrP626tYWYzB ZmFcOnXjgmosD0TTTy9KSza+w80ZRUbUOdvQpG0Qkz/BMTuAh+SjCX29V 56//Dlu+TqHu/Aqwgi9GeDN3dzu5/fc0rXXhEMepdj63xRuMN+VCmWmre G/q+2+7jZX0fZ7zYdlVxCP7REmDy0pkkMyVC4lvQ5GSvKzJCXqzPqaP+b u2ni8EeKIhs/fp67gPwF6jMuzZ15TYktAvro36iqIfHzya7NWe6HO0zL2 mKlq882bWWPIBCMHHbD1nElG9P/iMcrMo4DNVVM7VPFswhoUZ97hHQzZC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10973"; a="4225908" X-IronPort-AV: E=Sophos;i="6.05,242,1701158400"; d="scan'208";a="4225908" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2024 09:31:20 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,242,1701158400"; d="scan'208";a="31626386" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.intel.com) ([10.213.2.137]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Feb 2024 09:31:18 -0800 From: "Fabio M. De Francesco" To: Peter Zijlstra , Dan Williams , linux-kernel@vger.kernel.org Cc: Ingo Molnar , linux-cxl@vger.kernel.org, "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH 2/2] cxl/region: Use cond_guard() in show_targetN() Date: Sun, 4 Feb 2024 18:31:05 +0100 Message-ID: <20240204173105.935612-3-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204173105.935612-1-fabio.maria.de.francesco@linux.intel.com> References: <20240204173105.935612-1-fabio.maria.de.francesco@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Use cond_guard() in show_target() to not open code an up_read() in an 'out' block. If the down_read_interruptible() fails, the statement passed to the second argument of cond_guard() returns -EINTR. Cc: Peter Zijlstra Suggested-by: Dan Williams Suggested-by: Ira Weiny Signed-off-by: Fabio M. De Francesco --- drivers/cxl/core/region.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 0f05692bfec3..bd3236786a25 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -666,28 +666,20 @@ static size_t show_targetN(struct cxl_region *cxlr, char *buf, int pos) { struct cxl_region_params *p = &cxlr->params; struct cxl_endpoint_decoder *cxled; - int rc; - rc = down_read_interruptible(&cxl_region_rwsem); - if (rc) - return rc; + cond_guard(rwsem_read_intr, return -EINTR, &cxl_region_rwsem); if (pos >= p->interleave_ways) { dev_dbg(&cxlr->dev, "position %d out of range %d\n", pos, p->interleave_ways); - rc = -ENXIO; - goto out; + return -ENXIO; } cxled = p->targets[pos]; if (!cxled) - rc = sysfs_emit(buf, "\n"); + return sysfs_emit(buf, "\n"); else - rc = sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev)); -out: - up_read(&cxl_region_rwsem); - - return rc; + return sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev)); } static int match_free_decoder(struct device *dev, void *data) -- 2.43.0