Re: [PATCH v5] i2c: qcom-geni: Add support for GPI DMA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 17-02-22, 09:35, Bjorn Andersson wrote:

> > +static void i2c_gpi_cb_result(void *cb, const struct dmaengine_result *result)
> > +{
> > +	struct geni_i2c_dev *gi2c = cb;
> > +
> > +	if (result->result != DMA_TRANS_NOERROR) {
> > +		dev_err(gi2c->se.dev, "DMA txn failed:%d\n", result->result);
> 
> Iiuc the API the expectation is that if we get !NOERROR we shouldn't
> expect to get NOERROR after that.
>
> If so we're just returning here and leaving geni_i2c_gpi_xfer() to just
> timeout in a HZ or so. Given that xfer happens under the adaptor lock,
> how about carrying an error in geni_i2c_dev and complete(&done) here as
> well?

Yes we should call complete for errors too, will add that

> > +static int setup_gpi_dma(struct geni_i2c_dev *gi2c)
> > +{
> > +	int ret;
> > +
> > +	geni_se_select_mode(&gi2c->se, GENI_GPI_DMA);
> > +	gi2c->tx_c = dma_request_chan(gi2c->se.dev, "tx");
> > +	if (IS_ERR(gi2c->tx_c)) {
> > +		ret = dev_err_probe(gi2c->se.dev, PTR_ERR(gi2c->tx_c),
> > +				    "Failed to get tx DMA ch\n");
> > +		if (ret < 0)
> > +			goto err_tx;
> > +	}
> > +
> > +	gi2c->rx_c = dma_request_chan(gi2c->se.dev, "rx");
> > +	if (IS_ERR(gi2c->rx_c)) {
> > +		ret = dev_err_probe(gi2c->se.dev, PTR_ERR(gi2c->rx_c),
> > +				    "Failed to get rx DMA ch\n");
> > +		if (ret < 0)
> > +			goto err_rx;
> > +	}
> > +
> > +	dev_dbg(gi2c->se.dev, "Grabbed GPI dma channels\n");
> > +	return 0;
> > +
> > +err_rx:
> > +	dma_release_channel(gi2c->tx_c);
> > +	gi2c->tx_c = NULL;
> 
> You're not accessing tx_c or rx_c again when returning an error here. So
> I don't think there's a reason to clear them.

Will drop that

> >  static int geni_i2c_remove(struct platform_device *pdev)
> >  {
> >  	struct geni_i2c_dev *gi2c = platform_get_drvdata(pdev);
> >  
> > +	release_gpi_dma(gi2c);
> 
> Your i2c devices aren't torn down until i2c_del_adapter(), so you might
> still end up trying to use the two channels here, after releasing them.
> 
> In other words, I think you should reorder these.

Agreed it should be other way round!

Thanks
-- 
~Vinod



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux