Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp300012rdb; Thu, 8 Feb 2024 06:27:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFchxpl2m+Gcg/6acaXvbRhJkQIYcs/YAGvU59v1JOyASQ2kFswVeGiPsYnq57m6qyUepMZ X-Received: by 2002:a05:6830:1d4d:b0:6e2:bc4e:2a8 with SMTP id p13-20020a0568301d4d00b006e2bc4e02a8mr4523712oth.24.1707402436693; Thu, 08 Feb 2024 06:27:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707402436; cv=pass; d=google.com; s=arc-20160816; b=DJKfpvc12sbs1nT8txSuH4M3dCkRrPPKalbMHcKKUYYVdFAnwN4V0gW4eEPhFLSB2x nD8pvovFbQgncyuItcQRkPOJWFPmvhp8ukwQhiPrQ0j+L2gx05To1mjTOUVaqJ9Pdcue vH3FhMzvXYCJ0lDP7TJn70gMFd7Pp8XbxtLt6iPQFMiC5oEiLsPqTFA48GpKTuhtJvYI VeRTw8nWlRjcfKI7wa6/Q1EVnLAnSA9NaffVob93Qch7MhsHjoUKc1XP+oNt2w6XJHwk BoN/2ZYvfNotPMZHkRUrUn8AcRAsL8KSGNpyjBVdOt5zjl7cXUb2gGNX4BsX5jXTDFsK iOAQ== 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=H/IVSh3FB3kmTm8dvMi9BFAoRhQy1wsf4EnWS5mjoCo=; fh=xxYcxaxaeCPifH71lEYcVB9y8xdwA/2kA3YFMF7rn3E=; b=s0jaWPMiPXW3tv80wksFekw5c4gIBuekdSAUpCXTugzeeo2Fn/3mbFs3fkHtKoagiU Dcptngzs1RlcCwWNGp2BcYWfrWkeVSYZ2Yyggn/wTS7pf9wWY/blCKe0ZmaIFxwB353x Qqp7FZY/G/uodqozSKr++IrGRmjVEf9UyoXfTiYfngty74dbAej1BpmJhFb03q/RTxZR Gezk6MPOEbLvOzqMVexzSECMi8nZbASRLkLxO2oFz9f+9IHO5etLlFmNmYIWfO9neM4i afLu6nXToDvR+FMe8NssN5hwlwdfLDU+X9q7r89ltOoYjjJRvAoc7Q6RFJFf3XhOgN5x rxbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iRH+1aka; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-58105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58105-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCXv/Fsd5kW4bi4NXSIO3/WdiHG6gTACEw3AZE9Hpy69ah4DBGMt+8ranqyRpBhygUbbFq+oVgMuP7MghukVdOMMrqwQpKjF+QldpbV/yA== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id dq11-20020a056a020f8b00b005dc4128c731si1970170pgb.473.2024.02.08.06.27.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 06:27:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iRH+1aka; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-58105-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58105-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5CE29B28077 for ; Thu, 8 Feb 2024 13:05:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A197076C72; Thu, 8 Feb 2024 13:04:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="iRH+1aka" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (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 5A880768F9; Thu, 8 Feb 2024 13:04:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707397482; cv=none; b=SZYIY/oczyBX/SX5jCYht/i7vfj+j8gBWli5w8DCzzQ4V4lClEc4Tzbi9Q9DnCIVNeVsJa1LKqo3+4BRhNVDrIiBdvXgQ4tlKru5aWmAMpq3KJF4eJONcfqB6VpeIS475sSzscX2uehtrdaR5nINYKFUhuVCaVlT3/TbwnCwJ1k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707397482; c=relaxed/simple; bh=Lo4kkB4jLMq5jqNhPrPQyqJPfLO752skAxdfFETkocA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ImK1WwAzEfoUJal+iXfuD/KvAiDysjwFPCrR8+8pWwdiPOZ1smWRhDKNi9v+8AhaRkGyZEBOv/tkAFBgVqxl89JB+ybZOhE54b4KceWp9YE2LmpMdGiS/VyfG+gBw2BzMBM1qfsw6+BQXXOj1YWKuDL9fM9e/EL3RoT/eK/VkEQ= 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=iRH+1aka; arc=none smtp.client-ip=198.175.65.18 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=1707397481; x=1738933481; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Lo4kkB4jLMq5jqNhPrPQyqJPfLO752skAxdfFETkocA=; b=iRH+1akabI2fEvTiYXbDXnzCAom0tYcKswMYM2ilvOqFHLIZ1m8Di/1E fWBxX4lVzPFatiCOrVHn5tT6RAJMRcONVFCURp64R+uYavtvQK7ssgLP6 XNd5JqXCWZMd2QIj9lkpZgoi9CtJKZ1tAyFwOopFI7QfNPPc8VYFC3uXs BRtKNWzS2+JQ9NrZHJhXin5Yt/YC9KJR6d54QcgMEq1S4QEShq9wXxun8 4kP7vFgTXE2t3aAZN8cMBJI7S0MEOWMPwgpMP4ZFDGYCo1Xq0A+Ew3wgj mCzf3VpeMjrhIHuhe6eH5Lvtds5/m/+VMBUMLK2Q9+jwm3j01yo3IC8Lr Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="1354956" X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1354956" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 05:04:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,253,1701158400"; d="scan'208";a="1884047" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.intel.com) ([10.213.2.200]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 05:04:37 -0800 From: "Fabio M. De Francesco" To: Peter Zijlstra , Dan Williams , linux-kernel@vger.kernel.org Cc: linux-cxl@vger.kernel.org, Ingo Molnar , Dave Jiang , Jonathan Cameron , Ira Weiny , "Fabio M. De Francesco" Subject: [PATCH 2/2 v4] cxl/region: Use cond_guard() in show_targetN() Date: Thu, 8 Feb 2024 14:04:24 +0100 Message-ID: <20240208130424.59568-3-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240208130424.59568-1-fabio.maria.de.francesco@linux.intel.com> References: <20240208130424.59568-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 Reviewed-by: Dave Jiang Reviewed-by: Ira Weiny Reviewed-by: Jonathan Cameron 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 ce0e2d82bb2b..704102f75c14 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"); - else - rc = sysfs_emit(buf, "%s\n", dev_name(&cxled->cxld.dev)); -out: - up_read(&cxl_region_rwsem); + return sysfs_emit(buf, "\n"); - 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