From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753838Ab1IFI2F (ORCPT ); Tue, 6 Sep 2011 04:28:05 -0400 Received: from david.siemens.de ([192.35.17.14]:27676 "EHLO david.siemens.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753294Ab1IFI2B (ORCPT ); Tue, 6 Sep 2011 04:28:01 -0400 Message-ID: <4E65D981.7070201@siemens.com> Date: Tue, 06 Sep 2011 10:27:45 +0200 From: Jan Kiszka User-Agent: Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 MIME-Version: 1.0 To: "Michael S. Tsirkin" CC: Jesse Barnes , Brian King , "James E.J. Bottomley" , "Hans J. Koch" , Greg Kroah-Hartman , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "kvm@vger.kernel.org" Subject: Re: [RFC] pci: Rework config space blocking services References: <20110829150552.GA6851@redhat.com> <4E5BB358.3060705@siemens.com> <4E5BDEAB.5000405@siemens.com> <20110829191858.GA9415@redhat.com> <4E608A51.70509@siemens.com> <20110906055810.GA13286@redhat.com> <4E65C935.9000803@siemens.com> <20110906080410.GD13286@redhat.com> In-Reply-To: <20110906080410.GD13286@redhat.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2011-09-06 10:04, Michael S. Tsirkin wrote: > On Tue, Sep 06, 2011 at 09:18:13AM +0200, Jan Kiszka wrote: >>>> @@ -401,36 +403,58 @@ int pci_vpd_truncate(struct pci_dev *dev, size_t size) >>>> EXPORT_SYMBOL(pci_vpd_truncate); >>>> >>>> /** >>>> - * pci_block_user_cfg_access - Block userspace PCI config reads/writes >>>> + * pci_block_cfg_access - Block PCI config reads/writes >>> >>> This comment seems confusing. We don't in fact block all config >>> reads writes. Instead we block userspace accesses and >>> concurrent block requests. >> >> I'm open for a better suggestion that summarize the more verbose (and >> hopefully clearer) explanation below. > > I think the problem is, it doesn't block config access > and we call it pci_block_cfg_access. > > Thinking about it, doesn't this behave somewhat like a lock? > How about > > pci_user_cfg_access_trylock > pci_user_cfg_access_lock > pci_user_cfg_access_unlock > > And then: > * pci_user_cfg_access_lock - Lock userspace PCI config access Except that the "userspace" here is still only half of the truth and I prefer to drop it, the naming locks good to me. > * > * When locked, any userspace reads or writes to config space > * and concurrent lock requests will sleep, and trylock requests > * will fail, until pci_user_cfg_access_unlock is called. > > I had a brief thought of using an rwsem internally, but > this would make trylock fail if userspace does config read, > changing semantics. Also, I bet we would make lockdep unhappy when calling down_write_trylock from IRQ context. Jan -- Siemens AG, Corporate Technology, CT T DE IT 1 Corporate Competence Center Embedded Linux