Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp11132090rwd; Thu, 22 Jun 2023 09:06:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5YJcJ8RKNUEAihhSg7TbaFGrZ+p2xJ4yYTzCiN8VREgySQt8F5xQUUjUnhWfQCC4zZuRBq X-Received: by 2002:a17:90a:e602:b0:25e:c420:6a7d with SMTP id j2-20020a17090ae60200b0025ec4206a7dmr8032590pjy.33.1687450000411; Thu, 22 Jun 2023 09:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687450000; cv=none; d=google.com; s=arc-20160816; b=tgJNnu++OYkjvBU/jYSAnxIekr9UV+BmG+IUGSBN3j+cCz0dm+//fUQmLzhdUxh3+6 nEEpsOzP85H/1AfRBmHgdSt0UrA73G0feufV1Yk6xhwNbf5O5X5knamJgWtAcYktntJq xopoaFWe9Bms0GvlLx5bq/kURYJaJ/LgcbTVQFla69MwkRHY/GRHQhQQ0Uytv6cGz2G8 dEensvyC/PUNZSGi2Q/JI7Ixp84TnVC581UHGy0HO5LrU+Xj0XR0xVJCFQ6/Pws3Qo6c VPUjPKHrNkYO9+xAZ6N1H1xoArdG7SORdAkMnLWTpyoBnsii4tTNqoh426hBdt2tBw30 i8Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=Fcb3kUVNFDo6J4R8fao4VaxaClHXEjvtAaCoCz+jNIs=; b=niKb5Z9j8b7zTGaWrG/6UwHNZp8Tauz1oBQuGpeF9zYRwKrqFUGlbLIWh6MHZg3Fbu B1VZtTF5ckFX4zPWYWYPvbQDrcF+DkGax5Rbo3JAZGo6x0Y82QA9B4jYdJ/cVt3b9lls x9bkbwlTKjNzfDuGW761+fMKYVoL8k+0OVxX7Bz+GcBqYbrOcMpyZXvuS1ncNtIr5W9a 7TWS4//attfD7XA1QGK+jLGerQOkT0NML69L4HclKaJvYFgP9L+lTXb4boXgRAqQKX/k STufWpLgwXsb8Q9s1vVI6cRZMXZqU9akII7JpoBW5V9YFT6Cbt6iu3O1T9GzjyNuvzHU 9Ujw== ARC-Authentication-Results: i=1; mx.google.com; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s65-20020a637744000000b00541710a9d44si6033355pgc.114.2023.06.22.09.06.06; Thu, 22 Jun 2023 09:06:40 -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; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231465AbjFVPx3 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Jun 2023 11:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231244AbjFVPx1 (ORCPT ); Thu, 22 Jun 2023 11:53:27 -0400 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4839E10F8; Thu, 22 Jun 2023 08:53:26 -0700 (PDT) Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-98502b12fd4so202445466b.1; Thu, 22 Jun 2023 08:53:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687449205; x=1690041205; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LRq3IplvxHFodqnGJxa2C+GD1dW0/Z+gi8MyiCpWLqY=; b=ezFP1kQ9UrqWGUQwuQdT2Q2yvFI7Zv2wYsBzvyMtP8AyryTNgXYIXPkrrLT648Knva GUU7jraGSfoyW5EVCLhV/PwqGddKmcVUlXrMEh3DzsCsHYY/ORS5+ghJr/qEwWjb//af Cy99O3byqxA/F7ATAPbt9RZIGEvqnjsg7DuePz6ka0umCmk1sNFP7t7sgWoa83gLhM5+ +bSziO57seBKN1t5WXORAanIcoE6iVN058fL6V0IMj2Y3b8snZbZksgOOTv0yvNJaOAv lMMoBRVvj77OrIn+r4w/56HJZbj2LYM0oLRpF0JY0fiwwHOh1BRa5vGUQy36GIHb2V/Q kTJA== X-Gm-Message-State: AC+VfDyNbC/c177HRBdi/hRuBN3LmiWcd6c/7sl1jh1mRKtRhmiB1Ssm N1jqn+/IFaEjef2zfwuL7SAM3YPxn1Ob8La7NGY= X-Received: by 2002:a17:906:100a:b0:987:81d:9d49 with SMTP id 10-20020a170906100a00b00987081d9d49mr12869574ejm.7.1687449204470; Thu, 22 Jun 2023 08:53:24 -0700 (PDT) MIME-Version: 1.0 References: <20230621151652.79579-1-andriy.shevchenko@linux.intel.com> In-Reply-To: <20230621151652.79579-1-andriy.shevchenko@linux.intel.com> From: "Rafael J. Wysocki" Date: Thu, 22 Jun 2023 17:53:13 +0200 Message-ID: Subject: Re: [PATCH v2 1/2] ACPI: platform: Ignore SMB0001 only when it has resources To: Andy Shevchenko Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, acpica-devel@lists.linuxfoundation.org, "Rafael J. Wysocki" , Len Brown , Andi Shyti , Robert Moore , Michael Brunner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Wed, Jun 21, 2023 at 5:16 PM Andy Shevchenko wrote: > > After switching i2c-scmi driver to be a plaform one, it stopped "platform" > being enumerated on number of Kontron platforms, because it's > listed in the forbidden_id_list. > > To resolve the situation, split the list to generic one and > another that holds devices that has to be skipped if and only "have" > if they have bogus resources attached (_CRS method returns some). > > Fixes: 03d4287add6e ("i2c: scmi: Convert to be a platform driver") > Closes: https://lore.kernel.org/r/60c1756765b9a3f1eab0dcbd84f59f00fe1caf48.camel@kontron.com > Reported-by: Michael Brunner > Tested-by: Michael Brunner > Reviewed-by: Andi Shyti > Link: https://lore.kernel.org/r/20230620163534.1042-1-andriy.shevchenko@linux.intel.com > Signed-off-by: Andy Shevchenko > --- > v2: added tags (Andi, Michael), fixed spelling (Andi) > drivers/acpi/acpi_platform.c | 27 +++++++++++++++++++++++++-- > 1 file changed, 25 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c > index fe00a5783f53..089a98bd18bf 100644 > --- a/drivers/acpi/acpi_platform.c > +++ b/drivers/acpi/acpi_platform.c > @@ -19,13 +19,17 @@ > > #include "internal.h" > > +static const struct acpi_device_id forbidden_id_with_resourses[] = { I don't quite like this name and the driver_data field could be used to indicate the need to check the resources. > + {"SMB0001", 0}, /* ACPI SMBUS virtual device */ > + { } > +}; > + > static const struct acpi_device_id forbidden_id_list[] = { > {"ACPI0009", 0}, /* IOxAPIC */ > {"ACPI000A", 0}, /* IOAPIC */ > {"PNP0000", 0}, /* PIC */ > {"PNP0100", 0}, /* Timer */ > {"PNP0200", 0}, /* AT DMA Controller */ > - {"SMB0001", 0}, /* ACPI SMBUS virtual device */ > { } > }; > > @@ -83,6 +87,15 @@ static void acpi_platform_fill_resource(struct acpi_device *adev, > dest->parent = pci_find_resource(to_pci_dev(parent), dest); > } > > +static int acpi_platform_resource_count(struct acpi_resource *ares, void *data) > +{ > + int *count = data; > + > + *count = *count + 1; Why not (*count)++? > + > + return 1; > +} > + > /** > * acpi_create_platform_device - Create platform device for ACPI device node > * @adev: ACPI device node to create a platform device for. > @@ -103,7 +116,8 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, > struct resource_entry *rentry; > struct list_head resource_list; > struct resource *resources = NULL; > - int count; > + int count = 0; > + int ret; > > /* If the ACPI node already has a physical device attached, skip it. */ > if (adev->physical_node_count) > @@ -113,6 +127,15 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, > return ERR_PTR(-EINVAL); > > INIT_LIST_HEAD(&resource_list); > + ret = acpi_dev_get_resources(adev, &resource_list, acpi_platform_resource_count, &count); > + if (ret < 0) > + return ERR_PTR(ret); Why not use acpi_walk_resources() directly here? Also, this extra resources walk is only needed if the resources check is needed to decide whether or not to skip the device, so what's the benefit of doing it for every device that's not skipped? > + > + acpi_dev_free_resource_list(&resource_list); > + > + if (count > 0 && !acpi_match_device_ids(adev, forbidden_id_with_resourses)) > + return ERR_PTR(-EINVAL); > + > count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); > if (count < 0) > return NULL; > --