From owner-svn-src-head@freebsd.org Tue Jul 21 16:51:41 2015 Return-Path: Delivered-To: svn-src-head@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 E491E9A7E4A for ; Tue, 21 Jul 2015 16:51:41 +0000 (UTC) (envelope-from zbb@semihalf.com) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5839A1EF2 for ; Tue, 21 Jul 2015 16:51:41 +0000 (UTC) (envelope-from zbb@semihalf.com) Received: by wibud3 with SMTP id ud3so134236772wib.0 for ; Tue, 21 Jul 2015 09:51:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=sCvnUK8Ay1AjMgRSwKtwNqLIxF5L5m/r5hvriYVel7c=; b=Uwu/NSgw9BOPnZPh7sl0ZrncIq/rxwSlSMG5TtbDl+T20FG517kOvuKhB7SeejDg2K jEqFknY36hdWdCd6V/DG14eqxGXYYdu4sbaDK7YC3DBF/uZmiJNC1mNuFN3HsDAxjGgZ PNdAiyb0G+27sN20YYH79UXh1Iw3iYc6x1miI3Gr2GE89p5t9RZEnepBEDLzSTkvlqM4 SLakWlKebtDE2rfx18+mU2rx72RAEhO+BY91vDIGcwYXGRTw986pHwJycwnjfTtftFG+ 3fdsHKd2orUpU3Eoq9YbUPvKE99DO6ZbR5CeNtiRxTVOdREPwStyRCZS3FC0UqCQHrho hRFA== X-Gm-Message-State: ALoCoQlOtERxvhPw4TlUPXps0+SPJnjl9pELW5m6SQSrtlTvWSC9rs8rCuCqTVn5I+5UqEctN/oJ X-Received: by 10.180.74.162 with SMTP id u2mr34578056wiv.0.1437497493082; Tue, 21 Jul 2015 09:51:33 -0700 (PDT) MIME-Version: 1.0 Received: by 10.180.75.12 with HTTP; Tue, 21 Jul 2015 09:51:13 -0700 (PDT) In-Reply-To: <90C4DA24-6770-4DB5-AF87-20CB8E812657@bsdimp.com> References: <201507211447.t6LElO3r098030@repo.freebsd.org> <20150721160145.65c9798b@bender> <90C4DA24-6770-4DB5-AF87-20CB8E812657@bsdimp.com> From: Zbigniew Bodek Date: Tue, 21 Jul 2015 18:51:13 +0200 Message-ID: Subject: Re: svn commit: r285752 - in head/sys: arm64/arm64 dev/pci To: Warner Losh Cc: Andrew Turner , Zbigniew Bodek , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Content-Type: multipart/mixed; boundary=f46d043c07a271152b051b657786 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2015 16:51:42 -0000 --f46d043c07a271152b051b657786 Content-Type: text/plain; charset=UTF-8 Hello Warner, Do you think this will do the trick (please check out the attachment)? Best regards zbb 2015-07-21 18:24 GMT+02:00 Warner Losh : > > > Hi Zbigniew, > > This is a great brief explanation. Perhaps a one or two line comment > to this effect would be useful for others trying to figure it out later? > > Warner > >> On Jul 21, 2015, at 10:02 AM, Zbigniew Bodek wrote: >> >> Hello Andrew, >> >> Please check in-line. >> >> Best regards >> zbb >> >> 2015-07-21 17:01 GMT+02:00 Andrew Turner : >>> On Tue, 21 Jul 2015 14:47:24 +0000 (UTC) >>> Zbigniew Bodek wrote: >>> >>>> Author: zbb >>>> Date: Tue Jul 21 14:47:23 2015 >>>> New Revision: 285752 >>>> URL: https://svnweb.freebsd.org/changeset/base/285752 >>>> >>>> Log: >>>> Add support for vendor specific function for PCI devid acquisition >>>> in ITS >>>> It is possible that some HW will use different PCI devids, >>>> hence allow to replace the default domain:bus:slot:func schema >>>> by implementing and registering custom function. >>>> >>>> Obtained from: Semihalf >>>> Sponsored by: The FreeBSD Foundation >>>> Differential Revision: https://reviews.freebsd.org/D3118 >>>> >>>> Modified: >>>> head/sys/arm64/arm64/gic_v3_its.c >>>> head/sys/arm64/arm64/gic_v3_var.h >>>> head/sys/dev/pci/pcireg.h >>>> >>>> Modified: head/sys/arm64/arm64/gic_v3_its.c >>>> ============================================================================== >>>> --- head/sys/arm64/arm64/gic_v3_its.c Tue Jul 21 14:39:34 >>>> 2015 (r285751) +++ head/sys/arm64/arm64/gic_v3_its.c >>>> Tue Jul 21 14:47:23 2015 (r285752) @@ -44,6 +44,7 @@ >>>> __FBSDID("$FreeBSD$"); #include >>>> #include >>>> >>>> +#include >>>> #include >>>> >>>> #include >>>> @@ -89,6 +90,7 @@ static void its_free_tables(struct gic_v >>>> static void its_init_commandq(struct gic_v3_its_softc *); >>>> static int its_init_cpu(struct gic_v3_its_softc *); >>>> static void its_init_cpu_collection(struct gic_v3_its_softc *); >>>> +static uint32_t its_get_devid(device_t); >>>> >>>> static int its_cmd_send(struct gic_v3_its_softc *, struct >>>> its_cmd_desc *); >>>> @@ -133,6 +135,23 @@ const char *its_ptab_type[] = { >>>> [GITS_BASER_TYPE_RES7] = "Reserved (7)", >>>> }; >>>> >>>> +/* >>>> + * Vendor specific quirks. >>>> + * One needs to add appropriate entry to its_quirks[] >>>> + * table if the imlementation varies from the generic ARM ITS. >>>> + */ >>>> + >>>> +/* Cavium ThunderX PCI devid acquire function */ >>>> +static uint32_t its_get_devid_thunder(device_t); >>>> + >>>> +static const struct its_quirks its_quirks[] = { >>>> + { >>>> + .cpuid = CPU_ID_RAW(CPU_IMPL_CAVIUM, >>>> CPU_PART_THUNDER, 0, 0), >>>> + .cpuid_mask = CPU_IMPL_MASK | CPU_PART_MASK, >>>> + .devid_func = its_get_devid_thunder, >>>> + }, >>>> +}; >>>> + >>>> static struct gic_v3_its_softc *its_sc; >>>> >>>> #define gic_its_read(sc, len, reg) \ >>>> @@ -1300,7 +1319,7 @@ its_device_alloc_locked(struct gic_v3_it >>>> if (newdev != NULL) >>>> return (newdev); >>>> >>>> - devid = PCI_DEVID(pci_dev); >>>> + devid = its_get_devid(pci_dev); >>>> >>>> /* There was no previously created device. Create one now */ >>>> newdev = malloc(sizeof(*newdev), M_GIC_V3_ITS, (M_WAITOK | >>>> M_ZERO)); @@ -1353,6 +1372,73 @@ its_device_asign_lpi_locked(struct >>>> gic_v its_dev->lpis.lpi_free); >>>> its_dev->lpis.lpi_free--; >>>> } >>>> + >>>> +/* >>>> + * ITS quirks. >>>> + * Add vendor specific PCI devid function here. >>>> + */ >>>> +static uint32_t >>>> +its_get_devid_thunder(device_t pci_dev) >>>> +{ >>>> + int bsf; >>>> + int pem; >>>> + uint32_t bus; >>>> + >>>> + bus = pci_get_bus(pci_dev); >>>> + >>>> + bsf = PCI_RID(pci_get_bus(pci_dev), pci_get_slot(pci_dev), >>>> + pci_get_function(pci_dev)); >>>> + >>>> + /* ECAM is on bus=0 */ >>>> + if (bus == 0) { >>>> + return ((pci_get_domain(pci_dev) << >>>> PCI_RID_DOMAIN_SHIFT) | >>>> + bsf); >>>> + /* PEM otherwise */ >>>> + } else { >>>> + /* PEM number is equal to domain */ >>>> + pem = pci_get_domain(pci_dev); >>> >>> But what is a PEM number? >> >> PEM == PCI-E MAC. >> This is the number of root complex. >> >>> >>>> + >>>> + /* Hardcode appropriate PEM numbers */ >>>> + if (pem < 3 ) >>>> + return ((0x1 << PCI_RID_DOMAIN_SHIFT) | bsf); >>>> + >>>> + if (pem < 6 ) >>>> + return ((0x3 << PCI_RID_DOMAIN_SHIFT) | bsf); >>>> + >>>> + if (pem < 9 ) >>>> + return ((0x9 << PCI_RID_DOMAIN_SHIFT) | bsf); >>>> + >>>> + if (pem < 12 ) >>>> + return ((0xB << PCI_RID_DOMAIN_SHIFT) | bsf); >>> >>> What do these magic numbers mean? >> >> This is a domain portion of PCI device ID passed by the HW along with >> the transaction to memory. >> In that case the methodology differs from the genuine (default in this >> driver) ARM implementation and it is Thunder-specific. >> >>> >>>> + } >>>> + >>>> + return (0); >>>> +} >>>> + >>> >>> Andrew >>> _______________________________________________ >>> svn-src-all@freebsd.org mailing list >>> http://lists.freebsd.org/mailman/listinfo/svn-src-all >>> To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > --f46d043c07a271152b051b657786 Content-Type: text/plain; charset=US-ASCII; name="its_comment.diff" Content-Disposition: attachment; filename="its_comment.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_icdkt5wd1 ZGlmZiAtLWdpdCBhL3N5cy9hcm02NC9hcm02NC9naWNfdjNfaXRzLmMgYi9zeXMvYXJtNjQvYXJt NjQvZ2ljX3YzX2l0cy5jCmluZGV4IDI2OTdjN2QuLjM1YTc2OTYgMTAwNjQ0Ci0tLSBhL3N5cy9h cm02NC9hcm02NC9naWNfdjNfaXRzLmMKKysrIGIvc3lzL2FybTY0L2FybTY0L2dpY192M19pdHMu YwpAQCAtMTQyMywxMCArMTQyMywxNCBAQCBpdHNfZ2V0X2RldmlkX3RodW5kZXIoZGV2aWNlX3Qg cGNpX2RldikKIAkJICAgIGJzZik7CiAJLyogUEVNIG90aGVyd2lzZSAqLwogCX0gZWxzZSB7Ci0J CS8qIFBFTSBudW1iZXIgaXMgZXF1YWwgdG8gZG9tYWluICovCisJCS8qIFBFTSAoUENJZSBNQUMv cm9vdCBjb21wbGV4KSBudW1iZXIgaXMgZXF1YWwgdG8gZG9tYWluICovCiAJCXBlbSA9IHBjaV9n ZXRfZG9tYWluKHBjaV9kZXYpOwogCi0JCS8qIEhhcmRjb2RlIGFwcHJvcHJpYXRlIFBFTSBudW1i ZXJzICovCisJCS8qCisJCSAqIFNldCBhcHByb3ByaWF0ZSBkZXZpY2UgSUQgKHBhc3NlZCBieSB0 aGUgSFcgYWxvbmcgd2l0aAorCQkgKiB0aGUgdHJhbnNhY3Rpb24gdG8gbWVtb3J5KSBmb3IgZGlm ZmVyZW50IHJvb3QgY29tcGxleAorCQkgKiBudW1iZXJzIHVzaW5nIGhhcmQtY29kZWQgZG9tYWlu IHBvcnRpb24gZm9yIGVhY2ggZ3JvdXAuCisJCSAqLwogCQlpZiAocGVtIDwgMyApCiAJCQlyZXR1 cm4gKCgweDEgPDwgUENJX1JJRF9ET01BSU5fU0hJRlQpIHwgYnNmKTsKIAo= --f46d043c07a271152b051b657786--