From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 595BFC433DF for ; Wed, 14 Oct 2020 16:16:00 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CDF51214D8 for ; Wed, 14 Oct 2020 16:15:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="a9IbYsw8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDF51214D8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=h0Z8REvhoj9RHSxvFp81eyvUn8RWqIoZPSzsM1Pihss=; b=a9IbYsw83tiYbL9GOCFroQIZq 0FzgzW12zD6xvv+dpodtloCeOvxteDypI+dQFymfBEpBDfQYhAjp0Z8BnI3DFVteipCG26zU4wcC0 U6WbJNyIMcc6wU5xQyCBXMdrcXjYrXHXMSQC5Rh9GJrmM2fHg7fBcAWhRg9TDXaS99WDAPQwrcclj Oc76oINQkVsI1h4Bhb4iBiYtybnGBjlObmBZAwKRFSJ8KLvWPeT00TitxiZ21FcIyh0NGGhMX8Hqk EuhAUNEYyCVDTy8VdyQhAvHcUGQkfcKTHImF1471RcTcWjRvP5gt5LRjEwzV0ZVCXKHuzW8WbpzdE xiBso9O7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSjQC-0005fW-Kl; Wed, 14 Oct 2020 16:14:36 +0000 Received: from netrider.rowland.org ([192.131.102.5]) by merlin.infradead.org with smtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSjQA-0005eu-BE for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2020 16:14:35 +0000 Received: (qmail 718746 invoked by uid 1000); 14 Oct 2020 12:14:33 -0400 Date: Wed, 14 Oct 2020 12:14:33 -0400 From: Alan Stern To: Thomas Gleixner Subject: Re: [patch 03/12] USB: serial: keyspan_pda: Consolidate room query Message-ID: <20201014161433.GB712494@rowland.harvard.edu> References: <20201014145215.518912759@linutronix.de> <20201014145727.338773481@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201014145727.338773481@linutronix.de> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201014_121434_431978_A9D9B82F X-CRM114-Status: GOOD ( 24.66 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Felipe Balbi , Thomas Winischhofer , Mathias Nyman , Peter Zijlstra , Greg Kroah-Hartman , Sebastian Andrzej Siewior , linux-usb@vger.kernel.org, LKML , Krzysztof Kozlowski , Johan Hovold , linux-samsung-soc@vger.kernel.org, Kukjin Kim , Valentina Manea , Duncan Sands , "Ahmed S. Darwish" , linux-omap@vger.kernel.org, Shuah Khan , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 14, 2020 at 04:52:18PM +0200, Thomas Gleixner wrote: > From: Sebastian Andrzej Siewior > > Having two copies of the same code doesn't make the code more readable and > allocating a buffer of 1 byte for a synchronous operation is a pointless > exercise. Not so. In fact, it is required, because a portion of a structure cannot be mapped for DMA unless it is aligned at a cache line boundary. > Add a byte buffer to struct keyspan_pda_private which can be used > instead. The buffer is only used in open() and tty->write(). This won't work. > Console writes > are not calling into the query. open() obviously happens before write() and > the writes are serialized by bit 0 of port->write_urbs_free which protects > also the transaction itself. > > Move the actual query into a helper function and cleanup the usage sites in > keyspan_pda_write() and keyspan_pda_open(). > > Signed-off-by: Sebastian Andrzej Siewior > Signed-off-by: Thomas Gleixner > Cc: Johan Hovold > Cc: Greg Kroah-Hartman > Cc: linux-usb@vger.kernel.org > --- > drivers/usb/serial/keyspan_pda.c | 102 ++++++++++++++++----------------------- > 1 file changed, 43 insertions(+), 59 deletions(-) > > --- a/drivers/usb/serial/keyspan_pda.c > +++ b/drivers/usb/serial/keyspan_pda.c > @@ -47,6 +47,7 @@ struct keyspan_pda_private { > struct work_struct unthrottle_work; > struct usb_serial *serial; > struct usb_serial_port *port; > + u8 query_buf; > }; > > > @@ -436,6 +437,31 @@ static int keyspan_pda_tiocmset(struct t > return rc; > } > > +/* > + * Using priv->query_buf is safe here because this is only called for TTY > + * operations open() and write(). write() comes post open() obviously and > + * write() itself is serialized via bit 0 of port->write_urbs_free. Console > + * writes are never calling into this. > + */ > +static int keyspan_pda_query_room(struct usb_serial *serial, > + struct keyspan_pda_private *priv) > +{ > + int res; > + > + res = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), > + 6, /* write_room */ > + USB_TYPE_VENDOR | USB_RECIP_INTERFACE | USB_DIR_IN, > + 0, /* value */ > + 0, /* index */ > + &priv->query_buf, > + 1, > + 2000); Instead, consider using the new usb_control_msg_recv() API. But it might be better to allocate the buffer once and for all. Alan Stern _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel