1

coresight: Fixes for v6.6

Couple of fixes for the CoreSight self-hosted tracing
 targeting v6.6. Includes :
 
  - Fix runtime warnings while reusing the TMC-ETR buffer
  - Fix (disable) warning when a large buffer is allocated in
    the flat mode.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEuFy0byloRoXZHaWBxcXRZPKyBqEFAmUKwnoACgkQxcXRZPKy
 BqEHYA/9GEg3unx/X+3tJzOFx/OXT9wZYXVoTNK8shjvi7kprjGncPbE+xn5irTO
 CSwQgLPeV3bVxk/mBJPFrWt9PNS6OSNZ+tSD3YF3eQo0IfXa/MuPgOY5EzOUWl/9
 GX7K/9A97gzdseoderowjlyQ+IS/JDYSctI6xSKH2ojrC2gM5uqKq++LTAHbKade
 ClGyj1n/VEAPIxTqib/dJoMiQwg8KENMhlkjG516Hct3HIPSZYg7kL6m4vwWW7tR
 hOT5bBHZUpGqn0uCQiV6TqhKXgyU3WrozLMJMKr6/WgpDXJV6K94CSlFKNV0fg4n
 34ZHOmhYVnvwdXomF0W1d3ZOk9vaFWeYqKD736dMrWQFonhQCPPNBtJXwKv3n0gD
 7KSNM6VjXZSZadWL9lmYAwNNdZDkRFjHxR3Gn9IgttHgHPvlmLcPa8QGWrKEZLTx
 Lkb7EKSxXX3+7NqMEkkYF6auoMA6oFtEndo1bUE6UVtWbEBkTiCM/pEvFqhB0Vke
 Vo5oOiZpAN3iJnsmXetJYZPn1OJTD31R0KGYWI3G8jhBDmVn9sXAYP642Vb7NtWb
 po9Jt6MLaLOE4MURkkeL2qvC080Kss4Obn+QAFZNANbTS8yvlnekObFJBF/tgx7o
 k3RnbKc8g8RNPRsWQY6BgPf2PHQ7U+R/hRatfx6enkqWcxf2pfA=
 =mLe+
 -----END PGP SIGNATURE-----

Merge tag 'coresight-fixes-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux into char-misc-linus

Suzuki writes:

coresight: Fixes for v6.6

Couple of fixes for the CoreSight self-hosted tracing
targeting v6.6. Includes :

 - Fix runtime warnings while reusing the TMC-ETR buffer
 - Fix (disable) warning when a large buffer is allocated in
   the flat mode.

* tag 'coresight-fixes-v6.6-1' of git://git.kernel.org/pub/scm/linux/kernel/git/coresight/linux:
  coresight: tmc-etr: Disable warnings for allocation failures
  coresight: Fix run time warnings while reusing ETR buffer
This commit is contained in:
Greg Kroah-Hartman 2023-10-02 13:14:57 +02:00
commit fc5bf78b1a

View File

@ -610,7 +610,8 @@ static int tmc_etr_alloc_flat_buf(struct tmc_drvdata *drvdata,
flat_buf->vaddr = dma_alloc_noncoherent(real_dev, etr_buf->size, flat_buf->vaddr = dma_alloc_noncoherent(real_dev, etr_buf->size,
&flat_buf->daddr, &flat_buf->daddr,
DMA_FROM_DEVICE, GFP_KERNEL); DMA_FROM_DEVICE,
GFP_KERNEL | __GFP_NOWARN);
if (!flat_buf->vaddr) { if (!flat_buf->vaddr) {
kfree(flat_buf); kfree(flat_buf);
return -ENOMEM; return -ENOMEM;
@ -1173,16 +1174,6 @@ static struct etr_buf *tmc_etr_get_sysfs_buffer(struct coresight_device *csdev)
goto out; goto out;
} }
/*
* In sysFS mode we can have multiple writers per sink. Since this
* sink is already enabled no memory is needed and the HW need not be
* touched, even if the buffer size has changed.
*/
if (drvdata->mode == CS_MODE_SYSFS) {
atomic_inc(&csdev->refcnt);
goto out;
}
/* /*
* If we don't have a buffer or it doesn't match the requested size, * If we don't have a buffer or it doesn't match the requested size,
* use the buffer allocated above. Otherwise reuse the existing buffer. * use the buffer allocated above. Otherwise reuse the existing buffer.
@ -1204,7 +1195,7 @@ out:
static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev) static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
{ {
int ret; int ret = 0;
unsigned long flags; unsigned long flags;
struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent); struct tmc_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
struct etr_buf *sysfs_buf = tmc_etr_get_sysfs_buffer(csdev); struct etr_buf *sysfs_buf = tmc_etr_get_sysfs_buffer(csdev);
@ -1213,12 +1204,24 @@ static int tmc_enable_etr_sink_sysfs(struct coresight_device *csdev)
return PTR_ERR(sysfs_buf); return PTR_ERR(sysfs_buf);
spin_lock_irqsave(&drvdata->spinlock, flags); spin_lock_irqsave(&drvdata->spinlock, flags);
/*
* In sysFS mode we can have multiple writers per sink. Since this
* sink is already enabled no memory is needed and the HW need not be
* touched, even if the buffer size has changed.
*/
if (drvdata->mode == CS_MODE_SYSFS) {
atomic_inc(&csdev->refcnt);
goto out;
}
ret = tmc_etr_enable_hw(drvdata, sysfs_buf); ret = tmc_etr_enable_hw(drvdata, sysfs_buf);
if (!ret) { if (!ret) {
drvdata->mode = CS_MODE_SYSFS; drvdata->mode = CS_MODE_SYSFS;
atomic_inc(&csdev->refcnt); atomic_inc(&csdev->refcnt);
} }
out:
spin_unlock_irqrestore(&drvdata->spinlock, flags); spin_unlock_irqrestore(&drvdata->spinlock, flags);
if (!ret) if (!ret)