Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp1446245pxy; Fri, 23 Apr 2021 08:14:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuPcdaG//5K6yzmpl4wrX0N/9dWcOs+cmEFt9yhx0yXxLlK38GIKnCINJdJnkUwDvL+Xye X-Received: by 2002:a63:575b:: with SMTP id h27mr4361747pgm.180.1619190873966; Fri, 23 Apr 2021 08:14:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619190873; cv=none; d=google.com; s=arc-20160816; b=vIQ2xk4krB01SfKESGrLE/qTJ2K9nCiWtQL2xmKTxomBvItRLHIQuPBdFvbadRrWnm iK7JWnbiFnP00FFeA43qiiRZ6eKltGjQvfaYrzDa8Ixsg4aBPQs3yAEM5wZG07v0FyZS XWVFEjhqfJOLkNy2Rx5A6CQ7+m0+fopI9UvQpR3w/LF756jLevVFlBivf6qPg+bFIxOF jlBWqniz1H5sqXvATjzHQZ/WslDN37UHn9dFwsxBCe84uzM0m1z62zyQEWclS2MMT+L+ lLPZ6c4yuVjHBydEDnB9eQyzFdekp16vaZroq5wag7Lts+yj/P4kwy4B8rYM4fadD8Sy ntOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=bKNAUhnwOW9QUu3VUwufdB0TxP+RB1nost+Y7hxUsZQ=; b=mQZqCU6WoSXCxidn6xoALHe3iEvuscJKEfbhxoTQl19ZDEteDuCkwTN8tLeBKtkZ9t 6m0b/cd1zSx6zCJQMcrVk2PtHOO72fYogPrbn+/GUNLeOp5OquvliEYdoMRZgl2p87bx GjNb6cl5miD34gUNZBpuV31XXP3V5kLQB3iKEoXDbnFEgqFv/oiQbdiCrAnbkNj2VmP9 /dr6QREO6PsRCzk+i0+pBRxL0XJTS7oqbXG+B2tqHM5OlxLq1edI7MOgCZS1i20oWchf JImm2KwK/oQmUMI3zyZdFTZmTuSmFNQ2HJanIkOPCd9TymHYUE6LWhGP3T91Jq7sFupS UZIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jD20Plsb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z6si7266894plo.372.2021.04.23.08.14.22; Fri, 23 Apr 2021 08:14:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jD20Plsb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S242879AbhDWPMp (ORCPT + 99 others); Fri, 23 Apr 2021 11:12:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:48118 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237081AbhDWPMn (ORCPT ); Fri, 23 Apr 2021 11:12:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2305B613D5; Fri, 23 Apr 2021 15:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619190726; bh=8Mkj5bXqM2cvFiGupG938Y/QnyU3NfrDfuKS5blpr08=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jD20PlsbvdhCddy52R4Gpb3+mp9sbsN5mK9DcEUegwgXIsgvJNJdSyrv2j42xC7LS GlGjavrV+w7EJtijlqqDOm/SBrAqycY2V34hLtLSSsdr2/uYzE2dDmjGv7lo8sBAn1 LyuAoz8siw4oM8pqMgT8gMF789tH6tnnobQGtlRHsipdMSuhZSpfEhA4y6QTQm5tql LiAbjK9lcvXn8vJ9ANHwKvOAU3l/C7zUfb7TioUcUIjmGULYQZCfgLZqgC3K9ItI8J VOCDOxU/ix7kt2Do+gTaVH4vZDYYt5BSz5HqOVjI3omDs9nbliNNCZ0+TQXo/pmYEQ ma4fADxmufwPg== Subject: Re: [PATCH 1/1] PCI: Add pci reset quirk for Nvidia GPUs To: Shanker Donthineni , Bjorn Helgaas , Alex Williamson Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Vikram Sethi References: <20210423145402.14559-1-sdonthineni@nvidia.com> From: Sinan Kaya Message-ID: Date: Fri, 23 Apr 2021 11:12:05 -0400 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: <20210423145402.14559-1-sdonthineni@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Alex, On 4/23/2021 10:54 AM, Shanker Donthineni wrote: > +static int reset_nvidia_gpu_quirk(struct pci_dev *dev, int probe) > +{ > +#ifdef CONFIG_ACPI > + acpi_handle handle = ACPI_HANDLE(&dev->dev); > + > + /* > + * Check for the affected devices' ID range. If device is not in > + * the affected range, return -ENOTTY indicating no device > + * specific reset method is available. > + */ > + if ((dev->device & 0xffc0) != 0x2340) > + return -ENOTTY; > + > + /* > + * Return -ENOTTY indicating no device-specific reset method if _RST > + * method is not defined > + */ > + if (!handle || !acpi_has_method(handle, "_RST")) > + return -ENOTTY; > + > + /* Return 0 for probe phase indicating that we can reset this device */ > + if (probe) > + return 0; > + > + /* Invoke _RST() method to perform the device-specific reset */ > + if (ACPI_FAILURE(acpi_evaluate_object(handle, "_RST", NULL, NULL))) { > + pci_warn(dev, "Failed to reset the device\n"); > + return -EINVAL; > + } > + return 0; > +#else > + return -ENOTTY; > +#endif > +} Interesting, some pieces of this function (especially the ACPI _RST) could be generalized.