lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2f51079c-061a-2a04-2569-3ece3cd9beca@linux.intel.com>
Date: Thu, 18 Apr 2024 20:25:41 +0300 (EEST)
From: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
To: Parker Newman <parker@...est.io>
cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>, 
    Jiri Slaby <jirislaby@...nel.org>, LKML <linux-kernel@...r.kernel.org>, 
    linux-serial <linux-serial@...r.kernel.org>, 
    Parker Newman <pnewman@...necttech.com>
Subject: Re: [PATCH v4 6/7] serial: exar: add CTI specific setup code

On Thu, 18 Apr 2024, Parker Newman wrote:

> On Thu, 18 Apr 2024 19:29:44 +0300 (EEST)
> Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com> wrote:
> 
> > On Thu, 18 Apr 2024, Parker Newman wrote:
> > > On Thu, 18 Apr 2024 16:20:15 +0300 (EEST)
> > > Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com> wrote:
> > >   
> > > > On Wed, 17 Apr 2024, Parker Newman wrote:  
> > > > > From: Parker Newman <pnewman@...necttech.com>
> > > > > 
> > > > > This is a large patch but is only additions. All changes and removals
> > > > > are made in previous patches in this series.
> > > > > 
> > > > > - Add CTI board_init and port setup functions for each UART type
> > > > > - Add CTI_EXAR_DEVICE() and CTI_PCI_DEVICE() macros
> > > > > - Add support for reading a word from the Exar EEPROM.
> > > > > - Add support for configuring and setting a single MPIO
> > > > > - Add various helper functions for CTI boards.
> > > > > - Add osc_freq to struct exar8250
> > > > > 
> > > > > Signed-off-by: Parker Newman <pnewman@...necttech.com>  
> > 
> > > > > @@ -192,11 +252,201 @@ struct exar8250_board {
> > > > > 
> > > > >  struct exar8250 {
> > > > >  	unsigned int		nr;
> > > > > +	unsigned int		osc_freq;
> > > > >  	struct exar8250_board	*board;
> > > > >  	void __iomem		*virt;
> > > > >  	int			line[];
> > > > >  };
> > > > > 
> > > > > +static inline void exar_write_reg(struct exar8250 *priv,
> > > > > +				unsigned int reg, u8 value)
> > > > > +{
> > > > > +	writeb(value, priv->virt + reg);
> > > > > +}
> > > > > +
> > > > > +static inline u8 exar_read_reg(struct exar8250 *priv, unsigned int reg)
> > > > > +{
> > > > > +	return readb(priv->virt + reg);
> > > > > +}    
> > > > 
> > > > I tried to understand what is going on with this priv->virt in 8250_exar 
> > > > in general and why it exists but I failed. It seems to BAR0 is mapped 
> > > > there but also serial8250_pci_setup_port() does map the same BAR and 
> > > > sets it up into the usual place in membase.
> > > >   
> > > 
> > > Exar PCI/PCIe UARTs have global configuration registers from 0x80-0x9B.
> > > These registers are for reading the EEPROM, configuring the MPIO, etc.
> > > As these registers are only at 0x80, and not port specific, the driver maps
> > > BAR0 to priv->virt for accessing them.   
> > 
> > Okay, thanks for explaining. The naming & lack of comments wasn't exactly 
> > making it easy to follow this bit (this is not your fault in anyway but 
> > a pre-existing problem in the driver's code).
> > 
> > I've a follow up question now that it's confirmed they're different, 
> > see below...
> > 
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_8XMODE), 0x00);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_FCTR), UART_FCTR_EXAR_TRGD);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_TXTRG), 128);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_RXTRG), 128);    
> > > > 
> > > > Unnecessary parenthesis.  
> > 
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_8XMODE), 0x00);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_FCTR), UART_FCTR_EXAR_TRGD);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_TXTRG), 32);
> > > > > +	exar_write_reg(priv, (offset + UART_EXAR_RXTRG), 32);    
> > > > 
> > > > Unnecessary parenthesis.
> > > >   
> > > 
> > > I will fix these in my cleanup patches.   
> > 
> > Based on the wording in your response, I'm not sure you got this right. It 
> > is code you're adding in this patch so the parenthesis should be removed 
> > from this change so they never appear in the commit history.
> > 
> 
> Greg has already merged this series into his testing branch. I assumed any
> changes would need to be made in a separate patch series? Sorry if I 
> misunderstood. I already sent these fixes in a new mini-series. 

Okay. I was only aware he took the first patch but seemingly he took all 
of them. So you're correct then, ignore my advice which was based on 
incomplete picture.

> > > > I recommend you add a helper for this as it is repeated twice. Are the 
> > > > values 32 and 128 literal or do they have some specific meaning? If the 
> > > > latter case, they should be using named defines (this likely applies to 
> > > > the existing trigger code in the driver too).
> > > > 
> > > >   
> > > 
> > > They are the FIFO trigger levels so they are literally 128 and 32.   
> > 
> > Okay, no problem then if its 128 characters and 32 characters.
> > 
> > > These 4 writes come from Exar's out-of-tree driver and are in 
> > > pci_xr17v35x_setup() and some other vendor specific functions. 
> > > 
> > > I am not sure why/if these are needed.   
> > 
> > ...So the follow-up question. I see the existing code in 
> > pci_fastcom335_setup() and pci_xr17v35x_setup() writes into membase 
> > based address but your code uses exar_write_reg() which is priv->virt 
> > based. Is this difference intentional?
> > 
> 
> Both methods are effectively the same thing. I used exar_write_reg() to be
> consistent with my other code and it is a bit cleaner than:

Those people used to serial subsystem, using membase is way more familiar 
than using some driver private thing.

> 	u8 __iomem *p;
> 
> 	p = port->port.membase;
> 
> 	writeb(0x00, p + UART_EXAR_8XMODE);

It's inconsistent with the other two uses now but since you told they're 
effectively the same thing, I was hoping all of 4 places in 8250_exar 
would be converted to use a helper that is just given the threshold as 
parameter (the helper doesn't exist yet).

-- 
 i.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ