From owner-freebsd-hackers@freebsd.org Fri Sep 11 02:38:07 2015 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3666A01A4A for ; Fri, 11 Sep 2015 02:38:07 +0000 (UTC) (envelope-from rpokala@panasas.com) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0079.outbound.protection.outlook.com [207.46.100.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 62D7F1A0B; Fri, 11 Sep 2015 02:38:06 +0000 (UTC) (envelope-from rpokala@panasas.com) Received: from CY1PR08MB1803.namprd08.prod.outlook.com (10.162.218.25) by CY1PR08MB1804.namprd08.prod.outlook.com (10.162.218.26) with Microsoft SMTP Server (TLS) id 15.1.262.15; Fri, 11 Sep 2015 02:37:59 +0000 Received: from CY1PR08MB1803.namprd08.prod.outlook.com ([10.162.218.25]) by CY1PR08MB1803.namprd08.prod.outlook.com ([10.162.218.25]) with mapi id 15.01.0262.011; Fri, 11 Sep 2015 02:37:59 +0000 From: "Pokala, Ravi" To: John Baldwin , "freebsd-hackers@freebsd.org" Subject: Re: bus_.*_resource() and rid Thread-Topic: bus_.*_resource() and rid Thread-Index: AQHQ6qhpmlcbMDBrSUWapu14ripoSp42SMsAgAAUkAA= Date: Fri, 11 Sep 2015 02:37:58 +0000 Message-ID: References: <1685918.WyYIclYTSg@ralph.baldwin.cx> In-Reply-To: <1685918.WyYIclYTSg@ralph.baldwin.cx> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: user-agent: Microsoft-MacOutlook/14.5.4.150722 authentication-results: spf=none (sender IP is ) smtp.mailfrom=rpokala@panasas.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [24.90.136.147] x-microsoft-exchange-diagnostics: 1; CY1PR08MB1804; 5:l3ti8ipE91ARjYEUIikM/HARtUVoVj2L+LPygtCiPPL0nnoiMztPkfUU4wq74nNuyl31uzVdr3alfeDeXVXPxG5NegPmhAOrTLZVe9jeQAx/C6EMSC1WR1UNo80deww2ZoV8BTjTlQVZXbo+/mHSnw==; 24:Kdhvl7ROGXxHoPzHgNv4F9/bhj+ChhoZL2WO6We5F5mtgV1dD7GB5p90XOUb4bVb2xvUEJ1pGjQjIDtmSi5LY58I+MaGRnwFEsDdcMYU9/0=; 20:LmpKX5kdeYC0hdgzHJRkhKe/fiTelxh5+bz+O4CxDjZPhTefg5F3RnM6L82OiZNGAC8aH9SCXp7YD7d8hSFimA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR08MB1804; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:CY1PR08MB1804; BCL:0; PCL:0; RULEID:; SRVR:CY1PR08MB1804; x-forefront-prvs: 06968FD8C4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(13464003)(189002)(199003)(377424004)(77156002)(2501003)(2900100001)(450100001)(107886002)(87936001)(92566002)(101416001)(62966003)(11100500001)(10400500002)(2950100001)(102836002)(50986999)(54356999)(36756003)(5002640100001)(77096005)(97736004)(4001540100001)(5001770100001)(5001860100001)(189998001)(99286002)(68736005)(86362001)(122556002)(46102003)(5001830100001)(5001960100002)(105586002)(19580405001)(81156007)(5004730100002)(106356001)(40100003)(106116001)(5890100001)(83506001)(5007970100001)(64706001)(19580395003)(76176999)(4001350100001)(66066001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR08MB1804; H:CY1PR08MB1803.namprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: panasas.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <4A39DBCE8CCEFA469C7B611D917EB2D1@namprd08.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: panasas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Sep 2015 02:37:58.8785 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: acf01c9d-c699-42af-bdbb-44bf582e60b0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR08MB1804 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 11 Sep 2015 02:38:07 -0000 -----Original Message----- From: John Baldwin Date: 2015-09-10, Thursday at 17:24 To: "freebsd-hackers@freebsd.org" Cc: Ravi Pokala Subject: Re: bus_.*_resource() and rid >Each bus decides how to manage RIDs. For PCI devices, RIDs are the >address of the corresponding BAR for memory and I/O port resources and >follow a different convention for interrupts (0 =3D=3D INTx, 1...N =3D=3D >MSI/MSI-X). For ISA devices (and ACPI) RIDs are 0...N. If a device is >enumerated via the firmware (e.g. ACPI DSDT entry with _CRS or PNPBIOS >data for non-ACPI) then the firmware assigned resources are set for you >by the parent bus and start at 0 (if you have two I/O port resources >you'd have the second one at rid 1). I see the address ranges w/ `devinfo -r', but they don't list RIDs. >If you are doing this on the LPC, then that it is actually a PCI device, >and I don't know if the PCI bus is really going to let you create a rid >at 0 via bus_set_resource(). Hmm, it should, but it's kind of a bit >hacky. It might be somewhat cleaner if instead you treat this as an ISA >device that is a child of isa0 below the LPC device. You can use an >identify routine that looks at the grandparent isab0 device and then >allocates this. My understanding was that the *only* way to treat devices hanging off the LPC was as an ISA device, so that's what I've been doing. That is, the LPC controller is a transparent bridge to allow ISA devices to connect to modern systems. (In several cases, the LPC controller also has some BARs which point at integrated ISA devices, like GPIO controllers, but that's beside the point.) >However, a rid of 0 "should" work. You can check the resource list of >the device in kgdb to see if there's a valid resource entry for rid 0. >You could also try calling bus_get_resource() in your attach routine to >see if the bus_set_resource() "worked". I'll look into bus_get_resource(). Oh, look - there's no manpage (share/man/man9/bus_get_resource.9 does not exist, despite being a "see also" entry in bus_set_resource.9). :-S -Ravi >--=20 >John Baldwin