Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1163474pxj; Fri, 21 May 2021 07:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaKdTarm4IiMpxusW/O4A9Z/fRWPTYbqbbSlZpA9zYMoM5Y2VEqiPkdTjXkv2v/E48DveH X-Received: by 2002:a05:6638:14ce:: with SMTP id l14mr4759776jak.90.1621608903118; Fri, 21 May 2021 07:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621608903; cv=none; d=google.com; s=arc-20160816; b=O7eDa604kSGvsiZCNU9Qlq5ZEMenhxLCnRTmOl3r0Yk1AcnBN3LLJvqdOL5W4o0Yte yfa6iyr+18iVEHisPDIMZtUBENKDue5+sLV7GIOsIdOuFvkHBpcFRKBixgNx7zOARkwX Ak44MbL54u6vfCDuFhik3sb9NRfC4KNrGI7OlViseu3Cma1oFMSEStrrlaStG111k+ii xdA8VMfdYQqoW7FojvBDdk3etqiXsYQkfNqovKe2UeC6DYHKtGTwcDkzo+KUUQIscTBZ HIz+wHZnHqf9/0n4xF4Co/PDfZkI8jDcXV8TU3DIDevraYt+rFak51I3+NeoE09j1kkd m67w== 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; bh=OhFIRCkOs81fMaxAYpodGS2wjOUuiCI5qY37aZo8prk=; b=f3j0sVeQcPR/RJana22n0J1LLfipxx9ovoeQIRpmDM1A+9J67UMcOkHnXCHH806nuz NSoltWz1G2BR+wSnAEQtWJy7zeBb2Zag1pXypr6iTQ8QBb0CHIbn8JYk0w5oClWORRDu 3z2CWEZfAd+FxHr3N/MvlS/egT6qYtkMsk9eH5/iljyhJ8c9r1ggl8N1slVruL+S2Dg5 XgMth1zEx86LWXQM/x8VtG+ePdmWi6sMyMwl/Ebhu2NzgnxlqvgNj9cQSshK8HRQp/CJ tC0R08avY/VYIQ5lnMDEjYYOpBGPvFkyruaEPSA/tnNv/NAsFy9e32QQwOxw8hbBm6Jz 7MSQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si4029625jaj.29.2021.05.21.07.54.49; Fri, 21 May 2021 07:55:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233056AbhETQjD (ORCPT + 99 others); Thu, 20 May 2021 12:39:03 -0400 Received: from mail-ed1-f43.google.com ([209.85.208.43]:37517 "EHLO mail-ed1-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbhETQjD (ORCPT ); Thu, 20 May 2021 12:39:03 -0400 Received: by mail-ed1-f43.google.com with SMTP id g7so7993358edm.4; Thu, 20 May 2021 09:37:40 -0700 (PDT) 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=OhFIRCkOs81fMaxAYpodGS2wjOUuiCI5qY37aZo8prk=; b=paJHBuC02DD1NaG4qLKCqcv72RyFINn1psRzIrhztJX0jZgRc9221S4KXC8B8gePS8 XSW0wESRC8WD+j+gN9ICCoeDbssF8gJ+pn7wHLXHWmPicYT0JDp7xoECB7dsLc9BiZAn KQutSv7Gf2HpBjrxLrNGlFZ5DXxSzgiNKoXdE9OGkKYKJXZcI0FeJqrJGoTiTBrL7GO1 mUAd/ncKU1ZZRCyTSHvNGQKdMId2l/xJnhfms7bQgSxKsNol9WWOPXL2ET3xNay8udxo MXszzUwiks9a0dx0XlmREBp1Ca3MznegDYj5Fy0mWT3YiBDvZegRsmFFNf2WXGk9vhyw yhUg== X-Gm-Message-State: AOAM533bGLFPdGwZCsHe0q7RsHURQW2yIKShSQlv3WAfN1n/yJVrcBW8 vmJTs42BC22ZqtJcBcRPtcQ= X-Received: by 2002:aa7:cb90:: with SMTP id r16mr5935263edt.247.1621528659444; Thu, 20 May 2021 09:37:39 -0700 (PDT) Received: from rocinante.localdomain ([95.155.85.46]) by smtp.gmail.com with ESMTPSA id e12sm1675053ejk.99.2021.05.20.09.37.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 May 2021 09:37:38 -0700 (PDT) Date: Thu, 20 May 2021 18:37:37 +0200 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: Amey Narkhede Cc: Bjorn Helgaas , alex.williamson@redhat.com, raphael.norwitz@nutanix.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH RESEND v2 5/7] PCI/sysfs: Allow userspace to query and set device reset mechanism Message-ID: <20210520163737.GD641812@rocinante.localdomain> References: <20210519235426.99728-1-ameynarkhede03@gmail.com> <20210519235426.99728-6-ameynarkhede03@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210519235426.99728-6-ameynarkhede03@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Amey, [...] > + if (sysfs_streq(buf, "")) { > + pci_warn(pdev, "All device reset methods disabled by user"); > + goto set_reset_methods; > + } The sysfs_streq() is nice, indeed. > + while ((name = strsep((char **)&buf, ",")) != NULL) { I believe we could make this parsing a little bit more resilient, especially since we are handling user input and this cannot ever be really fully trusted, so for example: while ((name = strsep((char **)&buf, ","))) { if !(strlen(name)) <--- sysfs_streq() could be used here too. continue; name = strim(name); <--- remove leading and trailing whitespaces, if any. (...) [...] > + if (reset_methods[0] && > + reset_methods[0] != PCI_RESET_FN_METHODS) > + pci_warn(pdev, "Device specific reset disabled/de-prioritized by user"); What would be difference between disabling and de-prioritizing, is there be a way for us to distinguish between the two? I was wondering if we could, notify the user when the device specific reset is disable or when it has been de-prioritized? Krzysztof