From owner-freebsd-usb@freebsd.org Thu Jan 3 11:35:18 2019 Return-Path: Delivered-To: freebsd-usb@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3789F1425A85 for ; Thu, 3 Jan 2019 11:35:18 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from ms-10.1blu.de (ms-10.1blu.de [178.254.4.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1927A70E6E for ; Thu, 3 Jan 2019 11:35:16 +0000 (UTC) (envelope-from guru@unixarea.de) Received: from [89.204.135.249] (helo=localhost.unixarea.de) by ms-10.1blu.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.86_2) (envelope-from ) id 1gf1HO-0001zy-4r; Thu, 03 Jan 2019 12:35:14 +0100 Received: from localhost.my.domain (localhost [127.0.0.1]) by localhost.unixarea.de (8.15.2/8.14.9) with ESMTPS id x03BZCQ0002637 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 3 Jan 2019 12:35:12 +0100 (CET) (envelope-from guru@unixarea.de) Received: (from guru@localhost) by localhost.my.domain (8.15.2/8.14.9/Submit) id x03BZCUF002636; Thu, 3 Jan 2019 12:35:12 +0100 (CET) (envelope-from guru@unixarea.de) X-Authentication-Warning: localhost.my.domain: guru set sender to guru@unixarea.de using -f Date: Thu, 3 Jan 2019 12:35:12 +0100 From: Matthias Apitz To: Hans Petter Selasky Cc: freebsd-usb@freebsd.org Subject: Re: r342378: usbconfig takes 3-5 minutes to read the bus Message-ID: <20190103113512.GA2547@c720-r342378> Reply-To: Matthias Apitz Mail-Followup-To: Hans Petter Selasky , freebsd-usb@freebsd.org References: <3ac801b2-899a-ee09-1398-ecab6ec7130a@selasky.org> <20190102104853.GA2622@c720-r342378> <4bf80067-8e3a-572f-c1b5-ae83b1c40c22@selasky.org> <20190102154701.GA13702@c720-r342378> <2f013cf9-b073-04fd-9932-079f86fa24b1@selasky.org> <20190103060431.GA2711@c720-r342378> <5950d771-ffa9-9325-b102-295fd092052e@selasky.org> <20190103094850.GA2595@c720-r342378> <076e01a2-51e7-b140-28c9-1c58d034327b@selasky.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pWyiEgJYm5f9v55/" Content-Disposition: inline In-Reply-To: <076e01a2-51e7-b140-28c9-1c58d034327b@selasky.org> X-Operating-System: FreeBSD 13.0-CURRENT r342378 (amd64) X-message-flag: Mails containing HTML will not be read! Please send only plain text. User-Agent: Mutt/1.11.1 (2018-12-01) X-Con-Id: 51246 X-Con-U: 0-guru X-Originating-IP: 89.204.135.249 X-Rspamd-Queue-Id: 1927A70E6E X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.97 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[guru@unixarea.de]; HAS_XOIP(0.00)[]; TO_DN_SOME(0.00)[]; IP_SCORE(-3.28)[ip: (-8.93), ipnet: 178.254.0.0/19(-4.15), asn: 42730(-3.32), country: DE(-0.01)]; HAS_XAW(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; MX_GOOD(-0.01)[cached: mail.unixarea.de]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.88)[-0.877,0]; SIGNED_PGP(-2.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[101.4.254.178.list.dnswl.org : 127.0.5.1]; RECEIVED_SPAMHAUS_PBL(0.00)[249.135.204.89.zen.spamhaus.org : 127.0.0.11]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:42730, ipnet:178.254.0.0/19, country:DE]; MIME_TRACE(0.00)[0:+,1:+]; FROM_EQ_ENVFROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; DMARC_NA(0.00)[unixarea.de]; AUTH_NA(1.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; R_SPF_NA(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_LAST(0.00)[] X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jan 2019 11:35:18 -0000 --pWyiEgJYm5f9v55/ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable El d=C3=ADa jueves, enero 03, 2019 a las 11:03:26a. m. +0100, Hans Petter S= elasky escribi=C3=B3: > On 1/3/19 10:48 AM, Matthias Apitz wrote: > > Is there a way log log any init call to libusb.so to see which process > > is doing something with libusb.so after devd(8) started pcscd? >=20 > Hi, >=20 > You can add a print in the kernel sys/dev/usb/usb_generic.c in the functi= on: >=20 > static int > ugen_open(struct usb_fifo *f, int fflags) >=20 >=20 > printf("USB opened by PID %d %s\n", curthread->td_proc->p_pid,=20 > curthread->td_proc->p_comm); Hi, I've added the code and rebooted the new kernel. The only PID requesting the ugen_open() is PID 544 pcscd, which is=20 $ dmesg | grep PID =2E.. USB opened by PID 544 pcscd USB opened by PID 544 pcscd USB opened by PID 544 pcscd USB opened by PID 544 pcscd USB opened by PID 544 pcscd USB opened by PID 544 pcscd $ ps ax | grep 544 544 v0- S 0:00,51 /usr/local/sbin/pcscd --debug --foreground but is doing so 3000++ times: $ dmesg | grep 'PID 544' | wc -l 3441 This proc is started by devd(8) with that devd(8) hook: notify 1000 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "ATTACH"; # uTrust match "vendor" "0x04e6"; match "product" "0x5816"; action "logger CCID uTrust, type: $type, system: $system, subsystem: $subs= ystem";=20 action "logger /usr/local/sbin/pcscd --debug --foreground "; action "nohup /usr/local/sbin/pcscd --debug --foreground &"; }; # notify 1000 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "ATTACH"; # HID Omnikey match "vendor" "0x076b"; match "product" "0x6632"; action "logger CCID HID Omnikey, type: $type, system: $system, subsystem: = $subsystem";=20 action "logger /usr/local/sbin/pcscd --debug --foreground "; action "nohup /usr/local/sbin/pcscd --debug --foreground & "; }; # notify 1000 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "DETACH"; # uTrust match "vendor" "0x04e6"; match "product" "0x5816"; action "logger CCID uTrust, type: $type, system: $system, subsystem: $subs= ystem";=20 action "logger killall pcscd"; action "killall pcscd"; }; # notify 1000 { match "system" "USB"; match "subsystem" "INTERFACE"; match "type" "DETACH"; # HID Omnikey match "vendor" "0x076b"; match "product" "0x6632"; action "logger CCID HID Omnikey, type: $type, system: $system, subsystem: = $subsystem";=20 action "logger killall pcscd"; action "killall pcscd"; }; --=20 Matthias Apitz, =E2=9C=89 guru@unixarea.de, http://www.unixarea.de/ +49-176= -38902045 Public GnuPG key: http://www.unixarea.de/key.pub October, 7 -- The GDR was different: Peace instead of Bundeswehr and wars, = Druschba instead of Nazis, to live instead of to survive. --pWyiEgJYm5f9v55/ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEXmn7rBYYViyzy/vBR8z35Hb+nREFAlwt820ACgkQR8z35Hb+ nRGQixAAiQlROK9aTQy1MR8nml2qGHQ1uuCpfhUSLH/7kRKP9I5WgM8goQRYZdB0 sfLs80NJ9g02xeUvzUWTBNOfTjldunv17B24EKWdFVsxC6LWN940+G8HfR4O46MM uH+J93UtL6UnOpXFrlIkTRp1oNIZNMkd4rmPVZtnDdkhF/eMP0ZWtRrIE2U9TLoZ SO5sBjaKzlwRPGeZPOa52gECX+CqC2sfaj858koHcma4G95NnnpE4Eo704lg3Ys3 NAQvhWHclZxDHVMzJFXMUY38YAl1l5OW0L8wIuAmPx7zc4MGBBAXbgn6MJDC1E44 B3oL6PP+6t2wRPzji22tjzRWBcbLATbbhSJi0CKD2uTSl/j/uKDl7++jz4fdsmuH 7ZDKhppBRTdegX7JHd6ZUWKxxhu/8ODnR4ZC88WcCGb6f3zLgvqOpUUx5g2UMXT3 aavCfoGC0J1REziZKzsjmhqR5SjnUQrBQsuRHM6v8pFZF6sCoSxVlX0AYmuvAx8l I1vDUjRx7HF0RyV3XoIN6UkS9qDUYY8RTSGW1iFIpGSD0WH8ngws1coGB0LlDI2K 2SlwRL+lvPFVQNF+5O3Px/CRaSctVZ9/uTgjb8TJeGQnwuEa81Da6c4LLvxRZVVe WZ0j7unUYIolCPsf5j9UOBugVRVFQfvZktZJ8Znp8TtrOOE9wSo= =7EHq -----END PGP SIGNATURE----- --pWyiEgJYm5f9v55/--