Mipmap generation fails second time

I have the following situation: I have a material with a texture which I load from file.In some cases I just load the image, create OpenGL texture and generate mipmaps.Then just render it.Works fine when minimized.In other cases,I do some processing on that texture after the initial mipmaps generation.And because I do the processing only on the level zero I regenerate the mipmaps before returning to the renderer.The issue is that after second generation of mipmaps they don’t exist.The texture looks as if it has GL_NEAREST mag and min.I can’t understand why it doesn’t work second time.Here is my code to generate mipmaps:

glBindTexture(GL_TEXTURE_2D,_id);
glTexParameteri ( _target, GL_TEXTURE_BASE_LEVEL, 0 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,0);

My hardware is NVidia QUADRO K4000 ,OpenGL 4.2
One more thing.In OpenGL debug output I am getting the following warning:

State usage warning: Texture 2 is base level inconsistent.Check texture size.Severity:low ,ID131204

How are you updating the texture data?

Texture data should be “allocated” with glTexImage2D() at least one time (with right parameters) and already updated (using sync or async methods) on GPU before call glGenerateMipmap().

So (sync upload method):


glGenTextures(1, _id);
glBindTexture(GL_TEXTURE_2D,_id);   
glTexParameteri  (GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0 );
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);  
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);                       
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_BGRA, DEFAULT_RGBA_INTERNAL_FORMAT, pixelsData);
glGenerateMipmap(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,0);