From patchwork Wed Oct 9 19:02:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoder Stuart-B08248 X-Patchwork-Id: 3011321 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CDD1FBF924 for ; Wed, 9 Oct 2013 19:04:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9E6622026D for ; Wed, 9 Oct 2013 19:04:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E2AD72022A for ; Wed, 9 Oct 2013 19:04:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755010Ab3JITDx (ORCPT ); Wed, 9 Oct 2013 15:03:53 -0400 Received: from va3ehsobe004.messaging.microsoft.com ([216.32.180.14]:17971 "EHLO va3outboundpool.messaging.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754759Ab3JITDw convert rfc822-to-8bit (ORCPT ); Wed, 9 Oct 2013 15:03:52 -0400 Received: from mail103-va3-R.bigfish.com (10.7.14.252) by VA3EHSOBE004.bigfish.com (10.7.40.24) with Microsoft SMTP Server id 14.1.225.22; Wed, 9 Oct 2013 19:03:51 +0000 Received: from mail103-va3 (localhost [127.0.0.1]) by mail103-va3-R.bigfish.com (Postfix) with ESMTP id 09DAA4A00E2; Wed, 9 Oct 2013 19:03:51 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 1 X-BigFish: VS1(zzzz1f42h208ch1ee6h1de0h1fdah2073h1202h1e76h1d1ah1d2ah1fc6hzzz2dh2a8h839h8e2h8e3h944hd25hf0ah1220h1288h12a5h12a9h12bdh137ah13b6h1441h1504h1537h153bh15d0h162dh1631h1758h18e1h1946h19b5h1ad9h1b0ah1b2fh1fb3h1d0ch1d2eh1d3fh1dfeh1dffh1e1dh1fe8h1ff5hbe9i1155h) Received: from mail103-va3 (localhost.localdomain [127.0.0.1]) by mail103-va3 (MessageSwitch) id 1381345346344691_2304; Wed, 9 Oct 2013 19:02:26 +0000 (UTC) Received: from VA3EHSMHS004.bigfish.com (unknown [10.7.14.225]) by mail103-va3.bigfish.com (Postfix) with ESMTP id 4CD5C22004A; Wed, 9 Oct 2013 19:02:26 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by VA3EHSMHS004.bigfish.com (10.7.99.14) with Microsoft SMTP Server (TLS) id 14.16.227.3; Wed, 9 Oct 2013 19:02:25 +0000 Received: from 039-SN1MPN1-002.039d.mgd.msft.net ([169.254.2.133]) by 039-SN1MMR1-002.039d.mgd.msft.net ([10.84.1.15]) with mapi id 14.03.0158.002; Wed, 9 Oct 2013 19:02:25 +0000 From: Yoder Stuart-B08248 To: Wood Scott-B07421 , Kim Phillips CC: Christoffer Dall , Alex Williamson , "linux-kernel@vger.kernel.org" , "a.motakis@virtualopensystems.com" , "agraf@suse.de" , Wood Scott-B07421 , Sethi Varun-B16395 , Bhushan Bharat-R65777 , "peter.maydell@linaro.org" , "santosh.shukla@linaro.org" , "kvm@vger.kernel.org" , "gregkh@linuxfoundation.org" Subject: RE: RFC: (re-)binding the VFIO platform driver to a platform device Thread-Topic: RFC: (re-)binding the VFIO platform driver to a platform device Thread-Index: AQHOvtVyiXjaos/F7ECAilSa5Xx4A5ngRDQAgAAiCgCAAECXgIAAC74AgADT3ICAADSaMIAAAtYAgAADCQCAAB/ggIAACLGAgAACMICAAAU8gIAAIuWAgAE8pICAAAXnAIAABMAAgAAWmACACVE7IA== Date: Wed, 9 Oct 2013 19:02:25 +0000 Message-ID: <9F6FE96B71CF29479FF1CDC8046E15036DDA62@039-SN1MPN1-002.039d.mgd.msft.net> References: <1380738758.12932.43.camel@snotra.buserror.net> <20131002184330.GC5108@cbox> <20131002203735.GA10871@kroah.com> <1380748121.12932.89.camel@snotra.buserror.net> <20131002211631.GA11914@kroah.com> <1380749715.12932.109.camel@snotra.buserror.net> <20131002234009.GA27714@kroah.com> <1380825207.12932.151.camel@snotra.buserror.net> <20131003185434.GA26123@kroah.com> <1380827494.12932.161.camel@snotra.buserror.net> <20131003203226.GB27336@kroah.com> In-Reply-To: <20131003203226.GB27336@kroah.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.82.120.14] MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Have been thinking about this issue some more. As Scott mentioned, 'wildcard' matching for a driver can be fairly done in the platform bus driver. We could add a new flag to the platform driver struct: bus drivers that implement the 'match' function. Regards, Stuart --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 4f8bef3..4d6cf14 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -727,6 +727,10 @@ static int platform_match(struct device *dev, struct device_driver *drv) struct platform_device *pdev = to_platform_device(dev); struct platform_driver *pdrv = to_platform_driver(drv); + /* the driver matches any device */ + if (pdrv->match_any) + return 1; + /* Attempt an OF style match first */ if (of_driver_match_device(dev, drv)) return 1; However, the more problematic issue is that a bus driver has no way to differentiate from an explicit bind request via sysfs and a bind that happened through bus probing. I think something like the new flag in the snippet below would enable the platform bus to support platform drivers that only bind on explicit request: diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 4c289ab..daf6d24 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -201,7 +201,7 @@ static ssize_t bind_store(struct device_driver *drv, const char *buf, int err = -ENODEV; dev = bus_find_device_by_name(bus, NULL, buf); - if (dev && dev->driver == NULL && driver_match_device(drv, dev)) { + if (dev && dev->driver == NULL && driver_match_device(drv, dev, 1)) { if (dev->parent) /* Needed for USB */ device_lock(dev->parent); device_lock(dev); diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 35fa368..bb53785 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -389,7 +389,7 @@ static int __device_attach(struct device_driver *drv, void *data) { struct device *dev = data; - if (!driver_match_device(drv, dev)) + if (!driver_match_device(drv, dev, 0)) return 0; return driver_probe_device(drv, dev); @@ -450,7 +450,7 @@ static int __driver_attach(struct device *dev, void *data) * is an error. */ - if (!driver_match_device(drv, dev)) + if (!driver_match_device(drv, dev, 0)) return 0; if (dev->parent) /* Needed for USB */ diff --git a/drivers/base/base.h b/drivers/base/base.h index 2cbc677..7a15ef3 100644 --- a/drivers/base/base.h +++ b/drivers/base/base.h @@ -114,9 +114,9 @@ extern void driver_detach(struct device_driver *drv); extern int driver_probe_device(struct device_driver *drv, struct device *dev); extern void driver_deferred_probe_del(struct device *dev); static inline int driver_match_device(struct device_driver *drv, - struct device *dev) + struct device *dev, int explicit_bind) { - return drv->bus->match ? drv->bus->match(dev, drv) : 1; + return drv->bus->match ? drv->bus->match(dev, drv, explicit_bind) : 1; } Of, course the above change would need to be propagated to the different