From patchwork Tue Oct 1 12:46:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: You-Sheng Yang X-Patchwork-Id: 1169903 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46jJtl63fDz9sQy; Tue, 1 Oct 2019 22:46:55 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1iFHYH-0005R2-A8; Tue, 01 Oct 2019 12:46:49 +0000 Received: from mail-pg1-f196.google.com ([209.85.215.196]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iFHYC-0005MB-Sf for kernel-team@lists.ubuntu.com; Tue, 01 Oct 2019 12:46:45 +0000 Received: by mail-pg1-f196.google.com with SMTP id 23so1055863pgk.3 for ; Tue, 01 Oct 2019 05:46:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Etz6sQ6MaZDG0jQYQaSU5onM55rAaO2LxxksPIhocC0=; b=TNcApvY8C/qVxc6zRSIFgdz9JR/0BvZitztVQLI5cm5TDnBQdsEW/0C8aOFA9sxNcf U4z84K12+hLkHgUfFygbSV8YpfuDKx41s1kTFQSDFsRrARoNHcxdzXeDC14r2PxmhhJy qR0iKR9CUKuIA4nDfbkZ4Y01jCQ+etpcOEb0PW5aCaC4HULW/MXTk/g/3A/dC+lFli+0 HOW/00vNLtGFiOAUMGbwRHjCnq3l3HXmFLV9oBVq8jweApqV/tFYeUgvK7JWr2H/kdtI E6Woc69QJpPUxtS+dZ3922TdbZN3NdeYuzYxiWv/Khn/szaRuah2e4beS34rDzq8pj6r iakg== X-Gm-Message-State: APjAAAU5r4xwURLUXkbmBl57MZ+d/wJMO+K2b78R41ZUwMmZuDjW7UQ6 npi8yJnQfUPyhQjRhoT/vGhxHXTlsYw= X-Google-Smtp-Source: APXvYqwLcHmfDSgU86Glpdftzydsb98tAoCtcHl+m0EnnC9pdBEz6TIYjrluV5YJNQIS9gxiBX3sWQ== X-Received: by 2002:a63:f610:: with SMTP id m16mr597725pgh.357.1569934002293; Tue, 01 Oct 2019 05:46:42 -0700 (PDT) Received: from localhost (61-220-137-37.HINET-IP.hinet.net. [61.220.137.37]) by smtp.gmail.com with ESMTPSA id c64sm17913362pfc.19.2019.10.01.05.46.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Oct 2019 05:46:41 -0700 (PDT) From: You-Sheng Yang To: kernel-team@lists.ubuntu.com Subject: [PATCH 15/17][SRU][OEM-OSP1-B] thunderbolt: Expose active parts of NVM even if upgrade is not supported Date: Tue, 1 Oct 2019 20:46:08 +0800 Message-Id: <20191001124610.10587-16-vicamo.yang@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191001124610.10587-1-vicamo.yang@canonical.com> References: <20191001124610.10587-1-vicamo.yang@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1844680 Ice Lake Thunderbolt controller NVM firmware is part of the BIOS image which means it is not writable through the DMA port anymore. However, we can still read it so we can keep nvm_version and active parts of NVM. This way users still can find out the active NVM version and other potentially useful information directly from Linux. Signed-off-by: Mika Westerberg Reviewed-by: Yehezkel Bernat Tested-by: Mario Limonciello (cherry picked from commit 3f415e5ee18b0097755afc3ac3a5640b196a239e) Signed-off-by: You-Sheng Yang --- drivers/thunderbolt/switch.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index a73170419bad..5b05dd89e364 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -355,12 +355,14 @@ static int tb_switch_nvm_add(struct tb_switch *sw) nvm->active = nvm_dev; } - nvm_dev = register_nvmem(sw, nvm->id, NVM_MAX_SIZE, false); - if (IS_ERR(nvm_dev)) { - ret = PTR_ERR(nvm_dev); - goto err_nvm_active; + if (!sw->no_nvm_upgrade) { + nvm_dev = register_nvmem(sw, nvm->id, NVM_MAX_SIZE, false); + if (IS_ERR(nvm_dev)) { + ret = PTR_ERR(nvm_dev); + goto err_nvm_active; + } + nvm->non_active = nvm_dev; } - nvm->non_active = nvm_dev; sw->nvm = nvm; return 0; @@ -389,7 +391,8 @@ static void tb_switch_nvm_remove(struct tb_switch *sw) if (!nvm->authenticating) nvm_clear_auth_status(sw); - nvmem_unregister(nvm->non_active); + if (nvm->non_active) + nvmem_unregister(nvm->non_active); if (nvm->active) nvmem_unregister(nvm->active); ida_simple_remove(&nvm_ida, nvm->id); @@ -1177,8 +1180,11 @@ static umode_t switch_attr_is_visible(struct kobject *kobj, sw->security_level == TB_SECURITY_SECURE) return attr->mode; return 0; - } else if (attr == &dev_attr_nvm_authenticate.attr || - attr == &dev_attr_nvm_version.attr) { + } else if (attr == &dev_attr_nvm_authenticate.attr) { + if (sw->dma_port && !sw->no_nvm_upgrade) + return attr->mode; + return 0; + } else if (attr == &dev_attr_nvm_version.attr) { if (sw->dma_port) return attr->mode; return 0; @@ -1504,13 +1510,17 @@ static int tb_switch_add_dma_port(struct tb_switch *sw) break; } - if (sw->no_nvm_upgrade) + /* Root switch DMA port requires running firmware */ + if (!tb_route(sw) && sw->config.enabled) return 0; sw->dma_port = dma_port_alloc(sw); if (!sw->dma_port) return 0; + if (sw->no_nvm_upgrade) + return 0; + /* * Check status of the previous flash authentication. If there * is one we need to power cycle the switch in any case to make