Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp437358pxy; Sat, 31 Jul 2021 12:16:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyP+LoVq6ZotlSAPYtAsdCZubuTxs6NPHaqJoVxtem3ldUa0tNv9uxhVliUpe656ckX645e X-Received: by 2002:a6b:b287:: with SMTP id b129mr6120802iof.209.1627758972399; Sat, 31 Jul 2021 12:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627758972; cv=none; d=google.com; s=arc-20160816; b=A5+b0yrn8D9mwk3uf/q83jAVQ9yfnHoEZ+IuUiI0+3w5eMftpH4ARStRg+XwojytyR Y3aU81/oIxn0c5a4+eaVdws6qP9gIrrTfdZ7MCU64oZ51aFvd98wzLQGqNT84/v8E5FP PwoZ6XnoCjdbwIW9y/fKLHCg969qDBQkoRioA2LnYzcJ5D/AZYBGof+mgOTmptEp1sql jBRmtG9A8sZD6r/bvAyuRVHZ1c3wXdw5mS2s4g3N/GHJ7n9OaFrKqCnq5SgfQ6SzbYw/ qApc6HJg73rGrZ7cH8mQ7RIyBuuk2H4WnX1RLjhDHssThMWOLTTqymMojCM72bAbZUP2 Xyjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=1y8EiRS4BQiqhepS4ejW6iSDklPXdZhmSNW0+oA9248=; b=M+d5zpxVg+FaNhqZ+n/KZlzdNIUX7RIYJgDRHFE9JuePGhKH2Pdf0ZxLMXDiMazA6V fTL38WgpDJ+tam7kSreB8MoLeCY/QDOHYEPkvLnPRlTTphk9CztRxxWIxwxU7ALZLn6f 4VQTt6cXP+kR5xMeviuJMqzYpx//wJMOGHdJUWGdMrPK2XzYE0pd3eGEo4EMZ4aVdD+9 Nu59NVTwcoyZnfKK7GvDOw+uLsnZrajAiNRXY784WkkXVXtehQlXo1sURdOj61mB0b/r XByx3Keo67vxgGqtJQv1B1Jz+CU9r0z7weVqxMFPt4uwjdWNxzsBVss6sUYbtHIwiJQe Cp4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nr89TCXc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si7249875jat.88.2021.07.31.12.16.00; Sat, 31 Jul 2021 12:16:12 -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=@gmail.com header.s=20161025 header.b=nr89TCXc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbhGaTPX (ORCPT + 99 others); Sat, 31 Jul 2021 15:15:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229642AbhGaTPW (ORCPT ); Sat, 31 Jul 2021 15:15:22 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66C13C06175F; Sat, 31 Jul 2021 12:15:16 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id k4-20020a17090a5144b02901731c776526so25673941pjm.4; Sat, 31 Jul 2021 12:15:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1y8EiRS4BQiqhepS4ejW6iSDklPXdZhmSNW0+oA9248=; b=nr89TCXcL6sWAXhNE7YvOQZl4cmge5e+UOBa4P62eFaRTNvAOF2CFqjFzyvZR/PboA rjnKNXg/rxTOKXnyMQWX2WWKwWOMrhJG6iiRWAB91s9L5qqacA8kNfesp/fEHGuanp3s lDOBVBHUc34sbmJNzWAF4IaEQcPbRCJzMyrivRdGNC/di+0UCqWni1Fcw1FiL+ZxS9CD rWl53OmaJh3gc/KXp4tOaIgGq781Hh2cv5a6Tzv/vUrRYN0xcnuD7FGR3bnj8YTT1lzD VKVrsvjQJdMW2ZE/G1/+7mY7G4bDayZS2kM74Ylm0DoE6HS0PS/K3dBmVRavhG8J+lJu m7FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1y8EiRS4BQiqhepS4ejW6iSDklPXdZhmSNW0+oA9248=; b=gD1U1DjosnoLIIxA/K6bgHKdrgu36D8B28N5P0CIL1RSrNs0o4ozrBV51oiKF4RAxl xaZmTqGWbFYDoAu0XR+4q4hWZT/yKAAhOh/Ouq7sSqOV4DdeZtipwqeTL1x1SWvBfXss z+4UFePLHlNxuVx6e5Zwku8gTsnuPLU+/wLVDA4JsS/YhnBpczL114VAYAk3nvkM3fpY jGFxsxt6LRtlJfKCGn27dTgmOtEnpB592aTHON4qjcCowPw4iaKiw3ivdlww9rhylZPi 3ZeAPY7JePWxuI1qAiw7PPS5E62HUUrd3OogjTXgrL8jk2GmOcAWDaRGuj50+T+PLfjX 7UJw== X-Gm-Message-State: AOAM532dzq5uKbLb8fRszY6V5z96GVqF+UUr25Ttzr2u1DveHIrAdKHs PdxfSsPlwSq8tijnU5bG5TE= X-Received: by 2002:a05:6a00:178f:b029:32b:2092:c3f5 with SMTP id s15-20020a056a00178fb029032b2092c3f5mr8655310pfg.57.1627758915918; Sat, 31 Jul 2021 12:15:15 -0700 (PDT) Received: from localhost ([139.5.31.186]) by smtp.gmail.com with ESMTPSA id 135sm1464150pfv.20.2021.07.31.12.15.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 12:15:15 -0700 (PDT) Date: Sun, 1 Aug 2021 00:45:05 +0530 From: Amey Narkhede To: Bjorn Helgaas Cc: alex.williamson@redhat.com, Raphael Norwitz , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kw@linux.com, Shanker Donthineni , Sinan Kaya , Len Brown , "Rafael J. Wysocki" Subject: Re: [PATCH v10 4/8] PCI/sysfs: Allow userspace to query and set device reset mechanism Message-ID: <20210731191505.xzor5lpqv4ubmijf@archlinux> References: <20210709123813.8700-5-ameynarkhede03@gmail.com> <20210727232808.GA754831@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210727232808.GA754831@bjorn-Precision-5520> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/07/27 06:28PM, Bjorn Helgaas wrote: > On Fri, Jul 09, 2021 at 06:08:09PM +0530, Amey Narkhede wrote: > > Add reset_method sysfs attribute to enable user to query and set user > > preferred device reset methods and their ordering. > > > > Co-developed-by: Alex Williamson > > Signed-off-by: Alex Williamson > > Signed-off-by: Amey Narkhede > > --- > > Documentation/ABI/testing/sysfs-bus-pci | 19 +++++ > > drivers/pci/pci-sysfs.c | 103 ++++++++++++++++++++++++ > > 2 files changed, 122 insertions(+) > > [...] > > + if (i == PCI_NUM_RESET_METHODS) { > > + kfree(options); > > + return -EINVAL; > > + } > > + } > > + > > + if (!pci_reset_fn_methods[1].reset_fn(pdev, 1) && reset_methods[0] != 1) > > + pci_warn(pdev, "Device specific reset disabled/de-prioritized by user"); > > Hmmm. I sort of see the point here, but I wish we didn't have the > implicit dependency on pci_reset_fn_methods[1] being > pci_dev_specific_reset(). > > I know we've talked about this before. I'm still not 100% sure either > of these warnings is worthwhile, especially since we're not *using* > the reset here. It might be useful at the point where we try to *do* > a reset. I dunno. Maybe this is the best place since this is where > the user potentially screwed up. > I agree this is the best place for the warning as this where potentially broken reset methods may get called/prioritized. We can move this check to __pci_reset_function_locked() if you want. > > +set_reset_methods: > > + memcpy(pdev->reset_methods, reset_methods, sizeof(reset_methods)); > > + kfree(options); > > + return count; > > +} > > +static DEVICE_ATTR_RW(reset_method); > > + > > +static struct attribute *pci_dev_reset_method_attrs[] = { > > + &dev_attr_reset_method.attr, > > + NULL, > > +}; > > + > > +static umode_t pci_dev_reset_method_attr_is_visible(struct kobject *kobj, > > + struct attribute *a, int n) > > +{ > > + struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); > > + > > + if (!pci_reset_supported(pdev)) > > + return 0; > > + > > + return a->mode; > > +} > > + > > +static const struct attribute_group pci_dev_reset_method_attr_group = { > > + .attrs = pci_dev_reset_method_attrs, > > + .is_visible = pci_dev_reset_method_attr_is_visible, > > +}; > > + > > static ssize_t reset_store(struct device *dev, struct device_attribute *attr, > > const char *buf, size_t count) > > { > > @@ -1491,6 +1593,7 @@ const struct attribute_group *pci_dev_groups[] = { > > &pci_dev_config_attr_group, > > &pci_dev_rom_attr_group, > > &pci_dev_reset_attr_group, > > + &pci_dev_reset_method_attr_group, > > &pci_dev_vpd_attr_group, > > #ifdef CONFIG_DMI > > &pci_dev_smbios_attr_group, > > -- > > 2.32.0 > >