Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp438745ybb; Thu, 28 Mar 2019 05:43:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/JzieN9gR3jxUVkFuuz131IjG8jqR+EJf+2LQa0wncyOyCJC/pEvcDrh0TfBHCi6cyoKs X-Received: by 2002:a62:fb10:: with SMTP id x16mr41100143pfm.5.1553776980466; Thu, 28 Mar 2019 05:43:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553776980; cv=none; d=google.com; s=arc-20160816; b=GIkFP4A8W3p4ja+Y/QnPx9x0ZHyuJDkZhQxPssb98Rb+2436TJFTjKn0D8RIlUSjcg 7bZSjX1WkQULIynKCuoPX8dVjyK8NA/Znccd/XVOTNlKCLkGurk2kqzGAItKpuPrvBie gRheDOEnOmXy/EY+sepfX9oJNUgCjcMnEkwH1tsTJwL/OPcCu5paC43RiEU2glk96at7 UPbhrTpurq1p1S9hmkGpJsNyeg5/WErs626WGAavfuMZA0ZsORhQZFuWvDxCqdB+vkmZ i4/eWvSCg7p528iHzbGSIwawniJfy7NZOow900Ox5xsyFZbiRlsPe8EW1pK2xeIeHMIi XCEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=xfbrtklY9zyEyM0CdElW5W2PhPe2f01L6NqzXII4wSQ=; b=rZ8uk3+j1P1DrXNEKy7T6MN+IauHhHJiLhVpBghCY5AO/EvdbIqnF5GkP2Rgd0mRof pBBz97/RAtD+0SUzdo0+tsi4wT3q2g9SNUlXomQ64N+B2Ofvw2sB0BCqRT0Iy4DeLfEI vFRVlOIIh/GRoQThHdspAd34/N7sN/gFgEHa6dvpteEH1M8bmSsdpDnZ9utZxZ24lRi6 MQCDPZl/wP0oDfRSVDGEzsknVu+Hp0lcMlfMlr5iqkJLEnPmN+5pIrY08oAPn+mPeFPy DprRLi6A6WsUrvXuKGaselIqH9Enjy+o8OkcBqcwf0AHQt88kd0CWhJefgnhvQiEC6Db o4bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o12si8068769pgp.94.2019.03.28.05.42.45; Thu, 28 Mar 2019 05:43:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbfC1Mld (ORCPT + 99 others); Thu, 28 Mar 2019 08:41:33 -0400 Received: from mga11.intel.com ([192.55.52.93]:35002 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726520AbfC1Mgi (ORCPT ); Thu, 28 Mar 2019 08:36:38 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2019 05:36:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,280,1549958400"; d="scan'208";a="126619131" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga007.jf.intel.com with ESMTP; 28 Mar 2019 05:36:34 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id F011E63D; Thu, 28 Mar 2019 14:36:33 +0200 (EET) From: Mika Westerberg To: linux-kernel@vger.kernel.org Cc: Michael Jamet , Yehezkel Bernat , Andreas Noever , Lukas Wunner , "David S . Miller" , Andy Shevchenko , Christian Kellner , Mario.Limonciello@dell.com, Mika Westerberg , netdev@vger.kernel.org Subject: [PATCH v3 04/36] thunderbolt: Block reads and writes if switch is unplugged Date: Thu, 28 Mar 2019 15:36:01 +0300 Message-Id: <20190328123633.42882-5-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190328123633.42882-1-mika.westerberg@linux.intel.com> References: <20190328123633.42882-1-mika.westerberg@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If switch is already disconnected there is no point sending it commands and waiting for timeout. Instead in that case return error immediately. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tb.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index aea668c40d27..496dcd03ede1 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -277,6 +277,8 @@ static inline struct tb_port *tb_port_at(u64 route, struct tb_switch *sw) static inline int tb_sw_read(struct tb_switch *sw, void *buffer, enum tb_cfg_space space, u32 offset, u32 length) { + if (sw->is_unplugged) + return -ENODEV; return tb_cfg_read(sw->tb->ctl, buffer, tb_route(sw), @@ -289,6 +291,8 @@ static inline int tb_sw_read(struct tb_switch *sw, void *buffer, static inline int tb_sw_write(struct tb_switch *sw, void *buffer, enum tb_cfg_space space, u32 offset, u32 length) { + if (sw->is_unplugged) + return -ENODEV; return tb_cfg_write(sw->tb->ctl, buffer, tb_route(sw), @@ -301,6 +305,8 @@ static inline int tb_sw_write(struct tb_switch *sw, void *buffer, static inline int tb_port_read(struct tb_port *port, void *buffer, enum tb_cfg_space space, u32 offset, u32 length) { + if (port->sw->is_unplugged) + return -ENODEV; return tb_cfg_read(port->sw->tb->ctl, buffer, tb_route(port->sw), @@ -313,6 +319,8 @@ static inline int tb_port_read(struct tb_port *port, void *buffer, static inline int tb_port_write(struct tb_port *port, const void *buffer, enum tb_cfg_space space, u32 offset, u32 length) { + if (port->sw->is_unplugged) + return -ENODEV; return tb_cfg_write(port->sw->tb->ctl, buffer, tb_route(port->sw), -- 2.20.1