From owner-freebsd-hackers@freebsd.org Tue May 11 15:48:08 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C21C63C902 for ; Tue, 11 May 2021 15:48:08 +0000 (UTC) (envelope-from patrascu.naina14@gmail.com) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Ffj4R2FkDz4Wgj for ; Tue, 11 May 2021 15:48:07 +0000 (UTC) (envelope-from patrascu.naina14@gmail.com) Received: by mail-pl1-x634.google.com with SMTP id p17so11005280plf.12 for ; Tue, 11 May 2021 08:48:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=NVAC9nffN2v9jMiPjFlNew3VwWqx7/J9Y78ailOdn4M=; b=oiPG/nn46ZTtSEm6QdxkJWAGUZz0Cz+ss64DDLZAX7od1/UAdWKDbBWx/J/j7D4HMY kYV0FLB5w6wnFTZUN1ipYViQ0VyvD3yXdZSMsoFXdaOksjDL4S0tmpDxJES3wS8SR/3U 4ExwYRguNQBj4SIh+JbM10z+t+Q3ymPxds5O3EUxVaaTv14mOvOlzr8me/4MP4eK7tk7 cEPUpfV2QWOmrV+JtQIZfYB4zSCgsB6VwppgMofvxMYtRTdEyiNuqn5iD8NUrYgVuKgL qJNwJXz7SHbJO1p/Gf7uDTETLtnIYL5mllyiV05w8jyXXzwogiaOrYyqyawCiAyyp+yx DcUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=NVAC9nffN2v9jMiPjFlNew3VwWqx7/J9Y78ailOdn4M=; b=hYA1aAKwqrb9/vB34YhGzep5qOC61zXIdk96nc/CP/E5yBZYF5JQIH7xWeabLnIkeA v8kS6trxK3ZwN2wujD/i8OWP3j7uEWpXw468AVFn6nZ65A2yq9c0w/gQPF/OOp16EkqJ 0sjs9UpkWy/cKsCdTkXLoxwMF2BI1th8gXmI0s8oMQ3Ae9Izj6XfXCy/YGlhK69H19e7 jwFwkm++CiSrzvqjSA1nA7DV3/mkcaYBlydJ3EM3N49+OzqE5BNv1i1p+q3hlUu9U2AU TvfWPn863D2m2aAifi08EWMehv5w7TIoi1FUHwhBxn+A3wDO28G6JI6eN4KFHrcL/72P Scng== X-Gm-Message-State: AOAM533imlmFG4Bmm1/M2fQxGF3eyMo67ffkEZ4cXmiW8PlIFc4lfINw vnv2F0uTHR6hGecCFAW9rKWFmLh3O8K7kzzHkDKsLccXULRYBg== X-Google-Smtp-Source: ABdhPJyk5wvhFYNCtIrWMrvjrxXTj5bsXPjou5+vi+OOowvJNVU+xw35QNWhtyrks8wzrFx9mSNbmMwBSN3mr2C2HgA= X-Received: by 2002:a17:902:8d98:b029:eb:43c2:d294 with SMTP id v24-20020a1709028d98b02900eb43c2d294mr30655698plo.49.1620748085300; Tue, 11 May 2021 08:48:05 -0700 (PDT) MIME-Version: 1.0 From: Naina Patrascu Date: Tue, 11 May 2021 18:47:54 +0300 Message-ID: Subject: Indexing problem with address number of a USB device To: freebsd-hackers@freebsd.org Cc: lucian_ioan.popescu@stud.acs.upb.ro, Elena Mihailescu X-Rspamd-Queue-Id: 4Ffj4R2FkDz4Wgj X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=oiPG/nn4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of patrascunaina14@gmail.com designates 2607:f8b0:4864:20::634 as permitted sender) smtp.mailfrom=patrascunaina14@gmail.com X-Spamd-Result: default: False [-4.00 / 15.00]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; NEURAL_HAM_SHORT(-1.00)[-0.998]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[2607:f8b0:4864:20::634:from]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; TAGGED_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; SPAMHAUS_ZRD(0.00)[2607:f8b0:4864:20::634:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::634:from]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers]; FREEMAIL_CC(0.00)[stud.acs.upb.ro,gmail.com] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.34 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 May 2021 15:48:08 -0000 Hello, We are working on the USB passthrough functionality for bhyve. We are currently focusing on the passthrough of a USB stick and a USB keyboard. We are facing an indexing problem when trying to assign a USB device to a virtual machine. For example, we have the USB keyboard at busnum=1 and devaddr=2 on the FreeBSD host virtual machine: # usbconfig -d ugen1.2 ugen1.2: at usbus1, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA) We specify to "bhyve" command to pass through the device to a guest virtual machine: -s 30,xhci,1-2 As part of the enumeration process, the host controller executes the internal scan to discover the physical devices and to compare them with the ones assigned with the bhyve command. But the USB device is discovered at bus 1 address 1, and we have to adjust accordingly when parsing the bus-port to match the port number: 04f3:152e 1-1 connecting. 04f3:152e 1-1 belong to this vm. 04F3:152E 1-1 is attached to virtual port 5. We hardcoded when parsing bus-port: port -= 1. When trying to pass through a USB stick, we have to increase the port number to match the one discovered in the internal scan: # usbconfig -d ugen3.2 ugen3.2: at usbus3, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (300mA) 0951:1666 3-3 connecting. 0951:1666 3-3 belong to this vm. 0951:1666 3-3 is attached to virtual port 1. In our last investigation, we discovered that when increasing the number of USB devices on the FreeBSD host vm, the port indexes of the devices discovered by the internal scan, also varies. In function [1] we get the physical devices using libusb library and then we execute the internal scan using function [2]. We get the information about the physical device in function [3], also using libusb library. Can you help us understand where this problem could come from and how to debug it? Thank you! [1] https://github.com/FreeBSD-UPB/freebsd-src/blob/a861e57e10512c0e3406762ffba2249bbd786492/usr.sbin/bhyve/usb_pmapper.c#L121 [2] https://github.com/FreeBSD-UPB/freebsd-src/blob/a861e57e10512c0e3406762ffba2249bbd786492/usr.sbin/bhyve/usb_pmapper.c#L76 [3] https://github.com/FreeBSD-UPB/freebsd-src/blob/a861e57e10512c0e3406762ffba2249bbd786492/usr.sbin/bhyve/usb_pmapper.c#L24 From owner-freebsd-hackers@freebsd.org Wed May 12 19:15:00 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9BA2D6495E1 for ; Wed, 12 May 2021 19:15:00 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (gate2.funkthat.com [208.87.223.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gate2.funkthat.com", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FgPcf6f2Wz3Dcj for ; Wed, 12 May 2021 19:14:58 +0000 (UTC) (envelope-from jmg@gold.funkthat.com) Received: from gold.funkthat.com (localhost [127.0.0.1]) by gold.funkthat.com (8.15.2/8.15.2) with ESMTPS id 14CJEprN053384 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 12 May 2021 12:14:51 -0700 (PDT) (envelope-from jmg@gold.funkthat.com) Received: (from jmg@localhost) by gold.funkthat.com (8.15.2/8.15.2/Submit) id 14CJEmDP053380; Wed, 12 May 2021 12:14:48 -0700 (PDT) (envelope-from jmg) Date: Wed, 12 May 2021 12:14:48 -0700 From: John-Mark Gurney To: Naina Patrascu Cc: freebsd-hackers@freebsd.org, lucian_ioan.popescu@stud.acs.upb.ro, Elena Mihailescu Subject: Re: Indexing problem with address number of a USB device Message-ID: <20210512191448.GK14975@funkthat.com> Mail-Followup-To: Naina Patrascu , freebsd-hackers@freebsd.org, lucian_ioan.popescu@stud.acs.upb.ro, Elena Mihailescu References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 11.3-STABLE amd64 X-PGP-Fingerprint: D87A 235F FB71 1F3F 55B7 ED9B D5FF 5A51 C0AC 3D65 X-Files: The truth is out there X-URL: https://www.funkthat.com/ X-Resume: https://www.funkthat.com/~jmg/resume.html X-TipJar: bitcoin:13Qmb6AeTgQecazTWph4XasEsP7nGRbAPE X-to-the-FBI-CIA-and-NSA: HI! HOW YA DOIN? can i haz chizburger? User-Agent: Mutt/1.6.1 (2016-04-27) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (gold.funkthat.com [127.0.0.1]); Wed, 12 May 2021 12:14:51 -0700 (PDT) X-Rspamd-Queue-Id: 4FgPcf6f2Wz3Dcj X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of jmg@gold.funkthat.com has no SPF policy when checking 208.87.223.18) smtp.mailfrom=jmg@gold.funkthat.com X-Spamd-Result: default: False [-0.22 / 15.00]; FREEMAIL_CC(0.00)[freebsd.org,stud.acs.upb.ro,gmail.com]; TO_DN_SOME(0.00)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FREEMAIL_TO(0.00)[gmail.com]; FORGED_SENDER(0.30)[jmg@funkthat.com,jmg@gold.funkthat.com]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[208.87.223.18:from]; ASN(0.00)[asn:32354, ipnet:208.87.216.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; FROM_NEQ_ENVFROM(0.00)[jmg@funkthat.com,jmg@gold.funkthat.com]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.92)[-0.920]; FREEFALL_USER(0.00)[jmg]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; NEURAL_HAM_LONG(-1.00)[-1.000]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; AUTH_NA(1.00)[]; DMARC_NA(0.00)[funkthat.com]; SPAMHAUS_ZRD(0.00)[208.87.223.18:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_DKIM_NA(0.00)[]; R_SPF_NA(0.00)[no SPF record]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; SUSPICIOUS_RECIPS(1.50)[]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 19:15:00 -0000 Naina Patrascu wrote this message on Tue, May 11, 2021 at 18:47 +0300: > We are working on the USB passthrough functionality for bhyve. We are > currently focusing on the passthrough of a USB stick and a USB keyboard. > > We are facing an indexing problem when trying to assign a USB device to a > virtual machine. > For example, we have the USB keyboard at busnum=1 and devaddr=2 on the > FreeBSD host virtual machine: > > # usbconfig -d ugen1.2 > ugen1.2: at usbus1, cfg=0 md=HOST spd=LOW (1.5Mbps) > pwr=ON (100mA) > > We specify to "bhyve" command to pass through the device to a guest virtual > machine: -s 30,xhci,1-2 > > As part of the enumeration process, the host controller executes the > internal scan to discover the physical devices and to compare them with the > ones assigned with the bhyve command. > But the USB device is discovered at bus 1 address 1, and we have to adjust > accordingly when parsing the bus-port to match the port number: > > 04f3:152e 1-1 connecting. > 04f3:152e 1-1 belong to this vm. > 04F3:152E 1-1 is attached to virtual port 5. > > We hardcoded when parsing bus-port: port -= 1. > When trying to pass through a USB stick, we have to increase the port > number to match the one discovered in the internal scan: > > # usbconfig -d ugen3.2 > ugen3.2: at usbus3, cfg=0 md=HOST spd=HIGH > (480Mbps) pwr=ON (300mA) > > 0951:1666 3-3 connecting. > 0951:1666 3-3 belong to this vm. > 0951:1666 3-3 is attached to virtual port 1. > > In our last investigation, we discovered that when increasing the number of > USB devices on the FreeBSD host vm, the port indexes of the devices > discovered by the internal scan, also varies. > > In function [1] we get the physical devices using libusb library and then > we execute the internal scan using function [2]. We get the information > about the physical device in function [3], also using libusb library. > > Can you help us understand where this problem could come from and how to > debug it? Yes, the ugen named does not map to port naming. I ran across this when I did the work to make serial devices consistent based upon the port number. The review for that work is here: https://reviews.freebsd.org/D21886#554613 The device address is a different enumeration from the port address information. The script linked in the review creates a mapping from the device name to the proper port number mapping. To see this, you can look at devinfo -v, and look at the port value vs the devaddr (device address assigned at enumeration). Hope this helps. -- John-Mark Gurney Voice: +1 415 225 5579 "All that I will do, has been done, All that I have, has not." From owner-freebsd-hackers@freebsd.org Wed May 12 19:24:44 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45FC064A1AF for ; Wed, 12 May 2021 19:24:44 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FgPqv2Nm6z3FmG for ; Wed, 12 May 2021 19:24:42 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id BBEB2260556; Wed, 12 May 2021 21:24:34 +0200 (CEST) Subject: Re: Indexing problem with address number of a USB device To: Naina Patrascu , freebsd-hackers@freebsd.org, lucian_ioan.popescu@stud.acs.upb.ro, Elena Mihailescu References: <20210512191448.GK14975@funkthat.com> From: Hans Petter Selasky Message-ID: Date: Wed, 12 May 2021 21:23:15 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210512191448.GK14975@funkthat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4FgPqv2Nm6z3FmG X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-1.80 / 15.00]; RCVD_TLS_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; ARC_NA(0.00)[]; DMARC_NA(0.00)[selasky.org]; SPAMHAUS_ZRD(0.00)[2a01:4f8:c17:6c4b::2:from:127.0.2.255]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[2a01:4f8:c17:6c4b::2:from]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; FREEMAIL_TO(0.00)[gmail.com,freebsd.org,stud.acs.upb.ro]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/32, country:DE]; RCVD_COUNT_TWO(0.00)[2]; MAILMAN_DEST(0.00)[freebsd-hackers]; SUSPICIOUS_RECIPS(1.50)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 May 2021 19:24:44 -0000 On 5/12/21 9:14 PM, John-Mark Gurney wrote: > Naina Patrascu wrote this message on Tue, May 11, 2021 at 18:47 +0300: >> We are working on the USB passthrough functionality for bhyve. We are >> currently focusing on the passthrough of a USB stick and a USB keyboard. >> >> We are facing an indexing problem when trying to assign a USB device to a >> virtual machine. >> For example, we have the USB keyboard at busnum=1 and devaddr=2 on the >> FreeBSD host virtual machine: >> >> # usbconfig -d ugen1.2 >> ugen1.2: at usbus1, cfg=0 md=HOST spd=LOW (1.5Mbps) >> pwr=ON (100mA) >> >> We specify to "bhyve" command to pass through the device to a guest virtual >> machine: -s 30,xhci,1-2 >> >> As part of the enumeration process, the host controller executes the >> internal scan to discover the physical devices and to compare them with the >> ones assigned with the bhyve command. >> But the USB device is discovered at bus 1 address 1, and we have to adjust >> accordingly when parsing the bus-port to match the port number: >> >> 04f3:152e 1-1 connecting. >> 04f3:152e 1-1 belong to this vm. >> 04F3:152E 1-1 is attached to virtual port 5. >> >> We hardcoded when parsing bus-port: port -= 1. >> When trying to pass through a USB stick, we have to increase the port >> number to match the one discovered in the internal scan: >> >> # usbconfig -d ugen3.2 >> ugen3.2: at usbus3, cfg=0 md=HOST spd=HIGH >> (480Mbps) pwr=ON (300mA) >> >> 0951:1666 3-3 connecting. >> 0951:1666 3-3 belong to this vm. >> 0951:1666 3-3 is attached to virtual port 1. >> >> In our last investigation, we discovered that when increasing the number of >> USB devices on the FreeBSD host vm, the port indexes of the devices >> discovered by the internal scan, also varies. >> >> In function [1] we get the physical devices using libusb library and then >> we execute the internal scan using function [2]. We get the information >> about the physical device in function [3], also using libusb library. >> >> Can you help us understand where this problem could come from and how to >> debug it? > > Yes, the ugen named does not map to port naming. I ran across this when > I did the work to make serial devices consistent based upon the port > number. The review for that work is here: > https://reviews.freebsd.org/D21886#554613 > > The device address is a different enumeration from the port address > information. The script linked in the review creates a mapping from > the device name to the proper port number mapping. > > To see this, you can look at devinfo -v, and look at the port value > vs the devaddr (device address assigned at enumeration). > > Hope this helps. > > Hi, LibUSB in FreeBSD has a helper function to compute the full port topology: libusb_get_port_numbers() and: libusb20_dev_get_port_path() --HPS From owner-freebsd-hackers@freebsd.org Sat May 15 17:29:43 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EB76964BA02 for ; Sat, 15 May 2021 17:29:43 +0000 (UTC) (envelope-from matheus@eternamente.info) Received: from hobbes.arroway.org (hobbes.arroway.org [173.199.118.77]) by mx1.freebsd.org (Postfix) with ESMTP id 4FjC7q18q3z599l for ; Sat, 15 May 2021 17:29:42 +0000 (UTC) (envelope-from matheus@eternamente.info) Received: from [10.1.7.11] (unknown [187.61.214.250]) by hobbes.arroway.org (Postfix) with ESMTPA id 96F6514D20F for ; Sat, 15 May 2021 14:29:34 -0300 (-03) Received: from 10.1.4.100 (SquirrelMail authenticated user matheus) by 10.1.7.11 with HTTP; Sat, 15 May 2021 14:29:35 -0300 Message-ID: In-Reply-To: References: <36c9234e-4c1e-b7db-7905-c67e68c87bf6@m5p.com> <107fa9e2-8096-7bc5-b53d-8de8956899ac@selasky.org> Date: Sat, 15 May 2021 14:29:35 -0300 Subject: Re: amdgpu.ko crashes on Radeon Vega From: "Nenhum_de_Nos" To: freebsd-hackers@freebsd.org User-Agent: SquirrelMail/1.4.23 [SVN] MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Rspamd-Queue-Id: 4FjC7q18q3z599l X-Spamd-Bar: + Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of matheus@eternamente.info has no SPF policy when checking 173.199.118.77) smtp.mailfrom=matheus@eternamente.info X-Spamd-Result: default: False [1.82 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.02)[-0.021]; HAS_X_PRIO_THREE(0.00)[3]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RBL_DBL_DONT_QUERY_IPS(0.00)[173.199.118.77:from]; R_MIXED_CHARSET(0.68)[]; ASN(0.00)[asn:20473, ipnet:173.199.116.0/22, country:US]; R_DKIM_NA(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.93)[-0.925]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.91)[-0.908]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[eternamente.info]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; AUTH_NA(1.00)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[173.199.118.77:from:127.0.2.255]; R_SPF_NA(0.00)[no SPF record]; MID_BARE_IP(2.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 17:29:44 -0000 On Sat, May 8, 2021 19:51, George Mitchell wrote: > On 5/8/21 6:38 PM, Hans Petter Selasky wrote: >> On 5/9/21 12:34 AM, George Mitchell wrote: >>> I have (per dmesg): AMD Ryzen 3 2200G with Radeon Vega Graphics. >>> (pciconf -lv reports: >>> vgapci0@pci0:6:0:0:     class=0x030000 card=0xd0001458 >>> chip=0x15dd1002 >>> rev=0xc8 hdr=0x00 >>>      vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]' >>>      device     = 'Raven Ridge [Radeon Vega Series / Radeon >>> Vega Mobile >>> Series]') >>> I am running FreeBSD 12.2-RELEASE-p6 r369558. >>> I built amdgpu.ko from drm-fbsd12.0-kmod-4.16.g20201016_1. >>> When I boot single-user, with only kernel, vboxdrv.ko, and sem.ko >>> loaded, and I type "kldload amdgpu", I get about six or seven lines >>> of output, ending with "pci i/o bar is not found."  After a couple >>> more seconds, the screen goes blank and the machine is as frozen as >>> can be, and I have to cycle power to recover.  I've tried all four >>> combinations of hw.vga.textmode and hw.syscons.disable, but it >>> crashes each time.  >>> Help!                              -- >>> George >>> >> >> Hi, >> >> If you hook up a USB serial adapter and redirect the console to it >> using: >> >> hw.usb.ucom.cons_baud: 9600 >> hw.usb.ucom.cons_subunit: 0 >> hw.usb.ucom.cons_unit: -1 >> >> >> Then you might get the prints from the panic which is happening. Also >> try to build a kernel with debugging support to get an automatic core >> dump. >> >> It is also recommended to try 13-stable. The DRM code there is much >> newer. >> >> --HPS > > Thanks -- trying 13-stable sounds simpler, but for the moment I may > just stick with VESA mode ... -- George George, I'm about to try this on Ryzen 3400G here, where can I find this step by step to try to repeat what you did? My box has just basic FreeBSD install, cause I couldn't use Xorg at all. When I finish something on another OS I will try this. Thanks, matheus -- "We will call you Cygnus, the God of balance you shall be." From owner-freebsd-hackers@freebsd.org Sat May 15 17:50:33 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4B25F64C155 for ; Sat, 15 May 2021 17:50:33 +0000 (UTC) (envelope-from george+freebsd@m5p.com) Received: from mailhost.m5p.com (mailhost.m5p.com [74.104.188.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "m5p.com", Issuer "R3" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjCbr3Sbcz3DKl for ; Sat, 15 May 2021 17:50:32 +0000 (UTC) (envelope-from george+freebsd@m5p.com) Received: from [IPv6:2001:470:1f07:15ff::26] (court.m5p.com [IPv6:2001:470:1f07:15ff:0:0:0:26]) (authenticated bits=0) by mailhost.m5p.com (8.16.1/8.15.2) with ESMTPSA id 14FHoP4a083094 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Sat, 15 May 2021 13:50:30 -0400 (EDT) (envelope-from george+freebsd@m5p.com) Subject: Re: amdgpu.ko crashes on Radeon Vega To: freebsd-hackers@freebsd.org References: <36c9234e-4c1e-b7db-7905-c67e68c87bf6@m5p.com> <107fa9e2-8096-7bc5-b53d-8de8956899ac@selasky.org> From: George Mitchell Message-ID: <203dd4d3-bac3-178c-15b2-38344a39ae42@m5p.com> Date: Sat, 15 May 2021 13:50:25 -0400 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:78.0) Gecko/20100101 Thunderbird/78.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eMZwvPcgpxR8MbGyeW7ugUwJB8PLSrpNR" X-Spam-Status: No, score=0.2 required=10.0 tests=HELO_MISC_IP, HELO_NO_DOMAIN, NICE_REPLY_A autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on mattapan.m5p.com X-Rspamd-Queue-Id: 4FjCbr3Sbcz3DKl X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of george@m5p.com designates 74.104.188.4 as permitted sender) smtp.mailfrom=george@m5p.com X-Spamd-Result: default: False [-3.42 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+a:c]; HAS_ATTACHMENT(0.00)[]; TO_DN_NONE(0.00)[]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:~]; RBL_DBL_DONT_QUERY_IPS(0.00)[74.104.188.4:from]; ASN(0.00)[asn:701, ipnet:74.104.0.0/16, country:US]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[freebsd]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[m5p.com]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[74.104.188.4:from:127.0.2.255]; NEURAL_SPAM_SHORT(0.98)[0.981]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[freebsd-hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 17:50:33 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eMZwvPcgpxR8MbGyeW7ugUwJB8PLSrpNR Content-Type: multipart/mixed; boundary="wAy9yeCuIxYlGbfupXkmCbvT0BD1sRGj5"; protected-headers="v1" From: George Mitchell To: freebsd-hackers@freebsd.org Message-ID: <203dd4d3-bac3-178c-15b2-38344a39ae42@m5p.com> Subject: Re: amdgpu.ko crashes on Radeon Vega References: <36c9234e-4c1e-b7db-7905-c67e68c87bf6@m5p.com> <107fa9e2-8096-7bc5-b53d-8de8956899ac@selasky.org> In-Reply-To: --wAy9yeCuIxYlGbfupXkmCbvT0BD1sRGj5 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable On 5/15/21 1:29 PM, Nenhum_de_Nos wrote: >[...] > George, >=20 > I'm about to try this on Ryzen 3400G here, where can I find this step b= y > step to try to repeat what you did? My box has just basic FreeBSD insta= ll, > cause I couldn't use Xorg at all. When I finish something on another OS=20 I > will try this. >=20 > Thanks, >=20 > matheus >=20 >=20 1. Install FreeBSD 12. 2. Install drm-fbsd12.0-kmod. 3. Boot into single-user mode. 4. Type "kldload amdgpu". When you say you can't use Xorg at all, does that mean VESA mode is not working? -- George --wAy9yeCuIxYlGbfupXkmCbvT0BD1sRGj5-- --eMZwvPcgpxR8MbGyeW7ugUwJB8PLSrpNR Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsF5BAABCAAjFiEENdM4ZHktsJW5kKZXwRES3m+p4fkFAmCgCeEFAwAAAAAACgkQwRES3m+p4fmo aQ/+IduzUTWStyKQBF6GhHYzIn6jSqgRqwmbG+26aPI/cx5DzzeVYzLVzZ7YqFAyZb12GC930j1v 43gJ3gzSQ814sxaEyoX2sBt4YZKGdJM8B1fWCY/Bi+oh1bgTSFwUkV7OaN1LzZhFQINvm8b+aliE lWyZqGeID9RWNX1p2j7tpFLdrOEbXdwOhpY8nz2lOYN4N7SaYxZzELZeHfdsadx8K2/g3UWs4knQ fAhYPdaCv6JN0c5uyhRaoh+NmwFaCXafhRY819frAHb6g2lFxROqrI8Q9ms6C+E7JgLCxk4Lm7FG /abg8rWSdnjdelC6aNinHsYkWM1UzN4UnWi/zC59V+c1MXwW0hQKuIHdlxJDwdcW/q173kyZ9Yzt 4WGmG/bbXNfN5b3WS4EKW+/zsd1u4pfnx+hNAzvBbT+0I241yWt4vqo1VUwL/FngLrOsPdhYnWuD Ui2Zys1GdrxNwytJcTuKfuQv/GKY0kcE91+ubGeCU3Uq3yj5jPFRDHPY8rt1L05aEEe+HsRzYEj9 d1ISXiTbjo8xwSousMkScZWsyIHFrrb0psex5TmtWM/cfckX2MbJxzNuVIdur0IkAgWrAbH7/4sP bgRxHXOFEpVDlpEAJxQt9IhVAxAKZAZzOiKn/NFwXf4nmdV/s6iShQwo5pKuZ/FEtB0cpVpMlRav n5c= =iT0d -----END PGP SIGNATURE----- --eMZwvPcgpxR8MbGyeW7ugUwJB8PLSrpNR-- From owner-freebsd-hackers@freebsd.org Sat May 15 20:14:10 2021 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 9C1DC64E9F2 for ; Sat, 15 May 2021 20:14:10 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4FjGnZ38zZz3mf7 for ; Sat, 15 May 2021 20:14:10 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: by mailman.nyi.freebsd.org (Postfix) id 6AC6464ECB7; Sat, 15 May 2021 20:14:10 +0000 (UTC) Delivered-To: hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6A8BB64E968 for ; Sat, 15 May 2021 20:14:10 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4FjGnY3Fvxz3mbR for ; Sat, 15 May 2021 20:14:08 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (v-critter.freebsd.dk [192.168.55.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by phk.freebsd.dk (Postfix) with ESMTPS id B095289290 for ; Sat, 15 May 2021 20:14:01 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.16.1/8.16.1) with ESMTPS id 14FKE1FK012058 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO) for ; Sat, 15 May 2021 20:14:01 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.16.1/8.16.1/Submit) id 14FKE11C012057; Sat, 15 May 2021 20:14:01 GMT (envelope-from phk) To: hackers@freebsd.org Subject: patch: make i2c(8) usable for scripting From: Poul-Henning Kamp MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12055.1621109641.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Sat, 15 May 2021 20:14:01 +0000 Message-ID: <12056.1621109641@critter.freebsd.dk> X-Rspamd-Queue-Id: 4FjGnY3Fvxz3mbR X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of phk@critter.freebsd.dk designates 130.225.244.222 as permitted sender) smtp.mailfrom=phk@critter.freebsd.dk X-Spamd-Result: default: False [-2.99 / 15.00]; RCVD_TLS_ALL(0.00)[]; ARC_NA(0.00)[]; FREEFALL_USER(0.00)[phk]; FROM_HAS_DN(0.00)[]; RBL_DBL_DONT_QUERY_IPS(0.00)[130.225.244.222:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[hackers@freebsd.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; SPAMHAUS_ZRD(0.00)[130.225.244.222:from:127.0.2.255]; RCVD_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[freebsd.dk]; NEURAL_HAM_LONG(-0.99)[-0.995]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; FORGED_SENDER(0.30)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:1835, ipnet:130.225.0.0/16, country:EU]; FROM_NEQ_ENVFROM(0.00)[phk@phk.freebsd.dk,phk@critter.freebsd.dk]; MAILMAN_DEST(0.00)[hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Technical discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 May 2021 20:14:10 -0000 Here is a patch to make i2c(8) much more usable from scripts and scripting= languages: http://phk.freebsd.dk/misc/i2c.patch That patch applies only to -current, I had to give i2c.c a good wash first= . If you are not -current, it will be easier to fetch: http://phk.freebsd.dk/misc/i2c.c http://phk.freebsd.dk/misc/i2c.8 The patch adds two new modes "-i" and "-iv" "-i" mode is intended to use from hardware-initialization scripts etc, and= treats any error as fatal. "-iv" on the other hand treats no error as fatal, and is targeted more at = python classes, continous data collection etc. In both cases i2c(8) takes (argv/stdin) commands like: r 0 0x50 16BE 24 8 or w 0 0x50 16BE 24 48656c6c 6f20576f 726c6421 0a (see manpage for details) These modes always use the I2CRDWR ioctl, which works on all the hardware = I have. The /dev/iic%d filedescriptor is opened and closed for every single command, in the hope that it will aid multiple separate programs sharing I2C busses. I have not actually tried that yet, so it may need more work (exclusive opens etc.). Comments & inputs welcome... Poul-Henning -- = Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence= .