Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2134077lqo; Mon, 13 May 2024 08:43:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2I/cQHozZiswFizkRDpvi1Uth8z03oOcnWdIW3BYjy2FNOGK5wnk30Si6GMN0kR414WSksxX0PT0TBnxLBLGw3tkd1Vook22fu+M/0g== X-Google-Smtp-Source: AGHT+IFSRMi00KFEGqNeFGYLs48GzfmPcK0Ye07I1+SjEsQwTd6oBDaKHQTUs8xt/d7T6vi0bAlE X-Received: by 2002:ac2:5e71:0:b0:51f:4144:98fc with SMTP id 2adb3069b0e04-5220fa71c8bmr5955743e87.2.1715615031127; Mon, 13 May 2024 08:43:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715615031; cv=pass; d=google.com; s=arc-20160816; b=eNcXckOXjZnnjQh5gAwYAw2HS/sa76Lvu01d04+73B7FaFhUCcn7Rt85M3vwS8IweZ 4KwkM0jZkFZdKr/vXVtHeC9L2H7jPquiEW1dqinoRMPY2lPGbxTFrGTMLep2bXqy0uwa buBIdJuvzD6/BO5WZquUeU2VL2fkc5z5CkTRvni/eS0iUbaWONTUzTzw7J4EMRnqFw/3 fk9s1OfzSeerYzRrbWqGDJWCv1CltzIbznKSEf2P3S59OZZ5LZsnITMOhKXJqJ65KriS 2Ibk23NYIzlWFI1eRrDLXc+toINH7j8fucgd8+4vehU8vkwDxdexdGWzBDZhpXz0NjCU /2NA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=J45M9kzj0PgXeh53M3hkMA4dEKc6WhUAI2AS6c/eda8=; fh=akAIkR/0mFgN2LT3GMrqnNsoZmqBjI/Dnkqb/8bYMLY=; b=YfmhLKDNnZDfy2vEsY5HZHb79sh+ImCuaQ+e6YQ1Xx0bLMoiRrTT4Pb+7ov+vxgbEx Ntd3WEZ+VbiyCw/mVnqe9w+kjBwUr2ivzlC6rDCI1Xz6SwERzluNbGA2RA9TnFNrOQC5 W0wU6M8eurU2YpxP1ojHjJ0xPIdPbaWAiflHr/X++LhY/ITmNDCuoEYcmZoYoa6C5dpS nfuLJG6bsHk6t+nJ0K/l3mUXAXepPnnmGjsAyqjREl2SJqvGi2qkmiydWx8Pu9cAowVz Pwk+7+nn5Fi39rHpHbEuXD7+05wEKT+VAd5coNkq8RcyGQCx8yjxBygIkCm137usNyn+ qIGg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nMKbzLPP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177774-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17c2c04csi525944066b.913.2024.05.13.08.43.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 08:43:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177774-linux.lists.archive=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=@kernel.org header.s=k20201202 header.b=nMKbzLPP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-177774-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177774-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 D32161F21890 for ; Mon, 13 May 2024 15:43:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5888154430; Mon, 13 May 2024 15:43:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nMKbzLPP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C31DA5695; Mon, 13 May 2024 15:43:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715615022; cv=none; b=gG/gC62CJOrs5urX3JGjb8GxLhdoZfiIFRgC3Kfqvup3zX7Hz79s+Da4h7GPUYBi0epC20riu1GsLbbyMfbAYP91IfMXsEceKXQLhhNEbqr0Ntd9Gv24x8mAjt7guuJp1WeyMig8N6qjz/lpAcFT5EVCVHTyfT9YzlGZ2CvMJHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715615022; c=relaxed/simple; bh=J5hQzjcurJJsGoxq8banr21Pa9wy7hpwCT+lAe7WOE0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Cs7a9rN+DKEjlb0COyBiIYjOQUw80SrFuZiWKsxptnYCxHcaNa/RzmgQ+8RyZoEk0wIwv3h6oMjD6itmJW5zPv46IAQi1/11zfYmGsKk7o5x2/DzO5LcV0t7Jaugb8jXsTK4lT3YqmsH68P4UhumGO4Sz+XSJUFhyIp9L8yS9Yk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nMKbzLPP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFFD3C113CC; Mon, 13 May 2024 15:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715615022; bh=J5hQzjcurJJsGoxq8banr21Pa9wy7hpwCT+lAe7WOE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nMKbzLPPNsLi0Y8bkFTPWjaohdSK+zjR/LvuOiBHGWooKmEZhkO8GY5CGqx69n9SY gmUfcQnR/qlVBTtISjVkp1GIAEX62k9Xhy5MvfgYGpx738kE98QnYt6L4lh8D2UVvY njDTH1JHN7TLogXHGHglAmaOi+2EL6Fl7HL1evq0sj1Eg+m7KOniXC77KHE++f/xFr EmNYfasW0x5ush8kPti6vIYX2O0GXuxKaSCHTN+PV8z0wYb/ez5LtN0E7GW6dvX6vQ KVTiEDh+VA2pizGwAWFZY3iKFc66KeeAMxfYxtyR/K2OgZ5jAila5ho3auBdQSii6o H1+Y30X1MN4Uw== Date: Mon, 13 May 2024 17:43:37 +0200 From: Benjamin Tissoires To: Andy Shevchenko Cc: Devyn Liu , linus.walleij@linaro.org, brgl@bgdev.pl, f.fangjian@huawei.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mika.westerberg@linux.intel.com, linux-acpi@vger.kernel.org, jonathan.cameron@huawei.com, yangyicong@huawei.com, yisen.zhuang@huawei.com, kong.kongxinwei@hisilicon.com Subject: Re: [PATCH] gpiolib: acpi: Fix failed in acpi_gpiochip_find() by adding parent node match Message-ID: References: <20240513075901.2030293-1-liudingyuan@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On May 13 2024, Andy Shevchenko wrote: > On Mon, May 13, 2024 at 03:59:01PM +0800, Devyn Liu wrote: > > Previous patch modified the standard used by acpi_gpiochip_find() > > to match device nodes. Using the device node set in gc->gpiodev->d- > > ev instead of gc->parent. > > > > However, there is a situation in gpio-dwapb where the GPIO device > > driver will set gc->fwnode for each port corresponding to a child > > node under a GPIO device, so gc->gpiodev->dev will be assigned the > > value of each child node in gpiochip_add_data(). > > > > gpio-dwapb.c: > > 128,31 static int dwapb_gpio_add_port(struct dwapb_gpio *gpio, > > struct dwapb_port_property *pp, > > unsigned int offs); > > port->gc.fwnode = pp->fwnode; > > > > 693,39 static int dwapb_gpio_probe; > > err = dwapb_gpio_add_port(gpio, &pdata->properties[i], i); > > > > When other drivers request GPIO pin resources through the GPIO device > > node provided by ACPI (corresponding to the parent node), the change > > of the matching object to gc->gpiodev->dev in acpi_gpiochip_find() > > only allows finding the value of each port (child node), resulting > > in a failed request. > > > > Reapply the condition of using gc->parent for match in acpi_gpio- > > chip_find() in the code can compatible with the problem of gpio-dwapb, > > and will not affect the two cases mentioned in the patch: > > 1. There is no setting for gc->fwnode. > > 2. The case that depends on using gc->fwnode for match. > > Thanks for the report, analysis, and patch. > > ... > > > static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data) > > { > > - return device_match_acpi_handle(&gc->gpiodev->dev, data); > > + return device_match_acpi_handle(&gc->gpiodev->dev, data) || > > + (gc->parent && device_match_acpi_handle(gc->parent, data)); > > } The original patch (from Devyn) is: Tested-by: Benjamin Tissoires For reference, a successful run can be seen at: https://gitlab.freedesktop.org/bentiss/hid/-/jobs/58661693 > > I'm wondering if the below approach will work for all: > > static int acpi_gpiochip_find(struct gpio_chip *gc, const void *data) > { > struct device *dev = acpi_get_first_physical_node(ACPI_COMPANION(&gc->gpiodev->dev)); > > return device_match_acpi_handle(dev, data); > } Looks like I get a bad dev pointer in this situation: https://gitlab.freedesktop.org/bentiss/hid/-/jobs/58662689#L704 Not sure if this is because the not-yet-upstream patches I have in hid-cp2112 are doing something wrong or if there is a good reason for it... The patch that adds fwnode to hid-cp2112 are: https://gitlab.freedesktop.org/bentiss/gitlab-kernel-ci/-/blob/master/VM/0002-HID-usbhid-Share-USB-device-firmware-node-with-child.patch https://gitlab.freedesktop.org/bentiss/gitlab-kernel-ci/-/blob/master/VM/0003-HID-cp2112-Fwnode-Support.patch both of those patches are applied before compilation in the CI run from above. > > Cc'ing to Benjamin for testing and commenting. TL;DR: initial patch is fine, yours will probably need a check on the dev return value, so not sure if we gain a lot... Cheers, Benjamin