From patchwork Thu Feb 8 13:04:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 198384 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp150702dyd; Thu, 8 Feb 2024 05:05:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBc1ppm7bFXc8KhEcJLEPlXaXN79i6GaWqsmG3R5lPRP5z3gvkr3G2ps+q8zIzlCxihYv3 X-Received: by 2002:a17:907:f99:b0:a3b:a8b7:d019 with SMTP id kb25-20020a1709070f9900b00a3ba8b7d019mr1084696ejc.77.1707397556130; Thu, 08 Feb 2024 05:05:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707397556; cv=pass; d=google.com; s=arc-20160816; b=unD0T39knXCKpGa+FA99y8G6h+e48BYq9YwP+GfvnjtwQuclHuw5kq1t0nfDQfHcQ3 lSAkqc8bgI3atO7pPpNw87sxtFLxpw1Kv5M6hDZYEqOoqTEzwnpknTtQnr6nVdfVzfjr B3EFMdJWuvyy94lOempZB/pRpcvqsuiWpxe2WJvBlC81+jc4o184MexGpmPVgXakJnMI +zbZZD0OPMkSZlrw5n8NRWuArq6fj1xf/+dOTkZLEk+TIm4HZ1GyPyzoMrhXRzsr5/QE x74OD29I4LX7Z4hWPYVwhq1RseUCdSWO29dnj8qCmfivKwm0i+1sg6sXR31xzKo31+ye of5Q== 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=uBm8LOFp8bL6em3SGj7vxoTXn70oYw6ettvfukx0H8g=; b=WpO2HxZSMABjGHZZGkVGDjObJqk8afK1DOcn2Qlf8Hj3xbV+u2/wqU8VDJCUncZveo 6UTg3sAtZSgQULtxzgGkZ+H7iiAgbbbfOmCuB9a4dETF+0no/4l/6d1Pu+TuRAGTz+d5 n1J5XXsUcUSHKLeSHQ8hDUse9f/uU7Hf7QM2m0lWy5dJ39sLhQLOnqJm66XgAfD/qR0l oYKzAEXO518F+cw4o4+alF0hpmWpXjhypg7OZp6j1UdPFLx0CJ9/ol8j/9S8eBe10lTk IednPYArrvys9XVbs9ihS6vbUZn3ZItnrrOHhCNe3ITcXPK9w0FYsAR3+GfP/KqAr8X5 WThg==; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58105-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=2; AJvYcCWWkwk5OBZB6I3rmiCP2JiOF3ZvCZSzihdR7MIONkkbsbKIH2Nn/guJBGbu2IMlkBVAAMc1FC9krCvC/0jYqKmQVlcPVQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id pk16-20020a170906d7b000b00a37742795f7si15740ejb.935.2024.02.08.05.05.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 05:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-58105-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-58105-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id B848B1F25898 for ; Thu, 8 Feb 2024 13:05:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9536F78B74; Thu, 8 Feb 2024 13:04:45 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790336099470920013 X-GMAIL-MSGID: 1790336099470920013 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)