Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35852480rwd; Mon, 10 Jul 2023 13:44:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlFrK6lvNlPE1ccK9kiepqs/XPxPlkjbyuswVajkt9GPbcaHqCFRWzjHq2+c4J9xsIXE59C6 X-Received: by 2002:a05:6512:b96:b0:4fb:a990:bb28 with SMTP id b22-20020a0565120b9600b004fba990bb28mr14165970lfv.18.1689021863249; Mon, 10 Jul 2023 13:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689021863; cv=none; d=google.com; s=arc-20160816; b=E0CpC1ngv4Diuk1sB5WEQA6zwZOXXfirlQMe5p7XO0o8GJBhLjIY0rIC2ovplAPYcr V3UJMSsNf8jzHL8aAza0uYblnyI3ZIgS1n21McMFoPqwr8cj33Y3RKzbcV+UqRJIYlWf Wu1FGpccND4G2Kj3dwLLEoKydUYpUSVi4AbIcQOTJgS7ai0SZJh2hmY3tGyJrp5l5Quk +Y/x5cUzOpzWwz1UVDZYy1yFbWtjOA0ZCqxqy9zbeSZAFv/wv+lmXWbLY6iS4orW0uo8 HKRIk4caMo4vFH+n3ze9vPm7A/FSKrtLguHSMOiu4GqaRDGEq5GyHA4xdaghBJQ6MMZc kxeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NwA4CqvxKmvSRXgeGj2yadyCOJ4Y6n3edsoObSgx8d4=; fh=9VyUFYbCstQKBT1UOiWuIcrdDT17BteAq5KPHFf+DlQ=; b=eMRjHKq7fV9ijPaObd8FO4G1qEKG9naZGZ6fFXv6A3smD6WyLqAfWIcHXm8odbuU8v PGfu+jcsr7EgyFRVb1Tjxp2niHh08PBe+5NhPNHpZpE2Gog8FM6C7QKtETbyyIpusYVR f5BmWdWLY9DZqTTg3AKZA1AmKRIf7aMeSaXk7edXKJLZaaRxFRUMtJaL2SAQRPtEXriZ sYAHHjGtEyH+tGhFEeLm/NZVtcxyVgAal+rJ2qri7XYKQwdtDr4AU2DynAXHAGnxRR/0 nT6WxwBkwabsZRYCTeMGF77c4aTJ8JWW1s/RjMfhMG5tH+xJpOSTAUA9/fq2ZZ9WnHN6 W+ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Cdbg3Wzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i12-20020a1709064ecc00b00977e729a2f7si345170ejv.951.2023.07.10.13.43.58; Mon, 10 Jul 2023 13:44:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=Cdbg3Wzc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231355AbjGJU27 (ORCPT + 99 others); Mon, 10 Jul 2023 16:28:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbjGJU25 (ORCPT ); Mon, 10 Jul 2023 16:28:57 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 473B2AD; Mon, 10 Jul 2023 13:28:56 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2b6fdaf6eefso76014151fa.0; Mon, 10 Jul 2023 13:28:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689020934; x=1691612934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NwA4CqvxKmvSRXgeGj2yadyCOJ4Y6n3edsoObSgx8d4=; b=Cdbg3WzcN8W/VWeQQ49vaAlmTB8aKVQYef9AXCEh7EneO1Ufbzeoq0m4c4ePS0pijj CuDq6IMPiVqh8VC6KRN5IFBXOwRgb5sVm3TyTyX/EbntinrWdj3Y2PONkrBXRf0AQ2Y+ wcm+hLMEX9Se5p7128uD5j02kn6VrBj3EKOkbb1apArMYNhu83xrRi+wRr2tCu0SDeWI 6y/nSqv5qEZevC4tRP3tcO0ldog226UJRP5YqUkxkNr3bHFQSL71q4Ib+fx0hS2iLBqK ih8COm4OdSzBJpHciSa2fztN8tocQr3v64l1y9SrIlZeNSArU589egSSj9pIOOkMSYqO OZZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689020934; x=1691612934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NwA4CqvxKmvSRXgeGj2yadyCOJ4Y6n3edsoObSgx8d4=; b=EamBQgo3J94zrqm1R3wVjGr7FVpfMmhLkSV9JvZWDC1T9NEi5gwZkSqM2hMJ2/8j+W UfzLHra4jMS1q9zvgL7h39zysqQRTkVpLxxUbooLvrwQA6FDlz+gLcTgwbJoorcuwf11 jgz2+/OZibTfvTIIgPJPvpsC9Ok5XVV4xkPEi+vNcPmeURSfeWn5hTRDX63sOs4mKwUD 3w+Dd39QlezBxVe7N1nn8NrN+Df1NhBxl1J7Sc4jtMfC5CUz4YXIVrsj19ulOOIWm5en nYGCVvVRS9CLggg49xkRJrZdQzqVTN+lwTyO/+q/lJOxsRp+d2upZulGcOcQJooDXmWe IIYg== X-Gm-Message-State: ABy/qLYC2R6WTutV+MIehSpZAI0timRwMMbSVUjqFuMrTZI9Yc77R1hb XpGC87BVO15cRQtaDZOhbXI= X-Received: by 2002:a2e:3507:0:b0:2b6:b611:64e9 with SMTP id z7-20020a2e3507000000b002b6b61164e9mr9219778ljz.52.1689020934229; Mon, 10 Jul 2023 13:28:54 -0700 (PDT) Received: from valmont.froyen.eu ([2a01:799:ba5:6500::80f]) by smtp.gmail.com with ESMTPSA id s15-20020a2e9c0f000000b002b700ca0f61sm123522lji.112.2023.07.10.13.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 13:28:53 -0700 (PDT) From: Valentin David To: Jarkko Sakkinen , Peter Huewe , Jason Gunthorpe Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, Valentin David Subject: [PATCH v3] tpm: Do not remap from ACPI resouces again for Pluton TPM Date: Mon, 10 Jul 2023 22:27:49 +0200 Message-ID: <20230710202845.190917-1-valentin.david@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For Pluton TPM devices, it was assumed that there was no ACPI memory regions. This is not true for ASUS ROG Ally. ACPI advertises 0xfd500000-0xfd5fffff. Since remapping is already done in `crb_map_pluton`, remapping again in `crb_map_io` causes EBUSY error: ``` [ 3.510453] tpm_crb MSFT0101:00: can't request region for resource [mem 0xfd500000-0xfd5fffff] [ 3.510463] tpm_crb: probe of MSFT0101:00 failed with error -16 ``` Fixes: 4d2732882703 ("tpm_crb: Add support for CRB devices based on Pluton") Signed-off-by: Valentin David --- v3: Add fixes tag --- drivers/char/tpm/tpm_crb.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/char/tpm/tpm_crb.c b/drivers/char/tpm/tpm_crb.c index d43a0d7b97a8..1a5d09b18513 100644 --- a/drivers/char/tpm/tpm_crb.c +++ b/drivers/char/tpm/tpm_crb.c @@ -563,15 +563,18 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, u32 rsp_size; int ret; - INIT_LIST_HEAD(&acpi_resource_list); - ret = acpi_dev_get_resources(device, &acpi_resource_list, - crb_check_resource, iores_array); - if (ret < 0) - return ret; - acpi_dev_free_resource_list(&acpi_resource_list); - - /* Pluton doesn't appear to define ACPI memory regions */ + /* + * Pluton sometimes does not define ACPI memory regions. + * Mapping is then done in crb_map_pluton + */ if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) { + INIT_LIST_HEAD(&acpi_resource_list); + ret = acpi_dev_get_resources(device, &acpi_resource_list, + crb_check_resource, iores_array); + if (ret < 0) + return ret; + acpi_dev_free_resource_list(&acpi_resource_list); + if (resource_type(iores_array) != IORESOURCE_MEM) { dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n"); return -EINVAL; -- 2.41.0