From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756712Ab3LTKkp (ORCPT ); Fri, 20 Dec 2013 05:40:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:16470 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755720Ab3LTKkn (ORCPT ); Fri, 20 Dec 2013 05:40:43 -0500 Date: Fri, 20 Dec 2013 10:04:13 +0100 From: Alexander Gordeev To: Bjorn Helgaas Cc: "linux-kernel@vger.kernel.org" , Michael Ellerman , Benjamin Herrenschmidt , Tejun Heo , Ben Hutchings , David Laight , Mark Lord , "H. Peter Anvin" , "linux-pci@vger.kernel.org" Subject: Re: [PATCH v4 9/9] PCI/MSI: Introduce pci_auto_enable_msi*() family helpers Message-ID: <20131220090412.GA28367@dhcp-26-207.brq.redhat.com> References: <20131218003002.GA15119@google.com> <20131218132349.GA29552@dhcp-26-207.brq.redhat.com> <20131219134244.GA32238@dhcp-26-207.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 19, 2013 at 02:37:22PM -0700, Bjorn Helgaas wrote: > On Thu, Dec 19, 2013 at 6:42 AM, Alexander Gordeev wrote: > > On Wed, Dec 18, 2013 at 11:58:47AM -0700, Bjorn Helgaas wrote: > >> If rc == 13 and the device can only use 8, the extra 5 would be > >> ignored and wasted. > >> > >> If the waste is unacceptable, the driver can try this: > >> > >> rc = pci_enable_msix_range(dev->pdev, dev->irqs, 16, 16); > >> if (rc < 0) { > >> rc = pci_enable_msix_range(dev->pdev, dev->irqs, 8, 8); > >> if (rc < 0) { > >> rc = pci_enable_msix_range(dev->pdev, dev->irqs, 4, 4); > >> ... > >> } > > > > I have troubles with this fallback logic. On each failed step we get an > > error and we do not know if this is indeed an error or an indication of > > insufficient MSI resources. Even -ENOSPC would not tell much, since it > > could be thrown from a lower level. > > > > By contrast, with the tri-state return value we can distinguish and bail > > out on errors right away. > > I thought the main point of this was to get rid of interfaces that > were prone to misuse, and tri-state return values was a big part of > that. All we really care about in the driver is success/failure. I'm > not sure there's much to be gained by analyzing *why* we failed, and I > think it tends to make uncommon error paths more complicated than > necessary. If we fail four times instead of bailing out after the > first failure, well, that doesn't sound terrible to me. The last > failure can log the errno, which is enough for debugging. Sure, the main point is to get rid of try-state interfaces. I just afraid to throw out the baby with the bath water for unusual devices (which we do not have in the tree). I can only identify two downsides of the approach above - (a) repeated error logging in a platform code (i.e. caused by -ENOMEM) and (b) repeated attempts to enable MSI when the platform already reported a fatal error. I think if a device needs an extra magic to enable MSI (i.e. writing to specific registers etc.) it would be manageable with pci_enable_msix_range(), but may be I am missing something? So my thought is may be we deprecate the tri-state interfaces, but do not do it immediately. -- Regards, Alexander Gordeev agordeev@redhat.com