From owner-freebsd-hackers@freebsd.org Mon Nov 4 15:32:41 2019 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 D22731A632E for ; Mon, 4 Nov 2019 15:32:41 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) 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 476GyJ3gRKz3N5c for ; Mon, 4 Nov 2019 15:32:39 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x831.google.com with SMTP id o3so24498946qtj.8 for ; Mon, 04 Nov 2019 07:32:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=nNsTKMsnQCBkL7iesQggYuFIysAnCvgb1Pv8zcFIDb4=; b=LInoyZozFCEM6Sagt5+m9jCKuisPVha6VrYriSKywdOB/eqMJXDENZ1abgvfkMr8OV 4mTz69z8IKk0o7gaOlzGmuJJkTsPlNOXkJkmnpg8w8DSINZJxctn+83b7F/faTxMiW1Y BI1f5ORUoqWlPoXrlxASnRvD62CI+XqLdp46URke4WIJMC+d3GcVc2L+fLai6wg4fJaz 8SDLytCfOs2K96uJQk3Xk4Hux/Uev0JpvqJf/R5vpQs62cKLufGdo6ZX825Un4EyzefZ d+se8Zw0JNOhebrMbH0n74mPac67QMyeN9e+o5peUvUVYE8YEAN4CncJIbNt2F64KY11 bksw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=nNsTKMsnQCBkL7iesQggYuFIysAnCvgb1Pv8zcFIDb4=; b=DwkpsfUq6bodAY8I8ZCEJ2A5MQbzpUcGy+b3Og/n/G9q5wbG+8H4LNWqv+fmXiFhxm TUPX7Nyqn7dNP/xIZCmAND9F/hdGJgczGnr4YS/EyMW455FJhfUsXf8/KflH3qvkJcqh /UKFEUXfN1Zqs8LQzkLlHI8eBFFxX6OoIrZujssMjFrdOjvezG2yInPdBH3r36GJKUUH ffgkjBakzu7BBKJ53IRaDYjYYQjbCTJEMaSu8I+RoRhBgCkeWhqI9/VCpJgF1PzxdxKc f3eYNJYtvNKzF55+RfKDsUg17bZtfjK2l+vHFbsm6iECnLFXD0AtawL1A4k8Q4QA7cQ1 uIsw== X-Gm-Message-State: APjAAAXCH4iVu1wz7B0VEYRTWAOfqIJ59eumzdabFx8Lf17D/oFNfh4x nbPFWXBCLSdVSYrOXnJ0DLt0xx8ejT2Mzo2xbeUlPfQkH/E= X-Google-Smtp-Source: APXvYqxFL4StR07iwGdHQeS9pBcE9m9rgL5sLKFpuCslWCiD87UjZb0ZZevo6JMCfh58aoPnOrRbGBZWLLQm39NUMJ8= X-Received: by 2002:ac8:6697:: with SMTP id d23mr5412713qtp.32.1572881558767; Mon, 04 Nov 2019 07:32:38 -0800 (PST) MIME-Version: 1.0 References: <20191027214209.712d62ca@zeta.dino.sk> <20191027232956.28b11772@zeta.dino.sk> <20191028191005.GA89835@bluezbox.com> <20191028201952.20a92307@zeta.dino.sk> <20191102214100.500ba493@zeta.dino.sk> <20191103042321.GA49790@bluezbox.com> <20191103130118.36fa6eec@zeta.dino.sk> <20191104122816.63647120@zeta.dino.sk> In-Reply-To: <20191104122816.63647120@zeta.dino.sk> From: Warner Losh Date: Mon, 4 Nov 2019 08:32:27 -0700 Message-ID: Subject: Re: UART driver as kld - how? To: Milan Obuch Cc: "freebsd-hackers@freebsd.org" , Oleksandr Tymoshenko , Oliver Pinter X-Rspamd-Queue-Id: 476GyJ3gRKz3N5c X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=LInoyZoz; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::831) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-3.74 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; IP_SCORE(-2.74)[ip: (-9.27), ipnet: 2607:f8b0::/32(-2.37), asn: 15169(-2.03), country: US(-0.05)]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCVD_IN_DNSWL_NONE(0.00)[1.3.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Nov 2019 15:32:41 -0000 On Mon, Nov 4, 2019 at 4:35 AM Milan Obuch wrote: > On Sun, 3 Nov 2019 13:01:18 +0100 > Milan Obuch wrote: > > > On Sat, 2 Nov 2019 21:23:21 -0700 > > Oleksandr Tymoshenko wrote: > > > > > Milan Obuch (freebsd-hackers@dino.sk) wrote: > > [ snip ] > > > > > I am sure I need docs/description for other functions as well, so > > > > if anybody knows where good uart framework description could be > > > > found, please advice. Or if somebody already has good > > > > understanding of it and could help me with my issues, it wil be > > > > greatly appreciated. > > > > > > if you follow uart_dev_snsps.c template, the sc_class is set in > > > probe function: > > [ snip ] > > > I totally overlooked the obvious... yes, you are right. > > > > [ snip ] > > > > > In your case, my guess would be: you either do not set the sc_class > > > member var in probe function or your base var is not the first in > > > the struct. > > > > > > > Back to testing... probe function now does work, so I am going to > > analyze what should be done in attach... and why I am getting now > > panic... I'll write again when I find another obstacle I do not > > understand or I have working driver, whatever comes first :) > > > > Now I am getting further... attach works now, device nodes expected are > being created, but there are some warnings mentioning locks on detach. > Also, my hardware design currently does not use interrupts. Do we have > any example of uart device being polled? > All UARTS have interrupts. It's the nature of UARTS. At least that's the nature of the model that uart(4) uses: there's a number of conditions that we notice from time to time and make a note in the ipend mask so that we can call uart specific code later to deal with that condition. Your system may not connect those uart signals to a system interrupt, but the internal model is the same. I'd just use callouts to poll. Then call what would be the interrupt routines from there. Since we have a separation between noting a condition and processing it, that should work well. However, I'd also expect issues at higher data rates unless you have very deep FIFOs and some kind of hardware-assist for flow control. Warner